KVM: selftests: x86: Fix test failure on arch lbr capable platforms
PATCH v2 1/1 KVM: selftests: x86: Fix test failure on arch lbr capable platforms
On Arch LBR capable platforms, LBR_FMT in perf capability msr is 0x3f, so the last format test will fail. Use a true invalid format(0x30) for the test if it's running on these platforms. Opportunistically change the file name to reflect the tests actually carried out.
v2:
Select a true invalid format instead of skipping the test on arch lbr capable platforms.
---
tools/testing/selftests/kvm/Makefile | 2 +-
...vmx_pmu_msrs_test.c => vmx_pmu_caps_test.c} | 18 ++++++++++--------
2 files changed, 11 insertions(+), 9 deletions(-)
rename tools/testing/selftests/kvm/x86_64/{vmx_pmu_msrs_test.c => vmx_pmu_caps_test.c} (83%)tools/testing/selftests/kvm/Makefile +1 -1
@@ -81,7 +81,7 @@ TEST_GEN_PROGS_x86_64 += x86_64/xapic_state_test TEST_GEN_PROGS_x86_64 += x86_64/xss_msr_test TEST_GEN_PROGS_x86_64 += x86_64/debug_regs TEST_GEN_PROGS_x86_64 += x86_64/tsc_msrs_test -TEST_GEN_PROGS_x86_64 += x86_64/vmx_pmu_msrs_test +TEST_GEN_PROGS_x86_64 += x86_64/vmx_pmu_caps_test TEST_GEN_PROGS_x86_64 += x86_64/xen_shinfo_test TEST_GEN_PROGS_x86_64 += x86_64/xen_vmcall_test TEST_GEN_PROGS_x86_64 += x86_64/sev_migrate_tests
tools/testing/selftests/kvm/x86_64/vmx_pmu_caps_test.c renamed from tools/testing/selftests/kvm/x86_64/vmx_pmu_msrs_test.c +10 -8
@@ -1,15 +1,14 @@// SPDX-License-Identifier: GPL-2.0 /* -* VMX-pmu related msrs test +* Test for VMX-pmu perf capability msr * * Copyright (C) 2021 Intel Corporation * -* Test to check the effect of various CPUID settings -* on the MSR_IA32_PERF_CAPABILITIES MSR, and check that -* whatever we write with KVM_SET_MSR is _not_ modified -* in the guest and test it can be retrieved with KVM_GET_MSR. -* -* Test to check that invalid LBR formats are rejected. +* Test to check the effect of various CPUID settings on +* MSR_IA32_PERF_CAPABILITIES MSR, and check that what +* we write with KVM_SET_MSR is _not_ modified by the guest +* and check it can be retrieved with KVM_GET_MSR, also test +* the invalid LBR formats are rejected. */ #define _GNU_SOURCE/* for program_invocation_short_name */
@@ -107,8 +106,11 @@ int main(int argc, char *argv[])ASSERT_EQ (vcpu_get_msr (vm,VCPU_ID ,MSR_IA32_PERF_CAPABILITIES ), (u64 )host_cap.lbr_format);/* testcase 3, check invalid LBR format is rejected */ - ret =_vcpu_set_msr (vm,0 ,MSR_IA32_PERF_CAPABILITIES ,PMU_CAP_LBR_FMT ); +/* Note, on Arch LBR capable platforms, LBR_FMT in perf capability msr is 0x3f, +* to avoid the failure, use a true invalid format 0x30 for the test. */ + ret =_vcpu_set_msr (vm,0 ,MSR_IA32_PERF_CAPABILITIES ,0x30 );TEST_ASSERT (ret ==0 ,"Bad PERF_CAPABILITIES didn't fail." ); +printf ("Completed perf capability tests.\n" );kvm_vm_free (vm); }
base-commit: 672c0c5173427e6b3e2a9bbb7be51ceeec78093a
Signature · 1 line
2.27.0
Quoted 73 lines · Yang Weijiang
On Arch LBR capable platforms,
LBR_FMTin perf capability msr is0x3f, so the last format test will fail. Use a true invalid format(0x30) for the test if it's running on these platforms. Opportunistically change the file name to reflect the tests actually carried out.v2:
Select a true invalid format instead of skipping the test on arch lbr capable platforms.Suggested-by Paolo Bonzini <[email protected]>Signed-off-by Yang Weijiang <[email protected]>--- tools/testing/selftests/kvm/Makefile | 2 +- ...vmx_pmu_msrs_test.c => vmx_pmu_caps_test.c} | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-)rename
tools/testing/selftests/kvm/x86_64/{vmx_pmu_msrs_test.c=>vmx_pmu_caps_test.c} (83%)tools/testing/selftests/kvm/Makefile +1
-1@@ -81,7 +81,7 @@ TEST_GEN_PROGS_x86_64 += x86_64/xapic_state_test TEST_GEN_PROGS_x86_64 += x86_64/xss_msr_test TEST_GEN_PROGS_x86_64 += x86_64/debug_regs TEST_GEN_PROGS_x86_64 += x86_64/tsc_msrs_test -TEST_GEN_PROGS_x86_64 += x86_64/vmx_pmu_msrs_test +TEST_GEN_PROGS_x86_64 += x86_64/vmx_pmu_caps_test TEST_GEN_PROGS_x86_64 += x86_64/xen_shinfo_test TEST_GEN_PROGS_x86_64 += x86_64/xen_vmcall_test TEST_GEN_PROGS_x86_64 += x86_64/sev_migrate_teststools/testing/selftests/kvm/x86_64/vmx_pmu_caps_test.c renamed from tools/testing/selftests/kvm/x86_64/vmx_pmu_msrs_test.c +10
-8@@ -1,15 +1,14 @@// SPDX-License-Identifier: GPL-2.0 /* -* VMX-pmu related msrs test +* Test for VMX-pmu perf capability msr * * Copyright (C) 2021 Intel Corporation * -* Test to check the effect of various CPUID settings -* on the MSR_IA32_PERF_CAPABILITIES MSR, and check that -* whatever we write with KVM_SET_MSR is _not_ modified -* in the guest and test it can be retrieved with KVM_GET_MSR. -* -* Test to check that invalid LBR formats are rejected. +* Test to check the effect of various CPUID settings on +* MSR_IA32_PERF_CAPABILITIES MSR, and check that what +* we write with KVM_SET_MSR is _not_ modified by the guest +* and check it can be retrieved with KVM_GET_MSR, also test +* the invalid LBR formats are rejected. */ #define _GNU_SOURCE/* for program_invocation_short_name */ @@ -107,8 +106,11 @@ int main(int argc, char *argv[])ASSERT_EQ (vcpu_get_msr (vm,VCPU_ID ,MSR_IA32_PERF_CAPABILITIES ), (u64 )host_cap.lbr_format);/* testcase 3, check invalid LBR format is rejected */ - ret =_vcpu_set_msr (vm,0 ,MSR_IA32_PERF_CAPABILITIES ,PMU_CAP_LBR_FMT ); +/* Note, on Arch LBR capable platforms, LBR_FMT in perf capability msr is 0x3f, +* to avoid the failure, use a true invalid format 0x30 for the test. */ + ret =_vcpu_set_msr (vm,0 ,MSR_IA32_PERF_CAPABILITIES ,0x30 );TEST_ASSERT (ret ==0 ,"Bad PERF_CAPABILITIES didn't fail." ); +printf ("Completed perf capability tests.\n" );kvm_vm_free (vm); }
Quoted 1 line
base-commit:
672c0c5173427e6b3e2a9bbb7be51ceeec78093a
Applied, thanks.
Paolo