* [Qemu-devel] [PATCH v2 0/3] Minor nmi cleanups
@ 2016-05-20 16:28 Bandan Das
2016-05-20 16:28 ` [Qemu-devel] [PATCH v2 1/3] target-i386: add a generic x86 nmi handler Bandan Das
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Bandan Das @ 2016-05-20 16:28 UTC (permalink / raw)
To: qemu-devel; +Cc: pbonzini, aik
v2:
2/4: Remove inject_nmi and call nmi_monitor_handle()
directly
3/4: rm -rf
4/4: Call nmi_monitor_handle and pass cpu index
The primary change is a arch specific x86 nmi function
which can be called by the core nmi handler.
Bandan Das (3):
target-i386: add a generic x86 nmi handler
nmi: remove x86 specific nmi handling
cpus: call the core nmi injection function
cpus.c | 14 --------------
hw/core/nmi.c | 24 ------------------------
hw/i386/pc.c | 20 ++++++++++++++++++++
hw/watchdog/watchdog.c | 2 +-
include/hw/nmi.h | 1 -
5 files changed, 21 insertions(+), 40 deletions(-)
--
2.5.5
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH v2 1/3] target-i386: add a generic x86 nmi handler
2016-05-20 16:28 [Qemu-devel] [PATCH v2 0/3] Minor nmi cleanups Bandan Das
@ 2016-05-20 16:28 ` Bandan Das
2016-05-20 16:28 ` [Qemu-devel] [PATCH v2 2/3] nmi: remove x86 specific nmi handling Bandan Das
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Bandan Das @ 2016-05-20 16:28 UTC (permalink / raw)
To: qemu-devel; +Cc: pbonzini, aik
Instead of having x86 ifdefs in core nmi code, this
change adds a arch specific handler that the nmi common
code can call.
Signed-off-by: Bandan Das <bsd@redhat.com>
---
hw/i386/pc.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 99437e0..e29ccc8 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -67,6 +67,7 @@
#include "qapi/visitor.h"
#include "qapi-visit.h"
#include "qom/cpu.h"
+#include "hw/nmi.h"
/* debug PC/ISA interrupts */
//#define DEBUG_IRQ
@@ -1963,11 +1964,28 @@ static CPUArchIdList *pc_possible_cpu_arch_ids(MachineState *machine)
return list;
}
+static void x86_nmi(NMIState *n, int cpu_index, Error **errp)
+{
+ /* cpu index isn't used */
+ 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);
+ }
+ }
+}
+
static void pc_machine_class_init(ObjectClass *oc, void *data)
{
MachineClass *mc = MACHINE_CLASS(oc);
PCMachineClass *pcmc = PC_MACHINE_CLASS(oc);
HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(oc);
+ NMIClass *nc = NMI_CLASS(oc);
pcmc->get_hotplug_handler = mc->get_hotplug_handler;
pcmc->pci_enabled = true;
@@ -1993,6 +2011,7 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)
hc->plug = pc_machine_device_plug_cb;
hc->unplug_request = pc_machine_device_unplug_request_cb;
hc->unplug = pc_machine_device_unplug_cb;
+ nc->nmi_monitor_handler = x86_nmi;
}
static const TypeInfo pc_machine_info = {
@@ -2005,6 +2024,7 @@ static const TypeInfo pc_machine_info = {
.class_init = pc_machine_class_init,
.interfaces = (InterfaceInfo[]) {
{ TYPE_HOTPLUG_HANDLER },
+ { TYPE_NMI },
{ }
},
};
--
2.5.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH v2 2/3] nmi: remove x86 specific nmi handling
2016-05-20 16:28 [Qemu-devel] [PATCH v2 0/3] Minor nmi cleanups Bandan Das
2016-05-20 16:28 ` [Qemu-devel] [PATCH v2 1/3] target-i386: add a generic x86 nmi handler Bandan Das
@ 2016-05-20 16:28 ` Bandan Das
2016-05-20 16:28 ` [Qemu-devel] [PATCH v2 3/3] cpus: call the core nmi injection function Bandan Das
2016-05-23 8:31 ` [Qemu-devel] [PATCH v2 0/3] Minor nmi cleanups Paolo Bonzini
3 siblings, 0 replies; 5+ messages in thread
From: Bandan Das @ 2016-05-20 16:28 UTC (permalink / raw)
To: qemu-devel; +Cc: pbonzini, aik
nmi_monitor_handle is wired to call the x86 nmi
handler. So, we can directly use it at call sites.
Signed-off-by: Bandan Das <bsd@redhat.com>
---
hw/core/nmi.c | 24 ------------------------
hw/watchdog/watchdog.c | 2 +-
include/hw/nmi.h | 1 -
3 files changed, 1 insertion(+), 26 deletions(-)
diff --git a/hw/core/nmi.c b/hw/core/nmi.c
index f616a79..bfd0896 100644
--- a/hw/core/nmi.c
+++ b/hw/core/nmi.c
@@ -20,16 +20,11 @@
*/
#include "qemu/osdep.h"
-#include "qom/cpu.h"
#include "hw/nmi.h"
#include "qapi/error.h"
#include "qapi/qmp/qerror.h"
#include "monitor/monitor.h"
-#if defined(TARGET_I386)
-#include "cpu.h"
-#endif
-
struct do_nmi_s {
int cpu_index;
Error *err;
@@ -78,25 +73,6 @@ 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/hw/watchdog/watchdog.c b/hw/watchdog/watchdog.c
index bbf3646..2aeaf1f 100644
--- a/hw/watchdog/watchdog.c
+++ b/hw/watchdog/watchdog.c
@@ -143,7 +143,7 @@ void watchdog_perform_action(void)
case WDT_NMI:
qapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_INJECT_NMI,
&error_abort);
- inject_nmi();
+ nmi_monitor_handle(0, NULL);
break;
}
}
diff --git a/include/hw/nmi.h b/include/hw/nmi.h
index f4cec62..b541772 100644
--- a/include/hw/nmi.h
+++ b/include/hw/nmi.h
@@ -45,6 +45,5 @@ typedef struct NMIClass {
} NMIClass;
void nmi_monitor_handle(int cpu_index, Error **errp);
-void inject_nmi(void);
#endif /* NMI_H */
--
2.5.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH v2 3/3] cpus: call the core nmi injection function
2016-05-20 16:28 [Qemu-devel] [PATCH v2 0/3] Minor nmi cleanups Bandan Das
2016-05-20 16:28 ` [Qemu-devel] [PATCH v2 1/3] target-i386: add a generic x86 nmi handler Bandan Das
2016-05-20 16:28 ` [Qemu-devel] [PATCH v2 2/3] nmi: remove x86 specific nmi handling Bandan Das
@ 2016-05-20 16:28 ` Bandan Das
2016-05-23 8:31 ` [Qemu-devel] [PATCH v2 0/3] Minor nmi cleanups Paolo Bonzini
3 siblings, 0 replies; 5+ messages in thread
From: Bandan Das @ 2016-05-20 16:28 UTC (permalink / raw)
To: qemu-devel; +Cc: pbonzini, aik
We can call the common function here directly since
x86 specific actions will be taken care of by the arch
specific nmi handler
Signed-off-by: Bandan Das <bsd@redhat.com>
---
cpus.c | 14 --------------
1 file changed, 14 deletions(-)
diff --git a/cpus.c b/cpus.c
index eb34b4f..481f78a 100644
--- a/cpus.c
+++ b/cpus.c
@@ -1693,21 +1693,7 @@ exit:
void qmp_inject_nmi(Error **errp)
{
-#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(monitor_get_cpu_index(), errp);
-#endif
}
void dump_drift_info(FILE *f, fprintf_function cpu_fprintf)
--
2.5.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH v2 0/3] Minor nmi cleanups
2016-05-20 16:28 [Qemu-devel] [PATCH v2 0/3] Minor nmi cleanups Bandan Das
` (2 preceding siblings ...)
2016-05-20 16:28 ` [Qemu-devel] [PATCH v2 3/3] cpus: call the core nmi injection function Bandan Das
@ 2016-05-23 8:31 ` Paolo Bonzini
3 siblings, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2016-05-23 8:31 UTC (permalink / raw)
To: Bandan Das, qemu-devel; +Cc: aik
On 20/05/2016 18:28, Bandan Das wrote:
> v2:
> 2/4: Remove inject_nmi and call nmi_monitor_handle()
> directly
> 3/4: rm -rf
> 4/4: Call nmi_monitor_handle and pass cpu index
>
> The primary change is a arch specific x86 nmi function
> which can be called by the core nmi handler.
>
> Bandan Das (3):
> target-i386: add a generic x86 nmi handler
> nmi: remove x86 specific nmi handling
> cpus: call the core nmi injection function
>
> cpus.c | 14 --------------
> hw/core/nmi.c | 24 ------------------------
> hw/i386/pc.c | 20 ++++++++++++++++++++
> hw/watchdog/watchdog.c | 2 +-
> include/hw/nmi.h | 1 -
> 5 files changed, 21 insertions(+), 40 deletions(-)
>
Thanks, queued.
Paolo
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-05-23 8:31 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-20 16:28 [Qemu-devel] [PATCH v2 0/3] Minor nmi cleanups Bandan Das
2016-05-20 16:28 ` [Qemu-devel] [PATCH v2 1/3] target-i386: add a generic x86 nmi handler Bandan Das
2016-05-20 16:28 ` [Qemu-devel] [PATCH v2 2/3] nmi: remove x86 specific nmi handling Bandan Das
2016-05-20 16:28 ` [Qemu-devel] [PATCH v2 3/3] cpus: call the core nmi injection function Bandan Das
2016-05-23 8:31 ` [Qemu-devel] [PATCH v2 0/3] Minor nmi cleanups Paolo Bonzini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).