From cbabbc9f56599b6e0fcf6d9c059066abac941bd4 Mon Sep 17 00:00:00 2001 From: Andrew Cooper Date: Fri, 10 Jan 2020 14:05:29 +0000 Subject: [PATCH] x86/boot: Size the boot/directmap mappings dynamically ... rather than presuming that 16M will do. On the EFI side, use l2e_add_flags() to reduce the code-generation overhead of using l2e_from_paddr() twice. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- xen/arch/x86/boot/head.S | 21 +++++++++++++-------- xen/arch/x86/efi/efi-boot.h | 23 ++++++++++++++++++----- 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S index ef9f562505..0137ee99a4 100644 --- a/xen/arch/x86/boot/head.S +++ b/xen/arch/x86/boot/head.S @@ -687,14 +687,19 @@ trampoline_setup: * handling/walking), and identity map Xen into bootmap (needed for * the transition into long mode), using 2M superpages. */ - lea sym_esi(start),%ebx - lea (1<> L2_PAGETABLE_SHIFT) & (4 * L2_PAGETABLE_ENTRIES - 1)) + + for ( i = l2_4G_offset(_start); + i <= l2_4G_offset(_end - 1); ++i ) { - unsigned int slot = (xen_phys_start >> L2_PAGETABLE_SHIFT) + i; - paddr_t addr = slot << L2_PAGETABLE_SHIFT; + l2_pgentry_t pte = l2e_from_paddr(i << L2_PAGETABLE_SHIFT, + __PAGE_HYPERVISOR | _PAGE_PSE); + + l2_bootmap[i] = pte; + + /* Bootmap RWX/Non-global. Directmap RW/Global. */ + l2e_add_flags(pte, PAGE_HYPERVISOR); - l2_directmap[slot] = l2e_from_paddr(addr, PAGE_HYPERVISOR|_PAGE_PSE); - l2_bootmap[slot] = l2e_from_paddr(addr, __PAGE_HYPERVISOR|_PAGE_PSE); + l2_directmap[i] = pte; } +#undef l2_4G_offset } static void __init efi_arch_handle_module(struct file *file, const CHAR16 *name, -- 2.39.5