summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/kvm/include/x86
diff options
context:
space:
mode:
authorJim Mattson <jmattson@google.com>2026-06-09 17:30:30 -0700
committerSean Christopherson <seanjc@google.com>2026-06-17 17:56:17 -0700
commit70f4701c12e4bb6214f0ec762f928e96ff3dacc3 (patch)
tree71f099c12e5a18c30f4d57a60935a709a644b531 /tools/testing/selftests/kvm/include/x86
parent0c277410f5314bab45f92051b246d39d02923b64 (diff)
downloadlinux-next-70f4701c12e4bb6214f0ec762f928e96ff3dacc3.tar.gz
linux-next-70f4701c12e4bb6214f0ec762f928e96ff3dacc3.zip
KVM: selftests: Add svm_pmu_host_guest_test for Host-Only/Guest-Only bits
Add a selftest to verify KVM correctly virtualizes the AMD PMU Host-Only (bit 41) and Guest-Only (bit 40) event selector bits across all relevant SVM state transitions. The test programs 4 PMCs simultaneously with all combinations of the Host-Only and Guest-Only bits, then verifies correct counting behavior with EFER.SVME clear and set, as well as in host mode and guest mode. The test also verifies that updating Host-Only / Guest-Only bits for a PMC works as intended, and that event filtering is still respected. Signed-off-by: Jim Mattson <jmattson@google.com> Co-developed-by: Yosry Ahmed <yosry@kernel.org> Signed-off-by: Yosry Ahmed <yosry@kernel.org> Link: https://patch.msgid.link/20260610003030.2957261-6-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
Diffstat (limited to 'tools/testing/selftests/kvm/include/x86')
-rw-r--r--tools/testing/selftests/kvm/include/x86/pmu.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/tools/testing/selftests/kvm/include/x86/pmu.h b/tools/testing/selftests/kvm/include/x86/pmu.h
index 98537cc8840d..608ed83d7c6a 100644
--- a/tools/testing/selftests/kvm/include/x86/pmu.h
+++ b/tools/testing/selftests/kvm/include/x86/pmu.h
@@ -38,6 +38,12 @@
#define ARCH_PERFMON_EVENTSEL_INV BIT_ULL(23)
#define ARCH_PERFMON_EVENTSEL_CMASK GENMASK_ULL(31, 24)
+/*
+ * These are AMD-specific bits.
+ */
+#define AMD64_EVENTSEL_GUESTONLY BIT_ULL(40)
+#define AMD64_EVENTSEL_HOSTONLY BIT_ULL(41)
+
/* RDPMC control flags, Intel only. */
#define INTEL_RDPMC_METRICS BIT_ULL(29)
#define INTEL_RDPMC_FIXED BIT_ULL(30)