[xen master] x86/vmx: Defer vmx_vmcs_exit() as long as possible in construct_vmcs()

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[xen master] x86/vmx: Defer vmx_vmcs_exit() as long as possible in construct_vmcs()

patchbot
commit f30e3cf34042846e391e3f8361fc6a76d181a7ee
Author:     Andrew Cooper <[hidden email]>
AuthorDate: Mon May 28 15:02:34 2018 +0100
Commit:     Andrew Cooper <[hidden email]>
CommitDate: Thu Jun 28 11:31:26 2018 +0100

    x86/vmx: Defer vmx_vmcs_exit() as long as possible in construct_vmcs()
   
    paging_update_paging_modes() and vmx_vlapic_msr_changed() both operate on the
    VMCS being constructed.  Avoid dropping and re-acquiring the reference
    multiple times.
   
    Signed-off-by: Andrew Cooper <[hidden email]>
    Reviewed-by: Jan Beulich <[hidden email]>
    Acked-by: Kevin Tian <[hidden email]>
---
 xen/arch/x86/hvm/vmx/vmcs.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/xen/arch/x86/hvm/vmx/vmcs.c b/xen/arch/x86/hvm/vmx/vmcs.c
index 13b9cc5dbe..c7e6e29fe1 100644
--- a/xen/arch/x86/hvm/vmx/vmcs.c
+++ b/xen/arch/x86/hvm/vmx/vmcs.c
@@ -996,6 +996,7 @@ static int construct_vmcs(struct vcpu *v)
     struct domain *d = v->domain;
     u32 vmexit_ctl = vmx_vmexit_control;
     u32 vmentry_ctl = vmx_vmentry_control;
+    int rc = 0;
 
     vmx_vmcs_enter(v);
 
@@ -1083,8 +1084,8 @@ static int construct_vmcs(struct vcpu *v)
 
         if ( msr_bitmap == NULL )
         {
-            vmx_vmcs_exit(v);
-            return -ENOMEM;
+            rc = -ENOMEM;
+            goto out;
         }
 
         memset(msr_bitmap, ~0, PAGE_SIZE);
@@ -1260,14 +1261,15 @@ static int construct_vmcs(struct vcpu *v)
     if ( cpu_has_vmx_tsc_scaling )
         __vmwrite(TSC_MULTIPLIER, d->arch.hvm_domain.tsc_scaling_ratio);
 
-    vmx_vmcs_exit(v);
-
     /* will update HOST & GUEST_CR3 as reqd */
     paging_update_paging_modes(v);
 
     vmx_vlapic_msr_changed(v);
 
-    return 0;
+ out:
+    vmx_vmcs_exit(v);
+
+    return rc;
 }
 
 static int vmx_msr_entry_key_cmp(const void *key, const void *elt)
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
[hidden email]
https://lists.xenproject.org/xen-changelog