]> xenbits.xensource.com Git - people/royger/xen-test-framework.git/commitdiff
Common infrastructure for userspace execution
authorAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 24 Dec 2015 20:22:30 +0000 (20:22 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 5 Jan 2016 18:59:16 +0000 (18:59 +0000)
Introduce __USER_{CS,DS}, expand the boot stack to two pages, add some DPL3
GDT descriptors, and space in GDT for a TSS.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
arch/x86/desc.c
arch/x86/setup.c
include/arch/x86/segment.h
include/arch/x86/traps.h

index 9acd62c239e194168118120f0404f765f1cc6f8f..605876926a115634d249eb1e925ea228cb64c192 100644 (file)
@@ -6,6 +6,13 @@ user_desc gdt[NR_GDT_ENTRIES] =
     [GDTE_CS64_DPL0] = INIT_GDTE_SYM(0, 0xfffff, COMMON, CODE, DPL0, R, L),
     [GDTE_CS32_DPL0] = INIT_GDTE_SYM(0, 0xfffff, COMMON, CODE, DPL0, R, D),
     [GDTE_DS32_DPL0] = INIT_GDTE_SYM(0, 0xfffff, COMMON, DATA, DPL0, B, W),
+
+    [GDTE_CS64_DPL3] = INIT_GDTE_SYM(0, 0xfffff, COMMON, CODE, DPL3, R, L),
+    [GDTE_CS32_DPL3] = INIT_GDTE_SYM(0, 0xfffff, COMMON, CODE, DPL3, R, D),
+    [GDTE_DS32_DPL3] = INIT_GDTE_SYM(0, 0xfffff, COMMON, DATA, DPL3, B, W),
+
+    /* [GDTE_TSS]     */
+    /* [GDTE_TSS + 1] */
 };
 
 desc_ptr gdt_ptr =
index 0bfff1e0b88b2eae09c736b4aaa6c32a449ecf70..914fd389073d12d0606fecc4479c03a8c03db688 100644 (file)
@@ -7,7 +7,13 @@
 #include <arch/x86/mm.h>
 #include <arch/x86/traps.h>
 
-uint8_t boot_stack[PAGE_SIZE] __aligned(PAGE_SIZE);
+/*
+ * XTF Stack layout:
+ *
+ * boot_stack[page 2] Exception entrypoints
+ * boot_stack[page 1] Top of work stack
+ */
+uint8_t boot_stack[2 * PAGE_SIZE] __aligned(PAGE_SIZE);
 
 const char *environment_description =
 #if defined(CONFIG_ENV_pv32)
index b34bce408970d99ddfe64f26031b6623daebb878..8082e62bd4aecb8fbc36696b48ff1d5f26513002 100644 (file)
  *  1 - 64bit supervisor code
  *  2 - 32bit supervisor code
  *  3 - 32bit supervisor data
+ *  4 - 64bit userspace code
+ *  5 - 32bit userspace code
+ *  6 - 32bit userspace data
+ *  7 - TSS (two slots in long mode)
  */
 
 #define GDTE_CS64_DPL0 1
 #define GDTE_CS32_DPL0 2
 #define GDTE_DS32_DPL0 3
+#define GDTE_CS64_DPL3 4
+#define GDTE_CS32_DPL3 5
+#define GDTE_DS32_DPL3 6
 
-#define NR_GDT_ENTRIES 4
+#define GDTE_TSS 7
+
+#define NR_GDT_ENTRIES 9
 
 #if defined(CONFIG_ENV_hvm64)
 
 #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)
 
 #elif defined(CONFIG_ENV_hvm32)
 
 #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)
 
 #endif
 
  */
 #define __KERN_CS (FLAT_RING3_CS64 & ~3)
 #define __KERN_DS (FLAT_RING3_DS64 & ~3)
+#define __USER_CS FLAT_RING3_CS64
+#define __USER_DS FLAT_RING3_DS64
 
 #elif defined(CONFIG_ENV_pv32)
 
 #define __KERN_CS FLAT_RING1_CS
 #define __KERN_DS FLAT_RING1_DS
+#define __USER_CS FLAT_RING3_CS
+#define __USER_DS FLAT_RING3_DS
 
 #endif
 
index 53eabb7b779fc7e95f9eb4a127ff20013160875b..d6c0d0c32fa84cd2e73c2d424cc3a573ac53ed6b 100644 (file)
@@ -3,6 +3,7 @@
 
 #include <xtf/compiler.h>
 #include <arch/x86/regs.h>
+#include <arch/x86/page.h>
 
 /*
  * Arch-specific function to initialise the exception entry points, etc.
@@ -15,6 +16,8 @@ void arch_init_traps(void);
  */
 void __noreturn arch_crash_hard(void);
 
+extern uint8_t boot_stack[2 * PAGE_SIZE];
+
 #endif /* XTF_X86_TRAPS_H */
 
 /*