Index: sys/i386/i386/pmap.c =================================================================== --- sys/i386/i386/pmap.c +++ sys/i386/i386/pmap.c @@ -3466,11 +3466,19 @@ PMAP_LOCK(pmap); sched_pin(); - /* - * In the case that a page table page is not - * resident, we are creating it here. - */ - if (va < VM_MAXUSER_ADDRESS) { + pde = pmap_pde(pmap, va); + if ((*pde & PG_PS) != 0) { + /* PG_V is asserted by pmap_demote_pde */ + pmap_demote_pde(pmap, pde, va); + if (va < VM_MAXUSER_ADDRESS) { + mpte = PHYS_TO_VM_PAGE(*pde & PG_FRAME); + mpte->wire_count++; + } + } else if (va < VM_MAXUSER_ADDRESS) { + /* + * In the case that a page table page is not resident, + * we are creating it here. + */ mpte = pmap_allocpte(pmap, va, flags); if (mpte == NULL) { KASSERT((flags & PMAP_ENTER_NOSLEEP) != 0, @@ -3481,10 +3489,6 @@ return (KERN_RESOURCE_SHORTAGE); } } - - pde = pmap_pde(pmap, va); - if ((*pde & PG_PS) != 0) - panic("pmap_enter: attempted pmap_enter on 4MB page"); pte = pmap_pte_quick(pmap, va); /*