Minor nmi cleanups
v2 cover Minor nmi cleanups
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(-)
Signature · 1 line
2.5.5
PATCH v2 1/3 target-i386: add a generic x86 nmi handler
Instead 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 v2 2/3 nmi: remove x86 specific nmi handling
In reply to Bandan Dasnmi_monitor_handle is wired to call the x86 nmi handler. So, we can directly use it at call sites.
--- hw/core/nmi.c | 24 ------------------------ hw/watchdog/watchdog.c | 2 +- include/hw/nmi.h | 1 - 3 files changed, 1 insertion(+), 26 deletions(-)
hw/core/nmi.c +0 -24
@@ -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 ,
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 (); +nmi_monitor_handle (0 ,NULL );break ; } }
include/hw/nmi.h +0 -1
@@ -45,6 +45,5 @@ typedef struct NMIClass { } NMIClass;void nmi_monitor_handle (int cpu_index,Error **errp); -void inject_nmi (void );#endif /* NMI_H */
Signature · 1 line
2.5.5
PATCH v2 3/3 cpus: call the core nmi injection function
In reply to Bandan DasWe can call the common function here directly since x86 specific actions will be taken care of by the arch specific nmi handler
--- cpus.c | 14 -------------- 1 file changed, 14 deletions(-)
cpus.c +0 -14
@@ -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)
Signature · 1 line
2.5.5
Quoted 14 lines · Bandan Das
v2:
2/4: Removeinject_nmiand callnmi_monitor_handle()directly
3/4: rm -rf
4/4: Callnmi_monitor_handleand pass cpu indexThe 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
Quoted 7 lines
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