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

[Xen-changelog] [xen-unstable] vmx: Simplify cr0 update handling by deferring cr4 changes to the cr4 handler.


  • To: xen-changelog@xxxxxxxxxxxxxxxxxxx
  • From: Xen patchbot-unstable <patchbot@xxxxxxx>
  • Date: Mon, 04 Feb 2013 15:44:39 +0000
  • Delivery-date: Mon, 04 Feb 2013 15:44:45 +0000
  • List-id: "Change log for Mercurial \(receive only\)" <xen-changelog.lists.xen.org>

# HG changeset patch
# User Keir Fraser <keir@xxxxxxx>
# Date 1359566139 28800
# Node ID 8201b6ec3564c80db5516cdcf36dcfa9b7fdd93b
# Parent  1fe8ecfdf10cc9077fc810364663a0f25a5c5b96
vmx: Simplify cr0 update handling by deferring cr4 changes to the cr4 handler.

Signed-off-by: Keir Fraser <keir@xxxxxxx>
---


diff -r 1fe8ecfdf10c -r 8201b6ec3564 xen/arch/x86/hvm/vmx/vmx.c
--- a/xen/arch/x86/hvm/vmx/vmx.c        Wed Jan 30 03:04:42 2013 -0800
+++ b/xen/arch/x86/hvm/vmx/vmx.c        Wed Jan 30 09:15:39 2013 -0800
@@ -1068,20 +1068,18 @@ static void vmx_update_guest_cr(struct v
 
         if ( paging_mode_hap(v->domain) )
         {
-            /* We manage GUEST_CR3 when guest CR0.PE is zero or when cr3 
memevents are on */            
+            /* Manage GUEST_CR3 when CR0.PE=0. */
             uint32_t cr3_ctls = (CPU_BASED_CR3_LOAD_EXITING |
                                  CPU_BASED_CR3_STORE_EXITING);
             v->arch.hvm_vmx.exec_control &= ~cr3_ctls;
             if ( !hvm_paging_enabled(v) )
                 v->arch.hvm_vmx.exec_control |= cr3_ctls;
 
+            /* Trap CR3 updates if CR3 memory events are enabled. */
             if ( v->domain->arch.hvm_domain.params[HVM_PARAM_MEMORY_EVENT_CR3] 
)
                 v->arch.hvm_vmx.exec_control |= CPU_BASED_CR3_LOAD_EXITING;
 
             vmx_update_cpu_exec_control(v);
-
-            /* Changing CR0.PE can change some bits in real CR4. */
-            vmx_update_guest_cr(v, 4);
         }
 
         if ( !(v->arch.hvm_vcpu.guest_cr[0] & X86_CR0_TS) )
@@ -1111,8 +1109,6 @@ static void vmx_update_guest_cr(struct v
             {
                 for ( s = x86_seg_cs ; s <= x86_seg_tr ; s++ )
                     vmx_set_segment_register(v, s, &reg[s]);
-                v->arch.hvm_vcpu.hw_cr[4] |= X86_CR4_VME;
-                __vmwrite(GUEST_CR4, v->arch.hvm_vcpu.hw_cr[4]);
                 v->arch.hvm_vmx.exception_bitmap = 0xffffffff;
                 vmx_update_exception_bitmap(v);
             }
@@ -1122,10 +1118,6 @@ static void vmx_update_guest_cr(struct v
                     if ( !(v->arch.hvm_vmx.vm86_segment_mask & (1<<s)) )
                         vmx_set_segment_register(
                             v, s, &v->arch.hvm_vmx.vm86_saved_seg[s]);
-                v->arch.hvm_vcpu.hw_cr[4] =
-                    ((v->arch.hvm_vcpu.hw_cr[4] & ~X86_CR4_VME)
-                     |(v->arch.hvm_vcpu.guest_cr[4] & X86_CR4_VME));
-                __vmwrite(GUEST_CR4, v->arch.hvm_vcpu.hw_cr[4]);
                 v->arch.hvm_vmx.exception_bitmap = HVM_TRAP_MASK
                           | (paging_mode_hap(v->domain) ?
                              0 : (1U << TRAP_page_fault))
@@ -1139,6 +1131,9 @@ static void vmx_update_guest_cr(struct v
             v->arch.hvm_vcpu.guest_cr[0] | hw_cr0_mask;
         __vmwrite(GUEST_CR0, v->arch.hvm_vcpu.hw_cr[0]);
         __vmwrite(CR0_READ_SHADOW, v->arch.hvm_vcpu.guest_cr[0]);
+
+        /* Changing CR0 can change some bits in real CR4. */
+        vmx_update_guest_cr(v, 4);
         break;
     }
     case 2:

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

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