public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/14] KVM: selftests: Link with VFIO selftests lib and test device interrupts
@ 2026-03-31 19:40 Josh Hilke
  2026-03-31 19:40 ` [PATCH v2 01/14] KVM: selftests: Build and link sefltests/vfio/lib into KVM selftests Josh Hilke
                   ` (14 more replies)
  0 siblings, 15 replies; 42+ messages in thread
From: Josh Hilke @ 2026-03-31 19:40 UTC (permalink / raw)
  To: Paolo Bonzini, Sean Christopherson
  Cc: kvm, David Matlack, Alex Williamson, Josh Hilke

I am taking over development of this series from David Matlack. 
v1: https://lore.kernel.org/kvm/20250912222525.2515416-1-dmatlack@google.com/

This series is based on the kvm-upstream/queue branch.

This series introduces vfio_pci_irq_test, which exercises the delivery
of VFIO device interrupts (MSI/MSI-X) to guest vCPUs, and links the
VFIO selftests library into KVM selftests to enable testing of VFIO-KVM
interactions.

The test requires a PCI device bound to vfio-pci. It can be invoked by
passing the BDF the VFIO selftests setup script, and then running the
test with the device BDF:

  $ ./tools/testing/selftests/vfio/scripts/setup.sh 0000:6a:01.0
  $ tools/testing/selftests/kvm/vfio_pci_irq_test 0000:6a:01.0

This test only supports x86. Testing physical device interrupts (-d argument) is
only supported for Intel because there are no VFIO selftest drivers for AMD
devices.

The test can be run with following command-line arguments allow for broad
coverage of the interrupt delivery path:

  -a: Random IRQ Affinity. Randomly affinitizes the device IRQ to different 
      host CPUs to verify stable delivery during interrupt steering changes.
  -b: Block vCPUs. Causes vCPUs to HLT instead of spinning, verifying that 
      Posted-interrupt wakeup (PIW) correctly kicks blocked vCPUs.
  -d: Device MSI Triggers. Uses the physical device to trigger MSIs instead 
      of eventfd emulation (requires a supported device driver).
  -e: Clear GSI Routes. Periodically destroys/recreates KVM's GSI routing 
      table to verify handling of dynamic IRQ updates.
  -i: IRQ Count. Sets the number of interrupts to generate (default 1000).
  -n: NMI Delivery. Routes interrupts as NMIs into the guest to verify the 
      VFIO-NMI delivery path.
  -p: vCPU Pinning. Migrates vCPUs to random physical CPUs to verify that 
      posted interrupts follow the vCPU across host cores.
  -t: Timeout. Configurable timeout in seconds to wait for an interrupt.
  -v: vCPU Count. Distributes interrupts across multiple vCPUs via 
      round-robin routing.
  -x: xAPIC Mode. Forces legacy xAPIC mode to verify compatibility.


Changelog
---------
v2:
 - Split the monolithic test into a series of logical patches (Sean)
 - Move READ_FROM_GUEST and WRITE_TO_GUEST macros to kvm_util.h (Sean)
 - Add gettid, sched_setaffinity, and sched_getaffinity to kvm_syscalls.h (Sean)
 - Extract /proc/interrupts parsing logic into lib/irq_util.c (Sean)
 - Add -t command-line option for configurable interrupt timeout (Sean)
 - Improve assertion messages with specific vCPU failure context (Sean)
 - Update guest loop to use cpu_relax() when not blocking (Sean)
 - Add KVM_RANDOM_SEED support to kvm_selftest_init for reproducibility (Sean)
 - Randomize the default IRQ vector and GSI (Sean)
 - Ensure blocked vCPUs are cleaned up correctly after HLT (Sean)
 - Use kvm_mmap() instead of mmap() (Sean)

v1: https://lore.kernel.org/kvm/20250912222525.2515416-1-dmatlack@google.com/

David Matlack (11):
  KVM: selftests: Build and link sefltests/vfio/lib into KVM selftests
  KVM: selftests: Add vfio_pci_irq_test
  KVM: selftests: Add support for random host IRQ affinity
  KVM: selftests: Allow blocking vCPUs via HLT
  KVM: selftests: Add support for physical device MSI triggers
  KVM: selftests: Add option to clear GSI routes
  KVM: selftests: Make test IRQ count configurable
  KVM: selftests: Add support for NMI delivery
  KVM: selftests: Add support for vCPU pinning
  KVM: selftests: Support testing with multiple vCPUs
  KVM: selftests: Add xAPIC mode support

