提交 2847e347 编写于 作者: L Linus Torvalds

x86: use alternative instructions for fnsave/fxsave too

This one ends up using an inline asm format that claims to read memory
and then clobber it (rather than just write it directly), which made it
easier to use the existing "alternative_input()" infrastructure support.

Now the fxsave code matches the fxrstor.
上级 38afd6ad
...@@ -33,7 +33,7 @@ extern void init_fpu(struct task_struct *); ...@@ -33,7 +33,7 @@ extern void init_fpu(struct task_struct *);
"nop ; frstor %1", \ "nop ; frstor %1", \
"fxrstor %1", \ "fxrstor %1", \
X86_FEATURE_FXSR, \ X86_FEATURE_FXSR, \
"m" ((tsk)->thread.i387.fsave)) "m" ((tsk)->thread.i387.fxsave))
extern void kernel_fpu_begin(void); extern void kernel_fpu_begin(void);
#define kernel_fpu_end() do { stts(); preempt_enable(); } while(0) #define kernel_fpu_end() do { stts(); preempt_enable(); } while(0)
...@@ -43,13 +43,12 @@ extern void kernel_fpu_begin(void); ...@@ -43,13 +43,12 @@ extern void kernel_fpu_begin(void);
*/ */
static inline void __save_init_fpu( struct task_struct *tsk ) static inline void __save_init_fpu( struct task_struct *tsk )
{ {
if ( cpu_has_fxsr ) { alternative_input(
asm volatile( "fxsave %0 ; fnclex" "fnsave %1 ; fwait ;" GENERIC_NOP2,
: "=m" (tsk->thread.i387.fxsave) ); "fxsave %1 ; fnclex",
} else { X86_FEATURE_FXSR,
asm volatile( "fnsave %0 ; fwait" "m" (tsk->thread.i387.fxsave)
: "=m" (tsk->thread.i387.fsave) ); :"memory");
}
tsk->thread_info->status &= ~TS_USEDFPU; tsk->thread_info->status &= ~TS_USEDFPU;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册