Skip to content

Commit 53635ec

Browse files
committed
KVM: selftests: Move platform_info_test's main assert into guest code
As a first step toward gracefully handling the expected #GP on RDMSR in platform_info_test, move the test's assert on the non-faulting RDMSR result into the guest itself. This will allow using a unified flow for the host userspace side of things. Link: https://lore.kernel.org/r/20240314232637.2538648-6-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 0d95817 commit 53635ec

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

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

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ static void guest_code(void)
2727

2828
for (;;) {
2929
msr_platform_info = rdmsr(MSR_PLATFORM_INFO);
30-
GUEST_SYNC(msr_platform_info);
30+
GUEST_ASSERT_EQ(msr_platform_info & MSR_PLATFORM_INFO_MAX_TURBO_RATIO,
31+
MSR_PLATFORM_INFO_MAX_TURBO_RATIO);
32+
GUEST_SYNC(0);
3133
asm volatile ("inc %r11");
3234
}
3335
}
@@ -40,13 +42,15 @@ static void test_msr_platform_info_enabled(struct kvm_vcpu *vcpu)
4042
vcpu_run(vcpu);
4143
TEST_ASSERT_KVM_EXIT_REASON(vcpu, KVM_EXIT_IO);
4244

43-
get_ucall(vcpu, &uc);
44-
TEST_ASSERT(uc.cmd == UCALL_SYNC,
45-
"Received ucall other than UCALL_SYNC: %lu", uc.cmd);
46-
TEST_ASSERT((uc.args[1] & MSR_PLATFORM_INFO_MAX_TURBO_RATIO) ==
47-
MSR_PLATFORM_INFO_MAX_TURBO_RATIO,
48-
"Expected MSR_PLATFORM_INFO to have max turbo ratio mask: %i.",
49-
MSR_PLATFORM_INFO_MAX_TURBO_RATIO);
45+
switch (get_ucall(vcpu, &uc)) {
46+
case UCALL_SYNC:
47+
break;
48+
case UCALL_ABORT:
49+
REPORT_GUEST_ASSERT(uc);
50+
default:
51+
TEST_FAIL("Unexpected ucall %lu", uc.cmd);
52+
break;
53+
}
5054
}
5155

5256
static void test_msr_platform_info_disabled(struct kvm_vcpu *vcpu)

0 commit comments

Comments
 (0)