linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: tip-bot for Borislav Petkov <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: oleg@redhat.com, fenghua.yu@intel.com, andy.shevchenko@gmail.com,
	quentin.casasnovas@oracle.com, peterz@infradead.org,
	brgerst@gmail.com, torvalds@linux-foundation.org, bp@suse.de,
	tglx@linutronix.de, hpa@zytor.com, akpm@linux-foundation.org,
	mingo@kernel.org, dvlasenk@redhat.com, luto@amacapital.net,
	linux-kernel@vger.kernel.org, pure.logic@nexus-software.ie,
	yu-cheng.yu@intel.com, bp@alien8.de, dave.hansen@linux.intel.com
Subject: [tip:x86/urgent] x86/fpu: Fix eager-FPU handling on legacy FPU machines
Date: Sat, 12 Mar 2016 07:16:25 -0800	[thread overview]
Message-ID: <tip-6e6867093de35141f0a76b66ac13f9f2e2c8e77a@git.kernel.org> (raw)
In-Reply-To: <20160311113206.GD4312@pd.tnic>

Commit-ID:  6e6867093de35141f0a76b66ac13f9f2e2c8e77a
Gitweb:     http://git.kernel.org/tip/6e6867093de35141f0a76b66ac13f9f2e2c8e77a
Author:     Borislav Petkov <bp@alien8.de>
AuthorDate: Fri, 11 Mar 2016 12:32:06 +0100
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Sat, 12 Mar 2016 16:13:55 +0100

x86/fpu: Fix eager-FPU handling on legacy FPU machines

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>
---
 arch/x86/kernel/fpu/core.c | 4 +++-
 arch/x86/kernel/fpu/init.c | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c
index d25097c..d5804ad 100644
--- 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_fpregs(void)
 {
 	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);
 }
 
 /*
diff --git a/arch/x86/kernel/fpu/init.c b/arch/x86/kernel/fpu/init.c
index 9ee7e30..bd08fb7 100644
--- a/arch/x86/kernel/fpu/init.c
+++ b/arch/x86/kernel/fpu/init.c
@@ -134,7 +134,7 @@ static void __init fpu__init_system_generic(void)
 	 * 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:[~2016-03-12 15:18 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-10 10:46 Got FPU related warning on Intel Quark during boot Andy Shevchenko
2016-03-10 11:19 ` Ingo Molnar
2016-03-10 12:48   ` Andy Shevchenko
2016-03-10 12:56     ` Borislav Petkov
2016-03-10 13:31       ` Andy Shevchenko
2016-03-10 14:59         ` Borislav Petkov
2016-03-10 15:22           ` Andy Shevchenko
2016-03-10 15:45             ` Bryan O'Donoghue
2016-03-10 16:49               ` Borislav Petkov
2016-03-10 17:15                 ` Bryan O'Donoghue
2016-03-10 19:06                   ` Borislav Petkov
2016-03-11  1:31               ` Andy Lutomirski
2016-03-11 10:50                 ` Bryan O'Donoghue
2016-03-11  1:39           ` Andy Lutomirski
2016-03-11  9:08             ` Ingo Molnar
2016-03-11  9:48               ` Borislav Petkov
2016-03-11 11:02                 ` Bryan O'Donoghue
2016-03-11 11:26                   ` Borislav Petkov
2016-03-11 11:32                     ` [PATCH] x86/FPU: Fix FPU handling on legacy FPU machines Borislav Petkov
2016-03-11 18:32                       ` Linus Torvalds
2016-03-11 22:03                         ` Borislav Petkov
2016-03-11 22:07                           ` Dave Hansen
2016-03-11 22:20                             ` Borislav Petkov
2016-03-12 17:21                               ` Andy Lutomirski
2016-03-12 17:47                                 ` Borislav Petkov
2016-03-12 12:04                           ` Bryan O'Donoghue
2016-03-12 12:27                             ` Borislav Petkov
2016-03-12 15:17                           ` Ingo Molnar
2016-03-22 22:03                           ` Maciej W. Rozycki
2016-03-12 15:08                         ` Ingo Molnar
2016-03-12 15:12                           ` Ingo Molnar
2016-03-12 15:16                       ` tip-bot for Borislav Petkov [this message]

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=tip-6e6867093de35141f0a76b66ac13f9f2e2c8e77a@git.kernel.org \
    --to=tipbot@zytor.com \
    --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=linux-tip-commits@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=mingo@kernel.org \
    --cc=oleg@redhat.com \
    --cc=peterz@infradead.org \
    --cc=pure.logic@nexus-software.ie \
    --cc=quentin.casasnovas@oracle.com \
    --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).