This series can be found on GitHub: https://github.com/dmatlack/linux/tree/kvm/selftests/vfio_pci_irq_test/v1 I'm sending this series out a little early. VFIO selftests has landed in vfio/next[1] and is slated for 6.18, but has not yet been merged by Linus. But I wanted to start the discussion of linking the VFIO selftests library into KVM selftests so we can test VFIO-KVM interactions. To demostrate testing VFIO+KVM interactions, patch 2 contains a test to exercise delivering VFIO device interrupts to vCPUs. This test is heavily based on Sean's vfio_irq_test.c [2]. Running selftests with VFIO devices is slightly different than typical KVM selftests since it requires a PCI device bound to vfio-pci. The VFIO selftests have a helper script for setting up a device: $ ./run.sh -s -d 0000:6a:01.0 + echo "vfio-pci" > /sys/bus/pci/devices/0000:6a:01.0/driver_override + echo "0000:6a:01.0" > /sys/bus/pci/drivers/vfio-pci/bind Dropping into /bin/bash with VFIO_SELFTESTS_BDF=0000:6a:01.0 The test can then be run and it will detect the $VFIO_SELFTESTS_BDF environment variable. $ tools/testing/selftests/kvm/vfio_pci_irq_test $ tools/testing/selftests/kvm/vfio_pci_irq_test -v64 -d -x You can also pass the BDF directly to the test on the command-line (i.e. using run.sh and the environment variable is not a required). $ tools/testing/selftests/kvm/vfio_pci_irq_test 0000:6a:01.0 $ tools/testing/selftests/kvm/vfio_pci_irq_test -v64 -d -x 0000:6a:01.0 In order to test with real MSIs generated by the device (-d option), the device must also have a supported driver in tools/testing/selftests/vfio/lib/drivers/. At the moment we only have drivers for Intel CBDMA and Intel DSA devices, so I haven't been able to test with -d on AMD yet. Currently this test only supports x86_64, but it should be portable to at least ARM in the future, so I optimistically placed it in the top-level KVM selftests directory. [1] https://github.com/awilliam/linux-vfio/tree/next [2] https://lore.kernel.org/kvm/20250404193923.1413163-68-seanjc@xxxxxxxxxx/ Cc: Sean Christopherson <seanjc@xxxxxxxxxx> David Matlack (2): KVM: selftests: Build and link sefltests/vfio/lib into KVM selftests KVM: selftests: Add a test for vfio-pci device IRQ delivery to vCPUs tools/testing/selftests/kvm/Makefile.kvm | 6 +- .../testing/selftests/kvm/vfio_pci_irq_test.c | 507 ++++++++++++++++++ 2 files changed, 512 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/kvm/vfio_pci_irq_test.c base-commit: 093458c58f830d0a713fab0de037df5f0ce24fef prerequisite-patch-id: 72dce9cd586ac36ea378354735d9fabe2f3c445e prerequisite-patch-id: a8c7ccfd91ce3208f328e8af7b25c83bff8d464d -- 2.51.0.384.g4c02a37b29-goog