Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 191505
b: refs/heads/master
c: c9ad488
h: refs/heads/master
i:
  191503: 959c5a3
v: v3
  • Loading branch information
Avi Kivity authored and H. Peter Anvin committed May 10, 2010
1 parent a02b4dd commit e445e83
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 17 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: 250825008f1f94887bc039e9227a8adfb5ba366e
refs/heads/master: c9ad488289144ae5ef53b012e15895ef1f5e4bb6
20 changes: 16 additions & 4 deletions trunk/arch/x86/include/asm/i387.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@ extern int restore_i387_xstate_ia32(void __user *buf);

#define X87_FSW_ES (1 << 7) /* Exception Summary */

static inline bool use_xsave(void)
{
u8 has_xsave;

alternative_io("mov $0, %0",
"mov $1, %0",
X86_FEATURE_XSAVE,
"=g"(has_xsave));

return has_xsave;
}

#ifdef CONFIG_X86_64

/* Ignore delayed exceptions from user space */
Expand Down Expand Up @@ -99,7 +111,7 @@ static inline void clear_fpu_state(struct task_struct *tsk)
/*
* xsave header may indicate the init state of the FP.
*/
if ((task_thread_info(tsk)->status & TS_XSAVE) &&
if (use_xsave() &&
!(xstate->xsave_hdr.xstate_bv & XSTATE_FP))
return;

Expand Down Expand Up @@ -164,7 +176,7 @@ static inline void fxsave(struct task_struct *tsk)

static inline void __save_init_fpu(struct task_struct *tsk)
{
if (task_thread_info(tsk)->status & TS_XSAVE)
if (use_xsave())
xsave(tsk);
else
fxsave(tsk);
Expand Down Expand Up @@ -218,7 +230,7 @@ static inline int fxrstor_checking(struct i387_fxsave_struct *fx)
*/
static inline void __save_init_fpu(struct task_struct *tsk)
{
if (task_thread_info(tsk)->status & TS_XSAVE) {
if (use_xsave()) {
struct xsave_struct *xstate = &tsk->thread.xstate->xsave;
struct i387_fxsave_struct *fx = &tsk->thread.xstate->fxsave;

Expand Down Expand Up @@ -266,7 +278,7 @@ static inline void __save_init_fpu(struct task_struct *tsk)

static inline int restore_fpu_checking(struct task_struct *tsk)
{
if (task_thread_info(tsk)->status & TS_XSAVE)
if (use_xsave())
return xrstor_checking(&tsk->thread.xstate->xsave);
else
return fxrstor_checking(&tsk->thread.xstate->fxsave);
Expand Down
1 change: 0 additions & 1 deletion trunk/arch/x86/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ static inline struct thread_info *current_thread_info(void)
#define TS_POLLING 0x0004 /* true if in idle loop
and not sleeping */
#define TS_RESTORE_SIGMASK 0x0008 /* restore signal mask in do_signal() */
#define TS_XSAVE 0x0010 /* Use xsave/xrstor */

#define tsk_is_polling(t) (task_thread_info(t)->status & TS_POLLING)

Expand Down
5 changes: 1 addition & 4 deletions trunk/arch/x86/kernel/cpu/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1243,10 +1243,7 @@ void __cpuinit cpu_init(void)
/*
* Force FPU initialization:
*/
if (cpu_has_xsave)
current_thread_info()->status = TS_XSAVE;
else
current_thread_info()->status = 0;
current_thread_info()->status = 0;
clear_used_math();
mxcsr_feature_mask_init();

Expand Down
5 changes: 1 addition & 4 deletions trunk/arch/x86/kernel/i387.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,7 @@ void __cpuinit fpu_init(void)

mxcsr_feature_mask_init();
/* clean state in init */
if (cpu_has_xsave)
current_thread_info()->status = TS_XSAVE;
else
current_thread_info()->status = 0;
current_thread_info()->status = 0;
clear_used_math();
}
#endif /* CONFIG_X86_64 */
Expand Down
6 changes: 3 additions & 3 deletions trunk/arch/x86/kernel/xsave.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ int save_i387_xstate(void __user *buf)
if (err)
return err;

if (task_thread_info(tsk)->status & TS_XSAVE)
if (use_xsave())
err = xsave_user(buf);
else
err = fxsave_user(buf);
Expand All @@ -116,7 +116,7 @@ int save_i387_xstate(void __user *buf)

clear_used_math(); /* trigger finit */

if (task_thread_info(tsk)->status & TS_XSAVE) {
if (use_xsave()) {
struct _fpstate __user *fx = buf;
struct _xstate __user *x = buf;
u64 xstate_bv;
Expand Down Expand Up @@ -225,7 +225,7 @@ int restore_i387_xstate(void __user *buf)
clts();
task_thread_info(current)->status |= TS_USEDFPU;
}
if (task_thread_info(tsk)->status & TS_XSAVE)
if (use_xsave())
err = restore_user_xstate(buf);
else
err = fxrstor_checking((__force struct i387_fxsave_struct *)
Expand Down

0 comments on commit e445e83

Please sign in to comment.