aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/include/asm/i387.h
diff options
context:
space:
mode:
authorAvi Kivity <avi@redhat.com>2010-05-06 11:45:45 +0300
committerH. Peter Anvin <hpa@zytor.com>2010-05-10 10:39:33 -0700
commitc9ad488289144ae5ef53b012e15895ef1f5e4bb6 (patch)
tree06c29cda09e204d3b0b5b3d9a2a97bda0b4e340d /arch/x86/include/asm/i387.h
parentx86-32: Don't set ignore_fpu_irq in simd exception (diff)
downloadlinux-dev-c9ad488289144ae5ef53b012e15895ef1f5e4bb6.tar.xz
linux-dev-c9ad488289144ae5ef53b012e15895ef1f5e4bb6.zip
x86: Eliminate TS_XSAVE
The fpu code currently uses current->thread_info->status & TS_XSAVE as a way to distinguish between XSAVE capable processors and older processors. The decision is not really task specific; instead we use the task status to avoid a global memory reference - the value should be the same across all threads. Eliminate this tie-in into the task structure by using an alternative instruction keyed off the XSAVE cpu feature; this results in shorter and faster code, without introducing a global memory reference. [ hpa: in the future, this probably should use an asm jmp ] Signed-off-by: Avi Kivity <avi@redhat.com> Acked-by: Suresh Siddha <suresh.b.siddha@intel.com> LKML-Reference: <1273135546-29690-2-git-send-email-avi@redhat.com> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'arch/x86/include/asm/i387.h')
-rw-r--r--arch/x86/include/asm/i387.h20
1 files changed, 16 insertions, 4 deletions
diff --git a/arch/x86/include/asm/i387.h b/arch/x86/include/asm/i387.h
index da2930924501..a301a6825c3a 100644
--- a/arch/x86/include/asm/i387.h
+++ b/arch/x86/include/asm/i387.h
@@ -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 */
@@ -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;
@@ -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);
@@ -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;
@@ -266,7 +278,7 @@ end:
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);