From c54fe25dcb9f239a7f8b93cd213916d4208b9106 Mon Sep 17 00:00:00 2001 From: Emmanuel Vadot Date: Thu, 19 Jul 2018 21:58:06 +0000 Subject: [PATCH] Raise the size of L3 table for early devmap on arm64 Some driver (like efifb) needs to map more than the current L2_SIZE Raise the size so we can map the framebuffer setup by the bootloader. Reviewed by: cognet --- sys/arm64/arm64/pmap.c | 4 ++-- sys/arm64/include/pte.h | 2 ++ sys/kern/subr_devmap.c | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/sys/arm64/arm64/pmap.c b/sys/arm64/arm64/pmap.c index e600e5efeee2..403f70bb4965 100644 --- a/sys/arm64/arm64/pmap.c +++ b/sys/arm64/arm64/pmap.c @@ -836,7 +836,7 @@ pmap_bootstrap(vm_offset_t l0pt, vm_offset_t l1pt, vm_paddr_t kernstart, freemempos = pmap_bootstrap_l2(l1pt, va, freemempos); /* And the l3 tables for the early devmap */ freemempos = pmap_bootstrap_l3(l1pt, - VM_MAX_KERNEL_ADDRESS - L2_SIZE, freemempos); + VM_MAX_KERNEL_ADDRESS - (PMAP_MAPDEV_EARLY_SIZE), freemempos); cpu_tlb_flushID(); @@ -858,7 +858,7 @@ pmap_bootstrap(vm_offset_t l0pt, vm_offset_t l1pt, vm_paddr_t kernstart, virtual_avail = preinit_map_va + PMAP_PREINIT_MAPPING_SIZE; virtual_avail = roundup2(virtual_avail, L1_SIZE); - virtual_end = VM_MAX_KERNEL_ADDRESS - L2_SIZE; + virtual_end = VM_MAX_KERNEL_ADDRESS - (PMAP_MAPDEV_EARLY_SIZE); kernel_vm_end = virtual_avail; pa = pmap_early_vtophys(l1pt, freemempos); diff --git a/sys/arm64/include/pte.h b/sys/arm64/include/pte.h index 26421a61bafb..acd3f81ab41c 100644 --- a/sys/arm64/include/pte.h +++ b/sys/arm64/include/pte.h @@ -109,6 +109,8 @@ typedef uint64_t pt_entry_t; /* page table entry */ /* 0x2 also marks an invalid address */ #define L3_PAGE 0x3 +#define PMAP_MAPDEV_EARLY_SIZE (L2_SIZE * 4) + #define L0_ENTRIES_SHIFT 9 #define L0_ENTRIES (1 << L0_ENTRIES_SHIFT) #define L0_ADDR_MASK (L0_ENTRIES - 1) diff --git a/sys/kern/subr_devmap.c b/sys/kern/subr_devmap.c index ef19aea1ee6b..7dace37744e6 100644 --- a/sys/kern/subr_devmap.c +++ b/sys/kern/subr_devmap.c @@ -305,8 +305,8 @@ pmap_mapdev_attr(vm_offset_t pa, vm_size_t size, vm_memattr_t ma) if (early_boot) { akva_devmap_vaddr = trunc_page(akva_devmap_vaddr - size); va = akva_devmap_vaddr; - KASSERT(va >= VM_MAX_KERNEL_ADDRESS - L2_SIZE, - ("Too many early devmap mappings")); + KASSERT(va >= (VM_MAX_KERNEL_ADDRESS - (PMAP_MAPDEV_EARLY_SIZE)), + ("Too many early devmap mappings 2")); } else va = kva_alloc(size); if (!va)