Skip to content

Commit 6f32101

Browse files
committed
KVM: selftests: Print out guest RIP on unhandled exception
Use the newfanged printf-based guest assert framework to spit out the guest RIP when an unhandled exception is detected, which makes debugging such failures *much* easier. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
1 parent 7ce7f8e commit 6f32101

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

tools/testing/selftests/kvm/lib/x86_64/processor.c

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,11 +1074,6 @@ static bool kvm_fixup_exception(struct ex_regs *regs)
10741074
return true;
10751075
}
10761076

1077-
void kvm_exit_unexpected_vector(uint32_t value)
1078-
{
1079-
ucall(UCALL_UNHANDLED, 1, value);
1080-
}
1081-
10821077
void route_exception(struct ex_regs *regs)
10831078
{
10841079
typedef void(*handler)(struct ex_regs *);
@@ -1092,7 +1087,10 @@ void route_exception(struct ex_regs *regs)
10921087
if (kvm_fixup_exception(regs))
10931088
return;
10941089

1095-
kvm_exit_unexpected_vector(regs->vector);
1090+
ucall_assert(UCALL_UNHANDLED,
1091+
"Unhandled exception in guest", __FILE__, __LINE__,
1092+
"Unhandled exception '0x%lx' at guest RIP '0x%lx'",
1093+
regs->vector, regs->rip);
10961094
}
10971095

10981096
void vm_init_descriptor_tables(struct kvm_vm *vm)
@@ -1135,12 +1133,8 @@ void assert_on_unhandled_exception(struct kvm_vcpu *vcpu)
11351133
{
11361134
struct ucall uc;
11371135

1138-
if (get_ucall(vcpu, &uc) == UCALL_UNHANDLED) {
1139-
uint64_t vector = uc.args[0];
1140-
1141-
TEST_FAIL("Unexpected vectored event in guest (vector:0x%lx)",
1142-
vector);
1143-
}
1136+
if (get_ucall(vcpu, &uc) == UCALL_UNHANDLED)
1137+
REPORT_GUEST_ASSERT(uc);
11441138
}
11451139

11461140
const struct kvm_cpuid_entry2 *get_cpuid_entry(const struct kvm_cpuid2 *cpuid,

0 commit comments

Comments
 (0)