git: 65a33120c3d5 - main - riscv: fix vm.pmap.kernel_maps with Sv48

From: Mitchell Horne <mhorne_at_FreeBSD.org>
Date: Tue, 04 Jun 2024 23:19:36 UTC
The branch main has been updated by mhorne:

URL: https://cgit.FreeBSD.org/src/commit/?id=65a33120c3d5c4bd815de1c463fac0cd3ce7d368

commit 65a33120c3d5c4bd815de1c463fac0cd3ce7d368
Author:     Mitchell Horne <mhorne@FreeBSD.org>
AuthorDate: 2024-06-04 23:18:54 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2024-06-04 23:18:54 +0000

    riscv: fix vm.pmap.kernel_maps with Sv48
    
    With 4-level paging enabled, the layout of KVA is identical, but we need
    to step through an extra level to find the L1 table.
    
    Reviewed by:    markj
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D45473
---
 sys/riscv/riscv/pmap.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/sys/riscv/riscv/pmap.c b/sys/riscv/riscv/pmap.c
index e8504bcb0f59..0bdf3be8ea39 100644
--- a/sys/riscv/riscv/pmap.c
+++ b/sys/riscv/riscv/pmap.c
@@ -5017,7 +5017,7 @@ sysctl_kmaps(SYSCTL_HANDLER_ARGS)
 {
 	struct pmap_kernel_map_range range;
 	struct sbuf sbuf, *sb;
-	pd_entry_t l1e, *l2, l2e;
+	pd_entry_t *l1, l1e, *l2, l2e;
 	pt_entry_t *l3, l3e;
 	vm_offset_t sva;
 	vm_paddr_t pa;
@@ -5044,7 +5044,8 @@ sysctl_kmaps(SYSCTL_HANDLER_ARGS)
 		else if (i == pmap_l1_index(VM_MIN_KERNEL_ADDRESS))
 			sbuf_printf(sb, "\nKernel map:\n");
 
-		l1e = kernel_pmap->pm_top[i];
+		l1 = pmap_l1(kernel_pmap, sva);
+		l1e = pmap_load(l1);
 		if ((l1e & PTE_V) == 0) {
 			sysctl_kmaps_dump(sb, &range, sva);
 			sva += L1_SIZE;