Re: [PATCH v7 09/20] KVM: selftests: Add VFIO device support to eventfd IRQ test
From: David Matlack
Date: Thu Jun 18 2026 - 16:22:43 EST
On 2026-06-12 05:20 PM, Sean Christopherson wrote:
> From: David Matlack <dmatlack@xxxxxxxxxx>
>
> Extend the eventfd IRQ test with a '-d' argument that takes a BDF (in the
> format segment:bus:device.function) of an interrupt-capable PCI(e) device
> bound to VFIO, and use said device to trigger interrupts instead of always
> synthesizing interrupts via direct writes to the eventfd.
>
> Using a VFIO device to trigger interrupts validates the end-to-end delivery
> of IRQs for "real" devices, and when supported by hardware (and KVM), also
> validates interrupt delivery via IRQ bypass, i.e. via device posted IRQs.
>
> Now that IOMMUFD is a thing, auto-probe IOMMUFD vs. "legacy" VFIO by
> temporarily opening /dev/iommufd, and skip the test if neither IOMMUFD nor
> legacy VFIO is available. Add a '-t' option to the user override the probe
> logic, e.g. in case IOMMUFD is available but the system is configured for
> legacy usage.
>
> Note, the device must have a VFIO selftest driver in order to work with
> the test. A helper script to list supported devices will hopefully be
> available in the near future at
> tools/testing/selftests/vfio/scripts/list_supported_devices.sh[1].
> +static int vfio_setup_msi(struct vfio_pci_device *device)
> +{
> + const int flags = MAP_SHARED | MAP_ANONYMOUS;
> + const int prot = PROT_READ | PROT_WRITE;
> + struct dma_region *region;
> +
> + /* A driver is required to generate an MSI. */
> + TEST_REQUIRE(device->driver.ops);
This series is probably going to race with merging another VFIO
selftests patch to make send_msi() optional [1]. Can you add a check for
that here?
TEST_REQUIRE(device->driver.ops);
TEST_REQUIRE(device->driver.ops->send_msi);
[1] https://lore.kernel.org/kvm/20260609232855.3808971-4-rubind@xxxxxxxxxx/