From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57557) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yj155-0005wl-DU for qemu-devel@nongnu.org; Fri, 17 Apr 2015 03:52:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yj152-0006Xf-HB for qemu-devel@nongnu.org; Fri, 17 Apr 2015 03:52:55 -0400 Received: from e06smtp17.uk.ibm.com ([195.75.94.113]:45836) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yj152-0006Wy-8A for qemu-devel@nongnu.org; Fri, 17 Apr 2015 03:52:52 -0400 Received: from /spool/local by e06smtp17.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 17 Apr 2015 08:52:50 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id C065E2190061 for ; Fri, 17 Apr 2015 08:52:32 +0100 (BST) Received: from d06av06.portsmouth.uk.ibm.com (d06av06.portsmouth.uk.ibm.com [9.149.37.217]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t3H7qlO64260280 for ; Fri, 17 Apr 2015 07:52:48 GMT Received: from d06av06.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av06.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t3H2lDMU007617 for ; Thu, 16 Apr 2015 22:47:13 -0400 From: Cornelia Huck Date: Fri, 17 Apr 2015 09:52:40 +0200 Message-Id: <1429257161-29597-6-git-send-email-cornelia.huck@de.ibm.com> In-Reply-To: <1429257161-29597-1-git-send-email-cornelia.huck@de.ibm.com> References: <1429257161-29597-1-git-send-email-cornelia.huck@de.ibm.com> Subject: [Qemu-devel] [PATCH 5/6] nmi: Implement inject_nmi() for non-monitor context use List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: armbru@redhat.com, mdroth@linux.vnet.ibm.com, agraf@suse.de, borntraeger@de.ibm.com, jfrei@linux.vnet.ibm.com, Cornelia Huck , Xu Wang , lcapitulino@redhat.com From: Xu Wang Let's introduce a general "inject_nmi()" function that doesn't rely on the cpu index of the monitor, but uses cpu index 0 as default (except for x86). This function can then later be used from a non-monitor context. Signed-off-by: Xu Wang Reviewed-by: David Hildenbrand Signed-off-by: Cornelia Huck --- hw/core/nmi.c | 20 ++++++++++++++++++++ include/hw/nmi.h | 1 + 2 files changed, 21 insertions(+) diff --git a/hw/core/nmi.c b/hw/core/nmi.c index 3dff020..5260d6c 100644 --- a/hw/core/nmi.c +++ b/hw/core/nmi.c @@ -21,6 +21,7 @@ #include "hw/nmi.h" #include "qapi/qmp/qerror.h" +#include "monitor/monitor.h" struct do_nmi_s { int cpu_index; @@ -70,6 +71,25 @@ void nmi_monitor_handle(int cpu_index, Error **errp) } } +void inject_nmi(void) +{ +#if defined(TARGET_I386) + CPUState *cs; + + CPU_FOREACH(cs) { + X86CPU *cpu = X86_CPU(cs); + + if (!cpu->apic_state) { + cpu_interrupt(cs, CPU_INTERRUPT_NMI); + } else { + apic_deliver_nmi(cpu->apic_state); + } + } +#else + nmi_monitor_handle(0, NULL); +#endif +} + static const TypeInfo nmi_info = { .name = TYPE_NMI, .parent = TYPE_INTERFACE, diff --git a/include/hw/nmi.h b/include/hw/nmi.h index b541772..f4cec62 100644 --- a/include/hw/nmi.h +++ b/include/hw/nmi.h @@ -45,5 +45,6 @@ typedef struct NMIClass { } NMIClass; void nmi_monitor_handle(int cpu_index, Error **errp); +void inject_nmi(void); #endif /* NMI_H */ -- 2.3.5