Skip to content

Conversation

@hujun260
Copy link
Contributor

@hujun260 hujun260 commented Jan 22, 2026

Summary

This PR series adds comprehensive protected mode (CONFIG_BUILD_PROTECTED) support to ARM64
architecture, particularly for FVP platform, along with significant improvements to SMP
initialization and address environment functionality. The changes enable full kernel/user-space
isolation, simplify multi-core CPU synchronization, and extend address environment support
to MPU-based systems.

Changes Made

1. SMP Initialization Improvements

Remove Fixed Memory Address Configuration:

  • Replace CONFIG_ARM64_SMP_BUSY_WAIT_FLAG_ADDR with global variable g_smp_busy_wait_flag
  • Simplify multi-core CPU synchronization mechanism
  • Align with standard kernel synchronization patterns
  • Improve flexibility for different memory layouts
  • Remove hardcoded address configuration requirement

Benefits:

  • More flexible approach than fixed memory addresses
  • Consistent with NuttX kernel variable patterns
  • Cleaner configuration management
  • Support for dynamic memory layout

2. FVP Protected Mode Build Support

Enable Protected Build Mode:

  • Conditionally include fvp_userspace.c when CONFIG_BUILD_PROTECTED enabled
  • Add user-space heap allocation support (fvp_v8r_allocateheap.c)
  • Support kernel and user-space separation via MPU regions

Memory Map and Linker Scripts:

  • Add board-specific board_memorymap.h definitions
  • Create separate kernel and user-space linker scripts
  • Support KTEXT, KSRAM, and UTEXT region definitions
  • Enable dynamic memory layout configuration

Protected Mode Configuration:

  • Add protected build configurations (pnsh, pnsh_smp)
  • Configure MPU regions for kernel/user isolation
  • Support kernel-space stack and user-space execution
  • Enable proper privilege level management

3. ARM64 Core Protected Mode Support

Extend Protected Build Infrastructure:

  • Add CONFIG_BUILD_PROTECTED support alongside CONFIG_BUILD_KERNEL
  • Include arm64_task_start.c and arm64_pthread_start.c for protected mode
  • Enable signal dispatch infrastructure

Context and Memory Management:

  • Extend saved register pointer support for protected mode
  • Enable weak heap allocation function for board customization
  • Fix fork operation link register handling (Thumb bit masking)
  • Add protected mode declarations and structures

Build System Updates:

  • Update CMakeLists.txt for protected build compilation
  • Update Make.defs for protected mode source inclusion
  • Support both FLAT and PROTECTED build modes

4. Address Environment Support for MPU-Based Systems

Enable Addrenv in MPU-Only Systems:

  • Wrap MMU-specific configuration checks with CONFIG_ARCH_USE_MMU guard
  • Make CONFIG_MM_PGALLOC and CONFIG_MM_PGSIZE conditional on MMU
  • Allow addrenv support in systems using MPU instead of MMU
  • Enable mixed configurations supporting both MMU and MPU

Benefits:

  • Support for MPU-based systems without paging
  • Flexibility for different memory management approaches
  • Cleaner configuration separation
  • Better compatibility across architecture variants

Impact

SMP Improvements

  • Simplified CPU synchronization without fixed memory addresses
  • More flexible configuration approach
  • Standard kernel synchronization patterns
  • Cleaner assembly code

Protected Mode Support

  • Full kernel/user-space isolation capability
  • Board-specific customization options
  • Proper privilege level management
  • Signal dispatch and task management support

Address Environment

  • Support for MPU-based systems
  • Mixed MMU/MPU configuration support
  • Cleaner configuration management
  • Broader architecture support

Code Quality

  • Simplified configuration requirements
  • Cleaner separation of concerns
  • Better maintainability
  • Improved flexibility

Testing

Test Environment

  • Linux x86_64 host with NuttX cross-compiler
  • ARM64 FVP platform
  • Multiple configurations: SMP, Protected mode, Protected mode SMP

Test Procedure

  1. SMP Initialization:

    • Verify multi-core CPU synchronization without fixed addresses
    • Test concurrent operations
    • Confirm no synchronization issues
  2. Protected Mode:

    • Build with CONFIG_BUILD_PROTECTED
    • Boot in protected mode
    • Verify kernel/user-space isolation
    • Test user-space application execution
  3. Address Environment:

    • Test addrenv in protected mode
    • Verify MPU-based addrenv support
    • Confirm backward compatibility
  4. Integration:

    • Run NuttX test suite
    • Verify no regressions
    • Test device driver operations

Test Results

✅ SMP synchronization operational without fixed addresses
✅ Protected mode isolation enforced
✅ Address environment supports MPU-based systems
✅ All configurations compile successfully
✅ No test suite regressions
✅ Backward compatibility maintained


Verification Checklist

  • ✅ No JIRA IDs or internal identifiers
  • ✅ Commit messages follow NuttX conventions
  • ✅ Public API compatibility preserved
  • ✅ Configuration options properly guarded
  • ✅ Build system files updated
  • ✅ Protected mode fully functional
  • ✅ SMP improvements operational
  • ✅ Address environment extended to MPU systems
  • ✅ Backward compatibility maintained
  • ✅ All tests passing

Related Commits

  • ff4ac88811d - arm64: remove busy wait flag
  • 3905065eede - fvp-v8r: protect build support
  • d3c187322df - arm64: support protectbuild
  • 573bafbd880 - addrenv: support addrenv when mpu is used

@github-actions github-actions bot added Arch: arm64 Issues related to ARM64 (64-bit) architecture Area: OS Components OS Components issues Board: arm64 Size: XL The size of the change in this PR is very large. Consider breaking down the PR into smaller pieces. labels Jan 22, 2026
@hujun260 hujun260 changed the title Apache arm64 support protectbuild 1 arm64: MPU enhancements, protected mode support, and interface standardization Jan 22, 2026
Copy link
Contributor

@jerpelea jerpelea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please split the PR in separate areas:

  • MPU enhancements
  • interface standardization
  • Protected more support

@hujun260 hujun260 force-pushed the apache_arm64_support_protectbuild_1 branch from 2ec42a1 to c69b747 Compare January 22, 2026 11:44
@hujun260
Copy link
Contributor Author

please split the PR in separate areas:

  • MPU enhancements
  • interface standardization
  • Protected more support

done

@jerpelea
Copy link
Contributor

please split the PR in separate areas:

  • MPU enhancements
  • interface standardization
  • Protected more support

done

sorry for the misunderstanding
I was suggesting 3 PRs (1 for each area)
Best regards

@hujun260 hujun260 changed the title arm64: MPU enhancements, protected mode support, and interface standardization arm64: add protected mode support and SMP improvements Jan 22, 2026
@hujun260
Copy link
Contributor Author

hujun260 commented Jan 22, 2026

please split the PR in separate areas:

  • MPU enhancements
  • interface standardization
  • Protected more support

done

sorry for the misunderstanding I was suggesting 3 PRs (1 for each area) Best regards
done

@hujun260 hujun260 force-pushed the apache_arm64_support_protectbuild_1 branch 3 times, most recently from c599f47 to e681a92 Compare January 23, 2026 06:05
jerpelea
jerpelea previously approved these changes Jan 23, 2026
zyfeier and others added 2 commits January 24, 2026 13:45
Conditionally enable MMU-specific configuration
checks (CONFIG_MM_PGALLOC, CONFIG_MM_PGSIZE,
address base/size definitions) only when
CONFIG_ARCH_USE_MMU is defined. This allows
addrenv support in MPU-based systems that
don't use MMU paging.

Signed-off-by: zhangyuan29 <zhangyuan29@xiaomi.com>
Add CONFIG_BUILD_PROTECTED support alongside
CONFIG_BUILD_KERNEL for saved register
pointers and task startup functions. Fix
arm64_fork() to properly handle Thumb bit masking.
Enable weak_function for up_allocate_kheap()
to support board-specific heap allocation.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
@hujun260 hujun260 force-pushed the apache_arm64_support_protectbuild_1 branch from e681a92 to 767fe90 Compare January 24, 2026 05:47
@hujun260 hujun260 force-pushed the apache_arm64_support_protectbuild_1 branch 4 times, most recently from a55ff3c to f82c60e Compare January 24, 2026 08:20
Enable fvp_userspace.c compilation when
CONFIG_BUILD_PROTECTED is enabled, providing user-space
isolation support for FVP platform. Include
board memory map definitions for protected build
configuration and update MPU regions for
kernel/user space separation.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
Replace CONFIG_ARM64_SMP_BUSY_WAIT_FLAG_ADDR with global variable g_smp_busy_wait_flag for
SMP CPU synchronization. This improves flexibility over fixed memory addresses and aligns
with standard kernel variable patterns for multi-core startup.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
@hujun260 hujun260 force-pushed the apache_arm64_support_protectbuild_1 branch from f82c60e to 5d3dc7e Compare January 24, 2026 09:48
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 Area: OS Components OS Components issues Board: arm64 Size: XL The size of the change in this PR is very large. Consider breaking down the PR into smaller pieces.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants