[kvm-unit-tests PATCH 6/6] x86: nSVM: Print out RIP and LBRs from VMCB if LBRV guest test fails

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Print out the RIP and LBRs from the VMCB's save are if a LBRV guest test
fails, i.e. exits for a reason other than VMMCALL.  Debugging the guests
is still beyond painful, but with the guest RIP and LBRs, it's at least
possible to piece together things like shutdowns due to unexpected #PF
because the tests neglected to setup the guest stack.

Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>
---
 x86/svm_tests.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/x86/svm_tests.c b/x86/svm_tests.c
index de2cedc8..e56501c1 100644
--- a/x86/svm_tests.c
+++ b/x86/svm_tests.c
@@ -2791,6 +2791,12 @@ do {										\
 		asm volatile("ud2");						\
 } while (0)
 
+#define REPORT_GUEST_LBR_ERROR(vmcb)						\
+	report(false, "LBR guest test failed.  Exit reason 0x%x, RIP = %lx, from = %lx, to = %lx, ex from = %lx, ex to = %lx", \
+		       vmcb->control.exit_code, vmcb->save.rip,			\
+		       vmcb->save.br_from, vmcb->save.br_to,			\
+		       vmcb->save.last_excp_from, vmcb->save.last_excp_to)
+
 #define DO_BRANCH(branch_name)				\
 	asm volatile (					\
 		      # branch_name "_from:"		\
@@ -2888,8 +2894,7 @@ static void svm_lbrv_test1(void)
 	dbgctl = rdmsr(MSR_IA32_DEBUGCTLMSR);
 
 	if (vmcb->control.exit_code != SVM_EXIT_VMMCALL) {
-		report(false, "VMEXIT not due to vmmcall. Exit reason 0x%x",
-		       vmcb->control.exit_code);
+		REPORT_GUEST_LBR_ERROR(vmcb);
 		return;
 	}
 
@@ -2912,8 +2917,7 @@ static void svm_lbrv_test2(void)
 	wrmsr(MSR_IA32_DEBUGCTLMSR, 0);
 
 	if (vmcb->control.exit_code != SVM_EXIT_VMMCALL) {
-		report(false, "VMEXIT not due to vmmcall. Exit reason 0x%x",
-		       vmcb->control.exit_code);
+		REPORT_GUEST_LBR_ERROR(vmcb);
 		return;
 	}
 
@@ -2940,8 +2944,7 @@ static void svm_lbrv_nested_test1(void)
 	wrmsr(MSR_IA32_DEBUGCTLMSR, 0);
 
 	if (vmcb->control.exit_code != SVM_EXIT_VMMCALL) {
-		report(false, "VMEXIT not due to vmmcall. Exit reason 0x%x",
-		       vmcb->control.exit_code);
+		REPORT_GUEST_LBR_ERROR(vmcb);
 		return;
 	}
 
@@ -2976,8 +2979,7 @@ static void svm_lbrv_nested_test2(void)
 	wrmsr(MSR_IA32_DEBUGCTLMSR, 0);
 
 	if (vmcb->control.exit_code != SVM_EXIT_VMMCALL) {
-		report(false, "VMEXIT not due to vmmcall. Exit reason 0x%x",
-		       vmcb->control.exit_code);
+		REPORT_GUEST_LBR_ERROR(vmcb);
 		return;
 	}
 
-- 
2.41.0.162.gfafddb0af9-goog




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux