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 @@ -8567,6 +8567,11 @@ boolean_t rv; PG_V = pmap_valid_bit(pmap); + + /* + * Return TRUE if and only if the PTE for the specified virtual + * address is allocated but invalid. + */ rv = FALSE; PMAP_LOCK(pmap); pde = pmap_pde(pmap, addr); 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 @@ -5246,15 +5246,21 @@ boolean_t pmap_is_prefaultable(pmap_t pmap, vm_offset_t addr) { + pd_entry_t *pde; pt_entry_t *pte; boolean_t rv; int lvl; + /* + * Return TRUE if and only if the L3 entry for the specified virtual + * address is allocated but invalid. + */ rv = FALSE; PMAP_LOCK(pmap); - pte = pmap_pte(pmap, addr, &lvl); - if (pte != NULL && pmap_load(pte) != 0) { - rv = TRUE; + pde = pmap_pde(pmap, addr, &lvl); + if (pde != NULL && lvl == 2) { + pte = pmap_l2_to_l3(pde, addr); + rv = pmap_load(pte) == 0; } PMAP_UNLOCK(pmap); return (rv); diff --git a/sys/riscv/riscv/pmap.c b/sys/riscv/riscv/pmap.c --- a/sys/riscv/riscv/pmap.c +++ b/sys/riscv/riscv/pmap.c @@ -3850,10 +3850,14 @@ pt_entry_t *l3; boolean_t rv; + /* + * Return TRUE if and only if the L3 entry for the specified virtual + * address is allocated but invalid. + */ rv = FALSE; PMAP_LOCK(pmap); l3 = pmap_l3(pmap, addr); - if (l3 != NULL && pmap_load(l3) != 0) { + if (l3 != NULL && pmap_load(l3) == 0) { rv = TRUE; } PMAP_UNLOCK(pmap);