1 From 6fa756f7aa84827d2e839b8a1ef4360092ecf23d Mon Sep 17 00:00:00 2001
2 From: Sasha Levin <sashal@kernel.org>
3 Date: Wed, 1 Nov 2023 11:14:59 +0100
4 Subject: x86/CPU/AMD: Carve out the erratum 1386 fix
6 From: Borislav Petkov (AMD) <bp@alien8.de>
8 [ Upstream commit a7c32a1ae9ee43abfe884f5af376877c4301d166 ]
10 Call it on the affected CPU generations.
12 No functional changes.
14 Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
15 Reviewed-by: Nikolay Borisov <nik.borisov@suse.com>
16 Link: http://lore.kernel.org/r/20231120104152.13740-3-bp@alien8.de
17 Stable-dep-of: c7b2edd8377b ("perf/x86/amd/core: Update and fix stalled-cycles-* events for Zen 2 and later")
18 Signed-off-by: Sasha Levin <sashal@kernel.org>
20 arch/x86/kernel/cpu/amd.c | 24 +++++++++++++++---------
21 1 file changed, 15 insertions(+), 9 deletions(-)
23 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
24 index 5391385707b3f..28c3a1045b060 100644
25 --- a/arch/x86/kernel/cpu/amd.c
26 +++ b/arch/x86/kernel/cpu/amd.c
27 @@ -988,6 +988,19 @@ static void init_amd_bd(struct cpuinfo_x86 *c)
28 clear_rdrand_cpuid_bit(c);
31 +static void fix_erratum_1386(struct cpuinfo_x86 *c)
34 + * Work around Erratum 1386. The XSAVES instruction malfunctions in
35 + * certain circumstances on Zen1/2 uarch, and not all parts have had
36 + * updated microcode at the time of writing (March 2023).
38 + * Affected parts all have no supervisor XSAVE states, meaning that
39 + * the XSAVEC instruction (which works fine) is equivalent.
41 + clear_cpu_cap(c, X86_FEATURE_XSAVES);
44 void init_spectral_chicken(struct cpuinfo_x86 *c)
46 #ifdef CONFIG_CPU_UNRET_ENTRY
47 @@ -1008,15 +1021,6 @@ void init_spectral_chicken(struct cpuinfo_x86 *c)
52 - * Work around Erratum 1386. The XSAVES instruction malfunctions in
53 - * certain circumstances on Zen1/2 uarch, and not all parts have had
54 - * updated microcode at the time of writing (March 2023).
56 - * Affected parts all have no supervisor XSAVE states, meaning that
57 - * the XSAVEC instruction (which works fine) is equivalent.
59 - clear_cpu_cap(c, X86_FEATURE_XSAVES);
62 static void init_amd_zn(struct cpuinfo_x86 *c)
63 @@ -1085,10 +1089,12 @@ static void zenbleed_check(struct cpuinfo_x86 *c)
65 static void init_amd_zen(struct cpuinfo_x86 *c)
67 + fix_erratum_1386(c);
70 static void init_amd_zen2(struct cpuinfo_x86 *c)
72 + fix_erratum_1386(c);
75 static void init_amd_zen3(struct cpuinfo_x86 *c)