From patchwork Thu Jan 6 17:56:07 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 77754 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 24818B7145 for ; Fri, 7 Jan 2011 05:09:23 +1100 (EST) Received: from localhost ([127.0.0.1]:55305 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PauH1-0006h8-Pa for incoming@patchwork.ozlabs.org; Thu, 06 Jan 2011 13:09:19 -0500 Received: from [140.186.70.92] (port=32769 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PauBB-0003sj-VM for qemu-devel@nongnu.org; Thu, 06 Jan 2011 13:03:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PauB9-0006Zs-KT for qemu-devel@nongnu.org; Thu, 06 Jan 2011 13:03:17 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51967) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PauB9-0006ZP-Bx for qemu-devel@nongnu.org; Thu, 06 Jan 2011 13:03:15 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p06I3ChY019766 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 6 Jan 2011 13:03:12 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p06I3Bxd019658; Thu, 6 Jan 2011 13:03:11 -0500 Received: from amt.cnet (vpn1-4-164.ams2.redhat.com [10.36.4.164]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id p06I39Gx019101; Thu, 6 Jan 2011 13:03:10 -0500 Received: from amt.cnet (localhost.localdomain [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id C8BCC68A1D3; Thu, 6 Jan 2011 15:57:12 -0200 (BRST) Received: (from marcelo@localhost) by amt.cnet (8.14.4/8.14.4/Submit) id p06Hv8Sh011343; Thu, 6 Jan 2011 15:57:08 -0200 From: Marcelo Tosatti To: Anthony Liguori Date: Thu, 6 Jan 2011 15:56:07 -0200 Message-Id: <63d3a773666472fac5ba1923599fee64e2b8b4fc.1294336601.git.mtosatti@redhat.com> In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Marcelo Tosatti , qemu-devel@nongnu.org, kvm@vger.kernel.org, Lai Jiangshan Subject: [Qemu-devel] [PATCH 01/35] kvm: Enable user space NMI injection for kvm guest X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Lai Jiangshan Make use of the new KVM_NMI IOCTL to send NMIs into the KVM guest if the user space raised them. (example: qemu monitor's "nmi" command) Signed-off-by: Lai Jiangshan Acked-by: Jan Kiszka Signed-off-by: Marcelo Tosatti --- configure | 3 +++ target-i386/kvm.c | 7 +++++++ 2 files changed, 10 insertions(+), 0 deletions(-) diff --git a/configure b/configure index 47e4cf0..ec37a91 100755 --- a/configure +++ b/configure @@ -1674,6 +1674,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) &&