Minor nmi cleanups
cover Minor nmi cleanups
The primary change is a arch specific x86 nmi function which can be called by the core nmi handler.
Bandan Das (4):
target-i386: add a generic x86 nmi handler
nmi: remove x86 specific nmi handling
nmi: add errp function parameter to inject_nmi()
cpus: call the core nmi injection function
cpus.c | 16 +--------------- hw/core/nmi.c | 23 ++--------------------- hw/i386/pc.c | 20 ++++++++++++++++++++ hw/watchdog/watchdog.c | 2 +- include/hw/nmi.h | 2 +- 5 files changed, 25 insertions(+), 38 deletions(-)
Signature · 1 line
2.5.5
PATCH 2/4 nmi: remove x86 specific nmi handling
nmi_monitor_handle is wired to call the x86 nmi
handler now. So, we can call it here. Note that
this also reverts changes made by commit 33c11879
--- hw/core/nmi.c | 19 ------------------- 1 file changed, 19 deletions(-)
hw/core/nmi.c +0 -19
@@ -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;
@@ -80,21 +75,7 @@ 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 = {
Signature · 1 line
2.5.5
PATCH 1/4 target-i386: add a generic x86 nmi handler
In reply to Bandan DasInstead of having x86 ifdefs in core nmi code, this change adds a arch specific handler that the nmi common code can call.
--- hw/i386/pc.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
hw/i386/pc.c +20 -0
@@ -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 }, { } }, };
Signature · 1 line
2.5.5
PATCH 3/4 nmi: add errp function parameter to inject_nmi()
In reply to Bandan DasIf caller has errp, set it appropriately in case of an error and pass it along.
--- hw/core/nmi.c | 4 ++-- hw/watchdog/watchdog.c | 2 +- include/hw/nmi.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
hw/core/nmi.c +2 -2
@@ -73,9 +73,9 @@ void nmi_monitor_handle(int cpu_index, Error **errp) } } -void inject_nmi (void ) +void inject_nmi (Error **errp) { -nmi_monitor_handle (0 ,NULL ); +nmi_monitor_handle (0 , errp); }static const TypeInfo nmi_info = {
hw/watchdog/watchdog.c +1 -1
@@ -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 (); +inject_nmi (NULL );break ; } }
include/hw/nmi.h +1 -1
@@ -45,6 +45,6 @@ typedef struct NMIClass { } NMIClass;void nmi_monitor_handle (int cpu_index,Error **errp); -void inject_nmi (void ); +void inject_nmi (Error **errp);#endif /* NMI_H */
Signature · 1 line
2.5.5
PATCH 4/4 cpus: call the core nmi injection function
In reply to Bandan DasNow that the common functions are in place, we can call it instead of duplicating code.
--- cpus.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-)
cpus.c +1 -15
@@ -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 +inject_nmi (errp); }void dump_drift_info (FILE *f,fprintf_function cpu_fprintf)
Signature · 1 line
2.5.5
Re: [Qemu-devel] [PATCH 4/4] cpus: call the core nmi injection function
Quoted 8 lines · Bandan Das
void
qmp_inject_nmi(Error **errp)
{cpus.c +0
-6-#if defined(TARGET_I386 ) -CPUState *cs; - -CPU_FOREACH (cs) { -X86CPU *cpu =X86_CPU (cs); -
cpus.c exit: · line 1696
Quoted 10 lines
cpus.c +1
-9-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 +inject_nmi (errp);
This changes the first argument to nmi_monitor_handle in the !i386 case.
It should just remove the #ifdef, which I think makes the third patch
unnecessary. The first two patches are okay.
Paolo
Re: [Qemu-devel] [PATCH 4/4] cpus: call the core nmi injection function
In reply to Bandan DasQuoted 8 lines · Bandan Das
void
qmp_inject_nmi(Error **errp)
{cpus.c +0
-6-#if defined(TARGET_I386 ) -CPUState *cs; - -CPU_FOREACH (cs) { -X86CPU *cpu =X86_CPU (cs); -
cpus.c exit: · line 1696
Quoted 10 lines
cpus.c +1
-9-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 +inject_nmi (errp);
This changes the first argument to nmi_monitor_handle in the !i386 case.
It should just remove the #ifdef, which I think makes the third patch
unnecessary. The first two patches are okay.
Paolo
Re: [Qemu-devel] [PATCH 4/4] cpus: call the core nmi injection function
Quoted 15 lines · Paolo Bonzini
Quoted 14 lines · Bandan Das
void
qmp_inject_nmi(Error **errp)
{cpus.c +0
-12-#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); - } - }
Quoted 8 lines
cpus.c exit: · line 1696
Quoted 4 lines
cpus.c +1
-3-#else -nmi_monitor_handle (monitor_get_cpu_index (), errp); -#endif +inject_nmi (errp);This changes the first argument to
nmi_monitor_handlein the !i386 case.
It should just remove the #ifdef, which I think makes the third patch
unnecessary. The first two patches are okay.
Thanks for the review, I have sent a v2.
Quoted 1 line
Paolo