linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org,
	Andy Shevchenko <andy.shevchenko@gmail.com>,
	Borislav Petkov <bp@suse.de>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Andy Lutomirski <luto@amacapital.net>,
	Borislav Petkov <bp@alien8.de>, Brian Gerst <brgerst@gmail.com>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	Denys Vlasenko <dvlasenk@redhat.com>,
	Fenghua Yu <fenghua.yu@intel.com>,
	"H. Peter Anvin" <hpa@zytor.com>, Oleg Nesterov <oleg@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Quentin Casasnovas <quentin.casasnovas@oracle.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Yu-cheng <yu-cheng.yu@intel.com>, Ingo Molnar <mingo@kernel.org>
Subject: [PATCH 4.4 09/24] x86/fpu: Fix eager-FPU handling on legacy FPU machines
Date: Thu, 14 Jun 2018 16:05:04 +0200	[thread overview]
Message-ID: <20180614132724.861855858@linuxfoundation.org> (raw)
In-Reply-To: <20180614132724.483802160@linuxfoundation.org>

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Borislav Petkov <bp@alien8.de>

commit 6e6867093de35141f0a76b66ac13f9f2e2c8e77a upstream.

i486 derived cores like Intel Quark support only the very old,
legacy x87 FPU (FSAVE/FRSTOR, CPUID bit FXSR is not set), and
our FPU code wasn't handling the saving and restoring there
properly in the 'eagerfpu' case.

So after we made eagerfpu the default for all CPU types:

  58122bf1d856 x86/fpu: Default eagerfpu=on on all CPUs

these old FPU designs broke. First, Andy Shevchenko reported a splat:

  WARNING: CPU: 0 PID: 823 at arch/x86/include/asm/fpu/internal.h:163 fpu__clear+0x8c/0x160

which was us trying to execute FXRSTOR on those machines even though
they don't support it.

After taking care of that, Bryan O'Donoghue reported that a simple FPU
test still failed because we weren't initializing the FPU state properly
on those machines.

Take care of all that.

Reported-and-tested-by: Bryan O'Donoghue <pure.logic@nexus-software.ie>
Reported-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Quentin Casasnovas <quentin.casasnovas@oracle.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Yu-cheng <yu-cheng.yu@intel.com>
Link: http://lkml.kernel.org/r/20160311113206.GD4312@pd.tnic
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/x86/kernel/fpu/core.c |    4 +++-
 arch/x86/kernel/fpu/init.c |    2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

--- a/arch/x86/kernel/fpu/core.c
+++ b/arch/x86/kernel/fpu/core.c
@@ -409,8 +409,10 @@ static inline void copy_init_fpstate_to_
 {
 	if (use_xsave())
 		copy_kernel_to_xregs(&init_fpstate.xsave, -1);
-	else
+	else if (static_cpu_has(X86_FEATURE_FXSR))
 		copy_kernel_to_fxregs(&init_fpstate.fxsave);
+	else
+		copy_kernel_to_fregs(&init_fpstate.fsave);
 }
 
 /*
--- a/arch/x86/kernel/fpu/init.c
+++ b/arch/x86/kernel/fpu/init.c
@@ -135,7 +135,7 @@ static void __init fpu__init_system_gene
 	 * Set up the legacy init FPU context. (xstate init might overwrite this
 	 * with a more modern format, if the CPU supports it.)
 	 */
