[PATCH 22/23] KVM: selftests: Fix PERF_METRICS test by checking FC3 availability
Zide Chen <[email protected]>
| Newsgroups | org.kernel.vger.kvm,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
IA32_PERF_CAPABILITIES.PERF_METRICS_AVAILABLE[bit 15] is not tied to a particular PMU version, and userspace can enable it as long as it is advertised. On a PERF_METRICS capable host that supports fixed counter 3 through a non-contiguous fixed counter bitmap, userspace may enable this capability while configuring a guest PMU version lower than 5. This scenario is unlikely on bare-metal systems, but it can occur with PMU partitioning. For example, when kvm-intel is loaded with: perfmon_mask=guest_fixed=1-3;perf_metrics CPUID.0AH:ECX[4:0] is 0, and thus fixed counter 3 is not available when the guest PMU version is below 5. Skip the test in this case. Signed-off-by: Zide Chen <[email protected]> --- tools/testing/selftests/kvm/x86/pmu_counters_test.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/kvm/x86/pmu_counters_test.c b/tools/testing/selftests/kvm/x86/pmu_counters_test.c index 2797d7e0e3a3..edcd04b4111c 100644 --- a/tools/testing/selftests/kvm/x86/pmu_counters_test.c +++ b/tools/testing/selftests/kvm/x86/pmu_counters_test.c @@ -678,7 +678,8 @@ static void __guest_test_perf_metrics(void) if ((guest_get_pmu_version() < 2) || /* Does guest have GLOBAL_CTRL? */ !this_cpu_has(X86_FEATURE_PDCM) || - !(rdmsr(MSR_IA32_PERF_CAPABILITIES) & PERF_CAP_PERF_METRICS)) + !(rdmsr(MSR_IA32_PERF_CAPABILITIES) & PERF_CAP_PERF_METRICS) || + !this_pmu_has(X86_PMU_FEATURE_TOPDOWN_SLOTS_FIXED)) return; wrmsr(MSR_CORE_PERF_GLOBAL_CTRL, 0); -- 2.55.0