riscv pmap: add some pv list assertions

Ensure that we don't end up with a superpage in the vm_page_t's pv list.

This may help with debugging the panic reported in PR 250866, in which
l3 in pmap_remove_write() was found to be NULL. Adding a KASSERT to this
function will help narrow down the cause of this panic the next time it
occurs.

Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D28109
This commit is contained in:
mhorne 2020-11-04 13:51:10 -04:00 committed by Mitchell Horne
parent 70ba77706d
commit 0628f68357

View File

@ -3498,7 +3498,10 @@ pmap_page_wired_mappings(vm_page_t m)
goto restart; goto restart;
} }
} }
l3 = pmap_l3(pmap, pv->pv_va); l2 = pmap_l2(pmap, pv->pv_va);
KASSERT((pmap_load(l2) & PTE_RWX) == 0,
("%s: found a 2mpage in page %p's pv list", __func__, m));
l3 = pmap_l2_to_l3(l2, pv->pv_va);
if ((pmap_load(l3) & PTE_SW_WIRED) != 0) if ((pmap_load(l3) & PTE_SW_WIRED) != 0)
count++; count++;
PMAP_UNLOCK(pmap); PMAP_UNLOCK(pmap);
@ -3745,7 +3748,10 @@ pmap_page_test_mappings(vm_page_t m, boolean_t accessed, boolean_t modified)
goto restart; goto restart;
} }
} }
l3 = pmap_l3(pmap, pv->pv_va); l2 = pmap_l2(pmap, pv->pv_va);
KASSERT((pmap_load(l2) & PTE_RWX) == 0,
("%s: found a 2mpage in page %p's pv list", __func__, m));
l3 = pmap_l2_to_l3(l2, pv->pv_va);
rv = (pmap_load(l3) & mask) == mask; rv = (pmap_load(l3) & mask) == mask;
PMAP_UNLOCK(pmap); PMAP_UNLOCK(pmap);
if (rv) if (rv)
@ -3901,7 +3907,10 @@ pmap_remove_write(vm_page_t m)
goto retry_pv_loop; goto retry_pv_loop;
} }
} }
l3 = pmap_l3(pmap, pv->pv_va); l2 = pmap_l2(pmap, pv->pv_va);
KASSERT((pmap_load(l2) & PTE_RWX) == 0,
("%s: found a 2mpage in page %p's pv list", __func__, m));
l3 = pmap_l2_to_l3(l2, pv->pv_va);
oldl3 = pmap_load(l3); oldl3 = pmap_load(l3);
retry: retry:
if ((oldl3 & PTE_W) != 0) { if ((oldl3 & PTE_W) != 0) {
@ -4172,8 +4181,7 @@ pmap_clear_modify(vm_page_t m)
} }
l2 = pmap_l2(pmap, pv->pv_va); l2 = pmap_l2(pmap, pv->pv_va);
KASSERT((pmap_load(l2) & PTE_RWX) == 0, KASSERT((pmap_load(l2) & PTE_RWX) == 0,
("pmap_clear_modify: found a 2mpage in page %p's pv list", ("%s: found a 2mpage in page %p's pv list", __func__, m));
m));
l3 = pmap_l2_to_l3(l2, pv->pv_va); l3 = pmap_l2_to_l3(l2, pv->pv_va);
if ((pmap_load(l3) & (PTE_D | PTE_W)) == (PTE_D | PTE_W)) { if ((pmap_load(l3) & (PTE_D | PTE_W)) == (PTE_D | PTE_W)) {
pmap_clear_bits(l3, PTE_D | PTE_W); pmap_clear_bits(l3, PTE_D | PTE_W);