From: Jan Kiszka Date: Mon, 17 Oct 2011 16:00:06 +0000 (+0800) Subject: apic: Inject external NMI events via LINT1 X-Git-Tag: TizenStudio_2.0_p2.3.2~208^2~4673^2~14 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=02c091953cd8c24db46649ad2862b9648c50f865;p=sdk%2Femulator%2Fqemu.git apic: Inject external NMI events via LINT1 On real hardware, NMI button events are injected via the LINT1 line of the APICs. E.g. kdump expect this wiring and gets upset if the per-APIC LINT1 mask is not respected, i.e. if NMIs are injected to VCPUs that should not receive them. Change the APIC emulation code to reflect this. Based on qemu-kvm patch by Lai Jiangshan. CC: Lai Jiangshan Reported-by: Kenji Kaneshige Signed-off-by: Jan Kiszka --- diff --git a/cpus.c b/cpus.c index 2dae549..f45a438 100644 --- a/cpus.c +++ b/cpus.c @@ -1217,7 +1217,11 @@ void qmp_inject_nmi(Error **errp) CPUState *env; for (env = first_cpu; env != NULL; env = env->next_cpu) { - cpu_interrupt(env, CPU_INTERRUPT_NMI); + if (!env->apic_state) { + cpu_interrupt(env, CPU_INTERRUPT_NMI); + } else { + apic_deliver_nmi(env->apic_state); + } } #else error_set(errp, QERR_UNSUPPORTED); diff --git a/hw/apic.c b/hw/apic.c index 4b97b17..b9d733c 100644 --- a/hw/apic.c +++ b/hw/apic.c @@ -205,6 +205,13 @@ void apic_deliver_pic_intr(DeviceState *d, int level) } } +void apic_deliver_nmi(DeviceState *d) +{ + APICState *s = DO_UPCAST(APICState, busdev.qdev, d); + + apic_local_deliver(s, APIC_LVT_LINT1); +} + #define foreach_apic(apic, deliver_bitmask, code) \ {\ int __i, __j, __mask;\ diff --git a/hw/apic.h b/hw/apic.h index a5c910f..a62d83b 100644 --- a/hw/apic.h +++ b/hw/apic.h @@ -8,6 +8,7 @@ void apic_deliver_irq(uint8_t dest, uint8_t dest_mode, uint8_t delivery_mode, uint8_t vector_num, uint8_t trigger_mode); int apic_accept_pic_intr(DeviceState *s); void apic_deliver_pic_intr(DeviceState *s, int level); +void apic_deliver_nmi(DeviceState *d); int apic_get_interrupt(DeviceState *s); void apic_reset_irq_delivered(void); int apic_get_irq_delivered(void);