LKML Archive on lore.kernel.org
 help / Atom feed
* [PATCH v2 0/6] CPUID and FPU fixes
@ 2017-01-18 19:15 Andy Lutomirski
  2017-01-18 19:15 ` [PATCH v2 1/6] x86/cpu: Add X86_FEATURE_CPUID Andy Lutomirski
                   ` (5 more replies)
  0 siblings, 6 replies; 15+ messages in thread
From: Andy Lutomirski @ 2017-01-18 19:15 UTC (permalink / raw)
  To: X86 ML
  Cc: One Thousand Gnomes, Borislav Petkov, linux-kernel, Brian Gerst,
	Matthew Whitehead, Andy Lutomirski

Our CPUID-less FPU detection code was terminally broken and, as far
as I can tell, it's been broken for a long, long time.  This series
tries to improve the situation.

Changes from v1:
 - Whitespace fixes
 - Prettify the FPU probing code (Borislav)
 - Improve logging (Borislav)

Andy Lutomirski (5):
  x86/cpu: Factor out application of forced cpu caps
  x86/cpu: Re-apply forced caps every time cpu caps are re-read
  x86/fpu: Fix "x86/fpu: Legacy x87 FPU detected" message
  x86/fpu: Fix CPUID-less FPU detection
  x86/fpu: Fix the "Giving up, no FPU found" test

Borislav Petkov (1):
  x86/cpu: Add X86_FEATURE_CPUID

 arch/x86/include/asm/cpufeatures.h |  2 +-
 arch/x86/kernel/cpu/common.c       | 34 +++++++++++++++++++++++-----------
 arch/x86/kernel/fpu/init.c         | 31 +++++++++++++++++--------------
 arch/x86/kernel/fpu/xstate.c       |  8 +++++++-
 4 files changed, 48 insertions(+), 27 deletions(-)

-- 
2.9.3

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH v2 1/6] x86/cpu: Add X86_FEATURE_CPUID
  2017-01-18 19:15 [PATCH v2 0/6] CPUID and FPU fixes Andy Lutomirski
@ 2017-01-18 19:15 ` Andy Lutomirski
  2017-01-25 11:40   ` [tip:x86/fpu] " tip-bot for Borislav Petkov
  2017-01-18 19:15 ` [PATCH v2 2/6] x86/cpu: Factor out application of forced cpu caps Andy Lutomirski
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 15+ messages in thread
From: Andy Lutomirski @ 2017-01-18 19:15 UTC (permalink / raw)
  To: X86 ML
  Cc: One Thousand Gnomes, Borislav Petkov, linux-kernel, Brian Gerst,
	Matthew Whitehead, Borislav Petkov, Andy Lutomirski

From: Borislav Petkov <bp@suse.de>

Add a synthetic CPUID flag denoting whether the CPU sports the CPUID
instruction or not. This will come useful later when accomodating
CPUID-less CPUs.

Signed-off-by: Borislav Petkov <bp@suse.de>
[slightly prettified by Andy]
Signed-off-by: Andy Lutomirski <luto@kernel.org>
---
 arch/x86/include/asm/cpufeatures.h | 2 +-
 arch/x86/kernel/cpu/common.c       | 7 ++++---
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h
index 6ccbf1aaa7ce..5108c46e97c4 100644
--- a/arch/x86/include/asm/cpufeatures.h
+++ b/arch/x86/include/asm/cpufeatures.h
@@ -100,7 +100,7 @@
 #define X86_FEATURE_XTOPOLOGY	( 3*32+22) /* cpu topology enum extensions */
 #define X86_FEATURE_TSC_RELIABLE ( 3*32+23) /* TSC is known to be reliable */
 #define X86_FEATURE_NONSTOP_TSC	( 3*32+24) /* TSC does not stop in C states */
-/* free, was #define X86_FEATURE_CLFLUSH_MONITOR ( 3*32+25) * "" clflush reqd with monitor */
+#define X86_FEATURE_CPUID	( 3*32+25) /* CPU has CPUID instruction itself */
 #define X86_FEATURE_EXTD_APICID	( 3*32+26) /* has extended APICID (8 bits) */
 #define X86_FEATURE_AMD_DCM     ( 3*32+27) /* multi-node processor */
 #define X86_FEATURE_APERFMPERF	( 3*32+28) /* APERFMPERF */
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 1f6b50a449ab..8f06f7ea4262 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -800,14 +800,12 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)
 	memset(&c->x86_capability, 0, sizeof c->x86_capability);
 	c->extended_cpuid_level = 0;
 
-	if (!have_cpuid_p())
-		identify_cpu_without_cpuid(c);
-
 	/* cyrix could have cpuid enabled via c_identify()*/
 	if (have_cpuid_p()) {
 		cpu_detect(c);
 		get_cpu_vendor(c);
 		get_cpu_cap(c);
+		setup_force_cpu_cap(X86_FEATURE_CPUID);
 
 		if (this_cpu->c_early_init)
 			this_cpu->c_early_init(c);
@@ -817,6 +815,9 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)
 
 		if (this_cpu->c_bsp_init)
 			this_cpu->c_bsp_init(c);
+	} else {
+		identify_cpu_without_cpuid(c);
+		setup_clear_cpu_cap(X86_FEATURE_CPUID);
 	}
 
 	setup_force_cpu_cap(X86_FEATURE_ALWAYS);
-- 
2.9.3

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH v2 2/6] x86/cpu: Factor out application of forced cpu caps
  2017-01-18 19:15 [PATCH v2 0/6] CPUID and FPU fixes Andy Lutomirski
  2017-01-18 19:15 ` [PATCH v2 1/6] x86/cpu: Add X86_FEATURE_CPUID Andy Lutomirski
@ 2017-01-18 19:15 ` Andy Lutomirski
  2017-01-25 11:40   ` [tip:x86/fpu] x86/cpu: Factor out application of forced CPU caps tip-bot for Andy Lutomirski
  2017-01-18 19:15 ` [PATCH v2 3/6] x86/cpu: Re-apply forced caps every time cpu caps are re-read Andy Lutomirski
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 15+ messages in thread
From: Andy Lutomirski @ 2017-01-18 19:15 UTC (permalink / raw)
  To: X86 ML
  Cc: One Thousand Gnomes, Borislav Petkov, linux-kernel, Brian Gerst,
	Matthew Whitehead, Andy Lutomirski

There are multiple call sites that apply forced CPU caps.  Factor
them into a helper.

Signed-off-by: Andy Lutomirski <luto@kernel.org>
---
 arch/x86/kernel/cpu/common.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 8f06f7ea4262..337eac606f39 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -655,6 +655,16 @@ void cpu_detect(struct cpuinfo_x86 *c)
 	}
 }
 
+static void apply_forced_caps(struct cpuinfo_x86 *c)
+{
+	int i;
+
+	for (i = 0; i < NCAPINTS; i++) {
+		c->x86_capability[i] &= ~cpu_caps_cleared[i];
+		c->x86_capability[i] |= cpu_caps_set[i];
+	}
+}
+
 void get_cpu_cap(struct cpuinfo_x86 *c)
 {
 	u32 eax, ebx, ecx, edx;
@@ -1034,10 +1044,7 @@ static void identify_cpu(struct cpuinfo_x86 *c)
 		this_cpu->c_identify(c);
 
 	/* Clear/Set all flags overridden by options, after probe */
-	for (i = 0; i < NCAPINTS; i++) {
-		c->x86_capability[i] &= ~cpu_caps_cleared[i];
-		c->x86_capability[i] |= cpu_caps_set[i];
-	}
+	apply_forced_caps(c);
 
 #ifdef CONFIG_X86_64
 	c->apicid = apic->phys_pkg_id(c->initial_apicid, 0);
@@ -1096,10 +1103,7 @@ static void identify_cpu(struct cpuinfo_x86 *c)
 	 * Clear/Set all flags overridden by options, need do it
 	 * before following smp all cpus cap AND.
 	 */
-	for (i = 0; i < NCAPINTS; i++) {
-		c->x86_capability[i] &= ~cpu_caps_cleared[i];
-		c->x86_capability[i] |= cpu_caps_set[i];
-	}
+	apply_forced_caps(c);
 
 	/*
 	 * On SMP, boot_cpu_data holds the common feature set between
-- 
2.9.3

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH v2 3/6] x86/cpu: Re-apply forced caps every time cpu caps are re-read
  2017-01-18 19:15 [PATCH v2 0/6] CPUID and FPU fixes Andy Lutomirski
  2017-01-18 19:15 ` [PATCH v2 1/6] x86/cpu: Add X86_FEATURE_CPUID Andy Lutomirski
  2017-01-18 19:15 ` [PATCH v2 2/6] x86/cpu: Factor out application of forced cpu caps Andy Lutomirski
@ 2017-01-18 19:15 ` Andy Lutomirski
  2017-01-19 11:23   ` Borislav Petkov
  2017-01-25 11:41   ` [tip:x86/fpu] x86/cpu: Re-apply forced caps every time CPU " tip-bot for Andy Lutomirski
  2017-01-18 19:15 ` [PATCH v2 4/6] x86/fpu: Fix "x86/fpu: Legacy x87 FPU detected" message Andy Lutomirski
                   ` (2 subsequent siblings)
  5 siblings, 2 replies; 15+ messages in thread
From: Andy Lutomirski @ 2017-01-18 19:15 UTC (permalink / raw)
  To: X86 ML
  Cc: One Thousand Gnomes, Borislav Petkov, linux-kernel, Brian Gerst,
	Matthew Whitehead, Andy Lutomirski

Calling get_cpu_cap() will reset a bunch of CPU features.  This will
cause the system to lose track of force-set and force-cleared
featueres in the words that are reset until the end of CPU
initialization.  This can cause X86_FEATURE_FPU, for example, to
change back and forth during boot and potentially confuse CPU setup.

To minimize the chance of confusion, re-apply forced caps every time
get_cpu_cap() is called.

Signed-off-by: Andy Lutomirski <luto@kernel.org>
---
 arch/x86/kernel/cpu/common.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 337eac606f39..8efe6e77f91d 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -757,6 +757,13 @@ void get_cpu_cap(struct cpuinfo_x86 *c)
 		c->x86_capability[CPUID_8000_000A_EDX] = cpuid_edx(0x8000000a);
 
 	init_scattered_cpuid_features(c);
+
+	/*
+	 * Clear/Set all flags overridden by options, after probe.
+	 * This needs to happen each time we re-probe, which may happen
+	 * several times during CPU initialization.
+	 */
+	apply_forced_caps(c);
 }
 
 static void identify_cpu_without_cpuid(struct cpuinfo_x86 *c)
