Commit 8ed1383f authored by Linus Torvalds's avatar Linus Torvalds

x86: make restore_fpu() use alternative assembler instructions

It's really just a single instruction, conditional on whether the CPU
supports FXSR or not, so implement it as such instead of making it a
function that queries FXSR dynamically.

This means that the instruction just gets automatically rewritten to the
correct one at boot-time.
parent b339a18b
...@@ -82,17 +82,6 @@ void kernel_fpu_begin(void) ...@@ -82,17 +82,6 @@ void kernel_fpu_begin(void)
} }
EXPORT_SYMBOL_GPL(kernel_fpu_begin); EXPORT_SYMBOL_GPL(kernel_fpu_begin);
void restore_fpu( struct task_struct *tsk )
{
if ( cpu_has_fxsr ) {
asm volatile( "fxrstor %0"
: : "m" (tsk->thread.i387.fxsave) );
} else {
asm volatile( "frstor %0"
: : "m" (tsk->thread.i387.fsave) );
}
}
/* /*
* FPU tag word conversions. * FPU tag word conversions.
*/ */
......
...@@ -19,10 +19,21 @@ ...@@ -19,10 +19,21 @@
extern void mxcsr_feature_mask_init(void); extern void mxcsr_feature_mask_init(void);
extern void init_fpu(struct task_struct *); extern void init_fpu(struct task_struct *);
/* /*
* FPU lazy state save handling... * FPU lazy state save handling...
*/ */
extern void restore_fpu( struct task_struct *tsk );
/*
* The "nop" is needed to make the instructions the same
* length.
*/
#define restore_fpu(tsk) \
alternative_input( \
"nop ; frstor %1", \
"fxrstor %1", \
X86_FEATURE_FXSR, \
"m" ((tsk)->thread.i387.fsave))
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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment