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

[Xen-changelog] [xen-unstable] hvm: Fix CR0 handling, which I broke in 15652.



# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Date 1185871631 -3600
# Node ID 9174a8cfb57851a0def9e7d61adb4b2846120355
# Parent  8daf61f4d89da68e43b46f9af331e9e9bf937eb2
hvm: Fix CR0 handling, which I broke in 15652.
Thanks to Eric Liu for spotting this.
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
 xen/arch/x86/hvm/svm/svm.c    |    2 +-
 xen/arch/x86/hvm/vmx/vmx.c    |    2 +-
 xen/include/asm-x86/hvm/hvm.h |   22 ++++++++++++----------
 3 files changed, 14 insertions(+), 12 deletions(-)

diff -r 8daf61f4d89d -r 9174a8cfb578 xen/arch/x86/hvm/svm/svm.c
--- a/xen/arch/x86/hvm/svm/svm.c        Tue Jul 31 09:39:14 2007 +0100
+++ b/xen/arch/x86/hvm/svm/svm.c        Tue Jul 31 09:47:11 2007 +0100
@@ -1677,7 +1677,7 @@ static int svm_set_cr0(unsigned long val
         return 0;
     }
 
-    value &= HVM_CR0_GUEST_RESERVED_BITS;
+    value &= ~HVM_CR0_GUEST_RESERVED_BITS;
 
     /* ET is reserved and should be always be 1. */
     value |= X86_CR0_ET;
diff -r 8daf61f4d89d -r 9174a8cfb578 xen/arch/x86/hvm/vmx/vmx.c
--- a/xen/arch/x86/hvm/vmx/vmx.c        Tue Jul 31 09:39:14 2007 +0100
+++ b/xen/arch/x86/hvm/vmx/vmx.c        Tue Jul 31 09:47:11 2007 +0100
@@ -2209,7 +2209,7 @@ static int vmx_set_cr0(unsigned long val
         return 0;
     }
 
-    value &= HVM_CR0_GUEST_RESERVED_BITS;
+    value &= ~HVM_CR0_GUEST_RESERVED_BITS;
 
     /* ET is reserved and should be always be 1. */
     value |= X86_CR0_ET;
diff -r 8daf61f4d89d -r 9174a8cfb578 xen/include/asm-x86/hvm/hvm.h
--- a/xen/include/asm-x86/hvm/hvm.h     Tue Jul 31 09:39:14 2007 +0100
+++ b/xen/include/asm-x86/hvm/hvm.h     Tue Jul 31 09:47:11 2007 +0100
@@ -301,22 +301,24 @@ static inline int hvm_event_injection_fa
 }
 
 /* These reserved bits in lower 32 remain 0 after any load of CR0 */
-#define HVM_CR0_GUEST_RESERVED_BITS \
-    ~(X86_CR0_PE | X86_CR0_MP | X86_CR0_EM | \
-      X86_CR0_TS | X86_CR0_ET | X86_CR0_NE | \
-      X86_CR0_WP | X86_CR0_AM | X86_CR0_NW | \
-      X86_CR0_CD | X86_CR0_PG)
+#define HVM_CR0_GUEST_RESERVED_BITS             \
+    (~((unsigned long)                          \
+       (X86_CR0_PE | X86_CR0_MP | X86_CR0_EM |  \
+        X86_CR0_TS | X86_CR0_ET | X86_CR0_NE |  \
+        X86_CR0_WP | X86_CR0_AM | X86_CR0_NW |  \
+        X86_CR0_CD | X86_CR0_PG)))
 
 /* These bits in CR4 are owned by the host. */
 #define HVM_CR4_HOST_MASK (mmu_cr4_features & \
     (X86_CR4_VMXE | X86_CR4_PAE | X86_CR4_MCE))
 
 /* These bits in CR4 cannot be set by the guest. */
-#define HVM_CR4_GUEST_RESERVED_BITS \
-    ~(X86_CR4_VME | X86_CR4_PVI | X86_CR4_TSD | \
-      X86_CR4_DE  | X86_CR4_PSE | X86_CR4_PAE | \
-      X86_CR4_MCE | X86_CR4_PGE | X86_CR4_PCE | \
-      X86_CR4_OSFXSR | X86_CR4_OSXMMEXCPT)
+#define HVM_CR4_GUEST_RESERVED_BITS                     \
+    (~((unsigned long)                                  \
+       (X86_CR4_VME | X86_CR4_PVI | X86_CR4_TSD |       \
+        X86_CR4_DE  | X86_CR4_PSE | X86_CR4_PAE |       \
+        X86_CR4_MCE | X86_CR4_PGE | X86_CR4_PCE |       \
+        X86_CR4_OSFXSR | X86_CR4_OSXMMEXCPT)))
 
 /* These exceptions must always be intercepted. */
 #define HVM_TRAP_MASK (1U << TRAP_machine_check)

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