1 From: Matt Redfearn <matt.redfearn@imgtec.com>
2 Date: Mon, 19 Dec 2016 14:20:58 +0000
3 Subject: [PATCH] MIPS: Only change $28 to thread_info if coming from user
6 The SAVE_SOME macro is used to save the execution context on all
8 If an exception occurs while executing user code, the stack is switched
9 to the kernel's stack for the current task, and register $28 is switched
10 to point to the current_thread_info, which is at the bottom of the stack
12 If the exception occurs while executing kernel code, the stack is left,
13 and this change ensures that register $28 is not updated. This is the
14 correct behaviour when the kernel can be executing on the separate irq
15 stack, because the thread_info will not be at the base of it.
17 With this change, register $28 is only switched to it's kernel
18 conventional usage of the currrent thread info pointer at the point at
19 which execution enters kernel space. Doing it on every exception was
20 redundant, but OK without an IRQ stack, but will be erroneous once that
23 Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com>
24 Reviewed-by: Maciej W. Rozycki <macro@imgtec.com>
27 --- a/arch/mips/include/asm/stackframe.h
28 +++ b/arch/mips/include/asm/stackframe.h
30 LONG_S $25, PT_R25(sp)
31 LONG_S $28, PT_R28(sp)
32 LONG_S $31, PT_R31(sp)
34 + /* Set thread_info if we're coming from user mode */
36 + sll k0, 3 /* extract cu0 bit */
39 ori $28, sp, _THREAD_MASK
40 xori $28, _THREAD_MASK
41 #ifdef CONFIG_CPU_CAVIUM_OCTEON
43 pref 0, 0($28) /* Prefetch the current pointer */