Commit 59481062 authored by Jon Medhurst's avatar Jon Medhurst Committed by Tixy

ARM: Thumb-2: Fix exception return sequence to restore stack correctly

The implementation of svc_exit didn't take into account any stack hole
created by svc_entry; as happens with the undef handler when kprobes are
configured. The fix is to read the saved value of SP rather than trying
to calculate it.
Signed-off-by: default avatarJon Medhurst <tixy@yxit.co.uk>
Acked-by: default avatarNicolas Pitre <nicolas.pitre@linaro.org>
parent 620917de
...@@ -121,15 +121,13 @@ ...@@ -121,15 +121,13 @@
.endm .endm
#else /* CONFIG_THUMB2_KERNEL */ #else /* CONFIG_THUMB2_KERNEL */
.macro svc_exit, rpsr .macro svc_exit, rpsr
ldr lr, [sp, #S_SP] @ top of the stack
ldrd r0, r1, [sp, #S_LR] @ calling lr and pc
clrex @ clear the exclusive monitor clrex @ clear the exclusive monitor
ldr r0, [sp, #S_SP] @ top of the stack stmdb lr!, {r0, r1, \rpsr} @ calling lr and rfe context
ldr r1, [sp, #S_PC] @ return address
tst r0, #4 @ orig stack 8-byte aligned?
stmdb r0, {r1, \rpsr} @ rfe context
ldmia sp, {r0 - r12} ldmia sp, {r0 - r12}
ldr lr, [sp, #S_LR] mov sp, lr
addeq sp, sp, #S_FRAME_SIZE - 8 @ aligned ldr lr, [sp], #4
addne sp, sp, #S_FRAME_SIZE - 4 @ not aligned
rfeia sp! rfeia sp!
.endm .endm
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment