linux/arch
Sebastian Andrzej Siewior 39388e80f9 x86/fpu: Don't save fxregs for ia32 frames in copy_fpstate_to_sigframe()
In commit

  72a671ced6 ("x86, fpu: Unify signal handling code paths for x86 and x86_64 kernels")

the 32bit and 64bit path of the signal delivery code were merged.

The 32bit version:

  int save_i387_xstate_ia32(void __user *buf)
  …
         if (cpu_has_xsave)
                 return save_i387_xsave(fp);
         if (cpu_has_fxsr)
                 return save_i387_fxsave(fp);

The 64bit version:

  int save_i387_xstate(void __user *buf)
  …
         if (user_has_fpu()) {
                 if (use_xsave())
                         err = xsave_user(buf);
                 else
                         err = fxsave_user(buf);

                 if (unlikely(err)) {
                         __clear_user(buf, xstate_size);
                         return err;

The merge:

  int save_xstate_sig(void __user *buf, void __user *buf_fx, int size)
  …
         if (user_has_fpu()) {
                 /* Save the live register state to the user directly. */
                 if (save_user_xstate(buf_fx))
                         return -1;
                 /* Update the thread's fxstate to save the fsave header. */
                 if (ia32_fxstate)
                         fpu_fxsave(&tsk->thread.fpu);

I don't think that we needed to save the FPU registers to ->thread.fpu
because the registers were stored in buf_fx. Today the state will be
restored from buf_fx after the signal was handled (I assume that this
was also the case with lazy-FPU).

Since commit

  66463db4fc ("x86, fpu: shift drop_init_fpu() from save_xstate_sig() to handle_signal()")

it is ensured that the signal handler starts with clear/fresh set of FPU
registers which means that the previous store is futile.

Remove the copy_fxregs_to_kernel() call because task's FPU state is
cleared later in handle_signal() via fpu__clear().

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Dave Hansen <dave.hansen@intel.com>
Reviewed-by: Thomas 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-7-bigeasy@linutronix.de
2019-04-10 14:46:35 +02:00
..
alpha KVM: export <linux/kvm_para.h> and <asm/kvm_para.h> iif KVM is supported 2019-03-28 17:27:42 +01:00
arc KVM: export <linux/kvm_para.h> and <asm/kvm_para.h> iif KVM is supported 2019-03-28 17:27:42 +01:00
arm A collection of x86 and ARM bugfixes, and some improvements to documentation. 2019-03-31 08:55:59 -07:00
arm64 A collection of x86 and ARM bugfixes, and some improvements to documentation. 2019-03-31 08:55:59 -07:00
c6x KVM: export <linux/kvm_para.h> and <asm/kvm_para.h> iif KVM is supported 2019-03-28 17:27:42 +01:00
csky kbuild: force all architectures except um to include mandatory-y 2019-03-17 12:56:32 +09:00
h8300 KVM: export <linux/kvm_para.h> and <asm/kvm_para.h> iif KVM is supported 2019-03-28 17:27:42 +01:00
hexagon KVM: export <linux/kvm_para.h> and <asm/kvm_para.h> iif KVM is supported 2019-03-28 17:27:42 +01:00
ia64 KVM: export <linux/kvm_para.h> and <asm/kvm_para.h> iif KVM is supported 2019-03-28 17:27:42 +01:00
m68k KVM: export <linux/kvm_para.h> and <asm/kvm_para.h> iif KVM is supported 2019-03-28 17:27:42 +01:00
microblaze KVM: export <linux/kvm_para.h> and <asm/kvm_para.h> iif KVM is supported 2019-03-28 17:27:42 +01:00
mips A small batch of MIPS fixes for 5.1: 2019-03-19 10:50:15 -07:00
nds32 kbuild: force all architectures except um to include mandatory-y 2019-03-17 12:56:32 +09:00
nios2 KVM: export <linux/kvm_para.h> and <asm/kvm_para.h> iif KVM is supported 2019-03-28 17:27:42 +01:00
openrisc KVM: export <linux/kvm_para.h> and <asm/kvm_para.h> iif KVM is supported 2019-03-28 17:27:42 +01:00
parisc KVM: export <linux/kvm_para.h> and <asm/kvm_para.h> iif KVM is supported 2019-03-28 17:27:42 +01:00
powerpc powerpc fixes for 5.1 #4 2019-03-31 07:44:13 -07:00
riscv kbuild: force all architectures except um to include mandatory-y 2019-03-17 12:56:32 +09:00
s390 s390 update with improvements and bug fixes for 5.1-rc2 2019-03-28 08:35:32 -07:00
sh KVM: export <linux/kvm_para.h> and <asm/kvm_para.h> iif KVM is supported 2019-03-28 17:27:42 +01:00
sparc KVM: export <linux/kvm_para.h> and <asm/kvm_para.h> iif KVM is supported 2019-03-28 17:27:42 +01:00
um Merge branch 'for-linus-5.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rw/uml 2019-03-15 15:07:32 -07:00
unicore32 KVM: export <linux/kvm_para.h> and <asm/kvm_para.h> iif KVM is supported 2019-03-28 17:27:42 +01:00
x86 x86/fpu: Don't save fxregs for ia32 frames in copy_fpstate_to_sigframe() 2019-04-10 14:46:35 +02:00
xtensa KVM: export <linux/kvm_para.h> and <asm/kvm_para.h> iif KVM is supported 2019-03-28 17:27:42 +01:00
.gitignore
Kconfig Char/Misc driver patches for 5.1-rc1 2019-03-06 14:18:59 -08:00