Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:5.4 commit in: /
Date: Sat, 05 Sep 2020 10:47:52
Message-Id: 1599302854.09b9eacc5ccd529e35e950d1236d2e24afb864d2.mpagano@gentoo
1 commit: 09b9eacc5ccd529e35e950d1236d2e24afb864d2
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Sat Sep 5 10:47:34 2020 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Sat Sep 5 10:47:34 2020 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=09b9eacc
7
8 Linux patch 5.4.63
9
10 Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org>
11
12 0000_README | 4 +
13 1062_linux-5.4.63.patch | 931 ++++++++++++++++++++++++++++++++++++++++++++++++
14 2 files changed, 935 insertions(+)
15
16 diff --git a/0000_README b/0000_README
17 index edfdae1..ddaf543 100644
18 --- a/0000_README
19 +++ b/0000_README
20 @@ -291,6 +291,10 @@ Patch: 1061_linux-5.4.62.patch
21 From: http://www.kernel.org
22 Desc: Linux 5.4.62
23
24 +Patch: 1062_linux-5.4.63.patch
25 +From: http://www.kernel.org
26 +Desc: Linux 5.4.63
27 +
28 Patch: 1500_XATTR_USER_PREFIX.patch
29 From: https://bugs.gentoo.org/show_bug.cgi?id=470644
30 Desc: Support for namespace user.pax.* on tmpfs.
31
32 diff --git a/1062_linux-5.4.63.patch b/1062_linux-5.4.63.patch
33 new file mode 100644
34 index 0000000..bcca67e
35 --- /dev/null
36 +++ b/1062_linux-5.4.63.patch
37 @@ -0,0 +1,931 @@
38 +diff --git a/Documentation/devicetree/bindings/mmc/nvidia,tegra20-sdhci.txt b/Documentation/devicetree/bindings/mmc/nvidia,tegra20-sdhci.txt
39 +index 2cf3affa1be70..96c0b1440c9c5 100644
40 +--- a/Documentation/devicetree/bindings/mmc/nvidia,tegra20-sdhci.txt
41 ++++ b/Documentation/devicetree/bindings/mmc/nvidia,tegra20-sdhci.txt
42 +@@ -15,8 +15,15 @@ Required properties:
43 + - "nvidia,tegra210-sdhci": for Tegra210
44 + - "nvidia,tegra186-sdhci": for Tegra186
45 + - "nvidia,tegra194-sdhci": for Tegra194
46 +-- clocks : Must contain one entry, for the module clock.
47 +- See ../clocks/clock-bindings.txt for details.
48 ++- clocks: For Tegra210, Tegra186 and Tegra194 must contain two entries.
49 ++ One for the module clock and one for the timeout clock.
50 ++ For all other Tegra devices, must contain a single entry for
51 ++ the module clock. See ../clocks/clock-bindings.txt for details.
52 ++- clock-names: For Tegra210, Tegra186 and Tegra194 must contain the
53 ++ strings 'sdhci' and 'tmclk' to represent the module and
54 ++ the timeout clocks, respectively.
55 ++ For all other Tegra devices must contain the string 'sdhci'
56 ++ to represent the module clock.
57 + - resets : Must contain an entry for each entry in reset-names.
58 + See ../reset/reset.txt for details.
59 + - reset-names : Must include the following entries:
60 +@@ -99,7 +106,7 @@ Optional properties for Tegra210, Tegra186 and Tegra194:
61 +
62 + Example:
63 + sdhci@700b0000 {
64 +- compatible = "nvidia,tegra210-sdhci", "nvidia,tegra124-sdhci";
65 ++ compatible = "nvidia,tegra124-sdhci";
66 + reg = <0x0 0x700b0000 0x0 0x200>;
67 + interrupts = <GIC_SPI 14 IRQ_TYPE_LEVEL_HIGH>;
68 + clocks = <&tegra_car TEGRA210_CLK_SDMMC1>;
69 +@@ -115,3 +122,22 @@ sdhci@700b0000 {
70 + nvidia,pad-autocal-pull-down-offset-1v8 = <0x7b>;
71 + status = "disabled";
72 + };
73 ++
74 ++sdhci@700b0000 {
75 ++ compatible = "nvidia,tegra210-sdhci";
76 ++ reg = <0x0 0x700b0000 0x0 0x200>;
77 ++ interrupts = <GIC_SPI 14 IRQ_TYPE_LEVEL_HIGH>;
78 ++ clocks = <&tegra_car TEGRA210_CLK_SDMMC1>,
79 ++ <&tegra_car TEGRA210_CLK_SDMMC_LEGACY>;
80 ++ clock-names = "sdhci", "tmclk";
81 ++ resets = <&tegra_car 14>;
82 ++ reset-names = "sdhci";
83 ++ pinctrl-names = "sdmmc-3v3", "sdmmc-1v8";
84 ++ pinctrl-0 = <&sdmmc1_3v3>;
85 ++ pinctrl-1 = <&sdmmc1_1v8>;
86 ++ nvidia,pad-autocal-pull-up-offset-3v3 = <0x00>;
87 ++ nvidia,pad-autocal-pull-down-offset-3v3 = <0x7d>;
88 ++ nvidia,pad-autocal-pull-up-offset-1v8 = <0x7b>;
89 ++ nvidia,pad-autocal-pull-down-offset-1v8 = <0x7b>;
90 ++ status = "disabled";
91 ++};
92 +diff --git a/Makefile b/Makefile
93 +index aece56450bd9d..418814b108ae6 100644
94 +--- a/Makefile
95 ++++ b/Makefile
96 +@@ -1,7 +1,7 @@
97 + # SPDX-License-Identifier: GPL-2.0
98 + VERSION = 5
99 + PATCHLEVEL = 4
100 +-SUBLEVEL = 62
101 ++SUBLEVEL = 63
102 + EXTRAVERSION =
103 + NAME = Kleptomaniac Octopus
104 +
105 +diff --git a/arch/arm64/boot/dts/nvidia/tegra186.dtsi b/arch/arm64/boot/dts/nvidia/tegra186.dtsi
106 +index 47cd831fcf445..9abf0cb1dd67f 100644
107 +--- a/arch/arm64/boot/dts/nvidia/tegra186.dtsi
108 ++++ b/arch/arm64/boot/dts/nvidia/tegra186.dtsi
109 +@@ -309,8 +309,9 @@
110 + compatible = "nvidia,tegra186-sdhci";
111 + reg = <0x0 0x03400000 0x0 0x10000>;
112 + interrupts = <GIC_SPI 62 IRQ_TYPE_LEVEL_HIGH>;
113 +- clocks = <&bpmp TEGRA186_CLK_SDMMC1>;
114 +- clock-names = "sdhci";
115 ++ clocks = <&bpmp TEGRA186_CLK_SDMMC1>,
116 ++ <&bpmp TEGRA186_CLK_SDMMC_LEGACY_TM>;
117 ++ clock-names = "sdhci", "tmclk";
118 + resets = <&bpmp TEGRA186_RESET_SDMMC1>;
119 + reset-names = "sdhci";
120 + iommus = <&smmu TEGRA186_SID_SDMMC1>;
121 +@@ -335,8 +336,9 @@
122 + compatible = "nvidia,tegra186-sdhci";
123 + reg = <0x0 0x03420000 0x0 0x10000>;
124 + interrupts = <GIC_SPI 63 IRQ_TYPE_LEVEL_HIGH>;
125 +- clocks = <&bpmp TEGRA186_CLK_SDMMC2>;
126 +- clock-names = "sdhci";
127 ++ clocks = <&bpmp TEGRA186_CLK_SDMMC2>,
128 ++ <&bpmp TEGRA186_CLK_SDMMC_LEGACY_TM>;
129 ++ clock-names = "sdhci", "tmclk";
130 + resets = <&bpmp TEGRA186_RESET_SDMMC2>;
131 + reset-names = "sdhci";
132 + iommus = <&smmu TEGRA186_SID_SDMMC2>;
133 +@@ -356,8 +358,9 @@
134 + compatible = "nvidia,tegra186-sdhci";
135 + reg = <0x0 0x03440000 0x0 0x10000>;
136 + interrupts = <GIC_SPI 64 IRQ_TYPE_LEVEL_HIGH>;
137 +- clocks = <&bpmp TEGRA186_CLK_SDMMC3>;
138 +- clock-names = "sdhci";
139 ++ clocks = <&bpmp TEGRA186_CLK_SDMMC3>,
140 ++ <&bpmp TEGRA186_CLK_SDMMC_LEGACY_TM>;
141 ++ clock-names = "sdhci", "tmclk";
142 + resets = <&bpmp TEGRA186_RESET_SDMMC3>;
143 + reset-names = "sdhci";
144 + iommus = <&smmu TEGRA186_SID_SDMMC3>;
145 +@@ -379,8 +382,9 @@
146 + compatible = "nvidia,tegra186-sdhci";
147 + reg = <0x0 0x03460000 0x0 0x10000>;
148 + interrupts = <GIC_SPI 65 IRQ_TYPE_LEVEL_HIGH>;
149 +- clocks = <&bpmp TEGRA186_CLK_SDMMC4>;
150 +- clock-names = "sdhci";
151 ++ clocks = <&bpmp TEGRA186_CLK_SDMMC4>,
152 ++ <&bpmp TEGRA186_CLK_SDMMC_LEGACY_TM>;
153 ++ clock-names = "sdhci", "tmclk";
154 + assigned-clocks = <&bpmp TEGRA186_CLK_SDMMC4>,
155 + <&bpmp TEGRA186_CLK_PLLC4_VCO>;
156 + assigned-clock-parents = <&bpmp TEGRA186_CLK_PLLC4_VCO>;
157 +diff --git a/arch/arm64/boot/dts/nvidia/tegra194.dtsi b/arch/arm64/boot/dts/nvidia/tegra194.dtsi
158 +index 2f3926719434a..5728255bd0c1a 100644
159 +--- a/arch/arm64/boot/dts/nvidia/tegra194.dtsi
160 ++++ b/arch/arm64/boot/dts/nvidia/tegra194.dtsi
161 +@@ -403,8 +403,9 @@
162 + compatible = "nvidia,tegra194-sdhci", "nvidia,tegra186-sdhci";
163 + reg = <0x03400000 0x10000>;
164 + interrupts = <GIC_SPI 62 IRQ_TYPE_LEVEL_HIGH>;
165 +- clocks = <&bpmp TEGRA194_CLK_SDMMC1>;
166 +- clock-names = "sdhci";
167 ++ clocks = <&bpmp TEGRA194_CLK_SDMMC1>,
168 ++ <&bpmp TEGRA194_CLK_SDMMC_LEGACY_TM>;
169 ++ clock-names = "sdhci", "tmclk";
170 + resets = <&bpmp TEGRA194_RESET_SDMMC1>;
171 + reset-names = "sdhci";
172 + nvidia,pad-autocal-pull-up-offset-3v3-timeout =
173 +@@ -425,8 +426,9 @@
174 + compatible = "nvidia,tegra194-sdhci", "nvidia,tegra186-sdhci";
175 + reg = <0x03440000 0x10000>;
176 + interrupts = <GIC_SPI 64 IRQ_TYPE_LEVEL_HIGH>;
177 +- clocks = <&bpmp TEGRA194_CLK_SDMMC3>;
178 +- clock-names = "sdhci";
179 ++ clocks = <&bpmp TEGRA194_CLK_SDMMC3>,
180 ++ <&bpmp TEGRA194_CLK_SDMMC_LEGACY_TM>;
181 ++ clock-names = "sdhci", "tmclk";
182 + resets = <&bpmp TEGRA194_RESET_SDMMC3>;
183 + reset-names = "sdhci";
184 + nvidia,pad-autocal-pull-up-offset-1v8 = <0x00>;
185 +@@ -448,8 +450,9 @@
186 + compatible = "nvidia,tegra194-sdhci", "nvidia,tegra186-sdhci";
187 + reg = <0x03460000 0x10000>;
188 + interrupts = <GIC_SPI 65 IRQ_TYPE_LEVEL_HIGH>;
189 +- clocks = <&bpmp TEGRA194_CLK_SDMMC4>;
190 +- clock-names = "sdhci";
191 ++ clocks = <&bpmp TEGRA194_CLK_SDMMC4>,
192 ++ <&bpmp TEGRA194_CLK_SDMMC_LEGACY_TM>;
193 ++ clock-names = "sdhci", "tmclk";
194 + assigned-clocks = <&bpmp TEGRA194_CLK_SDMMC4>,
195 + <&bpmp TEGRA194_CLK_PLLC4>;
196 + assigned-clock-parents =
197 +diff --git a/arch/arm64/boot/dts/nvidia/tegra210.dtsi b/arch/arm64/boot/dts/nvidia/tegra210.dtsi
198 +index 659753118e96f..078d2506365c0 100644
199 +--- a/arch/arm64/boot/dts/nvidia/tegra210.dtsi
200 ++++ b/arch/arm64/boot/dts/nvidia/tegra210.dtsi
201 +@@ -1116,8 +1116,9 @@
202 + compatible = "nvidia,tegra210-sdhci", "nvidia,tegra124-sdhci";
203 + reg = <0x0 0x700b0000 0x0 0x200>;
204 + interrupts = <GIC_SPI 14 IRQ_TYPE_LEVEL_HIGH>;
205 +- clocks = <&tegra_car TEGRA210_CLK_SDMMC1>;
206 +- clock-names = "sdhci";
207 ++ clocks = <&tegra_car TEGRA210_CLK_SDMMC1>,
208 ++ <&tegra_car TEGRA210_CLK_SDMMC_LEGACY>;
209 ++ clock-names = "sdhci", "tmclk";
210 + resets = <&tegra_car 14>;
211 + reset-names = "sdhci";
212 + pinctrl-names = "sdmmc-3v3", "sdmmc-1v8",
213 +@@ -1144,8 +1145,9 @@
214 + compatible = "nvidia,tegra210-sdhci", "nvidia,tegra124-sdhci";
215 + reg = <0x0 0x700b0200 0x0 0x200>;
216 + interrupts = <GIC_SPI 15 IRQ_TYPE_LEVEL_HIGH>;
217 +- clocks = <&tegra_car TEGRA210_CLK_SDMMC2>;
218 +- clock-names = "sdhci";
219 ++ clocks = <&tegra_car TEGRA210_CLK_SDMMC2>,
220 ++ <&tegra_car TEGRA210_CLK_SDMMC_LEGACY>;
221 ++ clock-names = "sdhci", "tmclk";
222 + resets = <&tegra_car 9>;
223 + reset-names = "sdhci";
224 + pinctrl-names = "sdmmc-1v8-drv";
225 +@@ -1161,8 +1163,9 @@
226 + compatible = "nvidia,tegra210-sdhci", "nvidia,tegra124-sdhci";
227 + reg = <0x0 0x700b0400 0x0 0x200>;
228 + interrupts = <GIC_SPI 19 IRQ_TYPE_LEVEL_HIGH>;
229 +- clocks = <&tegra_car TEGRA210_CLK_SDMMC3>;
230 +- clock-names = "sdhci";
231 ++ clocks = <&tegra_car TEGRA210_CLK_SDMMC3>,
232 ++ <&tegra_car TEGRA210_CLK_SDMMC_LEGACY>;
233 ++ clock-names = "sdhci", "tmclk";
234 + resets = <&tegra_car 69>;
235 + reset-names = "sdhci";
236 + pinctrl-names = "sdmmc-3v3", "sdmmc-1v8",
237 +@@ -1184,8 +1187,9 @@
238 + compatible = "nvidia,tegra210-sdhci", "nvidia,tegra124-sdhci";
239 + reg = <0x0 0x700b0600 0x0 0x200>;
240 + interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>;
241 +- clocks = <&tegra_car TEGRA210_CLK_SDMMC4>;
242 +- clock-names = "sdhci";
243 ++ clocks = <&tegra_car TEGRA210_CLK_SDMMC4>,
244 ++ <&tegra_car TEGRA210_CLK_SDMMC_LEGACY>;
245 ++ clock-names = "sdhci", "tmclk";
246 + resets = <&tegra_car 15>;
247 + reset-names = "sdhci";
248 + pinctrl-names = "sdmmc-3v3-drv", "sdmmc-1v8-drv";
249 +diff --git a/arch/arm64/include/asm/kvm_arm.h b/arch/arm64/include/asm/kvm_arm.h
250 +index ddf9d762ac622..a4ffd9b55e72c 100644
251 +--- a/arch/arm64/include/asm/kvm_arm.h
252 ++++ b/arch/arm64/include/asm/kvm_arm.h
253 +@@ -72,11 +72,12 @@
254 + * IMO: Override CPSR.I and enable signaling with VI
255 + * FMO: Override CPSR.F and enable signaling with VF
256 + * SWIO: Turn set/way invalidates into set/way clean+invalidate
257 ++ * PTW: Take a stage2 fault if a stage1 walk steps in device memory
258 + */
259 + #define HCR_GUEST_FLAGS (HCR_TSC | HCR_TSW | HCR_TWE | HCR_TWI | HCR_VM | \
260 + HCR_TVM | HCR_BSU_IS | HCR_FB | HCR_TAC | \
261 + HCR_AMO | HCR_SWIO | HCR_TIDCP | HCR_RW | HCR_TLOR | \
262 +- HCR_FMO | HCR_IMO)
263 ++ HCR_FMO | HCR_IMO | HCR_PTW )
264 + #define HCR_VIRT_EXCP_MASK (HCR_VSE | HCR_VI | HCR_VF)
265 + #define HCR_HOST_NVHE_FLAGS (HCR_RW | HCR_API | HCR_APK)
266 + #define HCR_HOST_VHE_FLAGS (HCR_RW | HCR_TGE | HCR_E2H)
267 +diff --git a/arch/arm64/include/asm/kvm_asm.h b/arch/arm64/include/asm/kvm_asm.h
268 +index 44a243754c1b8..64d79b2884344 100644
269 +--- a/arch/arm64/include/asm/kvm_asm.h
270 ++++ b/arch/arm64/include/asm/kvm_asm.h
271 +@@ -88,6 +88,34 @@ extern u32 __kvm_get_mdcr_el2(void);
272 + *__hyp_this_cpu_ptr(sym); \
273 + })
274 +
275 ++#define __KVM_EXTABLE(from, to) \
276 ++ " .pushsection __kvm_ex_table, \"a\"\n" \
277 ++ " .align 3\n" \
278 ++ " .long (" #from " - .), (" #to " - .)\n" \
279 ++ " .popsection\n"
280 ++
281 ++
282 ++#define __kvm_at(at_op, addr) \
283 ++( { \
284 ++ int __kvm_at_err = 0; \
285 ++ u64 spsr, elr; \
286 ++ asm volatile( \
287 ++ " mrs %1, spsr_el2\n" \
288 ++ " mrs %2, elr_el2\n" \
289 ++ "1: at "at_op", %3\n" \
290 ++ " isb\n" \
291 ++ " b 9f\n" \
292 ++ "2: msr spsr_el2, %1\n" \
293 ++ " msr elr_el2, %2\n" \
294 ++ " mov %w0, %4\n" \
295 ++ "9:\n" \
296 ++ __KVM_EXTABLE(1b, 2b) \
297 ++ : "+r" (__kvm_at_err), "=&r" (spsr), "=&r" (elr) \
298 ++ : "r" (addr), "i" (-EFAULT)); \
299 ++ __kvm_at_err; \
300 ++} )
301 ++
302 ++
303 + #else /* __ASSEMBLY__ */
304 +
305 + .macro hyp_adr_this_cpu reg, sym, tmp
306 +@@ -113,6 +141,21 @@ extern u32 __kvm_get_mdcr_el2(void);
307 + kern_hyp_va \vcpu
308 + .endm
309 +
310 ++/*
311 ++ * KVM extable for unexpected exceptions.
312 ++ * In the same format _asm_extable, but output to a different section so that
313 ++ * it can be mapped to EL2. The KVM version is not sorted. The caller must
314 ++ * ensure:
315 ++ * x18 has the hypervisor value to allow any Shadow-Call-Stack instrumented
316 ++ * code to write to it, and that SPSR_EL2 and ELR_EL2 are restored by the fixup.
317 ++ */
318 ++.macro _kvm_extable, from, to
319 ++ .pushsection __kvm_ex_table, "a"
320 ++ .align 3
321 ++ .long (\from - .), (\to - .)
322 ++ .popsection
323 ++.endm
324 ++
325 + #endif
326 +
327 + #endif /* __ARM_KVM_ASM_H__ */
328 +diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S
329 +index 8d0374ffdd2d6..4f77de8ce1384 100644
330 +--- a/arch/arm64/kernel/vmlinux.lds.S
331 ++++ b/arch/arm64/kernel/vmlinux.lds.S
332 +@@ -24,6 +24,13 @@ ENTRY(_text)
333 +
334 + jiffies = jiffies_64;
335 +
336 ++
337 ++#define HYPERVISOR_EXTABLE \
338 ++ . = ALIGN(SZ_8); \
339 ++ __start___kvm_ex_table = .; \
340 ++ *(__kvm_ex_table) \
341 ++ __stop___kvm_ex_table = .;
342 ++
343 + #define HYPERVISOR_TEXT \
344 + /* \
345 + * Align to 4 KB so that \
346 +@@ -39,6 +46,7 @@ jiffies = jiffies_64;
347 + __hyp_idmap_text_end = .; \
348 + __hyp_text_start = .; \
349 + *(.hyp.text) \
350 ++ HYPERVISOR_EXTABLE \
351 + __hyp_text_end = .;
352 +
353 + #define IDMAP_TEXT \
354 +diff --git a/arch/arm64/kvm/hyp/entry.S b/arch/arm64/kvm/hyp/entry.S
355 +index e5cc8d66bf537..dc3d7bc2292fd 100644
356 +--- a/arch/arm64/kvm/hyp/entry.S
357 ++++ b/arch/arm64/kvm/hyp/entry.S
358 +@@ -173,20 +173,23 @@ alternative_endif
359 + // This is our single instruction exception window. A pending
360 + // SError is guaranteed to occur at the earliest when we unmask
361 + // it, and at the latest just after the ISB.
362 +- .global abort_guest_exit_start
363 + abort_guest_exit_start:
364 +
365 + isb
366 +
367 +- .global abort_guest_exit_end
368 + abort_guest_exit_end:
369 +
370 + msr daifset, #4 // Mask aborts
371 ++ ret
372 ++
373 ++ _kvm_extable abort_guest_exit_start, 9997f
374 ++ _kvm_extable abort_guest_exit_end, 9997f
375 ++9997:
376 ++ msr daifset, #4 // Mask aborts
377 ++ mov x0, #(1 << ARM_EXIT_WITH_SERROR_BIT)
378 +
379 +- // If the exception took place, restore the EL1 exception
380 +- // context so that we can report some information.
381 +- // Merge the exception code with the SError pending bit.
382 +- tbz x0, #ARM_EXIT_WITH_SERROR_BIT, 1f
383 ++ // restore the EL1 exception context so that we can report some
384 ++ // information. Merge the exception code with the SError pending bit.
385 + msr elr_el2, x2
386 + msr esr_el2, x3
387 + msr spsr_el2, x4
388 +diff --git a/arch/arm64/kvm/hyp/hyp-entry.S b/arch/arm64/kvm/hyp/hyp-entry.S
389 +index ffa68d5713f1d..f36aad0f207bb 100644
390 +--- a/arch/arm64/kvm/hyp/hyp-entry.S
391 ++++ b/arch/arm64/kvm/hyp/hyp-entry.S
392 +@@ -15,6 +15,30 @@
393 + #include <asm/kvm_mmu.h>
394 + #include <asm/mmu.h>
395 +
396 ++.macro save_caller_saved_regs_vect
397 ++ /* x0 and x1 were saved in the vector entry */
398 ++ stp x2, x3, [sp, #-16]!
399 ++ stp x4, x5, [sp, #-16]!
400 ++ stp x6, x7, [sp, #-16]!
401 ++ stp x8, x9, [sp, #-16]!
402 ++ stp x10, x11, [sp, #-16]!
403 ++ stp x12, x13, [sp, #-16]!
404 ++ stp x14, x15, [sp, #-16]!
405 ++ stp x16, x17, [sp, #-16]!
406 ++.endm
407 ++
408 ++.macro restore_caller_saved_regs_vect
409 ++ ldp x16, x17, [sp], #16
410 ++ ldp x14, x15, [sp], #16
411 ++ ldp x12, x13, [sp], #16
412 ++ ldp x10, x11, [sp], #16
413 ++ ldp x8, x9, [sp], #16
414 ++ ldp x6, x7, [sp], #16
415 ++ ldp x4, x5, [sp], #16
416 ++ ldp x2, x3, [sp], #16
417 ++ ldp x0, x1, [sp], #16
418 ++.endm
419 ++
420 + .text
421 + .pushsection .hyp.text, "ax"
422 +
423 +@@ -142,13 +166,19 @@ el1_error:
424 + b __guest_exit
425 +
426 + el2_sync:
427 +- /* Check for illegal exception return, otherwise panic */
428 ++ /* Check for illegal exception return */
429 + mrs x0, spsr_el2
430 ++ tbnz x0, #20, 1f
431 +
432 +- /* if this was something else, then panic! */
433 +- tst x0, #PSR_IL_BIT
434 +- b.eq __hyp_panic
435 ++ save_caller_saved_regs_vect
436 ++ stp x29, x30, [sp, #-16]!
437 ++ bl kvm_unexpected_el2_exception
438 ++ ldp x29, x30, [sp], #16
439 ++ restore_caller_saved_regs_vect
440 +
441 ++ eret
442 ++
443 ++1:
444 + /* Let's attempt a recovery from the illegal exception return */
445 + get_vcpu_ptr x1, x0
446 + mov x0, #ARM_EXCEPTION_IL
447 +@@ -156,27 +186,14 @@ el2_sync:
448 +
449 +
450 + el2_error:
451 +- ldp x0, x1, [sp], #16
452 ++ save_caller_saved_regs_vect
453 ++ stp x29, x30, [sp, #-16]!
454 ++
455 ++ bl kvm_unexpected_el2_exception
456 ++
457 ++ ldp x29, x30, [sp], #16
458 ++ restore_caller_saved_regs_vect
459 +
460 +- /*
461 +- * Only two possibilities:
462 +- * 1) Either we come from the exit path, having just unmasked
463 +- * PSTATE.A: change the return code to an EL2 fault, and
464 +- * carry on, as we're already in a sane state to handle it.
465 +- * 2) Or we come from anywhere else, and that's a bug: we panic.
466 +- *
467 +- * For (1), x0 contains the original return code and x1 doesn't
468 +- * contain anything meaningful at that stage. We can reuse them
469 +- * as temp registers.
470 +- * For (2), who cares?
471 +- */
472 +- mrs x0, elr_el2
473 +- adr x1, abort_guest_exit_start
474 +- cmp x0, x1
475 +- adr x1, abort_guest_exit_end
476 +- ccmp x0, x1, #4, ne
477 +- b.ne __hyp_panic
478 +- mov x0, #(1 << ARM_EXIT_WITH_SERROR_BIT)
479 + eret
480 + sb
481 +
482 +diff --git a/arch/arm64/kvm/hyp/switch.c b/arch/arm64/kvm/hyp/switch.c
483 +index 6f4838b475d0d..65660b6144740 100644
484 +--- a/arch/arm64/kvm/hyp/switch.c
485 ++++ b/arch/arm64/kvm/hyp/switch.c
486 +@@ -14,6 +14,7 @@
487 +
488 + #include <asm/arch_gicv3.h>
489 + #include <asm/cpufeature.h>
490 ++#include <asm/extable.h>
491 + #include <asm/kprobes.h>
492 + #include <asm/kvm_asm.h>
493 + #include <asm/kvm_emulate.h>
494 +@@ -25,6 +26,9 @@
495 + #include <asm/processor.h>
496 + #include <asm/thread_info.h>
497 +
498 ++extern struct exception_table_entry __start___kvm_ex_table;
499 ++extern struct exception_table_entry __stop___kvm_ex_table;
500 ++
501 + /* Check whether the FP regs were dirtied while in the host-side run loop: */
502 + static bool __hyp_text update_fp_enabled(struct kvm_vcpu *vcpu)
503 + {
504 +@@ -257,10 +261,10 @@ static bool __hyp_text __translate_far_to_hpfar(u64 far, u64 *hpfar)
505 + * saved the guest context yet, and we may return early...
506 + */
507 + par = read_sysreg(par_el1);
508 +- asm volatile("at s1e1r, %0" : : "r" (far));
509 +- isb();
510 +-
511 +- tmp = read_sysreg(par_el1);
512 ++ if (!__kvm_at("s1e1r", far))
513 ++ tmp = read_sysreg(par_el1);
514 ++ else
515 ++ tmp = SYS_PAR_EL1_F; /* back to the guest */
516 + write_sysreg(par, par_el1);
517 +
518 + if (unlikely(tmp & SYS_PAR_EL1_F))
519 +@@ -791,3 +795,30 @@ void __hyp_text __noreturn hyp_panic(struct kvm_cpu_context *host_ctxt)
520 +
521 + unreachable();
522 + }
523 ++
524 ++asmlinkage void __hyp_text kvm_unexpected_el2_exception(void)
525 ++{
526 ++ unsigned long addr, fixup;
527 ++ struct kvm_cpu_context *host_ctxt;
528 ++ struct exception_table_entry *entry, *end;
529 ++ unsigned long elr_el2 = read_sysreg(elr_el2);
530 ++
531 ++ entry = hyp_symbol_addr(__start___kvm_ex_table);
532 ++ end = hyp_symbol_addr(__stop___kvm_ex_table);
533 ++ host_ctxt = &__hyp_this_cpu_ptr(kvm_host_data)->host_ctxt;
534 ++
535 ++ while (entry < end) {
536 ++ addr = (unsigned long)&entry->insn + entry->insn;
537 ++ fixup = (unsigned long)&entry->fixup + entry->fixup;
538 ++
539 ++ if (addr != elr_el2) {
540 ++ entry++;
541 ++ continue;
542 ++ }
543 ++
544 ++ write_sysreg(fixup, elr_el2);
545 ++ return;
546 ++ }
547 ++
548 ++ hyp_panic(host_ctxt);
549 ++}
550 +diff --git a/drivers/gpu/drm/etnaviv/etnaviv_buffer.c b/drivers/gpu/drm/etnaviv/etnaviv_buffer.c
551 +index 7e4e2959bf4f7..0c9c40720ca9a 100644
552 +--- a/drivers/gpu/drm/etnaviv/etnaviv_buffer.c
553 ++++ b/drivers/gpu/drm/etnaviv/etnaviv_buffer.c
554 +@@ -12,6 +12,7 @@
555 +
556 + #include "common.xml.h"
557 + #include "state.xml.h"
558 ++#include "state_blt.xml.h"
559 + #include "state_hi.xml.h"
560 + #include "state_3d.xml.h"
561 + #include "cmdstream.xml.h"
562 +@@ -233,6 +234,8 @@ void etnaviv_buffer_end(struct etnaviv_gpu *gpu)
563 + struct etnaviv_cmdbuf *buffer = &gpu->buffer;
564 + unsigned int waitlink_offset = buffer->user_size - 16;
565 + u32 link_target, flush = 0;
566 ++ bool has_blt = !!(gpu->identity.minor_features5 &
567 ++ chipMinorFeatures5_BLT_ENGINE);
568 +
569 + lockdep_assert_held(&gpu->lock);
570 +
571 +@@ -248,16 +251,38 @@ void etnaviv_buffer_end(struct etnaviv_gpu *gpu)
572 + if (flush) {
573 + unsigned int dwords = 7;
574 +
575 ++ if (has_blt)
576 ++ dwords += 10;
577 ++
578 + link_target = etnaviv_buffer_reserve(gpu, buffer, dwords);
579 +
580 + CMD_SEM(buffer, SYNC_RECIPIENT_FE, SYNC_RECIPIENT_PE);
581 + CMD_STALL(buffer, SYNC_RECIPIENT_FE, SYNC_RECIPIENT_PE);
582 ++ if (has_blt) {
583 ++ CMD_LOAD_STATE(buffer, VIVS_BLT_ENABLE, 0x1);
584 ++ CMD_SEM(buffer, SYNC_RECIPIENT_FE, SYNC_RECIPIENT_BLT);
585 ++ CMD_STALL(buffer, SYNC_RECIPIENT_FE, SYNC_RECIPIENT_BLT);
586 ++ CMD_LOAD_STATE(buffer, VIVS_BLT_ENABLE, 0x0);
587 ++ }
588 + CMD_LOAD_STATE(buffer, VIVS_GL_FLUSH_CACHE, flush);
589 +- if (gpu->exec_state == ETNA_PIPE_3D)
590 +- CMD_LOAD_STATE(buffer, VIVS_TS_FLUSH_CACHE,
591 +- VIVS_TS_FLUSH_CACHE_FLUSH);
592 ++ if (gpu->exec_state == ETNA_PIPE_3D) {
593 ++ if (has_blt) {
594 ++ CMD_LOAD_STATE(buffer, VIVS_BLT_ENABLE, 0x1);
595 ++ CMD_LOAD_STATE(buffer, VIVS_BLT_SET_COMMAND, 0x1);
596 ++ CMD_LOAD_STATE(buffer, VIVS_BLT_ENABLE, 0x0);
597 ++ } else {
598 ++ CMD_LOAD_STATE(buffer, VIVS_TS_FLUSH_CACHE,
599 ++ VIVS_TS_FLUSH_CACHE_FLUSH);
600 ++ }
601 ++ }
602 + CMD_SEM(buffer, SYNC_RECIPIENT_FE, SYNC_RECIPIENT_PE);
603 + CMD_STALL(buffer, SYNC_RECIPIENT_FE, SYNC_RECIPIENT_PE);
604 ++ if (has_blt) {
605 ++ CMD_LOAD_STATE(buffer, VIVS_BLT_ENABLE, 0x1);
606 ++ CMD_SEM(buffer, SYNC_RECIPIENT_FE, SYNC_RECIPIENT_BLT);
607 ++ CMD_STALL(buffer, SYNC_RECIPIENT_FE, SYNC_RECIPIENT_BLT);
608 ++ CMD_LOAD_STATE(buffer, VIVS_BLT_ENABLE, 0x0);
609 ++ }
610 + CMD_END(buffer);
611 +
612 + etnaviv_buffer_replace_wait(buffer, waitlink_offset,
613 +@@ -323,6 +348,8 @@ void etnaviv_buffer_queue(struct etnaviv_gpu *gpu, u32 exec_state,
614 + bool switch_mmu_context = gpu->mmu_context != mmu_context;
615 + unsigned int new_flush_seq = READ_ONCE(gpu->mmu_context->flush_seq);
616 + bool need_flush = switch_mmu_context || gpu->flush_seq != new_flush_seq;
617 ++ bool has_blt = !!(gpu->identity.minor_features5 &
618 ++ chipMinorFeatures5_BLT_ENGINE);
619 +
620 + lockdep_assert_held(&gpu->lock);
621 +
622 +@@ -433,6 +460,15 @@ void etnaviv_buffer_queue(struct etnaviv_gpu *gpu, u32 exec_state,
623 + * 2 semaphore stall + 1 event + 1 wait + 1 link.
624 + */
625 + return_dwords = 7;
626 ++
627 ++ /*
628 ++ * When the BLT engine is present we need 6 more dwords in the return
629 ++ * target: 3 enable/flush/disable + 4 enable/semaphore stall/disable,
630 ++ * but we don't need the normal TS flush state.
631 ++ */
632 ++ if (has_blt)
633 ++ return_dwords += 6;
634 ++
635 + return_target = etnaviv_buffer_reserve(gpu, buffer, return_dwords);
636 + CMD_LINK(cmdbuf, return_dwords, return_target);
637 +
638 +@@ -447,11 +483,25 @@ void etnaviv_buffer_queue(struct etnaviv_gpu *gpu, u32 exec_state,
639 + CMD_LOAD_STATE(buffer, VIVS_GL_FLUSH_CACHE,
640 + VIVS_GL_FLUSH_CACHE_DEPTH |
641 + VIVS_GL_FLUSH_CACHE_COLOR);
642 +- CMD_LOAD_STATE(buffer, VIVS_TS_FLUSH_CACHE,
643 +- VIVS_TS_FLUSH_CACHE_FLUSH);
644 ++ if (has_blt) {
645 ++ CMD_LOAD_STATE(buffer, VIVS_BLT_ENABLE, 0x1);
646 ++ CMD_LOAD_STATE(buffer, VIVS_BLT_SET_COMMAND, 0x1);
647 ++ CMD_LOAD_STATE(buffer, VIVS_BLT_ENABLE, 0x0);
648 ++ } else {
649 ++ CMD_LOAD_STATE(buffer, VIVS_TS_FLUSH_CACHE,
650 ++ VIVS_TS_FLUSH_CACHE_FLUSH);
651 ++ }
652 + }
653 + CMD_SEM(buffer, SYNC_RECIPIENT_FE, SYNC_RECIPIENT_PE);
654 + CMD_STALL(buffer, SYNC_RECIPIENT_FE, SYNC_RECIPIENT_PE);
655 ++
656 ++ if (has_blt) {
657 ++ CMD_LOAD_STATE(buffer, VIVS_BLT_ENABLE, 0x1);
658 ++ CMD_SEM(buffer, SYNC_RECIPIENT_FE, SYNC_RECIPIENT_BLT);
659 ++ CMD_STALL(buffer, SYNC_RECIPIENT_FE, SYNC_RECIPIENT_BLT);
660 ++ CMD_LOAD_STATE(buffer, VIVS_BLT_ENABLE, 0x0);
661 ++ }
662 ++
663 + CMD_LOAD_STATE(buffer, VIVS_GL_EVENT, VIVS_GL_EVENT_EVENT_ID(event) |
664 + VIVS_GL_EVENT_FROM_PE);
665 + CMD_WAIT(buffer);
666 +diff --git a/drivers/gpu/drm/etnaviv/state_blt.xml.h b/drivers/gpu/drm/etnaviv/state_blt.xml.h
667 +index daae55995def0..0e8bcf9dcc93b 100644
668 +--- a/drivers/gpu/drm/etnaviv/state_blt.xml.h
669 ++++ b/drivers/gpu/drm/etnaviv/state_blt.xml.h
670 +@@ -46,6 +46,8 @@ DEALINGS IN THE SOFTWARE.
671 +
672 + /* This is a cut-down version of the state_blt.xml.h file */
673 +
674 ++#define VIVS_BLT_SET_COMMAND 0x000140ac
675 ++
676 + #define VIVS_BLT_ENABLE 0x000140b8
677 + #define VIVS_BLT_ENABLE_ENABLE 0x00000001
678 +
679 +diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c
680 +index dfb29e6eeff1e..30c5ddd6d081c 100644
681 +--- a/drivers/gpu/drm/scheduler/sched_main.c
682 ++++ b/drivers/gpu/drm/scheduler/sched_main.c
683 +@@ -496,8 +496,10 @@ void drm_sched_resubmit_jobs(struct drm_gpu_scheduler *sched)
684 + fence = sched->ops->run_job(s_job);
685 +
686 + if (IS_ERR_OR_NULL(fence)) {
687 ++ if (IS_ERR(fence))
688 ++ dma_fence_set_error(&s_fence->finished, PTR_ERR(fence));
689 ++
690 + s_job->s_fence->parent = NULL;
691 +- dma_fence_set_error(&s_fence->finished, PTR_ERR(fence));
692 + } else {
693 + s_job->s_fence->parent = fence;
694 + }
695 +@@ -748,8 +750,9 @@ static int drm_sched_main(void *param)
696 + r);
697 + dma_fence_put(fence);
698 + } else {
699 ++ if (IS_ERR(fence))
700 ++ dma_fence_set_error(&s_fence->finished, PTR_ERR(fence));
701 +
702 +- dma_fence_set_error(&s_fence->finished, PTR_ERR(fence));
703 + drm_sched_process_job(NULL, &sched_job->cb);
704 + }
705 +
706 +diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
707 +index 359616e3efbbb..d2ecc9c452554 100644
708 +--- a/drivers/hid/hid-core.c
709 ++++ b/drivers/hid/hid-core.c
710 +@@ -1597,6 +1597,17 @@ static void hid_output_field(const struct hid_device *hid,
711 + }
712 + }
713 +
714 ++/*
715 ++ * Compute the size of a report.
716 ++ */
717 ++static size_t hid_compute_report_size(struct hid_report *report)
718 ++{
719 ++ if (report->size)
720 ++ return ((report->size - 1) >> 3) + 1;
721 ++
722 ++ return 0;
723 ++}
724 ++
725 + /*
726 + * Create a report. 'data' has to be allocated using
727 + * hid_alloc_report_buf() so that it has proper size.
728 +@@ -1609,7 +1620,7 @@ void hid_output_report(struct hid_report *report, __u8 *data)
729 + if (report->id > 0)
730 + *data++ = report->id;
731 +
732 +- memset(data, 0, ((report->size - 1) >> 3) + 1);
733 ++ memset(data, 0, hid_compute_report_size(report));
734 + for (n = 0; n < report->maxfield; n++)
735 + hid_output_field(report->device, report->field[n], data);
736 + }
737 +@@ -1739,7 +1750,7 @@ int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, u32 size,
738 + csize--;
739 + }
740 +
741 +- rsize = ((report->size - 1) >> 3) + 1;
742 ++ rsize = hid_compute_report_size(report);
743 +
744 + if (report_enum->numbered && rsize >= HID_MAX_BUFFER_SIZE)
745 + rsize = HID_MAX_BUFFER_SIZE - 1;
746 +diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
747 +index e8641ce677e47..e3d475f4baf66 100644
748 +--- a/drivers/hid/hid-input.c
749 ++++ b/drivers/hid/hid-input.c
750 +@@ -1132,6 +1132,10 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
751 + }
752 +
753 + mapped:
754 ++ /* Mapping failed, bail out */
755 ++ if (!bit)
756 ++ return;
757 ++
758 + if (device->driver->input_mapped &&
759 + device->driver->input_mapped(device, hidinput, field, usage,
760 + &bit, &max) < 0) {
761 +diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
762 +index 39e4da7468e11..128d8f4319b9f 100644
763 +--- a/drivers/hid/hid-multitouch.c
764 ++++ b/drivers/hid/hid-multitouch.c
765 +@@ -864,6 +864,8 @@ static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi,
766 + code = BTN_0 + ((usage->hid - 1) & HID_USAGE);
767 +
768 + hid_map_usage(hi, usage, bit, max, EV_KEY, code);
769 ++ if (!*bit)
770 ++ return -1;
771 + input_set_capability(hi->input, EV_KEY, code);
772 + return 1;
773 +
774 +diff --git a/drivers/mmc/host/sdhci-tegra.c b/drivers/mmc/host/sdhci-tegra.c
775 +index a25c3a4d3f6cb..e37d271ca9636 100644
776 +--- a/drivers/mmc/host/sdhci-tegra.c
777 ++++ b/drivers/mmc/host/sdhci-tegra.c
778 +@@ -1370,7 +1370,6 @@ static const struct sdhci_ops tegra210_sdhci_ops = {
779 +
780 + static const struct sdhci_pltfm_data sdhci_tegra210_pdata = {
781 + .quirks = SDHCI_QUIRK_BROKEN_TIMEOUT_VAL |
782 +- SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK |
783 + SDHCI_QUIRK_SINGLE_POWER_WRITE |
784 + SDHCI_QUIRK_NO_HISPD_BIT |
785 + SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC |
786 +@@ -1407,7 +1406,6 @@ static const struct sdhci_ops tegra186_sdhci_ops = {
787 +
788 + static const struct sdhci_pltfm_data sdhci_tegra186_pdata = {
789 + .quirks = SDHCI_QUIRK_BROKEN_TIMEOUT_VAL |
790 +- SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK |
791 + SDHCI_QUIRK_SINGLE_POWER_WRITE |
792 + SDHCI_QUIRK_NO_HISPD_BIT |
793 + SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC |
794 +diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
795 +index 8888cdf3eead9..ea925b102b322 100644
796 +--- a/drivers/target/target_core_user.c
797 ++++ b/drivers/target/target_core_user.c
798 +@@ -676,8 +676,10 @@ static void scatter_data_area(struct tcmu_dev *udev,
799 + from = kmap_atomic(sg_page(sg)) + sg->offset;
800 + while (sg_remaining > 0) {
801 + if (block_remaining == 0) {
802 +- if (to)
803 ++ if (to) {
804 ++ flush_dcache_page(page);
805 + kunmap_atomic(to);
806 ++ }
807 +
808 + block_remaining = DATA_BLOCK_SIZE;
809 + dbi = tcmu_cmd_get_dbi(tcmu_cmd);
810 +@@ -722,7 +724,6 @@ static void scatter_data_area(struct tcmu_dev *udev,
811 + memcpy(to + offset,
812 + from + sg->length - sg_remaining,
813 + copy_bytes);
814 +- tcmu_flush_dcache_range(to, copy_bytes);
815 + }
816 +
817 + sg_remaining -= copy_bytes;
818 +@@ -731,8 +732,10 @@ static void scatter_data_area(struct tcmu_dev *udev,
819 + kunmap_atomic(from - sg->offset);
820 + }
821 +
822 +- if (to)
823 ++ if (to) {
824 ++ flush_dcache_page(page);
825 + kunmap_atomic(to);
826 ++ }
827 + }
828 +
829 + static void gather_data_area(struct tcmu_dev *udev, struct tcmu_cmd *cmd,
830 +@@ -778,13 +781,13 @@ static void gather_data_area(struct tcmu_dev *udev, struct tcmu_cmd *cmd,
831 + dbi = tcmu_cmd_get_dbi(cmd);
832 + page = tcmu_get_block_page(udev, dbi);
833 + from = kmap_atomic(page);
834 ++ flush_dcache_page(page);
835 + }
836 + copy_bytes = min_t(size_t, sg_remaining,
837 + block_remaining);
838 + if (read_len < copy_bytes)
839 + copy_bytes = read_len;
840 + offset = DATA_BLOCK_SIZE - block_remaining;
841 +- tcmu_flush_dcache_range(from, copy_bytes);
842 + memcpy(to + sg->length - sg_remaining, from + offset,
843 + copy_bytes);
844 +
845 +@@ -1007,7 +1010,7 @@ static int queue_cmd_ring(struct tcmu_cmd *tcmu_cmd, sense_reason_t *scsi_err)
846 + entry->hdr.cmd_id = 0; /* not used for PAD */
847 + entry->hdr.kflags = 0;
848 + entry->hdr.uflags = 0;
849 +- tcmu_flush_dcache_range(entry, sizeof(*entry));
850 ++ tcmu_flush_dcache_range(entry, sizeof(entry->hdr));
851 +
852 + UPDATE_HEAD(mb->cmd_head, pad_size, udev->cmdr_size);
853 + tcmu_flush_dcache_range(mb, sizeof(*mb));
854 +@@ -1072,7 +1075,7 @@ static int queue_cmd_ring(struct tcmu_cmd *tcmu_cmd, sense_reason_t *scsi_err)
855 + cdb_off = CMDR_OFF + cmd_head + base_command_size;
856 + memcpy((void *) mb + cdb_off, se_cmd->t_task_cdb, scsi_command_size(se_cmd->t_task_cdb));
857 + entry->req.cdb_off = cdb_off;
858 +- tcmu_flush_dcache_range(entry, sizeof(*entry));
859 ++ tcmu_flush_dcache_range(entry, command_size);
860 +
861 + UPDATE_HEAD(mb->cmd_head, command_size, udev->cmdr_size);
862 + tcmu_flush_dcache_range(mb, sizeof(*mb));
863 +diff --git a/include/linux/hid.h b/include/linux/hid.h
864 +index 875f71132b142..c7044a14200ea 100644
865 +--- a/include/linux/hid.h
866 ++++ b/include/linux/hid.h
867 +@@ -959,34 +959,49 @@ static inline void hid_device_io_stop(struct hid_device *hid) {
868 + * @max: maximal valid usage->code to consider later (out parameter)
869 + * @type: input event type (EV_KEY, EV_REL, ...)
870 + * @c: code which corresponds to this usage and type
871 ++ *
872 ++ * The value pointed to by @bit will be set to NULL if either @type is
873 ++ * an unhandled event type, or if @c is out of range for @type. This
874 ++ * can be used as an error condition.
875 + */
876 + static inline void hid_map_usage(struct hid_input *hidinput,
877 + struct hid_usage *usage, unsigned long **bit, int *max,
878 +- __u8 type, __u16 c)
879 ++ __u8 type, unsigned int c)
880 + {
881 + struct input_dev *input = hidinput->input;
882 +-
883 +- usage->type = type;
884 +- usage->code = c;
885 ++ unsigned long *bmap = NULL;
886 ++ unsigned int limit = 0;
887 +
888 + switch (type) {
889 + case EV_ABS:
890 +- *bit = input->absbit;
891 +- *max = ABS_MAX;
892 ++ bmap = input->absbit;
893 ++ limit = ABS_MAX;
894 + break;
895 + case EV_REL:
896 +- *bit = input->relbit;
897 +- *max = REL_MAX;
898 ++ bmap = input->relbit;
899 ++ limit = REL_MAX;
900 + break;
901 + case EV_KEY:
902 +- *bit = input->keybit;
903 +- *max = KEY_MAX;
904 ++ bmap = input->keybit;
905 ++ limit = KEY_MAX;
906 + break;
907 + case EV_LED:
908 +- *bit = input->ledbit;
909 +- *max = LED_MAX;
910 ++ bmap = input->ledbit;
911 ++ limit = LED_MAX;
912 + break;
913 + }
914 ++
915 ++ if (unlikely(c > limit || !bmap)) {
916 ++ pr_warn_ratelimited("%s: Invalid code %d type %d\n",
917 ++ input->name, c, type);
918 ++ *bit = NULL;
919 ++ return;
920 ++ }
921 ++
922 ++ usage->type = type;
923 ++ usage->code = c;
924 ++ *max = limit;
925 ++ *bit = bmap;
926 + }
927 +
928 + /**
929 +@@ -1000,7 +1015,8 @@ static inline void hid_map_usage_clear(struct hid_input *hidinput,
930 + __u8 type, __u16 c)
931 + {
932 + hid_map_usage(hidinput, usage, bit, max, type, c);
933 +- clear_bit(c, *bit);
934 ++ if (*bit)
935 ++ clear_bit(usage->code, *bit);
936 + }
937 +
938 + /**
939 +diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt
940 +index c6f9f31b60398..15fd108afbe63 100644
941 +--- a/tools/perf/Documentation/perf-record.txt
942 ++++ b/tools/perf/Documentation/perf-record.txt
943 +@@ -33,6 +33,10 @@ OPTIONS
944 + - a raw PMU event (eventsel+umask) in the form of rNNN where NNN is a
945 + hexadecimal event descriptor.
946 +
947 ++ - a symbolic or raw PMU event followed by an optional colon
948 ++ and a list of event modifiers, e.g., cpu-cycles:p. See the
949 ++ linkperf:perf-list[1] man page for details on event modifiers.
950 ++
951 + - a symbolically formed PMU event like 'pmu/param1=0x3,param2/' where
952 + 'param1', 'param2', etc are defined as formats for the PMU in
953 + /sys/bus/event_source/devices/<pmu>/format/*.
954 +diff --git a/tools/perf/Documentation/perf-stat.txt b/tools/perf/Documentation/perf-stat.txt
955 +index 930c51c01201a..9abf1cf217e28 100644
956 +--- a/tools/perf/Documentation/perf-stat.txt
957 ++++ b/tools/perf/Documentation/perf-stat.txt
958 +@@ -39,6 +39,10 @@ report::
959 + - a raw PMU event (eventsel+umask) in the form of rNNN where NNN is a
960 + hexadecimal event descriptor.
961 +
962 ++ - a symbolic or raw PMU event followed by an optional colon
963 ++ and a list of event modifiers, e.g., cpu-cycles:p. See the
964 ++ linkperf:perf-list[1] man page for details on event modifiers.
965 ++
966 + - a symbolically formed event like 'pmu/param1=0x3,param2/' where
967 + param1 and param2 are defined as formats for the PMU in
968 + /sys/bus/event_source/devices/<pmu>/format/*