Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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/20230729003643.1053367-34-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>

+6 -12
+6 -12
tools/testing/selftests/kvm/lib/x86_64/processor.c
··· 1074 1074 return true; 1075 1075 } 1076 1076 1077 - void kvm_exit_unexpected_vector(uint32_t value) 1078 - { 1079 - ucall(UCALL_UNHANDLED, 1, value); 1080 - } 1081 - 1082 1077 void route_exception(struct ex_regs *regs) 1083 1078 { 1084 1079 typedef void(*handler)(struct ex_regs *); ··· 1087 1092 if (kvm_fixup_exception(regs)) 1088 1093 return; 1089 1094 1090 - kvm_exit_unexpected_vector(regs->vector); 1095 + ucall_assert(UCALL_UNHANDLED, 1096 + "Unhandled exception in guest", __FILE__, __LINE__, 1097 + "Unhandled exception '0x%lx' at guest RIP '0x%lx'", 1098 + regs->vector, regs->rip); 1091 1099 } 1092 1100 1093 1101 void vm_init_descriptor_tables(struct kvm_vm *vm) ··· 1133 1135 { 1134 1136 struct ucall uc; 1135 1137 1136 - if (get_ucall(vcpu, &uc) == UCALL_UNHANDLED) { 1137 - uint64_t vector = uc.args[0]; 1138 - 1139 - TEST_FAIL("Unexpected vectored event in guest (vector:0x%lx)", 1140 - vector); 1141 - } 1138 + if (get_ucall(vcpu, &uc) == UCALL_UNHANDLED) 1139 + REPORT_GUEST_ASSERT(uc); 1142 1140 } 1143 1141 1144 1142 const struct kvm_cpuid_entry2 *get_cpuid_entry(const struct kvm_cpuid2 *cpuid,