Skip to content

KVM: cleanup ioapic and fix KVM_SET_IRQCHIP with irr != 0

Paolo Bonzini kvm lkml 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest4 patches 11 repliesIn review
  2. v1 posting 2/24 patches 8 repliesSuperseded
  3. v1 posting 1/24 patches 0 repliesSuperseded

Changes in v2 from the cover letter

more comments in patch 3
change argument name in patch 3 from level to irq_level use IOAPIC_NUM_PINS in patch 4 as a limit to for_each_set_bit remove debug printk in patch 4

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4KVM: ioapic: merge ioapic_deliver into ioapic_servicevirt/kvm/ioapic.c+9 -201 reply
2/4KVM: ioapic: clear IRR for edge-triggered interrupts at deliveryvirt/kvm/ioapic.c+3 -02 replies
3/4KVM: ioapic: extract body of kvm_ioapic_set_irqvirt/kvm/ioapic.c+50 -243 replies
4/4KVM: ioapic: reinject pending interrupts on KVM_SET_IRQCHIPvirt/kvm/ioapic.c+14 -14 replies

Reviews trailers per patch

All 4 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchAlex WilliamsonEduardo HabkostRadim Krčmář
SeriesR-b
1/4R-b R-b
2/4R-b
3/4R-b
4/4R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v2 thread

Cover letter [PATCH v2 0/4] KVM: cleanup ioapic and fix KVM_SET_IRQCHIP with irr != 0

Unlike the old qemu-kvm, which really never did that, with new QEMU it is for some reason somewhat likely to migrate a VM with a nonzero IRR in the ioapic. In the case of ISA edge-triggered interrupts, this represents an interrupt that has not left the IOAPIC, which would be okay but it is not handled right by KVM_SET_IRQCHIP. Because the interrupt is never injected, the guest never acknowledges it, the host never deasserts the pin and new interrupts are dropped.

There are two problems to solve.

The obvious one is that interrupts are not reinjected upon KVM_SET_IRQCHIP, which is taken care of by patches 3-4.

The second is that right now the IRR value depends on the falling edge of the interrupt (as passed by the userspace via kvm_ioapic_set_irq). This is unnecessary, and may lead to spurious reinjection in the destination of migration; instead, we can clear the (internal-only) IRR bit as soon as the interrupt leaves the IOAPIC. This is done by patch 2, which patch 1 prepares for.

This fixes migration of Windows guests without HPET. Please review.

Paolo

v1->v2:
more comments in patch 3
change argument name in patch 3 from level to irq_level use IOAPIC_NUM_PINS in patch 4 as a limit to for_each_set_bit remove debug printk in patch 4

Paolo Bonzini (4):
KVM: ioapic: merge ioapic_deliver into ioapic_service
KVM: ioapic: clear IRR for edge-triggered interrupts at delivery
KVM: ioapic: extract body of kvm_ioapic_set_irq
KVM: ioapic: reinject pending interrupts on KVM_SET_IRQCHIP

 virt/kvm/ioapic.c | 107 +++++++++++++++++++++++++++++++++++-------------------
 1 file changed, 69 insertions(+), 38 deletions(-)
Signature · 1 line
1.8.3.1