arch: arm: cortex_r: define MPU RASR size for ROM #95328
Closed
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.



Userspace threads need unpriviliged read access to .text and .rodata, both of which reside in the ROM region. However, in non-XIP builds, data resides on the RAM, for which, unpriviliged access is turned off by default (check REGION_RAM_ATTR). For this, MPU must be configured and Cortex-R allows only sizes that are powers of 2.
To solve this problem, the symbol _image_rom_end_order was added, which take the end address of ROM section, gets the next highest power of 2, subtracts one (RASR size value is decremented), and does a single left shift (RASR size field position). This is then directly used in the compile time symbol mpu_config by several SoCs.
This works for these SOCs since their ROM start address is 0x0, making the end address and the size the same value. So we,