Skip to content

Commit

Permalink
x86: use alternative instructions for fnsave/fxsave too
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Linus Torvalds committed Jul 22, 2005
1 parent 38afd6a commit 2847e34
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions include/asm-i386/i387.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ extern void init_fpu(struct task_struct *);
"nop ; frstor %1", \
"fxrstor %1", \
X86_FEATURE_FXSR, \
"m" ((tsk)->thread.i387.fsave))
"m" ((tsk)->thread.i387.fxsave))

extern void kernel_fpu_begin(void);
#define kernel_fpu_end() do { stts(); preempt_enable(); } while(0)
Expand All @@ -43,13 +43,12 @@ extern void kernel_fpu_begin(void);
*/
static inline void __save_init_fpu( struct task_struct *tsk )
{
if ( cpu_has_fxsr ) {
asm volatile( "fxsave %0 ; fnclex"
: "=m" (tsk->thread.i387.fxsave) );
} else {
asm volatile( "fnsave %0 ; fwait"
: "=m" (tsk->thread.i387.fsave) );
}
alternative_input(
"fnsave %1 ; fwait ;" GENERIC_NOP2,
"fxsave %1 ; fnclex",
X86_FEATURE_FXSR,
"m" (tsk->thread.i387.fxsave)
:"memory");
tsk->thread_info->status &= ~TS_USEDFPU;
}

Expand Down

0 comments on commit 2847e34

Please sign in to comment.