hujun260 opened a new pull request, #21989:
URL: https://github.com/apache/nuttx/pull/21989
# arm64: add dynamic MPU protection for FVP ARMv8-R
## Summary
Add dynamic ARMv8-R AArch64 MPU protection for per-task heap and stack
regions on the FVP platform.
The implementation configures user heap and stack regions as user read/write
memory and creates kernel-only background regions for the gaps between the user
regions.
## Changes
- Add dynamic MPU protection for the task heap.
- Add dynamic MPU protection for the task stack.
- Allocate and recycle MPU regions when the task address environment changes.
- Configure user heap and stack regions with read/write permissions.
- Configure background regions as inaccessible to user mode.
- Support both configurations:
- `CONFIG_MM_TASK_HEAP` with `CONFIG_ARCH_STACK_PROTECT`;
- `CONFIG_MM_TASK_HEAP` without stack protection.
- Move shared ARM64 MPU definitions and helpers as needed for the FVP
ARMv8-R implementation.
- Correct related ARM64 MPU/FVP naming and comment typos.
## MPU layout
When both task heap and stack protection are enabled, the effective layout
is:
```text
+------------------------------+
| Kernel RW background region |
+------------------------------+
| User heap RW |
+------------------------------+
| User stack RW |
+------------------------------+
| Kernel RW background region |
+------------------------------+
```
When only task heap protection is enabled:
```text
+------------------------------+
| Kernel RW background region |
+------------------------------+
| User heap RW |
+------------------------------+
| Kernel RW background region |
+------------------------------+
```
All user regions are configured as non-executable and shareable. Background
regions are configured as non-executable, privileged read/write, and user
inaccessible.
## Key implementation details
- Existing MPU region allocations are released before new regions are
allocated.
- Heap and stack boundaries are derived from the current task address
environment and TCB stack fields.
- The order of heap and stack regions is selected according to their
relative addresses.
- The remaining RAM gaps are covered by background regions to prevent user
access outside the active heap and stack.
## Testing
The changes were checked for formatting and patch consistency:
```text
$ git diff --check
$ tools/checkpatch.sh -g apache/master..HEAD
```
The feature is intended for ARMv8-R AArch64 FVP protected configurations
with task heap and stack protection enabled.
## Commits
```text
arm64: Armv8-R aarch64 MPU heap dynamic_protect
arm64: Armv8-R aarch64 MPU stack dynamic_protect
arm64: fix typo
```
--
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]