Skip to contentSkip to conversation

x86/amd: Only call setup_force_cpu_cap for boot CPU

PATCH In review Ross Lagerwall 2 participants 2 messages Aug 11, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/amd: Only call setup_force_cpu_cap for boot CPU

This should only be called for the boot CPU to avoid calling _init code after it has been unloaded.

Fixes 062868a5a8b4 ("x86/amd: Work around CLFLUSH ordering on older parts")

---

This replaces "x86/cpu: Drop _init from *_cpu_cap functions".

 xen/arch/x86/cpu/amd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/cpu/amd.c +1 -1
index 29c59bcba4..d5f8e5e899 100644
@@ -845,7 +845,7 @@ static void cf_check init_amd(struct cpuinfo_x86 *c)
 	 * everything, including reads and writes to address, and
 	 * LFENCE/SFENCE instructions.
 	 */
-	if (!cpu_has_clflushopt)
+	if (c == &boot_cpu_data && !cpu_has_clflushopt)
 		setup_force_cpu_cap(X86_BUG_CLFLUSH_MFENCE);
 
 	switch(c->x86)
Signature · 1 line
2.31.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Ross Lagerwall

This should only be called for the boot CPU to avoid calling _init code after it has been unloaded.

Fixes 062868a5a8b4 ("x86/amd: Work around CLFLUSH ordering on older parts")

albeit ...

xen/arch/x86/cpu/amd.c static void cf_check init_amd(struct cpuinfo_x86 *c) · line 848

Quoted 8 lines
xen/arch/x86/cpu/amd.c +1 -1
@@ -845,7 +845,7 @@ static void cf_check init_amd(struct cpuinfo_x86 *c)
 	 * everything, including reads and writes to address, and
 	 * LFENCE/SFENCE instructions.
 	 */
-	if (!cpu_has_clflushopt)
+	if (c == &boot_cpu_data && !cpu_has_clflushopt)

... I would have put the two sides of the && the other way around.

Jan