[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 1/1 V3] qemu-kvm: fix improper nmi emulation
From: |
Lai Jiangshan |
Subject: |
[Qemu-devel] [PATCH 1/1 V3] qemu-kvm: fix improper nmi emulation |
Date: |
Fri, 14 Oct 2011 08:54:55 +0800 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.9) Gecko/20100921 Fedora/3.1.4-1.fc14 Thunderbird/3.1.4 |
From: Kenji Kaneshige <address@hidden>
Currently, NMI interrupt is blindly sent to all the vCPUs when NMI
button event happens. This doesn't properly emulate real hardware on
which NMI button event triggers LINT1. Because of this, NMI is sent to
the processor even when LINT1 is maskied in LVT. For example, this
causes the problem that kdump initiated by NMI sometimes doesn't work
on KVM, because kdump assumes NMI is masked on CPUs other than CPU0.
With this patch, inject-nmi request is handled as follows.
- When in-kernel irqchip is disabled, inject LINT1 instead of NMI
interrupt.
- When in-kernel irqchip is enabled, send nmi event to kernel as the
current code does. LINT1 should be emulated in kernel.
Signed-off-by: Kenji Kaneshige <address@hidden>
Tested-by: Lai Jiangshan <address@hidden>
---
hw/apic.c | 11 +++++++++++
hw/apic.h | 1 +
monitor.c | 6 +++++-
3 files changed, 17 insertions(+), 1 deletions(-)
diff --git a/hw/apic.c b/hw/apic.c
index 69d6ac5..e4addbd 100644
--- a/hw/apic.c
+++ b/hw/apic.c
@@ -205,6 +205,17 @@ void apic_deliver_pic_intr(DeviceState *d, int level)
}
}
+void apic_deliver_nmi(DeviceState *d)
+{
+ APICState *s = DO_UPCAST(APICState, busdev.qdev, d);
+
+ if (kvm_enabled() && kvm_irqchip_in_kernel()) {
+ cpu_interrupt(s->cpu_env, CPU_INTERRUPT_NMI);
+ } else {
+ 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 c857d52..3a4be0a 100644
--- a/hw/apic.h
+++ b/hw/apic.h
@@ -10,6 +10,7 @@ void apic_deliver_irq(uint8_t dest, uint8_t dest_mode,
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);
diff --git a/monitor.c b/monitor.c
index cb485bf..0b81f17 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2616,7 +2616,11 @@ static int do_inject_nmi(Monitor *mon, const QDict
*qdict, QObject **ret_data)
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);
+ }
}
return 0;
- [Qemu-devel] [PATCH 1/1 V6] qemu: fix improper nmi emulation, (continued)
- [Qemu-devel] [PATCH 2/2 V5] qemu-kvm: fix improper nmi emulation, Lai Jiangshan, 2011/10/14
- Re: [Qemu-devel] [PATCH 2/2 V5] qemu-kvm: fix improper nmi emulation, Jan Kiszka, 2011/10/14
- [Qemu-devel] [PATCH 1/1 V5 tuning] kernel/kvm: introduce KVM_SET_LINT1 and fix improper nmi emulation, Lai Jiangshan, 2011/10/14
- Re: [Qemu-devel] [PATCH 1/1 V5 tuning] kernel/kvm: introduce KVM_SET_LINT1 and fix improper nmi emulation, Sasha Levin, 2011/10/14
- Re: [Qemu-devel] [PATCH 1/1 V5 tuning] kernel/kvm: introduce KVM_SET_LINT1 and fix improper nmi emulation, Jan Kiszka, 2011/10/14
- Re: [Qemu-devel] [PATCH 1/1 V5 tuning] kernel/kvm: introduce KVM_SET_LINT1 and fix improper nmi emulation, Lai Jiangshan, 2011/10/16
- [Qemu-devel] [PATCH 1/2 V5 tuning] qemu-kvm: Synchronize kernel headers, Lai Jiangshan, 2011/10/14
- [Qemu-devel] [PATCH 1/1 V3] qemu-kvm: fix improper nmi emulation,
Lai Jiangshan <=