diff options
author | Linus Torvalds <torvalds@evo.osdl.org> | 2005-07-22 16:06:16 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@evo.osdl.org> | 2005-07-22 16:06:16 -0400 |
commit | 8ed1383fb7b6685968588141d5934e0e6715e954 (patch) | |
tree | 7ee8476ec114dbab907e3acf4e8a9d0342bf6751 | |
parent | b339a18b81a1f6ca1455559594f5df872b9e59f4 (diff) |
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.
-rw-r--r-- | arch/i386/kernel/i387.c | 11 | ||||
-rw-r--r-- | include/asm-i386/i387.h | 13 |
2 files changed, 12 insertions, 12 deletions
diff --git a/arch/i386/kernel/i387.c b/arch/i386/kernel/i387.c index b817168d9c62..d75524758daf 100644 --- a/arch/i386/kernel/i387.c +++ b/arch/i386/kernel/i387.c | |||
@@ -82,17 +82,6 @@ void kernel_fpu_begin(void) | |||
82 | } | 82 | } |
83 | EXPORT_SYMBOL_GPL(kernel_fpu_begin); | 83 | EXPORT_SYMBOL_GPL(kernel_fpu_begin); |
84 | 84 | ||
85 | void restore_fpu( struct task_struct *tsk ) | ||
86 | { | ||
87 | if ( cpu_has_fxsr ) { | ||
88 | asm volatile( "fxrstor %0" | ||
89 | : : "m" (tsk->thread.i387.fxsave) ); | ||
90 | } else { | ||
91 | asm volatile( "frstor %0" | ||
92 | : : "m" (tsk->thread.i387.fsave) ); | ||
93 | } | ||
94 | } | ||
95 | |||
96 | /* | 85 | /* |
97 | * FPU tag word conversions. | 86 | * FPU tag word conversions. |
98 | */ | 87 | */ |
diff --git a/include/asm-i386/i387.h b/include/asm-i386/i387.h index f6feb98a9397..e678609bb57e 100644 --- a/include/asm-i386/i387.h +++ b/include/asm-i386/i387.h | |||
@@ -19,10 +19,21 @@ | |||
19 | 19 | ||
20 | extern void mxcsr_feature_mask_init(void); | 20 | extern void mxcsr_feature_mask_init(void); |
21 | extern void init_fpu(struct task_struct *); | 21 | extern void init_fpu(struct task_struct *); |
22 | |||
22 | /* | 23 | /* |
23 | * FPU lazy state save handling... | 24 | * FPU lazy state save handling... |
24 | */ | 25 | */ |
25 | extern void restore_fpu( struct task_struct *tsk ); | 26 | |
27 | /* | ||
28 | * The "nop" is needed to make the instructions the same | ||
29 | * length. | ||
30 | */ | ||
31 | #define restore_fpu(tsk) \ | ||
32 | alternative_input( \ | ||
33 | "nop ; frstor %1", \ | ||
34 | "fxrstor %1", \ | ||
35 | X86_FEATURE_FXSR, \ | ||
36 | "m" ((tsk)->thread.i387.fsave)) | ||
26 | 37 | ||
27 | extern void kernel_fpu_begin(void); | 38 | extern void kernel_fpu_begin(void); |
28 | #define kernel_fpu_end() do { stts(); preempt_enable(); } while(0) | 39 | #define kernel_fpu_end() do { stts(); preempt_enable(); } while(0) |