linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@alien8.de>
To: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@kernel.org>, X86 ML <x86@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>, Borislav Petkov <bp@suse.de>
Subject: [PATCH] x86, FPU: Fix FPU initialization
Date: Wed, 10 Apr 2013 23:29:50 +0200	[thread overview]
Message-ID: <20130410212950.GA6899@pd.tnic> (raw)
In-Reply-To: <20130410161122.GI6857@pd.tnic>

On Wed, Apr 10, 2013 at 06:11:22PM +0200, Borislav Petkov wrote:
> On Wed, Apr 10, 2013 at 08:35:43AM -0700, H. Peter Anvin wrote:
> > OK, this thread took off in another direction but you're still looking
> > at this, right?
> 
> Yep, and I think I have the rootcause, let's start (oops below for
> info).

Ok, here's a fix which boots fine here in qemu. Ingo, it would be cool
if you gave it a run to verify.

Thanks.

--
>From 2263430417dd8de1a5fef4b2c40127e681fdc1ab Mon Sep 17 00:00:00 2001
From: Borislav Petkov <bp@suse.de>
Date: Wed, 10 Apr 2013 21:37:03 +0200
Subject: [PATCH] x86, FPU: Fix FPU initialization

c70293d0e3fe ("x86: Get rid of ->hard_math and all the FPU asm
fu") converted the FPU detection code to C. Yours truly, in his
overzealousness, used static_cpu_has() too early, before alternatives
have run, leading to the checks in fpu_init() to fail and fpu_init() to
set CR0.EM.

This, in turn, lead to an early NULL ptr due to
a chicken-and-an-egg issue (full details here:
http://lkml.kernel.org/r/20130410161122.GI6857@pd.tnic).

Fix it back to the normal CPU feature checks.

Signed-off-by: Borislav Petkov <bp@suse.de>
---
 arch/x86/kernel/i387.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
index 3a6455304c8d..b0928898bf54 100644
--- a/arch/x86/kernel/i387.c
+++ b/arch/x86/kernel/i387.c
@@ -163,7 +163,7 @@ void __cpuinit fpu_init(void)
 	unsigned long cr4_mask = 0;
 
 #ifndef CONFIG_MATH_EMULATION
-	if (!static_cpu_has(X86_FEATURE_FPU)) {
+	if (!cpu_has_fpu) {
 		pr_emerg("No FPU found and no math emulation present\n");
 		pr_emerg("Giving up\n");
 		for (;;)
@@ -179,7 +179,7 @@ void __cpuinit fpu_init(void)
 
 	cr0 = read_cr0();
 	cr0 &= ~(X86_CR0_TS|X86_CR0_EM); /* clear TS and EM */
-	if (!static_cpu_has(X86_FEATURE_FPU))
+	if (!cpu_has_fpu)
 		cr0 |= X86_CR0_EM;
 	write_cr0(cr0);
 
-- 
1.8.2.135.g7b592fa


-- 
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--

  reply	other threads:[~2013-04-10 21:29 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-08 15:57 [PATCH 0/4] x86: FPU detection in C Borislav Petkov
2013-04-08 15:57 ` [PATCH 1/4] x86: Get rid of ->hard_math and all the FPU asm fu Borislav Petkov
2013-04-08 16:26   ` [tip:x86/cpu] " tip-bot for H. Peter Anvin
2013-06-12 20:48   ` [tip:x86/fpu] " tip-bot for H. Peter Anvin
2013-04-08 15:57 ` [PATCH 2/4] x86: Fold-in trivial check_config function Borislav Petkov
2013-04-08 16:27   ` [tip:x86/cpu] " tip-bot for Borislav Petkov
2013-04-16 13:51   ` tip-bot for Borislav Petkov
2013-04-08 15:57 ` [PATCH 3/4] x86, AMD: Correct {rd,wr}msr_amd_safe warnings Borislav Petkov
2013-04-08 16:28   ` [tip:x86/cpu] " tip-bot for Borislav Petkov
2013-04-16 13:53   ` tip-bot for Borislav Petkov
2013-04-08 15:57 ` [PATCH 4/4] x86, CPU, AMD: Drop useless label Borislav Petkov
2013-04-08 16:29   ` [tip:x86/cpu] " tip-bot for Borislav Petkov
2013-04-16 13:54   ` tip-bot for Borislav Petkov
2013-04-10 11:08 ` [PATCH 0/4] x86: FPU detection in C Ingo Molnar
2013-04-10 12:24   ` Borislav Petkov
2013-04-10 12:25     ` Ingo Molnar
2013-04-10 13:32       ` Borislav Petkov
2013-04-10 15:35         ` H. Peter Anvin
2013-04-10 16:11           ` Borislav Petkov
2013-04-10 21:29             ` Borislav Petkov [this message]
2013-04-11 12:09               ` [PATCH] x86, FPU: Fix FPU initialization Ingo Molnar
2013-04-11 14:23                 ` Borislav Petkov
2013-04-11 19:26                 ` H. Peter Anvin
2013-04-11 20:23                   ` Borislav Petkov
2013-04-12  5:32                     ` Ingo Molnar
2013-04-12  5:34                       ` H. Peter Anvin
2013-04-12  9:47                         ` Borislav Petkov
2013-04-12 11:26                           ` Borislav Petkov
2013-04-15 10:08                             ` Ingo Molnar
2013-04-15 10:17                               ` Borislav Petkov
2013-04-15 10:18                                 ` Ingo Molnar
2013-04-15 15:54                                   ` Borislav Petkov
2013-04-15 22:04                                     ` Borislav Petkov
2013-04-16  9:25                                       ` Ingo Molnar
2013-04-16  9:48                                         ` Borislav Petkov
2013-04-16 10:08                                           ` [GIT PULL] Rebase tip:x86/cpu Borislav Petkov
2013-04-16 11:35                                             ` Ingo Molnar
2013-04-16 11:33                                           ` [PATCH] x86, FPU: Fix FPU initialization Ingo Molnar
2013-04-29 14:04 [PATCH 0/3] FPU detection in C, second try Borislav Petkov
2013-04-29 14:04 ` [PATCH 1/3] x86: Get rid of ->hard_math and all the FPU asm fu Borislav Petkov
2013-04-29 14:04 ` [PATCH 2/3] x86: Sanity-check static_cpu_has usage Borislav Petkov
2013-04-29 15:38   ` H. Peter Anvin
2013-04-29 14:04 ` [PATCH 3/3] x86, FPU: Do not use static_cpu_has before alternatives Borislav Petkov
2013-04-29 15:42   ` H. Peter Anvin
2013-04-29 18:51     ` Borislav Petkov
2013-04-29 18:58       ` H. Peter Anvin

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=20130410212950.GA6899@pd.tnic \
    --to=bp@alien8.de \
    --cc=bp@suse.de \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=x86@kernel.org \
    /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).