⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

Conversation

@hujun260
Copy link
Contributor

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

@github-actions github-actions bot added Arch: arm64 Issues related to ARM64 (64-bit) architecture Size: M The size of the change in this PR is medium labels Jan 19, 2026
…iant

Rename arm64_addrenv.c to arm64_addrenv_mmu.c to separate MMU-specific logic.
Add new arm64_addrenv_mpu.c with stub implementations of address environment
functions for MPU-based systems. Enable address environment support in FVP ARMv8-R
Kconfig to support kernel stacks in protected mode. Conditionally build MPU or
MMU address environment code based on CONFIG_ARCH_USE_MMU/CONFIG_ARCH_USE_MPU.

Signed-off-by: hujun5 <[email protected]>
@hujun260 hujun260 force-pushed the apache_arm64_add_mpu_addrenv branch from 4998466 to ff10ff2 Compare January 19, 2026 02:56
@xiaoxiang781216
Copy link
Contributor

@hujun260 please fix:

common/arm64_initialstate.c: In function 'arm64_new_task':
Error: common/arm64_initialstate.c:66:55: error: 'ARCH_KERNEL_STACKSIZE' undeclared (first use in this function); did you mean 'CONFIG_ARCH_KERNEL_STACKSIZE'?
   66 |       stack_ptr        = (uintptr_t)tcb->xcp.kstack + ARCH_KERNEL_STACKSIZE;
      |                                                       ^~~~~~~~~~~~~~~~~~~~~
      |                                                       CONFIG_ARCH_KERNEL_STACKSIZE
common/arm64_initialstate.c:66:55: note: each undeclared identifier is reported only once for each function it appears in
make[1]: *** [Makefile:143: arm64_initialstate.o] Error 1
common/arm64_addrenv_kstack.c: In function 'up_addrenv_kstackalloc':
Error: common/arm64_addrenv_kstack.c:69:51: error: 'ARCH_KERNEL_STACKSIZE' undeclared (first use in this function); did you mean 'CONFIG_ARCH_KERNEL_STACKSIZE'?
   69 |   tcb->xcp.kstack = kmm_memalign(STACK_ALIGNMENT, ARCH_KERNEL_STACKSIZE);
      |                                                   ^~~~~~~~~~~~~~~~~~~~~
      |                                                   CONFIG_ARCH_KERNEL_STACKSIZE

@hujun260 hujun260 closed this Jan 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Arch: arm64 Issues related to ARM64 (64-bit) architecture Size: M The size of the change in this PR is medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants