1 |
commit: 645f3565be0d4dce743c0b1a2b71093f0889d815 |
2 |
Author: Mike Pagano <mpagano <AT> gentoo <DOT> org> |
3 |
AuthorDate: Mon Apr 30 10:29:51 2018 +0000 |
4 |
Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Apr 30 10:29:51 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=645f3565 |
7 |
|
8 |
Linux patch 4.14.38 |
9 |
|
10 |
0000_README | 4 + |
11 |
1037_linux-4.14.38.patch | 4524 ++++++++++++++++++++++++++++++++++++++++++++++ |
12 |
2 files changed, 4528 insertions(+) |
13 |
|
14 |
diff --git a/0000_README b/0000_README |
15 |
index 73aafae..03b1461 100644 |
16 |
--- a/0000_README |
17 |
+++ b/0000_README |
18 |
@@ -191,6 +191,10 @@ Patch: 1036_linux-4.14.37.patch |
19 |
From: http://www.kernel.org |
20 |
Desc: Linux 4.14.37 |
21 |
|
22 |
+Patch: 1037_linux-4.14.38.patch |
23 |
+From: http://www.kernel.org |
24 |
+Desc: Linux 4.14.38 |
25 |
+ |
26 |
Patch: 1500_XATTR_USER_PREFIX.patch |
27 |
From: https://bugs.gentoo.org/show_bug.cgi?id=470644 |
28 |
Desc: Support for namespace user.pax.* on tmpfs. |
29 |
|
30 |
diff --git a/1037_linux-4.14.38.patch b/1037_linux-4.14.38.patch |
31 |
new file mode 100644 |
32 |
index 0000000..4612b61 |
33 |
--- /dev/null |
34 |
+++ b/1037_linux-4.14.38.patch |
35 |
@@ -0,0 +1,4524 @@ |
36 |
+diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt |
37 |
+index fb385af482ff..8cfb44ffe853 100644 |
38 |
+--- a/Documentation/admin-guide/kernel-parameters.txt |
39 |
++++ b/Documentation/admin-guide/kernel-parameters.txt |
40 |
+@@ -2541,6 +2541,9 @@ |
41 |
+ |
42 |
+ noalign [KNL,ARM] |
43 |
+ |
44 |
++ noaltinstr [S390] Disables alternative instructions patching |
45 |
++ (CPU alternatives feature). |
46 |
++ |
47 |
+ noapic [SMP,APIC] Tells the kernel to not make use of any |
48 |
+ IOAPICs that may be present in the system. |
49 |
+ |
50 |
+diff --git a/Makefile b/Makefile |
51 |
+index ee330f5449e6..27a8d5c37180 100644 |
52 |
+--- a/Makefile |
53 |
++++ b/Makefile |
54 |
+@@ -1,7 +1,7 @@ |
55 |
+ # SPDX-License-Identifier: GPL-2.0 |
56 |
+ VERSION = 4 |
57 |
+ PATCHLEVEL = 14 |
58 |
+-SUBLEVEL = 37 |
59 |
++SUBLEVEL = 38 |
60 |
+ EXTRAVERSION = |
61 |
+ NAME = Petit Gorille |
62 |
+ |
63 |
+diff --git a/arch/arm64/boot/dts/rockchip/rk3399-puma.dtsi b/arch/arm64/boot/dts/rockchip/rk3399-puma.dtsi |
64 |
+index 910628d18add..1fc5060d7027 100644 |
65 |
+--- a/arch/arm64/boot/dts/rockchip/rk3399-puma.dtsi |
66 |
++++ b/arch/arm64/boot/dts/rockchip/rk3399-puma.dtsi |
67 |
+@@ -155,17 +155,6 @@ |
68 |
+ regulator-min-microvolt = <5000000>; |
69 |
+ regulator-max-microvolt = <5000000>; |
70 |
+ }; |
71 |
+- |
72 |
+- vdd_log: vdd-log { |
73 |
+- compatible = "pwm-regulator"; |
74 |
+- pwms = <&pwm2 0 25000 0>; |
75 |
+- regulator-name = "vdd_log"; |
76 |
+- regulator-min-microvolt = <800000>; |
77 |
+- regulator-max-microvolt = <1400000>; |
78 |
+- regulator-always-on; |
79 |
+- regulator-boot-on; |
80 |
+- status = "okay"; |
81 |
+- }; |
82 |
+ }; |
83 |
+ |
84 |
+ &cpu_b0 { |
85 |
+diff --git a/arch/microblaze/Kconfig.platform b/arch/microblaze/Kconfig.platform |
86 |
+index 1b3d8c849101..f7f1739c11b9 100644 |
87 |
+--- a/arch/microblaze/Kconfig.platform |
88 |
++++ b/arch/microblaze/Kconfig.platform |
89 |
+@@ -20,6 +20,7 @@ config OPT_LIB_FUNCTION |
90 |
+ config OPT_LIB_ASM |
91 |
+ bool "Optimalized lib function ASM" |
92 |
+ depends on OPT_LIB_FUNCTION && (XILINX_MICROBLAZE0_USE_BARREL = 1) |
93 |
++ depends on CPU_BIG_ENDIAN |
94 |
+ default n |
95 |
+ help |
96 |
+ Allows turn on optimalized library function (memcpy and memmove). |
97 |
+diff --git a/arch/microblaze/lib/fastcopy.S b/arch/microblaze/lib/fastcopy.S |
98 |
+index 62021d7e249e..fdc48bb065d8 100644 |
99 |
+--- a/arch/microblaze/lib/fastcopy.S |
100 |
++++ b/arch/microblaze/lib/fastcopy.S |
101 |
+@@ -29,10 +29,6 @@ |
102 |
+ * between mem locations with size of xfer spec'd in bytes |
103 |
+ */ |
104 |
+ |
105 |
+-#ifdef __MICROBLAZEEL__ |
106 |
+-#error Microblaze LE not support ASM optimized lib func. Disable OPT_LIB_ASM. |
107 |
+-#endif |
108 |
+- |
109 |
+ #include <linux/linkage.h> |
110 |
+ .text |
111 |
+ .globl memcpy |
112 |
+diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig |
113 |
+index ae55e715cc74..49fb6614ea8c 100644 |
114 |
+--- a/arch/s390/Kconfig |
115 |
++++ b/arch/s390/Kconfig |
116 |
+@@ -121,6 +121,7 @@ config S390 |
117 |
+ select GENERIC_CLOCKEVENTS |
118 |
+ select GENERIC_CPU_AUTOPROBE |
119 |
+ select GENERIC_CPU_DEVICES if !SMP |
120 |
++ select GENERIC_CPU_VULNERABILITIES |
121 |
+ select GENERIC_FIND_FIRST_BIT |
122 |
+ select GENERIC_SMP_IDLE_THREAD |
123 |
+ select GENERIC_TIME_VSYSCALL |
124 |
+@@ -538,6 +539,51 @@ config ARCH_RANDOM |
125 |
+ |
126 |
+ If unsure, say Y. |
127 |
+ |
128 |
++config KERNEL_NOBP |
129 |
++ def_bool n |
130 |
++ prompt "Enable modified branch prediction for the kernel by default" |
131 |
++ help |
132 |
++ If this option is selected the kernel will switch to a modified |
133 |
++ branch prediction mode if the firmware interface is available. |
134 |
++ The modified branch prediction mode improves the behaviour in |
135 |
++ regard to speculative execution. |
136 |
++ |
137 |
++ With the option enabled the kernel parameter "nobp=0" or "nospec" |
138 |
++ can be used to run the kernel in the normal branch prediction mode. |
139 |
++ |
140 |
++ With the option disabled the modified branch prediction mode is |
141 |
++ enabled with the "nobp=1" kernel parameter. |
142 |
++ |
143 |
++ If unsure, say N. |
144 |
++ |
145 |
++config EXPOLINE |
146 |
++ def_bool n |
147 |
++ prompt "Avoid speculative indirect branches in the kernel" |
148 |
++ help |
149 |
++ Compile the kernel with the expoline compiler options to guard |
150 |
++ against kernel-to-user data leaks by avoiding speculative indirect |
151 |
++ branches. |
152 |
++ Requires a compiler with -mindirect-branch=thunk support for full |
153 |
++ protection. The kernel may run slower. |
154 |
++ |
155 |
++ If unsure, say N. |
156 |
++ |
157 |
++choice |
158 |
++ prompt "Expoline default" |
159 |
++ depends on EXPOLINE |
160 |
++ default EXPOLINE_FULL |
161 |
++ |
162 |
++config EXPOLINE_OFF |
163 |
++ bool "spectre_v2=off" |
164 |
++ |
165 |
++config EXPOLINE_AUTO |
166 |
++ bool "spectre_v2=auto" |
167 |
++ |
168 |
++config EXPOLINE_FULL |
169 |
++ bool "spectre_v2=on" |
170 |
++ |
171 |
++endchoice |
172 |
++ |
173 |
+ endmenu |
174 |
+ |
175 |
+ menu "Memory setup" |
176 |
+@@ -812,6 +858,7 @@ config PFAULT |
177 |
+ config SHARED_KERNEL |
178 |
+ bool "VM shared kernel support" |
179 |
+ depends on !JUMP_LABEL |
180 |
++ depends on !ALTERNATIVES |
181 |
+ help |
182 |
+ Select this option, if you want to share the text segment of the |
183 |
+ Linux kernel between different VM guests. This reduces memory |
184 |
+diff --git a/arch/s390/Makefile b/arch/s390/Makefile |
185 |
+index dac821cfcd43..ec3fa105f448 100644 |
186 |
+--- a/arch/s390/Makefile |
187 |
++++ b/arch/s390/Makefile |
188 |
+@@ -81,6 +81,16 @@ ifeq ($(call cc-option-yn,-mwarn-dynamicstack),y) |
189 |
+ cflags-$(CONFIG_WARN_DYNAMIC_STACK) += -mwarn-dynamicstack |
190 |
+ endif |
191 |
+ |
192 |
++ifdef CONFIG_EXPOLINE |
193 |
++ ifeq ($(call cc-option-yn,$(CC_FLAGS_MARCH) -mindirect-branch=thunk),y) |
194 |
++ CC_FLAGS_EXPOLINE := -mindirect-branch=thunk |
195 |
++ CC_FLAGS_EXPOLINE += -mfunction-return=thunk |
196 |
++ CC_FLAGS_EXPOLINE += -mindirect-branch-table |
197 |
++ export CC_FLAGS_EXPOLINE |
198 |
++ cflags-y += $(CC_FLAGS_EXPOLINE) -DCC_USING_EXPOLINE |
199 |
++ endif |
200 |
++endif |
201 |
++ |
202 |
+ ifdef CONFIG_FUNCTION_TRACER |
203 |
+ # make use of hotpatch feature if the compiler supports it |
204 |
+ cc_hotpatch := -mhotpatch=0,3 |
205 |
+diff --git a/arch/s390/include/asm/alternative.h b/arch/s390/include/asm/alternative.h |
206 |
+new file mode 100644 |
207 |
+index 000000000000..a72002056b54 |
208 |
+--- /dev/null |
209 |
++++ b/arch/s390/include/asm/alternative.h |
210 |
+@@ -0,0 +1,149 @@ |
211 |
++#ifndef _ASM_S390_ALTERNATIVE_H |
212 |
++#define _ASM_S390_ALTERNATIVE_H |
213 |
++ |
214 |
++#ifndef __ASSEMBLY__ |
215 |
++ |
216 |
++#include <linux/types.h> |
217 |
++#include <linux/stddef.h> |
218 |
++#include <linux/stringify.h> |
219 |
++ |
220 |
++struct alt_instr { |
221 |
++ s32 instr_offset; /* original instruction */ |
222 |
++ s32 repl_offset; /* offset to replacement instruction */ |
223 |
++ u16 facility; /* facility bit set for replacement */ |
224 |
++ u8 instrlen; /* length of original instruction */ |
225 |
++ u8 replacementlen; /* length of new instruction */ |
226 |
++} __packed; |
227 |
++ |
228 |
++void apply_alternative_instructions(void); |
229 |
++void apply_alternatives(struct alt_instr *start, struct alt_instr *end); |
230 |
++ |
231 |
++/* |
232 |
++ * |661: |662: |6620 |663: |
233 |
++ * +-----------+---------------------+ |
234 |
++ * | oldinstr | oldinstr_padding | |
235 |
++ * | +----------+----------+ |
236 |
++ * | | | | |
237 |
++ * | | >6 bytes |6/4/2 nops| |
238 |
++ * | |6 bytes jg-----------> |
239 |
++ * +-----------+---------------------+ |
240 |
++ * ^^ static padding ^^ |
241 |
++ * |
242 |
++ * .altinstr_replacement section |
243 |
++ * +---------------------+-----------+ |
244 |
++ * |6641: |6651: |
245 |
++ * | alternative instr 1 | |
246 |
++ * +-----------+---------+- - - - - -+ |
247 |
++ * |6642: |6652: | |
248 |
++ * | alternative instr 2 | padding |
249 |
++ * +---------------------+- - - - - -+ |
250 |
++ * ^ runtime ^ |
251 |
++ * |
252 |
++ * .altinstructions section |
253 |
++ * +---------------------------------+ |
254 |
++ * | alt_instr entries for each | |
255 |
++ * | alternative instr | |
256 |
++ * +---------------------------------+ |
257 |
++ */ |
258 |
++ |
259 |
++#define b_altinstr(num) "664"#num |
260 |
++#define e_altinstr(num) "665"#num |
261 |
++ |
262 |
++#define e_oldinstr_pad_end "663" |
263 |
++#define oldinstr_len "662b-661b" |
264 |
++#define oldinstr_total_len e_oldinstr_pad_end"b-661b" |
265 |
++#define altinstr_len(num) e_altinstr(num)"b-"b_altinstr(num)"b" |
266 |
++#define oldinstr_pad_len(num) \ |
267 |
++ "-(((" altinstr_len(num) ")-(" oldinstr_len ")) > 0) * " \ |
268 |
++ "((" altinstr_len(num) ")-(" oldinstr_len "))" |
269 |
++ |
270 |
++#define INSTR_LEN_SANITY_CHECK(len) \ |
271 |
++ ".if " len " > 254\n" \ |
272 |
++ "\t.error \"cpu alternatives does not support instructions " \ |
273 |
++ "blocks > 254 bytes\"\n" \ |
274 |
++ ".endif\n" \ |
275 |
++ ".if (" len ") %% 2\n" \ |
276 |
++ "\t.error \"cpu alternatives instructions length is odd\"\n" \ |
277 |
++ ".endif\n" |
278 |
++ |
279 |
++#define OLDINSTR_PADDING(oldinstr, num) \ |
280 |
++ ".if " oldinstr_pad_len(num) " > 6\n" \ |
281 |
++ "\tjg " e_oldinstr_pad_end "f\n" \ |
282 |
++ "6620:\n" \ |
283 |
++ "\t.fill (" oldinstr_pad_len(num) " - (6620b-662b)) / 2, 2, 0x0700\n" \ |
284 |
++ ".else\n" \ |
285 |
++ "\t.fill " oldinstr_pad_len(num) " / 6, 6, 0xc0040000\n" \ |
286 |
++ "\t.fill " oldinstr_pad_len(num) " %% 6 / 4, 4, 0x47000000\n" \ |
287 |
++ "\t.fill " oldinstr_pad_len(num) " %% 6 %% 4 / 2, 2, 0x0700\n" \ |
288 |
++ ".endif\n" |
289 |
++ |
290 |
++#define OLDINSTR(oldinstr, num) \ |
291 |
++ "661:\n\t" oldinstr "\n662:\n" \ |
292 |
++ OLDINSTR_PADDING(oldinstr, num) \ |
293 |
++ e_oldinstr_pad_end ":\n" \ |
294 |
++ INSTR_LEN_SANITY_CHECK(oldinstr_len) |
295 |
++ |
296 |
++#define OLDINSTR_2(oldinstr, num1, num2) \ |
297 |
++ "661:\n\t" oldinstr "\n662:\n" \ |
298 |
++ ".if " altinstr_len(num1) " < " altinstr_len(num2) "\n" \ |
299 |
++ OLDINSTR_PADDING(oldinstr, num2) \ |
300 |
++ ".else\n" \ |
301 |
++ OLDINSTR_PADDING(oldinstr, num1) \ |
302 |
++ ".endif\n" \ |
303 |
++ e_oldinstr_pad_end ":\n" \ |
304 |
++ INSTR_LEN_SANITY_CHECK(oldinstr_len) |
305 |
++ |
306 |
++#define ALTINSTR_ENTRY(facility, num) \ |
307 |
++ "\t.long 661b - .\n" /* old instruction */ \ |
308 |
++ "\t.long " b_altinstr(num)"b - .\n" /* alt instruction */ \ |
309 |
++ "\t.word " __stringify(facility) "\n" /* facility bit */ \ |
310 |
++ "\t.byte " oldinstr_total_len "\n" /* source len */ \ |
311 |
++ "\t.byte " altinstr_len(num) "\n" /* alt instruction len */ |
312 |
++ |
313 |
++#define ALTINSTR_REPLACEMENT(altinstr, num) /* replacement */ \ |
314 |
++ b_altinstr(num)":\n\t" altinstr "\n" e_altinstr(num) ":\n" \ |
315 |
++ INSTR_LEN_SANITY_CHECK(altinstr_len(num)) |
316 |
++ |
317 |
++/* alternative assembly primitive: */ |
318 |
++#define ALTERNATIVE(oldinstr, altinstr, facility) \ |
319 |
++ ".pushsection .altinstr_replacement, \"ax\"\n" \ |
320 |
++ ALTINSTR_REPLACEMENT(altinstr, 1) \ |
321 |
++ ".popsection\n" \ |
322 |
++ OLDINSTR(oldinstr, 1) \ |
323 |
++ ".pushsection .altinstructions,\"a\"\n" \ |
324 |
++ ALTINSTR_ENTRY(facility, 1) \ |
325 |
++ ".popsection\n" |
326 |
++ |
327 |
++#define ALTERNATIVE_2(oldinstr, altinstr1, facility1, altinstr2, facility2)\ |
328 |
++ ".pushsection .altinstr_replacement, \"ax\"\n" \ |
329 |
++ ALTINSTR_REPLACEMENT(altinstr1, 1) \ |
330 |
++ ALTINSTR_REPLACEMENT(altinstr2, 2) \ |
331 |
++ ".popsection\n" \ |
332 |
++ OLDINSTR_2(oldinstr, 1, 2) \ |
333 |
++ ".pushsection .altinstructions,\"a\"\n" \ |
334 |
++ ALTINSTR_ENTRY(facility1, 1) \ |
335 |
++ ALTINSTR_ENTRY(facility2, 2) \ |
336 |
++ ".popsection\n" |
337 |
++ |
338 |
++/* |
339 |
++ * Alternative instructions for different CPU types or capabilities. |
340 |
++ * |
341 |
++ * This allows to use optimized instructions even on generic binary |
342 |
++ * kernels. |
343 |
++ * |
344 |
++ * oldinstr is padded with jump and nops at compile time if altinstr is |
345 |
++ * longer. altinstr is padded with jump and nops at run-time during patching. |
346 |
++ * |
347 |
++ * For non barrier like inlines please define new variants |
348 |
++ * without volatile and memory clobber. |
349 |
++ */ |
350 |
++#define alternative(oldinstr, altinstr, facility) \ |
351 |
++ asm volatile(ALTERNATIVE(oldinstr, altinstr, facility) : : : "memory") |
352 |
++ |
353 |
++#define alternative_2(oldinstr, altinstr1, facility1, altinstr2, facility2) \ |
354 |
++ asm volatile(ALTERNATIVE_2(oldinstr, altinstr1, facility1, \ |
355 |
++ altinstr2, facility2) ::: "memory") |
356 |
++ |
357 |
++#endif /* __ASSEMBLY__ */ |
358 |
++ |
359 |
++#endif /* _ASM_S390_ALTERNATIVE_H */ |
360 |
+diff --git a/arch/s390/include/asm/barrier.h b/arch/s390/include/asm/barrier.h |
361 |
+index 10432607a573..f9eddbca79d2 100644 |
362 |
+--- a/arch/s390/include/asm/barrier.h |
363 |
++++ b/arch/s390/include/asm/barrier.h |
364 |
+@@ -49,6 +49,30 @@ do { \ |
365 |
+ #define __smp_mb__before_atomic() barrier() |
366 |
+ #define __smp_mb__after_atomic() barrier() |
367 |
+ |
368 |
++/** |
369 |
++ * array_index_mask_nospec - generate a mask for array_idx() that is |
370 |
++ * ~0UL when the bounds check succeeds and 0 otherwise |
371 |
++ * @index: array element index |
372 |
++ * @size: number of elements in array |
373 |
++ */ |
374 |
++#define array_index_mask_nospec array_index_mask_nospec |
375 |
++static inline unsigned long array_index_mask_nospec(unsigned long index, |
376 |
++ unsigned long size) |
377 |
++{ |
378 |
++ unsigned long mask; |
379 |
++ |
380 |
++ if (__builtin_constant_p(size) && size > 0) { |
381 |
++ asm(" clgr %2,%1\n" |
382 |
++ " slbgr %0,%0\n" |
383 |
++ :"=d" (mask) : "d" (size-1), "d" (index) :"cc"); |
384 |
++ return mask; |
385 |
++ } |
386 |
++ asm(" clgr %1,%2\n" |
387 |
++ " slbgr %0,%0\n" |
388 |
++ :"=d" (mask) : "d" (size), "d" (index) :"cc"); |
389 |
++ return ~mask; |
390 |
++} |
391 |
++ |
392 |
+ #include <asm-generic/barrier.h> |
393 |
+ |
394 |
+ #endif /* __ASM_BARRIER_H */ |
395 |
+diff --git a/arch/s390/include/asm/facility.h b/arch/s390/include/asm/facility.h |
396 |
+index f040644575b7..2d58478c2745 100644 |
397 |
+--- a/arch/s390/include/asm/facility.h |
398 |
++++ b/arch/s390/include/asm/facility.h |
399 |
+@@ -15,6 +15,24 @@ |
400 |
+ |
401 |
+ #define MAX_FACILITY_BIT (sizeof(((struct lowcore *)0)->stfle_fac_list) * 8) |
402 |
+ |
403 |
++static inline void __set_facility(unsigned long nr, void *facilities) |
404 |
++{ |
405 |
++ unsigned char *ptr = (unsigned char *) facilities; |
406 |
++ |
407 |
++ if (nr >= MAX_FACILITY_BIT) |
408 |
++ return; |
409 |
++ ptr[nr >> 3] |= 0x80 >> (nr & 7); |
410 |
++} |
411 |
++ |
412 |
++static inline void __clear_facility(unsigned long nr, void *facilities) |
413 |
++{ |
414 |
++ unsigned char *ptr = (unsigned char *) facilities; |
415 |
++ |
416 |
++ if (nr >= MAX_FACILITY_BIT) |
417 |
++ return; |
418 |
++ ptr[nr >> 3] &= ~(0x80 >> (nr & 7)); |
419 |
++} |
420 |
++ |
421 |
+ static inline int __test_facility(unsigned long nr, void *facilities) |
422 |
+ { |
423 |
+ unsigned char *ptr; |
424 |
+diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h |
425 |
+index 51375e766e90..d660e784e445 100644 |
426 |
+--- a/arch/s390/include/asm/kvm_host.h |
427 |
++++ b/arch/s390/include/asm/kvm_host.h |
428 |
+@@ -210,7 +210,8 @@ struct kvm_s390_sie_block { |
429 |
+ __u16 ipa; /* 0x0056 */ |
430 |
+ __u32 ipb; /* 0x0058 */ |
431 |
+ __u32 scaoh; /* 0x005c */ |
432 |
+- __u8 reserved60; /* 0x0060 */ |
433 |
++#define FPF_BPBC 0x20 |
434 |
++ __u8 fpf; /* 0x0060 */ |
435 |
+ #define ECB_GS 0x40 |
436 |
+ #define ECB_TE 0x10 |
437 |
+ #define ECB_SRSI 0x04 |
438 |
+diff --git a/arch/s390/include/asm/lowcore.h b/arch/s390/include/asm/lowcore.h |
439 |
+index 917f7344cab6..88a212df0dbc 100644 |
440 |
+--- a/arch/s390/include/asm/lowcore.h |
441 |
++++ b/arch/s390/include/asm/lowcore.h |
442 |
+@@ -140,7 +140,9 @@ struct lowcore { |
443 |
+ /* Per cpu primary space access list */ |
444 |
+ __u32 paste[16]; /* 0x0400 */ |
445 |
+ |
446 |
+- __u8 pad_0x04c0[0x0e00-0x0440]; /* 0x0440 */ |
447 |
++ /* br %r1 trampoline */ |
448 |
++ __u16 br_r1_trampoline; /* 0x0440 */ |
449 |
++ __u8 pad_0x0442[0x0e00-0x0442]; /* 0x0442 */ |
450 |
+ |
451 |
+ /* |
452 |
+ * 0xe00 contains the address of the IPL Parameter Information |
453 |
+@@ -155,7 +157,8 @@ struct lowcore { |
454 |
+ __u8 pad_0x0e20[0x0f00-0x0e20]; /* 0x0e20 */ |
455 |
+ |
456 |
+ /* Extended facility list */ |
457 |
+- __u64 stfle_fac_list[32]; /* 0x0f00 */ |
458 |
++ __u64 stfle_fac_list[16]; /* 0x0f00 */ |
459 |
++ __u64 alt_stfle_fac_list[16]; /* 0x0f80 */ |
460 |
+ __u8 pad_0x1000[0x11b0-0x1000]; /* 0x1000 */ |
461 |
+ |
462 |
+ /* Pointer to the machine check extended save area */ |
463 |
+diff --git a/arch/s390/include/asm/nospec-branch.h b/arch/s390/include/asm/nospec-branch.h |
464 |
+new file mode 100644 |
465 |
+index 000000000000..b4bd8c41e9d3 |
466 |
+--- /dev/null |
467 |
++++ b/arch/s390/include/asm/nospec-branch.h |
468 |
+@@ -0,0 +1,17 @@ |
469 |
++/* SPDX-License-Identifier: GPL-2.0 */ |
470 |
++#ifndef _ASM_S390_EXPOLINE_H |
471 |
++#define _ASM_S390_EXPOLINE_H |
472 |
++ |
473 |
++#ifndef __ASSEMBLY__ |
474 |
++ |
475 |
++#include <linux/types.h> |
476 |
++ |
477 |
++extern int nospec_disable; |
478 |
++ |
479 |
++void nospec_init_branches(void); |
480 |
++void nospec_auto_detect(void); |
481 |
++void nospec_revert(s32 *start, s32 *end); |
482 |
++ |
483 |
++#endif /* __ASSEMBLY__ */ |
484 |
++ |
485 |
++#endif /* _ASM_S390_EXPOLINE_H */ |
486 |
+diff --git a/arch/s390/include/asm/processor.h b/arch/s390/include/asm/processor.h |
487 |
+index 9cf92abe23c3..0a39cd102c49 100644 |
488 |
+--- a/arch/s390/include/asm/processor.h |
489 |
++++ b/arch/s390/include/asm/processor.h |
490 |
+@@ -89,6 +89,7 @@ void cpu_detect_mhz_feature(void); |
491 |
+ extern const struct seq_operations cpuinfo_op; |
492 |
+ extern int sysctl_ieee_emulation_warnings; |
493 |
+ extern void execve_tail(void); |
494 |
++extern void __bpon(void); |
495 |
+ |
496 |
+ /* |
497 |
+ * User space process size: 2GB for 31 bit, 4TB or 8PT for 64 bit. |
498 |
+@@ -377,6 +378,9 @@ extern void memcpy_absolute(void *, void *, size_t); |
499 |
+ memcpy_absolute(&(dest), &__tmp, sizeof(__tmp)); \ |
500 |
+ } while (0) |
501 |
+ |
502 |
++extern int s390_isolate_bp(void); |
503 |
++extern int s390_isolate_bp_guest(void); |
504 |
++ |
505 |
+ #endif /* __ASSEMBLY__ */ |
506 |
+ |
507 |
+ #endif /* __ASM_S390_PROCESSOR_H */ |
508 |
+diff --git a/arch/s390/include/asm/thread_info.h b/arch/s390/include/asm/thread_info.h |
509 |
+index 0880a37b6d3b..301b4f70bf31 100644 |
510 |
+--- a/arch/s390/include/asm/thread_info.h |
511 |
++++ b/arch/s390/include/asm/thread_info.h |
512 |
+@@ -60,6 +60,8 @@ int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src); |
513 |
+ #define TIF_GUARDED_STORAGE 4 /* load guarded storage control block */ |
514 |
+ #define TIF_PATCH_PENDING 5 /* pending live patching update */ |
515 |
+ #define TIF_PGSTE 6 /* New mm's will use 4K page tables */ |
516 |
++#define TIF_ISOLATE_BP 8 /* Run process with isolated BP */ |
517 |
++#define TIF_ISOLATE_BP_GUEST 9 /* Run KVM guests with isolated BP */ |
518 |
+ |
519 |
+ #define TIF_31BIT 16 /* 32bit process */ |
520 |
+ #define TIF_MEMDIE 17 /* is terminating due to OOM killer */ |
521 |
+@@ -80,6 +82,8 @@ int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src); |
522 |
+ #define _TIF_UPROBE _BITUL(TIF_UPROBE) |
523 |
+ #define _TIF_GUARDED_STORAGE _BITUL(TIF_GUARDED_STORAGE) |
524 |
+ #define _TIF_PATCH_PENDING _BITUL(TIF_PATCH_PENDING) |
525 |
++#define _TIF_ISOLATE_BP _BITUL(TIF_ISOLATE_BP) |
526 |
++#define _TIF_ISOLATE_BP_GUEST _BITUL(TIF_ISOLATE_BP_GUEST) |
527 |
+ |
528 |
+ #define _TIF_31BIT _BITUL(TIF_31BIT) |
529 |
+ #define _TIF_SINGLE_STEP _BITUL(TIF_SINGLE_STEP) |
530 |
+diff --git a/arch/s390/include/uapi/asm/kvm.h b/arch/s390/include/uapi/asm/kvm.h |
531 |
+index 9ad172dcd912..a3938db010f7 100644 |
532 |
+--- a/arch/s390/include/uapi/asm/kvm.h |
533 |
++++ b/arch/s390/include/uapi/asm/kvm.h |
534 |
+@@ -228,6 +228,7 @@ struct kvm_guest_debug_arch { |
535 |
+ #define KVM_SYNC_RICCB (1UL << 7) |
536 |
+ #define KVM_SYNC_FPRS (1UL << 8) |
537 |
+ #define KVM_SYNC_GSCB (1UL << 9) |
538 |
++#define KVM_SYNC_BPBC (1UL << 10) |
539 |
+ /* length and alignment of the sdnx as a power of two */ |
540 |
+ #define SDNXC 8 |
541 |
+ #define SDNXL (1UL << SDNXC) |
542 |
+@@ -251,7 +252,9 @@ struct kvm_sync_regs { |
543 |
+ }; |
544 |
+ __u8 reserved[512]; /* for future vector expansion */ |
545 |
+ __u32 fpc; /* valid on KVM_SYNC_VRS or KVM_SYNC_FPRS */ |
546 |
+- __u8 padding1[52]; /* riccb needs to be 64byte aligned */ |
547 |
++ __u8 bpbc : 1; /* bp mode */ |
548 |
++ __u8 reserved2 : 7; |
549 |
++ __u8 padding1[51]; /* riccb needs to be 64byte aligned */ |
550 |
+ __u8 riccb[64]; /* runtime instrumentation controls block */ |
551 |
+ __u8 padding2[192]; /* sdnx needs to be 256byte aligned */ |
552 |
+ union { |
553 |
+diff --git a/arch/s390/kernel/Makefile b/arch/s390/kernel/Makefile |
554 |
+index 4ce2d05929a7..a3a4cafb6080 100644 |
555 |
+--- a/arch/s390/kernel/Makefile |
556 |
++++ b/arch/s390/kernel/Makefile |
557 |
+@@ -29,6 +29,7 @@ UBSAN_SANITIZE_early.o := n |
558 |
+ # |
559 |
+ ifneq ($(CC_FLAGS_MARCH),-march=z900) |
560 |
+ CFLAGS_REMOVE_als.o += $(CC_FLAGS_MARCH) |
561 |
++CFLAGS_REMOVE_als.o += $(CC_FLAGS_EXPOLINE) |
562 |
+ CFLAGS_als.o += -march=z900 |
563 |
+ AFLAGS_REMOVE_head.o += $(CC_FLAGS_MARCH) |
564 |
+ AFLAGS_head.o += -march=z900 |
565 |
+@@ -57,10 +58,13 @@ obj-y += processor.o sys_s390.o ptrace.o signal.o cpcmd.o ebcdic.o nmi.o |
566 |
+ obj-y += debug.o irq.o ipl.o dis.o diag.o vdso.o als.o |
567 |
+ obj-y += sysinfo.o jump_label.o lgr.o os_info.o machine_kexec.o pgm_check.o |
568 |
+ obj-y += runtime_instr.o cache.o fpu.o dumpstack.o guarded_storage.o |
569 |
+-obj-y += entry.o reipl.o relocate_kernel.o kdebugfs.o |
570 |
++obj-y += entry.o reipl.o relocate_kernel.o kdebugfs.o alternative.o |
571 |
++obj-y += nospec-branch.o |
572 |
+ |
573 |
+ extra-y += head.o head64.o vmlinux.lds |
574 |
+ |
575 |
++CFLAGS_REMOVE_nospec-branch.o += $(CC_FLAGS_EXPOLINE) |
576 |
++ |
577 |
+ obj-$(CONFIG_MODULES) += module.o |
578 |
+ obj-$(CONFIG_SMP) += smp.o |
579 |
+ obj-$(CONFIG_SCHED_TOPOLOGY) += topology.o |
580 |
+diff --git a/arch/s390/kernel/alternative.c b/arch/s390/kernel/alternative.c |
581 |
+new file mode 100644 |
582 |
+index 000000000000..b57b293998dc |
583 |
+--- /dev/null |
584 |
++++ b/arch/s390/kernel/alternative.c |
585 |
+@@ -0,0 +1,112 @@ |
586 |
++#include <linux/module.h> |
587 |
++#include <asm/alternative.h> |
588 |
++#include <asm/facility.h> |
589 |
++#include <asm/nospec-branch.h> |
590 |
++ |
591 |
++#define MAX_PATCH_LEN (255 - 1) |
592 |
++ |
593 |
++static int __initdata_or_module alt_instr_disabled; |
594 |
++ |
595 |
++static int __init disable_alternative_instructions(char *str) |
596 |
++{ |
597 |
++ alt_instr_disabled = 1; |
598 |
++ return 0; |
599 |
++} |
600 |
++ |
601 |
++early_param("noaltinstr", disable_alternative_instructions); |
602 |
++ |
603 |
++struct brcl_insn { |
604 |
++ u16 opc; |
605 |
++ s32 disp; |
606 |
++} __packed; |
607 |
++ |
608 |
++static u16 __initdata_or_module nop16 = 0x0700; |
609 |
++static u32 __initdata_or_module nop32 = 0x47000000; |
610 |
++static struct brcl_insn __initdata_or_module nop48 = { |
611 |
++ 0xc004, 0 |
612 |
++}; |
613 |
++ |
614 |
++static const void *nops[] __initdata_or_module = { |
615 |
++ &nop16, |
616 |
++ &nop32, |
617 |
++ &nop48 |
618 |
++}; |
619 |
++ |
620 |
++static void __init_or_module add_jump_padding(void *insns, unsigned int len) |
621 |
++{ |
622 |
++ struct brcl_insn brcl = { |
623 |
++ 0xc0f4, |
624 |
++ len / 2 |
625 |
++ }; |
626 |
++ |
627 |
++ memcpy(insns, &brcl, sizeof(brcl)); |
628 |
++ insns += sizeof(brcl); |
629 |
++ len -= sizeof(brcl); |
630 |
++ |
631 |
++ while (len > 0) { |
632 |
++ memcpy(insns, &nop16, 2); |
633 |
++ insns += 2; |
634 |
++ len -= 2; |
635 |
++ } |
636 |
++} |
637 |
++ |
638 |
++static void __init_or_module add_padding(void *insns, unsigned int len) |
639 |
++{ |
640 |
++ if (len > 6) |
641 |
++ add_jump_padding(insns, len); |
642 |
++ else if (len >= 2) |
643 |
++ memcpy(insns, nops[len / 2 - 1], len); |
644 |
++} |
645 |
++ |
646 |
++static void __init_or_module __apply_alternatives(struct alt_instr *start, |
647 |
++ struct alt_instr *end) |
648 |
++{ |
649 |
++ struct alt_instr *a; |
650 |
++ u8 *instr, *replacement; |
651 |
++ u8 insnbuf[MAX_PATCH_LEN]; |
652 |
++ |
653 |
++ /* |
654 |
++ * The scan order should be from start to end. A later scanned |
655 |
++ * alternative code can overwrite previously scanned alternative code. |
656 |
++ */ |
657 |
++ for (a = start; a < end; a++) { |
658 |
++ int insnbuf_sz = 0; |
659 |
++ |
660 |
++ instr = (u8 *)&a->instr_offset + a->instr_offset; |
661 |
++ replacement = (u8 *)&a->repl_offset + a->repl_offset; |
662 |
++ |
663 |
++ if (!__test_facility(a->facility, |
664 |
++ S390_lowcore.alt_stfle_fac_list)) |
665 |
++ continue; |
666 |
++ |
667 |
++ if (unlikely(a->instrlen % 2 || a->replacementlen % 2)) { |
668 |
++ WARN_ONCE(1, "cpu alternatives instructions length is " |
669 |
++ "odd, skipping patching\n"); |
670 |
++ continue; |
671 |
++ } |
672 |
++ |
673 |
++ memcpy(insnbuf, replacement, a->replacementlen); |
674 |
++ insnbuf_sz = a->replacementlen; |
675 |
++ |
676 |
++ if (a->instrlen > a->replacementlen) { |
677 |
++ add_padding(insnbuf + a->replacementlen, |
678 |
++ a->instrlen - a->replacementlen); |
679 |
++ insnbuf_sz += a->instrlen - a->replacementlen; |
680 |
++ } |
681 |
++ |
682 |
++ s390_kernel_write(instr, insnbuf, insnbuf_sz); |
683 |
++ } |
684 |
++} |
685 |
++ |
686 |
++void __init_or_module apply_alternatives(struct alt_instr *start, |
687 |
++ struct alt_instr *end) |
688 |
++{ |
689 |
++ if (!alt_instr_disabled) |
690 |
++ __apply_alternatives(start, end); |
691 |
++} |
692 |
++ |
693 |
++extern struct alt_instr __alt_instructions[], __alt_instructions_end[]; |
694 |
++void __init apply_alternative_instructions(void) |
695 |
++{ |
696 |
++ apply_alternatives(__alt_instructions, __alt_instructions_end); |
697 |
++} |
698 |
+diff --git a/arch/s390/kernel/early.c b/arch/s390/kernel/early.c |
699 |
+index f7b280f0ab16..a3219837fa70 100644 |
700 |
+--- a/arch/s390/kernel/early.c |
701 |
++++ b/arch/s390/kernel/early.c |
702 |
+@@ -329,6 +329,11 @@ static noinline __init void setup_facility_list(void) |
703 |
+ { |
704 |
+ stfle(S390_lowcore.stfle_fac_list, |
705 |
+ ARRAY_SIZE(S390_lowcore.stfle_fac_list)); |
706 |
++ memcpy(S390_lowcore.alt_stfle_fac_list, |
707 |
++ S390_lowcore.stfle_fac_list, |
708 |
++ sizeof(S390_lowcore.alt_stfle_fac_list)); |
709 |
++ if (!IS_ENABLED(CONFIG_KERNEL_NOBP)) |
710 |
++ __clear_facility(82, S390_lowcore.alt_stfle_fac_list); |
711 |
+ } |
712 |
+ |
713 |
+ static __init void detect_diag9c(void) |
714 |
+diff --git a/arch/s390/kernel/entry.S b/arch/s390/kernel/entry.S |
715 |
+index 7c6904d616d8..ed9aaa212d4a 100644 |
716 |
+--- a/arch/s390/kernel/entry.S |
717 |
++++ b/arch/s390/kernel/entry.S |
718 |
+@@ -106,6 +106,7 @@ _PIF_WORK = (_PIF_PER_TRAP | _PIF_SYSCALL_RESTART) |
719 |
+ aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE) |
720 |
+ j 3f |
721 |
+ 1: UPDATE_VTIME %r14,%r15,\timer |
722 |
++ BPENTER __TI_flags(%r12),_TIF_ISOLATE_BP |
723 |
+ 2: lg %r15,__LC_ASYNC_STACK # load async stack |
724 |
+ 3: la %r11,STACK_FRAME_OVERHEAD(%r15) |
725 |
+ .endm |
726 |
+@@ -158,6 +159,130 @@ _PIF_WORK = (_PIF_PER_TRAP | _PIF_SYSCALL_RESTART) |
727 |
+ tm off+\addr, \mask |
728 |
+ .endm |
729 |
+ |
730 |
++ .macro BPOFF |
731 |
++ .pushsection .altinstr_replacement, "ax" |
732 |
++660: .long 0xb2e8c000 |
733 |
++ .popsection |
734 |
++661: .long 0x47000000 |
735 |
++ .pushsection .altinstructions, "a" |
736 |
++ .long 661b - . |
737 |
++ .long 660b - . |
738 |
++ .word 82 |
739 |
++ .byte 4 |
740 |
++ .byte 4 |
741 |
++ .popsection |
742 |
++ .endm |
743 |
++ |
744 |
++ .macro BPON |
745 |
++ .pushsection .altinstr_replacement, "ax" |
746 |
++662: .long 0xb2e8d000 |
747 |
++ .popsection |
748 |
++663: .long 0x47000000 |
749 |
++ .pushsection .altinstructions, "a" |
750 |
++ .long 663b - . |
751 |
++ .long 662b - . |
752 |
++ .word 82 |
753 |
++ .byte 4 |
754 |
++ .byte 4 |
755 |
++ .popsection |
756 |
++ .endm |
757 |
++ |
758 |
++ .macro BPENTER tif_ptr,tif_mask |
759 |
++ .pushsection .altinstr_replacement, "ax" |
760 |
++662: .word 0xc004, 0x0000, 0x0000 # 6 byte nop |
761 |
++ .word 0xc004, 0x0000, 0x0000 # 6 byte nop |
762 |
++ .popsection |
763 |
++664: TSTMSK \tif_ptr,\tif_mask |
764 |
++ jz . + 8 |
765 |
++ .long 0xb2e8d000 |
766 |
++ .pushsection .altinstructions, "a" |
767 |
++ .long 664b - . |
768 |
++ .long 662b - . |
769 |
++ .word 82 |
770 |
++ .byte 12 |
771 |
++ .byte 12 |
772 |
++ .popsection |
773 |
++ .endm |
774 |
++ |
775 |
++ .macro BPEXIT tif_ptr,tif_mask |
776 |
++ TSTMSK \tif_ptr,\tif_mask |
777 |
++ .pushsection .altinstr_replacement, "ax" |
778 |
++662: jnz . + 8 |
779 |
++ .long 0xb2e8d000 |
780 |
++ .popsection |
781 |
++664: jz . + 8 |
782 |
++ .long 0xb2e8c000 |
783 |
++ .pushsection .altinstructions, "a" |
784 |
++ .long 664b - . |
785 |
++ .long 662b - . |
786 |
++ .word 82 |
787 |
++ .byte 8 |
788 |
++ .byte 8 |
789 |
++ .popsection |
790 |
++ .endm |
791 |
++ |
792 |
++#ifdef CONFIG_EXPOLINE |
793 |
++ |
794 |
++ .macro GEN_BR_THUNK name,reg,tmp |
795 |
++ .section .text.\name,"axG",@progbits,\name,comdat |
796 |
++ .globl \name |
797 |
++ .hidden \name |
798 |
++ .type \name,@function |
799 |
++\name: |
800 |
++ .cfi_startproc |
801 |
++#ifdef CONFIG_HAVE_MARCH_Z10_FEATURES |
802 |
++ exrl 0,0f |
803 |
++#else |
804 |
++ larl \tmp,0f |
805 |
++ ex 0,0(\tmp) |
806 |
++#endif |
807 |
++ j . |
808 |
++0: br \reg |
809 |
++ .cfi_endproc |
810 |
++ .endm |
811 |
++ |
812 |
++ GEN_BR_THUNK __s390x_indirect_jump_r1use_r9,%r9,%r1 |
813 |
++ GEN_BR_THUNK __s390x_indirect_jump_r1use_r14,%r14,%r1 |
814 |
++ GEN_BR_THUNK __s390x_indirect_jump_r11use_r14,%r14,%r11 |
815 |
++ |
816 |
++ .macro BASR_R14_R9 |
817 |
++0: brasl %r14,__s390x_indirect_jump_r1use_r9 |
818 |
++ .pushsection .s390_indirect_branches,"a",@progbits |
819 |
++ .long 0b-. |
820 |
++ .popsection |
821 |
++ .endm |
822 |
++ |
823 |
++ .macro BR_R1USE_R14 |
824 |
++0: jg __s390x_indirect_jump_r1use_r14 |
825 |
++ .pushsection .s390_indirect_branches,"a",@progbits |
826 |
++ .long 0b-. |
827 |
++ .popsection |
828 |
++ .endm |
829 |
++ |
830 |
++ .macro BR_R11USE_R14 |
831 |
++0: jg __s390x_indirect_jump_r11use_r14 |
832 |
++ .pushsection .s390_indirect_branches,"a",@progbits |
833 |
++ .long 0b-. |
834 |
++ .popsection |
835 |
++ .endm |
836 |
++ |
837 |
++#else /* CONFIG_EXPOLINE */ |
838 |
++ |
839 |
++ .macro BASR_R14_R9 |
840 |
++ basr %r14,%r9 |
841 |
++ .endm |
842 |
++ |
843 |
++ .macro BR_R1USE_R14 |
844 |
++ br %r14 |
845 |
++ .endm |
846 |
++ |
847 |
++ .macro BR_R11USE_R14 |
848 |
++ br %r14 |
849 |
++ .endm |
850 |
++ |
851 |
++#endif /* CONFIG_EXPOLINE */ |
852 |
++ |
853 |
++ |
854 |
+ .section .kprobes.text, "ax" |
855 |
+ .Ldummy: |
856 |
+ /* |
857 |
+@@ -170,6 +295,11 @@ _PIF_WORK = (_PIF_PER_TRAP | _PIF_SYSCALL_RESTART) |
858 |
+ */ |
859 |
+ nop 0 |
860 |
+ |
861 |
++ENTRY(__bpon) |
862 |
++ .globl __bpon |
863 |
++ BPON |
864 |
++ BR_R1USE_R14 |
865 |
++ |
866 |
+ /* |
867 |
+ * Scheduler resume function, called by switch_to |
868 |
+ * gpr2 = (task_struct *) prev |
869 |
+@@ -193,9 +323,9 @@ ENTRY(__switch_to) |
870 |
+ mvc __LC_CURRENT_PID(4,%r0),__TASK_pid(%r3) # store pid of next |
871 |
+ lmg %r6,%r15,__SF_GPRS(%r15) # load gprs of next task |
872 |
+ TSTMSK __LC_MACHINE_FLAGS,MACHINE_FLAG_LPP |
873 |
+- bzr %r14 |
874 |
++ jz 0f |
875 |
+ .insn s,0xb2800000,__LC_LPP # set program parameter |
876 |
+- br %r14 |
877 |
++0: BR_R1USE_R14 |
878 |
+ |
879 |
+ .L__critical_start: |
880 |
+ |
881 |
+@@ -207,9 +337,11 @@ ENTRY(__switch_to) |
882 |
+ */ |
883 |
+ ENTRY(sie64a) |
884 |
+ stmg %r6,%r14,__SF_GPRS(%r15) # save kernel registers |
885 |
++ lg %r12,__LC_CURRENT |
886 |
+ stg %r2,__SF_EMPTY(%r15) # save control block pointer |
887 |
+ stg %r3,__SF_EMPTY+8(%r15) # save guest register save area |
888 |
+ xc __SF_EMPTY+16(8,%r15),__SF_EMPTY+16(%r15) # reason code = 0 |
889 |
++ mvc __SF_EMPTY+24(8,%r15),__TI_flags(%r12) # copy thread flags |
890 |
+ TSTMSK __LC_CPU_FLAGS,_CIF_FPU # load guest fp/vx registers ? |
891 |
+ jno .Lsie_load_guest_gprs |
892 |
+ brasl %r14,load_fpu_regs # load guest fp/vx regs |
893 |
+@@ -226,8 +358,12 @@ ENTRY(sie64a) |
894 |
+ jnz .Lsie_skip |
895 |
+ TSTMSK __LC_CPU_FLAGS,_CIF_FPU |
896 |
+ jo .Lsie_skip # exit if fp/vx regs changed |
897 |
++ BPEXIT __SF_EMPTY+24(%r15),(_TIF_ISOLATE_BP|_TIF_ISOLATE_BP_GUEST) |
898 |
+ .Lsie_entry: |
899 |
+ sie 0(%r14) |
900 |
++.Lsie_exit: |
901 |
++ BPOFF |
902 |
++ BPENTER __SF_EMPTY+24(%r15),(_TIF_ISOLATE_BP|_TIF_ISOLATE_BP_GUEST) |
903 |
+ .Lsie_skip: |
904 |
+ ni __SIE_PROG0C+3(%r14),0xfe # no longer in SIE |
905 |
+ lctlg %c1,%c1,__LC_USER_ASCE # load primary asce |
906 |
+@@ -248,9 +384,15 @@ ENTRY(sie64a) |
907 |
+ sie_exit: |
908 |
+ lg %r14,__SF_EMPTY+8(%r15) # load guest register save area |
909 |
+ stmg %r0,%r13,0(%r14) # save guest gprs 0-13 |
910 |
++ xgr %r0,%r0 # clear guest registers to |
911 |
++ xgr %r1,%r1 # prevent speculative use |
912 |
++ xgr %r2,%r2 |
913 |
++ xgr %r3,%r3 |
914 |
++ xgr %r4,%r4 |
915 |
++ xgr %r5,%r5 |
916 |
+ lmg %r6,%r14,__SF_GPRS(%r15) # restore kernel registers |
917 |
+ lg %r2,__SF_EMPTY+16(%r15) # return exit reason code |
918 |
+- br %r14 |
919 |
++ BR_R1USE_R14 |
920 |
+ .Lsie_fault: |
921 |
+ lghi %r14,-EFAULT |
922 |
+ stg %r14,__SF_EMPTY+16(%r15) # set exit reason code |
923 |
+@@ -273,6 +415,7 @@ ENTRY(system_call) |
924 |
+ stpt __LC_SYNC_ENTER_TIMER |
925 |
+ .Lsysc_stmg: |
926 |
+ stmg %r8,%r15,__LC_SAVE_AREA_SYNC |
927 |
++ BPOFF |
928 |
+ lg %r12,__LC_CURRENT |
929 |
+ lghi %r13,__TASK_thread |
930 |
+ lghi %r14,_PIF_SYSCALL |
931 |
+@@ -281,12 +424,15 @@ ENTRY(system_call) |
932 |
+ la %r11,STACK_FRAME_OVERHEAD(%r15) # pointer to pt_regs |
933 |
+ .Lsysc_vtime: |
934 |
+ UPDATE_VTIME %r8,%r9,__LC_SYNC_ENTER_TIMER |
935 |
++ BPENTER __TI_flags(%r12),_TIF_ISOLATE_BP |
936 |
+ stmg %r0,%r7,__PT_R0(%r11) |
937 |
+ mvc __PT_R8(64,%r11),__LC_SAVE_AREA_SYNC |
938 |
+ mvc __PT_PSW(16,%r11),__LC_SVC_OLD_PSW |
939 |
+ mvc __PT_INT_CODE(4,%r11),__LC_SVC_ILC |
940 |
+ stg %r14,__PT_FLAGS(%r11) |
941 |
+ .Lsysc_do_svc: |
942 |
++ # clear user controlled register to prevent speculative use |
943 |
++ xgr %r0,%r0 |
944 |
+ # load address of system call table |
945 |
+ lg %r10,__THREAD_sysc_table(%r13,%r12) |
946 |
+ llgh %r8,__PT_INT_CODE+2(%r11) |
947 |
+@@ -305,7 +451,7 @@ ENTRY(system_call) |
948 |
+ lgf %r9,0(%r8,%r10) # get system call add. |
949 |
+ TSTMSK __TI_flags(%r12),_TIF_TRACE |
950 |
+ jnz .Lsysc_tracesys |
951 |
+- basr %r14,%r9 # call sys_xxxx |
952 |
++ BASR_R14_R9 # call sys_xxxx |
953 |
+ stg %r2,__PT_R2(%r11) # store return value |
954 |
+ |
955 |
+ .Lsysc_return: |
956 |
+@@ -317,6 +463,7 @@ ENTRY(system_call) |
957 |
+ jnz .Lsysc_work # check for work |
958 |
+ TSTMSK __LC_CPU_FLAGS,_CIF_WORK |
959 |
+ jnz .Lsysc_work |
960 |
++ BPEXIT __TI_flags(%r12),_TIF_ISOLATE_BP |
961 |
+ .Lsysc_restore: |
962 |
+ lg %r14,__LC_VDSO_PER_CPU |
963 |
+ lmg %r0,%r10,__PT_R0(%r11) |
964 |
+@@ -481,7 +628,7 @@ ENTRY(system_call) |
965 |
+ lmg %r3,%r7,__PT_R3(%r11) |
966 |
+ stg %r7,STACK_FRAME_OVERHEAD(%r15) |
967 |
+ lg %r2,__PT_ORIG_GPR2(%r11) |
968 |
+- basr %r14,%r9 # call sys_xxx |
969 |
++ BASR_R14_R9 # call sys_xxx |
970 |
+ stg %r2,__PT_R2(%r11) # store return value |
971 |
+ .Lsysc_tracenogo: |
972 |
+ TSTMSK __TI_flags(%r12),_TIF_TRACE |
973 |
+@@ -505,7 +652,7 @@ ENTRY(ret_from_fork) |
974 |
+ lmg %r9,%r10,__PT_R9(%r11) # load gprs |
975 |
+ ENTRY(kernel_thread_starter) |
976 |
+ la %r2,0(%r10) |
977 |
+- basr %r14,%r9 |
978 |
++ BASR_R14_R9 |
979 |
+ j .Lsysc_tracenogo |
980 |
+ |
981 |
+ /* |
982 |
+@@ -514,6 +661,7 @@ ENTRY(kernel_thread_starter) |
983 |
+ |
984 |
+ ENTRY(pgm_check_handler) |
985 |
+ stpt __LC_SYNC_ENTER_TIMER |
986 |
++ BPOFF |
987 |
+ stmg %r8,%r15,__LC_SAVE_AREA_SYNC |
988 |
+ lg %r10,__LC_LAST_BREAK |
989 |
+ lg %r12,__LC_CURRENT |
990 |
+@@ -540,6 +688,7 @@ ENTRY(pgm_check_handler) |
991 |
+ aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE) |
992 |
+ j 4f |
993 |
+ 2: UPDATE_VTIME %r14,%r15,__LC_SYNC_ENTER_TIMER |
994 |
++ BPENTER __TI_flags(%r12),_TIF_ISOLATE_BP |
995 |
+ lg %r15,__LC_KERNEL_STACK |
996 |
+ lgr %r14,%r12 |
997 |
+ aghi %r14,__TASK_thread # pointer to thread_struct |
998 |
+@@ -550,6 +699,15 @@ ENTRY(pgm_check_handler) |
999 |
+ 3: stg %r10,__THREAD_last_break(%r14) |
1000 |
+ 4: la %r11,STACK_FRAME_OVERHEAD(%r15) |
1001 |
+ stmg %r0,%r7,__PT_R0(%r11) |
1002 |
++ # clear user controlled registers to prevent speculative use |
1003 |
++ xgr %r0,%r0 |
1004 |
++ xgr %r1,%r1 |
1005 |
++ xgr %r2,%r2 |
1006 |
++ xgr %r3,%r3 |
1007 |
++ xgr %r4,%r4 |
1008 |
++ xgr %r5,%r5 |
1009 |
++ xgr %r6,%r6 |
1010 |
++ xgr %r7,%r7 |
1011 |
+ mvc __PT_R8(64,%r11),__LC_SAVE_AREA_SYNC |
1012 |
+ stmg %r8,%r9,__PT_PSW(%r11) |
1013 |
+ mvc __PT_INT_CODE(4,%r11),__LC_PGM_ILC |
1014 |
+@@ -571,9 +729,9 @@ ENTRY(pgm_check_handler) |
1015 |
+ nill %r10,0x007f |
1016 |
+ sll %r10,2 |
1017 |
+ je .Lpgm_return |
1018 |
+- lgf %r1,0(%r10,%r1) # load address of handler routine |
1019 |
++ lgf %r9,0(%r10,%r1) # load address of handler routine |
1020 |
+ lgr %r2,%r11 # pass pointer to pt_regs |
1021 |
+- basr %r14,%r1 # branch to interrupt-handler |
1022 |
++ BASR_R14_R9 # branch to interrupt-handler |
1023 |
+ .Lpgm_return: |
1024 |
+ LOCKDEP_SYS_EXIT |
1025 |
+ tm __PT_PSW+1(%r11),0x01 # returning to user ? |
1026 |
+@@ -609,12 +767,23 @@ ENTRY(pgm_check_handler) |
1027 |
+ ENTRY(io_int_handler) |
1028 |
+ STCK __LC_INT_CLOCK |
1029 |
+ stpt __LC_ASYNC_ENTER_TIMER |
1030 |
++ BPOFF |
1031 |
+ stmg %r8,%r15,__LC_SAVE_AREA_ASYNC |
1032 |
+ lg %r12,__LC_CURRENT |
1033 |
+ larl %r13,cleanup_critical |
1034 |
+ lmg %r8,%r9,__LC_IO_OLD_PSW |
1035 |
+ SWITCH_ASYNC __LC_SAVE_AREA_ASYNC,__LC_ASYNC_ENTER_TIMER |
1036 |
+ stmg %r0,%r7,__PT_R0(%r11) |
1037 |
++ # clear user controlled registers to prevent speculative use |
1038 |
++ xgr %r0,%r0 |
1039 |
++ xgr %r1,%r1 |
1040 |
++ xgr %r2,%r2 |
1041 |
++ xgr %r3,%r3 |
1042 |
++ xgr %r4,%r4 |
1043 |
++ xgr %r5,%r5 |
1044 |
++ xgr %r6,%r6 |
1045 |
++ xgr %r7,%r7 |
1046 |
++ xgr %r10,%r10 |
1047 |
+ mvc __PT_R8(64,%r11),__LC_SAVE_AREA_ASYNC |
1048 |
+ stmg %r8,%r9,__PT_PSW(%r11) |
1049 |
+ mvc __PT_INT_CODE(12,%r11),__LC_SUBCHANNEL_ID |
1050 |
+@@ -649,9 +818,13 @@ ENTRY(io_int_handler) |
1051 |
+ lg %r14,__LC_VDSO_PER_CPU |
1052 |
+ lmg %r0,%r10,__PT_R0(%r11) |
1053 |
+ mvc __LC_RETURN_PSW(16),__PT_PSW(%r11) |
1054 |
++ tm __PT_PSW+1(%r11),0x01 # returning to user ? |
1055 |
++ jno .Lio_exit_kernel |
1056 |
++ BPEXIT __TI_flags(%r12),_TIF_ISOLATE_BP |
1057 |
+ .Lio_exit_timer: |
1058 |
+ stpt __LC_EXIT_TIMER |
1059 |
+ mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER |
1060 |
++.Lio_exit_kernel: |
1061 |
+ lmg %r11,%r15,__PT_R11(%r11) |
1062 |
+ lpswe __LC_RETURN_PSW |
1063 |
+ .Lio_done: |
1064 |
+@@ -814,12 +987,23 @@ ENTRY(io_int_handler) |
1065 |
+ ENTRY(ext_int_handler) |
1066 |
+ STCK __LC_INT_CLOCK |
1067 |
+ stpt __LC_ASYNC_ENTER_TIMER |
1068 |
++ BPOFF |
1069 |
+ stmg %r8,%r15,__LC_SAVE_AREA_ASYNC |
1070 |
+ lg %r12,__LC_CURRENT |
1071 |
+ larl %r13,cleanup_critical |
1072 |
+ lmg %r8,%r9,__LC_EXT_OLD_PSW |
1073 |
+ SWITCH_ASYNC __LC_SAVE_AREA_ASYNC,__LC_ASYNC_ENTER_TIMER |
1074 |
+ stmg %r0,%r7,__PT_R0(%r11) |
1075 |
++ # clear user controlled registers to prevent speculative use |
1076 |
++ xgr %r0,%r0 |
1077 |
++ xgr %r1,%r1 |
1078 |
++ xgr %r2,%r2 |
1079 |
++ xgr %r3,%r3 |
1080 |
++ xgr %r4,%r4 |
1081 |
++ xgr %r5,%r5 |
1082 |
++ xgr %r6,%r6 |
1083 |
++ xgr %r7,%r7 |
1084 |
++ xgr %r10,%r10 |
1085 |
+ mvc __PT_R8(64,%r11),__LC_SAVE_AREA_ASYNC |
1086 |
+ stmg %r8,%r9,__PT_PSW(%r11) |
1087 |
+ lghi %r1,__LC_EXT_PARAMS2 |
1088 |
+@@ -852,11 +1036,12 @@ ENTRY(psw_idle) |
1089 |
+ .Lpsw_idle_stcctm: |
1090 |
+ #endif |
1091 |
+ oi __LC_CPU_FLAGS+7,_CIF_ENABLED_WAIT |
1092 |
++ BPON |
1093 |
+ STCK __CLOCK_IDLE_ENTER(%r2) |
1094 |
+ stpt __TIMER_IDLE_ENTER(%r2) |
1095 |
+ .Lpsw_idle_lpsw: |
1096 |
+ lpswe __SF_EMPTY(%r15) |
1097 |
+- br %r14 |
1098 |
++ BR_R1USE_R14 |
1099 |
+ .Lpsw_idle_end: |
1100 |
+ |
1101 |
+ /* |
1102 |
+@@ -870,7 +1055,7 @@ ENTRY(save_fpu_regs) |
1103 |
+ lg %r2,__LC_CURRENT |
1104 |
+ aghi %r2,__TASK_thread |
1105 |
+ TSTMSK __LC_CPU_FLAGS,_CIF_FPU |
1106 |
+- bor %r14 |
1107 |
++ jo .Lsave_fpu_regs_exit |
1108 |
+ stfpc __THREAD_FPU_fpc(%r2) |
1109 |
+ lg %r3,__THREAD_FPU_regs(%r2) |
1110 |
+ TSTMSK __LC_MACHINE_FLAGS,MACHINE_FLAG_VX |
1111 |
+@@ -897,7 +1082,8 @@ ENTRY(save_fpu_regs) |
1112 |
+ std 15,120(%r3) |
1113 |
+ .Lsave_fpu_regs_done: |
1114 |
+ oi __LC_CPU_FLAGS+7,_CIF_FPU |
1115 |
+- br %r14 |
1116 |
++.Lsave_fpu_regs_exit: |
1117 |
++ BR_R1USE_R14 |
1118 |
+ .Lsave_fpu_regs_end: |
1119 |
+ EXPORT_SYMBOL(save_fpu_regs) |
1120 |
+ |
1121 |
+@@ -915,7 +1101,7 @@ load_fpu_regs: |
1122 |
+ lg %r4,__LC_CURRENT |
1123 |
+ aghi %r4,__TASK_thread |
1124 |
+ TSTMSK __LC_CPU_FLAGS,_CIF_FPU |
1125 |
+- bnor %r14 |
1126 |
++ jno .Lload_fpu_regs_exit |
1127 |
+ lfpc __THREAD_FPU_fpc(%r4) |
1128 |
+ TSTMSK __LC_MACHINE_FLAGS,MACHINE_FLAG_VX |
1129 |
+ lg %r4,__THREAD_FPU_regs(%r4) # %r4 <- reg save area |
1130 |
+@@ -942,7 +1128,8 @@ load_fpu_regs: |
1131 |
+ ld 15,120(%r4) |
1132 |
+ .Lload_fpu_regs_done: |
1133 |
+ ni __LC_CPU_FLAGS+7,255-_CIF_FPU |
1134 |
+- br %r14 |
1135 |
++.Lload_fpu_regs_exit: |
1136 |
++ BR_R1USE_R14 |
1137 |
+ .Lload_fpu_regs_end: |
1138 |
+ |
1139 |
+ .L__critical_end: |
1140 |
+@@ -952,6 +1139,7 @@ load_fpu_regs: |
1141 |
+ */ |
1142 |
+ ENTRY(mcck_int_handler) |
1143 |
+ STCK __LC_MCCK_CLOCK |
1144 |
++ BPOFF |
1145 |
+ la %r1,4095 # revalidate r1 |
1146 |
+ spt __LC_CPU_TIMER_SAVE_AREA-4095(%r1) # revalidate cpu timer |
1147 |
+ lmg %r0,%r15,__LC_GPREGS_SAVE_AREA-4095(%r1)# revalidate gprs |
1148 |
+@@ -982,6 +1170,16 @@ ENTRY(mcck_int_handler) |
1149 |
+ .Lmcck_skip: |
1150 |
+ lghi %r14,__LC_GPREGS_SAVE_AREA+64 |
1151 |
+ stmg %r0,%r7,__PT_R0(%r11) |
1152 |
++ # clear user controlled registers to prevent speculative use |
1153 |
++ xgr %r0,%r0 |
1154 |
++ xgr %r1,%r1 |
1155 |
++ xgr %r2,%r2 |
1156 |
++ xgr %r3,%r3 |
1157 |
++ xgr %r4,%r4 |
1158 |
++ xgr %r5,%r5 |
1159 |
++ xgr %r6,%r6 |
1160 |
++ xgr %r7,%r7 |
1161 |
++ xgr %r10,%r10 |
1162 |
+ mvc __PT_R8(64,%r11),0(%r14) |
1163 |
+ stmg %r8,%r9,__PT_PSW(%r11) |
1164 |
+ xc __PT_FLAGS(8,%r11),__PT_FLAGS(%r11) |
1165 |
+@@ -1007,6 +1205,7 @@ ENTRY(mcck_int_handler) |
1166 |
+ mvc __LC_RETURN_MCCK_PSW(16),__PT_PSW(%r11) # move return PSW |
1167 |
+ tm __LC_RETURN_MCCK_PSW+1,0x01 # returning to user ? |
1168 |
+ jno 0f |
1169 |
++ BPEXIT __TI_flags(%r12),_TIF_ISOLATE_BP |
1170 |
+ stpt __LC_EXIT_TIMER |
1171 |
+ mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER |
1172 |
+ 0: lmg %r11,%r15,__PT_R11(%r11) |
1173 |
+@@ -1102,7 +1301,7 @@ cleanup_critical: |
1174 |
+ jl 0f |
1175 |
+ clg %r9,BASED(.Lcleanup_table+104) # .Lload_fpu_regs_end |
1176 |
+ jl .Lcleanup_load_fpu_regs |
1177 |
+-0: br %r14 |
1178 |
++0: BR_R11USE_R14 |
1179 |
+ |
1180 |
+ .align 8 |
1181 |
+ .Lcleanup_table: |
1182 |
+@@ -1133,11 +1332,12 @@ cleanup_critical: |
1183 |
+ clg %r9,BASED(.Lsie_crit_mcck_length) |
1184 |
+ jh 1f |
1185 |
+ oi __LC_CPU_FLAGS+7, _CIF_MCCK_GUEST |
1186 |
+-1: lg %r9,__SF_EMPTY(%r15) # get control block pointer |
1187 |
++1: BPENTER __SF_EMPTY+24(%r15),(_TIF_ISOLATE_BP|_TIF_ISOLATE_BP_GUEST) |
1188 |
++ lg %r9,__SF_EMPTY(%r15) # get control block pointer |
1189 |
+ ni __SIE_PROG0C+3(%r9),0xfe # no longer in SIE |
1190 |
+ lctlg %c1,%c1,__LC_USER_ASCE # load primary asce |
1191 |
+ larl %r9,sie_exit # skip forward to sie_exit |
1192 |
+- br %r14 |
1193 |
++ BR_R11USE_R14 |
1194 |
+ #endif |
1195 |
+ |
1196 |
+ .Lcleanup_system_call: |
1197 |
+@@ -1175,6 +1375,7 @@ cleanup_critical: |
1198 |
+ stg %r15,__LC_SYSTEM_TIMER |
1199 |
+ 0: # update accounting time stamp |
1200 |
+ mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER |
1201 |
++ BPENTER __TI_flags(%r12),_TIF_ISOLATE_BP |
1202 |
+ # set up saved register r11 |
1203 |
+ lg %r15,__LC_KERNEL_STACK |
1204 |
+ la %r9,STACK_FRAME_OVERHEAD(%r15) |
1205 |
+@@ -1190,7 +1391,7 @@ cleanup_critical: |
1206 |
+ stg %r15,56(%r11) # r15 stack pointer |
1207 |
+ # set new psw address and exit |
1208 |
+ larl %r9,.Lsysc_do_svc |
1209 |
+- br %r14 |
1210 |
++ BR_R11USE_R14 |
1211 |
+ .Lcleanup_system_call_insn: |
1212 |
+ .quad system_call |
1213 |
+ .quad .Lsysc_stmg |
1214 |
+@@ -1202,7 +1403,7 @@ cleanup_critical: |
1215 |
+ |
1216 |
+ .Lcleanup_sysc_tif: |
1217 |
+ larl %r9,.Lsysc_tif |
1218 |
+- br %r14 |
1219 |
++ BR_R11USE_R14 |
1220 |
+ |
1221 |
+ .Lcleanup_sysc_restore: |
1222 |
+ # check if stpt has been executed |
1223 |
+@@ -1219,14 +1420,14 @@ cleanup_critical: |
1224 |
+ mvc 0(64,%r11),__PT_R8(%r9) |
1225 |
+ lmg %r0,%r7,__PT_R0(%r9) |
1226 |
+ 1: lmg %r8,%r9,__LC_RETURN_PSW |
1227 |
+- br %r14 |
1228 |
++ BR_R11USE_R14 |
1229 |
+ .Lcleanup_sysc_restore_insn: |
1230 |
+ .quad .Lsysc_exit_timer |
1231 |
+ .quad .Lsysc_done - 4 |
1232 |
+ |
1233 |
+ .Lcleanup_io_tif: |
1234 |
+ larl %r9,.Lio_tif |
1235 |
+- br %r14 |
1236 |
++ BR_R11USE_R14 |
1237 |
+ |
1238 |
+ .Lcleanup_io_restore: |
1239 |
+ # check if stpt has been executed |
1240 |
+@@ -1240,7 +1441,7 @@ cleanup_critical: |
1241 |
+ mvc 0(64,%r11),__PT_R8(%r9) |
1242 |
+ lmg %r0,%r7,__PT_R0(%r9) |
1243 |
+ 1: lmg %r8,%r9,__LC_RETURN_PSW |
1244 |
+- br %r14 |
1245 |
++ BR_R11USE_R14 |
1246 |
+ .Lcleanup_io_restore_insn: |
1247 |
+ .quad .Lio_exit_timer |
1248 |
+ .quad .Lio_done - 4 |
1249 |
+@@ -1293,17 +1494,17 @@ cleanup_critical: |
1250 |
+ # prepare return psw |
1251 |
+ nihh %r8,0xfcfd # clear irq & wait state bits |
1252 |
+ lg %r9,48(%r11) # return from psw_idle |
1253 |
+- br %r14 |
1254 |
++ BR_R11USE_R14 |
1255 |
+ .Lcleanup_idle_insn: |
1256 |
+ .quad .Lpsw_idle_lpsw |
1257 |
+ |
1258 |
+ .Lcleanup_save_fpu_regs: |
1259 |
+ larl %r9,save_fpu_regs |
1260 |
+- br %r14 |
1261 |
++ BR_R11USE_R14 |
1262 |
+ |
1263 |
+ .Lcleanup_load_fpu_regs: |
1264 |
+ larl %r9,load_fpu_regs |
1265 |
+- br %r14 |
1266 |
++ BR_R11USE_R14 |
1267 |
+ |
1268 |
+ /* |
1269 |
+ * Integer constants |
1270 |
+@@ -1323,7 +1524,6 @@ cleanup_critical: |
1271 |
+ .Lsie_crit_mcck_length: |
1272 |
+ .quad .Lsie_skip - .Lsie_entry |
1273 |
+ #endif |
1274 |
+- |
1275 |
+ .section .rodata, "a" |
1276 |
+ #define SYSCALL(esame,emu) .long esame |
1277 |
+ .globl sys_call_table |
1278 |
+diff --git a/arch/s390/kernel/ipl.c b/arch/s390/kernel/ipl.c |
1279 |
+index d1a0e2c521d7..b565e784bae8 100644 |
1280 |
+--- a/arch/s390/kernel/ipl.c |
1281 |
++++ b/arch/s390/kernel/ipl.c |
1282 |
+@@ -564,6 +564,7 @@ static struct kset *ipl_kset; |
1283 |
+ |
1284 |
+ static void __ipl_run(void *unused) |
1285 |
+ { |
1286 |
++ __bpon(); |
1287 |
+ diag308(DIAG308_LOAD_CLEAR, NULL); |
1288 |
+ if (MACHINE_IS_VM) |
1289 |
+ __cpcmd("IPL", NULL, 0, NULL); |
1290 |
+diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c |
1291 |
+index 1a27f307a920..b441e069e674 100644 |
1292 |
+--- a/arch/s390/kernel/module.c |
1293 |
++++ b/arch/s390/kernel/module.c |
1294 |
+@@ -31,6 +31,9 @@ |
1295 |
+ #include <linux/kernel.h> |
1296 |
+ #include <linux/moduleloader.h> |
1297 |
+ #include <linux/bug.h> |
1298 |
++#include <asm/alternative.h> |
1299 |
++#include <asm/nospec-branch.h> |
1300 |
++#include <asm/facility.h> |
1301 |
+ |
1302 |
+ #if 0 |
1303 |
+ #define DEBUGP printk |
1304 |
+@@ -168,7 +171,11 @@ int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs, |
1305 |
+ me->arch.got_offset = me->core_layout.size; |
1306 |
+ me->core_layout.size += me->arch.got_size; |
1307 |
+ me->arch.plt_offset = me->core_layout.size; |
1308 |
+- me->core_layout.size += me->arch.plt_size; |
1309 |
++ if (me->arch.plt_size) { |
1310 |
++ if (IS_ENABLED(CONFIG_EXPOLINE) && !nospec_disable) |
1311 |
++ me->arch.plt_size += PLT_ENTRY_SIZE; |
1312 |
++ me->core_layout.size += me->arch.plt_size; |
1313 |
++ } |
1314 |
+ return 0; |
1315 |
+ } |
1316 |
+ |
1317 |
+@@ -322,9 +329,20 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab, |
1318 |
+ unsigned int *ip; |
1319 |
+ ip = me->core_layout.base + me->arch.plt_offset + |
1320 |
+ info->plt_offset; |
1321 |
+- ip[0] = 0x0d10e310; /* basr 1,0; lg 1,10(1); br 1 */ |
1322 |
+- ip[1] = 0x100a0004; |
1323 |
+- ip[2] = 0x07f10000; |
1324 |
++ ip[0] = 0x0d10e310; /* basr 1,0 */ |
1325 |
++ ip[1] = 0x100a0004; /* lg 1,10(1) */ |
1326 |
++ if (IS_ENABLED(CONFIG_EXPOLINE) && !nospec_disable) { |
1327 |
++ unsigned int *ij; |
1328 |
++ ij = me->core_layout.base + |
1329 |
++ me->arch.plt_offset + |
1330 |
++ me->arch.plt_size - PLT_ENTRY_SIZE; |
1331 |
++ ip[2] = 0xa7f40000 + /* j __jump_r1 */ |
1332 |
++ (unsigned int)(u16) |
1333 |
++ (((unsigned long) ij - 8 - |
1334 |
++ (unsigned long) ip) / 2); |
1335 |
++ } else { |
1336 |
++ ip[2] = 0x07f10000; /* br %r1 */ |
1337 |
++ } |
1338 |
+ ip[3] = (unsigned int) (val >> 32); |
1339 |
+ ip[4] = (unsigned int) val; |
1340 |
+ info->plt_initialized = 1; |
1341 |
+@@ -429,6 +447,45 @@ int module_finalize(const Elf_Ehdr *hdr, |
1342 |
+ const Elf_Shdr *sechdrs, |
1343 |
+ struct module *me) |
1344 |
+ { |
1345 |
++ const Elf_Shdr *s; |
1346 |
++ char *secstrings, *secname; |
1347 |
++ void *aseg; |
1348 |
++ |
1349 |
++ if (IS_ENABLED(CONFIG_EXPOLINE) && |
1350 |
++ !nospec_disable && me->arch.plt_size) { |
1351 |
++ unsigned int *ij; |
1352 |
++ |
1353 |
++ ij = me->core_layout.base + me->arch.plt_offset + |
1354 |
++ me->arch.plt_size - PLT_ENTRY_SIZE; |
1355 |
++ if (test_facility(35)) { |
1356 |
++ ij[0] = 0xc6000000; /* exrl %r0,.+10 */ |
1357 |
++ ij[1] = 0x0005a7f4; /* j . */ |
1358 |
++ ij[2] = 0x000007f1; /* br %r1 */ |
1359 |
++ } else { |
1360 |
++ ij[0] = 0x44000000 | (unsigned int) |
1361 |
++ offsetof(struct lowcore, br_r1_trampoline); |
1362 |
++ ij[1] = 0xa7f40000; /* j . */ |
1363 |
++ } |
1364 |
++ } |
1365 |
++ |
1366 |
++ secstrings = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset; |
1367 |
++ for (s = sechdrs; s < sechdrs + hdr->e_shnum; s++) { |
1368 |
++ aseg = (void *) s->sh_addr; |
1369 |
++ secname = secstrings + s->sh_name; |
1370 |
++ |
1371 |
++ if (!strcmp(".altinstructions", secname)) |
1372 |
++ /* patch .altinstructions */ |
1373 |
++ apply_alternatives(aseg, aseg + s->sh_size); |
1374 |
++ |
1375 |
++ if (IS_ENABLED(CONFIG_EXPOLINE) && |
1376 |
++ (!strncmp(".s390_indirect", secname, 14))) |
1377 |
++ nospec_revert(aseg, aseg + s->sh_size); |
1378 |
++ |
1379 |
++ if (IS_ENABLED(CONFIG_EXPOLINE) && |
1380 |
++ (!strncmp(".s390_return", secname, 12))) |
1381 |
++ nospec_revert(aseg, aseg + s->sh_size); |
1382 |
++ } |
1383 |
++ |
1384 |
+ jump_label_apply_nops(me); |
1385 |
+ return 0; |
1386 |
+ } |
1387 |
+diff --git a/arch/s390/kernel/nospec-branch.c b/arch/s390/kernel/nospec-branch.c |
1388 |
+new file mode 100644 |
1389 |
+index 000000000000..9f3b5b382743 |
1390 |
+--- /dev/null |
1391 |
++++ b/arch/s390/kernel/nospec-branch.c |
1392 |
+@@ -0,0 +1,169 @@ |
1393 |
++// SPDX-License-Identifier: GPL-2.0 |
1394 |
++#include <linux/module.h> |
1395 |
++#include <linux/device.h> |
1396 |
++#include <asm/facility.h> |
1397 |
++#include <asm/nospec-branch.h> |
1398 |
++ |
1399 |
++static int __init nobp_setup_early(char *str) |
1400 |
++{ |
1401 |
++ bool enabled; |
1402 |
++ int rc; |
1403 |
++ |
1404 |
++ rc = kstrtobool(str, &enabled); |
1405 |
++ if (rc) |
1406 |
++ return rc; |
1407 |
++ if (enabled && test_facility(82)) { |
1408 |
++ /* |
1409 |
++ * The user explicitely requested nobp=1, enable it and |
1410 |
++ * disable the expoline support. |
1411 |
++ */ |
1412 |
++ __set_facility(82, S390_lowcore.alt_stfle_fac_list); |
1413 |
++ if (IS_ENABLED(CONFIG_EXPOLINE)) |
1414 |
++ nospec_disable = 1; |
1415 |
++ } else { |
1416 |
++ __clear_facility(82, S390_lowcore.alt_stfle_fac_list); |
1417 |
++ } |
1418 |
++ return 0; |
1419 |
++} |
1420 |
++early_param("nobp", nobp_setup_early); |
1421 |
++ |
1422 |
++static int __init nospec_setup_early(char *str) |
1423 |
++{ |
1424 |
++ __clear_facility(82, S390_lowcore.alt_stfle_fac_list); |
1425 |
++ return 0; |
1426 |
++} |
1427 |
++early_param("nospec", nospec_setup_early); |
1428 |
++ |
1429 |
++static int __init nospec_report(void) |
1430 |
++{ |
1431 |
++ if (IS_ENABLED(CC_USING_EXPOLINE) && !nospec_disable) |
1432 |
++ pr_info("Spectre V2 mitigation: execute trampolines.\n"); |
1433 |
++ if (__test_facility(82, S390_lowcore.alt_stfle_fac_list)) |
1434 |
++ pr_info("Spectre V2 mitigation: limited branch prediction.\n"); |
1435 |
++ return 0; |
1436 |
++} |
1437 |
++arch_initcall(nospec_report); |
1438 |
++ |
1439 |
++#ifdef CONFIG_SYSFS |
1440 |
++ssize_t cpu_show_spectre_v1(struct device *dev, |
1441 |
++ struct device_attribute *attr, char *buf) |
1442 |
++{ |
1443 |
++ return sprintf(buf, "Mitigation: __user pointer sanitization\n"); |
1444 |
++} |
1445 |
++ |
1446 |
++ssize_t cpu_show_spectre_v2(struct device *dev, |
1447 |
++ struct device_attribute *attr, char *buf) |
1448 |
++{ |
1449 |
++ if (IS_ENABLED(CC_USING_EXPOLINE) && !nospec_disable) |
1450 |
++ return sprintf(buf, "Mitigation: execute trampolines\n"); |
1451 |
++ if (__test_facility(82, S390_lowcore.alt_stfle_fac_list)) |
1452 |
++ return sprintf(buf, "Mitigation: limited branch prediction.\n"); |
1453 |
++ return sprintf(buf, "Vulnerable\n"); |
1454 |
++} |
1455 |
++#endif |
1456 |
++ |
1457 |
++#ifdef CONFIG_EXPOLINE |
1458 |
++ |
1459 |
++int nospec_disable = IS_ENABLED(CONFIG_EXPOLINE_OFF); |
1460 |
++ |
1461 |
++static int __init nospectre_v2_setup_early(char *str) |
1462 |
++{ |
1463 |
++ nospec_disable = 1; |
1464 |
++ return 0; |
1465 |
++} |
1466 |
++early_param("nospectre_v2", nospectre_v2_setup_early); |
1467 |
++ |
1468 |
++void __init nospec_auto_detect(void) |
1469 |
++{ |
1470 |
++ if (IS_ENABLED(CC_USING_EXPOLINE)) { |
1471 |
++ /* |
1472 |
++ * The kernel has been compiled with expolines. |
1473 |
++ * Keep expolines enabled and disable nobp. |
1474 |
++ */ |
1475 |
++ nospec_disable = 0; |
1476 |
++ __clear_facility(82, S390_lowcore.alt_stfle_fac_list); |
1477 |
++ } |
1478 |
++ /* |
1479 |
++ * If the kernel has not been compiled with expolines the |
1480 |
++ * nobp setting decides what is done, this depends on the |
1481 |
++ * CONFIG_KERNEL_NP option and the nobp/nospec parameters. |
1482 |
++ */ |
1483 |
++} |
1484 |
++ |
1485 |
++static int __init spectre_v2_setup_early(char *str) |
1486 |
++{ |
1487 |
++ if (str && !strncmp(str, "on", 2)) { |
1488 |
++ nospec_disable = 0; |
1489 |
++ __clear_facility(82, S390_lowcore.alt_stfle_fac_list); |
1490 |
++ } |
1491 |
++ if (str && !strncmp(str, "off", 3)) |
1492 |
++ nospec_disable = 1; |
1493 |
++ if (str && !strncmp(str, "auto", 4)) |
1494 |
++ nospec_auto_detect(); |
1495 |
++ return 0; |
1496 |
++} |
1497 |
++early_param("spectre_v2", spectre_v2_setup_early); |
1498 |
++ |
1499 |
++static void __init_or_module __nospec_revert(s32 *start, s32 *end) |
1500 |
++{ |
1501 |
++ enum { BRCL_EXPOLINE, BRASL_EXPOLINE } type; |
1502 |
++ u8 *instr, *thunk, *br; |
1503 |
++ u8 insnbuf[6]; |
1504 |
++ s32 *epo; |
1505 |
++ |
1506 |
++ /* Second part of the instruction replace is always a nop */ |
1507 |
++ memcpy(insnbuf + 2, (char[]) { 0x47, 0x00, 0x00, 0x00 }, 4); |
1508 |
++ for (epo = start; epo < end; epo++) { |
1509 |
++ instr = (u8 *) epo + *epo; |
1510 |
++ if (instr[0] == 0xc0 && (instr[1] & 0x0f) == 0x04) |
1511 |
++ type = BRCL_EXPOLINE; /* brcl instruction */ |
1512 |
++ else if (instr[0] == 0xc0 && (instr[1] & 0x0f) == 0x05) |
1513 |
++ type = BRASL_EXPOLINE; /* brasl instruction */ |
1514 |
++ else |
1515 |
++ continue; |
1516 |
++ thunk = instr + (*(int *)(instr + 2)) * 2; |
1517 |
++ if (thunk[0] == 0xc6 && thunk[1] == 0x00) |
1518 |
++ /* exrl %r0,<target-br> */ |
1519 |
++ br = thunk + (*(int *)(thunk + 2)) * 2; |
1520 |
++ else if (thunk[0] == 0xc0 && (thunk[1] & 0x0f) == 0x00 && |
1521 |
++ thunk[6] == 0x44 && thunk[7] == 0x00 && |
1522 |
++ (thunk[8] & 0x0f) == 0x00 && thunk[9] == 0x00 && |
1523 |
++ (thunk[1] & 0xf0) == (thunk[8] & 0xf0)) |
1524 |
++ /* larl %rx,<target br> + ex %r0,0(%rx) */ |
1525 |
++ br = thunk + (*(int *)(thunk + 2)) * 2; |
1526 |
++ else |
1527 |
++ continue; |
1528 |
++ if (br[0] != 0x07 || (br[1] & 0xf0) != 0xf0) |
1529 |
++ continue; |
1530 |
++ switch (type) { |
1531 |
++ case BRCL_EXPOLINE: |
1532 |
++ /* brcl to thunk, replace with br + nop */ |
1533 |
++ insnbuf[0] = br[0]; |
1534 |
++ insnbuf[1] = (instr[1] & 0xf0) | (br[1] & 0x0f); |
1535 |
++ break; |
1536 |
++ case BRASL_EXPOLINE: |
1537 |
++ /* brasl to thunk, replace with basr + nop */ |
1538 |
++ insnbuf[0] = 0x0d; |
1539 |
++ insnbuf[1] = (instr[1] & 0xf0) | (br[1] & 0x0f); |
1540 |
++ break; |
1541 |
++ } |
1542 |
++ |
1543 |
++ s390_kernel_write(instr, insnbuf, 6); |
1544 |
++ } |
1545 |
++} |
1546 |
++ |
1547 |
++void __init_or_module nospec_revert(s32 *start, s32 *end) |
1548 |
++{ |
1549 |
++ if (nospec_disable) |
1550 |
++ __nospec_revert(start, end); |
1551 |
++} |
1552 |
++ |
1553 |
++extern s32 __nospec_call_start[], __nospec_call_end[]; |
1554 |
++extern s32 __nospec_return_start[], __nospec_return_end[]; |
1555 |
++void __init nospec_init_branches(void) |
1556 |
++{ |
1557 |
++ nospec_revert(__nospec_call_start, __nospec_call_end); |
1558 |
++ nospec_revert(__nospec_return_start, __nospec_return_end); |
1559 |
++} |
1560 |
++ |
1561 |
++#endif /* CONFIG_EXPOLINE */ |
1562 |
+diff --git a/arch/s390/kernel/processor.c b/arch/s390/kernel/processor.c |
1563 |
+index 5362fd868d0d..6fe2e1875058 100644 |
1564 |
+--- a/arch/s390/kernel/processor.c |
1565 |
++++ b/arch/s390/kernel/processor.c |
1566 |
+@@ -197,3 +197,21 @@ const struct seq_operations cpuinfo_op = { |
1567 |
+ .stop = c_stop, |
1568 |
+ .show = show_cpuinfo, |
1569 |
+ }; |
1570 |
++ |
1571 |
++int s390_isolate_bp(void) |
1572 |
++{ |
1573 |
++ if (!test_facility(82)) |
1574 |
++ return -EOPNOTSUPP; |
1575 |
++ set_thread_flag(TIF_ISOLATE_BP); |
1576 |
++ return 0; |
1577 |
++} |
1578 |
++EXPORT_SYMBOL(s390_isolate_bp); |
1579 |
++ |
1580 |
++int s390_isolate_bp_guest(void) |
1581 |
++{ |
1582 |
++ if (!test_facility(82)) |
1583 |
++ return -EOPNOTSUPP; |
1584 |
++ set_thread_flag(TIF_ISOLATE_BP_GUEST); |
1585 |
++ return 0; |
1586 |
++} |
1587 |
++EXPORT_SYMBOL(s390_isolate_bp_guest); |
1588 |
+diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c |
1589 |
+index 164a1e16b53e..98c1f7941142 100644 |
1590 |
+--- a/arch/s390/kernel/setup.c |
1591 |
++++ b/arch/s390/kernel/setup.c |
1592 |
+@@ -66,6 +66,8 @@ |
1593 |
+ #include <asm/sclp.h> |
1594 |
+ #include <asm/sysinfo.h> |
1595 |
+ #include <asm/numa.h> |
1596 |
++#include <asm/alternative.h> |
1597 |
++#include <asm/nospec-branch.h> |
1598 |
+ #include "entry.h" |
1599 |
+ |
1600 |
+ /* |
1601 |
+@@ -338,7 +340,9 @@ static void __init setup_lowcore(void) |
1602 |
+ lc->preempt_count = S390_lowcore.preempt_count; |
1603 |
+ lc->stfl_fac_list = S390_lowcore.stfl_fac_list; |
1604 |
+ memcpy(lc->stfle_fac_list, S390_lowcore.stfle_fac_list, |
1605 |
+- MAX_FACILITY_BIT/8); |
1606 |
++ sizeof(lc->stfle_fac_list)); |
1607 |
++ memcpy(lc->alt_stfle_fac_list, S390_lowcore.alt_stfle_fac_list, |
1608 |
++ sizeof(lc->alt_stfle_fac_list)); |
1609 |
+ if (MACHINE_HAS_VX || MACHINE_HAS_GS) { |
1610 |
+ unsigned long bits, size; |
1611 |
+ |
1612 |
+@@ -381,6 +385,7 @@ static void __init setup_lowcore(void) |
1613 |
+ #ifdef CONFIG_SMP |
1614 |
+ lc->spinlock_lockval = arch_spin_lockval(0); |
1615 |
+ #endif |
1616 |
++ lc->br_r1_trampoline = 0x07f1; /* br %r1 */ |
1617 |
+ |
1618 |
+ set_prefix((u32)(unsigned long) lc); |
1619 |
+ lowcore_ptr[0] = lc; |
1620 |
+@@ -892,6 +897,9 @@ void __init setup_arch(char **cmdline_p) |
1621 |
+ init_mm.end_data = (unsigned long) &_edata; |
1622 |
+ init_mm.brk = (unsigned long) &_end; |
1623 |
+ |
1624 |
++ if (IS_ENABLED(CONFIG_EXPOLINE_AUTO)) |
1625 |
++ nospec_auto_detect(); |
1626 |
++ |
1627 |
+ parse_early_param(); |
1628 |
+ #ifdef CONFIG_CRASH_DUMP |
1629 |
+ /* Deactivate elfcorehdr= kernel parameter */ |
1630 |
+@@ -955,6 +963,10 @@ void __init setup_arch(char **cmdline_p) |
1631 |
+ conmode_default(); |
1632 |
+ set_preferred_console(); |
1633 |
+ |
1634 |
++ apply_alternative_instructions(); |
1635 |
++ if (IS_ENABLED(CONFIG_EXPOLINE)) |
1636 |
++ nospec_init_branches(); |
1637 |
++ |
1638 |
+ /* Setup zfcpdump support */ |
1639 |
+ setup_zfcpdump(); |
1640 |
+ |
1641 |
+diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c |
1642 |
+index 7ffaf9fd6d19..ae5df4177803 100644 |
1643 |
+--- a/arch/s390/kernel/smp.c |
1644 |
++++ b/arch/s390/kernel/smp.c |
1645 |
+@@ -228,6 +228,7 @@ static int pcpu_alloc_lowcore(struct pcpu *pcpu, int cpu) |
1646 |
+ lc->mcesad = mcesa_origin | mcesa_bits; |
1647 |
+ lc->cpu_nr = cpu; |
1648 |
+ lc->spinlock_lockval = arch_spin_lockval(cpu); |
1649 |
++ lc->br_r1_trampoline = 0x07f1; /* br %r1 */ |
1650 |
+ if (vdso_alloc_per_cpu(lc)) |
1651 |
+ goto out; |
1652 |
+ lowcore_ptr[cpu] = lc; |
1653 |
+@@ -282,7 +283,9 @@ static void pcpu_prepare_secondary(struct pcpu *pcpu, int cpu) |
1654 |
+ __ctl_store(lc->cregs_save_area, 0, 15); |
1655 |
+ save_access_regs((unsigned int *) lc->access_regs_save_area); |
1656 |
+ memcpy(lc->stfle_fac_list, S390_lowcore.stfle_fac_list, |
1657 |
+- MAX_FACILITY_BIT/8); |
1658 |
++ sizeof(lc->stfle_fac_list)); |
1659 |
++ memcpy(lc->alt_stfle_fac_list, S390_lowcore.alt_stfle_fac_list, |
1660 |
++ sizeof(lc->alt_stfle_fac_list)); |
1661 |
+ } |
1662 |
+ |
1663 |
+ static void pcpu_attach_task(struct pcpu *pcpu, struct task_struct *tsk) |
1664 |
+@@ -332,6 +335,7 @@ static void pcpu_delegate(struct pcpu *pcpu, void (*func)(void *), |
1665 |
+ mem_assign_absolute(lc->restart_fn, (unsigned long) func); |
1666 |
+ mem_assign_absolute(lc->restart_data, (unsigned long) data); |
1667 |
+ mem_assign_absolute(lc->restart_source, source_cpu); |
1668 |
++ __bpon(); |
1669 |
+ asm volatile( |
1670 |
+ "0: sigp 0,%0,%2 # sigp restart to target cpu\n" |
1671 |
+ " brc 2,0b # busy, try again\n" |
1672 |
+@@ -907,6 +911,7 @@ void __cpu_die(unsigned int cpu) |
1673 |
+ void __noreturn cpu_die(void) |
1674 |
+ { |
1675 |
+ idle_task_exit(); |
1676 |
++ __bpon(); |
1677 |
+ pcpu_sigp_retry(pcpu_devices + smp_processor_id(), SIGP_STOP, 0); |
1678 |
+ for (;;) ; |
1679 |
+ } |
1680 |
+diff --git a/arch/s390/kernel/uprobes.c b/arch/s390/kernel/uprobes.c |
1681 |
+index d9d1f512f019..5007fac01bb5 100644 |
1682 |
+--- a/arch/s390/kernel/uprobes.c |
1683 |
++++ b/arch/s390/kernel/uprobes.c |
1684 |
+@@ -150,6 +150,15 @@ unsigned long arch_uretprobe_hijack_return_addr(unsigned long trampoline, |
1685 |
+ return orig; |
1686 |
+ } |
1687 |
+ |
1688 |
++bool arch_uretprobe_is_alive(struct return_instance *ret, enum rp_check ctx, |
1689 |
++ struct pt_regs *regs) |
1690 |
++{ |
1691 |
++ if (ctx == RP_CHECK_CHAIN_CALL) |
1692 |
++ return user_stack_pointer(regs) <= ret->stack; |
1693 |
++ else |
1694 |
++ return user_stack_pointer(regs) < ret->stack; |
1695 |
++} |
1696 |
++ |
1697 |
+ /* Instruction Emulation */ |
1698 |
+ |
1699 |
+ static void adjust_psw_addr(psw_t *psw, unsigned long len) |
1700 |
+diff --git a/arch/s390/kernel/vmlinux.lds.S b/arch/s390/kernel/vmlinux.lds.S |
1701 |
+index 96a713a470e7..85dd3c7bdd86 100644 |
1702 |
+--- a/arch/s390/kernel/vmlinux.lds.S |
1703 |
++++ b/arch/s390/kernel/vmlinux.lds.S |
1704 |
+@@ -105,6 +105,43 @@ SECTIONS |
1705 |
+ EXIT_DATA |
1706 |
+ } |
1707 |
+ |
1708 |
++ /* |
1709 |
++ * struct alt_inst entries. From the header (alternative.h): |
1710 |
++ * "Alternative instructions for different CPU types or capabilities" |
1711 |
++ * Think locking instructions on spinlocks. |
1712 |
++ * Note, that it is a part of __init region. |
1713 |
++ */ |
1714 |
++ . = ALIGN(8); |
1715 |
++ .altinstructions : { |
1716 |
++ __alt_instructions = .; |
1717 |
++ *(.altinstructions) |
1718 |
++ __alt_instructions_end = .; |
1719 |
++ } |
1720 |
++ |
1721 |
++ /* |
1722 |
++ * And here are the replacement instructions. The linker sticks |
1723 |
++ * them as binary blobs. The .altinstructions has enough data to |
1724 |
++ * get the address and the length of them to patch the kernel safely. |
1725 |
++ * Note, that it is a part of __init region. |
1726 |
++ */ |
1727 |
++ .altinstr_replacement : { |
1728 |
++ *(.altinstr_replacement) |
1729 |
++ } |
1730 |
++ |
1731 |
++ /* |
1732 |
++ * Table with the patch locations to undo expolines |
1733 |
++ */ |
1734 |
++ .nospec_call_table : { |
1735 |
++ __nospec_call_start = . ; |
1736 |
++ *(.s390_indirect*) |
1737 |
++ __nospec_call_end = . ; |
1738 |
++ } |
1739 |
++ .nospec_return_table : { |
1740 |
++ __nospec_return_start = . ; |
1741 |
++ *(.s390_return*) |
1742 |
++ __nospec_return_end = . ; |
1743 |
++ } |
1744 |
++ |
1745 |
+ /* early.c uses stsi, which requires page aligned data. */ |
1746 |
+ . = ALIGN(PAGE_SIZE); |
1747 |
+ INIT_DATA_SECTION(0x100) |
1748 |
+diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c |
1749 |
+index 0bce918db11a..4f6adbea592b 100644 |
1750 |
+--- a/arch/s390/kvm/kvm-s390.c |
1751 |
++++ b/arch/s390/kvm/kvm-s390.c |
1752 |
+@@ -449,6 +449,9 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext) |
1753 |
+ case KVM_CAP_S390_GS: |
1754 |
+ r = test_facility(133); |
1755 |
+ break; |
1756 |
++ case KVM_CAP_S390_BPB: |
1757 |
++ r = test_facility(82); |
1758 |
++ break; |
1759 |
+ default: |
1760 |
+ r = 0; |
1761 |
+ } |
1762 |
+@@ -2231,6 +2234,8 @@ int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu) |
1763 |
+ kvm_s390_set_prefix(vcpu, 0); |
1764 |
+ if (test_kvm_facility(vcpu->kvm, 64)) |
1765 |
+ vcpu->run->kvm_valid_regs |= KVM_SYNC_RICCB; |
1766 |
++ if (test_kvm_facility(vcpu->kvm, 82)) |
1767 |
++ vcpu->run->kvm_valid_regs |= KVM_SYNC_BPBC; |
1768 |
+ if (test_kvm_facility(vcpu->kvm, 133)) |
1769 |
+ vcpu->run->kvm_valid_regs |= KVM_SYNC_GSCB; |
1770 |
+ /* fprs can be synchronized via vrs, even if the guest has no vx. With |
1771 |
+@@ -2372,6 +2377,7 @@ static void kvm_s390_vcpu_initial_reset(struct kvm_vcpu *vcpu) |
1772 |
+ current->thread.fpu.fpc = 0; |
1773 |
+ vcpu->arch.sie_block->gbea = 1; |
1774 |
+ vcpu->arch.sie_block->pp = 0; |
1775 |
++ vcpu->arch.sie_block->fpf &= ~FPF_BPBC; |
1776 |
+ vcpu->arch.pfault_token = KVM_S390_PFAULT_TOKEN_INVALID; |
1777 |
+ kvm_clear_async_pf_completion_queue(vcpu); |
1778 |
+ if (!kvm_s390_user_cpu_state_ctrl(vcpu->kvm)) |
1779 |
+@@ -3318,6 +3324,11 @@ static void sync_regs(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) |
1780 |
+ vcpu->arch.sie_block->ecd |= ECD_HOSTREGMGMT; |
1781 |
+ vcpu->arch.gs_enabled = 1; |
1782 |
+ } |
1783 |
++ if ((kvm_run->kvm_dirty_regs & KVM_SYNC_BPBC) && |
1784 |
++ test_kvm_facility(vcpu->kvm, 82)) { |
1785 |
++ vcpu->arch.sie_block->fpf &= ~FPF_BPBC; |
1786 |
++ vcpu->arch.sie_block->fpf |= kvm_run->s.regs.bpbc ? FPF_BPBC : 0; |
1787 |
++ } |
1788 |
+ save_access_regs(vcpu->arch.host_acrs); |
1789 |
+ restore_access_regs(vcpu->run->s.regs.acrs); |
1790 |
+ /* save host (userspace) fprs/vrs */ |
1791 |
+@@ -3364,6 +3375,7 @@ static void store_regs(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) |
1792 |
+ kvm_run->s.regs.pft = vcpu->arch.pfault_token; |
1793 |
+ kvm_run->s.regs.pfs = vcpu->arch.pfault_select; |
1794 |
+ kvm_run->s.regs.pfc = vcpu->arch.pfault_compare; |
1795 |
++ kvm_run->s.regs.bpbc = (vcpu->arch.sie_block->fpf & FPF_BPBC) == FPF_BPBC; |
1796 |
+ save_access_regs(vcpu->run->s.regs.acrs); |
1797 |
+ restore_access_regs(vcpu->arch.host_acrs); |
1798 |
+ /* Save guest register state */ |
1799 |
+diff --git a/arch/s390/kvm/vsie.c b/arch/s390/kvm/vsie.c |
1800 |
+index a74204db759b..eb7b530d1783 100644 |
1801 |
+--- a/arch/s390/kvm/vsie.c |
1802 |
++++ b/arch/s390/kvm/vsie.c |
1803 |
+@@ -234,6 +234,12 @@ static void unshadow_scb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page) |
1804 |
+ memcpy(scb_o->gcr, scb_s->gcr, 128); |
1805 |
+ scb_o->pp = scb_s->pp; |
1806 |
+ |
1807 |
++ /* branch prediction */ |
1808 |
++ if (test_kvm_facility(vcpu->kvm, 82)) { |
1809 |
++ scb_o->fpf &= ~FPF_BPBC; |
1810 |
++ scb_o->fpf |= scb_s->fpf & FPF_BPBC; |
1811 |
++ } |
1812 |
++ |
1813 |
+ /* interrupt intercept */ |
1814 |
+ switch (scb_s->icptcode) { |
1815 |
+ case ICPT_PROGI: |
1816 |
+@@ -280,6 +286,7 @@ static int shadow_scb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page) |
1817 |
+ scb_s->ecb3 = 0; |
1818 |
+ scb_s->ecd = 0; |
1819 |
+ scb_s->fac = 0; |
1820 |
++ scb_s->fpf = 0; |
1821 |
+ |
1822 |
+ rc = prepare_cpuflags(vcpu, vsie_page); |
1823 |
+ if (rc) |
1824 |
+@@ -339,6 +346,9 @@ static int shadow_scb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page) |
1825 |
+ prefix_unmapped(vsie_page); |
1826 |
+ scb_s->ecb |= ECB_TE; |
1827 |
+ } |
1828 |
++ /* branch prediction */ |
1829 |
++ if (test_kvm_facility(vcpu->kvm, 82)) |
1830 |
++ scb_s->fpf |= scb_o->fpf & FPF_BPBC; |
1831 |
+ /* SIMD */ |
1832 |
+ if (test_kvm_facility(vcpu->kvm, 129)) { |
1833 |
+ scb_s->eca |= scb_o->eca & ECA_VX; |
1834 |
+@@ -821,6 +831,7 @@ static int do_vsie_run(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page) |
1835 |
+ { |
1836 |
+ struct kvm_s390_sie_block *scb_s = &vsie_page->scb_s; |
1837 |
+ struct kvm_s390_sie_block *scb_o = vsie_page->scb_o; |
1838 |
++ int guest_bp_isolation; |
1839 |
+ int rc; |
1840 |
+ |
1841 |
+ handle_last_fault(vcpu, vsie_page); |
1842 |
+@@ -831,6 +842,20 @@ static int do_vsie_run(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page) |
1843 |
+ s390_handle_mcck(); |
1844 |
+ |
1845 |
+ srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx); |
1846 |
++ |
1847 |
++ /* save current guest state of bp isolation override */ |
1848 |
++ guest_bp_isolation = test_thread_flag(TIF_ISOLATE_BP_GUEST); |
1849 |
++ |
1850 |
++ /* |
1851 |
++ * The guest is running with BPBC, so we have to force it on for our |
1852 |
++ * nested guest. This is done by enabling BPBC globally, so the BPBC |
1853 |
++ * control in the SCB (which the nested guest can modify) is simply |
1854 |
++ * ignored. |
1855 |
++ */ |
1856 |
++ if (test_kvm_facility(vcpu->kvm, 82) && |
1857 |
++ vcpu->arch.sie_block->fpf & FPF_BPBC) |
1858 |
++ set_thread_flag(TIF_ISOLATE_BP_GUEST); |
1859 |
++ |
1860 |
+ local_irq_disable(); |
1861 |
+ guest_enter_irqoff(); |
1862 |
+ local_irq_enable(); |
1863 |
+@@ -840,6 +865,11 @@ static int do_vsie_run(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page) |
1864 |
+ local_irq_disable(); |
1865 |
+ guest_exit_irqoff(); |
1866 |
+ local_irq_enable(); |
1867 |
++ |
1868 |
++ /* restore guest state for bp isolation override */ |
1869 |
++ if (!guest_bp_isolation) |
1870 |
++ clear_thread_flag(TIF_ISOLATE_BP_GUEST); |
1871 |
++ |
1872 |
+ vcpu->srcu_idx = srcu_read_lock(&vcpu->kvm->srcu); |
1873 |
+ |
1874 |
+ if (rc == -EINTR) { |
1875 |
+diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c |
1876 |
+index f53ccc680238..dbdd460a9958 100644 |
1877 |
+--- a/drivers/acpi/acpi_video.c |
1878 |
++++ b/drivers/acpi/acpi_video.c |
1879 |
+@@ -2123,6 +2123,25 @@ static int __init intel_opregion_present(void) |
1880 |
+ return opregion; |
1881 |
+ } |
1882 |
+ |
1883 |
++static bool dmi_is_desktop(void) |
1884 |
++{ |
1885 |
++ const char *chassis_type; |
1886 |
++ |
1887 |
++ chassis_type = dmi_get_system_info(DMI_CHASSIS_TYPE); |
1888 |
++ if (!chassis_type) |
1889 |
++ return false; |
1890 |
++ |
1891 |
++ if (!strcmp(chassis_type, "3") || /* 3: Desktop */ |
1892 |
++ !strcmp(chassis_type, "4") || /* 4: Low Profile Desktop */ |
1893 |
++ !strcmp(chassis_type, "5") || /* 5: Pizza Box */ |
1894 |
++ !strcmp(chassis_type, "6") || /* 6: Mini Tower */ |
1895 |
++ !strcmp(chassis_type, "7") || /* 7: Tower */ |
1896 |
++ !strcmp(chassis_type, "11")) /* 11: Main Server Chassis */ |
1897 |
++ return true; |
1898 |
++ |
1899 |
++ return false; |
1900 |
++} |
1901 |
++ |
1902 |
+ int acpi_video_register(void) |
1903 |
+ { |
1904 |
+ int ret = 0; |
1905 |
+@@ -2143,8 +2162,12 @@ int acpi_video_register(void) |
1906 |
+ * win8 ready (where we also prefer the native backlight driver, so |
1907 |
+ * normally the acpi_video code should not register there anyways). |
1908 |
+ */ |
1909 |
+- if (only_lcd == -1) |
1910 |
+- only_lcd = acpi_osi_is_win8(); |
1911 |
++ if (only_lcd == -1) { |
1912 |
++ if (dmi_is_desktop() && acpi_osi_is_win8()) |
1913 |
++ only_lcd = true; |
1914 |
++ else |
1915 |
++ only_lcd = false; |
1916 |
++ } |
1917 |
+ |
1918 |
+ dmi_check_system(video_dmi_table); |
1919 |
+ |
1920 |
+diff --git a/drivers/block/swim.c b/drivers/block/swim.c |
1921 |
+index 84434d3ea19b..e88d50f75a4a 100644 |
1922 |
+--- a/drivers/block/swim.c |
1923 |
++++ b/drivers/block/swim.c |
1924 |
+@@ -110,7 +110,7 @@ struct iwm { |
1925 |
+ /* Select values for swim_select and swim_readbit */ |
1926 |
+ |
1927 |
+ #define READ_DATA_0 0x074 |
1928 |
+-#define TWOMEG_DRIVE 0x075 |
1929 |
++#define ONEMEG_DRIVE 0x075 |
1930 |
+ #define SINGLE_SIDED 0x076 |
1931 |
+ #define DRIVE_PRESENT 0x077 |
1932 |
+ #define DISK_IN 0x170 |
1933 |
+@@ -118,9 +118,9 @@ struct iwm { |
1934 |
+ #define TRACK_ZERO 0x172 |
1935 |
+ #define TACHO 0x173 |
1936 |
+ #define READ_DATA_1 0x174 |
1937 |
+-#define MFM_MODE 0x175 |
1938 |
++#define GCR_MODE 0x175 |
1939 |
+ #define SEEK_COMPLETE 0x176 |
1940 |
+-#define ONEMEG_MEDIA 0x177 |
1941 |
++#define TWOMEG_MEDIA 0x177 |
1942 |
+ |
1943 |
+ /* Bits in handshake register */ |
1944 |
+ |
1945 |
+@@ -612,7 +612,6 @@ static void setup_medium(struct floppy_state *fs) |
1946 |
+ struct floppy_struct *g; |
1947 |
+ fs->disk_in = 1; |
1948 |
+ fs->write_protected = swim_readbit(base, WRITE_PROT); |
1949 |
+- fs->type = swim_readbit(base, ONEMEG_MEDIA); |
1950 |
+ |
1951 |
+ if (swim_track00(base)) |
1952 |
+ printk(KERN_ERR |
1953 |
+@@ -620,6 +619,9 @@ static void setup_medium(struct floppy_state *fs) |
1954 |
+ |
1955 |
+ swim_track00(base); |
1956 |
+ |
1957 |
++ fs->type = swim_readbit(base, TWOMEG_MEDIA) ? |
1958 |
++ HD_MEDIA : DD_MEDIA; |
1959 |
++ fs->head_number = swim_readbit(base, SINGLE_SIDED) ? 1 : 2; |
1960 |
+ get_floppy_geometry(fs, 0, &g); |
1961 |
+ fs->total_secs = g->size; |
1962 |
+ fs->secpercyl = g->head * g->sect; |
1963 |
+@@ -646,7 +648,7 @@ static int floppy_open(struct block_device *bdev, fmode_t mode) |
1964 |
+ |
1965 |
+ swim_write(base, setup, S_IBM_DRIVE | S_FCLK_DIV2); |
1966 |
+ udelay(10); |
1967 |
+- swim_drive(base, INTERNAL_DRIVE); |
1968 |
++ swim_drive(base, fs->location); |
1969 |
+ swim_motor(base, ON); |
1970 |
+ swim_action(base, SETMFM); |
1971 |
+ if (fs->ejected) |
1972 |
+@@ -656,6 +658,8 @@ static int floppy_open(struct block_device *bdev, fmode_t mode) |
1973 |
+ goto out; |
1974 |
+ } |
1975 |
+ |
1976 |
++ set_capacity(fs->disk, fs->total_secs); |
1977 |
++ |
1978 |
+ if (mode & FMODE_NDELAY) |
1979 |
+ return 0; |
1980 |
+ |
1981 |
+@@ -727,14 +731,9 @@ static int floppy_ioctl(struct block_device *bdev, fmode_t mode, |
1982 |
+ if (copy_to_user((void __user *) param, (void *) &floppy_type, |
1983 |
+ sizeof(struct floppy_struct))) |
1984 |
+ return -EFAULT; |
1985 |
+- break; |
1986 |
+- |
1987 |
+- default: |
1988 |
+- printk(KERN_DEBUG "SWIM floppy_ioctl: unknown cmd %d\n", |
1989 |
+- cmd); |
1990 |
+- return -ENOSYS; |
1991 |
++ return 0; |
1992 |
+ } |
1993 |
+- return 0; |
1994 |
++ return -ENOTTY; |
1995 |
+ } |
1996 |
+ |
1997 |
+ static int floppy_getgeo(struct block_device *bdev, struct hd_geometry *geo) |
1998 |
+@@ -795,7 +794,7 @@ static struct kobject *floppy_find(dev_t dev, int *part, void *data) |
1999 |
+ struct swim_priv *swd = data; |
2000 |
+ int drive = (*part & 3); |
2001 |
+ |
2002 |
+- if (drive > swd->floppy_count) |
2003 |
++ if (drive >= swd->floppy_count) |
2004 |
+ return NULL; |
2005 |
+ |
2006 |
+ *part = 0; |
2007 |
+@@ -813,10 +812,9 @@ static int swim_add_floppy(struct swim_priv *swd, enum drive_location location) |
2008 |
+ |
2009 |
+ swim_motor(base, OFF); |
2010 |
+ |
2011 |
+- if (swim_readbit(base, SINGLE_SIDED)) |
2012 |
+- fs->head_number = 1; |
2013 |
+- else |
2014 |
+- fs->head_number = 2; |
2015 |
++ fs->type = HD_MEDIA; |
2016 |
++ fs->head_number = 2; |
2017 |
++ |
2018 |
+ fs->ref_count = 0; |
2019 |
+ fs->ejected = 1; |
2020 |
+ |
2021 |
+@@ -834,10 +832,12 @@ static int swim_floppy_init(struct swim_priv *swd) |
2022 |
+ /* scan floppy drives */ |
2023 |
+ |
2024 |
+ swim_drive(base, INTERNAL_DRIVE); |
2025 |
+- if (swim_readbit(base, DRIVE_PRESENT)) |
2026 |
++ if (swim_readbit(base, DRIVE_PRESENT) && |
2027 |
++ !swim_readbit(base, ONEMEG_DRIVE)) |
2028 |
+ swim_add_floppy(swd, INTERNAL_DRIVE); |
2029 |
+ swim_drive(base, EXTERNAL_DRIVE); |
2030 |
+- if (swim_readbit(base, DRIVE_PRESENT)) |
2031 |
++ if (swim_readbit(base, DRIVE_PRESENT) && |
2032 |
++ !swim_readbit(base, ONEMEG_DRIVE)) |
2033 |
+ swim_add_floppy(swd, EXTERNAL_DRIVE); |
2034 |
+ |
2035 |
+ /* register floppy drives */ |
2036 |
+@@ -861,7 +861,6 @@ static int swim_floppy_init(struct swim_priv *swd) |
2037 |
+ &swd->lock); |
2038 |
+ if (!swd->unit[drive].disk->queue) { |
2039 |
+ err = -ENOMEM; |
2040 |
+- put_disk(swd->unit[drive].disk); |
2041 |
+ goto exit_put_disks; |
2042 |
+ } |
2043 |
+ blk_queue_bounce_limit(swd->unit[drive].disk->queue, |
2044 |
+@@ -911,7 +910,7 @@ static int swim_probe(struct platform_device *dev) |
2045 |
+ goto out; |
2046 |
+ } |
2047 |
+ |
2048 |
+- swim_base = ioremap(res->start, resource_size(res)); |
2049 |
++ swim_base = (struct swim __iomem *)res->start; |
2050 |
+ if (!swim_base) { |
2051 |
+ ret = -ENOMEM; |
2052 |
+ goto out_release_io; |
2053 |
+@@ -923,7 +922,7 @@ static int swim_probe(struct platform_device *dev) |
2054 |
+ if (!get_swim_mode(swim_base)) { |
2055 |
+ printk(KERN_INFO "SWIM device not found !\n"); |
2056 |
+ ret = -ENODEV; |
2057 |
+- goto out_iounmap; |
2058 |
++ goto out_release_io; |
2059 |
+ } |
2060 |
+ |
2061 |
+ /* set platform driver data */ |
2062 |
+@@ -931,7 +930,7 @@ static int swim_probe(struct platform_device *dev) |
2063 |
+ swd = kzalloc(sizeof(struct swim_priv), GFP_KERNEL); |
2064 |
+ if (!swd) { |
2065 |
+ ret = -ENOMEM; |
2066 |
+- goto out_iounmap; |
2067 |
++ goto out_release_io; |
2068 |
+ } |
2069 |
+ platform_set_drvdata(dev, swd); |
2070 |
+ |
2071 |
+@@ -945,8 +944,6 @@ static int swim_probe(struct platform_device *dev) |
2072 |
+ |
2073 |
+ out_kfree: |
2074 |
+ kfree(swd); |
2075 |
+-out_iounmap: |
2076 |
+- iounmap(swim_base); |
2077 |
+ out_release_io: |
2078 |
+ release_mem_region(res->start, resource_size(res)); |
2079 |
+ out: |
2080 |
+@@ -974,8 +971,6 @@ static int swim_remove(struct platform_device *dev) |
2081 |
+ for (drive = 0; drive < swd->floppy_count; drive++) |
2082 |
+ floppy_eject(&swd->unit[drive]); |
2083 |
+ |
2084 |
+- iounmap(swd->base); |
2085 |
+- |
2086 |
+ res = platform_get_resource(dev, IORESOURCE_MEM, 0); |
2087 |
+ if (res) |
2088 |
+ release_mem_region(res->start, resource_size(res)); |
2089 |
+diff --git a/drivers/block/swim3.c b/drivers/block/swim3.c |
2090 |
+index 9f931f8f6b4c..0d7527c6825a 100644 |
2091 |
+--- a/drivers/block/swim3.c |
2092 |
++++ b/drivers/block/swim3.c |
2093 |
+@@ -148,7 +148,7 @@ struct swim3 { |
2094 |
+ #define MOTOR_ON 2 |
2095 |
+ #define RELAX 3 /* also eject in progress */ |
2096 |
+ #define READ_DATA_0 4 |
2097 |
+-#define TWOMEG_DRIVE 5 |
2098 |
++#define ONEMEG_DRIVE 5 |
2099 |
+ #define SINGLE_SIDED 6 /* drive or diskette is 4MB type? */ |
2100 |
+ #define DRIVE_PRESENT 7 |
2101 |
+ #define DISK_IN 8 |
2102 |
+@@ -156,9 +156,9 @@ struct swim3 { |
2103 |
+ #define TRACK_ZERO 10 |
2104 |
+ #define TACHO 11 |
2105 |
+ #define READ_DATA_1 12 |
2106 |
+-#define MFM_MODE 13 |
2107 |
++#define GCR_MODE 13 |
2108 |
+ #define SEEK_COMPLETE 14 |
2109 |
+-#define ONEMEG_MEDIA 15 |
2110 |
++#define TWOMEG_MEDIA 15 |
2111 |
+ |
2112 |
+ /* Definitions of values used in writing and formatting */ |
2113 |
+ #define DATA_ESCAPE 0x99 |
2114 |
+diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c |
2115 |
+index e36d160c458f..5f7d86509f2f 100644 |
2116 |
+--- a/drivers/cdrom/cdrom.c |
2117 |
++++ b/drivers/cdrom/cdrom.c |
2118 |
+@@ -2374,7 +2374,7 @@ static int cdrom_ioctl_media_changed(struct cdrom_device_info *cdi, |
2119 |
+ if (!CDROM_CAN(CDC_SELECT_DISC) || arg == CDSL_CURRENT) |
2120 |
+ return media_changed(cdi, 1); |
2121 |
+ |
2122 |
+- if ((unsigned int)arg >= cdi->capacity) |
2123 |
++ if (arg >= cdi->capacity) |
2124 |
+ return -EINVAL; |
2125 |
+ |
2126 |
+ info = kmalloc(sizeof(*info), GFP_KERNEL); |
2127 |
+diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c |
2128 |
+index 1d01a8f77db1..dba5259def60 100644 |
2129 |
+--- a/drivers/char/tpm/tpm-interface.c |
2130 |
++++ b/drivers/char/tpm/tpm-interface.c |
2131 |
+@@ -369,20 +369,40 @@ static int tpm_validate_command(struct tpm_chip *chip, |
2132 |
+ return -EINVAL; |
2133 |
+ } |
2134 |
+ |
2135 |
+-/** |
2136 |
+- * tmp_transmit - Internal kernel interface to transmit TPM commands. |
2137 |
+- * |
2138 |
+- * @chip: TPM chip to use |
2139 |
+- * @buf: TPM command buffer |
2140 |
+- * @bufsiz: length of the TPM command buffer |
2141 |
+- * @flags: tpm transmit flags - bitmap |
2142 |
+- * |
2143 |
+- * Return: |
2144 |
+- * 0 when the operation is successful. |
2145 |
+- * A negative number for system errors (errno). |
2146 |
+- */ |
2147 |
+-ssize_t tpm_transmit(struct tpm_chip *chip, struct tpm_space *space, |
2148 |
+- u8 *buf, size_t bufsiz, unsigned int flags) |
2149 |
++static int tpm_request_locality(struct tpm_chip *chip) |
2150 |
++{ |
2151 |
++ int rc; |
2152 |
++ |
2153 |
++ if (!chip->ops->request_locality) |
2154 |
++ return 0; |
2155 |
++ |
2156 |
++ rc = chip->ops->request_locality(chip, 0); |
2157 |
++ if (rc < 0) |
2158 |
++ return rc; |
2159 |
++ |
2160 |
++ chip->locality = rc; |
2161 |
++ |
2162 |
++ return 0; |
2163 |
++} |
2164 |
++ |
2165 |
++static void tpm_relinquish_locality(struct tpm_chip *chip) |
2166 |
++{ |
2167 |
++ int rc; |
2168 |
++ |
2169 |
++ if (!chip->ops->relinquish_locality) |
2170 |
++ return; |
2171 |
++ |
2172 |
++ rc = chip->ops->relinquish_locality(chip, chip->locality); |
2173 |
++ if (rc) |
2174 |
++ dev_err(&chip->dev, "%s: : error %d\n", __func__, rc); |
2175 |
++ |
2176 |
++ chip->locality = -1; |
2177 |
++} |
2178 |
++ |
2179 |
++static ssize_t tpm_try_transmit(struct tpm_chip *chip, |
2180 |
++ struct tpm_space *space, |
2181 |
++ u8 *buf, size_t bufsiz, |
2182 |
++ unsigned int flags) |
2183 |
+ { |
2184 |
+ struct tpm_output_header *header = (void *)buf; |
2185 |
+ int rc; |
2186 |
+@@ -422,8 +442,6 @@ ssize_t tpm_transmit(struct tpm_chip *chip, struct tpm_space *space, |
2187 |
+ if (!(flags & TPM_TRANSMIT_UNLOCKED)) |
2188 |
+ mutex_lock(&chip->tpm_mutex); |
2189 |
+ |
2190 |
+- if (chip->dev.parent) |
2191 |
+- pm_runtime_get_sync(chip->dev.parent); |
2192 |
+ |
2193 |
+ if (chip->ops->clk_enable != NULL) |
2194 |
+ chip->ops->clk_enable(chip, true); |
2195 |
+@@ -431,14 +449,15 @@ ssize_t tpm_transmit(struct tpm_chip *chip, struct tpm_space *space, |
2196 |
+ /* Store the decision as chip->locality will be changed. */ |
2197 |
+ need_locality = chip->locality == -1; |
2198 |
+ |
2199 |
+- if (!(flags & TPM_TRANSMIT_RAW) && |
2200 |
+- need_locality && chip->ops->request_locality) { |
2201 |
+- rc = chip->ops->request_locality(chip, 0); |
2202 |
++ if (!(flags & TPM_TRANSMIT_RAW) && need_locality) { |
2203 |
++ rc = tpm_request_locality(chip); |
2204 |
+ if (rc < 0) |
2205 |
+ goto out_no_locality; |
2206 |
+- chip->locality = rc; |
2207 |
+ } |
2208 |
+ |
2209 |
++ if (chip->dev.parent) |
2210 |
++ pm_runtime_get_sync(chip->dev.parent); |
2211 |
++ |
2212 |
+ rc = tpm2_prepare_space(chip, space, ordinal, buf); |
2213 |
+ if (rc) |
2214 |
+ goto out; |
2215 |
+@@ -499,27 +518,83 @@ ssize_t tpm_transmit(struct tpm_chip *chip, struct tpm_space *space, |
2216 |
+ rc = tpm2_commit_space(chip, space, ordinal, buf, &len); |
2217 |
+ |
2218 |
+ out: |
2219 |
+- if (need_locality && chip->ops->relinquish_locality) { |
2220 |
+- chip->ops->relinquish_locality(chip, chip->locality); |
2221 |
+- chip->locality = -1; |
2222 |
+- } |
2223 |
++ if (chip->dev.parent) |
2224 |
++ pm_runtime_put_sync(chip->dev.parent); |
2225 |
++ |
2226 |
++ if (need_locality) |
2227 |
++ tpm_relinquish_locality(chip); |
2228 |
++ |
2229 |
+ out_no_locality: |
2230 |
+ if (chip->ops->clk_enable != NULL) |
2231 |
+ chip->ops->clk_enable(chip, false); |
2232 |
+ |
2233 |
+- if (chip->dev.parent) |
2234 |
+- pm_runtime_put_sync(chip->dev.parent); |
2235 |
+- |
2236 |
+ if (!(flags & TPM_TRANSMIT_UNLOCKED)) |
2237 |
+ mutex_unlock(&chip->tpm_mutex); |
2238 |
+ return rc ? rc : len; |
2239 |
+ } |
2240 |
+ |
2241 |
+ /** |
2242 |
+- * tmp_transmit_cmd - send a tpm command to the device |
2243 |
++ * tpm_transmit - Internal kernel interface to transmit TPM commands. |
2244 |
++ * |
2245 |
++ * @chip: TPM chip to use |
2246 |
++ * @space: tpm space |
2247 |
++ * @buf: TPM command buffer |
2248 |
++ * @bufsiz: length of the TPM command buffer |
2249 |
++ * @flags: tpm transmit flags - bitmap |
2250 |
++ * |
2251 |
++ * A wrapper around tpm_try_transmit that handles TPM2_RC_RETRY |
2252 |
++ * returns from the TPM and retransmits the command after a delay up |
2253 |
++ * to a maximum wait of TPM2_DURATION_LONG. |
2254 |
++ * |
2255 |
++ * Note: TPM1 never returns TPM2_RC_RETRY so the retry logic is TPM2 |
2256 |
++ * only |
2257 |
++ * |
2258 |
++ * Return: |
2259 |
++ * the length of the return when the operation is successful. |
2260 |
++ * A negative number for system errors (errno). |
2261 |
++ */ |
2262 |
++ssize_t tpm_transmit(struct tpm_chip *chip, struct tpm_space *space, |
2263 |
++ u8 *buf, size_t bufsiz, unsigned int flags) |
2264 |
++{ |
2265 |
++ struct tpm_output_header *header = (struct tpm_output_header *)buf; |
2266 |
++ /* space for header and handles */ |
2267 |
++ u8 save[TPM_HEADER_SIZE + 3*sizeof(u32)]; |
2268 |
++ unsigned int delay_msec = TPM2_DURATION_SHORT; |
2269 |
++ u32 rc = 0; |
2270 |
++ ssize_t ret; |
2271 |
++ const size_t save_size = min(space ? sizeof(save) : TPM_HEADER_SIZE, |
2272 |
++ bufsiz); |
2273 |
++ |
2274 |
++ /* |
2275 |
++ * Subtlety here: if we have a space, the handles will be |
2276 |
++ * transformed, so when we restore the header we also have to |
2277 |
++ * restore the handles. |
2278 |
++ */ |
2279 |
++ memcpy(save, buf, save_size); |
2280 |
++ |
2281 |
++ for (;;) { |
2282 |
++ ret = tpm_try_transmit(chip, space, buf, bufsiz, flags); |
2283 |
++ if (ret < 0) |
2284 |
++ break; |
2285 |
++ rc = be32_to_cpu(header->return_code); |
2286 |
++ if (rc != TPM2_RC_RETRY) |
2287 |
++ break; |
2288 |
++ delay_msec *= 2; |
2289 |
++ if (delay_msec > TPM2_DURATION_LONG) { |
2290 |
++ dev_err(&chip->dev, "TPM is in retry loop\n"); |
2291 |
++ break; |
2292 |
++ } |
2293 |
++ tpm_msleep(delay_msec); |
2294 |
++ memcpy(buf, save, save_size); |
2295 |
++ } |
2296 |
++ return ret; |
2297 |
++} |
2298 |
++/** |
2299 |
++ * tpm_transmit_cmd - send a tpm command to the device |
2300 |
+ * The function extracts tpm out header return code |
2301 |
+ * |
2302 |
+ * @chip: TPM chip to use |
2303 |
++ * @space: tpm space |
2304 |
+ * @buf: TPM command buffer |
2305 |
+ * @bufsiz: length of the buffer |
2306 |
+ * @min_rsp_body_length: minimum expected length of response body |
2307 |
+diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h |
2308 |
+index 0b5b499f726a..b83b30a3eea5 100644 |
2309 |
+--- a/drivers/char/tpm/tpm.h |
2310 |
++++ b/drivers/char/tpm/tpm.h |
2311 |
+@@ -106,6 +106,7 @@ enum tpm2_return_codes { |
2312 |
+ TPM2_RC_COMMAND_CODE = 0x0143, |
2313 |
+ TPM2_RC_TESTING = 0x090A, /* RC_WARN */ |
2314 |
+ TPM2_RC_REFERENCE_H0 = 0x0910, |
2315 |
++ TPM2_RC_RETRY = 0x0922, |
2316 |
+ }; |
2317 |
+ |
2318 |
+ enum tpm2_algorithms { |
2319 |
+diff --git a/drivers/char/tpm/tpm_crb.c b/drivers/char/tpm/tpm_crb.c |
2320 |
+index 8f0a98dea327..bb756ad7897e 100644 |
2321 |
+--- a/drivers/char/tpm/tpm_crb.c |
2322 |
++++ b/drivers/char/tpm/tpm_crb.c |
2323 |
+@@ -117,6 +117,25 @@ struct tpm2_crb_smc { |
2324 |
+ u32 smc_func_id; |
2325 |
+ }; |
2326 |
+ |
2327 |
++static bool crb_wait_for_reg_32(u32 __iomem *reg, u32 mask, u32 value, |
2328 |
++ unsigned long timeout) |
2329 |
++{ |
2330 |
++ ktime_t start; |
2331 |
++ ktime_t stop; |
2332 |
++ |
2333 |
++ start = ktime_get(); |
2334 |
++ stop = ktime_add(start, ms_to_ktime(timeout)); |
2335 |
++ |
2336 |
++ do { |
2337 |
++ if ((ioread32(reg) & mask) == value) |
2338 |
++ return true; |
2339 |
++ |
2340 |
++ usleep_range(50, 100); |
2341 |
++ } while (ktime_before(ktime_get(), stop)); |
2342 |
++ |
2343 |
++ return ((ioread32(reg) & mask) == value); |
2344 |
++} |
2345 |
++ |
2346 |
+ /** |
2347 |
+ * crb_go_idle - request tpm crb device to go the idle state |
2348 |
+ * |
2349 |
+@@ -132,37 +151,24 @@ struct tpm2_crb_smc { |
2350 |
+ * |
2351 |
+ * Return: 0 always |
2352 |
+ */ |
2353 |
+-static int __maybe_unused crb_go_idle(struct device *dev, struct crb_priv *priv) |
2354 |
++static int crb_go_idle(struct device *dev, struct crb_priv *priv) |
2355 |
+ { |
2356 |
+ if ((priv->flags & CRB_FL_ACPI_START) || |
2357 |
+ (priv->flags & CRB_FL_CRB_SMC_START)) |
2358 |
+ return 0; |
2359 |
+ |
2360 |
+ iowrite32(CRB_CTRL_REQ_GO_IDLE, &priv->regs_t->ctrl_req); |
2361 |
+- /* we don't really care when this settles */ |
2362 |
+ |
2363 |
++ if (!crb_wait_for_reg_32(&priv->regs_t->ctrl_req, |
2364 |
++ CRB_CTRL_REQ_GO_IDLE/* mask */, |
2365 |
++ 0, /* value */ |
2366 |
++ TPM2_TIMEOUT_C)) { |
2367 |
++ dev_warn(dev, "goIdle timed out\n"); |
2368 |
++ return -ETIME; |
2369 |
++ } |
2370 |
+ return 0; |
2371 |
+ } |
2372 |
+ |
2373 |
+-static bool crb_wait_for_reg_32(u32 __iomem *reg, u32 mask, u32 value, |
2374 |
+- unsigned long timeout) |
2375 |
+-{ |
2376 |
+- ktime_t start; |
2377 |
+- ktime_t stop; |
2378 |
+- |
2379 |
+- start = ktime_get(); |
2380 |
+- stop = ktime_add(start, ms_to_ktime(timeout)); |
2381 |
+- |
2382 |
+- do { |
2383 |
+- if ((ioread32(reg) & mask) == value) |
2384 |
+- return true; |
2385 |
+- |
2386 |
+- usleep_range(50, 100); |
2387 |
+- } while (ktime_before(ktime_get(), stop)); |
2388 |
+- |
2389 |
+- return false; |
2390 |
+-} |
2391 |
+- |
2392 |
+ /** |
2393 |
+ * crb_cmd_ready - request tpm crb device to enter ready state |
2394 |
+ * |
2395 |
+@@ -177,8 +183,7 @@ static bool crb_wait_for_reg_32(u32 __iomem *reg, u32 mask, u32 value, |
2396 |
+ * |
2397 |
+ * Return: 0 on success -ETIME on timeout; |
2398 |
+ */ |
2399 |
+-static int __maybe_unused crb_cmd_ready(struct device *dev, |
2400 |
+- struct crb_priv *priv) |
2401 |
++static int crb_cmd_ready(struct device *dev, struct crb_priv *priv) |
2402 |
+ { |
2403 |
+ if ((priv->flags & CRB_FL_ACPI_START) || |
2404 |
+ (priv->flags & CRB_FL_CRB_SMC_START)) |
2405 |
+@@ -196,11 +201,11 @@ static int __maybe_unused crb_cmd_ready(struct device *dev, |
2406 |
+ return 0; |
2407 |
+ } |
2408 |
+ |
2409 |
+-static int crb_request_locality(struct tpm_chip *chip, int loc) |
2410 |
++static int __crb_request_locality(struct device *dev, |
2411 |
++ struct crb_priv *priv, int loc) |
2412 |
+ { |
2413 |
+- struct crb_priv *priv = dev_get_drvdata(&chip->dev); |
2414 |
+ u32 value = CRB_LOC_STATE_LOC_ASSIGNED | |
2415 |
+- CRB_LOC_STATE_TPM_REG_VALID_STS; |
2416 |
++ CRB_LOC_STATE_TPM_REG_VALID_STS; |
2417 |
+ |
2418 |
+ if (!priv->regs_h) |
2419 |
+ return 0; |
2420 |
+@@ -208,21 +213,45 @@ static int crb_request_locality(struct tpm_chip *chip, int loc) |
2421 |
+ iowrite32(CRB_LOC_CTRL_REQUEST_ACCESS, &priv->regs_h->loc_ctrl); |
2422 |
+ if (!crb_wait_for_reg_32(&priv->regs_h->loc_state, value, value, |
2423 |
+ TPM2_TIMEOUT_C)) { |
2424 |
+- dev_warn(&chip->dev, "TPM_LOC_STATE_x.requestAccess timed out\n"); |
2425 |
++ dev_warn(dev, "TPM_LOC_STATE_x.requestAccess timed out\n"); |
2426 |
+ return -ETIME; |
2427 |
+ } |
2428 |
+ |
2429 |
+ return 0; |
2430 |
+ } |
2431 |
+ |
2432 |
+-static void crb_relinquish_locality(struct tpm_chip *chip, int loc) |
2433 |
++static int crb_request_locality(struct tpm_chip *chip, int loc) |
2434 |
+ { |
2435 |
+ struct crb_priv *priv = dev_get_drvdata(&chip->dev); |
2436 |
+ |
2437 |
++ return __crb_request_locality(&chip->dev, priv, loc); |
2438 |
++} |
2439 |
++ |
2440 |
++static int __crb_relinquish_locality(struct device *dev, |
2441 |
++ struct crb_priv *priv, int loc) |
2442 |
++{ |
2443 |
++ u32 mask = CRB_LOC_STATE_LOC_ASSIGNED | |
2444 |
++ CRB_LOC_STATE_TPM_REG_VALID_STS; |
2445 |
++ u32 value = CRB_LOC_STATE_TPM_REG_VALID_STS; |
2446 |
++ |
2447 |
+ if (!priv->regs_h) |
2448 |
+- return; |
2449 |
++ return 0; |
2450 |
+ |
2451 |
+ iowrite32(CRB_LOC_CTRL_RELINQUISH, &priv->regs_h->loc_ctrl); |
2452 |
++ if (!crb_wait_for_reg_32(&priv->regs_h->loc_state, mask, value, |
2453 |
++ TPM2_TIMEOUT_C)) { |
2454 |
++ dev_warn(dev, "TPM_LOC_STATE_x.requestAccess timed out\n"); |
2455 |
++ return -ETIME; |
2456 |
++ } |
2457 |
++ |
2458 |
++ return 0; |
2459 |
++} |
2460 |
++ |
2461 |
++static int crb_relinquish_locality(struct tpm_chip *chip, int loc) |
2462 |
++{ |
2463 |
++ struct crb_priv *priv = dev_get_drvdata(&chip->dev); |
2464 |
++ |
2465 |
++ return __crb_relinquish_locality(&chip->dev, priv, loc); |
2466 |
+ } |
2467 |
+ |
2468 |
+ static u8 crb_status(struct tpm_chip *chip) |
2469 |
+@@ -466,6 +495,10 @@ static int crb_map_io(struct acpi_device *device, struct crb_priv *priv, |
2470 |
+ dev_warn(dev, FW_BUG "Bad ACPI memory layout"); |
2471 |
+ } |
2472 |
+ |
2473 |
++ ret = __crb_request_locality(dev, priv, 0); |
2474 |
++ if (ret) |
2475 |
++ return ret; |
2476 |
++ |
2477 |
+ priv->regs_t = crb_map_res(dev, priv, &io_res, buf->control_address, |
2478 |
+ sizeof(struct crb_regs_tail)); |
2479 |
+ if (IS_ERR(priv->regs_t)) |
2480 |
+@@ -522,6 +555,8 @@ static int crb_map_io(struct acpi_device *device, struct crb_priv *priv, |
2481 |
+ |
2482 |
+ crb_go_idle(dev, priv); |
2483 |
+ |
2484 |
++ __crb_relinquish_locality(dev, priv, 0); |
2485 |
++ |
2486 |
+ return ret; |
2487 |
+ } |
2488 |
+ |
2489 |
+@@ -589,10 +624,14 @@ static int crb_acpi_add(struct acpi_device *device) |
2490 |
+ chip->acpi_dev_handle = device->handle; |
2491 |
+ chip->flags = TPM_CHIP_FLAG_TPM2; |
2492 |
+ |
2493 |
+- rc = crb_cmd_ready(dev, priv); |
2494 |
++ rc = __crb_request_locality(dev, priv, 0); |
2495 |
+ if (rc) |
2496 |
+ return rc; |
2497 |
+ |
2498 |
++ rc = crb_cmd_ready(dev, priv); |
2499 |
++ if (rc) |
2500 |
++ goto out; |
2501 |
++ |
2502 |
+ pm_runtime_get_noresume(dev); |
2503 |
+ pm_runtime_set_active(dev); |
2504 |
+ pm_runtime_enable(dev); |
2505 |
+@@ -602,12 +641,15 @@ static int crb_acpi_add(struct acpi_device *device) |
2506 |
+ crb_go_idle(dev, priv); |
2507 |
+ pm_runtime_put_noidle(dev); |
2508 |
+ pm_runtime_disable(dev); |
2509 |
+- return rc; |
2510 |
++ goto out; |
2511 |
+ } |
2512 |
+ |
2513 |
+- pm_runtime_put(dev); |
2514 |
++ pm_runtime_put_sync(dev); |
2515 |
+ |
2516 |
+- return 0; |
2517 |
++out: |
2518 |
++ __crb_relinquish_locality(dev, priv, 0); |
2519 |
++ |
2520 |
++ return rc; |
2521 |
+ } |
2522 |
+ |
2523 |
+ static int crb_acpi_remove(struct acpi_device *device) |
2524 |
+diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c |
2525 |
+index a21e31c2b952..58123df6b5f6 100644 |
2526 |
+--- a/drivers/char/tpm/tpm_tis_core.c |
2527 |
++++ b/drivers/char/tpm/tpm_tis_core.c |
2528 |
+@@ -77,11 +77,13 @@ static bool check_locality(struct tpm_chip *chip, int l) |
2529 |
+ return false; |
2530 |
+ } |
2531 |
+ |
2532 |
+-static void release_locality(struct tpm_chip *chip, int l) |
2533 |
++static int release_locality(struct tpm_chip *chip, int l) |
2534 |
+ { |
2535 |
+ struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev); |
2536 |
+ |
2537 |
+ tpm_tis_write8(priv, TPM_ACCESS(l), TPM_ACCESS_ACTIVE_LOCALITY); |
2538 |
++ |
2539 |
++ return 0; |
2540 |
+ } |
2541 |
+ |
2542 |
+ static int request_locality(struct tpm_chip *chip, int l) |
2543 |
+diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c |
2544 |
+index bf14214fa464..4db31b89507c 100644 |
2545 |
+--- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c |
2546 |
++++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c |
2547 |
+@@ -1634,6 +1634,8 @@ static void dw_hdmi_clear_overflow(struct dw_hdmi *hdmi) |
2548 |
+ * (and possibly on the platform). So far only i.MX6Q (v1.30a) and |
2549 |
+ * i.MX6DL (v1.31a) have been identified as needing the workaround, with |
2550 |
+ * 4 and 1 iterations respectively. |
2551 |
++ * The Amlogic Meson GX SoCs (v2.01a) have been identified as needing |
2552 |
++ * the workaround with a single iteration. |
2553 |
+ */ |
2554 |
+ |
2555 |
+ switch (hdmi->version) { |
2556 |
+@@ -1641,6 +1643,7 @@ static void dw_hdmi_clear_overflow(struct dw_hdmi *hdmi) |
2557 |
+ count = 4; |
2558 |
+ break; |
2559 |
+ case 0x131a: |
2560 |
++ case 0x201a: |
2561 |
+ count = 1; |
2562 |
+ break; |
2563 |
+ default: |
2564 |
+diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c |
2565 |
+index 345f6035599e..f1d93676b0fc 100644 |
2566 |
+--- a/drivers/message/fusion/mptsas.c |
2567 |
++++ b/drivers/message/fusion/mptsas.c |
2568 |
+@@ -1995,6 +1995,7 @@ static struct scsi_host_template mptsas_driver_template = { |
2569 |
+ .cmd_per_lun = 7, |
2570 |
+ .use_clustering = ENABLE_CLUSTERING, |
2571 |
+ .shost_attrs = mptscsih_host_attrs, |
2572 |
++ .no_write_same = 1, |
2573 |
+ }; |
2574 |
+ |
2575 |
+ static int mptsas_get_linkerrors(struct sas_phy *phy) |