From: David Matlack <dmatlack@google.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
Sean Christopherson <seanjc@google.com>
Cc: Alex Williamson <alex.williamson@redhat.com>,
kvm@vger.kernel.org, David Matlack <dmatlack@google.com>
Subject: [PATCH 0/2] KVM: selftests: Link with VFIO selftests lib and test device interrupts
Date: Fri, 12 Sep 2025 22:25:22 +0000 [thread overview]
Message-ID: <20250912222525.2515416-1-dmatlack@google.com> (raw)
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@google.com/
Cc: Sean Christopherson <seanjc@google.com>
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
next reply other threads:[~2025-09-12 22:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-12 22:25 David Matlack [this message]
2025-09-12 22:25 ` [PATCH 1/2] KVM: selftests: Build and link sefltests/vfio/lib into KVM selftests David Matlack
2025-09-12 22:25 ` [PATCH 2/2] KVM: selftests: Add a test for vfio-pci device IRQ delivery to vCPUs David Matlack
2025-10-27 16:52 ` Sean Christopherson
2025-10-27 17:46 ` David Matlack
2025-10-27 18:50 ` Sean Christopherson
2025-10-27 15:47 ` [PATCH 0/2] KVM: selftests: Link with VFIO selftests lib and test device interrupts Sean Christopherson
2025-10-27 16:03 ` David Matlack
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250912222525.2515416-1-dmatlack@google.com \
--to=dmatlack@google.com \
--cc=alex.williamson@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox