Skip to content

Commit

Permalink
xtensa: fix access to THREAD_RA/THREAD_SP/THREAD_DS
Browse files Browse the repository at this point in the history
With SMP and a lot of debug options enabled task_struct::thread gets out
of reach of s32i/l32i instructions with base pointing at task_struct,
breaking build with the following messages:

  arch/xtensa/kernel/entry.S: Assembler messages:
  arch/xtensa/kernel/entry.S:1002: Error: operand 3 of 'l32i.n' has invalid value '1048'
  arch/xtensa/kernel/entry.S:1831: Error: operand 3 of 's32i.n' has invalid value '1040'
  arch/xtensa/kernel/entry.S:1832: Error: operand 3 of 's32i.n' has invalid value '1044'

Change base to point to task_struct::thread in such cases.
Don't use a10 in _switch_to to save/restore prev pointer as a2 is not
clobbered.

Cc: [email protected]
Signed-off-by: Max Filippov <[email protected]>
  • Loading branch information
jcmvbkbc committed Aug 14, 2014
1 parent 89f77c6 commit 5224712
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
5 changes: 5 additions & 0 deletions arch/xtensa/include/asm/uaccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@
*/
.macro get_fs ad, sp
GET_CURRENT(\ad,\sp)
#if THREAD_CURRENT_DS > 1020
addi \ad, \ad, TASK_THREAD
l32i \ad, \ad, THREAD_CURRENT_DS - TASK_THREAD
#else
l32i \ad, \ad, THREAD_CURRENT_DS
#endif
.endm

/*
Expand Down
12 changes: 8 additions & 4 deletions arch/xtensa/kernel/entry.S
Original file line number Diff line number Diff line change
Expand Up @@ -1820,16 +1820,21 @@ ENTRY(_switch_to)

entry a1, 16

mov a10, a2 # preserve 'prev' (a2)
mov a11, a3 # and 'next' (a3)

l32i a4, a2, TASK_THREAD_INFO
l32i a5, a3, TASK_THREAD_INFO

save_xtregs_user a4 a6 a8 a9 a12 a13 THREAD_XTREGS_USER

s32i a0, a10, THREAD_RA # save return address
s32i a1, a10, THREAD_SP # save stack pointer
#if THREAD_RA > 1020 || THREAD_SP > 1020
addi a10, a2, TASK_THREAD
s32i a0, a10, THREAD_RA - TASK_THREAD # save return address
s32i a1, a10, THREAD_SP - TASK_THREAD # save stack pointer
#else
s32i a0, a2, THREAD_RA # save return address
s32i a1, a2, THREAD_SP # save stack pointer
#endif

/* Disable ints while we manipulate the stack pointer. */

Expand Down Expand Up @@ -1870,7 +1875,6 @@ ENTRY(_switch_to)
load_xtregs_user a5 a6 a8 a9 a12 a13 THREAD_XTREGS_USER

wsr a14, ps
mov a2, a10 # return 'prev'
rsync

retw
Expand Down

0 comments on commit 5224712

Please sign in to comment.