[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>
This commit is contained in:
@@ -201,13 +201,13 @@ int dump_spe(struct pt_regs *regs, elf_vrregset_t *evrregs)
|
||||
}
|
||||
#endif /* CONFIG_SPE */
|
||||
|
||||
#ifndef CONFIG_SMP
|
||||
/*
|
||||
* If we are doing lazy switching of CPU state (FP, altivec or SPE),
|
||||
* and the current task has some state, discard it.
|
||||
*/
|
||||
static inline void discard_lazy_cpu_state(void)
|
||||
void discard_lazy_cpu_state(void)
|
||||
{
|
||||
#ifndef CONFIG_SMP
|
||||
preempt_disable();
|
||||
if (last_task_used_math == current)
|
||||
last_task_used_math = NULL;
|
||||
@@ -220,8 +220,8 @@ static inline void discard_lazy_cpu_state(void)
|
||||
last_task_used_spe = NULL;
|
||||
#endif
|
||||
preempt_enable();
|
||||
#endif /* CONFIG_SMP */
|
||||
}
|
||||
#endif /* CONFIG_SMP */
|
||||
|
||||
int set_dabr(unsigned long dabr)
|
||||
{
|
||||
|
Reference in New Issue
Block a user