]> xenbits.xensource.com Git - xtf.git/commitdiff
Introduce cr3_target as an alias of the pagetable pointed to by %cr3
authorAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 17 Oct 2016 17:24:55 +0000 (18:24 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 18 Oct 2016 12:24:44 +0000 (13:24 +0100)
Use the new alias to simplify the pagetable setup in in head_hvm.S

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
arch/x86/boot/head_hvm.S
arch/x86/hvm/pagetables.S
include/arch/x86/page.h

index 1ffd91820604d0819f1de96c0741ab77a5d48e25..231d746afee822208409537cc1333555fd4c1100 100644 (file)
@@ -10,25 +10,6 @@ GLOBAL(_start)                  /* HVM common setup. */
 
 #if CONFIG_PAGING_LEVELS > 0    /* Paging setup for CR3 and CR4 */
 
-#if CONFIG_PAGING_LEVELS == 4   /* 64bit PAE, 4 levels */
-
-        mov $X86_CR4_PAE, %eax
-        mov $pae_l4_identmap, %ebx
-
-#elif CONFIG_PAGING_LEVELS == 3 /* 32bit PAE, 3 levels */
-
-        mov $X86_CR4_PAE, %eax
-        mov $pae32_l3_identmap, %ebx
-
-#elif CONFIG_PAGING_LEVELS == 2 /* 32bit PSE, 2 levels */
-
-        mov $X86_CR4_PSE, %eax
-        mov $pse_l2_identmap, %ebx
-
-#else
-# error Bad paging mode
-#endif
-
         /* Set _PAGE_USER on leaf mappings if a test wants them. */
         cmpb $0, test_wants_user_mappings
         je .Lskip_user
@@ -44,7 +25,16 @@ GLOBAL(_start)                  /* HVM common setup. */
         loop .Lnext_pte
 .Lskip_user:
 
+#if CONFIG_PAGING_LEVELS == 2
+        mov $X86_CR4_PSE, %eax
+#elif CONFIG_PAGING_LEVELS == 3 || CONFIG_PAGING_LEVELS == 4
+        mov $X86_CR4_PAE, %eax
+#else
+# error Bad paging mode
+#endif
         mov %eax, %cr4
+
+        mov $cr3_target, %ebx
         mov %ebx, %cr3
 #endif /* CONFIG_PAGING_LEVELS > 0 */
 
index 44e3825e85b43029e135c5034eeb7c0bd0219d4e..cfe241f937ac06ab39fb1360731e5f7ee920f50d 100644 (file)
@@ -95,6 +95,24 @@ PAGETABLE_END(pae32_l3_identmap)
         .global l2_identmap
         .global l2_identmap_end
 
+        /* Alias of the pagetable %cr3 points at. */
+#if CONFIG_PAGING_LEVELS > 0
+
+#if CONFIG_PAGING_LEVELS == 2
+        .set cr3_target, pse_l2_identmap
+#elif CONFIG_PAGING_LEVELS == 3
+        .set cr3_target, pae32_l3_identmap
+#elif CONFIG_PAGING_LEVELS == 4
+        .set cr3_target, pae_l4_identmap
+#else
+# error Bad paging mode
+#endif
+
+#else
+        .set cr3_target, 0
+#endif
+        .global cr3_target
+
 /*
  * Local variables:
  * tab-width: 8
index bff5063588cbe7d3edbd5c7c5bc5e7c6420a473c..fea642616747364a181cb0815c98bc25195b375d 100644 (file)
@@ -173,6 +173,9 @@ extern intpte_t l2_identmap[4 *L2_PT_ENTRIES];
 extern intpte_t l2_identmap[L2_PT_ENTRIES];
 #endif
 
+/* Alias of the pagetable %cr3 points at. */
+extern intpte_t cr3_target[];
+
 #endif /* CONFIG_HVM */
 
 #endif /* !__ASSEMBLY__ */