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

[Xen-devel] [PATCH for-4.11 v2 3/3] VMX: check host CR0 before entering guest



While we don't expect CR0 to change behind our backs, cope with this
happening, but other than for CR4 also log a (debug) message.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

--- a/xen/arch/x86/hvm/vmx/vmcs.c
+++ b/xen/arch/x86/hvm/vmx/vmcs.c
@@ -1676,7 +1676,7 @@ void vmx_vmentry_failure(void)
 void vmx_do_resume(struct vcpu *v)
 {
     bool_t debug_state;
-    unsigned long host_cr4;
+    unsigned long host_cr4, host_cr0, cr0;
 
     if ( v->arch.hvm_vmx.active_cpu == smp_processor_id() )
         vmx_vmcs_reload(v);
@@ -1732,6 +1732,15 @@ void vmx_do_resume(struct vcpu *v)
     if ( host_cr4 != read_cr4() )
         __vmwrite(HOST_CR4, read_cr4());
 
+    /* Check host CR0 (its value shouldn't have changed). */
+    __vmread(HOST_CR0, &host_cr0);
+    cr0 = read_cr0();
+    if ( host_cr0 != cr0 )
+    {
+        dprintk(XENLOG_ERR, "%pv: CR0 %lx != %lx\n", v, host_cr0, cr0);
+        __vmwrite(HOST_CR0, cr0);
+    }
+
     reset_stack_and_jump(vmx_asm_do_vmentry);
 }
 



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

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