From: Yongan Liu Date: Thu, 5 Jan 2012 08:29:59 +0000 (+0100) Subject: x86/vIRQ: IRR and TMR race condition bug fix X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=b4799791c1e88341688142408051e65867bcdf82;p=xen.git x86/vIRQ: IRR and TMR race condition bug fix In vlapic_set_irq, we set the IRR register before the TMR. And the IRR might be serviced before setting TMR, and even worse EOI might occur before TMR setting, in which case the vioapic_update_EOI won't be called, and further prevent all the subsequent interrupt injecting. Reorder setting the TMR and IRR will solve the problem. Besides, KVM has fixed a similar bug in: http://markmail.org/search/?q=APIC_TMR#query:APIC_TMR+page:1+mid:rphs4f7lkxjlldne+state:results Signed-off-by: Yongan Liu Signed-off-by: Jan Beulich Committed-by: Jan Beulich --- diff --git a/xen/arch/x86/hvm/vlapic.c b/xen/arch/x86/hvm/vlapic.c index 8b05f1adc3..b4142875ef 100644 --- a/xen/arch/x86/hvm/vlapic.c +++ b/xen/arch/x86/hvm/vlapic.c @@ -142,14 +142,11 @@ static int vlapic_find_highest_irr(struct vlapic *vlapic) int vlapic_set_irq(struct vlapic *vlapic, uint8_t vec, uint8_t trig) { - int ret; - - ret = !vlapic_test_and_set_irr(vec, vlapic); if ( trig ) vlapic_set_vector(vec, &vlapic->regs->data[APIC_TMR]); /* We may need to wake up target vcpu, besides set pending bit here */ - return ret; + return !vlapic_test_and_set_irr(vec, vlapic); } static int vlapic_find_highest_isr(struct vlapic *vlapic)