Ruchirtripathi opened a new pull request, #19975:
URL: https://github.com/apache/nuttx/pull/19975

   Fixes  #19874 
   
     Note: Please adhere to Contributing Guidelines 
https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md.
     ## Summary
     When running QEMU with a backend file to simulate RAM with randomized or 
uninitialized data, the MMU page tables
     contain garbage values. This occurs because the m_l1_pgtable, 
m_l2_pgtable, and m_l3_pgtable structures are placed
     in the .pgtables section, which is marked as NONLOAD in the linker script.
   
     Because they aren't zeroed out alongside .bss during initialization, 
qemu_rv_kernel_mappings() incorrectly uses this
     uninitialized memory when configuring the MMU, causing mmu_ln_getentry to 
fetch invalid mappings and fail.
   
     This PR fixes the issue by explicitly calling memset() to zero-initialize 
the L1/L2/L3 page tables at the beginning
     of qemu_rv_kernel_mappings() prior to setting up the slab allocator.
   
     ## Impact
   
     • Users: Resolves boot failures for users running qemu-rv boards on QEMU 
with simulated/randomized RAM backend files.
     • Architecture: Changes are strictly confined to the qemu-rv RISC-V 
architecture memory initialization logic. No
     impact on other targets.
     • Build/Hardware: No build or hardware compatibility impact.
   
     ## Testing
   
     • Host machine: Ubuntu 24.04 (Host QEMU 10.0.0)
     • Target: qemu-rv (rv32 / rv64)
     • Testing procedure:
         1. Configured NuttX for the qemu-rv target.
         2. Booted the resulting image using QEMU with a backend file 
simulating randomly initialized RAM.
         3. Verified that the map_region MMU logic correctly allocates from the 
zero-initialized page tables, and the
         kernel boots smoothly without faults.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to