]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
4.4-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 13 Jun 2018 17:27:02 +0000 (19:27 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 13 Jun 2018 17:27:02 +0000 (19:27 +0200)
added patches:
x86-fpu-fix-fnsave-usage-in-eagerfpu-mode.patch
x86-fpu-fix-math-emulation-in-eager-fpu-mode.patch

queue-4.4/series
queue-4.4/x86-fpu-fix-fnsave-usage-in-eagerfpu-mode.patch [new file with mode: 0644]
queue-4.4/x86-fpu-fix-math-emulation-in-eager-fpu-mode.patch [new file with mode: 0644]

index ee9c380a7e956127de17c8329574f3aeba93d89a..eb53f2c1c42dc7de95001a002798515bfad9932b 100644 (file)
@@ -18,3 +18,5 @@ x86-fpu-fix-no387-regression.patch
 x86-fpu-revert-x86-fpu-disable-avx-when-eagerfpu-is-off.patch
 x86-fpu-fix-eager-fpu-handling-on-legacy-fpu-machines.patch
 x86-fpu-hard-disable-lazy-fpu-mode.patch
+x86-fpu-fix-fnsave-usage-in-eagerfpu-mode.patch
+x86-fpu-fix-math-emulation-in-eager-fpu-mode.patch
diff --git a/queue-4.4/x86-fpu-fix-fnsave-usage-in-eagerfpu-mode.patch b/queue-4.4/x86-fpu-fix-fnsave-usage-in-eagerfpu-mode.patch
new file mode 100644 (file)
index 0000000..6b5860c
--- /dev/null
@@ -0,0 +1,82 @@
+From 5ed73f40735c68d8a656b46d09b1885d3b8740ae Mon Sep 17 00:00:00 2001
+From: Andy Lutomirski <luto@kernel.org>
+Date: Sun, 24 Jan 2016 14:38:07 -0800
+Subject: x86/fpu: Fix FNSAVE usage in eagerfpu mode
+
+From: Andy Lutomirski <luto@kernel.org>
+
+commit 5ed73f40735c68d8a656b46d09b1885d3b8740ae upstream.
+
+In eager fpu mode, having deactivated FPU without immediately
+reloading some other context is illegal.  Therefore, to recover from
+FNSAVE, we can't just deactivate the state -- we need to reload it
+if we're not actively context switching.
+
+We had this wrong in fpu__save() and fpu__copy().  Fix both.
+__kernel_fpu_begin() was fine -- add a comment.
+
+This fixes a warning triggerable with nofxsr eagerfpu=on.
+
+Signed-off-by: Andy Lutomirski <luto@kernel.org>
+Cc: Andy Lutomirski <luto@amacapital.net>
+Cc: Borislav Petkov <bp@alien8.de>
+Cc: Dave Hansen <dave.hansen@linux.intel.com>
+Cc: Fenghua Yu <fenghua.yu@intel.com>
+Cc: H. Peter Anvin <hpa@zytor.com>
+Cc: Linus Torvalds <torvalds@linux-foundation.org>
+Cc: Oleg Nesterov <oleg@redhat.com>
+Cc: Peter Zijlstra <peterz@infradead.org>
+Cc: Quentin Casasnovas <quentin.casasnovas@oracle.com>
+Cc: Rik van Riel <riel@redhat.com>
+Cc: Sai Praneeth Prakhya <sai.praneeth.prakhya@intel.com>
+Cc: Thomas Gleixner <tglx@linutronix.de>
+Cc: yu-cheng yu <yu-cheng.yu@intel.com>
+Link: http://lkml.kernel.org/r/60662444e13c76f06e23c15c5dcdba31b4ac3d67.1453675014.git.luto@kernel.org
+Signed-off-by: Ingo Molnar <mingo@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/x86/kernel/fpu/core.c |   18 +++++++++++++++---
+ 1 file changed, 15 insertions(+), 3 deletions(-)
+
+--- a/arch/x86/kernel/fpu/core.c
++++ b/arch/x86/kernel/fpu/core.c
+@@ -114,6 +114,10 @@ void __kernel_fpu_begin(void)
+       kernel_fpu_disable();
+       if (fpu->fpregs_active) {
++              /*
++               * Ignore return value -- we don't care if reg state
++               * is clobbered.
++               */
+               copy_fpregs_to_fpstate(fpu);
+       } else {
+               this_cpu_write(fpu_fpregs_owner_ctx, NULL);
+@@ -189,8 +193,12 @@ void fpu__save(struct fpu *fpu)
+       preempt_disable();
+       if (fpu->fpregs_active) {
+-              if (!copy_fpregs_to_fpstate(fpu))
+-                      fpregs_deactivate(fpu);
++              if (!copy_fpregs_to_fpstate(fpu)) {
++                      if (use_eager_fpu())
++                              copy_kernel_to_fpregs(&fpu->state);
++                      else
++                              fpregs_deactivate(fpu);
++              }
+       }
+       preempt_enable();
+ }
+@@ -259,7 +267,11 @@ static void fpu_copy(struct fpu *dst_fpu
+       preempt_disable();
+       if (!copy_fpregs_to_fpstate(dst_fpu)) {
+               memcpy(&src_fpu->state, &dst_fpu->state, xstate_size);
+-              fpregs_deactivate(src_fpu);
++
++              if (use_eager_fpu())
++                      copy_kernel_to_fpregs(&src_fpu->state);
++              else
++                      fpregs_deactivate(src_fpu);
+       }
+       preempt_enable();
+ }
diff --git a/queue-4.4/x86-fpu-fix-math-emulation-in-eager-fpu-mode.patch b/queue-4.4/x86-fpu-fix-math-emulation-in-eager-fpu-mode.patch
new file mode 100644 (file)
index 0000000..d529cf3
--- /dev/null
@@ -0,0 +1,74 @@
+From 4ecd16ec7059390b430af34bd8bc3ca2b5dcef9a Mon Sep 17 00:00:00 2001
+From: Andy Lutomirski <luto@kernel.org>
+Date: Sun, 24 Jan 2016 14:38:06 -0800
+Subject: x86/fpu: Fix math emulation in eager fpu mode
+
+From: Andy Lutomirski <luto@kernel.org>
+
+commit 4ecd16ec7059390b430af34bd8bc3ca2b5dcef9a upstream.
+
+Systems without an FPU are generally old and therefore use lazy FPU
+switching. Unsurprisingly, math emulation in eager FPU mode is a
+bit buggy. Fix it.
+
+There were two bugs involving kernel code trying to use the FPU
+registers in eager mode even if they didn't exist and one BUG_ON()
+that was incorrect.
+
+Signed-off-by: Andy Lutomirski <luto@kernel.org>
+Cc: Andy Lutomirski <luto@amacapital.net>
+Cc: Borislav Petkov <bp@alien8.de>
+Cc: Dave Hansen <dave.hansen@linux.intel.com>
+Cc: Fenghua Yu <fenghua.yu@intel.com>
+Cc: H. Peter Anvin <hpa@zytor.com>
+Cc: Linus Torvalds <torvalds@linux-foundation.org>
+Cc: Oleg Nesterov <oleg@redhat.com>
+Cc: Peter Zijlstra <peterz@infradead.org>
+Cc: Quentin Casasnovas <quentin.casasnovas@oracle.com>
+Cc: Rik van Riel <riel@redhat.com>
+Cc: Sai Praneeth Prakhya <sai.praneeth.prakhya@intel.com>
+Cc: Thomas Gleixner <tglx@linutronix.de>
+Cc: yu-cheng yu <yu-cheng.yu@intel.com>
+Link: http://lkml.kernel.org/r/b4b8d112436bd6fab866e1b4011131507e8d7fbe.1453675014.git.luto@kernel.org
+Signed-off-by: Ingo Molnar <mingo@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/x86/include/asm/fpu/internal.h |    3 ++-
+ arch/x86/kernel/fpu/core.c          |    2 +-
+ arch/x86/kernel/traps.c             |    1 -
+ 3 files changed, 3 insertions(+), 3 deletions(-)
+
+--- a/arch/x86/include/asm/fpu/internal.h
++++ b/arch/x86/include/asm/fpu/internal.h
+@@ -596,7 +596,8 @@ switch_fpu_prepare(struct fpu *old_fpu,
+        * If the task has used the math, pre-load the FPU on xsave processors
+        * or if the past 5 consecutive context-switches used math.
+        */
+-      fpu.preload = new_fpu->fpstate_active &&
++      fpu.preload = static_cpu_has(X86_FEATURE_FPU) &&
++                    new_fpu->fpstate_active &&
+                     (use_eager_fpu() || new_fpu->counter > 5);
+       if (old_fpu->fpregs_active) {
+--- a/arch/x86/kernel/fpu/core.c
++++ b/arch/x86/kernel/fpu/core.c
+@@ -437,7 +437,7 @@ void fpu__clear(struct fpu *fpu)
+ {
+       WARN_ON_FPU(fpu != &current->thread.fpu); /* Almost certainly an anomaly */
+-      if (!use_eager_fpu()) {
++      if (!use_eager_fpu() || !static_cpu_has(X86_FEATURE_FPU)) {
+               /* FPU state will be reallocated lazily at the first use. */
+               fpu__drop(fpu);
+       } else {
+--- a/arch/x86/kernel/traps.c
++++ b/arch/x86/kernel/traps.c
+@@ -751,7 +751,6 @@ dotraplinkage void
+ do_device_not_available(struct pt_regs *regs, long error_code)
+ {
+       RCU_LOCKDEP_WARN(!rcu_is_watching(), "entry code didn't wake RCU");
+-      BUG_ON(use_eager_fpu());
+ #ifdef CONFIG_MATH_EMULATION
+       if (read_cr0() & X86_CR0_EM) {