]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - include/asm-i386/i387.h
Merge branch 'for-linus' of git://brick.kernel.dk/data/git/linux-2.6-block
[karo-tx-linux.git] / include / asm-i386 / i387.h
index f6feb98a93972e7971662fbe09fec8f247e53fee..152d0baa576a675b39bfa408a6b69f670e8ad118 100644 (file)
 
 extern void mxcsr_feature_mask_init(void);
 extern void init_fpu(struct task_struct *);
+
 /*
  * 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.fxsave))
 
 extern void kernel_fpu_begin(void);
 #define kernel_fpu_end() do { stts(); preempt_enable(); } while(0)
@@ -32,26 +43,25 @@ 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) );
-       }
-       tsk->thread_info->status &= ~TS_USEDFPU;
+       alternative_input(
+               "fnsave %1 ; fwait ;" GENERIC_NOP2,
+               "fxsave %1 ; fnclex",
+               X86_FEATURE_FXSR,
+               "m" (tsk->thread.i387.fxsave)
+               :"memory");
+       task_thread_info(tsk)->status &= ~TS_USEDFPU;
 }
 
 #define __unlazy_fpu( tsk ) do { \
-       if ((tsk)->thread_info->status & TS_USEDFPU) \
+       if (task_thread_info(tsk)->status & TS_USEDFPU) \
                save_init_fpu( tsk ); \
 } while (0)
 
 #define __clear_fpu( tsk )                                     \
 do {                                                           \
-       if ((tsk)->thread_info->status & TS_USEDFPU) {          \
+       if (task_thread_info(tsk)->status & TS_USEDFPU) {               \
                asm volatile("fnclex ; fwait");                         \
-               (tsk)->thread_info->status &= ~TS_USEDFPU;      \
+               task_thread_info(tsk)->status &= ~TS_USEDFPU;   \
                stts();                                         \
        }                                                       \
 } while (0)