Skip to content

Commit

Permalink
x86: unify restore_fpu_checking
Browse files Browse the repository at this point in the history
Impact: cleanup

On x86_32, separate f*rstor to an inline function which makes
restore_fpu_checking the same on both platforms -> move it
outside the ifdefs.

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
LKML-Reference: <1239190320-23952-2-git-send-email-jirislaby@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Jiri Slaby authored and Ingo Molnar committed Apr 8, 2009
1 parent fcb2ac5 commit 34ba476
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions arch/x86/include/asm/i387.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,6 @@ static inline int fxrstor_checking(struct i387_fxsave_struct *fx)
return err;
}

static inline int restore_fpu_checking(struct task_struct *tsk)
{
if (task_thread_info(tsk)->status & TS_XSAVE)
return xrstor_checking(&tsk->thread.xstate->xsave);
else
return fxrstor_checking(&tsk->thread.xstate->fxsave);
}

/* AMD CPUs don't save/restore FDP/FIP/FOP unless an exception
is pending. Clear the x87 state here by setting it to fixed
values. The kernel data segment can be sometimes 0 and sometimes
Expand Down Expand Up @@ -185,10 +177,9 @@ static inline void tolerant_fwait(void)
asm volatile("fnclex ; fwait");
}

static inline int restore_fpu_checking(struct task_struct *tsk)
/* perform fxrstor iff the processor has extended states, otherwise frstor */
static inline int fxrstor_checking(struct i387_fxsave_struct *fx)
{
if (task_thread_info(tsk)->status & TS_XSAVE)
return xrstor_checking(&tsk->thread.xstate->xsave);
/*
* The "nop" is needed to make the instructions the same
* length.
Expand All @@ -197,7 +188,8 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
"nop ; frstor %1",
"fxrstor %1",
X86_FEATURE_FXSR,
"m" (tsk->thread.xstate->fxsave));
"m" (*fx));

return 0;
}

Expand Down Expand Up @@ -261,6 +253,14 @@ static inline void __save_init_fpu(struct task_struct *tsk)

#endif /* CONFIG_X86_64 */

static inline int restore_fpu_checking(struct task_struct *tsk)
{
if (task_thread_info(tsk)->status & TS_XSAVE)
return xrstor_checking(&tsk->thread.xstate->xsave);
else
return fxrstor_checking(&tsk->thread.xstate->fxsave);
}

/*
* Signal frame handlers...
*/
Expand Down

0 comments on commit 34ba476

Please sign in to comment.