From 0cd5689bcbcdfdef078276ba081efb4d3f830ac5 Mon Sep 17 00:00:00 2001 From: Ville Juven Date: Thu, 2 May 2024 13:55:19 +0300 Subject: [PATCH] riscv/pgmap: Fix bug in kernel page directory init The L2 table was not connected -> results in random crashes. Also add missing data sync barrier to the end. --- arch/risc-v/src/common/riscv_addrenv_pgmap.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/risc-v/src/common/riscv_addrenv_pgmap.c b/arch/risc-v/src/common/riscv_addrenv_pgmap.c index 0d36c1adeb1..08335387a02 100644 --- a/arch/risc-v/src/common/riscv_addrenv_pgmap.c +++ b/arch/risc-v/src/common/riscv_addrenv_pgmap.c @@ -198,7 +198,7 @@ int up_addrenv_kmap_init(void) next = g_kernel_pgt_pbase; vaddr = CONFIG_ARCH_KMAP_VBASE; - for (i = 0; i < (ARCH_SPGTS - 1); i++) + for (i = 0; i < ARCH_SPGTS; i++) { /* Connect the static page tables */ @@ -211,6 +211,10 @@ int up_addrenv_kmap_init(void) addrenv->satp = mmu_satp_reg(g_kernel_pgt_pbase, 0); + /* When all is set and done, flush the data caches */ + + __DMB(); + return OK; }