diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -7537,20 +7537,25 @@ * resident, we are creating it here. */ if (va < VM_MAXUSER_ADDRESS) { + pdp_entry_t *pdpe; + pd_entry_t *pde; vm_pindex_t ptepindex; - pd_entry_t *ptepa; /* * Calculate pagetable page index */ ptepindex = pmap_pde_pindex(va); - if (mpte && (mpte->pindex == ptepindex)) { + if (mpte != NULL && (mpte->pindex == ptepindex)) { mpte->ref_count++; } else { - /* - * Get the page directory entry - */ - ptepa = pmap_pde(pmap, va); + pdpe = pmap_pdpe(pmap, va); + if (pdpe != NULL && (*pdpe & PG_V) != 0) { + if ((*pdpe & PG_PS) != 0) + return (NULL); + pde = pmap_pdpe_to_pde(pdpe, va); + } else { + pde = NULL; + } /* * If the page table page is mapped, we just increment @@ -7558,10 +7563,10 @@ * attempt to allocate a page table page. If this * attempt fails, we don't retry. Instead, we give up. */ - if (ptepa && (*ptepa & PG_V) != 0) { - if (*ptepa & PG_PS) + if (pde != NULL && (*pde & PG_V) != 0) { + if (*pde & PG_PS) return (NULL); - mpte = PHYS_TO_VM_PAGE(*ptepa & PG_FRAME); + mpte = PHYS_TO_VM_PAGE(*pde & PG_FRAME); mpte->ref_count++; } else { /*