-- 
2.9.3

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH v2 4/6] x86/fpu: Fix "x86/fpu: Legacy x87 FPU detected" message
  2017-01-18 19:15 [PATCH v2 0/6] CPUID and FPU fixes Andy Lutomirski
                   ` (2 preceding siblings ...)
  2017-01-18 19:15 ` [PATCH v2 3/6] x86/cpu: Re-apply forced caps every time cpu caps are re-read Andy Lutomirski
@ 2017-01-18 19:15 ` Andy Lutomirski
  2017-01-25 11:42   ` [tip:x86/fpu] " tip-bot for Andy Lutomirski
  2017-01-18 19:15 ` [PATCH v2 5/6] x86/fpu: Fix CPUID-less FPU detection Andy Lutomirski
  2017-01-18 19:15 ` [PATCH v2 6/6] x86/fpu: Fix the "Giving up, no FPU found" test Andy Lutomirski
  5 siblings, 1 reply; 15+ messages in thread
From: Andy Lutomirski @ 2017-01-18 19:15 UTC (permalink / raw)
  To: X86 ML
  Cc: One Thousand Gnomes, Borislav Petkov, linux-kernel, Brian Gerst,
	Matthew Whitehead, Andy Lutomirski

That message isn't at all clear -- what does "Legacy x87" even
mean?

Clarify it.  If there's no FPU, say "x86/fpu: No FPU detected".  If
there's an FPU that doesn't have XSAVE, say "x86/fpu: x87 FPU will use
FSAVE|FXSAVE".

Signed-off-by: Andy Lutomirski <luto@kernel.org>
---
 arch/x86/kernel/fpu/xstate.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c
index 1d7770447b3e..1691311e5b23 100644
--- a/arch/x86/kernel/fpu/xstate.c
+++ b/arch/x86/kernel/fpu/xstate.c
@@ -705,8 +705,14 @@ void __init fpu__init_system_xstate(void)
 	WARN_ON_FPU(!on_boot_cpu);
 	on_boot_cpu = 0;
 
+	if (!boot_cpu_has(X86_FEATURE_FPU)) {
+		pr_info("x86/fpu: No FPU detected.\n");
+		return;
+	}
+
 	if (!boot_cpu_has(X86_FEATURE_XSAVE)) {
-		pr_info("x86/fpu: Legacy x87 FPU detected.\n");
+		pr_info("x86/fpu: x87 FPU will use %s.\n",
+			boot_cpu_has(X86_FEATURE_FXSR) ? "FXSAVE" : "FSAVE");
 		return;
 	}
 
-- 
2.9.3

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH v2 5/6] x86/fpu: Fix CPUID-less FPU detection
  2017-01-18 19:15 [PATCH v2 0/6] CPUID and FPU fixes Andy Lutomirski
                   ` (3 preceding siblings ...)
  2017-01-18 19:15 ` [PATCH v2 4/6] x86/fpu: Fix "x86/fpu: Legacy x87 FPU detected" message Andy Lutomirski
@ 2017-01-18 19:15 ` Andy Lutomirski
  2017-01-19 11:23   ` Borislav Petkov
  2017-01-25 11:42   ` [tip:x86/fpu] " tip-bot for Andy Lutomirski
  2017-01-18 19:15 ` [PATCH v2 6/6] x86/fpu: Fix the "Giving up, no FPU found" test Andy Lutomirski
  5 siblings, 2 replies; 15+ messages in thread
From: Andy Lutomirski @ 2017-01-18 19:15 UTC (permalink / raw)
  To: X86 ML
  Cc: One Thousand Gnomes, Borislav Petkov, linux-kernel, Brian Gerst,
	Matthew Whitehead, Andy Lutomirski

The old code didn't work at all because it adjusted the current caps
instead of the forced caps.  Anything it did would be undone later
during cpu identification.  Fix that and, while we're at it, improve
the logging and don't bother running it if CPUID is available.

Reported-by: Matthew Whitehead <tedheadster@gmail.com>
Signed-off-by: Andy Lutomirski <luto@kernel.org>
---
 arch/x86/kernel/fpu/init.c | 29 ++++++++++++++++-------------
 1 file changed, 16 insertions(+), 13 deletions(-)

diff --git a/arch/x86/kernel/fpu/init.c b/arch/x86/kernel/fpu/init.c
index 60dece392b3a..23601db7b90f 100644
--- a/arch/x86/kernel/fpu/init.c
+++ b/arch/x86/kernel/fpu/init.c
@@ -48,13 +48,7 @@ void fpu__init_cpu(void)
 	fpu__init_cpu_xstate();
 }
 
