{bp-19123} armv7-m/armv8-m: honor SP modifications on signal return#19284
Merged
Conversation
On ARMv7-M/ARMv8-M, the hardware exception return determines the final SP from the physical location of the HW exception frame, ignoring any software modification to REG_R13 in the saved register context. This means signal handlers that adjust SP have their change silently discarded. Fix this by relocating the saved context in arm_sigdeliver before calling arm_fullcontextrestore. If the desired SP (regs[REG_R13]) differs from the implied SP, memmove the entire context frame so that the hardware exception return produces the correct final SP. The fix runs only in the signal return path, adding zero overhead to the normal exception return hot path. Signed-off-by: Andrew Au <cshung@gmail.com>
Contributor
Author
|
@acassis ping |
linguini1
approved these changes
Jul 3, 2026
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.
Summary
On ARMv7-M/ARMv8-M, the hardware exception return determines the final SP from the physical location of the HW exception frame, ignoring any software modification to REG_R13 in the saved register context. This means signal handlers that adjust SP have their change silently discarded.
Fix this by relocating the saved context in arm_sigdeliver before calling arm_fullcontextrestore. If the desired SP (regs[REG_R13]) differs from the implied SP, memmove the entire context frame so that the hardware exception return produces the correct final SP.
The fix runs only in the signal return path, adding zero overhead to the normal exception return hot path.
Impact
RELEASE
Testing
CI