]> git.proxmox.com Git - pve-kernel.git/blob - patches/kernel/0124-x86-Make-X86_BUG_FXSAVE_LEAK-detectable-in-CPUID-on-.patch
342f3ef7e4dacfc6d17461f701faa930a534dd0e
[pve-kernel.git] / patches / kernel / 0124-x86-Make-X86_BUG_FXSAVE_LEAK-detectable-in-CPUID-on-.patch
1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Rudolf Marek <r.marek@assembler.cz>
3 Date: Tue, 28 Nov 2017 22:01:06 +0100
4 Subject: [PATCH] x86: Make X86_BUG_FXSAVE_LEAK detectable in CPUID on AMD
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 CVE-2017-5754
10
11 [ Note, this is a Git cherry-pick of the following commit:
12
13 2b67799bdf25 ("x86: Make X86_BUG_FXSAVE_LEAK detectable in CPUID on AMD")
14
15 ... for easier x86 PTI code testing and back-porting. ]
16
17 The latest AMD AMD64 Architecture Programmer's Manual
18 adds a CPUID feature XSaveErPtr (CPUID_Fn80000008_EBX[2]).
19
20 If this feature is set, the FXSAVE, XSAVE, FXSAVEOPT, XSAVEC, XSAVES
21 / FXRSTOR, XRSTOR, XRSTORS always save/restore error pointers,
22 thus making the X86_BUG_FXSAVE_LEAK workaround obsolete on such CPUs.
23
24 Signed-Off-By: Rudolf Marek <r.marek@assembler.cz>
25 Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
26 Reviewed-by: Borislav Petkov <bp@suse.de>
27 Tested-by: Borislav Petkov <bp@suse.de>
28 Cc: Andy Lutomirski <luto@amacapital.net>
29 Link: https://lkml.kernel.org/r/bdcebe90-62c5-1f05-083c-eba7f08b2540@assembler.cz
30 Signed-off-by: Ingo Molnar <mingo@kernel.org>
31 (cherry picked from commit f2dbad36c55e5d3a91dccbde6e8cae345fe5632f)
32 Signed-off-by: Andy Whitcroft <apw@canonical.com>
33 Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
34 (cherry picked from commit 281b622113c66ba2de9b7725e1d232ea3c282114)
35 Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
36 ---
37 arch/x86/include/asm/cpufeatures.h | 1 +
38 arch/x86/kernel/cpu/amd.c | 7 +++++--
39 2 files changed, 6 insertions(+), 2 deletions(-)
40
41 diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h
42 index 0ea630bb3e74..d57a174ec97c 100644
43 --- a/arch/x86/include/asm/cpufeatures.h
44 +++ b/arch/x86/include/asm/cpufeatures.h
45 @@ -265,6 +265,7 @@
46 /* AMD-defined CPU features, CPUID level 0x80000008 (EBX), word 13 */
47 #define X86_FEATURE_CLZERO (13*32+ 0) /* CLZERO instruction */
48 #define X86_FEATURE_IRPERF (13*32+ 1) /* Instructions Retired Count */
49 +#define X86_FEATURE_XSAVEERPTR (13*32+ 2) /* Always save/restore FP error pointers */
50
51 /* Thermal and Power Management Leaf, CPUID level 0x00000006 (EAX), word 14 */
52 #define X86_FEATURE_DTHERM (14*32+ 0) /* Digital Thermal Sensor */
53 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
54 index 3b9e220621f8..2a5328cc03a6 100644
55 --- a/arch/x86/kernel/cpu/amd.c
56 +++ b/arch/x86/kernel/cpu/amd.c
57 @@ -760,8 +760,11 @@ static void init_amd(struct cpuinfo_x86 *c)
58 case 0x15: init_amd_bd(c); break;
59 }
60
61 - /* Enable workaround for FXSAVE leak */
62 - if (c->x86 >= 6)
63 + /*
64 + * Enable workaround for FXSAVE leak on CPUs
65 + * without a XSaveErPtr feature
66 + */
67 + if ((c->x86 >= 6) && (!cpu_has(c, X86_FEATURE_XSAVEERPTR)))
68 set_cpu_bug(c, X86_BUG_FXSAVE_LEAK);
69
70 cpu_detect_cache_sizes(c);
71 --
72 2.14.2
73