The branch main has been updated by mhorne:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=3ff981587ff8f05c06092d05edcc50f1ede1bbd6

commit 3ff981587ff8f05c06092d05edcc50f1ede1bbd6
Author:     Mitchell Horne <mho...@freebsd.org>
AuthorDate: 2023-11-24 17:21:51 +0000
Commit:     Mitchell Horne <mho...@freebsd.org>
CommitDate: 2024-06-14 18:02:05 +0000

    riscv: Don't handle missing kernel L3 pages
    
    This code path should never be hit, if it does it means we did not
    bootstrap correctly. Turn it into a panic like we do on amd64 and arm64.
    
    Reviewed by:    markj, jhb
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D45326
---
 sys/riscv/riscv/pmap.c | 43 +++++--------------------------------------
 1 file changed, 5 insertions(+), 38 deletions(-)

diff --git a/sys/riscv/riscv/pmap.c b/sys/riscv/riscv/pmap.c
index 8176975b049c..1902f1f4009b 100644
--- a/sys/riscv/riscv/pmap.c
+++ b/sys/riscv/riscv/pmap.c
@@ -2911,14 +2911,13 @@ pmap_enter(pmap_t pmap, vm_offset_t va, vm_page_t m, 
vm_prot_t prot,
     u_int flags, int8_t psind)
 {
        struct rwlock *lock;
-       pd_entry_t *l1, *l2, l2e;
+       pd_entry_t *l2, l2e;
        pt_entry_t new_l3, orig_l3;
        pt_entry_t *l3;
        pv_entry_t pv;
-       vm_paddr_t opa, pa, l2_pa, l3_pa;
-       vm_page_t mpte, om, l2_m, l3_m;
-       pt_entry_t entry;
-       pn_t l2_pn, l3_pn, pn;
+       vm_paddr_t opa, pa;
+       vm_page_t mpte, om;
+       pn_t pn;
        int rv;
        bool nosleep;
 
@@ -2990,39 +2989,7 @@ pmap_enter(pmap_t pmap, vm_offset_t va, vm_page_t m, 
vm_prot_t prot,
                }
                l3 = pmap_l3(pmap, va);
        } else {
-               l3 = pmap_l3(pmap, va);
-               /* TODO: This is not optimal, but should mostly work */
-               if (l3 == NULL) {
-                       if (l2 == NULL) {
-                               l2_m = vm_page_alloc_noobj(VM_ALLOC_WIRED |
-                                   VM_ALLOC_ZERO);
-                               if (l2_m == NULL)
-                                       panic("pmap_enter: l2 pte_m == NULL");
-
-                               l2_pa = VM_PAGE_TO_PHYS(l2_m);
-                               l2_pn = (l2_pa / PAGE_SIZE);
-
-                               l1 = pmap_l1(pmap, va);
-                               entry = (PTE_V);
-                               entry |= (l2_pn << PTE_PPN0_S);
-                               pmap_store(l1, entry);
-                               pmap_distribute_l1(pmap, pmap_l1_index(va), 
entry);
-                               l2 = pmap_l1_to_l2(l1, va);
-                       }
-
-                       l3_m = vm_page_alloc_noobj(VM_ALLOC_WIRED |
-                           VM_ALLOC_ZERO);
-                       if (l3_m == NULL)
-                               panic("pmap_enter: l3 pte_m == NULL");
-
-                       l3_pa = VM_PAGE_TO_PHYS(l3_m);
-                       l3_pn = (l3_pa / PAGE_SIZE);
-                       entry = (PTE_V);
-                       entry |= (l3_pn << PTE_PPN0_S);
-                       pmap_store(l2, entry);
-                       l3 = pmap_l2_to_l3(l2, va);
-               }
-               pmap_invalidate_page(pmap, va);
+               panic("pmap_enter: missing L3 table for kernel va %#lx", va);
        }
 
        orig_l3 = pmap_load(l3);

Reply via email to