[kvm-unit-tests] kvm: nVMX: Always VMCLEAR before the first VMPTRLD
diff mbox series

Message ID 20181129000046.93876-1-jmattson@google.com
State New
Headers show
Series
  • [kvm-unit-tests] kvm: nVMX: Always VMCLEAR before the first VMPTRLD
Related show

Commit Message

Jim Mattson Nov. 29, 2018, midnight UTC
Per SDM volume 3, section 24.11.3: Initializing a VMCS, "to avoid the
uncertainties of implementation-specific behavior, software should
execute VMCLEAR on a VMCS region before making the corresponding VMCS
active with VMPTRLD for the first time."

Signed-off-by: Jim Mattson <jmattson@google.com>
---
 x86/vmx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

David Hildenbrand Nov. 29, 2018, 10:15 a.m. UTC | #1
On 29.11.18 01:00, Jim Mattson wrote:
> Per SDM volume 3, section 24.11.3: Initializing a VMCS, "to avoid the
> uncertainties of implementation-specific behavior, software should
> execute VMCLEAR on a VMCS region before making the corresponding VMCS
> active with VMPTRLD for the first time."
> 
> Signed-off-by: Jim Mattson <jmattson@google.com>
> ---
>  x86/vmx.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/x86/vmx.c b/x86/vmx.c
> index ab3c2a4..6ba56bc 100644
> --- a/x86/vmx.c
> +++ b/x86/vmx.c
> @@ -1384,7 +1384,8 @@ static void test_vmptrld(void)
>  	       make_vmcs_current(tmp_root) == 1);
>  
>  	/* Pass VMXON region */
> -	make_vmcs_current(vmcs);
> +	assert(!vmcs_clear(vmcs));
> +	assert(!make_vmcs_current(vmcs));
>  	tmp_root = (struct vmcs *)vmxon_region;
>  	report("test vmptrld with vmxon region",
>  	       make_vmcs_current(tmp_root) == 1);
> 

Reviewed-by: David Hildenbrand <david@redhat.com>

Patch
diff mbox series

diff --git a/x86/vmx.c b/x86/vmx.c
index ab3c2a4..6ba56bc 100644
--- a/x86/vmx.c
+++ b/x86/vmx.c
@@ -1384,7 +1384,8 @@  static void test_vmptrld(void)
 	       make_vmcs_current(tmp_root) == 1);
 
 	/* Pass VMXON region */
-	make_vmcs_current(vmcs);
+	assert(!vmcs_clear(vmcs));
+	assert(!make_vmcs_current(vmcs));
 	tmp_root = (struct vmcs *)vmxon_region;
 	report("test vmptrld with vmxon region",
 	       make_vmcs_current(tmp_root) == 1);