Josh Hilke (3):
  KVM: selftests: Add helper functions for IRQ testing
  KVM: selftests: Reproduce tests that rely on randomization
  KVM: selftests: Make vfio_pci_irq_test timeout configurable

 tools/testing/selftests/kvm/Makefile.kvm      |   7 +-
 .../testing/selftests/kvm/include/irq_util.h  |  11 +
 .../selftests/kvm/include/kvm_syscalls.h      |   7 +
 .../testing/selftests/kvm/include/kvm_util.h  |  11 +
 tools/testing/selftests/kvm/lib/irq_util.c    |  84 ++++
 tools/testing/selftests/kvm/lib/kvm_util.c    |  11 +-
 .../testing/selftests/kvm/vfio_pci_irq_test.c | 439 ++++++++++++++++++
 7 files changed, 568 insertions(+), 2 deletions(-)
 create mode 100644 tools/testing/selftests/kvm/include/irq_util.h
 create mode 100644 tools/testing/selftests/kvm/lib/irq_util.c
 create mode 100644 tools/testing/selftests/kvm/vfio_pci_irq_test.c

-- 
2.53.0.1118.gaef5881109-goog


^ permalink raw reply	[flat|nested] 42+ messages in thread

end of thread, other threads:[~2026-04-02 18:07 UTC | newest]

Thread overview: 42+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-31 19:40 [PATCH v2 00/14] KVM: selftests: Link with VFIO selftests lib and test device interrupts Josh Hilke
2026-03-31 19:40 ` [PATCH v2 01/14] KVM: selftests: Build and link sefltests/vfio/lib into KVM selftests Josh Hilke
2026-04-01 18:17   ` Sean Christopherson
2026-04-01 23:49     ` Josh Hilke
2026-03-31 19:40 ` [PATCH v2 02/14] KVM: selftests: Add helper functions for IRQ testing Josh Hilke
2026-04-01 18:26   ` Sean Christopherson
2026-04-01 23:54     ` Josh Hilke
2026-03-31 19:40 ` [PATCH v2 03/14] KVM: selftests: Add vfio_pci_irq_test Josh Hilke
2026-04-01 19:58   ` Sean Christopherson
2026-04-02  0:13     ` Josh Hilke
2026-04-02 17:52       ` Sean Christopherson
2026-03-31 19:40 ` [PATCH v2 04/14] KVM: selftests: Reproduce tests that rely on randomization Josh Hilke
2026-03-31 19:40 ` [PATCH v2 05/14] KVM: selftests: Add support for random host IRQ affinity Josh Hilke
2026-04-01 20:01   ` Sean Christopherson
2026-04-02  1:16     ` Josh Hilke
2026-03-31 19:40 ` [PATCH v2 06/14] KVM: selftests: Allow blocking vCPUs via HLT Josh Hilke
2026-04-01 20:03   ` Sean Christopherson
2026-03-31 19:40 ` [PATCH v2 07/14] KVM: selftests: Add support for physical device MSI triggers Josh Hilke
2026-04-01 20:24   ` Sean Christopherson
2026-04-02  3:23     ` Josh Hilke
2026-03-31 19:40 ` [PATCH v2 08/14] KVM: selftests: Add option to clear GSI routes Josh Hilke
2026-03-31 19:40 ` [PATCH v2 09/14] KVM: selftests: Make test IRQ count configurable Josh Hilke
2026-03-31 19:40 ` [PATCH v2 10/14] KVM: selftests: Add support for NMI delivery Josh Hilke
2026-04-01 20:29   ` Sean Christopherson
2026-04-02  5:27     ` Josh Hilke
2026-03-31 19:40 ` [PATCH v2 11/14] KVM: selftests: Add support for vCPU pinning Josh Hilke
2026-04-01 20:55   ` Sean Christopherson
2026-03-31 19:40 ` [PATCH v2 12/14] KVM: selftests: Support testing with multiple vCPUs Josh Hilke
2026-03-31 19:40 ` [PATCH v2 13/14] KVM: selftests: Add xAPIC mode support Josh Hilke
2026-03-31 19:40 ` [PATCH v2 14/14] KVM: selftests: Make vfio_pci_irq_test timeout configurable Josh Hilke
2026-04-01 21:00   ` Sean Christopherson
2026-04-01 18:17 ` [PATCH v2 00/14] KVM: selftests: Link with VFIO selftests lib and test device interrupts Sean Christopherson
2026-04-01 18:52   ` David Matlack
2026-04-01 19:07     ` Sean Christopherson
2026-04-01 20:12       ` David Matlack
2026-04-01 23:41         ` Josh Hilke
2026-04-01 23:58           ` David Matlack
2026-04-02  0:38             ` Josh Hilke
2026-04-02  1:49               ` Josh Hilke
2026-04-02 17:35                 ` Sean Christopherson
2026-04-02 17:56                   ` David Matlack
2026-04-02 18:07                     ` Josh Hilke

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox