[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 5/6] nmi: Implement inject_nmi() for non-monitor con
From: |
Christian Borntraeger |
Subject: |
[Qemu-devel] [PATCH 5/6] nmi: Implement inject_nmi() for non-monitor context use |
Date: |
Thu, 11 Jun 2015 17:53:32 +0200 |
From: Xu Wang <address@hidden>
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 <address@hidden>
Reviewed-by: David Hildenbrand <address@hidden>
CC: Alexey Kardashevskiy <address@hidden>
Signed-off-by: Christian Borntraeger <address@hidden>
---
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.0
- [Qemu-devel] [PATCH 0/6] s390x/watchdog: add diag288 based watchdog, Christian Borntraeger, 2015/06/11
- [Qemu-devel] [PATCH 5/6] nmi: Implement inject_nmi() for non-monitor context use,
Christian Borntraeger <=
- [Qemu-devel] [PATCH 2/6] s390x/watchdog: introduce diag288 watchdog device, Christian Borntraeger, 2015/06/11
- [Qemu-devel] [PATCH 3/6] s390x/kvm: diag288 instruction interception and handling, Christian Borntraeger, 2015/06/11
- [Qemu-devel] [PATCH 1/6] watchdog: change option wording to allow for more watchdogs, Christian Borntraeger, 2015/06/11
- [Qemu-devel] [PATCH 6/6] watchdog: Add new Virtual Watchdog action INJECT-NMI, Christian Borntraeger, 2015/06/11
- [Qemu-devel] [PATCH 4/6] s390x/watchdog: diag288 migration support, Christian Borntraeger, 2015/06/11