Skip to content

Commit 8b95b41

Browse files
committed
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 <seanjc@google.com>
1 parent 8ac2f77 commit 8b95b41

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

tools/testing/selftests/kvm/x86_64/vmx_pmu_caps_test.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,16 @@ static void test_immutable_perf_capabilities(union perf_capabilities host_cap)
191191
val.lbr_format, host_cap.lbr_format);
192192
}
193193

194+
/* Ditto for the PEBS format. */
195+
for (val.pebs_format = 1; val.pebs_format; val.pebs_format++) {
196+
if (val.pebs_format == host_cap.pebs_format)
197+
continue;
198+
199+
r = _vcpu_set_msr(vcpu, MSR_IA32_PERF_CAPABILITIES, val.capabilities);
200+
TEST_ASSERT(!r, "Bad PEBS FMT = 0x%x didn't fail, host = 0x%x",
201+
val.pebs_format, host_cap.pebs_format);
202+
}
203+
194204
kvm_vm_free(vm);
195205
}
196206

0 commit comments

Comments
 (0)