]> xenbits.xensource.com Git - people/liuw/xtf.git/commitdiff
hvm: Honour test_wants_user_mappings
authorAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 19 Jul 2016 13:51:30 +0000 (14:51 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 19 Jul 2016 15:09:47 +0000 (16:09 +0100)
Fewer tests overall need user mappings, so construct the identity pagetables
without _PAGE_USER set in leaf entries by default.

Before loading paging settings, check whether a test has opted-in to user
mappings, and re-add _PAGE_USER to the l1 and l2 pagetable entries.

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

index 3288216af0a4a831864e0ecccbca0691fb60e044..1ffd91820604d0819f1de96c0741ab77a5d48e25 100644 (file)
@@ -29,6 +29,21 @@ GLOBAL(_start)                  /* HVM common setup. */
 # 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
+
+        mov $l1_identmap, %edx
+        mov $l2_identmap_end, %ecx
+        sub %edx, %ecx
+        shr $PTE_ORDER, %ecx
+        add $PTE_SIZE, %edx /* Avoid setting _PAGE_USER in the NULL entry. */
+.Lnext_pte:
+        orb $_PAGE_USER, (%edx)
+        add $PTE_SIZE, %edx
+        loop .Lnext_pte
+.Lskip_user:
+
         mov %eax, %cr4
         mov %ebx, %cr3
 #endif /* CONFIG_PAGING_LEVELS > 0 */
index ffb94dc6337ca1d406b750001f43e94c28ac9a4d..44e3825e85b43029e135c5034eeb7c0bd0219d4e 100644 (file)
@@ -9,7 +9,9 @@
         .type sym, STT_OBJECT; \
         SIZE(sym)
 
-#define PAGE_COMMON _PAGE_DIRTY + _PAGE_ACCESSED + _PAGE_USER + _PAGE_RW + _PAGE_PRESENT
+#define _PAGE_LEAF    (_PAGE_AD + _PAGE_RW + _PAGE_PRESENT)
+#define _PAGE_SUPER   (_PAGE_PSE + _PAGE_LEAF)
+#define _PAGE_NONLEAF (_PAGE_USER + _PAGE_LEAF)
 
 #define PAE_IDX(sym) ((. - (sym)) / PAE_PTE_SIZE)
 #define PSE_IDX(sym) ((. - (sym)) / PSE_PTE_SIZE)
 PAGETABLE_START(pae_l1_identmap)
         .long 0, 0 /* Unmap page at 0 to catch errors with NULL pointers. */
         .rept PAE_L1_PT_ENTRIES - 1
-        .long (PAE_IDX(pae_l1_identmap) << PAE_L1_PT_SHIFT) + PAGE_COMMON
+        .long (PAE_IDX(pae_l1_identmap) << PAE_L1_PT_SHIFT) + _PAGE_LEAF
         .long 0
         .endr
 PAGETABLE_END(pae_l1_identmap)
 
 /* PAE mappings up to 4G, mostly in 2M superpages. Uses 4x 4k pages. */
 PAGETABLE_START(pae_l2_identmap)
-        .long pae_l1_identmap + PAGE_COMMON
+        .long pae_l1_identmap + _PAGE_NONLEAF
         .long 0
         .rept (4 * PAE_L2_PT_ENTRIES) - 1
-        .long (PAE_IDX(pae_l2_identmap) << PAE_L2_PT_SHIFT) + _PAGE_PSE + PAGE_COMMON
+        .long (PAE_IDX(pae_l2_identmap) << PAE_L2_PT_SHIFT) + _PAGE_SUPER
         .long 0
         .endr
 PAGETABLE_END(pae_l2_identmap)
+.Lpae_l2_identmap_end:
 
 /* PAE l3 pagetable.  Maps 4x l2 tables. */
 PAGETABLE_START(pae_l3_identmap)
         .rept 4
-        .long pae_l2_identmap + (PAE_IDX(pae_l3_identmap) << PAGE_SHIFT) + PAGE_COMMON
+        .long pae_l2_identmap + (PAE_IDX(pae_l3_identmap) << PAGE_SHIFT) + _PAGE_NONLEAF
         .long 0
         .endr
         .fill PAE_L3_PT_ENTRIES - 4, 8, 0
@@ -47,7 +50,7 @@ PAGETABLE_END(pae_l3_identmap)
 
 /* PAE l4 pagetable.  Maps 1x l3 table. */
 PAGETABLE_START(pae_l4_identmap)
-        .long pae_l3_identmap + PAGE_COMMON
+        .long pae_l3_identmap + _PAGE_NONLEAF
         .long 0
         .fill PAE_L4_PT_ENTRIES - 1, 8, 0
 PAGETABLE_END(pae_l4_identmap)
@@ -56,17 +59,18 @@ PAGETABLE_END(pae_l4_identmap)
 PAGETABLE_START(pse_l1_identmap)
         .long 0 /* Unmap page at 0 to catch errors with NULL pointers. */
         .rept PSE_L1_PT_ENTRIES - 1
-        .long (PSE_IDX(pse_l1_identmap) << PSE_L1_PT_SHIFT) + PAGE_COMMON
+        .long (PSE_IDX(pse_l1_identmap) << PSE_L1_PT_SHIFT) + _PAGE_LEAF
         .endr
 PAGETABLE_END(pse_l1_identmap)
 
 /* PSE mappings up to 4G, mostly in 4M superpages.  Uses 1x 4k page. */
 PAGETABLE_START(pse_l2_identmap)
-        .long pse_l1_identmap + PAGE_COMMON
+        .long pse_l1_identmap + _PAGE_NONLEAF
         .rept PSE_L2_PT_ENTRIES - 1
-        .long (PSE_IDX(pse_l2_identmap) << PSE_L2_PT_SHIFT) + _PAGE_PSE + PAGE_COMMON
+        .long (PSE_IDX(pse_l2_identmap) << PSE_L2_PT_SHIFT) + _PAGE_SUPER
         .endr
 PAGETABLE_END(pse_l2_identmap)
+.Lpse_l2_identmap_end:
 
 /* PAE l3 32bit quad.  Contains 4 64bit entries. */
 PAGETABLE_START(pae32_l3_identmap)
@@ -81,12 +85,15 @@ PAGETABLE_END(pae32_l3_identmap)
 #if CONFIG_PAGING_LEVELS >= 3
         .set l1_identmap, pae_l1_identmap
         .set l2_identmap, pae_l2_identmap
+        .set l2_identmap_end, .Lpae_l2_identmap_end
 #else
         .set l1_identmap, pse_l1_identmap
         .set l2_identmap, pse_l2_identmap
+        .set l2_identmap_end, .Lpse_l2_identmap_end
 #endif
         .global l1_identmap
         .global l2_identmap
+        .global l2_identmap_end
 
 /*
  * Local variables: