From: Josh Hilke <jrhilke@google.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
Sean Christopherson <seanjc@google.com>
Cc: kvm@vger.kernel.org, David Matlack <dmatlack@google.com>,
Alex Williamson <alex@shazbot.org>,
Josh Hilke <jrhilke@google.com>
Subject: [PATCH v2 06/14] KVM: selftests: Allow blocking vCPUs via HLT
Date: Tue, 31 Mar 2026 19:40:25 +0000 [thread overview]
Message-ID: <20260331194033.3890309-7-jrhilke@google.com> (raw)
In-Reply-To: <20260331194033.3890309-1-jrhilke@google.com>
From: David Matlack <dmatlack@google.com>
Add the '-b' flag to vfio_pci_irq_test to test IRQ delivery while
vCPUs are in a halted state. This verifies that interrupts correctly
wake vCPUs from HLT, which is a critical path for both power
management and correct architectural behavior during asynchronous events.
Signed-off-by: David Matlack <dmatlack@google.com>
Signed-off-by: Josh Hilke <jrhilke@google.com>
Co-developed-by: Josh Hilke <jrhilke@google.com>
---
.../testing/selftests/kvm/vfio_pci_irq_test.c | 21 ++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/kvm/vfio_pci_irq_test.c b/tools/testing/selftests/kvm/vfio_pci_irq_test.c
index 1957d1b7bbf2..98dc1f4a7836 100644
--- a/tools/testing/selftests/kvm/vfio_pci_irq_test.c
+++ b/tools/testing/selftests/kvm/vfio_pci_irq_test.c
@@ -16,6 +16,7 @@
#include <libvfio.h>
static bool done;
+static bool block;
static bool guest_ready_for_irqs[KVM_MAX_VCPUS];
static bool guest_received_irq[KVM_MAX_VCPUS];
@@ -42,7 +43,10 @@ static void guest_code(void)
WRITE_ONCE(guest_ready_for_irqs[guest_get_vcpu_id()], true);
while (!READ_ONCE(done)) {
- cpu_relax();
+ if (block)
+ hlt();
+ else
+ cpu_relax();
}
GUEST_DONE();
@@ -88,11 +92,12 @@ static void send_msi(struct vfio_pci_device *device, int msi)
static void help(const char *name)
{
- printf("Usage: %s [-a] [-h] segment:bus:device.function\n",
+ printf("Usage: %s [-a] [-b] [-h] segment:bus:device.function\n",
name);
printf("\n");
printf(" -a: Randomly affinitize the device IRQ to different CPUs\n"
" throughout the test.\n");
+ printf(" -b: Block vCPUs (e.g. HLT) instead of spinning in guest-mode\n");
printf("\n");
exit(KSFT_FAIL);
}
@@ -133,11 +138,14 @@ int main(int argc, char **argv)
device_bdf = vfio_selftests_get_bdf(&argc, argv);
- while ((c = getopt(argc, argv, "ah")) != -1) {
+ while ((c = getopt(argc, argv, "abh")) != -1) {
switch (c) {
case 'a':
irq_affinity = true;
break;
+ case 'b':
+ block = true;
+ break;
case 'h':
default:
help(argv[0]);
@@ -162,6 +170,8 @@ int main(int argc, char **argv)
kvm_assign_irqfd(vm, gsi, device->msi_eventfds[msi]);
+ sync_global_to_guest(vm, block);
+
for (i = 0; i < nr_vcpus; i++)
pthread_create(&vcpu_threads[i], NULL, vcpu_thread_main, vcpus[i]);
@@ -226,6 +236,11 @@ int main(int argc, char **argv)
WRITE_TO_GUEST(vm, done, true);
for (i = 0; i < nr_vcpus; i++) {
+ if (block) {
+ kvm_route_msi(vm, gsi, vcpus[i], vector);
+ send_msi(device, msi);
+ }
+
pthread_join(vcpu_threads[i], NULL);
}
--
2.53.0.1118.gaef5881109-goog
next prev parent reply other threads:[~2026-03-31 19:41 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Josh Hilke [this message]
2026-04-01 20:03 ` [PATCH v2 06/14] KVM: selftests: Allow blocking vCPUs via HLT 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
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=20260331194033.3890309-7-jrhilke@google.com \
--to=jrhilke@google.com \
--cc=alex@shazbot.org \
--cc=dmatlack@google.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