-/*
- * The earliest FPU detection code.
- *
- * Set the X86_FEATURE_FPU CPU-capability bit based on
- * trying to execute an actual sequence of FPU instructions:
- */
-static void fpu__init_system_early_generic(struct cpuinfo_x86 *c)
+static bool fpu__probe_without_cpuid(void)
 {
 	unsigned long cr0;
 	u16 fsw, fcw;
@@ -65,14 +59,23 @@ static void fpu__init_system_early_generic(struct cpuinfo_x86 *c)
 	cr0 &= ~(X86_CR0_TS | X86_CR0_EM);
 	write_cr0(cr0);
 
-	if (!test_bit(X86_FEATURE_FPU, (unsigned long *)cpu_caps_cleared)) {
-		asm volatile("fninit ; fnstsw %0 ; fnstcw %1"
-			     : "+m" (fsw), "+m" (fcw));
+	asm volatile("fninit ; fnstsw %0 ; fnstcw %1"
+		     : "+m" (fsw), "+m" (fcw));
+
+	pr_info("x86/fpu: Probing for FPU: FSW=0x%04hx FCW=0x%04hx\n",
+		fsw, fcw);
 
-		if (fsw == 0 && (fcw & 0x103f) == 0x003f)
-			set_cpu_cap(c, X86_FEATURE_FPU);
+	return fsw == 0 && (fcw & 0x103f) == 0x003f;
+}
+
+static void fpu__init_system_early_generic(struct cpuinfo_x86 *c)
+{
+	if (!boot_cpu_has(X86_FEATURE_CPUID) &&
+	    !test_bit(X86_FEATURE_FPU, (unsigned long *)cpu_caps_cleared)) {
+		if (fpu__probe_without_cpuid())
+			setup_force_cpu_cap(X86_FEATURE_FPU);
 		else
-			clear_cpu_cap(c, X86_FEATURE_FPU);
+			setup_clear_cpu_cap(X86_FEATURE_FPU);
 	}
 
 #ifndef CONFIG_MATH_EMULATION
-- 
2.9.3

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH v2 6/6] x86/fpu: Fix the "Giving up, no FPU found" test
  2017-01-18 19:15 [PATCH v2 0/6] CPUID and FPU fixes Andy Lutomirski
                   ` (4 preceding siblings ...)
  2017-01-18 19:15 ` [PATCH v2 5/6] x86/fpu: Fix CPUID-less FPU detection Andy Lutomirski
@ 2017-01-18 19:15 ` Andy Lutomirski
  2017-01-25 11:43   ` [tip:x86/fpu] " tip-bot for Andy Lutomirski
  5 siblings, 1 reply; 15+ messages in thread
From: Andy Lutomirski @ 2017-01-18 19:15 UTC (permalink / raw)
  To: X86 ML
  Cc: One Thousand Gnomes, Borislav Petkov, linux-kernel, Brian Gerst,
	Matthew Whitehead, Andy Lutomirski

We would never print "Giving up, no FPU found" because
X86_FEATURE_FPU was in REQUIRED_MASK on non-FPU-emulating builds, so
the boot_cpu_has() test didn't do anything.

Signed-off-by: Andy Lutomirski <luto@kernel.org>
---
 arch/x86/kernel/fpu/init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/fpu/init.c b/arch/x86/kernel/fpu/init.c
index 23601db7b90f..08300d2b9c0f 100644
--- a/arch/x86/kernel/fpu/init.c
+++ b/arch/x86/kernel/fpu/init.c
@@ -79,7 +79,7 @@ static void fpu__init_system_early_generic(struct cpuinfo_x86 *c)
 	}
 
 #ifndef CONFIG_MATH_EMULATION
