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

[Xen-changelog] [xen-unstable] Nested VMX: always mark VVMCS as not-launched on VMCLEAR.



# HG changeset patch
# User Tim Deegan <Tim.Deegan@xxxxxxxxxx>
# Date 1311696024 -3600
# Node ID 3114b45cf7a0a2d915884bba544be451968b6d0c
# Parent  e8d1c8f074babcb0e4511393106e80a918a38204
Nested VMX: always mark VVMCS as not-launched on VMCLEAR.

The SDM says to flush changes and clear the launch state even if this
isn't the "current VMCS".  KVM relies on this behaviour, so take the
warning printk away as well.

Signed-off-by: Tim Deegan <Tim.Deegan@xxxxxxxxxx>
---


diff -r e8d1c8f074ba -r 3114b45cf7a0 xen/arch/x86/hvm/vmx/vvmx.c
--- a/xen/arch/x86/hvm/vmx/vvmx.c       Mon Jul 25 16:43:26 2011 +0100
+++ b/xen/arch/x86/hvm/vmx/vvmx.c       Tue Jul 26 17:00:24 2011 +0100
@@ -1162,6 +1162,7 @@
     struct vmx_inst_decoded decode;
     struct nestedvcpu *nvcpu = &vcpu_nestedhvm(v);
     unsigned long gpa = 0;
+    void *vvmcs;
     int rc;
 
     rc = decode_vmx_inst(regs, &decode, &gpa, 0);
@@ -1171,24 +1172,24 @@
     if ( gpa & 0xfff )
     {
         vmreturn(regs, VMFAIL_INVALID);
-        goto out;
+        return X86EMUL_OKAY;
+    }
+    
+    if ( gpa == nvcpu->nv_vvmcxaddr ) 
+    {
+        __set_vvmcs(nvcpu->nv_vvmcx, NVMX_LAUNCH_STATE, 0);
+        nvmx_purge_vvmcs(v);
+    }
+    else 
+    {
+        /* Even if this VMCS isn't the current one, we must clear it. */
+        vvmcs = hvm_map_guest_frame_rw(gpa >> PAGE_SHIFT);
+        if ( vvmcs ) 
+            __set_vvmcs(vvmcs, NVMX_LAUNCH_STATE, 0);
+        hvm_unmap_guest_frame(vvmcs);
     }
 
-    if ( gpa != nvcpu->nv_vvmcxaddr && nvcpu->nv_vvmcxaddr != VMCX_EADDR )
-    {
-        gdprintk(XENLOG_WARNING, 
-                 "vmclear gpa %lx not the same as current vmcs %"PRIpaddr"\n",
-                 gpa, nvcpu->nv_vvmcxaddr);
-        vmreturn(regs, VMSUCCEED);
-        goto out;
-    }
-    if ( nvcpu->nv_vvmcxaddr != VMCX_EADDR )
-        __set_vvmcs(nvcpu->nv_vvmcx, NVMX_LAUNCH_STATE, 0);
-    nvmx_purge_vvmcs(v);
-
     vmreturn(regs, VMSUCCEED);
-
-out:
     return X86EMUL_OKAY;
 }
 

_______________________________________________
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®.