summaryrefslogtreecommitdiffstats
path: root/hw/core
diff options
context:
space:
mode:
authorXu Wang2015-02-05 11:28:35 +0100
committerChristian Borntraeger2015-06-11 17:45:50 +0200
commitf9a535e089abcbc7ac99db83c8c6e4644e395b12 (patch)
treec1f4d6ede264a3fffa4dbff4d13c98364b08de2f /hw/core
parents390x/watchdog: diag288 migration support (diff)
downloadqemu-f9a535e089abcbc7ac99db83c8c6e4644e395b12.tar.gz
qemu-f9a535e089abcbc7ac99db83c8c6e4644e395b12.tar.xz
qemu-f9a535e089abcbc7ac99db83c8c6e4644e395b12.zip
nmi: Implement inject_nmi() for non-monitor context use
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 <gesaint@linux.vnet.ibm.com> Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com> CC: Alexey Kardashevskiy <aik@ozlabs.ru> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Diffstat (limited to 'hw/core')
-rw-r--r--hw/core/nmi.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/hw/core/nmi.c b/hw/core/nmi.c
index 3dff020659..5260d6c1ec 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,