-	if (!boot_cpu_has(X86_FEATURE_FPU)) {
+	if (!test_cpu_cap(&boot_cpu_data, X86_FEATURE_FPU)) {
 		pr_emerg("x86/fpu: Giving up, no FPU found and no math emulation present\n");
 		for (;;)
 			asm volatile("hlt");
-- 
2.9.3

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v2 3/6] x86/cpu: Re-apply forced caps every time cpu caps are re-read
  2017-01-18 19:15 ` [PATCH v2 3/6] x86/cpu: Re-apply forced caps every time cpu caps are re-read Andy Lutomirski
@ 2017-01-19 11:23   ` Borislav Petkov
  2017-01-25 11:41   ` [tip:x86/fpu] x86/cpu: Re-apply forced caps every time CPU " tip-bot for Andy Lutomirski
  1 sibling, 0 replies; 15+ messages in thread
From: Borislav Petkov @ 2017-01-19 11:23 UTC (permalink / raw)
  To: Andy Lutomirski
  Cc: X86 ML, One Thousand Gnomes, linux-kernel, Brian Gerst,
	Matthew Whitehead

On Wed, Jan 18, 2017 at 11:15:39AM -0800, Andy Lutomirski wrote:
> Calling get_cpu_cap() will reset a bunch of CPU features.  This will
> cause the system to lose track of force-set and force-cleared
> featueres in the words that are reset until the end of CPU

features

> initialization.  This can cause X86_FEATURE_FPU, for example, to
> change back and forth during boot and potentially confuse CPU setup.
> 
> To minimize the chance of confusion, re-apply forced caps every time
> get_cpu_cap() is called.
> 
> Signed-off-by: Andy Lutomirski <luto@kernel.org>

-- 
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v2 5/6] x86/fpu: Fix CPUID-less FPU detection
  2017-01-18 19:15 ` [PATCH v2 5/6] x86/fpu: Fix CPUID-less FPU detection Andy Lutomirski
@ 2017-01-19 11:23   ` Borislav Petkov
  2017-01-25 11:42   ` [tip:x86/fpu] " tip-bot for Andy Lutomirski
  1 sibling, 0 replies; 15+ messages in thread
From: Borislav Petkov @ 2017-01-19 11:23 UTC (permalink / raw)
  To: Andy Lutomirski
  Cc: X86 ML, One Thousand Gnomes, linux-kernel, Brian Gerst,
	Matthew Whitehead

On Wed, Jan 18, 2017 at 11:15:41AM -0800, Andy Lutomirski wrote:
> The old code didn't work at all because it adjusted the current caps
> instead of the forced caps.  Anything it did would be undone later
> during cpu identification.  Fix that and, while we're at it, improve

	CPU

> the logging and don't bother running it if CPUID is available.
> 
> Reported-by: Matthew Whitehead <tedheadster@gmail.com>
> Signed-off-by: Andy Lutomirski <luto@kernel.org>

Just two minor typos which can be fixed en-route. Other than that, for
all 6:

Reviewed-by: Borislav Petkov <bp@suse.de>

-- 
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [tip:x86/fpu] x86/cpu: Add X86_FEATURE_CPUID
  2017-01-18 19:15 ` [PATCH v2 1/6] x86/cpu: Add X86_FEATURE_CPUID Andy Lutomirski
@ 2017-01-25 11:40   ` " tip-bot for Borislav Petkov
  0 siblings, 0 replies; 15+ messages in thread
From: tip-bot for Borislav Petkov @ 2017-01-25 11:40 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: mingo, tedheadster, oleg, tglx, peterz, gnomes, linux-kernel,
	riel, torvalds, hpa, fenghua.yu, brgerst, bp, yu-cheng.yu,
	dave.hansen, bp, luto

Commit-ID:  78d1b296843a719935277b0d24d1358416ed0204
Gitweb:     http://git.kernel.org/tip/78d1b296843a719935277b0d24d1358416ed0204
Author:     Borislav Petkov <bp@suse.de>
AuthorDate: Wed, 18 Jan 2017 11:15:37 -0800
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 25 Jan 2017 10:12:39 +0100

x86/cpu: Add X86_FEATURE_CPUID

Add a synthetic CPUID flag denoting whether the CPU sports the CPUID
instruction or not. This will come useful later when accomodating
CPUID-less CPUs.

Signed-off-by: Borislav Petkov <bp@suse.de>
[ Slightly prettified. ]
Signed-off-by: Andy Lutomirski <luto@kernel.org>
Reviewed-by: Borislav Petkov <bp@suse.de>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
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: Matthew Whitehead <tedheadster@gmail.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Yu-cheng Yu <yu-cheng.yu@intel.com>
Link: http://lkml.kernel.org/r/dcb355adae3ab812c79397056a61c212f1a0c7cc.1484705016.git.luto@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/include/asm/cpufeatures.h | 2 +-
 arch/x86/kernel/cpu/common.c       | 7 ++++---
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h
index eafee31..a0f4ff2 100644
--- a/arch/x86/include/asm/cpufeatures.h
+++ b/arch/x86/include/asm/cpufeatures.h
@@ -100,7 +100,7 @@
 #define X86_FEATURE_XTOPOLOGY	( 3*32+22) /* cpu topology enum extensions */
 #define X86_FEATURE_TSC_RELIABLE ( 3*32+23) /* TSC is known to be reliable */
 #define X86_FEATURE_NONSTOP_TSC	( 3*32+24) /* TSC does not stop in C states */
-/* free, was #define X86_FEATURE_CLFLUSH_MONITOR ( 3*32+25) * "" clflush reqd with monitor */
+#define X86_FEATURE_CPUID	( 3*32+25) /* CPU has CPUID instruction itself */
 #define X86_FEATURE_EXTD_APICID	( 3*32+26) /* has extended APICID (8 bits) */
 #define X86_FEATURE_AMD_DCM     ( 3*32+27) /* multi-node processor */
 #define X86_FEATURE_APERFMPERF	( 3*32+28) /* APERFMPERF */
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 9bab7a8..c3328d0 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -801,14 +801,12 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)
 	memset(&c->x86_capability, 0, sizeof c->x86_capability);
 	c->extended_cpuid_level = 0;
 
-	if (!have_cpuid_p())
-		identify_cpu_without_cpuid(c);
-
 	/* cyrix could have cpuid enabled via c_identify()*/
 	if (have_cpuid_p()) {
 		cpu_detect(c);
 		get_cpu_vendor(c);
 		get_cpu_cap(c);
+		setup_force_cpu_cap(X86_FEATURE_CPUID);
 
 		if (this_cpu->c_early_init)
 			this_cpu->c_early_init(c);
@@ -818,6 +816,9 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)
 
 		if (this_cpu->c_bsp_init)
 			this_cpu->c_bsp_init(c);
+	} else {
+		identify_cpu_without_cpuid(c);
+		setup_clear_cpu_cap(X86_FEATURE_CPUID);
 	}
 
 	setup_force_cpu_cap(X86_FEATURE_ALWAYS);

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [tip:x86/fpu] x86/cpu: Factor out application of forced CPU caps
  2017-01-18 19:15 ` [PATCH v2 2/6] x86/cpu: Factor out application of forced cpu caps Andy Lutomirski
@ 2017-01-25 11:40   ` tip-bot for Andy Lutomirski
  0 siblings, 0 replies; 15+ messages in thread
From: tip-bot for Andy Lutomirski @ 2017-01-25 11:40 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: bp, mingo, luto, fenghua.yu, yu-cheng.yu, brgerst, bp,
	linux-kernel, riel, oleg, hpa, peterz, tedheadster, torvalds,
	dave.hansen, gnomes, tglx

Commit-ID:  8bf1ebca215c262e48c15a4a15f175991776f57f
Gitweb:     http://git.kernel.org/tip/8bf1ebca215c262e48c15a4a15f175991776f57f
Author:     Andy Lutomirski <luto@kernel.org>
AuthorDate: Wed, 18 Jan 2017 11:15:38 -0800
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 25 Jan 2017 10:12:40 +0100

x86/cpu: Factor out application of forced CPU caps

There are multiple call sites that apply forced CPU caps.  Factor
them into a helper.

