Skip to content

Commit f2dbad3

Browse files
ruikruikIngo Molnar
authored andcommitted
x86: Make X86_BUG_FXSAVE_LEAK detectable in CPUID on AMD
[ Note, this is a Git cherry-pick of the following commit: 2b67799bdf25 ("x86: Make X86_BUG_FXSAVE_LEAK detectable in CPUID on AMD") ... for easier x86 PTI code testing and back-porting. ] The latest AMD AMD64 Architecture Programmer's Manual adds a CPUID feature XSaveErPtr (CPUID_Fn80000008_EBX[2]). If this feature is set, the FXSAVE, XSAVE, FXSAVEOPT, XSAVEC, XSAVES / FXRSTOR, XRSTOR, XRSTORS always save/restore error pointers, thus making the X86_BUG_FXSAVE_LEAK workaround obsolete on such CPUs. Signed-Off-By: Rudolf Marek <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Borislav Petkov <[email protected]> Tested-by: Borislav Petkov <[email protected]> Cc: Andy Lutomirski <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent a8b4db5 commit f2dbad3

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

arch/x86/include/asm/cpufeatures.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@
266266
/* AMD-defined CPU features, CPUID level 0x80000008 (EBX), word 13 */
267267
#define X86_FEATURE_CLZERO (13*32+ 0) /* CLZERO instruction */
268268
#define X86_FEATURE_IRPERF (13*32+ 1) /* Instructions Retired Count */
269+
#define X86_FEATURE_XSAVEERPTR (13*32+ 2) /* Always save/restore FP error pointers */
269270

270271
/* Thermal and Power Management Leaf, CPUID level 0x00000006 (EAX), word 14 */
271272
#define X86_FEATURE_DTHERM (14*32+ 0) /* Digital Thermal Sensor */

arch/x86/kernel/cpu/amd.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -804,8 +804,11 @@ static void init_amd(struct cpuinfo_x86 *c)
804804
case 0x17: init_amd_zn(c); break;
805805
}
806806

807-
/* Enable workaround for FXSAVE leak */
808-
if (c->x86 >= 6)
807+
/*
808+
* Enable workaround for FXSAVE leak on CPUs
809+
* without a XSaveErPtr feature
810+
*/
811+
if ((c->x86 >= 6) && (!cpu_has(c, X86_FEATURE_XSAVEERPTR)))
809812
set_cpu_bug(c, X86_BUG_FXSAVE_LEAK);
810813

811814
cpu_detect_cache_sizes(c);

0 commit comments

Comments
 (0)