cortex-m-rt: Add optional MSPLIM initialization, fix vector table size on armv8m #580
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.
This PR adds an optional initialization for the Main Stack Pointer Limit (MSPLIM) register, controlled by the new
set-msplim
feature andarmv8_main
cfg.The
Main Stack Pointer Limit (MSPLIM)
register is used to define the lowest valid stack address, helping to enforce stack limits and prevent unintended stack overflows. This register is only available on ARMv8-M Mainline (Cortex-M33).MSPLIM initialization is often handled in the startup assembly file:
https://github.com/ARMmbed/uvisor/blob/97906335ea6892866e1fab7c6ef287004233826f/core/system/src/main.c#L84-L86
Some chip bootloaders also configure MSPLIM in advance. If it is not explicitly initialized in the startup code of user firmware, it will cause a HardFault when the program pushes to the stack in main().
Instead of relying on HALs or applications to define
__pre_init
forMSPLIM
initialization, it seems more appropriate to handle this directly in cortex-m-rt, I think.