Skip to contentSkip to conversation

nVMX: Check EXIT_QUALIFICATION on VM-Enter failures due to bad guest state

PATCH Applied Sean Christopherson 2 participants 3 messages Apr 24, 2020 – May 8, 2020 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nVMX: Check EXIT_QUALIFICATION on VM-Enter failures due to bad guest state

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.

---
 x86/vmx.h       | 7 +++++++
 x86/vmx_tests.c | 3 ++-
 2 files changed, 9 insertions(+), 1 deletion(-)
x86/vmx.h +7 -0
index 2e28ecb..08b354d 100644
@@ -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"		\
x86/vmx_tests.c +2 -1
index 4a3c56b..f5a646f 100644
@@ -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)
Signature · 1 line
2.26.0
maintainer Applied
#1 lore raw
Quoted 35 lines · Sean Christopherson

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.

---
 x86/vmx.h       | 7 +++++++
 x86/vmx_tests.c | 3 ++-
 2 files changed, 9 insertions(+), 1 deletion(-)
x86/vmx.h +7 -0
index 2e28ecb..08b354d 100644
@@ -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"		\
x86/vmx_tests.c +0 -0
index 4a3c56b..f5a646f 100644

x86/vmx_tests.c static void test_guest_state(const char *test, bool xfail, u64 field, · line 5262

Quoted 9 lines
x86/vmx_tests.c +2 -1
@@ -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)

Queued, thanks.

Paolo

#2 lore raw
In reply to Sean Christopherson
Quoted 4 lines · Sean Christopherson

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.

                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

...except for atomic_switch_overflow_msrs_test. I'll get a fix sent out next week.

Quoted 41 lines
---
 x86/vmx.h       | 7 +++++++
 x86/vmx_tests.c | 3 ++-
 2 files changed, 9 insertions(+), 1 deletion(-)
x86/vmx.h +7 -0
index 2e28ecb..08b354d 100644
@@ -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"		\
x86/vmx_tests.c +2 -1
index 4a3c56b..f5a646f 100644
@@ -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)
Signature · 1 line
2.26.0