-
Notifications
You must be signed in to change notification settings - Fork 7.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
arch: arm: enable PXN support for armv8.1-m #86942
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9cb985e
to
73c4ae7
Compare
What is the change? This commit adds support for Armv8.1-M MPU architecture's PXN attribute. This includes support for configuring MPU regions with PXN via custom mpu_config, devicetree and static mpu_config. The existing MPU region attribute macros are updated to retain existing behaviour with this change with an addition of REGION_RAM_ATTR_PXN to be used if one needs to configure a RAM region with PXN MPU attribute. Why do we need this change? Armv8.1-M architecture introduced a new MPU region attribute called Privilege eXecute Never (PXN). If an MPU region is configured with the PXN attribute set and if the, processor attempts to execute code in this region while at privileged level, a Memory Management Fault exception is triggered. This ensures that specific tasks are executed only in unprivileged mode and helps in preventing secure privilege escalation attacks. Signed-off-by: Sudan Landge <sudan.landge@arm.com>
What is the change? - PXN attributes is set for static mpu regions such that __ramfunc and __ram_text_reloc having userspace code cannot be executed in privileged mode. - Updated the notable change section to inform about the change in behaviour of code executed from __ramfunc and __ram_text_reloc MPU regions. Why do we need this change? - The current static MPU regions allows executing userspace/unprivileged code from privileged mode which may not be expected and can lead to secure privileged escalation attacks. Signed-off-by: Sudan Landge <sudan.landge@arm.com>
cbdc821
to
5f8af7a
Compare
Adds a test to verify Armv8.1-M MPU architecture's PXN attribute. Verify PXN via static mpu config by utilizing existing __ramfunc MPU region Since previous commit changes the behaviour of __ramfunc region, executing userspace code in this region in privileged mode will result in an MPU fault while execution in unprivileged mode should work fine. Verify PXN via DT by creating a custom section in the unused SRAM region. Since the overlay sets the PXN attribute for the SRAM, executing code in this region in privileged mode will result in an MPU fault while, execution in unprivileged mode should work fine. Also, instead of testing DT config for each board, do it only for MPS3 boards that which can be tested with simulation. Signed-off-by: Sudan Landge <sudan.landge@arm.com>
ithinuel
approved these changes
Mar 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks !
fabiobaltieri
approved these changes
Mar 20, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area: Architectures
area: ARM
ARM (32-bit) Architecture
platform: ARM
Arm Limited
Release Notes
To be mentioned in the release notes
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What is the change?
This commit adds support for Armv8.1-M MPU architecture's PXN attribute.
This includes support for configuring MPU regions with PXN via
custom mpu_config, devicetree and static mpu_config.
The existing MPU region attribute macros are updated to retain existing
behaviour with this change with an addition of REGION_RAM_ATTR_PXN to be
used if one needs to configure a RAM region with PXN MPU attribute.
Why do we need this change?
Armv8.1-M architecture introduced a new MPU region attribute called
Privilege eXecute Never (PXN).
If an MPU region is configured with the PXN attribute set and if the,
processor attempts to execute code in this region while at
privileged level, a Memory Management Fault exception is triggered.
This ensures that specific tasks are executed only in unprivileged mode
and helps in preventing secure privilege escalation attacks.