KVM: selftests: x86: Skip unsupported test when Arch LBR is available
PATCH 1/1 KVM: selftests: x86: Skip unsupported test when Arch LBR is available
On Arch LBR capable platforms, LBR_FMT in perf capability msr is 0x3f, so skip invalid format test if it's running on these platforms. Opportunistically change the file name to reflect the tests actually carried out.
Signed-off-by Yang Weijiang <[email protected]>
---
tools/testing/selftests/kvm/Makefile | 2 +-
.../x86_64/{vmx_pmu_msrs_test.c => vmx_pmu_caps_test.c} | 9 +++++++--
2 files changed, 8 insertions(+), 3 deletions(-)
rename tools/testing/selftests/kvm/x86_64/{vmx_pmu_msrs_test.c => vmx_pmu_caps_test.c} (88%)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 +7 -2
@@ -107,8 +107,13 @@ 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 ); -TEST_ASSERT (ret ==0 ,"Bad PERF_CAPABILITIES didn't fail." ); +/* Note, on Arch LBR capable platforms, LBR_FMT in perf capability msr is 0x3f, +* so skip below test if running on these platforms. */ +if (host_cap.lbr_format !=PMU_CAP_LBR_FMT ) { + ret =_vcpu_set_msr (vm,0 ,MSR_IA32_PERF_CAPABILITIES ,PMU_CAP_LBR_FMT ); +TEST_ASSERT (ret ==0 ,"Bad PERF_CAPABILITIES didn't fail." ); + } +printf ("Completed pmu capability tests successfully.\n" );kvm_vm_free (vm); }
Signature · 1 line
2.27.0
Paolo Bonzini
maintainerHi,
tools/testing/selftests/kvm/x86_64/vmx_pmu_caps_test.c int main(int argc, char *argv[]) · line 115
Quoted 8 lines
tools/testing/selftests/kvm/x86_64/vmx_pmu_caps_test.c renamed from tools/testing/selftests/kvm/x86_64/vmx_pmu_msrs_test.c +6
-2- ret =_vcpu_set_msr (vm,0 ,MSR_IA32_PERF_CAPABILITIES ,PMU_CAP_LBR_FMT ); -TEST_ASSERT (ret ==0 ,"Bad PERF_CAPABILITIES didn't fail." ); +/* Note, on Arch LBR capable platforms, LBR_FMT in perf capability msr is 0x3f, +* so skip below test if running on these platforms. */ +if (host_cap.lbr_format !=PMU_CAP_LBR_FMT ) { + ret =_vcpu_set_msr (vm,0 ,MSR_IA32_PERF_CAPABILITIES ,PMU_CAP_LBR_FMT ); +TEST_ASSERT (ret ==0 ,"Bad PERF_CAPABILITIES didn't fail." ); + }
Why not try a different value?
Paolo
Quoted 11 lines · Paolo Bonzini
Hi,
tools/testing/selftests/kvm/x86_64/vmx_pmu_caps_test.c int main(int argc, char *argv[]) · line 115
Quoted 8 lines
tools/testing/selftests/kvm/x86_64/vmx_pmu_caps_test.c renamed from tools/testing/selftests/kvm/x86_64/vmx_pmu_msrs_test.c +6
-2- ret =_vcpu_set_msr (vm,0 ,MSR_IA32_PERF_CAPABILITIES ,PMU_CAP_LBR_FMT ); -TEST_ASSERT (ret ==0 ,"Bad PERF_CAPABILITIES didn't fail." ); +/* Note, on Arch LBR capable platforms, LBR_FMT in perf capability msr is 0x3f, +* so skip below test if running on these platforms. */ +if (host_cap.lbr_format !=PMU_CAP_LBR_FMT ) { + ret =_vcpu_set_msr (vm,0 ,MSR_IA32_PERF_CAPABILITIES ,PMU_CAP_LBR_FMT ); +TEST_ASSERT (ret ==0 ,"Bad PERF_CAPABILITIES didn't fail." ); + }Why not try a different value?
OK, I'll select a "real" invalid format and re-post the patch, thanks!
Quoted 4 lines
Paolo