aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/process.c
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2006-01-11 06:11:39 -0500
committerPaul Mackerras <paulus@samba.org>2006-01-12 04:09:29 -0500
commit5388fb1025443ec223ba556b10efc4c5f83f8682 (patch)
treeb14832a8886bd254533f226263a2047545c57805 /arch/powerpc/kernel/process.c
parent593195f9b2309693f27b402f34573f7920b82c3e (diff)
[PATCH] powerpc: Avoid potential FP corruption with preempt and UP
Heikki Lindholm pointed out that there was a potential race with the lazy CPU state (FP, VR, EVR) stuff if preempt is enabled. The race is that in the process of restoring FP state on sigreturn, the task gets preempted by a user task that wants to use the FPU. It will take an FP unavailable exception, which will write the current FPU state to the thread_struct, overwriting the values which sigreturn has stored. Note that this can only happen on UP since we don't implement lazy CPU state on SMP. The fix is to flush the lazy CPU state before updating the thread_struct. To do this we re-use the flush_lazy_cpu_state() function from process.c. Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc/kernel/process.c')
-rw-r--r--arch/powerpc/kernel/process.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 105d5609ff57..913f90692a36 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -201,13 +201,13 @@ int dump_spe(struct pt_regs *regs, elf_vrregset_t *evrregs)
201} 201}
202#endif /* CONFIG_SPE */ 202#endif /* CONFIG_SPE */
203 203
204#ifndef CONFIG_SMP
204/* 205/*
205 * If we are doing lazy switching of CPU state (FP, altivec or SPE), 206 * If we are doing lazy switching of CPU state (FP, altivec or SPE),
206 * and the current task has some state, discard it. 207 * and the current task has some state, discard it.
207 */ 208 */
208static inline void discard_lazy_cpu_state(void) 209void discard_lazy_cpu_state(void)
209{ 210{
210#ifndef CONFIG_SMP
211 preempt_disable(); 211 preempt_disable();
212 if (last_task_used_math == current) 212 if (last_task_used_math == current)
213 last_task_used_math = NULL; 213 last_task_used_math = NULL;
@@ -220,8 +220,8 @@ static inline void discard_lazy_cpu_state(void)
220 last_task_used_spe = NULL; 220 last_task_used_spe = NULL;
221#endif 221#endif
222 preempt_enable(); 222 preempt_enable();
223#endif /* CONFIG_SMP */
224} 223}
224#endif /* CONFIG_SMP */
225 225
226int set_dabr(unsigned long dabr) 226int set_dabr(unsigned long dabr)
227{ 227{