]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - arch/x86/include/asm/i387.h
Merge branch 'x86-xsave-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[karo-tx-linux.git] / arch / x86 / include / asm / i387.h
index 815c5b2b9f57de3011c4cbfa1aba663a2c0033f1..a73a8d5a5e6963e6fef9b52c28666e913a74160c 100644 (file)
@@ -31,7 +31,6 @@ extern void mxcsr_feature_mask_init(void);
 extern int init_fpu(struct task_struct *child);
 extern asmlinkage void math_state_restore(void);
 extern void __math_state_restore(void);
-extern void init_thread_xstate(void);
 extern int dump_fpu(struct pt_regs *, struct user_i387_struct *);
 
 extern user_regset_active_fn fpregs_active, xfpregs_active;
@@ -58,11 +57,25 @@ extern int restore_i387_xstate_ia32(void __user *buf);
 
 #define X87_FSW_ES (1 << 7)    /* Exception Summary */
 
+static __always_inline __pure bool use_xsaveopt(void)
+{
+       return static_cpu_has(X86_FEATURE_XSAVEOPT);
+}
+
 static __always_inline __pure bool use_xsave(void)
 {
        return static_cpu_has(X86_FEATURE_XSAVE);
 }
 
+extern void __sanitize_i387_state(struct task_struct *);
+
+static inline void sanitize_i387_state(struct task_struct *tsk)
+{
+       if (!use_xsaveopt())
+               return;
+       __sanitize_i387_state(tsk);
+}
+
 #ifdef CONFIG_X86_64
 
 /* Ignore delayed exceptions from user space */
@@ -127,6 +140,15 @@ static inline int fxsave_user(struct i387_fxsave_struct __user *fx)
 {
        int err;
 
+       /*
+        * Clear the bytes not touched by the fxsave and reserved
+        * for the SW usage.
+        */
+       err = __clear_user(&fx->sw_reserved,
+                          sizeof(struct _fpx_sw_bytes));
+       if (unlikely(err))
+               return -EFAULT;
+
        asm volatile("1:  rex64/fxsave (%[fx])\n\t"
                     "2:\n"
                     ".section .fixup,\"ax\"\n"