From patchwork Fri Dec 10 07:42:53 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lai Jiangshan X-Patchwork-Id: 397682 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oBA7dihU026444 for ; Fri, 10 Dec 2010 07:39:45 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753250Ab0LJHjl (ORCPT ); Fri, 10 Dec 2010 02:39:41 -0500 Received: from cn.fujitsu.com ([222.73.24.84]:63048 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1753184Ab0LJHjk (ORCPT ); Fri, 10 Dec 2010 02:39:40 -0500 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id 0DB0D17048C; Fri, 10 Dec 2010 15:39:39 +0800 (CST) Received: from mailserver.fnst.cn.fujitus.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id oBA7YsJj010992; Fri, 10 Dec 2010 15:34:54 +0800 Received: from [10.167.225.68] ([10.167.225.68]) by mailserver.fnst.cn.fujitus.com (Lotus Domino Release 8.5.1FP4) with ESMTP id 2010121015394170-205336 ; Fri, 10 Dec 2010 15:39:41 +0800 Message-ID: <4D01D9FD.8020801@cn.fujitsu.com> Date: Fri, 10 Dec 2010 15:42:53 +0800 From: Lai Jiangshan User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.9) Gecko/20100423 Thunderbird/3.0.4 MIME-Version: 1.0 To: Jan Kiszka CC: Avi Kivity , "qemu-devel@nongnu.org" , "kvm@vger.kernel.org" Subject: [PATCH V2] qemu, kvm: Enable user space NMI injection for kvm guest References: <4D007E2C.4070308@cn.fujitsu.com> <4D00845F.9000503@siemens.com> In-Reply-To: <4D00845F.9000503@siemens.com> X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2010-12-10 15:39:41, Serialize by Router on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2010-12-10 15:39:42, Serialize complete at 2010-12-10 15:39:42 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Fri, 10 Dec 2010 07:39:45 +0000 (UTC) diff --git a/configure b/configure index 2917874..f6f9362 100755 --- a/configure +++ b/configure @@ -1646,6 +1646,9 @@ if test "$kvm" != "no" ; then #if !defined(KVM_CAP_DESTROY_MEMORY_REGION_WORKS) #error Missing KVM capability KVM_CAP_DESTROY_MEMORY_REGION_WORKS #endif +#if !defined(KVM_CAP_USER_NMI) +#error Missing KVM capability KVM_CAP_USER_NMI +#endif int main(void) { return 0; } EOF if test "$kerneldir" != "" ; then diff --git a/target-i386/kvm.c b/target-i386/kvm.c index 7dfc357..755f8c9 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -1417,6 +1417,13 @@ int kvm_arch_get_registers(CPUState *env) int kvm_arch_pre_run(CPUState *env, struct kvm_run *run) { + /* Inject NMI */ + if (env->interrupt_request & CPU_INTERRUPT_NMI) { + env->interrupt_request &= ~CPU_INTERRUPT_NMI; + DPRINTF("injected NMI\n"); + kvm_vcpu_ioctl(env, KVM_NMI); + } + /* Try to inject an interrupt if the guest can accept it */ if (run->ready_for_interrupt_injection && (env->interrupt_request & CPU_INTERRUPT_HARD) &&