-	fpstate_init_fxstate(&init_fpstate.fxsave);
+	fpstate_init(&init_fpstate);
 
 	fpu__init_system_mxcsr();
 }



  parent reply	other threads:[~2018-06-14 14:15 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-14 14:04 [PATCH 4.4 00/24] 4.4.138-stable review Greg Kroah-Hartman
2018-06-14 14:04 ` [PATCH 4.4 01/24] x86/fpu: Fix early FPU command-line parsing Greg Kroah-Hartman
2018-06-14 14:04 ` [PATCH 4.4 02/24] x86: Remove unused function cpu_has_ht_siblings() Greg Kroah-Hartman
2018-06-14 14:04 ` [PATCH 4.4 03/24] x86/cpufeature: Remove unused and seldomly used cpu_has_xx macros Greg Kroah-Hartman
2018-06-14 14:04 ` [PATCH 4.4 04/24] x86/fpu: Disable MPX when eagerfpu is off Greg Kroah-Hartman
2018-06-14 14:05 ` [PATCH 4.4 05/24] x86/fpu: Disable AVX " Greg Kroah-Hartman
2018-06-14 14:05 ` [PATCH 4.4 06/24] x86/fpu: Default eagerfpu=on on all CPUs Greg Kroah-Hartman
2018-06-14 14:05 ` [PATCH 4.4 07/24] x86/fpu: Fix no387 regression Greg Kroah-Hartman
2018-06-14 14:05 ` [PATCH 4.4 08/24] x86/fpu: Revert ("x86/fpu: Disable AVX when eagerfpu is off") Greg Kroah-Hartman
2018-06-14 14:05 ` Greg Kroah-Hartman [this message]
2018-06-14 14:05 ` [PATCH 4.4 10/24] x86/fpu: Hard-disable lazy FPU mode Greg Kroah-Hartman
2018-06-15  4:24   ` Daniel Sangorrin
2018-06-15  4:56     ` 'Greg Kroah-Hartman'
2018-06-15  5:23       ` Daniel Sangorrin
2018-06-15  7:06         ` 'Greg Kroah-Hartman'
2018-06-15  9:49           ` Daniel Sangorrin
2018-06-19 15:02     ` Ben Hutchings
2018-06-14 14:05 ` [PATCH 4.4 11/24] x86/fpu: Fix FNSAVE usage in eagerfpu mode Greg Kroah-Hartman
2018-06-14 14:05 ` [PATCH 4.4 12/24] x86/fpu: Fix math emulation in eager fpu mode Greg Kroah-Hartman
2018-06-14 14:05 ` [PATCH 4.4 13/24] af_key: Always verify length of provided sadb_key Greg Kroah-Hartman
2018-06-14 14:05 ` [PATCH 4.4 14/24] x86/crypto, x86/fpu: Remove X86_FEATURE_EAGER_FPU #ifdef from the crc32c code Greg Kroah-Hartman
2018-06-14 14:05 ` [PATCH 4.4 15/24] gpio: No NULL owner Greg Kroah-Hartman
2018-06-14 14:05 ` [PATCH 4.4 16/24] Clarify (and fix) MAX_LFS_FILESIZE macros Greg Kroah-Hartman
2018-06-14 14:05 ` [PATCH 4.4 17/24] KVM: x86: introduce linear_{read,write}_system Greg Kroah-Hartman
2018-06-14 14:05 ` [PATCH 4.4 18/24] KVM: x86: pass kvm_vcpu to kvm_read_guest_virt and kvm_write_guest_virt_system Greg Kroah-Hartman
2018-06-14 14:05 ` [PATCH 4.4 19/24] serial: samsung: fix maxburst parameter for DMA transactions Greg Kroah-Hartman
2018-06-14 14:05 ` [PATCH 4.4 20/24] vmw_balloon: fixing double free when batching mode is off Greg Kroah-Hartman
2018-06-14 14:05 ` [PATCH 4.4 21/24] kvm: x86: use correct privilege level for sgdt/sidt/fxsave/fxrstor access Greg Kroah-Hartman
2018-06-14 14:05 ` [PATCH 4.4 22/24] Input: goodix - add new ACPI id for GPD Win 2 touch screen Greg Kroah-Hartman
2018-06-14 14:05 ` [PATCH 4.4 23/24] Input: elan_i2c - add ELAN0612 (Lenovo v330 14IKB) ACPI ID Greg Kroah-Hartman
2018-06-14 14:05 ` [PATCH 4.4 24/24] crypto: vmx - Remove overly verbose printk from AES init routines Greg Kroah-Hartman
2018-06-14 16:57 ` [PATCH 4.4 00/24] 4.4.138-stable review Nathan Chancellor
2018-06-14 18:47   ` Greg Kroah-Hartman
2018-06-14 22:43 ` Shuah Khan
2018-06-15  0:24 ` Naresh Kamboju
2018-06-15 15:18 ` Guenter Roeck
2018-06-19 14:28 ` Ben Hutchings
2018-06-28  4:09   ` Daniel Sangorrin
2018-07-05 16:08   ` Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180614132724.861855858@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=andy.shevchenko@gmail.com \
    --cc=bp@alien8.de \
    --cc=bp@suse.de \
    --cc=brgerst@gmail.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=dvlasenk@redhat.com \
    --cc=fenghua.yu@intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=mingo@kernel.org \
    --cc=oleg@redhat.com \
    --cc=peterz@infradead.org \
    --cc=quentin.casasnovas@oracle.com \
    --cc=stable@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=yu-cheng.yu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).