Signed-off-by: Andy Lutomirski <luto@kernel.org>
Reviewed-by: Borislav Petkov <bp@suse.de>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
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: Matthew Whitehead <tedheadster@gmail.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Yu-cheng Yu <yu-cheng.yu@intel.com>
Link: http://lkml.kernel.org/r/623ff7555488122143e4417de09b18be2085ad06.1484705016.git.luto@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/kernel/cpu/common.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index c3328d0..2ea16e0 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -655,6 +655,16 @@ void cpu_detect(struct cpuinfo_x86 *c)
 	}
 }
 
+static void apply_forced_caps(struct cpuinfo_x86 *c)
+{
+	int i;
+
+	for (i = 0; i < NCAPINTS; i++) {
+		c->x86_capability[i] &= ~cpu_caps_cleared[i];
+		c->x86_capability[i] |= cpu_caps_set[i];
+	}
+}
+
 void get_cpu_cap(struct cpuinfo_x86 *c)
 {
 	u32 eax, ebx, ecx, edx;
@@ -1035,10 +1045,7 @@ static void identify_cpu(struct cpuinfo_x86 *c)
 		this_cpu->c_identify(c);
 
 	/* Clear/Set all flags overridden by options, after probe */
-	for (i = 0; i < NCAPINTS; i++) {
-		c->x86_capability[i] &= ~cpu_caps_cleared[i];
-		c->x86_capability[i] |= cpu_caps_set[i];
-	}
+	apply_forced_caps(c);
 
 #ifdef CONFIG_X86_64
 	c->apicid = apic->phys_pkg_id(c->initial_apicid, 0);
@@ -1097,10 +1104,7 @@ static void identify_cpu(struct cpuinfo_x86 *c)
 	 * Clear/Set all flags overridden by options, need do it
 	 * before following smp all cpus cap AND.
 	 */
-	for (i = 0; i < NCAPINTS; i++) {
-		c->x86_capability[i] &= ~cpu_caps_cleared[i];
-		c->x86_capability[i] |= cpu_caps_set[i];
-	}
+	apply_forced_caps(c);
 
 	/*
 	 * On SMP, boot_cpu_data holds the common feature set between

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [tip:x86/fpu] x86/cpu: Re-apply forced caps every time CPU caps are re-read
  2017-01-18 19:15 ` [PATCH v2 3/6] x86/cpu: Re-apply forced caps every time cpu caps are re-read Andy Lutomirski
  2017-01-19 11:23   ` Borislav Petkov
@ 2017-01-25 11:41   ` " tip-bot for Andy Lutomirski
  1 sibling, 0 replies; 15+ messages in thread
From: tip-bot for Andy Lutomirski @ 2017-01-25 11:41 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: tglx, luto, gnomes, bp, fenghua.yu, hpa, dave.hansen, torvalds,
	oleg, linux-kernel, tedheadster, mingo, bp, yu-cheng.yu, peterz,
	brgerst, riel

Commit-ID:  60d3450167433f2d099ce2869dc52dd9e7dc9b29
Gitweb:     http://git.kernel.org/tip/60d3450167433f2d099ce2869dc52dd9e7dc9b29
Author:     Andy Lutomirski <luto@kernel.org>
AuthorDate: Wed, 18 Jan 2017 11:15:39 -0800
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 25 Jan 2017 10:12:41 +0100

x86/cpu: Re-apply forced caps every time CPU caps are re-read

Calling get_cpu_cap() will reset a bunch of CPU features.  This will
cause the system to lose track of force-set and force-cleared
features in the words that are reset until the end of CPU
initialization.  This can cause X86_FEATURE_FPU, for example, to
change back and forth during boot and potentially confuse CPU setup.

To minimize the chance of confusion, re-apply forced caps every time
get_cpu_cap() is called.

Signed-off-by: Andy Lutomirski <luto@kernel.org>
Reviewed-by: Borislav Petkov <bp@suse.de>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
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: Matthew Whitehead <tedheadster@gmail.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Yu-cheng Yu <yu-cheng.yu@intel.com>
Link: http://lkml.kernel.org/r/c817eb373d2c67c2c81413a70fc9b845fa34a37e.1484705016.git.luto@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/kernel/cpu/common.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 2ea16e0..d09b5ee 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -758,6 +758,13 @@ void get_cpu_cap(struct cpuinfo_x86 *c)
 		c->x86_capability[CPUID_8000_000A_EDX] = cpuid_edx(0x8000000a);
 
 	init_scattered_cpuid_features(c);
+
+	/*
+	 * Clear/Set all flags overridden by options, after probe.
+	 * This needs to happen each time we re-probe, which may happen
+	 * several times during CPU initialization.
+	 */
+	apply_forced_caps(c);
 }
 
 static void identify_cpu_without_cpuid(struct cpuinfo_x86 *c)

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [tip:x86/fpu] x86/fpu: Fix "x86/fpu: Legacy x87 FPU detected" message
  2017-01-18 19:15 ` [PATCH v2 4/6] x86/fpu: Fix "x86/fpu: Legacy x87 FPU detected" message Andy Lutomirski
@ 2017-01-25 11:42   ` " tip-bot for Andy Lutomirski
  0 siblings, 0 replies; 15+ messages in thread
From: tip-bot for Andy Lutomirski @ 2017-01-25 11:42 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: tedheadster, riel, gnomes, fenghua.yu, mingo, luto, torvalds,
	hpa, yu-cheng.yu, peterz, bp, bp, brgerst, oleg, linux-kernel,
	dave.hansen, tglx

