From: Sean Christopherson Date: Sat, 11 Mar 2023 00:46:17 +0000 (-0800) Subject: KVM: selftests: Add negative testcase for PEBS format in PERF_CAPABILITIES X-Git-Tag: v6.6.7~2927^2~3^2~12 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8b95b4155523dcb5412a73c631c680098bcbbb40;p=platform%2Fkernel%2Flinux-starfive.git KVM: selftests: Add negative testcase for PEBS format in PERF_CAPABILITIES Expand the immutable features sub-test for PERF_CAPABILITIES to verify KVM rejects any attempt to use a PEBS format other than the host's. Link: https://lore.kernel.org/r/20230311004618.920745-21-seanjc@google.com Signed-off-by: Sean Christopherson --- diff --git a/tools/testing/selftests/kvm/x86_64/vmx_pmu_caps_test.c b/tools/testing/selftests/kvm/x86_64/vmx_pmu_caps_test.c index 38aec88..29aaa04 100644 --- a/tools/testing/selftests/kvm/x86_64/vmx_pmu_caps_test.c +++ b/tools/testing/selftests/kvm/x86_64/vmx_pmu_caps_test.c @@ -191,6 +191,16 @@ static void test_immutable_perf_capabilities(union perf_capabilities host_cap) val.lbr_format, host_cap.lbr_format); } + /* Ditto for the PEBS format. */ + for (val.pebs_format = 1; val.pebs_format; val.pebs_format++) { + if (val.pebs_format == host_cap.pebs_format) + continue; + + r = _vcpu_set_msr(vcpu, MSR_IA32_PERF_CAPABILITIES, val.capabilities); + TEST_ASSERT(!r, "Bad PEBS FMT = 0x%x didn't fail, host = 0x%x", + val.pebs_format, host_cap.pebs_format); + } + kvm_vm_free(vm); }