x86/fpu: Change math_error() to use unlazy_fpu(), kill (now) unused save_init_fpu()
math_error() calls save_init_fpu() after conditional_sti(), this means that the caller can be preempted. If !use_eager_fpu() we can hit the WARN_ON_ONCE(!__thread_has_fpu(tsk)) and/or save the wrong FPU state. Change math_error() to use unlazy_fpu() and kill save_init_fpu(). Signed-off-by: Oleg Nesterov <oleg@redhat.com> Signed-off-by: Rik van Riel <riel@redhat.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Link: http://lkml.kernel.org/r/1423252925-14451-4-git-send-email-riel@redhat.com Signed-off-by: Borislav Petkov <bp@suse.de>
This commit is contained in:
parent
1a2a7f4ec8
commit
08a744c6bf
2 changed files with 1 additions and 19 deletions
|
@ -517,24 +517,6 @@ static inline void __save_fpu(struct task_struct *tsk)
|
||||||
fpu_fxsave(&tsk->thread.fpu);
|
fpu_fxsave(&tsk->thread.fpu);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* These disable preemption on their own and are safe
|
|
||||||
*/
|
|
||||||
static inline void save_init_fpu(struct task_struct *tsk)
|
|
||||||
{
|
|
||||||
WARN_ON_ONCE(!__thread_has_fpu(tsk));
|
|
||||||
|
|
||||||
if (use_eager_fpu()) {
|
|
||||||
__save_fpu(tsk);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
preempt_disable();
|
|
||||||
__save_init_fpu(tsk);
|
|
||||||
__thread_fpu_end(tsk);
|
|
||||||
preempt_enable();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* i387 state interaction
|
* i387 state interaction
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -663,7 +663,7 @@ static void math_error(struct pt_regs *regs, int error_code, int trapnr)
|
||||||
/*
|
/*
|
||||||
* Save the info for the exception handler and clear the error.
|
* Save the info for the exception handler and clear the error.
|
||||||
*/
|
*/
|
||||||
save_init_fpu(task);
|
unlazy_fpu(task);
|
||||||
task->thread.trap_nr = trapnr;
|
task->thread.trap_nr = trapnr;
|
||||||
task->thread.error_code = error_code;
|
task->thread.error_code = error_code;
|
||||||
info.si_signo = SIGFPE;
|
info.si_signo = SIGFPE;
|
||||||
|
|
Loading…
Add table
Reference in a new issue