]> err.no Git - linux-2.6/blobdiff - include/asm-x86/i387.h
Merge commit 'v2.6.26-rc8' into x86/mce
[linux-2.6] / include / asm-x86 / i387.h
index 382a5fa9d492a1715f1c2b378139d6ad32c46951..37672f79dcc8f3c879e7899f31868d7d06c2e0ae 100644 (file)
@@ -21,7 +21,7 @@
 
 extern void fpu_init(void);
 extern void mxcsr_feature_mask_init(void);
-extern void init_fpu(struct task_struct *child);
+extern int init_fpu(struct task_struct *child);
 extern asmlinkage void math_state_restore(void);
 extern void init_thread_xstate(void);
 
@@ -175,7 +175,15 @@ static inline int save_i387(struct _fpstate __user *buf)
  */
 static inline int restore_i387(struct _fpstate __user *buf)
 {
-       set_used_math();
+       struct task_struct *tsk = current;
+       int err;
+
+       if (!used_math()) {
+               err = init_fpu(tsk);
+               if (err)
+                       return err;
+       }
+
        if (!(task_thread_info(current)->status & TS_USEDFPU)) {
                clts();
                task_thread_info(current)->status |= TS_USEDFPU;
@@ -185,6 +193,8 @@ static inline int restore_i387(struct _fpstate __user *buf)
 
 #else  /* CONFIG_X86_32 */
 
+extern void finit(void);
+
 static inline void tolerant_fwait(void)
 {
        asm volatile("fnclex ; fwait");
@@ -328,7 +338,7 @@ static inline unsigned short get_fpu_cwd(struct task_struct *tsk)
        if (cpu_has_fxsr) {
                return tsk->thread.xstate->fxsave.cwd;
        } else {
-               return (unsigned short) tsk->thread.xstate->fsave.cwd;
+               return (unsigned short)tsk->thread.xstate->fsave.cwd;
        }
 }
 
@@ -337,7 +347,7 @@ static inline unsigned short get_fpu_swd(struct task_struct *tsk)
        if (cpu_has_fxsr) {
                return tsk->thread.xstate->fxsave.swd;
        } else {
-               return (unsigned short) tsk->thread.xstate->fsave.swd;
+               return (unsigned short)tsk->thread.xstate->fsave.swd;
        }
 }