mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] x86/boot: Delay BSP init until after FPU initialization
@ 2020-09-20  1:03 Mike Hommey
  2020-09-20  8:36 ` Borislav Petkov
  0 siblings, 1 reply; 6+ messages in thread
From: Mike Hommey @ 2020-09-20  1:03 UTC (permalink / raw)
  To: x86; +Cc: linux-kernel, Mike Hommey

FPU initialization handles the clearcpuid command line argument. If it
comes after BSP init, clearcpuid cannot be used to disable features that
trigger some parts of the BSP init code.

Signed-off-by: Mike Hommey <mh@glandium.org>
---
 arch/x86/kernel/cpu/common.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

I was trying to use clearcpuid=440 to disable X86_FEATURES_AMD_SSBD to
reproduce the behavior that happens on Zen/Zen+ on a Zen2 machine, but
that didn't work because the command line is handled after the setup for
X86_FEATURE_LS_CFG_SSBD.

I tought about either moving the command line handling earlier, but it
seems there wasn't a specific reason for BSP init being earlier than FPU
initialization so I went with reordering those instead.

diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index c5d6f17d9b9d..c3bbca91a14b 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -1261,9 +1261,6 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)
 
 		c->cpu_index = 0;
 		filter_cpuid_features(c, false);
-
-		if (this_cpu->c_bsp_init)
-			this_cpu->c_bsp_init(c);
 	} else {
 		setup_clear_cpu_cap(X86_FEATURE_CPUID);
 	}
@@ -1276,6 +1273,10 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)
 
 	fpu__init_system(c);
 
+	if (have_cpuid_p()) {
+		if (this_cpu->c_bsp_init)
+			this_cpu->c_bsp_init(c);
+	}
 #ifdef CONFIG_X86_32
 	/*
 	 * Regardless of whether PCID is enumerated, the SDM says
-- 
2.28.0


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

end of thread, other threads:[~2020-09-22  9:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-20  1:03 [PATCH] x86/boot: Delay BSP init until after FPU initialization Mike Hommey
2020-09-20  8:36 ` Borislav Petkov
2020-09-20 22:00   ` [PATCH v2] x86/boot: Handle fpu-related and clearcpuid command line arguments earlier Mike Hommey
2020-09-21 13:10     ` Borislav Petkov
2020-09-21 21:56       ` [PATCH v3] " Mike Hommey
2020-09-22  9:25         ` [tip: x86/fpu] x86/fpu: Handle FPU-related " tip-bot2 for Mike Hommey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®