Skip to contentSkip to conversation

Nested VMX: load current_vmcs only when it exists

PATCH In review Yang Zhang 5 participants 5 messages May 9, 2014

lore
Share & tools
lore

Yang Zhang

author
#0 lore raw

PATCH 1/1 Nested VMX: load current_vmcs only when it exists

From: Yang Zhang <[email protected]>

There may not have valid vmcs on current CPU. So only load it when it exists.

This original fixing is from Edmud <[email protected]>.

---
 xen/arch/x86/hvm/vmx/vmcs.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
xen/arch/x86/hvm/vmx/vmcs.c +5 -1
index cc84ca2..7564895 100644
@@ -824,8 +824,12 @@ void virtual_vmcs_enter(void *vvmcs)
 
 void virtual_vmcs_exit(void *vvmcs)
 {
+    struct vmcs_struct *cur = this_cpu(current_vmcs);
+
     __vmpclear(pfn_to_paddr(domain_page_map_to_mfn(vvmcs)));
-    __vmptrld(virt_to_maddr(this_cpu(current_vmcs)));
+    if ( cur )
+        __vmptrld(virt_to_maddr(cur));
+
 }
 
 u64 virtual_vmcs_vmread(void *vvmcs, u32 vmcs_encoding)
Signature · 1 line
1.7.1
Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines

From: Zhang, Yang Z
Sent: Friday, May 09, 2014 12:56 PM

From: Yang Zhang <[email protected]>

There may not have valid vmcs on current CPU. So only load it when it exists.

This original fixing is from Edmud <[email protected]>.

Quoted 24 lines
---
 xen/arch/x86/hvm/vmx/vmcs.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
xen/arch/x86/hvm/vmx/vmcs.c +5 -2
index cc84ca2..7564895 100644
@@ -824,8 +824,12 @@ void virtual_vmcs_enter(void *vvmcs)
 
 void virtual_vmcs_exit(void *vvmcs)
 {
+    struct vmcs_struct *cur = this_cpu(current_vmcs);
+
     __vmpclear(pfn_to_paddr(domain_page_map_to_mfn(vvmcs)));
-    __vmptrld(virt_to_maddr(this_cpu(current_vmcs)));
+    if ( cur )
+        __vmptrld(virt_to_maddr(cur));
+
 }
 
 u64 virtual_vmcs_vmread(void *vvmcs, u32 vmcs_encoding)
--

1.7.1

Reviewed-by
#2 lore raw
Quoted 5 lines · Kevin
Quoted 5 lines

From: Zhang, Yang Z
Sent: Friday, May 09, 2014 12:56 PM

From: Yang Zhang <[email protected]>

Quoted 7 lines
Quoted 6 lines

There may not have valid vmcs on current CPU. So only load it when it exists.

This original fixing is from Edmud <[email protected]>.

Quoted 30 lines
Quoted 24 lines
---
 xen/arch/x86/hvm/vmx/vmcs.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
xen/arch/x86/hvm/vmx/vmcs.c +5 -2
index cc84ca2..7564895 100644
@@ -824,8 +824,12 @@ void virtual_vmcs_enter(void *vvmcs)
 
 void virtual_vmcs_exit(void *vvmcs)
 {
+    struct vmcs_struct *cur = this_cpu(current_vmcs);
+
     __vmpclear(pfn_to_paddr(domain_page_map_to_mfn(vvmcs)));
-    __vmptrld(virt_to_maddr(this_cpu(current_vmcs)));
+    if ( cur )
+        __vmptrld(virt_to_maddr(cur));
+
 }
 
 u64 virtual_vmcs_vmread(void *vvmcs, u32 vmcs_encoding)
--
Quoted 1 line

1.7.1

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#3 lore raw
In reply to Yang Zhang
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 09.05.14 at 06:56, <[email protected]> wrote:

From: Yang Zhang <[email protected]>

There may not have valid vmcs on current CPU. So only load it when it exists.

Under what condition(s) might that happen?

Quoted 1 line

This original fixing is from Edmud <[email protected]>.

Rather than stating this here, the From: above should say so.

Quoted 28 lines
---
 xen/arch/x86/hvm/vmx/vmcs.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
xen/arch/x86/hvm/vmx/vmcs.c +5 -1
index cc84ca2..7564895 100644
@@ -824,8 +824,12 @@ void virtual_vmcs_enter(void *vvmcs)
 
 void virtual_vmcs_exit(void *vvmcs)
 {
+    struct vmcs_struct *cur = this_cpu(current_vmcs);
+
     __vmpclear(pfn_to_paddr(domain_page_map_to_mfn(vvmcs)));
-    __vmptrld(virt_to_maddr(this_cpu(current_vmcs)));
+    if ( cur )
+        __vmptrld(virt_to_maddr(cur));
+
 }
 
 u64 virtual_vmcs_vmread(void *vvmcs, u32 vmcs_encoding)
Signature · 3 lines
1.7.1

.
#4 lore raw

It can happen if no domU vcpu has previously been scheduled on this hardware thread.
________________________________________
From: Jan Beulich [[email protected]]
Sent: Friday, May 09, 2014 2:46 AM
To: Zhang, Yang Z
Cc: [email protected]; White, Edmund H; Tian, Kevin; xen-devel
Subject: Re: [PATCH] Nested VMX: load current_vmcs only when it exists

Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 09.05.14 at 06:56, <[email protected]> wrote:

From: Yang Zhang <[email protected]>

There may not have valid vmcs on current CPU. So only load it when it exists.

Under what condition(s) might that happen?

Quoted 1 line

This original fixing is from Edmud <[email protected]>.

Rather than stating this here, the From: above should say so.

Quoted 28 lines
---
 xen/arch/x86/hvm/vmx/vmcs.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
xen/arch/x86/hvm/vmx/vmcs.c +5 -2
index cc84ca2..7564895 100644
@@ -824,8 +824,12 @@ void virtual_vmcs_enter(void *vvmcs)
 
 void virtual_vmcs_exit(void *vvmcs)
 {
+    struct vmcs_struct *cur = this_cpu(current_vmcs);
+
     __vmpclear(pfn_to_paddr(domain_page_map_to_mfn(vvmcs)));
-    __vmptrld(virt_to_maddr(this_cpu(current_vmcs)));
+    if ( cur )
+        __vmptrld(virt_to_maddr(cur));
+
 }
 
 u64 virtual_vmcs_vmread(void *vvmcs, u32 vmcs_encoding)
--

1.7.1

.