diff --git a/sys/arm64/arm64/pmap.c b/sys/arm64/arm64/pmap.c --- a/sys/arm64/arm64/pmap.c +++ b/sys/arm64/arm64/pmap.c @@ -6518,6 +6518,20 @@ pt_entry_t *l2; int i, lvl, l2_blocks, free_l2_count, start_idx; + /* Use the DMAP region if we can */ + if (PHYS_IN_DMAP(pa) && PHYS_IN_DMAP(pa + size - 1)) { + vm_paddr_t tmp_pa; + + tmp_pa = pa; + while ((tmp_pa - pa) < size) { + if (!pmap_klookup(PHYS_TO_DMAP(tmp_pa), NULL)) + goto no_dmap; + tmp_pa += PAGE_SIZE; + } + + return ((void *)PHYS_TO_DMAP(pa)); + } +no_dmap: if (!vm_initialized) { /* * No L3 ptables so map entire L2 blocks where start VA is: @@ -6637,6 +6651,9 @@ bool preinit_map; va = (vm_offset_t)p; + if (VIRT_IN_DMAP(va)) + return; + l2_blocks = (roundup2(va + size, L2_SIZE) - rounddown2(va, L2_SIZE)) >> L2_SHIFT; KASSERT(l2_blocks > 0, ("pmap_unmapbios: invalid size %lx", size));