riscv: fix a bug in calculating the pindex for L1 page

pmap_l1_pindex(va) expands to: ((va >> L1_SHIFT) + NUL2E)

Reviewed by:	mhorne
MFC after:	1 week
Fixes:		a4667e09e6 ("Convert vm_page_alloc() callers to...")
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1360
This commit is contained in:
Wuyang Chung 2024-08-04 22:04:12 +08:00 committed by Mitchell Horne
parent 05cf677bb8
commit 2e33abc354

View file

@ -1887,8 +1887,8 @@ pmap_growkernel(vm_offset_t addr)
nkpg = vm_page_alloc_noobj(VM_ALLOC_INTERRUPT |
VM_ALLOC_NOFREE | VM_ALLOC_WIRED | VM_ALLOC_ZERO);
if (nkpg == NULL)
panic("pmap_growkernel: no memory to grow kernel");
nkpg->pindex = kernel_vm_end >> L1_SHIFT;
panic("%s: no memory to grow kernel", __func__);
nkpg->pindex = pmap_l1_pindex(kernel_vm_end);
paddr = VM_PAGE_TO_PHYS(nkpg);
pn = (paddr / PAGE_SIZE);
@ -1913,8 +1913,8 @@ pmap_growkernel(vm_offset_t addr)
nkpg = vm_page_alloc_noobj(VM_ALLOC_INTERRUPT |
VM_ALLOC_NOFREE | VM_ALLOC_WIRED | VM_ALLOC_ZERO);
if (nkpg == NULL)
panic("pmap_growkernel: no memory to grow kernel");
nkpg->pindex = kernel_vm_end >> L2_SHIFT;
panic("%s: no memory to grow kernel", __func__);
nkpg->pindex = pmap_l2_pindex(kernel_vm_end);
paddr = VM_PAGE_TO_PHYS(nkpg);
pn = (paddr / PAGE_SIZE);