]> xenbits.xensource.com Git - xen.git/commitdiff
x86/compat: Cleanup and further debugging of SMAP/SMEP fixup 4.7.0-rc3
authorAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 16 May 2016 10:48:52 +0000 (11:48 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 16 May 2016 12:11:05 +0000 (13:11 +0100)
 * Abstract (X86_CR4_SMEP | X86_CR4_SMAP) behind XEN_CR4_PV32_BITS to avoid
   opencoding the invidial bits which are fixed up behind a 32bit PV guests
   back.
 * In the debug case, perform the the AND and CMP on 64bit values rather than
   32bit values, to match the logic in then non-debug case.
 * Show cr4_pv32_mask in the BUG register dump

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Release-acked-by: Wei Liu <wei.liu2@citrix.com>
xen/arch/x86/setup.c
xen/arch/x86/x86_64/compat/entry.S
xen/include/asm-x86/processor.h

index 4c2d01ad5d4138c1c0c91bf1d8587f98c4d483d8..de682e7c26881b6e66d7140e17e29cfae19367b8 100644 (file)
@@ -1400,7 +1400,7 @@ void __init noreturn __start_xen(unsigned long mbi_p)
     if ( cpu_has_smap )
         set_in_cr4(X86_CR4_SMAP);
 
-    cr4_pv32_mask = mmu_cr4_features & (X86_CR4_SMEP | X86_CR4_SMAP);
+    cr4_pv32_mask = mmu_cr4_features & XEN_CR4_PV32_BITS;
 
     if ( cpu_has_fsgsbase )
         set_in_cr4(X86_CR4_FSGSBASE);
index dbc39840bdefda97d5fd3af32d1d372314d0d4b6..ee72ece7e61e58d916b565479358c6ebc4b9bbaa 100644 (file)
@@ -204,7 +204,7 @@ ENTRY(cr4_pv32_restore)
         push  %rdx
         GET_CPUINFO_FIELD(cr4, dx)
         mov   (%rdx), %rax
-        test  $X86_CR4_SMEP|X86_CR4_SMAP,%eax
+        test  $XEN_CR4_PV32_BITS, %eax
         jnz   0f
         or    cr4_pv32_mask(%rip), %rax
         mov   %rax, %cr4
@@ -215,9 +215,11 @@ ENTRY(cr4_pv32_restore)
 #ifndef NDEBUG
         /* Check that _all_ of the bits intended to be set actually are. */
         mov   %cr4, %rax
-        and   cr4_pv32_mask(%rip), %eax
-        cmp   cr4_pv32_mask(%rip), %eax
+        and   cr4_pv32_mask(%rip), %rax
+        cmp   cr4_pv32_mask(%rip), %rax
         je    1f
+        /* Cause cr4_pv32_mask to be visible in the BUG register dump. */
+        mov   cr4_pv32_mask(%rip), %rdx
         BUG
 1:
 #endif
index 4a6af0fc83ef6fac63ca0ac6b88fd2a87b394513..ddaaf2dedc88a56812283a9c45acff541b4afea6 100644 (file)
 
 #define XEN_MINIMAL_CR4 (X86_CR4_PGE | X86_CR4_PAE)
 
+#define XEN_CR4_PV32_BITS (X86_CR4_SMEP|X86_CR4_SMAP)
+
 #define XEN_SYSCALL_MASK (X86_EFLAGS_AC|X86_EFLAGS_VM|X86_EFLAGS_RF|    \
                           X86_EFLAGS_NT|X86_EFLAGS_DF|X86_EFLAGS_IF|    \
                           X86_EFLAGS_TF)