hujun260 opened a new pull request, #17998:
URL: https://github.com/apache/nuttx/pull/17998
## Summary
Add MPU-based address environment support for ARM64 architecture. Separate
MMU-specific address environment code from generic implementation by renaming
arm64_addrenv.c to arm64_addrenv_mmu.c. Add new arm64_addrenv_mpu.c with stub
implementations of address environment functions for MPU-based systems. Enable
ARCH_HAVE_ADDRENV for FVP ARMv8-R platform to support kernel stacks in
protected mode.
## Changes
- **arch/arm64/src/common/arm64_addrenv.c → arm64_addrenv_mmu.c**:
- Rename to clearly indicate MMU-specific implementation
- Move CONFIG_MM_PGSIZE validation from generic arch.h to this file
- Retain all MMU-based address environment logic
- **arch/arm64/src/common/arm64_addrenv_mpu.c** (new):
- Add 432-line MPU-based address environment implementation
- Provide stub implementations of core functions: up_addrenv_create(),
up_addrenv_destroy(), up_addrenv_select(), etc.
- Support address environment operations for MPU-protected systems
- Include optional stack protection functions (up_addrenv_ustackswitch,
up_addrenv_kstackswitch)
- **arch/arm64/Kconfig**:
- Enable ARCH_HAVE_ADDRENV and ARCH_NEED_ADDRENV_MAPPING for FVP ARMv8-R
platform
- Allows address environment features in protected mode configurations
- **arch/arm64/src/common/CMakeLists.txt & Make.defs**:
- Conditionally include MMU address environment files when
CONFIG_ARCH_USE_MMU is enabled
- Conditionally include MPU address environment files when
CONFIG_ARCH_USE_MPU is enabled
- Build only required address environment variant based on memory
protection type
- **Cleanup**:
- Remove redundant #include "addrenv.h" from arm64_initialstate.c and
arm64_syscall.c
- Remove duplicate CONFIG_MM_PGSIZE check from arch.h
## Benefits & Technical Details
- **Architecture flexibility**: Supports both MMU and MPU-based ARM64 memory
protection
- **Clean separation**: MMU and MPU implementations are separate, reducing
complexity
- **Protected mode support**: Enables kernel stack allocation in protected
mode via address environments
- **Scalability**: Framework ready for future MPU feature implementation
- **Code organization**: Clear naming and logical separation improves
maintainability
## Testing
- Verified address environment functions are properly callable in MPU mode
- Confirmed MMU variant continues working without regression
- Tested FVP ARMv8-R platform with address environment enabled
- Validated kernel stack support in protected mode builds
- Confirmed no build issues with both CMake and Make.defs systems
## Impact
- **Compatibility**: Fully backward compatible, MMU path unchanged
- **Scope**: ARM64 architecture address environment support
- **Configuration**: Enables new ARCH_HAVE_ADDRENV option for MPU-based
ARM64 platforms
- **Future**: Provides foundation for full MPU address environment
implementation
--
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]