From: Sean Christopherson <seanjc@google.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
Marc Zyngier <maz@kernel.org>, Oliver Upton <oupton@kernel.org>,
Sean Christopherson <seanjc@google.com>
Cc: Joey Gouly <joey.gouly@arm.com>,
Steffen Eiden <seiden@linux.ibm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Zenghui Yu <yuzenghui@huawei.com>,
kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org,
David Matlack <dmatlack@google.com>,
Josh Hilke <jrhilke@google.com>
Subject: [PATCH v8 12/20] KVM: selftests: Add option to set empty routing between IRQs in eventfd IRQ test
Date: Fri, 26 Jun 2026 14:35:25 -0700 [thread overview]
Message-ID: <20260626213534.3866178-13-seanjc@google.com> (raw)
In-Reply-To: <20260626213534.3866178-1-seanjc@google.com>
From: David Matlack <dmatlack@google.com>
Extend the eventfd IRQ test with an '-e' flag to set empty GSI routing
between interrupts. Clobbering the GSI routing table verifies that KVM
correctly handles CPUx => NULL => CPUy transitions, not just CPUx => CPUy
transitions, and verifies that KVM can "rebuild" an entire routing setup.
Signed-off-by: David Matlack <dmatlack@google.com>
Co-developed-by: Josh Hilke <jrhilke@google.com>
Signed-off-by: Josh Hilke <jrhilke@google.com>
[sean: '-e' for "empty" instead of '-c' for "clear", massage changelog]
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
tools/testing/selftests/kvm/irq_test.c | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/kvm/irq_test.c b/tools/testing/selftests/kvm/irq_test.c
index fd386e3e9ac3..fd03ec940362 100644
--- a/tools/testing/selftests/kvm/irq_test.c
+++ b/tools/testing/selftests/kvm/irq_test.c
@@ -121,6 +121,13 @@ static void kvm_route_msi(struct kvm_vm *vm, u32 gsi, struct kvm_vcpu *vcpu,
vm_ioctl(vm, KVM_SET_GSI_ROUTING, &routing.header);
}
+static void kvm_set_empty_gsi_routing(struct kvm_vm *vm)
+{
+ struct kvm_irq_routing routing = {};
+
+ vm_ioctl(vm, KVM_SET_GSI_ROUTING, &routing);
+}
+
static const char *probe_iommu_type(void)
{
int io_fd;
@@ -139,11 +146,12 @@ static const char *probe_iommu_type(void)
static void help(const char *name)
{
- printf("Usage: %s [-a] [-d <segment:bus:device.function>] [-h] [-t iommu_type]\n", name);
+ printf("Usage: %s [-a] [-d <segment:bus:device.function>] [-e] [-h] [-t iommu_type]\n", name);
printf("\n");
printf("Tests KVM interrupt routing and delivery via irqfd.\n");
printf("-a Affine the device's host IRQ to a random physical CPU\n");
printf("-d Use a VFIO device to send MSI-X interrupts instead of manually signaling the eventfd\n");
+ printf("-e Set empty GSI routing in-between some interrupts\n");
printf("-t Override the IOMMU type to use (vfio_type1_iommu or iommufd)\n");
printf("\n");
exit(KSFT_FAIL);
@@ -170,6 +178,7 @@ int main(int argc, char **argv)
struct kvm_vcpu *vcpus[KVM_MAX_VCPUS];
struct vfio_pci_device *device = NULL;
int nr_irqs = 1000, nr_vcpus = 1;
+ bool set_empty_routing = false;
const char *device_bdf = NULL;
const char *iommu_type = NULL;
int i, j, c, msix, eventfd;
@@ -177,7 +186,7 @@ int main(int argc, char **argv)
struct kvm_vm *vm;
int irq, irq_cpu;
- while ((c = getopt(argc, argv, "ad:ht:")) != -1) {
+ while ((c = getopt(argc, argv, "ad:eht:")) != -1) {
switch (c) {
case 'a':
irq_affinity = true;
@@ -185,6 +194,9 @@ int main(int argc, char **argv)
case 'd':
device_bdf = optarg;
break;
+ case 'e':
+ set_empty_routing = true;
+ break;
case 't':
iommu_type = optarg;
break;
@@ -234,9 +246,13 @@ int main(int argc, char **argv)
}
for (i = 0; i < nr_irqs; i++) {
+ const bool do_set_empty_routing = set_empty_routing && (i & BIT(3));
struct kvm_vcpu *vcpu = vcpus[i % nr_vcpus];
struct timespec start;
+ if (do_set_empty_routing)
+ kvm_set_empty_gsi_routing(vm);
+
kvm_route_msi(vm, gsi, vcpu, vector);
if (irq_affinity) {
--
2.55.0.rc0.799.gd6f94ed593-goog
next prev parent reply other threads:[~2026-06-26 21:36 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-26 21:35 [PATCH v8 00/20] KVM: selftests: Add eventfd+VFIO IRQ test Sean Christopherson
2026-06-26 21:35 ` [PATCH v8 01/20] KVM: selftests: Build and link selftests/vfio/lib into KVM selftests Sean Christopherson
2026-06-26 21:35 ` [PATCH v8 02/20] KVM: selftests: Add macros to read/write+sync to/from guest memory Sean Christopherson
2026-06-26 21:35 ` [PATCH v8 03/20] KVM: selftests: Rename guest_rng to kvm_rng Sean Christopherson
2026-06-26 21:35 ` [PATCH v8 04/20] KVM: selftests: Initialize the default/global pRNG during kvm_selftest_init() Sean Christopherson
2026-06-26 21:35 ` [PATCH v8 05/20] KVM: selftests: Seed libc's RNG before using it to generate a seed for KVM's pRNG Sean Christopherson
2026-06-26 21:35 ` [PATCH v8 06/20] KVM: selftests: Add helper to generate random u64 in range [min,max] Sean Christopherson
2026-06-26 21:35 ` [PATCH v8 07/20] KVM: selftests: Add an irqfd send+receive (and later IRQ bypass) test Sean Christopherson
2026-06-26 21:35 ` [PATCH v8 08/20] KVM: selftests: Add helper to get host IRQ from device MSI-X for IRQ bypass test Sean Christopherson
2026-06-26 21:35 ` [PATCH v8 09/20] KVM: selftests: Add VFIO device support to eventfd IRQ test Sean Christopherson
2026-06-26 21:35 ` [PATCH v8 10/20] KVM: selftests: Add a helper to set proc IRQ affinity for " Sean Christopherson
2026-06-26 21:35 ` [PATCH v8 11/20] KVM: selftests: Verify interrupts are received when IRQ affinity changes in " Sean Christopherson
2026-06-26 21:35 ` Sean Christopherson [this message]
2026-06-26 21:35 ` [PATCH v8 13/20] KVM: selftests: Make number of IRQs configurable " Sean Christopherson
2026-06-26 21:35 ` [PATCH v8 14/20] KVM: selftests: Verify non-postable IRQ remapping " Sean Christopherson
2026-06-26 21:35 ` [PATCH v8 15/20] KVM: selftests: Add kvm_gettid() wrapper and convert users Sean Christopherson
2026-06-26 21:35 ` [PATCH v8 16/20] KVM: selftests: Add kvm_sched_getaffinity() " Sean Christopherson
2026-06-26 21:35 ` [PATCH v8 17/20] KVM: selftests: Add a utility to pin a task to a random CPU, given a CPU set Sean Christopherson
2026-06-26 21:35 ` [PATCH v8 18/20] KVM: selftests: Verify vCPU migration during IRQ delivery in IRQ test Sean Christopherson
2026-06-26 21:35 ` [PATCH v8 19/20] KVM: selftests: Make number of vCPUs configurable " Sean Christopherson
2026-06-26 21:35 ` [PATCH v8 20/20] KVM: selftests: Add xAPIC support in eventfd " Sean Christopherson
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=20260626213534.3866178-13-seanjc@google.com \
--to=seanjc@google.com \
--cc=dmatlack@google.com \
--cc=joey.gouly@arm.com \
--cc=jrhilke@google.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maz@kernel.org \
--cc=oupton@kernel.org \
--cc=pbonzini@redhat.com \
--cc=seiden@linux.ibm.com \
--cc=suzuki.poulose@arm.com \
--cc=yuzenghui@huawei.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