[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen staging] VMX: don't needlessly write CR4 guest/host mask



commit c2c0f0db02623d9ad1ca70d1f1d759bb76715e47
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Mon Jul 2 13:12:10 2018 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Mon Jul 2 13:12:10 2018 +0200

    VMX: don't needlessly write CR4 guest/host mask
    
    In shadow mode the field never changes from ~0UL, so there's no need for
    a VMWRITE (or an update of its cached value).
    
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Reviewed-by: Andrew Cooper <andrew.cooper@xxxxxxxxxx>
    Acked-by: Kevin Tian <kevin.tian@xxxxxxxxx>
---
 xen/arch/x86/hvm/vmx/vmx.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index 20a8a69fbe..8e63eb7813 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -1585,14 +1585,12 @@ static void vmx_update_guest_cr(struct vcpu *v, 
unsigned int cr,
 
         __vmwrite(GUEST_CR4, v->arch.hvm_vcpu.hw_cr[4]);
 
-        if ( !paging_mode_hap(v->domain) )
-            /*
-             * Shadow path has not been optimized because it requires
-             * unconditionally trapping more CR4 bits, at which point the
-             * performance benefit of doing this is quite dubious.
-             */
-            v->arch.hvm_vmx.cr4_host_mask = ~0UL;
-        else
+        /*
+         * Shadow path has not been optimized because it requires
+         * unconditionally trapping more CR4 bits, at which point the
+         * performance benefit of doing this is quite dubious.
+         */
+        if ( paging_mode_hap(v->domain) )
         {
             /*
              * Update CR4 host mask to only trap when the guest tries to set
@@ -1617,8 +1615,9 @@ static void vmx_update_guest_cr(struct vcpu *v, unsigned 
int cr,
                 /* Add the nested host mask to get the more restrictive one. */
                 v->arch.hvm_vmx.cr4_host_mask |= get_vvmcs(v,
                                                            
CR4_GUEST_HOST_MASK);
+
+            __vmwrite(CR4_GUEST_HOST_MASK, v->arch.hvm_vmx.cr4_host_mask);
         }
-        __vmwrite(CR4_GUEST_HOST_MASK, v->arch.hvm_vmx.cr4_host_mask);
 
         break;
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.