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