Skip to contentSkip to conversation

KVM: irqfd: resampler EOI can go to the wrong GSI

BUG Cheng Yongkang 1 participant 1 message Nov 15 KVM

lore
Share & tools
lore
#0 lore raw

Hi Paolo, Sean,

I hit two corner cases with resampling irqfds. Both need the VMM to set up IRQ routing in an unusual way, so they may not be worth fixing. They come from the same mechanism, so I am putting them in one mail.

On EOI, KVM maps the irqchip pin back to a GSI and signals that GSI's resamplefd. The reverse map only keeps one GSI per pin, the last one set up, and it follows the current routing table, not the one in use when the interrupt was asserted.

1) Routing changed while a level interrupt is pending

GSI 16 asserts I/O APIC pin 16 through a resampling irqfd. Userspace then swaps the routes of GSI 16 and GSI 17 with KVM_SET_GSI_ROUTING. On EOI of pin 16, KVM signals GSI 17's resamplefd, and GSI 16's resamplefd is never signalled.

2) Two GSIs routed to the same pin

GSI 24 and GSI 25 are both routed to I/O APIC pin 9, and each has a resampling irqfd. When GSI 24 is asserted and the guest EOIs, KVM signals GSI 25's resamplefd, and GSI 24's is never signalled.

Both were seen on v7.3. In both cases the owner of the silent resamplefd is never told about the EOI, although api.rst says that when the irqchip is resampled "the gsi is de-asserted and the user is notified via kvm_irqfd.resamplefd". I could not find anything in the KVM_IRQFD or KVM_SET_GSI_ROUTING documentation that forbids either routing. setup_routing_entry() and the EOI path are unchanged in next-20261113.

A fix probably needs two parts: reject a resampling irqfd, or a routing table, that would make the pin resolve to a different GSI, and keep a routing update from changing a pin that a resampler has asserted. I have a draft series for that but it has not been built or tested on the current tree, so I am asking first whether you want this fixed and in which direction.

Thanks,
Cheng Yongkang