Skip to contentSkip to conversation

x86/CPU/AMD: Move the Zen3 BTC_NO detection to the Zen3 init function

PATCH Applied Ben Hutchings 2 participants 3 messages May 28 – Jun 16 Stable branch

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/CPU/AMD: Move the Zen3 BTC_NO detection to the Zen3 init function

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

commit affc66cb96f865b3763a8e18add52e133d864f04 upstream.

No functional changes.

Stable-dep-of: 7c81ad8e8bc2 ("x86/CPU/AMD: Rename init_amd_zn() to init_amd_zen_common()") [bwh: Adjusted to apply after backports of the above commit which actually
depended on this]

---
 arch/x86/kernel/cpu/amd.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
arch/x86/kernel/cpu/amd.c +10 -8
index df6dbeeca556..a61606a614bd 100644
@@ -1087,14 +1087,6 @@ static void init_amd_zen1(struct cpuinfo_x86 *c)
 		/* Erratum 1076: CPB feature bit not being set in CPUID. */
 		if (!cpu_has(c, X86_FEATURE_CPB))
 			set_cpu_cap(c, X86_FEATURE_CPB);
-
-		/*
-		 * Zen3 (Fam19 model < 0x10) parts are not susceptible to
-		 * Branch Type Confusion, but predate the allocation of the
-		 * BTC_NO bit.
-		 */
-		if (c->x86 == 0x19 && !cpu_has(c, X86_FEATURE_BTC_NO))
-			set_cpu_cap(c, X86_FEATURE_BTC_NO);
 	}
 
 	pr_notice_once("AMD Zen1 FPDSS bug detected, enabling mitigation.\n");
@@ -1154,6 +1146,16 @@ static void init_amd_zen2(struct cpuinfo_x86 *c)
 static void init_amd_zen3(struct cpuinfo_x86 *c)
 {
 	init_amd_zen_common();
+
+	if (!cpu_has(c, X86_FEATURE_HYPERVISOR)) {
+		/*
+		 * Zen3 (Fam19 model < 0x10) parts are not susceptible to
+		 * Branch Type Confusion, but predate the allocation of the
+		 * BTC_NO bit.
+		 */
+		if (!cpu_has(c, X86_FEATURE_BTC_NO))
+			set_cpu_cap(c, X86_FEATURE_BTC_NO);
+	}
 }
 
 static void init_amd_zen4(struct cpuinfo_x86 *c)
#1 lore raw

[6.6] x86/CPU/AMD: Move the Zen3 BTC_NO detection to the Zen3 init function

For 6.6, please cherry-pick commit affc66cb96f8 "x86/CPU/AMD: Move the Zen3 BTC_NO detection to the Zen3 init function" as stable dependency of commit 0da91912fc15 ("x86/CPU/AMD: Move erratum 1076 fix into the Zen1 init function"). This seems to be applicable without changes.

It seems like 6.6 should also get backports of:

cfbf4f992bfc x86/CPU/AMD: Call the spectral chicken in the Zen2 init function 7c81ad8e8bc2 x86/CPU/AMD: Rename init_amd_zn() to init_amd_zen_common()

which have already been applied to the older branches. But these don't apply cleanly.

Ben.

Signature · 2 lines
Ben Hutchings - Debian developer, member of kernel, installer and LTS
teams
maintainer Applied
#2 lore raw

Re: [6.6] x86/CPU/AMD: Move the Zen3 BTC_NO detection to the Zen3 init function

Quoted 4 lines · Ben Hutchings

For 6.6, please cherry-pick commit affc66cb96f8 "x86/CPU/AMD: Move the Zen3 BTC_NO detection to the Zen3 init function" as stable dependency of commit 0da91912fc15 ("x86/CPU/AMD: Move erratum 1076 fix into the Zen1 init function"). This seems to be applicable without changes.

Now applied.

Quoted 7 lines

It seems like 6.6 should also get backports of:

cfbf4f992bfc x86/CPU/AMD: Call the spectral chicken in the Zen2 init function 7c81ad8e8bc2 x86/CPU/AMD: Rename init_amd_zn() to init_amd_zen_common()

which have already been applied to the older branches. But these don't apply cleanly.

I've applied them now, thanks.

greg k-h