* value at reset if we support XMM instructions and then
* remember the current task has used the FPU.
*/
-static int init_fpu(struct task_struct *tsk)
+static int fpu__unlazy_stopped(struct task_struct *child)
{
int ret;
- if (tsk_used_math(tsk)) {
- if (cpu_has_fpu && tsk == current)
- fpu__save(tsk);
- task_disable_lazy_fpu_restore(tsk);
+ if (WARN_ON_ONCE(child == current))
+ return -EINVAL;
+
+ if (tsk_used_math(child)) {
+ if (cpu_has_fpu && child == current)
+ fpu__save(child);
+ task_disable_lazy_fpu_restore(child);
return 0;
}
/*
* Memory allocation at the first usage of the FPU and other state.
*/
- ret = fpu_alloc(&tsk->thread.fpu);
+ ret = fpu_alloc(&child->thread.fpu);
if (ret)
return ret;
- fpu_finit(&tsk->thread.fpu);
+ fpu_finit(&child->thread.fpu);
- set_stopped_child_used_math(tsk);
+ set_stopped_child_used_math(child);
return 0;
}
if (!cpu_has_fxsr)
return -ENODEV;
- ret = init_fpu(target);
+ ret = fpu__unlazy_stopped(target);
if (ret)
return ret;
if (!cpu_has_fxsr)
return -ENODEV;
- ret = init_fpu(target);
+ ret = fpu__unlazy_stopped(target);
if (ret)
return ret;
if (!cpu_has_xsave)
return -ENODEV;
- ret = init_fpu(target);
+ ret = fpu__unlazy_stopped(target);
if (ret)
return ret;
if (!cpu_has_xsave)
return -ENODEV;
- ret = init_fpu(target);
+ ret = fpu__unlazy_stopped(target);
if (ret)
return ret;
struct user_i387_ia32_struct env;
int ret;
- ret = init_fpu(target);
+ ret = fpu__unlazy_stopped(target);
if (ret)
return ret;
struct user_i387_ia32_struct env;
int ret;
- ret = init_fpu(target);
+ ret = fpu__unlazy_stopped(target);
if (ret)
return ret;