Skip to content

Commit 35baff2

Browse files
markmcavikivity
authored andcommitted
KVM: IOAPIC: Fix level-triggered irq injection hang
The "remote_irr" variable is used to indicate an interrupt which has been received by the LAPIC, but not acked. In our EOI handler, we unset remote_irr and re-inject the interrupt if the interrupt line is still asserted. However, we do not set remote_irr here, leading to a situation where if kvm_ioapic_set_irq() is called, then we go ahead and call ioapic_service(). This means that IRR is re-asserted even though the interrupt is currently in service (i.e. LAPIC IRR is cleared and ISR/TMR set) The issue with this is that when the currently executing interrupt handler finishes and writes LAPIC EOI, then TMR is unset and EOI sent to the IOAPIC. Since IRR is now asserted, but TMR is not, then when the second interrupt is handled, no EOI is sent and if there is any pending interrupt, it is not re-injected. This fixes a hang only seen while running mke2fs -j on an 8Gb virtio disk backed by a fully sparse raw file, with aliguori "avoid fragmented virtio-blk transfers by copying" changes. Signed-off-by: Mark McLoughlin <[email protected]> Acked-by: Marcelo Tosatti <[email protected]> Signed-off-by: Avi Kivity <[email protected]>
1 parent ca37393 commit 35baff2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

virt/kvm/ioapic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ static void __kvm_ioapic_update_eoi(struct kvm_ioapic *ioapic, int gsi)
278278

279279
ent->fields.remote_irr = 0;
280280
if (!ent->fields.mask && (ioapic->irr & (1 << gsi)))
281-
ioapic_deliver(ioapic, gsi);
281+
ioapic_service(ioapic, gsi);
282282
}
283283

284284
void kvm_ioapic_update_eoi(struct kvm *kvm, int vector)

0 commit comments

Comments
 (0)