On Thu, 25 Sep 2025 10:01:16 +0100, Maximilian Dittgen mdittgen@amazon.de wrote:
From: Maximilian Dittgen mdittgen@amazon.de
At the moment, all MSIs injected from userspace using KVM_SIGNAL_MSI are processed as LPIs in software with a hypervisor trap and exit.
Not really. Injecting an interrupt preempts the guest injecting a host IPI, but there is no trap.
To properly test GICv4 direct vLPI injection from KVM selftests, we write a KVM_DEBUG_GIC_MSI_SETUP ioctl that manually creates an IRQ routing table entry for the specified MSI, and populates ITS structures (device, collection, and interrupt translation table entries) to map the MSI to a vLPI. We then call GICv4 kvm_vgic_v4_set_forwarding to let the vLPI bypass hypervisor traps and inject directly to the vCPU.
I think that's totally overkill, and there is at least two ways to achieve the same thing without adding any additional code to the kernel:
- your test can simulate the restore of a guest with pending interrupts in the in-memory tables, start it, see the expected interrupts in the guest. Additional benefit: you can now test LPI restore.
- you use the interrupt injection mechanism that has been in the core code since 536e2e34bd0022, and let the GIC inject the interrupt for you. In case you wonder why it is there: for the exact purpose you describe.
Thanks,
M.