diff options
Diffstat (limited to 'arch/x86/include/asm/i387.h')
-rw-r--r-- | arch/x86/include/asm/i387.h | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/arch/x86/include/asm/i387.h b/arch/x86/include/asm/i387.h index 815c5b2b9f57..a73a8d5a5e69 100644 --- a/arch/x86/include/asm/i387.h +++ b/arch/x86/include/asm/i387.h | |||
@@ -31,7 +31,6 @@ extern void mxcsr_feature_mask_init(void); | |||
31 | extern int init_fpu(struct task_struct *child); | 31 | extern int init_fpu(struct task_struct *child); |
32 | extern asmlinkage void math_state_restore(void); | 32 | extern asmlinkage void math_state_restore(void); |
33 | extern void __math_state_restore(void); | 33 | extern void __math_state_restore(void); |
34 | extern void init_thread_xstate(void); | ||
35 | extern int dump_fpu(struct pt_regs *, struct user_i387_struct *); | 34 | extern int dump_fpu(struct pt_regs *, struct user_i387_struct *); |
36 | 35 | ||
37 | extern user_regset_active_fn fpregs_active, xfpregs_active; | 36 | extern user_regset_active_fn fpregs_active, xfpregs_active; |
@@ -58,11 +57,25 @@ extern int restore_i387_xstate_ia32(void __user *buf); | |||
58 | 57 | ||
59 | #define X87_FSW_ES (1 << 7) /* Exception Summary */ | 58 | #define X87_FSW_ES (1 << 7) /* Exception Summary */ |
60 | 59 | ||
60 | static __always_inline __pure bool use_xsaveopt(void) | ||
61 | { | ||
62 | return static_cpu_has(X86_FEATURE_XSAVEOPT); | ||
63 | } | ||
64 | |||
61 | static __always_inline __pure bool use_xsave(void) | 65 | static __always_inline __pure bool use_xsave(void) |
62 | { | 66 | { |
63 | return static_cpu_has(X86_FEATURE_XSAVE); | 67 | return static_cpu_has(X86_FEATURE_XSAVE); |
64 | } | 68 | } |
65 | 69 | ||
70 | extern void __sanitize_i387_state(struct task_struct *); | ||
71 | |||
72 | static inline void sanitize_i387_state(struct task_struct *tsk) | ||
73 | { | ||
74 | if (!use_xsaveopt()) | ||
75 | return; | ||
76 | __sanitize_i387_state(tsk); | ||
77 | } | ||
78 | |||
66 | #ifdef CONFIG_X86_64 | 79 | #ifdef CONFIG_X86_64 |
67 | 80 | ||
68 | /* Ignore delayed exceptions from user space */ | 81 | /* Ignore delayed exceptions from user space */ |
@@ -127,6 +140,15 @@ static inline int fxsave_user(struct i387_fxsave_struct __user *fx) | |||
127 | { | 140 | { |
128 | int err; | 141 | int err; |
129 | 142 | ||
143 | /* | ||
144 | * Clear the bytes not touched by the fxsave and reserved | ||
145 | * for the SW usage. | ||
146 | */ | ||
147 | err = __clear_user(&fx->sw_reserved, | ||
148 | sizeof(struct _fpx_sw_bytes)); | ||
149 | if (unlikely(err)) | ||
150 | return -EFAULT; | ||
151 | |||
130 | asm volatile("1: rex64/fxsave (%[fx])\n\t" | 152 | asm volatile("1: rex64/fxsave (%[fx])\n\t" |
131 | "2:\n" | 153 | "2:\n" |
132 | ".section .fixup,\"ax\"\n" | 154 | ".section .fixup,\"ax\"\n" |