Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9744b0a

Browse files
committedJun 1, 2016
core: thread: fix unaligned stack pointer
Fixes unaligned stack pointer in __thread_enter_user_mode. The stack pointer must always be 8 byte aligned when entering a new function. Reviewed-by: Joakim Bech <joakim.bech@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
1 parent 007a97a commit 9744b0a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed
 

‎core/arch/arm/kernel/thread_a32.S

+4-4
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ UNWIND( .cantunwind)
522522
mov r6, sp
523523
mov sp, r4
524524
cps #CPSR_MODE_SVC
525-
push {r6}
525+
push {r6,r7}
526526

527527
/*
528528
* Don't allow return from this function, return is done through
@@ -542,13 +542,13 @@ END_FUNC __thread_enter_user_mode
542542
FUNC thread_unwind_user_mode , :
543543
UNWIND( .fnstart)
544544
UNWIND( .cantunwind)
545-
ldr ip, [sp, #(14 * 0x4)] /* &ctx->panicked */
545+
ldr ip, [sp, #(15 * 0x4)] /* &ctx->panicked */
546546
str r1, [ip]
547-
ldr ip, [sp, #(15 * 0x4)] /* &ctx->panic_code */
547+
ldr ip, [sp, #(16 * 0x4)] /* &ctx->panic_code */
548548
str r2, [ip]
549549

550550
/* Restore old user sp */
551-
pop {r4}
551+
pop {r4,r7}
552552
cps #CPSR_MODE_SYS
553553
mov sp, r4
554554
cps #CPSR_MODE_SVC

0 commit comments

Comments
 (0)
Please sign in to comment.