qemu/include/hw/vfio
Steve Sistare 322ee16824 vfio/pci: preserve pending interrupts
cpr-transfer may lose a VFIO interrupt because the KVM instance is
destroyed and recreated.  If an interrupt arrives in the middle, it is
dropped.  To fix, stop pending new interrupts during cpr save, and pick
up the pieces.  In more detail:

Stop the VCPUs. Call kvm_irqchip_remove_irqfd_notifier_gsi --> KVM_IRQFD to
deassign the irqfd gsi that routes interrupts directly to the VCPU and KVM.
After this call, interrupts fall back to the kernel vfio_msihandler, which
writes to QEMU's kvm_interrupt eventfd.  CPR already preserves that
eventfd.  When the route is re-established in new QEMU, the kernel tests
the eventfd and injects an interrupt to KVM if necessary.

Deassign INTx in a similar manner.  For both MSI and INTx, remove the
eventfd handler so old QEMU does not consume an event.

If an interrupt was already pended to KVM prior to the completion of
kvm_irqchip_remove_irqfd_notifier_gsi, it will be recovered by the
subsequent call to cpu_synchronize_all_states, which pulls KVM interrupt
state to userland prior to saving it in vmstate.

Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Link: https://lore.kernel.org/qemu-devel/1752689169-233452-3-git-send-email-steven.sistare@oracle.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
2025-08-09 00:06:48 +02:00
..
vfio-amd-xgbe.h Use DECLARE_*CHECKER* macros 2020-09-09 09:27:09 -04:00
vfio-calxeda-xgmac.h Use DECLARE_*CHECKER* macros 2020-09-09 09:27:09 -04:00
vfio-container-base.h vfio/iommufd: use IOMMU_IOAS_MAP_FILE 2025-07-03 13:42:28 +02:00
vfio-container.h vfio/container: register container for cpr 2025-06-11 14:01:58 +02:00
vfio-cpr.h vfio/pci: preserve pending interrupts 2025-08-09 00:06:48 +02:00
vfio-device.h vfio/migration: Max in-flight VFIO device state buffers size limit 2025-07-15 17:11:12 +02:00
vfio-migration.h vfio: Introduce a new header file for external migration services 2025-04-25 09:01:37 +02:00
vfio-platform.h vfio: Rename vfio-common.h to vfio-device.h 2025-04-25 09:01:37 +02:00
vfio-region.h vfio: mark posted writes in region write callbacks 2025-06-11 14:01:58 +02:00