Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
	 Sean Christopherson <seanjc@google.com>
Subject: [GIT PULL] KVM: x86: KVM: Selftests change for 7.3, part 2
Date: Wed, 12 Aug 2026 14:32:03 -0700	[thread overview]
Message-ID: <20260812213206.1564354-9-seanjc@google.com> (raw)
In-Reply-To: <20260812213206.1564354-1-seanjc@google.com>

Selftests, part 2.  This was originally just the irq_test from David and Josh,
but I piled on fixes for hardware_disable_test and pmu_counters_test that rely
on the pRNG changes/enhancements.

There have been a few hiccups with linking to the VFIO selfest library, but I
think they're all sorted out.  I.e. this should Just Work on your end.

As mentioned in the cover letter, this will conflict with part 1.  Part 2 just
adds syscall wrappers, i.e. keep the functional test changes from part 1, but
use the newfangled wrappers from part 2.

diff --cc tools/testing/selftests/kvm/steal_time.c
index 92e7ffcd68b7,83a1e3aa15cf..6e9cc0e34ec0
--- tools/testing/selftests/kvm/steal_time.c
+++ tools/testing/selftests/kvm/steal_time.c
@@@ -553,11 -553,7 +548,11 @@@ int main(int ac, char **av
  
                /* Steal time from the VCPU. The steal time thread has the same CPU affinity as the VCPUs. */
                run_delay = get_run_delay();
-               pthread_create(&thread, NULL, do_steal_time, NULL);
-               pthread_getaffinity_np(thread, sizeof(cpuset), &cpuset);
 -              kvm_pthread_create(&thread, &attr, do_steal_time, NULL);
++              kvm_pthread_create(&thread, NULL, do_steal_time, NULL);
++              kvm_pthread_getaffinity_np(thread, sizeof(cpuset), &cpuset);
 +              TEST_ASSERT(CPU_COUNT(&cpuset) == 1 && CPU_ISSET(cpu, &cpuset),
 +                          "Worker failed to inherit parent's CPU affinity");
 +
                do
                        sched_yield();
                while (get_run_delay() - run_delay < MIN_RUN_DELAY_NS);

The following changes since commit 8cdeaa50eae8dad34885515f62559ee83e7e8dda:

  Linux 7.2-rc2 (2026-07-05 14:44:06 -1000)

are available in the Git repository at:

  https://github.com/kvm-x86/linux.git tags/kvm-x86-selftests2-7.3

for you to fetch changes up to 4fe8b4e1545a0179ceebe098cce0dcfe9134a6cd:

  KVM: selftests: Create one VM with many vCPUs for each major PMU counters test (2026-08-10 08:04:13 -0700)

----------------------------------------------------------------
KVM selftests changes for 7.3, part 2

 - Fix several issues with seeding KVM's pRNG, and rework the pRNG APIs to that
   the pRNG can be sanely used in host code, not just guest code.

 - Add an IRQ test to validate virtual IRQ deliverty for IRQs wired up via
   KVM_IRQFD + KVM_SET_GSI_ROUTING, with optional support for triggering IRQs
   via writes to an assigned VFIO device.

 - Add syscall wrappers to assert success on a variety of pthreads and CPU
   affinity APIs.

 - Set vCPU pthread affinity as early as possible to reduce contention issues
   that were surfaced by PREEMPT_LAZY, which result in runtimes of over a
   minute on large hosts, versus the expected ~5 seconds.

 - Rework the PMU counters test to run each testcase using a single VM with
   many vCPUs for each sub-testcase, instead of using a unique VM for each
   sub-testcase.  This cuts the runtime by ~20x.

----------------------------------------------------------------
David Matlack (11):
      KVM: selftests: Build and link selftests/vfio/lib into KVM selftests
      KVM: selftests: Add macros to read/write+sync to/from guest memory
      KVM: selftests: Add an irqfd send+receive (and later IRQ bypass) test
      KVM: selftests: Add helper to get host IRQ from device MSI-X for IRQ bypass test
      KVM: selftests: Add VFIO device support to eventfd IRQ test
      KVM: selftests: Verify interrupts are received when IRQ affinity changes in IRQ test
      KVM: selftests: Add option to set empty routing between IRQs in eventfd IRQ test
      KVM: selftests: Make number of IRQs configurable in IRQ test
      KVM: selftests: Verify vCPU migration during IRQ delivery in IRQ test
      KVM: selftests: Make number of vCPUs configurable in IRQ test
      KVM: selftests: Add xAPIC support in eventfd IRQ test

Josh Hilke (6):
      KVM: selftests: Rename guest_rng to kvm_rng
      KVM: selftests: Add helper to generate random u64 in range [min,max]
      KVM: selftests: Add a helper to set proc IRQ affinity for IRQ test
      KVM: selftests: Add kvm_gettid() wrapper and convert users
      KVM: selftests: Add kvm_sched_getaffinity() wrapper and convert users
      KVM: selftests: Add a utility to pin a task to a random CPU, given a CPU set

Sean Christopherson (18):
      KVM: selftests: Initialize the default/global pRNG during kvm_selftest_init()
      KVM: selftests: Seed libc's RNG before using it to generate a seed for KVM's pRNG
      KVM: selftests: Verify non-postable IRQ remapping in IRQ test
      KVM: selftests: Only link to VFIO library on x86
      KVM: selftests: Add a KVM syscall wrapper for sched_setaffinity()
      KVM: selftests: Set threads CPU affinity before doing work in hardware disable test
      KVM: selftests: Pre-set threads affinity in hardware disable test when possible
      KVM: selftests: Return the target CPU from pin_task_to_random_cpu()
      KVM: selftests: Extract picking of random CPU from cpu_set_t to separate API
      KVM: selftests: Affine threads to random CPUs in hardware disable test
      KVM: selftests: Drop unreachable, dead code from hardware disable test
      KVM: selftests: Add KVM syscall wrapper for pthread_create()
      KVM: selftests: Add KVM syscall wrappers for pthread_{cancel,join}()
      KVM: selftests: Add helper APIs to cancel+join pthreads
      KVM: selftests: Clean up global constants in hardware disable test
      KVM: selftests: Add KVM syscall wrappers for pthread_{g,s}etaffinity_np()
      KVM: selftests: Test one random GP counter in PMU arch events testcase
      KVM: selftests: Create one VM with many vCPUs for each major PMU counters test

 tools/testing/selftests/kvm/Makefile.kvm                       |  12 +++-
 tools/testing/selftests/kvm/arch_timer.c                       |  20 ++----
 tools/testing/selftests/kvm/arm64/arch_timer_edge_cases.c      |   2 +-
 tools/testing/selftests/kvm/arm64/vgic_irq.c                   |  14 ++--
 tools/testing/selftests/kvm/arm64/vgic_lpi_stress.c            |   8 +--
 tools/testing/selftests/kvm/demand_paging_test.c               |   2 +-
 tools/testing/selftests/kvm/dirty_log_perf_test.c              |   4 +-
 tools/testing/selftests/kvm/dirty_log_test.c                   |  15 ++---
 tools/testing/selftests/kvm/hardware_disable_test.c            | 109 ++++++++++++++-----------------
 tools/testing/selftests/kvm/include/kvm_syscalls.h             |  55 ++++++++++++++++
 tools/testing/selftests/kvm/include/kvm_util.h                 |  21 ++++++
 tools/testing/selftests/kvm/include/proc_util.h                |  11 ++++
 tools/testing/selftests/kvm/include/test_util.h                |  25 +++----
 tools/testing/selftests/kvm/include/x86/kvm_util_arch.h        |   4 +-
 tools/testing/selftests/kvm/irq_test.c                         | 362 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 tools/testing/selftests/kvm/irqfd_test.c                       |   4 +-
 tools/testing/selftests/kvm/kvm_page_table_test.c              |   6 +-
 tools/testing/selftests/kvm/lib/assert.c                       |   8 +--
 tools/testing/selftests/kvm/lib/kvm_util.c                     |  52 +++++++++++----
 tools/testing/selftests/kvm/lib/memstress.c                    |  12 ++--
 tools/testing/selftests/kvm/lib/proc_util.c                    |  54 ++++++++++++++++
 tools/testing/selftests/kvm/lib/test_util.c                    |  41 ++++++++++--
 tools/testing/selftests/kvm/lib/userfaultfd_util.c             |   7 +-
 tools/testing/selftests/kvm/memslot_perf_test.c                |   4 +-
 tools/testing/selftests/kvm/mmu_stress_test.c                  |  19 ++----
 tools/testing/selftests/kvm/pre_fault_memory_test.c            |   4 +-
 tools/testing/selftests/kvm/rseq_test.c                        |  16 ++---
 tools/testing/selftests/kvm/s390/memop.c                       |   4 +-
 tools/testing/selftests/kvm/set_memory_region_test.c           |   6 +-
 tools/testing/selftests/kvm/steal_time.c                       |  26 +++-----
 tools/testing/selftests/kvm/x86/hyperv_ipi.c                   |  32 ++-------
 tools/testing/selftests/kvm/x86/hyperv_tlb_flush.c             |  30 ++-------
 tools/testing/selftests/kvm/x86/pmu_counters_test.c            | 227 ++++++++++++++++++++++++++++++++++++----------------------------
 tools/testing/selftests/kvm/x86/private_mem_conversions_test.c |   4 +-
 tools/testing/selftests/kvm/x86/private_mem_kvm_exits_test.c   |   7 +-
 tools/testing/selftests/kvm/x86/recalc_apic_map_test.c         |   5 +-
 tools/testing/selftests/kvm/x86/sev_dbg_test.c                 |   2 +-
 tools/testing/selftests/kvm/x86/sev_migrate_tests.c            |   4 +-
 tools/testing/selftests/kvm/x86/sync_regs_test.c               |   5 +-
 tools/testing/selftests/kvm/x86/tsc_scaling_sync.c             |   4 +-
 tools/testing/selftests/kvm/x86/xapic_ipi_test.c               |  31 ++-------
 tools/testing/selftests/kvm/x86/xen_shinfo_test.c              |  10 +--
 42 files changed, 883 insertions(+), 405 deletions(-)
 create mode 100644 tools/testing/selftests/kvm/include/proc_util.h
 create mode 100644 tools/testing/selftests/kvm/irq_test.c
 create mode 100644 tools/testing/selftests/kvm/lib/proc_util.c

  parent reply	other threads:[~2026-08-12 21:32 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-12 21:31 [GIT PULL] KVM: x86 pull requests for 7.3 Sean Christopherson
2026-08-12 21:31 ` [GIT PULL] KVM: x86: Xen clock/timekeeping changes " Sean Christopherson
2026-08-12 21:31 ` [GIT PULL] KVM: guest_memfd and x86 CoCo " Sean Christopherson
2026-08-12 21:31 ` [GIT PULL] KVM: Generic and documentation updates " Sean Christopherson
2026-08-12 21:31 ` [GIT PULL] KVM: MAINTAINERS " Sean Christopherson
2026-08-12 21:32 ` [GIT PULL] KVM: x86: Misc changes " Sean Christopherson
2026-08-12 21:32 ` [GIT PULL] KVM: x86: MMU " Sean Christopherson
2026-08-12 21:32 ` [GIT PULL] KVM: Selftests change for 7.3, part 1 Sean Christopherson
2026-08-12 21:32 ` Sean Christopherson [this message]
2026-08-12 21:32 ` [GIT PULL] KVM: x86: SVM changes for 7.3 Sean Christopherson
2026-08-12 21:32 ` [GIT PULL] KVM: x86: VMX " Sean Christopherson
2026-08-14 19:25 ` [GIT PULL] KVM: x86 pull requests " David Woodhouse
2026-08-15  7:55   ` Paolo Bonzini
2026-08-15 10:29     ` David Woodhouse
2026-08-17 14:40       ` 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=20260812213206.1564354-9-seanjc@google.com \
    --to=seanjc@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.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