diff options
| -rw-r--r-- | arch/x86/include/asm/fpu-internal.h | 17 | ||||
| -rw-r--r-- | arch/x86/kernel/xsave.c | 6 |
2 files changed, 20 insertions, 3 deletions
diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h index 409b9ccf5518..831dbb9c6c02 100644 --- a/arch/x86/include/asm/fpu-internal.h +++ b/arch/x86/include/asm/fpu-internal.h | |||
| @@ -181,11 +181,28 @@ static inline int fxrstor_checking(struct i387_fxsave_struct *fx) | |||
| 181 | "m" (*fx)); | 181 | "m" (*fx)); |
| 182 | } | 182 | } |
| 183 | 183 | ||
| 184 | static inline int fxrstor_user(struct i387_fxsave_struct __user *fx) | ||
| 185 | { | ||
| 186 | if (config_enabled(CONFIG_X86_32)) | ||
| 187 | return user_insn(fxrstor %[fx], "=m" (*fx), [fx] "m" (*fx)); | ||
| 188 | else if (config_enabled(CONFIG_AS_FXSAVEQ)) | ||
| 189 | return user_insn(fxrstorq %[fx], "=m" (*fx), [fx] "m" (*fx)); | ||
| 190 | |||
| 191 | /* See comment in fpu_fxsave() below. */ | ||
| 192 | return user_insn(rex64/fxrstor (%[fx]), "=m" (*fx), [fx] "R" (fx), | ||
| 193 | "m" (*fx)); | ||
| 194 | } | ||
| 195 | |||
| 184 | static inline int frstor_checking(struct i387_fsave_struct *fx) | 196 | static inline int frstor_checking(struct i387_fsave_struct *fx) |
| 185 | { | 197 | { |
| 186 | return check_insn(frstor %[fx], "=m" (*fx), [fx] "m" (*fx)); | 198 | return check_insn(frstor %[fx], "=m" (*fx), [fx] "m" (*fx)); |
| 187 | } | 199 | } |
| 188 | 200 | ||
| 201 | static inline int frstor_user(struct i387_fsave_struct __user *fx) | ||
| 202 | { | ||
| 203 | return user_insn(frstor %[fx], "=m" (*fx), [fx] "m" (*fx)); | ||
| 204 | } | ||
| 205 | |||
| 189 | static inline void fpu_fxsave(struct fpu *fpu) | 206 | static inline void fpu_fxsave(struct fpu *fpu) |
| 190 | { | 207 | { |
| 191 | if (config_enabled(CONFIG_X86_32)) | 208 | if (config_enabled(CONFIG_X86_32)) |
diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c index 4e89b3dd408d..ada87a329edc 100644 --- a/arch/x86/kernel/xsave.c +++ b/arch/x86/kernel/xsave.c | |||
| @@ -315,7 +315,7 @@ static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only) | |||
| 315 | if ((unsigned long)buf % 64 || fx_only) { | 315 | if ((unsigned long)buf % 64 || fx_only) { |
| 316 | u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE; | 316 | u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE; |
| 317 | xrstor_state(init_xstate_buf, init_bv); | 317 | xrstor_state(init_xstate_buf, init_bv); |
| 318 | return fxrstor_checking((__force void *) buf); | 318 | return fxrstor_user(buf); |
| 319 | } else { | 319 | } else { |
| 320 | u64 init_bv = pcntxt_mask & ~xbv; | 320 | u64 init_bv = pcntxt_mask & ~xbv; |
| 321 | if (unlikely(init_bv)) | 321 | if (unlikely(init_bv)) |
| @@ -323,9 +323,9 @@ static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only) | |||
| 323 | return xrestore_user(buf, xbv); | 323 | return xrestore_user(buf, xbv); |
| 324 | } | 324 | } |
| 325 | } else if (use_fxsr()) { | 325 | } else if (use_fxsr()) { |
| 326 | return fxrstor_checking((__force void *) buf); | 326 | return fxrstor_user(buf); |
| 327 | } else | 327 | } else |
| 328 | return frstor_checking((__force void *) buf); | 328 | return frstor_user(buf); |
| 329 | } | 329 | } |
| 330 | 330 | ||
| 331 | int __restore_xstate_sig(void __user *buf, void __user *buf_fx, int size) | 331 | int __restore_xstate_sig(void __user *buf, void __user *buf_fx, int size) |
