All of lore.kernel.org
 help / color / mirror / Atom feed
* [kvm-unit-tests PATCH] x86: VMX: Mask advanced VM-exit info
@ 2019-10-03 13:26 Nadav Amit
  2019-10-07 11:21 ` Paolo Bonzini
  0 siblings, 1 reply; 2+ messages in thread
From: Nadav Amit @ 2019-10-03 13:26 UTC (permalink / raw)
  To: pbonzini; +Cc: kvm, sean.j.christopherson, Nadav Amit

Bits [9:11] are undefined in the VM-exit qualification when "advanced
VM-exit information for EPT violations" is not supported.

Mask these bits for now to avoid false failures. If KVM supports this
feature, the tests would need to be adapted, and the masking would need
to be removed.

Unfortunately, I do not have hardware that supports this feature
available for my use to make a better fix.

Signed-off-by: Nadav Amit <namit@vmware.com>
---
 x86/vmx.h       | 2 ++
 x86/vmx_tests.c | 7 +++++++
 2 files changed, 9 insertions(+)

diff --git a/x86/vmx.h b/x86/vmx.h
index a8bc847..8496be7 100644
--- a/x86/vmx.h
+++ b/x86/vmx.h
@@ -618,6 +618,8 @@ enum vm_instruction_error_number {
 #define EPT_VLT_GUEST_USER	(1ull << 9)
 #define EPT_VLT_GUEST_RW	(1ull << 10)
 #define EPT_VLT_GUEST_EX	(1ull << 11)
+#define EPT_VLT_GUEST_MASK	(EPT_VLT_GUEST_USER | EPT_VLT_GUEST_RW | \
+				 EPT_VLT_GUEST_EX)
 
 #define MAGIC_VAL_1		0x12345678ul
 #define MAGIC_VAL_2		0x87654321ul
diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
index f4b348b..6b9dc10 100644
--- a/x86/vmx_tests.c
+++ b/x86/vmx_tests.c
@@ -1409,6 +1409,13 @@ static int ept_exit_handler_common(bool have_ad)
 		}
 		return VMX_TEST_RESUME;
 	case VMX_EPT_VIOLATION:
+		/*
+		 * Exit-qualifications are masked not to account for advanced
+		 * VM-exit information. Once KVM supports this feature, this
+		 * masking should be removed.
+		 */
+		exit_qual &= ~EPT_VLT_GUEST_MASK;
+
 		switch(vmx_get_test_stage()) {
 		case 3:
 			check_ept_ad(pml4, guest_cr3, (unsigned long)data_page1, 0,
-- 
2.17.1


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

* Re: [kvm-unit-tests PATCH] x86: VMX: Mask advanced VM-exit info
  2019-10-03 13:26 [kvm-unit-tests PATCH] x86: VMX: Mask advanced VM-exit info Nadav Amit
@ 2019-10-07 11:21 ` Paolo Bonzini
  0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2019-10-07 11:21 UTC (permalink / raw)
  To: Nadav Amit; +Cc: kvm, sean.j.christopherson

On 03/10/19 15:26, Nadav Amit wrote:
> Bits [9:11] are undefined in the VM-exit qualification when "advanced
> VM-exit information for EPT violations" is not supported.
> 
> Mask these bits for now to avoid false failures. If KVM supports this
> feature, the tests would need to be adapted, and the masking would need
> to be removed.
> 
> Unfortunately, I do not have hardware that supports this feature
> available for my use to make a better fix.
> 
> Signed-off-by: Nadav Amit <namit@vmware.com>
> ---
>  x86/vmx.h       | 2 ++
>  x86/vmx_tests.c | 7 +++++++
>  2 files changed, 9 insertions(+)
> 
> diff --git a/x86/vmx.h b/x86/vmx.h
> index a8bc847..8496be7 100644
> --- a/x86/vmx.h
> +++ b/x86/vmx.h
> @@ -618,6 +618,8 @@ enum vm_instruction_error_number {
>  #define EPT_VLT_GUEST_USER	(1ull << 9)
>  #define EPT_VLT_GUEST_RW	(1ull << 10)
>  #define EPT_VLT_GUEST_EX	(1ull << 11)
> +#define EPT_VLT_GUEST_MASK	(EPT_VLT_GUEST_USER | EPT_VLT_GUEST_RW | \
> +				 EPT_VLT_GUEST_EX)
>  
>  #define MAGIC_VAL_1		0x12345678ul
>  #define MAGIC_VAL_2		0x87654321ul
> diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
> index f4b348b..6b9dc10 100644
> --- a/x86/vmx_tests.c
> +++ b/x86/vmx_tests.c
> @@ -1409,6 +1409,13 @@ static int ept_exit_handler_common(bool have_ad)
>  		}
>  		return VMX_TEST_RESUME;
>  	case VMX_EPT_VIOLATION:
> +		/*
> +		 * Exit-qualifications are masked not to account for advanced
> +		 * VM-exit information. Once KVM supports this feature, this
> +		 * masking should be removed.
> +		 */
> +		exit_qual &= ~EPT_VLT_GUEST_MASK;
> +
>  		switch(vmx_get_test_stage()) {
>  		case 3:
>  			check_ept_ad(pml4, guest_cr3, (unsigned long)data_page1, 0,
> 

Queued, thanks.

Paolo


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

end of thread, other threads:[~2019-10-07 11:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-03 13:26 [kvm-unit-tests PATCH] x86: VMX: Mask advanced VM-exit info Nadav Amit
2019-10-07 11:21 ` Paolo Bonzini

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.