diff options
author | Rudolf Marek <r.marek@assembler.cz> | 2017-11-28 16:01:06 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2017-12-17 07:55:02 -0500 |
commit | f2dbad36c55e5d3a91dccbde6e8cae345fe5632f (patch) | |
tree | d66f74d28d8c2ebe4dac3a57bf4e11ca3fbe8ca1 | |
parent | a8b4db562e7283a1520f9e9730297ecaab7622ea (diff) |
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 <r.marek@assembler.cz>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Borislav Petkov <bp@suse.de>
Tested-by: Borislav Petkov <bp@suse.de>
Cc: Andy Lutomirski <luto@amacapital.net>
Link: https://lkml.kernel.org/r/bdcebe90-62c5-1f05-083c-eba7f08b2540@assembler.cz
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | arch/x86/include/asm/cpufeatures.h | 1 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/amd.c | 7 |
2 files changed, 6 insertions, 2 deletions
diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h index c0b0e9e8aa66..800104c8a3ed 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h | |||
@@ -266,6 +266,7 @@ | |||
266 | /* AMD-defined CPU features, CPUID level 0x80000008 (EBX), word 13 */ | 266 | /* AMD-defined CPU features, CPUID level 0x80000008 (EBX), word 13 */ |
267 | #define X86_FEATURE_CLZERO (13*32+ 0) /* CLZERO instruction */ | 267 | #define X86_FEATURE_CLZERO (13*32+ 0) /* CLZERO instruction */ |
268 | #define X86_FEATURE_IRPERF (13*32+ 1) /* Instructions Retired Count */ | 268 | #define X86_FEATURE_IRPERF (13*32+ 1) /* Instructions Retired Count */ |
269 | #define X86_FEATURE_XSAVEERPTR (13*32+ 2) /* Always save/restore FP error pointers */ | ||
269 | 270 | ||
270 | /* Thermal and Power Management Leaf, CPUID level 0x00000006 (EAX), word 14 */ | 271 | /* Thermal and Power Management Leaf, CPUID level 0x00000006 (EAX), word 14 */ |
271 | #define X86_FEATURE_DTHERM (14*32+ 0) /* Digital Thermal Sensor */ | 272 | #define X86_FEATURE_DTHERM (14*32+ 0) /* Digital Thermal Sensor */ |
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c index d58184b7cd44..bcb75dc97d44 100644 --- a/arch/x86/kernel/cpu/amd.c +++ b/arch/x86/kernel/cpu/amd.c | |||
@@ -804,8 +804,11 @@ static void init_amd(struct cpuinfo_x86 *c) | |||
804 | case 0x17: init_amd_zn(c); break; | 804 | case 0x17: init_amd_zn(c); break; |
805 | } | 805 | } |
806 | 806 | ||
807 | /* Enable workaround for FXSAVE leak */ | 807 | /* |
808 | if (c->x86 >= 6) | 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))) | ||
809 | set_cpu_bug(c, X86_BUG_FXSAVE_LEAK); | 812 | set_cpu_bug(c, X86_BUG_FXSAVE_LEAK); |
810 | 813 | ||
811 | cpu_detect_cache_sizes(c); | 814 | cpu_detect_cache_sizes(c); |