]> xenbits.xensource.com Git - people/royger/xen-test-framework.git/commitdiff
Rework config.h and head_hvm.S for better paging separation
authorAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 18 Jan 2016 10:48:53 +0000 (10:48 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 18 Jan 2016 10:48:53 +0000 (10:48 +0000)
config.h is modified to turn CONFIG_ENV_$foo into the finer grain
CONFIG_{PV,HVM}, CONFIG_PAGING_LEVELS and possibly CONFIG_PAGING_PAE.  It then
undefines the CONFIG_ENV_$foo #define, to prevent mistakes in regular code.
Generation of environment_description is also moved into config.h, and it is
extended to include paging information.

head_hvm.S is then modified to use the finer grain #defines.  Specifically,
CR4.PAE is only set if CONFIG_PAGING_PAE, and CR3 and CR0.PG are only set if
CONFIG_PAGING_LEVELS is greater than 0.

The existing setting of CR0.PE is removed, as it is guaranteed always to be
set.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
arch/x86/boot/head_hvm.S
arch/x86/setup.c
docs/mainpage.dox
include/arch/x86/config.h

index eaa80d5bfa436c9598d5a199d2427ae3e9c5a3b1..86909ac447c03796359fe761387996a336c1372c 100644 (file)
@@ -5,36 +5,39 @@
 #include <arch/x86/msr-index.h>
 #include <arch/x86/segment.h>
 
-        .code32 /* Always starts in 32bit flat mode. */
+        .code32                 /* Always starts in 32bit flat mode. */
+GLOBAL(_start)                  /* HVM common setup. */
 
-
-/* HVM common setup for pae paging. */
-GLOBAL(_start)
-
-        /* CR4.PAE = 1 */
+#ifdef CONFIG_PAGING_PAE        /* CR4.PAE = 1 */
         mov $X86_CR4_PAE, %eax
         mov %eax, %cr4
+#endif /* CONFIG_PAGING_PAE */
 
-        /* CR3 = l?_???map */
-#ifdef __x86_64__
+#if CONFIG_PAGING_LEVELS > 0    /* CR3 = pagetable */
+
+#if CONFIG_PAGING_LEVELS == 4
         mov $l4_identmap, %eax
-#else
+#elif CONFIG_PAGING_LEVELS == 3 && defined CONFIG_PAGING_PAE
         mov $l3_paemap, %eax
+#else
+# error Bad paging mode
 #endif
+
         mov %eax, %cr3
+#endif /* CONFIG_PAGING_LEVELS > 0 */
 
-#ifdef __x86_64__
-        /* EFER.LME = 1 */
+#ifdef __x86_64__               /* EFER.LME = 1 */
         mov $MSR_EFER, %ecx
         rdmsr
         bts $_EFER_LME, %eax
         wrmsr
-#endif
+#endif /* __x86_64__ */
 
-        /* CR0.{PG,PE} = 1 */
+#if CONFIG_PAGING_LEVELS > 0    /* CR0.PG = 1 */
         mov %cr0, %eax
-        or $(X86_CR0_PG | X86_CR0_PE), %eax
+        or $X86_CR0_PG, %eax
         mov %eax, %cr0
+#endif /* CONFIG_PAGING_LEVELS > 0 */
 
         lgdt gdt_ptr
 
index 4d092b91ecc4baa090ef4e0deca310053b8119c6..e0cab47612aeea486f2095239074a2493af9943b 100644 (file)
  */
 uint8_t boot_stack[2 * PAGE_SIZE] __aligned(PAGE_SIZE);
 
-const char *environment_description =
-#if defined(CONFIG_PV)
-    "PV"
-#elif defined(CONFIG_HVM)
-    "HVM"
-#else
-# error Bad Guest Type
-#endif
-
-#if defined(__x86_64__)
-    " 64bit"
-#elif defined(__i386__)
-    " 32bit"
-#else
-# error Bad Width
-#endif
-    ;
+const char *environment_description = ENVIRONMENT_DESCRIPTION;
 
 #ifdef CONFIG_PV
 /* Filled in by head_pv.S */
index eea5a075b9656a06eb8fc101be10f1b7c2b9aec8..c099ae34904497f859e0afe6a80935b14f0b1cf5 100644 (file)
@@ -42,7 +42,7 @@ To run tests: (see @ref errata first)
     # xl create test-pv64-example.cfg
     # cat /var/log/xen/console/guest-test-pv64-example.log
     --- Xen Test Framework ---
-    Environment: PV 64bit
+    Environment: PV 64bit (Long mode 4 levels)
     Hello World
     Test result: SUCCESS
 
index 33fd8481638f10056d23da9ce7c6ab315054e130..48bdf304c814b5b2d3da948ea1c139bb2a76e116 100644 (file)
@@ -1,10 +1,55 @@
+/**
+ * @file include/arch/x86/config.h
+ * Logic to split an environment into finer-grain @#define's
+ *
+ * Converts `CONFIG_ENV_$foo` into:
+ * - `CONFIG_PV` or `CONFIG_HVM`
+ * - `CONFIG_PAGING_LEVELS = $num`
+ * - Possibly `CONFIG_PAGING_PAE`
+ *
+ * The `CONFIG_ENV_$foo` is then undefined, to prevent its use in general code.
+ */
 #ifndef XTF_X86_CONFIG_H
 #define XTF_X86_CONFIG_H
 
-#if defined(CONFIG_ENV_pv64) || defined(CONFIG_ENV_pv32pae)
-# define CONFIG_PV
-#elif defined(CONFIG_ENV_hvm64) || defined(CONFIG_ENV_hvm32pae)
-# define CONFIG_HVM
+#if defined(CONFIG_ENV_pv64)
+
+#define CONFIG_PV
+#define CONFIG_PAGING_LEVELS 4
+#define CONFIG_PAGING_PAE
+#define ENVIRONMENT_DESCRIPTION "PV 64bit (Long mode 4 levels)"
+
+#undef CONFIG_ENV_pv64
+
+#elif defined(CONFIG_ENV_pv32pae)
+
+#define CONFIG_PV
+#define CONFIG_PAGING_LEVELS 3
+#define CONFIG_PAGING_PAE
+#define ENVIRONMENT_DESCRIPTION "PV 32bit (PAE 3 levels)"
+
+#undef CONFIG_ENV_pv32pae
+
+#elif defined(CONFIG_ENV_hvm64)
+
+#define CONFIG_HVM
+#define CONFIG_PAGING_LEVELS 4
+#define CONFIG_PAGING_PAE
+#define ENVIRONMENT_DESCRIPTION "HVM 64bit (Long mode 4 levels)"
+
+#undef CONFIG_ENV_hvm64
+
+#elif defined(CONFIG_ENV_hvm32pae)
+
+#define CONFIG_HVM
+#define CONFIG_PAGING_LEVELS 3
+#define CONFIG_PAGING_PAE
+#define ENVIRONMENT_DESCRIPTION "HVM 32bit (PAE 3 levels)"
+
+#undef CONFIG_ENV_hvm32pae
+
+#else
+# error Bad environment
 #endif
 
 #endif /* XTF_X86_CONFIG_H */