Index: sys/amd64/amd64/pmap.c =================================================================== --- sys/amd64/amd64/pmap.c +++ sys/amd64/amd64/pmap.c @@ -421,6 +421,8 @@ static vmem_t *large_vmem; static u_int lm_ents; +#define LARGEMAP_RT_MAX_ADDRESS \ + (LARGEMAP_MIN_ADDRESS + NBPML4 * (u_long)lm_ents) int pmap_pcid_enabled = 1; SYSCTL_INT(_vm_pmap, OID_AUTO, pcid_enabled, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, @@ -1060,6 +1062,7 @@ pd_entry_t pde); static void pmap_kenter_attr(vm_offset_t va, vm_paddr_t pa, int mode); static vm_page_t pmap_large_map_getptp_unlocked(void); +static vm_paddr_t pmap_large_map_kextract(vm_offset_t va); static void pmap_pde_attr(pd_entry_t *pde, int cache_bits, int mask); #if VM_NRESERVLEVEL > 0 static void pmap_promote_pde(pmap_t pmap, pd_entry_t *pde, vm_offset_t va, @@ -2961,6 +2964,8 @@ if (va >= DMAP_MIN_ADDRESS && va < DMAP_MAX_ADDRESS) { pa = DMAP_TO_PHYS(va); + } else if (LARGEMAP_MIN_ADDRESS <= va && va < LARGEMAP_RT_MAX_ADDRESS) { + pa = pmap_large_map_kextract(va); } else { pde = *vtopde(va); if (pde & PG_PS) { @@ -8775,6 +8780,39 @@ return ((pt_entry_t *)PHYS_TO_DMAP(mphys) + pmap_pte_index(va)); } +static vm_paddr_t +pmap_large_map_kextract(vm_offset_t va) +{ + pdp_entry_t *pdpe, pdp; + pd_entry_t *pde, pd; + pt_entry_t *pte, pt; + + KASSERT(LARGEMAP_MIN_ADDRESS <= va && va < LARGEMAP_RT_MAX_ADDRESS, + ("not largemap range %#lx", (u_long)va)); + pdpe = pmap_large_map_pdpe(va); + pdp = *pdpe; + KASSERT((pdp & X86_PG_V) != 0, + ("invalid pdp va %#lx pdpe %#lx pdp %#lx", va, + (u_long)pdpe, pdp)); + if ((pdp & X86_PG_PS) != 0) { + KASSERT((amd_feature & AMDID_PAGE1GB) != 0, + ("no 1G pages, va %#lx pdpe %#lx pdp %#lx", va, + (u_long)pdpe, pdp)); + return ((pdp & PG_PSPDP_FRAME) | (va & PDPMASK)); + } + pde = pmap_pdpe_to_pde(pdpe, va); + pd = *pde; + KASSERT((pd & X86_PG_V) != 0, + ("invalid pd va %#lx pde %#lx pd %#lx", va, (u_long)pde, pd)); + if ((pd & X86_PG_PS) != 0) + return ((pd & PG_PS_FRAME) | (va & PDRMASK)); + pte = pmap_pde_to_pte(pde, va); + pt = *pte; + KASSERT((pt & X86_PG_V) != 0, + ("invalid pte va %#lx pte %#lx pt %#lx", va, (u_long)pte, pt)); + return ((pt & PG_FRAME) | (va & PAGE_MASK)); +} + static int pmap_large_map_getva(vm_size_t len, vm_offset_t align, vm_offset_t phase, vmem_addr_t *vmem_res) @@ -8891,8 +8929,8 @@ return; SLIST_INIT(&spgf); - KASSERT(LARGEMAP_MIN_ADDRESS <= sva && sva + len <= - LARGEMAP_MAX_ADDRESS + NBPML4 * (u_long)lm_ents, + KASSERT(LARGEMAP_MIN_ADDRESS <= sva && + sva + len <= LARGEMAP_RT_MAX_ADDRESS, ("not largemap range %#lx %#lx", (u_long)svaa, (u_long)svaa + len)); PMAP_LOCK(kernel_pmap); for (va = sva; va < sva + len; va += inc) { Index: sys/amd64/include/pmap.h =================================================================== --- sys/amd64/include/pmap.h +++ sys/amd64/include/pmap.h @@ -119,6 +119,7 @@ #define PG_PROMOTED X86_PG_AVAIL(54) /* PDE only */ #define PG_FRAME (0x000ffffffffff000ul) #define PG_PS_FRAME (0x000fffffffe00000ul) +#define PG_PSPDP_FRAME (0x000fffffc0000000ul) /* * Promotion to a 2MB (PDE) page mapping requires that the corresponding 4KB