All of lore.kernel.org
 help / color / mirror / Atom feed
* [kvm-unit-tests PATCH] nVMX: Check EXIT_QUALIFICATION on VM-Enter failures due to bad guest state
@ 2020-04-24 17:40 Sean Christopherson
  2020-05-04 16:34 ` Paolo Bonzini
  2020-05-08 23:37 ` Sean Christopherson
  0 siblings, 2 replies; 3+ messages in thread
From: Sean Christopherson @ 2020-04-24 17:40 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: kvm, 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.

Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
---
 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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [kvm-unit-tests PATCH] nVMX: Check EXIT_QUALIFICATION on VM-Enter failures due to bad guest state
  2020-04-24 17:40 [kvm-unit-tests PATCH] nVMX: Check EXIT_QUALIFICATION on VM-Enter failures due to bad guest state Sean Christopherson
@ 2020-05-04 16:34 ` Paolo Bonzini
  2020-05-08 23:37 ` Sean Christopherson
  1 sibling, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2020-05-04 16:34 UTC (permalink / raw)
  To: Sean Christopherson; +Cc: kvm

On 24/04/20 19:40, Sean Christopherson wrote:
> 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@intel.com>
> ---
>  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)
> 

Queued, thanks.

Paolo


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [kvm-unit-tests PATCH] nVMX: Check EXIT_QUALIFICATION on VM-Enter failures due to bad guest state
  2020-04-24 17:40 [kvm-unit-tests PATCH] nVMX: Check EXIT_QUALIFICATION on VM-Enter failures due to bad guest state Sean Christopherson
  2020-05-04 16:34 ` Paolo Bonzini
@ 2020-05-08 23:37 ` Sean Christopherson
  1 sibling, 0 replies; 3+ messages in thread
From: Sean Christopherson @ 2020-05-08 23:37 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: kvm

On Fri, Apr 24, 2020 at 10:40:25AM -0700, Sean Christopherson wrote:
> 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.

> Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
> ---
>  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
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-05-08 23:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-24 17:40 [kvm-unit-tests PATCH] nVMX: Check EXIT_QUALIFICATION on VM-Enter failures due to bad guest state Sean Christopherson
2020-05-04 16:34 ` Paolo Bonzini
2020-05-08 23:37 ` Sean Christopherson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.