Commit-ID:  9170fb409437b246078bcad3f1481d32dfe2ca28
Gitweb:     http://git.kernel.org/tip/9170fb409437b246078bcad3f1481d32dfe2ca28
Author:     Andy Lutomirski <luto@kernel.org>
AuthorDate: Wed, 18 Jan 2017 11:15:40 -0800
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 25 Jan 2017 10:12:42 +0100

x86/fpu: Fix "x86/fpu: Legacy x87 FPU detected" message

That message isn't at all clear -- what does "Legacy x87" even mean?

Clarify it.  If there's no FPU, say:

  x86/fpu: No FPU detected

If there's an FPU that doesn't have XSAVE, say:

  x86/fpu: x87 FPU will use FSAVE|FXSAVE

Signed-off-by: Andy Lutomirski <luto@kernel.org>
Reviewed-by: Borislav Petkov <bp@suse.de>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
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: Matthew Whitehead <tedheadster@gmail.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Yu-cheng Yu <yu-cheng.yu@intel.com>
Link: http://lkml.kernel.org/r/bb839385e18e27bca23fe8666dfdad8170473045.1484705016.git.luto@kernel.org
[ Small tweaks to the messages. ]
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/kernel/fpu/xstate.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c
index 1d77704..96002f1 100644
--- a/arch/x86/kernel/fpu/xstate.c
+++ b/arch/x86/kernel/fpu/xstate.c
@@ -705,8 +705,14 @@ void __init fpu__init_system_xstate(void)
 	WARN_ON_FPU(!on_boot_cpu);
 	on_boot_cpu = 0;
 
+	if (!boot_cpu_has(X86_FEATURE_FPU)) {
+		pr_info("x86/fpu: No FPU detected\n");
+		return;
+	}
+
 	if (!boot_cpu_has(X86_FEATURE_XSAVE)) {
-		pr_info("x86/fpu: Legacy x87 FPU detected.\n");
+		pr_info("x86/fpu: x87 FPU will use %s\n",
+			boot_cpu_has(X86_FEATURE_FXSR) ? "FXSAVE" : "FSAVE");
 		return;
 	}
 

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [tip:x86/fpu] x86/fpu: Fix CPUID-less FPU detection
  2017-01-18 19:15 ` [PATCH v2 5/6] x86/fpu: Fix CPUID-less FPU detection Andy Lutomirski
  2017-01-19 11:23   ` Borislav Petkov
@ 2017-01-25 11:42   ` " tip-bot for Andy Lutomirski
  1 sibling, 0 replies; 15+ messages in thread
From: tip-bot for Andy Lutomirski @ 2017-01-25 11:42 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: peterz, yu-cheng.yu, torvalds, tedheadster, gnomes, brgerst, bp,
	tglx, riel, oleg, dave.hansen, luto, bp, fenghua.yu, hpa, mingo,
	linux-kernel

Commit-ID:  37ac78b67b3384d1ced5424d5a13ee146041bda3
Gitweb:     http://git.kernel.org/tip/37ac78b67b3384d1ced5424d5a13ee146041bda3
Author:     Andy Lutomirski <luto@kernel.org>
AuthorDate: Wed, 18 Jan 2017 11:15:41 -0800
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 25 Jan 2017 10:12:43 +0100

x86/fpu: Fix CPUID-less FPU detection

The old code didn't work at all because it adjusted the current caps
instead of the forced caps.  Anything it did would be undone later
during CPU identification.  Fix that and, while we're at it, improve
the logging and don't bother running it if CPUID is available.

Reported-by: Matthew Whitehead <tedheadster@gmail.com>
Signed-off-by: Andy Lutomirski <luto@kernel.org>
Reviewed-by: Borislav Petkov <bp@suse.de>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
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: One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Yu-cheng Yu <yu-cheng.yu@intel.com>
Link: http://lkml.kernel.org/r/f1134e30cafa73c4e2e68119e9741793622cfd15.1484705016.git.luto@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/kernel/fpu/init.c | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/arch/x86/kernel/fpu/init.c b/arch/x86/kernel/fpu/init.c
index 60dece3..8b526c5 100644
--- a/arch/x86/kernel/fpu/init.c
+++ b/arch/x86/kernel/fpu/init.c
@@ -48,13 +48,7 @@ void fpu__init_cpu(void)
 	fpu__init_cpu_xstate();
 }
 
-/*
- * The earliest FPU detection code.
- *
- * Set the X86_FEATURE_FPU CPU-capability bit based on
- * trying to execute an actual sequence of FPU instructions:
- */
-static void fpu__init_system_early_generic(struct cpuinfo_x86 *c)
+static bool fpu__probe_without_cpuid(void)
 {
 	unsigned long cr0;
 	u16 fsw, fcw;
@@ -65,14 +59,21 @@ static void fpu__init_system_early_generic(struct cpuinfo_x86 *c)
 	cr0 &= ~(X86_CR0_TS | X86_CR0_EM);
 	write_cr0(cr0);
 
-	if (!test_bit(X86_FEATURE_FPU, (unsigned long *)cpu_caps_cleared)) {
-		asm volatile("fninit ; fnstsw %0 ; fnstcw %1"
-			     : "+m" (fsw), "+m" (fcw));
+	asm volatile("fninit ; fnstsw %0 ; fnstcw %1" : "+m" (fsw), "+m" (fcw));
+
+	pr_info("x86/fpu: Probing for FPU: FSW=0x%04hx FCW=0x%04hx\n", fsw, fcw);
 
-		if (fsw == 0 && (fcw & 0x103f) == 0x003f)
-			set_cpu_cap(c, X86_FEATURE_FPU);
+	return fsw == 0 && (fcw & 0x103f) == 0x003f;
+}
+
+static void fpu__init_system_early_generic(struct cpuinfo_x86 *c)
+{
+	if (!boot_cpu_has(X86_FEATURE_CPUID) &&
+	    !test_bit(X86_FEATURE_FPU, (unsigned long *)cpu_caps_cleared)) {
+		if (fpu__probe_without_cpuid())
+			setup_force_cpu_cap(X86_FEATURE_FPU);
 		else
-			clear_cpu_cap(c, X86_FEATURE_FPU);
+			setup_clear_cpu_cap(X86_FEATURE_FPU);
 	}
 
 #ifndef CONFIG_MATH_EMULATION

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [tip:x86/fpu] x86/fpu: Fix the "Giving up, no FPU found" test
  2017-01-18 19:15 ` [PATCH v2 6/6] x86/fpu: Fix the "Giving up, no FPU found" test Andy Lutomirski
