Commit e0d3602f authored by Sebastian Andrzej Siewior's avatar Sebastian Andrzej Siewior Committed by Borislav Petkov

x86/fpu: Inline copy_user_to_fpregs_zeroing()

Start refactoring __fpu__restore_sig() by inlining
copy_user_to_fpregs_zeroing(). The original function remains and will be
used to restore from userland memory if possible.
Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
Reviewed-by: default avatarDave Hansen <dave.hansen@intel.com>
Reviewed-by: default avatarThomas Gleixner <tglx@linutronix.de>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jann Horn <jannh@google.com>
Cc: "Jason A. Donenfeld" <Jason@zx2c4.com>
Cc: kvm ML <kvm@vger.kernel.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Cc: Rik van Riel <riel@surriel.com>
Cc: x86-ml <x86@kernel.org>
Link: https://lkml.kernel.org/r/20190403164156.19645-21-bigeasy@linutronix.de
parent 0d714dba
...@@ -337,11 +337,29 @@ static int __fpu__restore_sig(void __user *buf, void __user *buf_fx, int size) ...@@ -337,11 +337,29 @@ static int __fpu__restore_sig(void __user *buf, void __user *buf_fx, int size)
kfree(tmp); kfree(tmp);
return err; return err;
} else { } else {
int ret;
/* /*
* For 64-bit frames and 32-bit fsave frames, restore the user * For 64-bit frames and 32-bit fsave frames, restore the user
* state to the registers directly (with exceptions handled). * state to the registers directly (with exceptions handled).
*/ */
if (copy_user_to_fpregs_zeroing(buf_fx, xfeatures, fx_only)) { if (use_xsave()) {
if ((unsigned long)buf_fx % 64 || fx_only) {
u64 init_bv = xfeatures_mask & ~XFEATURE_MASK_FPSSE;
copy_kernel_to_xregs(&init_fpstate.xsave, init_bv);
ret = copy_user_to_fxregs(buf_fx);
} else {
u64 init_bv = xfeatures_mask & ~xfeatures;
if (unlikely(init_bv))
copy_kernel_to_xregs(&init_fpstate.xsave, init_bv);
ret = copy_user_to_xregs(buf_fx, xfeatures);
}
} else if (use_fxsr()) {
ret = copy_user_to_fxregs(buf_fx);
} else
ret = copy_user_to_fregs(buf_fx);
if (ret) {
fpu__clear(fpu); fpu__clear(fpu);
return -1; return -1;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment