From: Andrew Cooper Date: Thu, 22 Mar 2018 11:50:50 +0000 (+0000) Subject: Use a linker ASSERT() to check that the mappings are within l1_identmap[] X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=1ae15cb320a59276c2333ee20fef7c7549ffc0f7;p=xtf.git Use a linker ASSERT() to check that the mappings are within l1_identmap[] This avoids needing the runtime checks in hvm's arch_init_traps() Signed-off-by: Andrew Cooper --- diff --git a/arch/x86/hvm/traps.c b/arch/x86/hvm/traps.c index 9d732e6..96374aa 100644 --- a/arch/x86/hvm/traps.c +++ b/arch/x86/hvm/traps.c @@ -133,17 +133,11 @@ void arch_init_traps(void) { unsigned long gfn = virt_to_gfn(user_stack); - if ( gfn >= ARRAY_SIZE(l1_identmap) ) - panic("user_stack[] outside of l1_identmap[]\n"); - l1_identmap[gfn] |= _PAGE_USER; extern const char __start_user_text[], __end_user_text[]; unsigned long end = virt_to_gfn(__end_user_text); - if ( gfn >= ARRAY_SIZE(l1_identmap) ) - panic("__{start,end}_user_text[] outside of l1_identmap[]\n"); - for ( gfn = virt_to_gfn(__start_user_text); gfn < end; ++gfn ) l1_identmap[gfn] |= _PAGE_USER; diff --git a/arch/x86/link.lds.S b/arch/x86/link.lds.S index 03c9455..db77d35 100644 --- a/arch/x86/link.lds.S +++ b/arch/x86/link.lds.S @@ -92,6 +92,9 @@ ASSERT(IS_ALIGNED(__end_user_text, PAGE_SIZE), "__end_user_text misaligned"); #ifdef CONFIG_HVM +/* Check everything lives within l1_identmap[] for user and r/o mappings. */ +ASSERT(_end < (1 << (PT_ORDER + PAGE_SHIFT)), "Mappings exceed l1_identmap[]"); + ASSERT(IS_ALIGNED(pae_l1_identmap, PAGE_SIZE), "pae_l1_identmap misaligned"); ASSERT(IS_ALIGNED(pae_l2_identmap, PAGE_SIZE), "pae_l2_identmap misaligned"); ASSERT(IS_ALIGNED(pae_l3_identmap, PAGE_SIZE), "pae_l3_identmap misaligned");