diff options
author | Ralf Baechle <ralf@linux-mips.org> | 2007-10-30 13:25:26 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2007-11-26 12:26:13 -0500 |
commit | 07500b0d855b7f3f47ca263b21b6397d743d45d2 (patch) | |
tree | aff5b665b397e49b0beadfd6621394d39296f4c9 /include/asm-mips | |
parent | 98ce472181e760a552314850c238b14bbf3f04ec (diff) |
[MIPS] Fix context DSP context / TLS pointer switching bug for new threads.
A new born thread starts execution not in schedule but rather in
ret_from_fork which results in it bypassing the part of the code to
load a new context written in C which are the DSP context and the
userlocal register which Linux uses for the TLS pointer. Frequently
we were just getting away with this bug for a number of reasons:
o Real world application scenarios are very unlikely to use clone or fork
in blocks of DSP code.
o Linux by default runs the child process right after the fork, so the
child by luck will find all the right context in the DSP and userlocal
registers.
o So far the rdhwr instruction was emulated on all hardware so userlocal
wasn't getting referenced at all and the emulation wasn't suffering
from the issue since it gets it's value straight from the thread's
thread_info.
Fixed by moving the code to load the context from switch_to() to
finish_arch_switch which will be called by newborn and old threads.
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'include/asm-mips')
-rw-r--r-- | include/asm-mips/system.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/include/asm-mips/system.h b/include/asm-mips/system.h index 90e4b403f531..1030562d6ea6 100644 --- a/include/asm-mips/system.h +++ b/include/asm-mips/system.h | |||
@@ -68,11 +68,15 @@ do { \ | |||
68 | if (cpu_has_dsp) \ | 68 | if (cpu_has_dsp) \ |
69 | __save_dsp(prev); \ | 69 | __save_dsp(prev); \ |
70 | (last) = resume(prev, next, task_thread_info(next)); \ | 70 | (last) = resume(prev, next, task_thread_info(next)); \ |
71 | } while (0) | ||
72 | |||
73 | #define finish_arch_switch(prev) \ | ||
74 | do { \ | ||
71 | if (cpu_has_dsp) \ | 75 | if (cpu_has_dsp) \ |
72 | __restore_dsp(current); \ | 76 | __restore_dsp(current); \ |
73 | if (cpu_has_userlocal) \ | 77 | if (cpu_has_userlocal) \ |
74 | write_c0_userlocal(task_thread_info(current)->tp_value);\ | 78 | write_c0_userlocal(current_thread_info()->tp_value); \ |
75 | } while(0) | 79 | } while (0) |
76 | 80 | ||
77 | static inline unsigned long __xchg_u32(volatile int * m, unsigned int val) | 81 | static inline unsigned long __xchg_u32(volatile int * m, unsigned int val) |
78 | { | 82 | { |