]> git.proxmox.com Git - pve-kernel.git/blame - patches/kernel/0067-x86-fpu-Parse-clearcpuid-as-early-XSAVE-argument.patch
KPTI: add follow-up fixes
[pve-kernel.git] / patches / kernel / 0067-x86-fpu-Parse-clearcpuid-as-early-XSAVE-argument.patch
CommitLineData
321d628a
FG
1From df469cffe07c84906be43e89d33f2a8a5312e60f Mon Sep 17 00:00:00 2001
2From: Andi Kleen <ak@linux.intel.com>
3Date: Fri, 13 Oct 2017 14:56:43 -0700
e4cdf2a5 4Subject: [PATCH 067/241] x86/fpu: Parse clearcpuid= as early XSAVE argument
321d628a
FG
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9CVE-2017-5754
10
11With a followon patch we want to make clearcpuid affect the XSAVE
12configuration. But xsave is currently initialized before arguments
13are parsed. Move the clearcpuid= parsing into the special
14early xsave argument parsing code.
15
16Since clearcpuid= contains a = we need to keep the old __setup
17around as a dummy, otherwise it would end up as a environment
18variable in init's environment.
19
20Signed-off-by: Andi Kleen <ak@linux.intel.com>
21Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
22Cc: Linus Torvalds <torvalds@linux-foundation.org>
23Cc: Peter Zijlstra <peterz@infradead.org>
24Link: http://lkml.kernel.org/r/20171013215645.23166-4-andi@firstfloor.org
25Signed-off-by: Ingo Molnar <mingo@kernel.org>
26(cherry picked from commit 0c2a3913d6f50503f7c59d83a6219e39508cc898)
27Signed-off-by: Andy Whitcroft <apw@canonical.com>
28Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
29(cherry picked from commit 27deb452eb0d27c406f3817ab057201aa8767abe)
30Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
31---
32 arch/x86/kernel/cpu/common.c | 16 +++++++---------
33 arch/x86/kernel/fpu/init.c | 11 +++++++++++
34 2 files changed, 18 insertions(+), 9 deletions(-)
35
36diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
37index 4be7b209a3d6..ef7b1ba56363 100644
38--- a/arch/x86/kernel/cpu/common.c
39+++ b/arch/x86/kernel/cpu/common.c
40@@ -1293,18 +1293,16 @@ void print_cpu_info(struct cpuinfo_x86 *c)
41 pr_cont(")\n");
42 }
43
44-static __init int setup_disablecpuid(char *arg)
45+/*
46+ * clearcpuid= was already parsed in fpu__init_parse_early_param.
47+ * But we need to keep a dummy __setup around otherwise it would
48+ * show up as an environment variable for init.
49+ */
50+static __init int setup_clearcpuid(char *arg)
51 {
52- int bit;
53-
54- if (get_option(&arg, &bit) && bit >= 0 && bit < NCAPINTS * 32)
55- setup_clear_cpu_cap(bit);
56- else
57- return 0;
58-
59 return 1;
60 }
61-__setup("clearcpuid=", setup_disablecpuid);
62+__setup("clearcpuid=", setup_clearcpuid);
63
64 #ifdef CONFIG_X86_64
65 struct desc_ptr idt_descr __ro_after_init = {
66diff --git a/arch/x86/kernel/fpu/init.c b/arch/x86/kernel/fpu/init.c
67index d5d44c452624..07f0ab877f49 100644
68--- a/arch/x86/kernel/fpu/init.c
69+++ b/arch/x86/kernel/fpu/init.c
70@@ -249,6 +249,10 @@ static void __init fpu__init_system_ctx_switch(void)
71 */
72 static void __init fpu__init_parse_early_param(void)
73 {
74+ char arg[32];
75+ char *argptr = arg;
76+ int bit;
77+
78 if (cmdline_find_option_bool(boot_command_line, "no387"))
79 setup_clear_cpu_cap(X86_FEATURE_FPU);
80
81@@ -266,6 +270,13 @@ static void __init fpu__init_parse_early_param(void)
82
83 if (cmdline_find_option_bool(boot_command_line, "noxsaves"))
84 setup_clear_cpu_cap(X86_FEATURE_XSAVES);
85+
86+ if (cmdline_find_option(boot_command_line, "clearcpuid", arg,
87+ sizeof(arg)) &&
88+ get_option(&argptr, &bit) &&
89+ bit >= 0 &&
90+ bit < NCAPINTS * 32)
91+ setup_clear_cpu_cap(bit);
92 }
93
94 /*
95--
962.14.2
97