[PATCH] KVM: x86: fix xen guest panic due to lack of KVM_REQ_EVENT

From: Wanpeng Li
Date: Mon Aug 25 2014 - 03:56:15 EST

This patch fix bug https://bugzilla.kernel.org/show_bug.cgi?id=82211

(XEN) ..MP-BIOS bug: 8254 timer not connected to IO-APIC
(XEN) ...trying to set up timer (IRQ0) through the 8259A ... failed.
(XEN) ...trying to set up timer as Virtual Wire IRQ... failed.
(XEN) ...trying to set up timer as ExtINT IRQ... failed :(.
(XEN) ****************************************
(XEN) Panic on CPU 0:
(XEN) IO-APIC + timer doesn't work! Boot with apic_verbosity=debug and send a report.
(XEN) ****************************************

Commit 6addfc42992b ("KVM: x86: avoid useless set of KVM_REQ_EVENT after
emulation") sets a KVM_REQ_EVENT if an interrupt could be injected, which
happens a) if an interrupt shadow bit (STI or MOV SS) has gone away; b)
if the interrupt flag has just been set. However, a KVM_REQ_EVENT should
be set if there is no sti sequence. This patch fix it by set a KVM_REQ_EVENT
if both the first and the second instructions are not sti.

Signed-off-by: Wanpeng Li <wanpeng.li@xxxxxxxxxxxxxxx>
arch/x86/kvm/x86.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index c10408e..b7c0073 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -4928,6 +4928,8 @@ static void toggle_interruptibility(struct kvm_vcpu *vcpu, u32 mask)
if (!mask)
kvm_make_request(KVM_REQ_EVENT, vcpu);
+ if (!(int_shadow || mask))
+ kvm_make_request(KVM_REQ_EVENT, vcpu);

static void inject_emulated_exception(struct kvm_vcpu *vcpu)

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/