]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.14.21/x86-speculation-clean-up-various-spectre-related-details.patch
fixes for 4.19
[thirdparty/kernel/stable-queue.git] / releases / 4.14.21 / x86-speculation-clean-up-various-spectre-related-details.patch
1 From 21e433bdb95bdf3aa48226fd3d33af608437f293 Mon Sep 17 00:00:00 2001
2 From: Ingo Molnar <mingo@kernel.org>
3 Date: Tue, 13 Feb 2018 09:03:08 +0100
4 Subject: x86/speculation: Clean up various Spectre related details
5
6 From: Ingo Molnar <mingo@kernel.org>
7
8 commit 21e433bdb95bdf3aa48226fd3d33af608437f293 upstream.
9
10 Harmonize all the Spectre messages so that a:
11
12 dmesg | grep -i spectre
13
14 ... gives us most Spectre related kernel boot messages.
15
16 Also fix a few other details:
17
18 - clarify a comment about firmware speculation control
19
20 - s/KPTI/PTI
21
22 - remove various line-breaks that made the code uglier
23
24 Acked-by: David Woodhouse <dwmw@amazon.co.uk>
25 Cc: Andy Lutomirski <luto@kernel.org>
26 Cc: Arjan van de Ven <arjan@linux.intel.com>
27 Cc: Borislav Petkov <bp@alien8.de>
28 Cc: Dan Williams <dan.j.williams@intel.com>
29 Cc: Dave Hansen <dave.hansen@linux.intel.com>
30 Cc: David Woodhouse <dwmw2@infradead.org>
31 Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
32 Cc: Josh Poimboeuf <jpoimboe@redhat.com>
33 Cc: Linus Torvalds <torvalds@linux-foundation.org>
34 Cc: Peter Zijlstra <peterz@infradead.org>
35 Cc: Thomas Gleixner <tglx@linutronix.de>
36 Cc: linux-kernel@vger.kernel.org
37 Signed-off-by: Ingo Molnar <mingo@kernel.org>
38 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
39
40 ---
41 arch/x86/kernel/cpu/bugs.c | 28 +++++++++++-----------------
42 1 file changed, 11 insertions(+), 17 deletions(-)
43
44 --- a/arch/x86/kernel/cpu/bugs.c
45 +++ b/arch/x86/kernel/cpu/bugs.c
46 @@ -162,8 +162,7 @@ static enum spectre_v2_mitigation_cmd __
47 if (cmdline_find_option_bool(boot_command_line, "nospectre_v2"))
48 return SPECTRE_V2_CMD_NONE;
49 else {
50 - ret = cmdline_find_option(boot_command_line, "spectre_v2", arg,
51 - sizeof(arg));
52 + ret = cmdline_find_option(boot_command_line, "spectre_v2", arg, sizeof(arg));
53 if (ret < 0)
54 return SPECTRE_V2_CMD_AUTO;
55
56 @@ -175,8 +174,7 @@ static enum spectre_v2_mitigation_cmd __
57 }
58
59 if (i >= ARRAY_SIZE(mitigation_options)) {
60 - pr_err("unknown option (%s). Switching to AUTO select\n",
61 - mitigation_options[i].option);
62 + pr_err("unknown option (%s). Switching to AUTO select\n", mitigation_options[i].option);
63 return SPECTRE_V2_CMD_AUTO;
64 }
65 }
66 @@ -185,8 +183,7 @@ static enum spectre_v2_mitigation_cmd __
67 cmd == SPECTRE_V2_CMD_RETPOLINE_AMD ||
68 cmd == SPECTRE_V2_CMD_RETPOLINE_GENERIC) &&
69 !IS_ENABLED(CONFIG_RETPOLINE)) {
70 - pr_err("%s selected but not compiled in. Switching to AUTO select\n",
71 - mitigation_options[i].option);
72 + pr_err("%s selected but not compiled in. Switching to AUTO select\n", mitigation_options[i].option);
73 return SPECTRE_V2_CMD_AUTO;
74 }
75
76 @@ -256,14 +253,14 @@ static void __init spectre_v2_select_mit
77 goto retpoline_auto;
78 break;
79 }
80 - pr_err("kernel not compiled with retpoline; no mitigation available!");
81 + pr_err("Spectre mitigation: kernel not compiled with retpoline; no mitigation available!");
82 return;
83
84 retpoline_auto:
85 if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD) {
86 retpoline_amd:
87 if (!boot_cpu_has(X86_FEATURE_LFENCE_RDTSC)) {
88 - pr_err("LFENCE not serializing. Switching to generic retpoline\n");
89 + pr_err("Spectre mitigation: LFENCE not serializing, switching to generic retpoline\n");
90 goto retpoline_generic;
91 }
92 mode = retp_compiler() ? SPECTRE_V2_RETPOLINE_AMD :
93 @@ -281,7 +278,7 @@ retpoline_auto:
94 pr_info("%s\n", spectre_v2_strings[mode]);
95
96 /*
97 - * If neither SMEP or KPTI are available, there is a risk of
98 + * If neither SMEP nor PTI are available, there is a risk of
99 * hitting userspace addresses in the RSB after a context switch
100 * from a shallow call stack to a deeper one. To prevent this fill
101 * the entire RSB, even when using IBRS.
102 @@ -295,21 +292,20 @@ retpoline_auto:
103 if ((!boot_cpu_has(X86_FEATURE_PTI) &&
104 !boot_cpu_has(X86_FEATURE_SMEP)) || is_skylake_era()) {
105 setup_force_cpu_cap(X86_FEATURE_RSB_CTXSW);
106 - pr_info("Filling RSB on context switch\n");
107 + pr_info("Spectre v2 mitigation: Filling RSB on context switch\n");
108 }
109
110 /* Initialize Indirect Branch Prediction Barrier if supported */
111 if (boot_cpu_has(X86_FEATURE_IBPB)) {
112 setup_force_cpu_cap(X86_FEATURE_USE_IBPB);
113 - pr_info("Enabling Indirect Branch Prediction Barrier\n");
114 + pr_info("Spectre v2 mitigation: Enabling Indirect Branch Prediction Barrier\n");
115 }
116 }
117
118 #undef pr_fmt
119
120 #ifdef CONFIG_SYSFS
121 -ssize_t cpu_show_meltdown(struct device *dev,
122 - struct device_attribute *attr, char *buf)
123 +ssize_t cpu_show_meltdown(struct device *dev, struct device_attribute *attr, char *buf)
124 {
125 if (!boot_cpu_has_bug(X86_BUG_CPU_MELTDOWN))
126 return sprintf(buf, "Not affected\n");
127 @@ -318,16 +314,14 @@ ssize_t cpu_show_meltdown(struct device
128 return sprintf(buf, "Vulnerable\n");
129 }
130
131 -ssize_t cpu_show_spectre_v1(struct device *dev,
132 - struct device_attribute *attr, char *buf)
133 +ssize_t cpu_show_spectre_v1(struct device *dev, struct device_attribute *attr, char *buf)
134 {
135 if (!boot_cpu_has_bug(X86_BUG_SPECTRE_V1))
136 return sprintf(buf, "Not affected\n");
137 return sprintf(buf, "Mitigation: __user pointer sanitization\n");
138 }
139
140 -ssize_t cpu_show_spectre_v2(struct device *dev,
141 - struct device_attribute *attr, char *buf)
142 +ssize_t cpu_show_spectre_v2(struct device *dev, struct device_attribute *attr, char *buf)
143 {
144 if (!boot_cpu_has_bug(X86_BUG_SPECTRE_V2))
145 return sprintf(buf, "Not affected\n");