]> git.ipfire.org Git - thirdparty/qemu.git/commit
migration: ensure APIC is loaded prior to VFIO PCI devices
authorYanfei Xu <yanfei.xu@bytedance.com>
Mon, 18 Aug 2025 13:11:27 +0000 (21:11 +0800)
committerPeter Xu <peterx@redhat.com>
Fri, 3 Oct 2025 13:48:02 +0000 (09:48 -0400)
commitd943cef76090b5255e68ba38ce6ddf20537b07bc
treecc2269e4193dfa3354043b73aa6264eebb245f1b
parent725a9e5f7885a3c0d0cd82022d6eb5a758ac9d47
migration: ensure APIC is loaded prior to VFIO PCI devices

The load procedure of VFIO PCI devices involves setting up IRT
for each VFIO PCI devices. This requires determining whether an
interrupt is single-destination interrupt to decide between
Posted Interrupt(PI) or remapping mode for the IRTE. However,
determining this may require accessing the VM's APIC registers.

For example:
ioctl(vbasedev->fd, VFIO_DEVICE_SET_IRQS, irqs)
  ...
    kvm_arch_irq_bypass_add_producer
      kvm_x86_call(pi_update_irte)
        vmx_pi_update_irte
          kvm_intr_is_single_vcpu

If the LAPIC has not been loaded yet, interrupts will use remapping
mode. To prevent the fallback of interrupt mode, keep APIC is always
loaded prior to VFIO PCI devices.

Signed-off-by: Yicong Shen <shenyicong.1023@bytedance.com>
Signed-off-by: Yanfei Xu <yanfei.xu@bytedance.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Link: https://lore.kernel.org/r/20250818131127.1021648-1-yanfei.xu@bytedance.com
Signed-off-by: Peter Xu <peterx@redhat.com>
hw/intc/apic_common.c
include/migration/vmstate.h