@ 2017-01-25 11:43   ` " tip-bot for Andy Lutomirski
  0 siblings, 0 replies; 15+ messages in thread
From: tip-bot for Andy Lutomirski @ 2017-01-25 11:43 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: hpa, yu-cheng.yu, gnomes, dave.hansen, linux-kernel, bp, bp,
	mingo, torvalds, tglx, oleg, riel, peterz, tedheadster, luto,
	fenghua.yu, brgerst

Commit-ID:  9729017f844431ab2800519297d8d1b0ecbc420d
Gitweb:     http://git.kernel.org/tip/9729017f844431ab2800519297d8d1b0ecbc420d
Author:     Andy Lutomirski <luto@kernel.org>
AuthorDate: Wed, 18 Jan 2017 11:15:42 -0800
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 25 Jan 2017 10:12:44 +0100

x86/fpu: Fix the "Giving up, no FPU found" test

We would never print "Giving up, no FPU found" because
X86_FEATURE_FPU was in REQUIRED_MASK on non-FPU-emulating builds, so
the boot_cpu_has() test didn't do anything.

Signed-off-by: Andy Lutomirski <luto@kernel.org>
Reviewed-by: Borislav Petkov <bp@suse.de>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
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: Matthew Whitehead <tedheadster@gmail.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Yu-cheng Yu <yu-cheng.yu@intel.com>
Link: http://lkml.kernel.org/r/1499077fa76f0f84b8ea28e37d3fa70beca4e310.1484705016.git.luto@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/kernel/fpu/init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/fpu/init.c b/arch/x86/kernel/fpu/init.c
index 8b526c5..19bdd1b 100644
--- a/arch/x86/kernel/fpu/init.c
+++ b/arch/x86/kernel/fpu/init.c
@@ -77,7 +77,7 @@ static void fpu__init_system_early_generic(struct cpuinfo_x86 *c)
 	}
 
 #ifndef CONFIG_MATH_EMULATION
-	if (!boot_cpu_has(X86_FEATURE_FPU)) {
+	if (!test_cpu_cap(&boot_cpu_data, X86_FEATURE_FPU)) {
 		pr_emerg("x86/fpu: Giving up, no FPU found and no math emulation present\n");
 		for (;;)
 			asm volatile("hlt");

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, back to index

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-18 19:15 [PATCH v2 0/6] CPUID and FPU fixes Andy Lutomirski
2017-01-18 19:15 ` [PATCH v2 1/6] x86/cpu: Add X86_FEATURE_CPUID Andy Lutomirski
2017-01-25 11:40   ` [tip:x86/fpu] " tip-bot for Borislav Petkov
2017-01-18 19:15 ` [PATCH v2 2/6] x86/cpu: Factor out application of forced cpu caps Andy Lutomirski
2017-01-25 11:40   ` [tip:x86/fpu] x86/cpu: Factor out application of forced CPU caps tip-bot for Andy Lutomirski
2017-01-18 19:15 ` [PATCH v2 3/6] x86/cpu: Re-apply forced caps every time cpu caps are re-read Andy Lutomirski
2017-01-19 11:23   ` Borislav Petkov
2017-01-25 11:41   ` [tip:x86/fpu] x86/cpu: Re-apply forced caps every time CPU " tip-bot for Andy Lutomirski
2017-01-18 19:15 ` [PATCH v2 4/6] x86/fpu: Fix "x86/fpu: Legacy x87 FPU detected" message Andy Lutomirski
2017-01-25 11:42   ` [tip:x86/fpu] " tip-bot for Andy Lutomirski
2017-01-18 19:15 ` [PATCH v2 5/6] x86/fpu: Fix CPUID-less FPU detection Andy Lutomirski
2017-01-19 11:23   ` Borislav Petkov
2017-01-25 11:42   ` [tip:x86/fpu] " tip-bot for Andy Lutomirski
2017-01-18 19:15 ` [PATCH v2 6/6] x86/fpu: Fix the "Giving up, no FPU found" test Andy Lutomirski
2017-01-25 11:43   ` [tip:x86/fpu] " tip-bot for Andy Lutomirski

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org linux-kernel@archiver.kernel.org
	public-inbox-index lkml


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/ public-inbox