This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 6a543b8fb31 arch/risc-v: initialize qemu-rv mmu pagetable data to zero
6a543b8fb31 is described below

commit 6a543b8fb31e2998fde9443b334e343989ece44b
Author: Ruchirtripathi <[email protected]>
AuthorDate: Wed Aug 26 16:30:00 2026 +0530

    arch/risc-v: initialize qemu-rv mmu pagetable data to zero
    
    Fixes #19874
    
    Signed-off-by: Ruchirtripathi <[email protected]>
---
 arch/risc-v/src/qemu-rv/qemu_rv_mm_init.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/arch/risc-v/src/qemu-rv/qemu_rv_mm_init.c 
b/arch/risc-v/src/qemu-rv/qemu_rv_mm_init.c
index e321d3cfb5b..153a746d095 100644
--- a/arch/risc-v/src/qemu-rv/qemu_rv_mm_init.c
+++ b/arch/risc-v/src/qemu-rv/qemu_rv_mm_init.c
@@ -29,6 +29,7 @@
 #include <nuttx/nuttx.h>
 
 #include <stdint.h>
+#include <string.h>
 #include <assert.h>
 #include <nuttx/debug.h>
 
@@ -173,6 +174,7 @@ static void slab_init(uintptr_t start)
 static uintptr_t slab_alloc(void)
 {
   pgalloc_slab_t *slab = (pgalloc_slab_t *)sq_remfirst(&g_free_slabs);
+
   return slab ? (uintptr_t)slab->memory : 0;
 }
 
@@ -245,6 +247,14 @@ static void map_region(uintptr_t paddr, uintptr_t vaddr, 
size_t size,
 
 void qemu_rv_kernel_mappings(void)
 {
+  /* Clear page tables */
+
+  memset(m_l1_pgtable, 0, sizeof(m_l1_pgtable));
+  memset(m_l2_pgtable, 0, sizeof(m_l2_pgtable));
+#ifdef CONFIG_ARCH_MMU_TYPE_SV39
+  memset(m_l3_pgtable, 0, sizeof(m_l3_pgtable));
+#endif
+
   /* Initialize slab allocator for the L2/L3 page tables */
 
   slab_init(KMM_PBASE);

Reply via email to