Skip to content

{bp-19123} armv7-m/armv8-m: honor SP modifications on signal return#19284

Merged
linguini1 merged 1 commit into
apache:releases/13.0from
jerpelea:bp-19123
Jul 3, 2026
Merged

{bp-19123} armv7-m/armv8-m: honor SP modifications on signal return#19284
linguini1 merged 1 commit into
apache:releases/13.0from
jerpelea:bp-19123

Conversation

@jerpelea

@jerpelea jerpelea commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

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

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>
@jerpelea jerpelea requested a review from GUIDINGLI as a code owner July 3, 2026 07:28
@github-actions github-actions Bot added Arch: arm Issues related to ARM (32-bit) architecture Size: S The size of the change in this PR is small labels Jul 3, 2026
@jerpelea jerpelea requested a review from xiaoxiang781216 July 3, 2026 10:06
@jerpelea

jerpelea commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

@acassis ping

@linguini1 linguini1 merged commit fd4e34b into apache:releases/13.0 Jul 3, 2026
26 checks passed
@jerpelea jerpelea deleted the bp-19123 branch July 4, 2026 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Arch: arm Issues related to ARM (32-bit) architecture Size: S The size of the change in this PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants