WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

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

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] VMX world switch does not handle all cases
From: Leendert van Doorn <leendert@xxxxxxxxxxxxxx>
Date: Sat, 28 May 2005 10:40:35 -0400
Delivery-date: Sat, 28 May 2005 15:12:36 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Organization: IBM T.J. Watson Research Center
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
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>


--- xeno-unstable.orig/xen/arch/x86/vmx.c       2005-05-28 10:29:32.000000000 
-0400
+++ xeno-unstable.mine/xen/arch/x86/vmx.c       2005-05-28 10:39:59.000000000 
-0400
@@ -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-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] VMX world switch does not handle all cases, Leendert van Doorn <=