x86/CPU/AMD: Carve out the erratum 1386 fix
authorBorislav Petkov (AMD) <bp@alien8.de>
Wed, 1 Nov 2023 10:14:59 +0000 (11:14 +0100)
committerBorislav Petkov (AMD) <bp@alien8.de>
Wed, 29 Nov 2023 11:11:21 +0000 (12:11 +0100)
Call it on the affected CPU generations.

No functional changes.

Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Nikolay Borisov <nik.borisov@suse.com>
Link: http://lore.kernel.org/r/20231120104152.13740-3-bp@alien8.de
arch/x86/kernel/cpu/amd.c

index 6aba2244d6c623efce01dfab53dc7bb78a78172c..0a499cbbf644050d5815ebb78d3f709c094d00f7 100644 (file)
@@ -984,6 +984,19 @@ static void init_amd_bd(struct cpuinfo_x86 *c)
        clear_rdrand_cpuid_bit(c);
 }
 
+static void fix_erratum_1386(struct cpuinfo_x86 *c)
+{
+       /*
+        * Work around Erratum 1386.  The XSAVES instruction malfunctions in
+        * certain circumstances on Zen1/2 uarch, and not all parts have had
+        * updated microcode at the time of writing (March 2023).
+        *
+        * Affected parts all have no supervisor XSAVE states, meaning that
+        * the XSAVEC instruction (which works fine) is equivalent.
+        */
+       clear_cpu_cap(c, X86_FEATURE_XSAVES);
+}
+
 void init_spectral_chicken(struct cpuinfo_x86 *c)
 {
 #ifdef CONFIG_CPU_UNRET_ENTRY
@@ -1004,15 +1017,6 @@ void init_spectral_chicken(struct cpuinfo_x86 *c)
                }
        }
 #endif
-       /*
-        * Work around Erratum 1386.  The XSAVES instruction malfunctions in
-        * certain circumstances on Zen1/2 uarch, and not all parts have had
-        * updated microcode at the time of writing (March 2023).
-        *
-        * Affected parts all have no supervisor XSAVE states, meaning that
-        * the XSAVEC instruction (which works fine) is equivalent.
-        */
-       clear_cpu_cap(c, X86_FEATURE_XSAVES);
 }
 
 static void init_amd_zn(struct cpuinfo_x86 *c)
@@ -1080,10 +1084,12 @@ static void zenbleed_check(struct cpuinfo_x86 *c)
 
 static void init_amd_zen(struct cpuinfo_x86 *c)
 {
+       fix_erratum_1386(c);
 }
 
 static void init_amd_zen2(struct cpuinfo_x86 *c)
 {
+       fix_erratum_1386(c);
 }
 
 static void init_amd_zen3(struct cpuinfo_x86 *c)