]> xenbits.xensource.com Git - xtf.git/commitdiff
Introduce __{KERN,USER}_{CS,DS}32 selector constants
authorAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 9 Apr 2018 13:06:20 +0000 (14:06 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 9 Apr 2018 13:19:22 +0000 (14:19 +0100)
These are intended to facilitate 64bit compatiblity mode segments, but are
exposed in 32bit builds as straight aliases of __{KERN,USER}_{CS,DS} for the
benefit of common code.

Fix up one opencoded use in the XSA-196 PoC.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
arch/x86/include/arch/segment.h
tests/xsa-196/main.c

index 328d46423d125e56b60df31a1fd20abf0bc52f2f..d915e978d272d084f3b9638bf958e07ffb77ec41 100644 (file)
 
 #ifdef __x86_64__
 
-#define __KERN_CS (GDTE_CS64_DPL0 * 8)
-#define __KERN_DS (0)
-#define __USER_CS (GDTE_CS64_DPL3 * 8 + 3)
-#define __USER_DS (GDTE_DS32_DPL3 * 8 + 3)
+#define __KERN_CS   (GDTE_CS64_DPL0 * 8)
+#define __KERN_DS   (0)
+#define __KERN_CS32 (GDTE_CS32_DPL0 * 8)
+#define __KERN_DS32 __KERN_DS
+
+#define __USER_CS   (GDTE_CS64_DPL3 * 8 + 3)
+#define __USER_DS   (GDTE_DS32_DPL3 * 8 + 3)
+#define __USER_CS32 (GDTE_CS32_DPL3 * 8 + 3)
+#define __USER_DS32 __USER_DS
 
 #else /* __x86_64__ */
 
-#define __KERN_CS (GDTE_CS32_DPL0 * 8)
-#define __KERN_DS (GDTE_DS32_DPL0 * 8)
-#define __USER_CS (GDTE_CS32_DPL3 * 8 + 3)
-#define __USER_DS (GDTE_DS32_DPL3 * 8 + 3)
+#define __KERN_CS   (GDTE_CS32_DPL0 * 8)
+#define __KERN_DS   (GDTE_DS32_DPL0 * 8)
+#define __KERN_CS32 __KERN_CS
+#define __KERN_DS32 __KERN_DS
+
+#define __USER_CS   (GDTE_CS32_DPL3 * 8 + 3)
+#define __USER_DS   (GDTE_DS32_DPL3 * 8 + 3)
+#define __USER_CS32 __USER_CS
+#define __USER_DS32 __USER_DS
 
 #endif /* __x86_64__ */
 
  * __{KERN,USER}_DS are used for all data selectors including %ss, use the
  * FLAT_RING3_SS64 rather than FLAT_RING3_DS64.
  */
-#define __KERN_CS (FLAT_RING3_CS64 & ~3)
-#define __KERN_DS (FLAT_RING3_SS64 & ~3)
-#define __USER_CS FLAT_RING3_CS64
-#define __USER_DS FLAT_RING3_SS64
+#define __KERN_CS   (FLAT_RING3_CS64 & ~3)
+#define __KERN_DS   (FLAT_RING3_SS64 & ~3)
+#define __KERN_CS32 (FLAT_RING3_CS32 & ~3)
+#define __KERN_DS32 __KERN_DS
+
+#define __USER_CS   FLAT_RING3_CS64
+#define __USER_DS   FLAT_RING3_SS64
+#define __USER_CS32 FLAT_RING3_CS32
+#define __USER_DS32 __USER_DS
 
 #else /* __x86_64__ */
 
-#define __KERN_CS FLAT_RING1_CS
-#define __KERN_DS FLAT_RING1_DS
-#define __USER_CS FLAT_RING3_CS
-#define __USER_DS FLAT_RING3_DS
+#define __KERN_CS   FLAT_RING1_CS
+#define __KERN_DS   FLAT_RING1_DS
+#define __KERN_CS32 __KERN_CS
+#define __KERN_DS32 __KERN_DS
+
+#define __USER_CS   FLAT_RING3_CS
+#define __USER_DS   FLAT_RING3_DS
+#define __USER_CS32 __USER_CS
+#define __USER_DS32 __USER_DS
 
 #endif /* __x86_64__ */
 
index 7d4a68fbef0aea225a67653f57785b747b6a78ea..504ea692a6d74c6fe966ad751799d6de18374319 100644 (file)
@@ -60,7 +60,7 @@ unsigned long compat_userspace(void)
                   ".code64; 1:"
                   : "+a" (fault)
                   : [df]   "i" (X86_EXC_DF),
-                    [cs32] "i" (GDTE_CS32_DPL3 * 8 + 3),
+                    [cs32] "i" (__USER_CS32),
                     [cs]   "i" (__USER_CS),
                     "X" (ex_record_fault_eax));