Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 96350
b: refs/heads/master
c: fd3c3ed
h: refs/heads/master
v: v3
  • Loading branch information
Suresh Siddha authored and Thomas Gleixner committed May 10, 2008
1 parent b4fa24b commit dce3f91
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0646153921892cc7a81320a6920beaca06b3e9f0
refs/heads/master: fd3c3ed5d1e3ceb37635cbe6d220ab94aae0781d
12 changes: 10 additions & 2 deletions trunk/arch/x86/kernel/i387.c
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,6 @@ static inline int restore_i387_fsave(struct _fpstate_ia32 __user *buf)
{
struct task_struct *tsk = current;

clear_fpu(tsk);
return __copy_from_user(&tsk->thread.xstate->fsave, buf,
sizeof(struct i387_fsave_struct));
}
Expand All @@ -461,7 +460,6 @@ static int restore_i387_fxsave(struct _fpstate_ia32 __user *buf)
struct user_i387_ia32_struct env;
int err;

clear_fpu(tsk);
err = __copy_from_user(&tsk->thread.xstate->fxsave, &buf->_fxsr_env[0],
sizeof(struct i387_fxsave_struct));
/* mxcsr reserved bits must be masked to zero for security reasons */
Expand All @@ -478,6 +476,16 @@ int restore_i387_ia32(struct _fpstate_ia32 __user *buf)
int err;

if (HAVE_HWFP) {
struct task_struct *tsk = current;

clear_fpu(tsk);

if (!used_math()) {
err = init_fpu(tsk);
if (err)
return err;
}

if (cpu_has_fxsr)
err = restore_i387_fxsave(buf);
else
Expand Down
10 changes: 9 additions & 1 deletion trunk/include/asm-x86/i387.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,15 @@ static inline int save_i387(struct _fpstate __user *buf)
*/
static inline int restore_i387(struct _fpstate __user *buf)
{
set_used_math();
struct task_struct *tsk = current;
int err;

if (!used_math()) {
err = init_fpu(tsk);
if (err)
return err;
}

if (!(task_thread_info(current)->status & TS_USEDFPU)) {
clts();
task_thread_info(current)->status |= TS_USEDFPU;
Expand Down

0 comments on commit dce3f91

Please sign in to comment.