[kvm-unit-tests PATCH] nVMX: Check EXIT_QUALIFICATION on VM-Enter failures due to bad guest state

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

 



Assert that vmcs.EXIT_QUALIFICATION contains the correct failure code on
failed VM-Enter due to invalid guest state.  Hardcode the expected code
to the default code, '0', rather than passing in the expected code to
minimize churn and boilerplate code, which works for all existing tests.

Signed-off-by: Sean Christopherson <sean.j.christopherson@xxxxxxxxx>
---
 x86/vmx.h       | 7 +++++++
 x86/vmx_tests.c | 3 ++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/x86/vmx.h b/x86/vmx.h
index 2e28ecb..08b354d 100644
--- a/x86/vmx.h
+++ b/x86/vmx.h
@@ -521,6 +521,13 @@ enum vm_instruction_error_number {
 	VMXERR_INVALID_OPERAND_TO_INVEPT_INVVPID = 28,
 };
 
+enum vm_entry_failure_code {
+	ENTRY_FAIL_DEFAULT		= 0,
+	ENTRY_FAIL_PDPTE		= 2,
+	ENTRY_FAIL_NMI			= 3,
+	ENTRY_FAIL_VMCS_LINK_PTR	= 4,
+};
+
 #define SAVE_GPR				\
 	"xchg %rax, regs\n\t"			\
 	"xchg %rcx, regs+0x8\n\t"		\
diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
index 4a3c56b..f5a646f 100644
--- a/x86/vmx_tests.c
+++ b/x86/vmx_tests.c
@@ -5255,7 +5255,8 @@ static void test_guest_state(const char *test, bool xfail, u64 field,
 
 	report(result.exit_reason.failed_vmentry == xfail &&
 	       ((xfail && result.exit_reason.basic == VMX_FAIL_STATE) ||
-	        (!xfail && result.exit_reason.basic == VMX_VMCALL)),
+	        (!xfail && result.exit_reason.basic == VMX_VMCALL)) &&
+		(!xfail || vmcs_read(EXI_QUALIFICATION) == ENTRY_FAIL_DEFAULT),
 	        "%s, %s %lx", test, field_name, field);
 
 	if (!result.exit_reason.failed_vmentry)
-- 
2.26.0




[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