From 5d62c43a17edaa7f6a88821c9086e6c8e0e5327d Mon Sep 17 00:00:00 2001 From: Jan Kiszka Date: Mon, 9 Jul 2012 16:42:32 +0200 Subject: apic: Defer interrupt updates to VCPU thread KVM performs TPR raising asynchronously to QEMU, specifically outside QEMU's global lock. When an interrupt is injected into the APIC and TPR is checked to decide if this can be delivered, a stale TPR value may be used, causing spurious interrupts in the end. Fix this by deferring apic_update_irq to the context of the target VCPU. We introduce a new interrupt flag for this, CPU_INTERRUPT_POLL. When it is set, the VCPU calls apic_poll_irq before checking for further pending interrupts. To avoid special-casing KVM, we also implement this logic for TCG mode. Signed-off-by: Jan Kiszka Signed-off-by: Avi Kivity --- cpu-exec.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'cpu-exec.c') diff --git a/cpu-exec.c b/cpu-exec.c index 08c35f72d4..fc185a4f04 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -288,6 +288,12 @@ int cpu_exec(CPUArchState *env) } #endif #if defined(TARGET_I386) +#if !defined(CONFIG_USER_ONLY) + if (interrupt_request & CPU_INTERRUPT_POLL) { + env->interrupt_request &= ~CPU_INTERRUPT_POLL; + apic_poll_irq(env->apic_state); + } +#endif if (interrupt_request & CPU_INTERRUPT_INIT) { cpu_svm_check_intercept_param(env, SVM_EXIT_INIT, 0); -- cgit v1.2.3