aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/kernel/head.S
diff options
context:
space:
mode:
authorDavid Daney <ddaney@caviumnetworks.com>2009-07-08 13:07:50 -0400
committerRalf Baechle <ralf@linux-mips.org>2009-08-03 12:52:41 -0400
commit484889fc85a223ef56edc31828b86751b2296b7c (patch)
treef511d75b729c331260bc544a0f03b7d5bea26d9a /arch/mips/kernel/head.S
parent1de010a2702eb21d90883b83bf8c737d5e69d234 (diff)
MIPS: Avoid clobbering struct pt_regs in kthreads
The resume() implementation octeon_switch.S examines the saved cp0_status register. We were clobbering the entire pt_regs structure in kernel threads leading to random crashes. When switching away from a kernel thread, the saved cp0_status is examined and if bit 30 is set it is cleared and the CP2 state saved into the pt_regs structure. Since the kernel thread stack overlaid the pt_regs structure this resulted in a corrupt stack. When the kthread with the corrupt stack was resumed, it could crash if it used any of the data in the stack that was clobbered. We fix it by moving the kernel thread stack down so it doesn't overlay pt_regs. Signed-off-by: David Daney <ddaney@caviumnetworks.com> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/kernel/head.S')
-rw-r--r--arch/mips/kernel/head.S3
1 files changed, 2 insertions, 1 deletions
diff --git a/arch/mips/kernel/head.S b/arch/mips/kernel/head.S
index 492a0a8d70f..531ce7b1612 100644
--- a/arch/mips/kernel/head.S
+++ b/arch/mips/kernel/head.S
@@ -188,7 +188,8 @@ NESTED(kernel_entry, 16, sp) # kernel entry point
188 188
189 MTC0 zero, CP0_CONTEXT # clear context register 189 MTC0 zero, CP0_CONTEXT # clear context register
190 PTR_LA $28, init_thread_union 190 PTR_LA $28, init_thread_union
191 PTR_LI sp, _THREAD_SIZE - 32 191 /* Set the SP after an empty pt_regs. */
192 PTR_LI sp, _THREAD_SIZE - 32 - PT_SIZE
192 PTR_ADDU sp, $28 193 PTR_ADDU sp, $28
193 set_saved_sp sp, t0, t1 194 set_saved_sp sp, t0, t1
194 PTR_SUBU sp, 4 * SZREG # init stack pointer 195 PTR_SUBU sp, 4 * SZREG # init stack pointer