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

   ## Summary
   
   Fix ARM64 multi-core stack pointer initialization when 
CONFIG_STACK_COLORATION is not defined. The boot code now correctly advances 
the stack pointer (x24) by SMP_STACK_SIZE for each CPU even when stack 
coloration is disabled, preventing adjacent CPU stacks from overlapping. The 
fix adds a missing else clause to handle the non-coloration code path.
   
   ## Changes
   
   - **arch/arm64/src/common/arm64_head.S**:
     - Add else clause after CONFIG_STACK_COLORATION conditional in real_start 
label
     - In the non-coloration path, advance x24 (current stack pointer) by 
SMP_STACK_SIZE
     - Ensures proper per-CPU stack spacing regardless of 
CONFIG_STACK_COLORATION setting
   
   ## Benefits & Technical Details
   
   - **Correct stack layout**: Each CPU stack occupies SMP_STACK_SIZE bytes 
without overlap
   - **Configuration independence**: Stack initialization works correctly with 
or without coloration enabled
   - **Boot safety**: Prevents stack corruption from concurrent CPU 
initialization
   - **Multi-core correctness**: Ensures each CPU has properly isolated stack 
space
   - **Consistency**: Matches stack pointer advancement behavior from 
coloration code path
   
   ## Testing
   
   - Verified stack pointers correctly spaced by SMP_STACK_SIZE for each CPU 
without coloration
   - Confirmed no stack corruption when multiple CPUs boot simultaneously 
without coloration enabled
   - Tested system boot with CONFIG_STACK_COLORATION disabled on multi-core 
ARM64
   - Validated stack traces show correct stack boundaries for each CPU
   - Confirmed no memory overlap between different CPU stacks
   
   ## Impact
   
   - **Correctness**: Fixes multi-core stack initialization bug when coloration 
is disabled
   - **Compatibility**: Fully backward compatible, no API changes
   - **Configuration**: Particularly important for builds without 
CONFIG_STACK_COLORATION
   - **Scope**: Affects ARM64 multi-core boot sequence and stack initialization


-- 
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