Skip to contentSkip to conversation

x86/CPU/AMD: Check vendor in the AMD microcode callback

PATCH Applied Borislav Petkov 2 participants 2 messages Dec 1, 2023 – Dec 2, 2023 x86

lore
Share & tools
lore

Borislav Petkov

author maintainer
#0 lore raw

PATCH 1/1 x86/CPU/AMD: Check vendor in the AMD microcode callback

From: "Borislav Petkov (AMD)" <[email protected]>

Commit in Fixes added an AMD-specific microcode callback. However, it didn't check the CPU vendor the kernel runs on explicitly.

The only reason the Zenbleed check in it didn't run on other x86 vendors hardware was pure coincidental luck:

if (!cpu_has_amd_erratum(c, amd_zenbleed))

gives true on other vendors because they don't have those families and models.

However, with the removal of the cpu_has_amd_erratum() in

05f5f73936fa ("x86/CPU/AMD: Drop now unused CPU erratum checking function")

that coincidental condition is gone, leading to the zenbleed check getting executed on other vendors too.

Add the explicit vendor check for the whole callback as it should've been done in the first place.

Fixes 522b1d69219d ("x86/cpu/amd: Add a Zenbleed fix")
---
 arch/x86/kernel/cpu/amd.c | 3 +++
 1 file changed, 3 insertions(+)
arch/x86/kernel/cpu/amd.c +3 -0
index a7eab05e5f29..f322ebd053a9 100644
@@ -1320,6 +1320,9 @@ static void zenbleed_check_cpu(void *unused)
 
 void amd_check_microcode(void)
 {
+	if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD)
+		return;
+
 	on_each_cpu(zenbleed_check_cpu, NULL, 1);
 }
 
Signature · 1 line
2.42.0.rc0.25.ga82fb66fed25
#1 lore raw
The following commit has been merged into the x86/urgent branch of tip:

The following commit has been merged into the x86/urgent branch of tip:

Commit-ID:     9b8493dc43044376716d789d07699f17d538a7c4
Gitweb:        https://git.kernel.org/tip/9b8493dc43044376716d789d07699f17d538a7c4
Author:        Borislav Petkov (AMD) <[email protected]>
AuthorDate:    Fri, 01 Dec 2023 19:37:27 +01:00
Committer:     Borislav Petkov (AMD) <[email protected]>
CommitterDate: Sat, 02 Dec 2023 11:40:24 +01:00

x86/CPU/AMD: Check vendor in the AMD microcode callback

Commit in Fixes added an AMD-specific microcode callback. However, it didn't check the CPU vendor the kernel runs on explicitly.

The only reason the Zenbleed check in it didn't run on other x86 vendors hardware was pure coincidental luck:

if (!cpu_has_amd_erratum(c, amd_zenbleed))

	  return;

gives true on other vendors because they don't have those families and models.

However, with the removal of the cpu_has_amd_erratum() in

05f5f73936fa ("x86/CPU/AMD: Drop now unused CPU erratum checking function")

that coincidental condition is gone, leading to the zenbleed check getting executed on other vendors too.

Add the explicit vendor check for the whole callback as it should've been done in the first place.

Fixes 522b1d69219d ("x86/cpu/amd: Add a Zenbleed fix")
---
 arch/x86/kernel/cpu/amd.c | 3 +++
 1 file changed, 3 insertions(+)
arch/x86/kernel/cpu/amd.c +3 -0
index a7eab05..f322ebd 100644
@@ -1320,6 +1320,9 @@ static void zenbleed_check_cpu(void *unused)
 
 void amd_check_microcode(void)
 {
+	if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD)
+		return;
+
 	on_each_cpu(zenbleed_check_cpu, NULL, 1);
 }