riscv: Handle invalid L2 entries in pmap_extract()
While here, eliminate a single-use local variable.
PR: 266103
Reviewed by: mhorne
(cherry picked from commit ec21f85ab5
)
This commit is contained in:
parent
38b1cbc87b
commit
4539de92bc
@ -903,27 +903,25 @@ vm_paddr_t
|
|||||||
pmap_extract(pmap_t pmap, vm_offset_t va)
|
pmap_extract(pmap_t pmap, vm_offset_t va)
|
||||||
{
|
{
|
||||||
pd_entry_t *l2p, l2;
|
pd_entry_t *l2p, l2;
|
||||||
pt_entry_t *l3p, l3;
|
pt_entry_t *l3p;
|
||||||
vm_paddr_t pa;
|
vm_paddr_t pa;
|
||||||
|
|
||||||
pa = 0;
|
pa = 0;
|
||||||
PMAP_LOCK(pmap);
|
|
||||||
/*
|
/*
|
||||||
* Start with the l2 tabel. We are unable to allocate
|
* Start with an L2 lookup, L1 superpages are currently not implemented.
|
||||||
* pages in the l1 table.
|
|
||||||
*/
|
*/
|
||||||
|
PMAP_LOCK(pmap);
|
||||||
l2p = pmap_l2(pmap, va);
|
l2p = pmap_l2(pmap, va);
|
||||||
if (l2p != NULL) {
|
if (l2p != NULL && ((l2 = pmap_load(l2p)) & PTE_V) != 0) {
|
||||||
l2 = pmap_load(l2p);
|
if ((l2 & PTE_RWX) == 0) {
|
||||||
if ((l2 & PTE_RX) == 0) {
|
|
||||||
l3p = pmap_l2_to_l3(l2p, va);
|
l3p = pmap_l2_to_l3(l2p, va);
|
||||||
if (l3p != NULL) {
|
if (l3p != NULL) {
|
||||||
l3 = pmap_load(l3p);
|
pa = PTE_TO_PHYS(pmap_load(l3p));
|
||||||
pa = PTE_TO_PHYS(l3);
|
|
||||||
pa |= (va & L3_OFFSET);
|
pa |= (va & L3_OFFSET);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* L2 is superpages */
|
/* L2 is a superpage mapping. */
|
||||||
pa = L2PTE_TO_PHYS(l2);
|
pa = L2PTE_TO_PHYS(l2);
|
||||||
pa |= (va & L2_OFFSET);
|
pa |= (va & L2_OFFSET);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user