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/241] x86/fpu: Parse clearcpuid= as early XSAVE argument
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
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.
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.
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>
32 arch/x86/kernel/cpu/common.c | 16 +++++++---------
33 arch/x86/kernel/fpu/init.c | 11 +++++++++++
34 2 files changed, 18 insertions(+), 9 deletions(-)
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)
44 -static __init int setup_disablecpuid(char *arg)
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.
50 +static __init int setup_clearcpuid(char *arg)
54 - if (get_option(&arg, &bit) && bit >= 0 && bit < NCAPINTS * 32)
55 - setup_clear_cpu_cap(bit);
61 -__setup("clearcpuid=", setup_disablecpuid);
62 +__setup("clearcpuid=", setup_clearcpuid);
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)
72 static void __init fpu__init_parse_early_param(void)
78 if (cmdline_find_option_bool(boot_command_line, "no387"))
79 setup_clear_cpu_cap(X86_FEATURE_FPU);
81 @@ -266,6 +270,13 @@ static void __init fpu__init_parse_early_param(void)
83 if (cmdline_find_option_bool(boot_command_line, "noxsaves"))
84 setup_clear_cpu_cap(X86_FEATURE_XSAVES);
86 + if (cmdline_find_option(boot_command_line, "clearcpuid", arg,
88 + get_option(&argptr, &bit) &&
90 + bit < NCAPINTS * 32)
91 + setup_clear_cpu_cap(bit);