| 62838fa5 | 26-Feb-2025 |
Sean Christopherson <[email protected]> |
KVM: selftests: Relax assertion on HLT exits if CPU supports Idle HLT
If the CPU supports Idle HLT, which elides HLT VM-Exits if the vCPU has an unmasked pending IRQ or NMI, relax the xAPIC IPI test
KVM: selftests: Relax assertion on HLT exits if CPU supports Idle HLT
If the CPU supports Idle HLT, which elides HLT VM-Exits if the vCPU has an unmasked pending IRQ or NMI, relax the xAPIC IPI test's assertion on the number of HLT exits to only require that the number of exits is less than or equal to the number of HLT instructions that were executed. I.e. don't fail the test if Idle HLT does what it's supposed to do.
Note, unfortunately there's no way to determine if *KVM* supports Idle HLT, as this_cpu_has() checks raw CPU support, and kvm_cpu_has() checks what can be exposed to L1, i.e. the latter would check if KVM supports nested Idle HLT. But, since the assert is purely bonus coverage, checking for CPU support is good enough.
Cc: Manali Shukla <[email protected]> Tested-by: Manali Shukla <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
show more ...
|
| 16fc7cb4 | 11-Jan-2025 |
Sean Christopherson <[email protected]> |
KVM: selftests: Add infrastructure for getting vCPU binary stats
Now that the binary stats cache infrastructure is largely scope agnostic, add support for vCPU-scoped stats. Like VM stats, open and
KVM: selftests: Add infrastructure for getting vCPU binary stats
Now that the binary stats cache infrastructure is largely scope agnostic, add support for vCPU-scoped stats. Like VM stats, open and cache the stats FD when the vCPU is created so that it's guaranteed to be valid when vcpu_get_stats() is invoked.
Account for the extra per-vCPU file descriptor in kvm_set_files_rlimit(), so that tests that create large VMs don't run afoul of resource limits.
To sanity check that the infrastructure actually works, and to get a bit of bonus coverage, add an assert in x86's xapic_ipi_test to verify that the number of HLTs executed by the test matches the number of HLT exits observed by KVM.
Tested-by: Manali Shukla <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
show more ...
|
| 54108e73 | 17-Jan-2025 |
Sean Christopherson <[email protected]> |
KVM: selftests: Print out the actual Top-Down Slots count on failure
Print out the expected vs. actual count of the Top-Down Slots event on failure in the Intel PMU counters test. GUEST_ASSERT() on
KVM: selftests: Print out the actual Top-Down Slots count on failure
Print out the expected vs. actual count of the Top-Down Slots event on failure in the Intel PMU counters test. GUEST_ASSERT() only expands constants/macros, i.e. only prints the value of the expected count, which makes it difficult to debug and triage failures.
Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
show more ...
|
| 0e671473 | 17-Jan-2025 |
Sean Christopherson <[email protected]> |
KVM: selftests: Drop the "feature event" param from guest test helpers
Now that validation of event count is tied to hardware support for event, and not to guest support for an event, drop the unuse
KVM: selftests: Drop the "feature event" param from guest test helpers
Now that validation of event count is tied to hardware support for event, and not to guest support for an event, drop the unused "event" parameter from the various helpers.
No functional change intended.
Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
show more ...
|
| e327630e | 17-Jan-2025 |
Sean Christopherson <[email protected]> |
KVM: selftests: Remove dead code in Intel PMU counters test
Drop the local "nr_arch_events" in the Intel PMU counters test as the test asserts that "nr_arch_events <= NR_INTEL_ARCH_EVENTS", and then
KVM: selftests: Remove dead code in Intel PMU counters test
Drop the local "nr_arch_events" in the Intel PMU counters test as the test asserts that "nr_arch_events <= NR_INTEL_ARCH_EVENTS", and then sets nr_arch_events to the max of the two. I.e. nr_arch_events is guaranteed to be NR_INTEL_ARCH_EVENTS for the meat of the test, just use NR_INTEL_ARCH_EVENTS directly.
No functional change intended.
Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
show more ...
|
| 8752e2b4 | 17-Jan-2025 |
Sean Christopherson <[email protected]> |
KVM: selftests: Only validate counts for hardware-supported arch events
In the Intel PMU counters test, only validate the counts for architectural events that are supported in hardware. If an arch
KVM: selftests: Only validate counts for hardware-supported arch events
In the Intel PMU counters test, only validate the counts for architectural events that are supported in hardware. If an arch event isn't supported, the event selector may enable a completely different event, and thus the logic for the expected count is bogus.
This fixes test failures on pre-Icelake systems due to the encoding for the architectural Top-Down Slots event corresponding to something else (at least on the Skylake family of CPUs).
Note, validation relies on *hardware* support, not KVM support and not guest support. Architectural events are all about enumerating the event selector encoding; lack of enumeration for an architectural event doesn't mean the event itself is unsupported, i.e. the event should still count as expected even if KVM and/or guest CPUID doesn't enumerate the event as being "architectural".
Note #2, it's desirable to _program_ the architectural event encoding even if hardware doesn't support the event. The count can't be validated when the event is fully enabled, but KVM should still let the guest program the event selector, and the PMC shouldn't count if the event is disabled.
Fixes: 4f1bd6b16074 ("KVM: selftests: Test Intel PMU architectural events on gp counters") Reported-by: kernel test robot <[email protected]> Closes: https://lore.kernel.org/oe-lkp/[email protected] Debugged-by: Dapeng Mi <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
show more ...
|
| 933178dd | 17-Jan-2025 |
Sean Christopherson <[email protected]> |
KVM: selftests: Make Intel arch events globally available in PMU counters test
Wrap PMU counter test's array of Intel architectrual in a helper function so that the events can be queried in multiple
KVM: selftests: Make Intel arch events globally available in PMU counters test
Wrap PMU counter test's array of Intel architectrual in a helper function so that the events can be queried in multiple locations. Add a comment to explain the need for a wrapper.
No functional change intended.
Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
show more ...
|
| 983820cb | 20-Dec-2024 |
Sean Christopherson <[email protected]> |
KVM: selftests: Add helpers for locally (un)blocking IRQs on x86
Copy KVM-Unit-Tests' x86 helpers for emitting STI and CLI, comments and all, and use them throughout x86 selftests. The safe_halt()
KVM: selftests: Add helpers for locally (un)blocking IRQs on x86
Copy KVM-Unit-Tests' x86 helpers for emitting STI and CLI, comments and all, and use them throughout x86 selftests. The safe_halt() and sti_nop() logic in particular benefits from centralized comments, as the behavior isn't obvious unless the reader is already aware of the STI shadow.
Cc: Manali Shukla <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
show more ...
|
| 7803339f | 27-Nov-2024 |
Sean Christopherson <[email protected]> |
KVM: selftests: Use data load to trigger LLC references/misses in Intel PMU
In the PMU counters test, add a data load in the measured loop and target the data with CLFLUSH{OPT} in order to (try to)
KVM: selftests: Use data load to trigger LLC references/misses in Intel PMU
In the PMU counters test, add a data load in the measured loop and target the data with CLFLUSH{OPT} in order to (try to) guarantee the loop generates LLC misses and fills. Per the SDM, some hardware prefetchers are allowed to omit relevant PMU events, and Emerald Rapids (and possibly Sapphire Rapids) appears to have gained an instruction prefetcher that bypasses event counts. E.g. the test will consistently fail on EMR CPUs, but then pass with seemingly benign changes to the code.
The event count includes speculation and cache line fills due to the first-level cache hardware prefetcher, but may exclude cache line fills due to other hardware-prefetchers.
Generate a data load as a last ditch effort to preserve the (minimal) test coverage for LLC references and misses.
Cc: Maxim Levitsky <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
show more ...
|
| 59cb3acd | 28-Nov-2024 |
Sean Christopherson <[email protected]> |
KVM: selftests: Update x86's KVM PV test to match KVM's disabling exits behavior
Rework x86's KVM PV features test to align with KVM's new, fixed behavior of not allowing userspace to disable HLT-ex
KVM: selftests: Update x86's KVM PV test to match KVM's disabling exits behavior
Rework x86's KVM PV features test to align with KVM's new, fixed behavior of not allowing userspace to disable HLT-exiting after vCPUs have been created. Rework the core testcase to disable HLT-exiting before creating a vCPU, and opportunistically modify keep the paired VM+vCPU creation to verify that KVM rejects KVM_CAP_X86_DISABLE_EXITS as expected.
Reviewed-by: Maxim Levitsky <[email protected]> Reviewed-by: Binbin Wu <[email protected]> Reviewed-by: Xiaoyao Li <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
show more ...
|
| 7b2658cb | 28-Nov-2024 |
Sean Christopherson <[email protected]> |
KVM: selftests: Fix a bad TEST_REQUIRE() in x86's KVM PV test
Actually check for KVM support for disabling HLT-exiting instead of effectively checking that KVM_CAP_X86_DISABLE_EXITS is #defined to a
KVM: selftests: Fix a bad TEST_REQUIRE() in x86's KVM PV test
Actually check for KVM support for disabling HLT-exiting instead of effectively checking that KVM_CAP_X86_DISABLE_EXITS is #defined to a non-zero value, and convert the TEST_REQUIRE() to a simple return so that only the sub-test is skipped if HLT-exiting is mandatory.
The goof has likely gone unnoticed because all x86 CPUs support disabling HLT-exiting, only systems with the opt-in mitigate_smt_rsb KVM module param disallow HLT-exiting.
Reviewed-by: Maxim Levitsky <[email protected]> Reviewed-by: Binbin Wu <[email protected]> Reviewed-by: Xiaoyao Li <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
show more ...
|
| 01bcd829 | 28-Nov-2024 |
Sean Christopherson <[email protected]> |
KVM: selftests: Verify KVM stuffs runtime CPUID OS bits on CR4 writes
Extend x86's set sregs test to verify that KVM sets/clears OSXSAVE and OSKPKE according to CR4.XSAVE and CR4.PKE respectively.
KVM: selftests: Verify KVM stuffs runtime CPUID OS bits on CR4 writes
Extend x86's set sregs test to verify that KVM sets/clears OSXSAVE and OSKPKE according to CR4.XSAVE and CR4.PKE respectively. For performance reasons, KVM is responsible for emulating the architectural behavior of the OS CPUID bits tracking CR4.
Reviewed-by: Maxim Levitsky <[email protected]> Reviewed-by: Binbin Wu <[email protected]> Reviewed-by: Xiaoyao Li <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
show more ...
|
| bf4dfc3a | 28-Nov-2024 |
Sean Christopherson <[email protected]> |
KVM: selftests: Update x86's set_sregs_test to match KVM's CPUID enforcement
Rework x86's set sregs test to verify that KVM enforces CPUID vs. CR4 features even if userspace hasn't explicitly set gu
KVM: selftests: Update x86's set_sregs_test to match KVM's CPUID enforcement
Rework x86's set sregs test to verify that KVM enforces CPUID vs. CR4 features even if userspace hasn't explicitly set guest CPUID. KVM used to allow userspace to set any KVM-supported CR4 value prior to KVM_SET_CPUID2, and the test verified that behavior.
However, the testcase was written purely to verify KVM's existing behavior, i.e. was NOT written to match the needs of real world VMMs.
Opportunistically verify that KVM continues to reject unsupported features after KVM_SET_CPUID2 (using KVM_GET_SUPPORTED_CPUID).
Reviewed-by: Maxim Levitsky <[email protected]> Reviewed-by: Binbin Wu <[email protected]> Reviewed-by: Xiaoyao Li <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
show more ...
|