mirror of
https://github.com/torvalds/linux.git
synced 2026-06-05 13:06:59 +02:00
KVM: selftests: Convert VMX's PMU capabilities test to printf guest asserts
Convert x86's VMX PMU capabilities test to use printf-based guest asserts. Opportunstically add a helper to do the WRMSR+assert so as to reduce the amount of copy+paste needed to spit out debug information. Link: https://lore.kernel.org/r/20230729003643.1053367-31-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
This commit is contained in:
parent
417bfd0c82
commit
30a6e0b455
|
|
@ -10,6 +10,7 @@
|
|||
* and check it can be retrieved with KVM_GET_MSR, also test
|
||||
* the invalid LBR formats are rejected.
|
||||
*/
|
||||
#define USE_GUEST_ASSERT_PRINTF 1
|
||||
|
||||
#define _GNU_SOURCE /* for program_invocation_short_name */
|
||||
#include <sys/ioctl.h>
|
||||
|
|
@ -52,23 +53,24 @@ static const union perf_capabilities format_caps = {
|
|||
.pebs_format = -1,
|
||||
};
|
||||
|
||||
static void guest_test_perf_capabilities_gp(uint64_t val)
|
||||
{
|
||||
uint8_t vector = wrmsr_safe(MSR_IA32_PERF_CAPABILITIES, val);
|
||||
|
||||
__GUEST_ASSERT(vector == GP_VECTOR,
|
||||
"Expected #GP for value '0x%llx', got vector '0x%x'",
|
||||
val, vector);
|
||||
}
|
||||
|
||||
static void guest_code(uint64_t current_val)
|
||||
{
|
||||
uint8_t vector;
|
||||
int i;
|
||||
|
||||
vector = wrmsr_safe(MSR_IA32_PERF_CAPABILITIES, current_val);
|
||||
GUEST_ASSERT_2(vector == GP_VECTOR, current_val, vector);
|
||||
guest_test_perf_capabilities_gp(current_val);
|
||||
guest_test_perf_capabilities_gp(0);
|
||||
|
||||
vector = wrmsr_safe(MSR_IA32_PERF_CAPABILITIES, 0);
|
||||
GUEST_ASSERT_2(vector == GP_VECTOR, 0, vector);
|
||||
|
||||
for (i = 0; i < 64; i++) {
|
||||
vector = wrmsr_safe(MSR_IA32_PERF_CAPABILITIES,
|
||||
current_val ^ BIT_ULL(i));
|
||||
GUEST_ASSERT_2(vector == GP_VECTOR,
|
||||
current_val ^ BIT_ULL(i), vector);
|
||||
}
|
||||
for (i = 0; i < 64; i++)
|
||||
guest_test_perf_capabilities_gp(current_val ^ BIT_ULL(i));
|
||||
|
||||
GUEST_DONE();
|
||||
}
|
||||
|
|
@ -95,7 +97,7 @@ static void test_guest_wrmsr_perf_capabilities(union perf_capabilities host_cap)
|
|||
|
||||
switch (get_ucall(vcpu, &uc)) {
|
||||
case UCALL_ABORT:
|
||||
REPORT_GUEST_ASSERT_2(uc, "val = 0x%lx, vector = %lu");
|
||||
REPORT_GUEST_ASSERT(uc);
|
||||
break;
|
||||
case UCALL_DONE:
|
||||
break;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user