]> git.proxmox.com Git - pve-kernel.git/blob - patches/kernel/0067-x86-fpu-Parse-clearcpuid-as-early-XSAVE-argument.patch
eedd16824bfd70e4cf9fb13b0537d88b5deaeb43
[pve-kernel.git] / patches / kernel / 0067-x86-fpu-Parse-clearcpuid-as-early-XSAVE-argument.patch
1 From df469cffe07c84906be43e89d33f2a8a5312e60f Mon Sep 17 00:00:00 2001
2 From: Andi Kleen <ak@linux.intel.com>
3 Date: Fri, 13 Oct 2017 14:56:43 -0700
4 Subject: [PATCH 067/233] x86/fpu: Parse clearcpuid= as early XSAVE argument
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 With a followon patch we want to make clearcpuid affect the XSAVE
12 configuration. But xsave is currently initialized before arguments
13 are parsed. Move the clearcpuid= parsing into the special
14 early xsave argument parsing code.
15
16 Since clearcpuid= contains a = we need to keep the old __setup
17 around as a dummy, otherwise it would end up as a environment
18 variable in init's environment.
19
20 Signed-off-by: Andi Kleen <ak@linux.intel.com>
21 Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
22 Cc: Linus Torvalds <torvalds@linux-foundation.org>
23 Cc: Peter Zijlstra <peterz@infradead.org>
24 Link: http://lkml.kernel.org/r/20171013215645.23166-4-andi@firstfloor.org
25 Signed-off-by: Ingo Molnar <mingo@kernel.org>
26 (cherry picked from commit 0c2a3913d6f50503f7c59d83a6219e39508cc898)
27 Signed-off-by: Andy Whitcroft <apw@canonical.com>
28 Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
29 (cherry picked from commit 27deb452eb0d27c406f3817ab057201aa8767abe)
30 Signed-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
36 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
37 index 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 = {
66 diff --git a/arch/x86/kernel/fpu/init.c b/arch/x86/kernel/fpu/init.c
67 index 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 --
96 2.14.2
97