From: Andrew Cooper Date: Mon, 17 Oct 2016 17:24:55 +0000 (+0100) Subject: Introduce cr3_target as an alias of the pagetable pointed to by %cr3 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=b0bfc2bf146e1d255b2550172ec7ac7f58c95263;p=xtf.git Introduce cr3_target as an alias of the pagetable pointed to by %cr3 Use the new alias to simplify the pagetable setup in in head_hvm.S Signed-off-by: Andrew Cooper --- diff --git a/arch/x86/boot/head_hvm.S b/arch/x86/boot/head_hvm.S index 1ffd918..231d746 100644 --- a/arch/x86/boot/head_hvm.S +++ b/arch/x86/boot/head_hvm.S @@ -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 */ diff --git a/arch/x86/hvm/pagetables.S b/arch/x86/hvm/pagetables.S index 44e3825..cfe241f 100644 --- a/arch/x86/hvm/pagetables.S +++ b/arch/x86/hvm/pagetables.S @@ -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 diff --git a/include/arch/x86/page.h b/include/arch/x86/page.h index bff5063..fea6426 100644 --- a/include/arch/x86/page.h +++ b/include/arch/x86/page.h @@ -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__ */