diff mbox series

[2/4] KVM: ioapic: clear IRR for edge-triggered interrupts at delivery

Message ID 1536589422-20822-3-git-send-email-gavin.guo@canonical.com
State New
Headers show
Series [1/4] KVM: ioapic: merge ioapic_deliver into ioapic_service | expand

Commit Message

Gavin Guo Sept. 10, 2018, 2:23 p.m. UTC
From: Paolo Bonzini <pbonzini@redhat.com>

BugLink: https://bugs.launchpad.net/bugs/1791286

This ensures that IRR bits are set in the KVM_GET_IRQCHIP result only if
the interrupt is still sitting in the IOAPIC.  After the next patches, it
avoids spurious reinjection of the interrupt when KVM_SET_IRQCHIP is
called.

Reviewed-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit 0bc830b05c667218d703f2026ec866c49df974fc)
Signed-off-by: Gavin Guo <gavin.guo@canonical.com>
---
 virt/kvm/ioapic.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/virt/kvm/ioapic.c b/virt/kvm/ioapic.c
index 3a0ccff16830..1cc1851812fa 100644
--- a/virt/kvm/ioapic.c
+++ b/virt/kvm/ioapic.c
@@ -287,6 +287,9 @@  static int ioapic_service(struct kvm_ioapic *ioapic, int irq, bool line_status)
 	irqe.level = 1;
 	irqe.shorthand = 0;
 
+	if (irqe.trig_mode == IOAPIC_EDGE_TRIG)
+		ioapic->irr &= ~(1 << irq);
+
 	if (irq == RTC_GSI && line_status) {
 		BUG_ON(ioapic->rtc_status.pending_eoi != 0);
 		ret = kvm_irq_delivery_to_apic(ioapic->kvm, NULL, &irqe,