git: 2e33abc35460 - main - riscv: fix a bug in calculating the pindex for L1 page

From: Mitchell Horne <mhorne_at_FreeBSD.org>
Date: Thu, 29 Aug 2024 15:21:52 UTC
The branch main has been updated by mhorne:

URL: https://cgit.FreeBSD.org/src/commit/?id=2e33abc35460b9e2c2eeb1e43a0614db7bebbdb3

commit 2e33abc35460b9e2c2eeb1e43a0614db7bebbdb3
Author:     Wuyang Chung <wy-chung@outlook.com>
AuthorDate: 2024-08-04 14:04:12 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2024-08-29 15:20:28 +0000

    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:          a4667e09e652 ("Convert vm_page_alloc() callers to...")
    Pull Request:   https://github.com/freebsd/freebsd-src/pull/1360
---
 sys/riscv/riscv/pmap.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sys/riscv/riscv/pmap.c b/sys/riscv/riscv/pmap.c
index c372e6f7362b..4baa4948e442 100644
--- a/sys/riscv/riscv/pmap.c
+++ b/sys/riscv/riscv/pmap.c
@@ -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);