Skip to content

KVM: selftests: Link with VFIO selftests lib and test device interrupts

David Matlack kvm 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 5 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2KVM: selftests: Build and link sefltests/vfio/lib into KVM selfteststools/testing/selftests/kvm/Makefile.kvm+4 -10 replies
2/2KVM: selftests: Add a test for vfio-pci device IRQ delivery to vCPUstools/testing/selftests/kvm/Makefile.kvm tools/testing/selftests/kvm/vfio_pci_irq_test.c+508 -03 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/2] KVM: selftests: Link with VFIO selftests lib and test device interrupts

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/[email protected]/

Cc Sean Christopherson <[email protected]>

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

Signature · 1 line
2.51.0.384.g4c02a37b29-goog