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

[Xen-changelog] [PATCH] [PATCH] VMX world switch does not handle all cases



ChangeSet 1.1585, 2005/05/28 16:21:07+01:00, leendert@xxxxxxxxxxxxxx

        [PATCH] [PATCH] VMX world switch does not handle all cases
        
        The latest world switch modification does not handle all cases. 
Specifically,
        when a partition enables CR0.PG|CR0.PE and performs a world switch at 
the
        the same time. The patch below handles this case.
        
        Signed-Off-By: Leendert van Doorn <leendert@xxxxxxxxxxxxxx>



 vmx.c |   54 ++++++++++++++++++++++++++++++------------------------
 1 files changed, 30 insertions(+), 24 deletions(-)


diff -Nru a/xen/arch/x86/vmx.c b/xen/arch/x86/vmx.c
--- a/xen/arch/x86/vmx.c        2005-05-28 12:03:24 -04:00
+++ b/xen/arch/x86/vmx.c        2005-05-28 12:03:24 -04:00
@@ -744,8 +744,8 @@
     __vmwrite(CR0_READ_SHADOW, value);
 
     VMX_DBG_LOG(DBG_LEVEL_VMMU, "Update CR0 value = %lx\n", value);
-    if ((value & X86_CR0_PE) && (value & X86_CR0_PG) 
-        && !paging_enabled) {
+
+    if ((value & X86_CR0_PE) && (value & X86_CR0_PG) && !paging_enabled) {
         /*
          * The guest CR3 must be pointing to the guest physical.
          */
@@ -775,33 +775,39 @@
          */
         VMX_DBG_LOG(DBG_LEVEL_VMMU, "Update CR3 value = %lx, mfn = %lx", 
                 d->arch.arch_vmx.cpu_cr3, mfn);
-    } else {
-        if ((value & X86_CR0_PE) == 0) {
-            __vmread(GUEST_EIP, &eip);
-            VMX_DBG_LOG(DBG_LEVEL_1, "Disabling CR0.PE at %%eip 0x%lx\n", eip);
-           if (vmx_assist(d, VMX_ASSIST_INVOKE)) {
-               set_bit(VMX_CPU_STATE_ASSIST_ENABLED,
-                                       &d->arch.arch_vmx.cpu_state);
-               __vmread(GUEST_EIP, &eip);
-               VMX_DBG_LOG(DBG_LEVEL_1,
-                   "Transfering control to vmxassist %%eip 0x%lx", eip);
-               return 0; /* do not update eip! */
-           }
-       } else if (test_bit(VMX_CPU_STATE_ASSIST_ENABLED,
-                                       &d->arch.arch_vmx.cpu_state)) {
+    }
+
+    /*
+     * VMX does not implement real-mode virtualization. We emulate
+     * real-mode by performing a world switch to VMXAssist whenever
+     * a partition disables the CR0.PE bit.
+     */
+    if ((value & X86_CR0_PE) == 0) {
+       __vmread(GUEST_EIP, &eip);
+       VMX_DBG_LOG(DBG_LEVEL_1,
+           "Disabling CR0.PE at %%eip 0x%lx\n", eip);
+       if (vmx_assist(d, VMX_ASSIST_INVOKE)) {
+           set_bit(VMX_CPU_STATE_ASSIST_ENABLED, &d->arch.arch_vmx.cpu_state);
            __vmread(GUEST_EIP, &eip);
            VMX_DBG_LOG(DBG_LEVEL_1,
-               "Enabling CR0.PE at %%eip 0x%lx", eip);
-           if (vmx_assist(d, VMX_ASSIST_RESTORE)) {
-               clear_bit(VMX_CPU_STATE_ASSIST_ENABLED,
+               "Transfering control to vmxassist %%eip 0x%lx\n", eip);
+           return 0; /* do not update eip! */
+       }
+    } else if (test_bit(VMX_CPU_STATE_ASSIST_ENABLED,
+                                       &d->arch.arch_vmx.cpu_state)) {
+       __vmread(GUEST_EIP, &eip);
+       VMX_DBG_LOG(DBG_LEVEL_1,
+           "Enabling CR0.PE at %%eip 0x%lx\n", eip);
+       if (vmx_assist(d, VMX_ASSIST_RESTORE)) {
+           clear_bit(VMX_CPU_STATE_ASSIST_ENABLED,
                                        &d->arch.arch_vmx.cpu_state);
-               __vmread(GUEST_EIP, &eip);
-               VMX_DBG_LOG(DBG_LEVEL_1,
-                   "Restoring to %%eip 0x%lx", eip);
-               return 0; /* do not update eip! */
-           }
+           __vmread(GUEST_EIP, &eip);
+           VMX_DBG_LOG(DBG_LEVEL_1,
+               "Restoring to %%eip 0x%lx\n", eip);
+           return 0; /* do not update eip! */
        }
     }
+
     return 1;
 }
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
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®.