cortex-m-rt: Add optional MSPLIM initialization, fix vector table size on armv8m#580
Merged
Merged
Conversation
4ca45b0 to
e849c7c
Compare
e849c7c to
b188019
Compare
Contributor
Author
set-msplim featuref17d98d to
7e83181
Compare
Fixed interrupt count for Cortex-M23 (ARMv8-M Baseline, 240) and Cortex-M33 (ARMv8-M Mainline, 480) based on the technical reference manual. The original value of 496 referred to the entire vector table length, with exceptions length already included in the assert check.
7e83181 to
77449e5
Compare
Member
|
Works as expected on an rp2350. While without msplim, it happens only when running out of RAM (after overwriting all the heap): After enabling SHCSR.USGFAULTENA I also see the UsageFault being called, and the STKOF bit in UFSR being set. (*0xe000ed28 == 0x100000) |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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-msplimfeature andarmv8_maincfg.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_initforMSPLIMinitialization, it seems more appropriate to handle this directly in cortex-m-rt, I think.