Contents of /trunk/kernel-alx/patches-5.4/0118-5.4.19-all-fixes.patch
Parent Directory | Revision Log
Revision 3499 -
(show annotations)
(download)
Mon May 11 14:36:20 2020 UTC (4 years, 4 months ago) by niro
File size: 515166 byte(s)
Mon May 11 14:36:20 2020 UTC (4 years, 4 months ago) by niro
File size: 515166 byte(s)
-linux-5.4.19
1 | diff --git a/MAINTAINERS b/MAINTAINERS |
2 | index 4f7ac27d8651..d1aeebb59e6a 100644 |
3 | --- a/MAINTAINERS |
4 | +++ b/MAINTAINERS |
5 | @@ -8704,8 +8704,10 @@ L: isdn4linux@listserv.isdn4linux.de (subscribers-only) |
6 | L: netdev@vger.kernel.org |
7 | W: http://www.isdn4linux.de |
8 | S: Maintained |
9 | -F: drivers/isdn/mISDN |
10 | -F: drivers/isdn/hardware |
11 | +F: drivers/isdn/mISDN/ |
12 | +F: drivers/isdn/hardware/ |
13 | +F: drivers/isdn/Kconfig |
14 | +F: drivers/isdn/Makefile |
15 | |
16 | ISDN/CAPI SUBSYSTEM |
17 | M: Karsten Keil <isdn@linux-pingi.de> |
18 | diff --git a/Makefile b/Makefile |
19 | index b6c151fd5227..2f55d377f0db 100644 |
20 | --- a/Makefile |
21 | +++ b/Makefile |
22 | @@ -1,7 +1,7 @@ |
23 | # SPDX-License-Identifier: GPL-2.0 |
24 | VERSION = 5 |
25 | PATCHLEVEL = 4 |
26 | -SUBLEVEL = 18 |
27 | +SUBLEVEL = 19 |
28 | EXTRAVERSION = |
29 | NAME = Kleptomaniac Octopus |
30 | |
31 | diff --git a/arch/Kconfig b/arch/Kconfig |
32 | index 5f8a5d84dbbe..43102756304c 100644 |
33 | --- a/arch/Kconfig |
34 | +++ b/arch/Kconfig |
35 | @@ -396,9 +396,6 @@ config HAVE_ARCH_JUMP_LABEL_RELATIVE |
36 | config HAVE_RCU_TABLE_FREE |
37 | bool |
38 | |
39 | -config HAVE_RCU_TABLE_NO_INVALIDATE |
40 | - bool |
41 | - |
42 | config HAVE_MMU_GATHER_PAGE_SIZE |
43 | bool |
44 | |
45 | diff --git a/arch/arm/include/asm/kvm_emulate.h b/arch/arm/include/asm/kvm_emulate.h |
46 | index 40002416efec..8e995ec796c8 100644 |
47 | --- a/arch/arm/include/asm/kvm_emulate.h |
48 | +++ b/arch/arm/include/asm/kvm_emulate.h |
49 | @@ -14,13 +14,25 @@ |
50 | #include <asm/cputype.h> |
51 | |
52 | /* arm64 compatibility macros */ |
53 | +#define PSR_AA32_MODE_FIQ FIQ_MODE |
54 | +#define PSR_AA32_MODE_SVC SVC_MODE |
55 | #define PSR_AA32_MODE_ABT ABT_MODE |
56 | #define PSR_AA32_MODE_UND UND_MODE |
57 | #define PSR_AA32_T_BIT PSR_T_BIT |
58 | +#define PSR_AA32_F_BIT PSR_F_BIT |
59 | #define PSR_AA32_I_BIT PSR_I_BIT |
60 | #define PSR_AA32_A_BIT PSR_A_BIT |
61 | #define PSR_AA32_E_BIT PSR_E_BIT |
62 | #define PSR_AA32_IT_MASK PSR_IT_MASK |
63 | +#define PSR_AA32_GE_MASK 0x000f0000 |
64 | +#define PSR_AA32_DIT_BIT 0x00200000 |
65 | +#define PSR_AA32_PAN_BIT 0x00400000 |
66 | +#define PSR_AA32_SSBS_BIT 0x00800000 |
67 | +#define PSR_AA32_Q_BIT PSR_Q_BIT |
68 | +#define PSR_AA32_V_BIT PSR_V_BIT |
69 | +#define PSR_AA32_C_BIT PSR_C_BIT |
70 | +#define PSR_AA32_Z_BIT PSR_Z_BIT |
71 | +#define PSR_AA32_N_BIT PSR_N_BIT |
72 | |
73 | unsigned long *vcpu_reg(struct kvm_vcpu *vcpu, u8 reg_num); |
74 | |
75 | @@ -41,6 +53,11 @@ static inline void vcpu_write_spsr(struct kvm_vcpu *vcpu, unsigned long v) |
76 | *__vcpu_spsr(vcpu) = v; |
77 | } |
78 | |
79 | +static inline unsigned long host_spsr_to_spsr32(unsigned long spsr) |
80 | +{ |
81 | + return spsr; |
82 | +} |
83 | + |
84 | static inline unsigned long vcpu_get_reg(struct kvm_vcpu *vcpu, |
85 | u8 reg_num) |
86 | { |
87 | @@ -177,6 +194,11 @@ static inline bool kvm_vcpu_dabt_issext(struct kvm_vcpu *vcpu) |
88 | return kvm_vcpu_get_hsr(vcpu) & HSR_SSE; |
89 | } |
90 | |
91 | +static inline bool kvm_vcpu_dabt_issf(const struct kvm_vcpu *vcpu) |
92 | +{ |
93 | + return false; |
94 | +} |
95 | + |
96 | static inline int kvm_vcpu_dabt_get_rd(struct kvm_vcpu *vcpu) |
97 | { |
98 | return (kvm_vcpu_get_hsr(vcpu) & HSR_SRT_MASK) >> HSR_SRT_SHIFT; |
99 | diff --git a/arch/arm/include/asm/kvm_mmio.h b/arch/arm/include/asm/kvm_mmio.h |
100 | index 7c0eddb0adb2..32fbf82e3ebc 100644 |
101 | --- a/arch/arm/include/asm/kvm_mmio.h |
102 | +++ b/arch/arm/include/asm/kvm_mmio.h |
103 | @@ -14,6 +14,8 @@ |
104 | struct kvm_decode { |
105 | unsigned long rt; |
106 | bool sign_extend; |
107 | + /* Not used on 32-bit arm */ |
108 | + bool sixty_four; |
109 | }; |
110 | |
111 | void kvm_mmio_write_buf(void *buf, unsigned int len, unsigned long data); |
112 | diff --git a/arch/arm/mach-tegra/sleep-tegra30.S b/arch/arm/mach-tegra/sleep-tegra30.S |
113 | index b408fa56eb89..6922dd8d3e2d 100644 |
114 | --- a/arch/arm/mach-tegra/sleep-tegra30.S |
115 | +++ b/arch/arm/mach-tegra/sleep-tegra30.S |
116 | @@ -370,6 +370,14 @@ _pll_m_c_x_done: |
117 | pll_locked r1, r0, CLK_RESET_PLLC_BASE |
118 | pll_locked r1, r0, CLK_RESET_PLLX_BASE |
119 | |
120 | + tegra_get_soc_id TEGRA_APB_MISC_BASE, r1 |
121 | + cmp r1, #TEGRA30 |
122 | + beq 1f |
123 | + ldr r1, [r0, #CLK_RESET_PLLP_BASE] |
124 | + bic r1, r1, #(1<<31) @ disable PllP bypass |
125 | + str r1, [r0, #CLK_RESET_PLLP_BASE] |
126 | +1: |
127 | + |
128 | mov32 r7, TEGRA_TMRUS_BASE |
129 | ldr r1, [r7] |
130 | add r1, r1, #LOCK_DELAY |
131 | @@ -630,7 +638,10 @@ tegra30_switch_cpu_to_clk32k: |
132 | str r0, [r4, #PMC_PLLP_WB0_OVERRIDE] |
133 | |
134 | /* disable PLLP, PLLA, PLLC and PLLX */ |
135 | + tegra_get_soc_id TEGRA_APB_MISC_BASE, r1 |
136 | + cmp r1, #TEGRA30 |
137 | ldr r0, [r5, #CLK_RESET_PLLP_BASE] |
138 | + orrne r0, r0, #(1 << 31) @ enable PllP bypass on fast cluster |
139 | bic r0, r0, #(1 << 30) |
140 | str r0, [r5, #CLK_RESET_PLLP_BASE] |
141 | ldr r0, [r5, #CLK_RESET_PLLA_BASE] |
142 | diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c |
143 | index 7d042d5c43e3..27576c7b836e 100644 |
144 | --- a/arch/arm/mm/dma-mapping.c |
145 | +++ b/arch/arm/mm/dma-mapping.c |
146 | @@ -221,7 +221,7 @@ EXPORT_SYMBOL(arm_coherent_dma_ops); |
147 | |
148 | static int __dma_supported(struct device *dev, u64 mask, bool warn) |
149 | { |
150 | - unsigned long max_dma_pfn = min(max_pfn, arm_dma_pfn_limit); |
151 | + unsigned long max_dma_pfn = min(max_pfn - 1, arm_dma_pfn_limit); |
152 | |
153 | /* |
154 | * Translate the device's DMA mask to a PFN limit. This |
155 | diff --git a/arch/arm64/boot/dts/qcom/qcs404-evb.dtsi b/arch/arm64/boot/dts/qcom/qcs404-evb.dtsi |
156 | index 501a7330dbc8..522d3ef72df5 100644 |
157 | --- a/arch/arm64/boot/dts/qcom/qcs404-evb.dtsi |
158 | +++ b/arch/arm64/boot/dts/qcom/qcs404-evb.dtsi |
159 | @@ -73,6 +73,7 @@ |
160 | regulator-always-on; |
161 | regulator-boot-on; |
162 | regulator-name = "vdd_apc"; |
163 | + regulator-initial-mode = <1>; |
164 | regulator-min-microvolt = <1048000>; |
165 | regulator-max-microvolt = <1384000>; |
166 | }; |
167 | diff --git a/arch/arm64/crypto/ghash-ce-glue.c b/arch/arm64/crypto/ghash-ce-glue.c |
168 | index 70b1469783f9..24bc0a3f26e2 100644 |
169 | --- a/arch/arm64/crypto/ghash-ce-glue.c |
170 | +++ b/arch/arm64/crypto/ghash-ce-glue.c |
171 | @@ -261,7 +261,7 @@ static int ghash_setkey(struct crypto_shash *tfm, |
172 | static struct shash_alg ghash_alg[] = {{ |
173 | .base.cra_name = "ghash", |
174 | .base.cra_driver_name = "ghash-neon", |
175 | - .base.cra_priority = 100, |
176 | + .base.cra_priority = 150, |
177 | .base.cra_blocksize = GHASH_BLOCK_SIZE, |
178 | .base.cra_ctxsize = sizeof(struct ghash_key), |
179 | .base.cra_module = THIS_MODULE, |
180 | diff --git a/arch/arm64/include/asm/daifflags.h b/arch/arm64/include/asm/daifflags.h |
181 | index 063c964af705..48bfbf70dbb0 100644 |
182 | --- a/arch/arm64/include/asm/daifflags.h |
183 | +++ b/arch/arm64/include/asm/daifflags.h |
184 | @@ -36,7 +36,7 @@ static inline void local_daif_mask(void) |
185 | trace_hardirqs_off(); |
186 | } |
187 | |
188 | -static inline unsigned long local_daif_save(void) |
189 | +static inline unsigned long local_daif_save_flags(void) |
190 | { |
191 | unsigned long flags; |
192 | |
193 | @@ -48,6 +48,15 @@ static inline unsigned long local_daif_save(void) |
194 | flags |= PSR_I_BIT; |
195 | } |
196 | |
197 | + return flags; |
198 | +} |
199 | + |
200 | +static inline unsigned long local_daif_save(void) |
201 | +{ |
202 | + unsigned long flags; |
203 | + |
204 | + flags = local_daif_save_flags(); |
205 | + |
206 | local_daif_mask(); |
207 | |
208 | return flags; |
209 | diff --git a/arch/arm64/include/asm/kvm_emulate.h b/arch/arm64/include/asm/kvm_emulate.h |
210 | index d69c1efc63e7..6ff84f1f3b4c 100644 |
211 | --- a/arch/arm64/include/asm/kvm_emulate.h |
212 | +++ b/arch/arm64/include/asm/kvm_emulate.h |
213 | @@ -204,6 +204,38 @@ static inline void vcpu_write_spsr(struct kvm_vcpu *vcpu, unsigned long v) |
214 | vcpu_gp_regs(vcpu)->spsr[KVM_SPSR_EL1] = v; |
215 | } |
216 | |
217 | +/* |
218 | + * The layout of SPSR for an AArch32 state is different when observed from an |
219 | + * AArch64 SPSR_ELx or an AArch32 SPSR_*. This function generates the AArch32 |
220 | + * view given an AArch64 view. |
221 | + * |
222 | + * In ARM DDI 0487E.a see: |
223 | + * |
224 | + * - The AArch64 view (SPSR_EL2) in section C5.2.18, page C5-426 |
225 | + * - The AArch32 view (SPSR_abt) in section G8.2.126, page G8-6256 |
226 | + * - The AArch32 view (SPSR_und) in section G8.2.132, page G8-6280 |
227 | + * |
228 | + * Which show the following differences: |
229 | + * |
230 | + * | Bit | AA64 | AA32 | Notes | |
231 | + * +-----+------+------+-----------------------------| |
232 | + * | 24 | DIT | J | J is RES0 in ARMv8 | |
233 | + * | 21 | SS | DIT | SS doesn't exist in AArch32 | |
234 | + * |
235 | + * ... and all other bits are (currently) common. |
236 | + */ |
237 | +static inline unsigned long host_spsr_to_spsr32(unsigned long spsr) |
238 | +{ |
239 | + const unsigned long overlap = BIT(24) | BIT(21); |
240 | + unsigned long dit = !!(spsr & PSR_AA32_DIT_BIT); |
241 | + |
242 | + spsr &= ~overlap; |
243 | + |
244 | + spsr |= dit << 21; |
245 | + |
246 | + return spsr; |
247 | +} |
248 | + |
249 | static inline bool vcpu_mode_priv(const struct kvm_vcpu *vcpu) |
250 | { |
251 | u32 mode; |
252 | @@ -263,6 +295,11 @@ static inline bool kvm_vcpu_dabt_issext(const struct kvm_vcpu *vcpu) |
253 | return !!(kvm_vcpu_get_hsr(vcpu) & ESR_ELx_SSE); |
254 | } |
255 | |
256 | +static inline bool kvm_vcpu_dabt_issf(const struct kvm_vcpu *vcpu) |
257 | +{ |
258 | + return !!(kvm_vcpu_get_hsr(vcpu) & ESR_ELx_SF); |
259 | +} |
260 | + |
261 | static inline int kvm_vcpu_dabt_get_rd(const struct kvm_vcpu *vcpu) |
262 | { |
263 | return (kvm_vcpu_get_hsr(vcpu) & ESR_ELx_SRT_MASK) >> ESR_ELx_SRT_SHIFT; |
264 | diff --git a/arch/arm64/include/asm/kvm_mmio.h b/arch/arm64/include/asm/kvm_mmio.h |
265 | index 02b5c48fd467..b204501a0c39 100644 |
266 | --- a/arch/arm64/include/asm/kvm_mmio.h |
267 | +++ b/arch/arm64/include/asm/kvm_mmio.h |
268 | @@ -10,13 +10,11 @@ |
269 | #include <linux/kvm_host.h> |
270 | #include <asm/kvm_arm.h> |
271 | |
272 | -/* |
273 | - * This is annoying. The mmio code requires this, even if we don't |
274 | - * need any decoding. To be fixed. |
275 | - */ |
276 | struct kvm_decode { |
277 | unsigned long rt; |
278 | bool sign_extend; |
279 | + /* Witdth of the register accessed by the faulting instruction is 64-bits */ |
280 | + bool sixty_four; |
281 | }; |
282 | |
283 | void kvm_mmio_write_buf(void *buf, unsigned int len, unsigned long data); |
284 | diff --git a/arch/arm64/include/asm/ptrace.h b/arch/arm64/include/asm/ptrace.h |
285 | index fbebb411ae20..bf57308fcd63 100644 |
286 | --- a/arch/arm64/include/asm/ptrace.h |
287 | +++ b/arch/arm64/include/asm/ptrace.h |
288 | @@ -62,6 +62,7 @@ |
289 | #define PSR_AA32_I_BIT 0x00000080 |
290 | #define PSR_AA32_A_BIT 0x00000100 |
291 | #define PSR_AA32_E_BIT 0x00000200 |
292 | +#define PSR_AA32_PAN_BIT 0x00400000 |
293 | #define PSR_AA32_SSBS_BIT 0x00800000 |
294 | #define PSR_AA32_DIT_BIT 0x01000000 |
295 | #define PSR_AA32_Q_BIT 0x08000000 |
296 | diff --git a/arch/arm64/include/uapi/asm/ptrace.h b/arch/arm64/include/uapi/asm/ptrace.h |
297 | index 7ed9294e2004..d1bb5b69f1ce 100644 |
298 | --- a/arch/arm64/include/uapi/asm/ptrace.h |
299 | +++ b/arch/arm64/include/uapi/asm/ptrace.h |
300 | @@ -49,6 +49,7 @@ |
301 | #define PSR_SSBS_BIT 0x00001000 |
302 | #define PSR_PAN_BIT 0x00400000 |
303 | #define PSR_UAO_BIT 0x00800000 |
304 | +#define PSR_DIT_BIT 0x01000000 |
305 | #define PSR_V_BIT 0x10000000 |
306 | #define PSR_C_BIT 0x20000000 |
307 | #define PSR_Z_BIT 0x40000000 |
308 | diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c |
309 | index 3a58e9db5cfe..a100483b47c4 100644 |
310 | --- a/arch/arm64/kernel/acpi.c |
311 | +++ b/arch/arm64/kernel/acpi.c |
312 | @@ -274,7 +274,7 @@ int apei_claim_sea(struct pt_regs *regs) |
313 | if (!IS_ENABLED(CONFIG_ACPI_APEI_GHES)) |
314 | return err; |
315 | |
316 | - current_flags = arch_local_save_flags(); |
317 | + current_flags = local_daif_save_flags(); |
318 | |
319 | /* |
320 | * SEA can interrupt SError, mask it and describe this as an NMI so |
321 | diff --git a/arch/arm64/kvm/inject_fault.c b/arch/arm64/kvm/inject_fault.c |
322 | index a9d25a305af5..a364a4ad5479 100644 |
323 | --- a/arch/arm64/kvm/inject_fault.c |
324 | +++ b/arch/arm64/kvm/inject_fault.c |
325 | @@ -14,9 +14,6 @@ |
326 | #include <asm/kvm_emulate.h> |
327 | #include <asm/esr.h> |
328 | |
329 | -#define PSTATE_FAULT_BITS_64 (PSR_MODE_EL1h | PSR_A_BIT | PSR_F_BIT | \ |
330 | - PSR_I_BIT | PSR_D_BIT) |
331 | - |
332 | #define CURRENT_EL_SP_EL0_VECTOR 0x0 |
333 | #define CURRENT_EL_SP_ELx_VECTOR 0x200 |
334 | #define LOWER_EL_AArch64_VECTOR 0x400 |
335 | @@ -50,6 +47,69 @@ static u64 get_except_vector(struct kvm_vcpu *vcpu, enum exception_type type) |
336 | return vcpu_read_sys_reg(vcpu, VBAR_EL1) + exc_offset + type; |
337 | } |
338 | |
339 | +/* |
340 | + * When an exception is taken, most PSTATE fields are left unchanged in the |
341 | + * handler. However, some are explicitly overridden (e.g. M[4:0]). Luckily all |
342 | + * of the inherited bits have the same position in the AArch64/AArch32 SPSR_ELx |
343 | + * layouts, so we don't need to shuffle these for exceptions from AArch32 EL0. |
344 | + * |
345 | + * For the SPSR_ELx layout for AArch64, see ARM DDI 0487E.a page C5-429. |
346 | + * For the SPSR_ELx layout for AArch32, see ARM DDI 0487E.a page C5-426. |
347 | + * |
348 | + * Here we manipulate the fields in order of the AArch64 SPSR_ELx layout, from |
349 | + * MSB to LSB. |
350 | + */ |
351 | +static unsigned long get_except64_pstate(struct kvm_vcpu *vcpu) |
352 | +{ |
353 | + unsigned long sctlr = vcpu_read_sys_reg(vcpu, SCTLR_EL1); |
354 | + unsigned long old, new; |
355 | + |
356 | + old = *vcpu_cpsr(vcpu); |
357 | + new = 0; |
358 | + |
359 | + new |= (old & PSR_N_BIT); |
360 | + new |= (old & PSR_Z_BIT); |
361 | + new |= (old & PSR_C_BIT); |
362 | + new |= (old & PSR_V_BIT); |
363 | + |
364 | + // TODO: TCO (if/when ARMv8.5-MemTag is exposed to guests) |
365 | + |
366 | + new |= (old & PSR_DIT_BIT); |
367 | + |
368 | + // PSTATE.UAO is set to zero upon any exception to AArch64 |
369 | + // See ARM DDI 0487E.a, page D5-2579. |
370 | + |
371 | + // PSTATE.PAN is unchanged unless SCTLR_ELx.SPAN == 0b0 |
372 | + // SCTLR_ELx.SPAN is RES1 when ARMv8.1-PAN is not implemented |
373 | + // See ARM DDI 0487E.a, page D5-2578. |
374 | + new |= (old & PSR_PAN_BIT); |
375 | + if (!(sctlr & SCTLR_EL1_SPAN)) |
376 | + new |= PSR_PAN_BIT; |
377 | + |
378 | + // PSTATE.SS is set to zero upon any exception to AArch64 |
379 | + // See ARM DDI 0487E.a, page D2-2452. |
380 | + |
381 | + // PSTATE.IL is set to zero upon any exception to AArch64 |
382 | + // See ARM DDI 0487E.a, page D1-2306. |
383 | + |
384 | + // PSTATE.SSBS is set to SCTLR_ELx.DSSBS upon any exception to AArch64 |
385 | + // See ARM DDI 0487E.a, page D13-3258 |
386 | + if (sctlr & SCTLR_ELx_DSSBS) |
387 | + new |= PSR_SSBS_BIT; |
388 | + |
389 | + // PSTATE.BTYPE is set to zero upon any exception to AArch64 |
390 | + // See ARM DDI 0487E.a, pages D1-2293 to D1-2294. |
391 | + |
392 | + new |= PSR_D_BIT; |
393 | + new |= PSR_A_BIT; |
394 | + new |= PSR_I_BIT; |
395 | + new |= PSR_F_BIT; |
396 | + |
397 | + new |= PSR_MODE_EL1h; |
398 | + |
399 | + return new; |
400 | +} |
401 | + |
402 | static void inject_abt64(struct kvm_vcpu *vcpu, bool is_iabt, unsigned long addr) |
403 | { |
404 | unsigned long cpsr = *vcpu_cpsr(vcpu); |
405 | @@ -59,7 +119,7 @@ static void inject_abt64(struct kvm_vcpu *vcpu, bool is_iabt, unsigned long addr |
406 | vcpu_write_elr_el1(vcpu, *vcpu_pc(vcpu)); |
407 | *vcpu_pc(vcpu) = get_except_vector(vcpu, except_type_sync); |
408 | |
409 | - *vcpu_cpsr(vcpu) = PSTATE_FAULT_BITS_64; |
410 | + *vcpu_cpsr(vcpu) = get_except64_pstate(vcpu); |
411 | vcpu_write_spsr(vcpu, cpsr); |
412 | |
413 | vcpu_write_sys_reg(vcpu, addr, FAR_EL1); |
414 | @@ -94,7 +154,7 @@ static void inject_undef64(struct kvm_vcpu *vcpu) |
415 | vcpu_write_elr_el1(vcpu, *vcpu_pc(vcpu)); |
416 | *vcpu_pc(vcpu) = get_except_vector(vcpu, except_type_sync); |
417 | |
418 | - *vcpu_cpsr(vcpu) = PSTATE_FAULT_BITS_64; |
419 | + *vcpu_cpsr(vcpu) = get_except64_pstate(vcpu); |
420 | vcpu_write_spsr(vcpu, cpsr); |
421 | |
422 | /* |
423 | diff --git a/arch/mips/Makefile.postlink b/arch/mips/Makefile.postlink |
424 | index 4eea4188cb20..13e0beb9eee3 100644 |
425 | --- a/arch/mips/Makefile.postlink |
426 | +++ b/arch/mips/Makefile.postlink |
427 | @@ -12,7 +12,7 @@ __archpost: |
428 | include scripts/Kbuild.include |
429 | |
430 | CMD_RELOCS = arch/mips/boot/tools/relocs |
431 | -quiet_cmd_relocs = RELOCS $@ |
432 | +quiet_cmd_relocs = RELOCS $@ |
433 | cmd_relocs = $(CMD_RELOCS) $@ |
434 | |
435 | # `@true` prevents complaint when there is nothing to be done |
436 | diff --git a/arch/mips/boot/Makefile b/arch/mips/boot/Makefile |
437 | index 528bd73d530a..4ed45ade32a1 100644 |
438 | --- a/arch/mips/boot/Makefile |
439 | +++ b/arch/mips/boot/Makefile |
440 | @@ -123,7 +123,7 @@ $(obj)/vmlinux.its.S: $(addprefix $(srctree)/arch/mips/$(PLATFORM)/,$(ITS_INPUTS |
441 | targets += vmlinux.its |
442 | targets += vmlinux.gz.its |
443 | targets += vmlinux.bz2.its |
444 | -targets += vmlinux.lzmo.its |
445 | +targets += vmlinux.lzma.its |
446 | targets += vmlinux.lzo.its |
447 | |
448 | quiet_cmd_cpp_its_S = ITS $@ |
449 | diff --git a/arch/mips/kernel/syscalls/Makefile b/arch/mips/kernel/syscalls/Makefile |
450 | index a3d4bec695c6..6efb2f6889a7 100644 |
451 | --- a/arch/mips/kernel/syscalls/Makefile |
452 | +++ b/arch/mips/kernel/syscalls/Makefile |
453 | @@ -18,7 +18,7 @@ quiet_cmd_syshdr = SYSHDR $@ |
454 | '$(syshdr_pfx_$(basetarget))' \ |
455 | '$(syshdr_offset_$(basetarget))' |
456 | |
457 | -quiet_cmd_sysnr = SYSNR $@ |
458 | +quiet_cmd_sysnr = SYSNR $@ |
459 | cmd_sysnr = $(CONFIG_SHELL) '$(sysnr)' '$<' '$@' \ |
460 | '$(sysnr_abis_$(basetarget))' \ |
461 | '$(sysnr_pfx_$(basetarget))' \ |
462 | diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig |
463 | index 3e56c9c2f16e..2b1033f13210 100644 |
464 | --- a/arch/powerpc/Kconfig |
465 | +++ b/arch/powerpc/Kconfig |
466 | @@ -221,8 +221,7 @@ config PPC |
467 | select HAVE_HARDLOCKUP_DETECTOR_PERF if PERF_EVENTS && HAVE_PERF_EVENTS_NMI && !HAVE_HARDLOCKUP_DETECTOR_ARCH |
468 | select HAVE_PERF_REGS |
469 | select HAVE_PERF_USER_STACK_DUMP |
470 | - select HAVE_RCU_TABLE_FREE if SMP |
471 | - select HAVE_RCU_TABLE_NO_INVALIDATE if HAVE_RCU_TABLE_FREE |
472 | + select HAVE_RCU_TABLE_FREE |
473 | select HAVE_MMU_GATHER_PAGE_SIZE |
474 | select HAVE_REGS_AND_STACK_ACCESS_API |
475 | select HAVE_RELIABLE_STACKTRACE if PPC_BOOK3S_64 && CPU_LITTLE_ENDIAN |
476 | @@ -237,6 +236,7 @@ config PPC |
477 | select NEED_DMA_MAP_STATE if PPC64 || NOT_COHERENT_CACHE |
478 | select NEED_SG_DMA_LENGTH |
479 | select OF |
480 | + select OF_DMA_DEFAULT_COHERENT if !NOT_COHERENT_CACHE |
481 | select OF_EARLY_FLATTREE |
482 | select OLD_SIGACTION if PPC32 |
483 | select OLD_SIGSUSPEND |
484 | diff --git a/arch/powerpc/boot/4xx.c b/arch/powerpc/boot/4xx.c |
485 | index 1699e9531552..00c4d843a023 100644 |
486 | --- a/arch/powerpc/boot/4xx.c |
487 | +++ b/arch/powerpc/boot/4xx.c |
488 | @@ -228,7 +228,7 @@ void ibm4xx_denali_fixup_memsize(void) |
489 | dpath = 8; /* 64 bits */ |
490 | |
491 | /* get address pins (rows) */ |
492 | - val = SDRAM0_READ(DDR0_42); |
493 | + val = SDRAM0_READ(DDR0_42); |
494 | |
495 | row = DDR_GET_VAL(val, DDR_APIN, DDR_APIN_SHIFT); |
496 | if (row > max_row) |
497 | diff --git a/arch/powerpc/include/asm/book3s/32/kup.h b/arch/powerpc/include/asm/book3s/32/kup.h |
498 | index f9dc597b0b86..91c8f1d9bcee 100644 |
499 | --- a/arch/powerpc/include/asm/book3s/32/kup.h |
500 | +++ b/arch/powerpc/include/asm/book3s/32/kup.h |
501 | @@ -102,11 +102,13 @@ static inline void kuap_update_sr(u32 sr, u32 addr, u32 end) |
502 | isync(); /* Context sync required after mtsrin() */ |
503 | } |
504 | |
505 | -static inline void allow_user_access(void __user *to, const void __user *from, u32 size) |
506 | +static __always_inline void allow_user_access(void __user *to, const void __user *from, |
507 | + u32 size, unsigned long dir) |
508 | { |
509 | u32 addr, end; |
510 | |
511 | - if (__builtin_constant_p(to) && to == NULL) |
512 | + BUILD_BUG_ON(!__builtin_constant_p(dir)); |
513 | + if (!(dir & KUAP_WRITE)) |
514 | return; |
515 | |
516 | addr = (__force u32)to; |
517 | @@ -119,11 +121,16 @@ static inline void allow_user_access(void __user *to, const void __user *from, u |
518 | kuap_update_sr(mfsrin(addr) & ~SR_KS, addr, end); /* Clear Ks */ |
519 | } |
520 | |
521 | -static inline void prevent_user_access(void __user *to, const void __user *from, u32 size) |
522 | +static __always_inline void prevent_user_access(void __user *to, const void __user *from, |
523 | + u32 size, unsigned long dir) |
524 | { |
525 | u32 addr = (__force u32)to; |
526 | u32 end = min(addr + size, TASK_SIZE); |
527 | |
528 | + BUILD_BUG_ON(!__builtin_constant_p(dir)); |
529 | + if (!(dir & KUAP_WRITE)) |
530 | + return; |
531 | + |
532 | if (!addr || addr >= TASK_SIZE || !size) |
533 | return; |
534 | |
535 | @@ -131,12 +138,17 @@ static inline void prevent_user_access(void __user *to, const void __user *from, |
536 | kuap_update_sr(mfsrin(addr) | SR_KS, addr, end); /* set Ks */ |
537 | } |
538 | |
539 | -static inline bool bad_kuap_fault(struct pt_regs *regs, bool is_write) |
540 | +static inline bool |
541 | +bad_kuap_fault(struct pt_regs *regs, unsigned long address, bool is_write) |
542 | { |
543 | + unsigned long begin = regs->kuap & 0xf0000000; |
544 | + unsigned long end = regs->kuap << 28; |
545 | + |
546 | if (!is_write) |
547 | return false; |
548 | |
549 | - return WARN(!regs->kuap, "Bug: write fault blocked by segment registers !"); |
550 | + return WARN(address < begin || address >= end, |
551 | + "Bug: write fault blocked by segment registers !"); |
552 | } |
553 | |
554 | #endif /* CONFIG_PPC_KUAP */ |
555 | diff --git a/arch/powerpc/include/asm/book3s/32/pgalloc.h b/arch/powerpc/include/asm/book3s/32/pgalloc.h |
556 | index 998317702630..dc5c039eb28e 100644 |
557 | --- a/arch/powerpc/include/asm/book3s/32/pgalloc.h |
558 | +++ b/arch/powerpc/include/asm/book3s/32/pgalloc.h |
559 | @@ -49,7 +49,6 @@ static inline void pgtable_free(void *table, unsigned index_size) |
560 | |
561 | #define get_hugepd_cache_index(x) (x) |
562 | |
563 | -#ifdef CONFIG_SMP |
564 | static inline void pgtable_free_tlb(struct mmu_gather *tlb, |
565 | void *table, int shift) |
566 | { |
567 | @@ -66,13 +65,6 @@ static inline void __tlb_remove_table(void *_table) |
568 | |
569 | pgtable_free(table, shift); |
570 | } |
571 | -#else |
572 | -static inline void pgtable_free_tlb(struct mmu_gather *tlb, |
573 | - void *table, int shift) |
574 | -{ |
575 | - pgtable_free(table, shift); |
576 | -} |
577 | -#endif |
578 | |
579 | static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t table, |
580 | unsigned long address) |
581 | diff --git a/arch/powerpc/include/asm/book3s/64/kup-radix.h b/arch/powerpc/include/asm/book3s/64/kup-radix.h |
582 | index f254de956d6a..c8d1076e0ebb 100644 |
583 | --- a/arch/powerpc/include/asm/book3s/64/kup-radix.h |
584 | +++ b/arch/powerpc/include/asm/book3s/64/kup-radix.h |
585 | @@ -77,25 +77,27 @@ static inline void set_kuap(unsigned long value) |
586 | isync(); |
587 | } |
588 | |
589 | -static inline void allow_user_access(void __user *to, const void __user *from, |
590 | - unsigned long size) |
591 | +static __always_inline void allow_user_access(void __user *to, const void __user *from, |
592 | + unsigned long size, unsigned long dir) |
593 | { |
594 | // This is written so we can resolve to a single case at build time |
595 | - if (__builtin_constant_p(to) && to == NULL) |
596 | + BUILD_BUG_ON(!__builtin_constant_p(dir)); |
597 | + if (dir == KUAP_READ) |
598 | set_kuap(AMR_KUAP_BLOCK_WRITE); |
599 | - else if (__builtin_constant_p(from) && from == NULL) |
600 | + else if (dir == KUAP_WRITE) |
601 | set_kuap(AMR_KUAP_BLOCK_READ); |
602 | else |
603 | set_kuap(0); |
604 | } |
605 | |
606 | static inline void prevent_user_access(void __user *to, const void __user *from, |
607 | - unsigned long size) |
608 | + unsigned long size, unsigned long dir) |
609 | { |
610 | set_kuap(AMR_KUAP_BLOCKED); |
611 | } |
612 | |
613 | -static inline bool bad_kuap_fault(struct pt_regs *regs, bool is_write) |
614 | +static inline bool |
615 | +bad_kuap_fault(struct pt_regs *regs, unsigned long address, bool is_write) |
616 | { |
617 | return WARN(mmu_has_feature(MMU_FTR_RADIX_KUAP) && |
618 | (regs->kuap & (is_write ? AMR_KUAP_BLOCK_WRITE : AMR_KUAP_BLOCK_READ)), |
619 | diff --git a/arch/powerpc/include/asm/book3s/64/pgalloc.h b/arch/powerpc/include/asm/book3s/64/pgalloc.h |
620 | index d5a44912902f..cae9e814593a 100644 |
621 | --- a/arch/powerpc/include/asm/book3s/64/pgalloc.h |
622 | +++ b/arch/powerpc/include/asm/book3s/64/pgalloc.h |
623 | @@ -19,9 +19,7 @@ extern struct vmemmap_backing *vmemmap_list; |
624 | extern pmd_t *pmd_fragment_alloc(struct mm_struct *, unsigned long); |
625 | extern void pmd_fragment_free(unsigned long *); |
626 | extern void pgtable_free_tlb(struct mmu_gather *tlb, void *table, int shift); |
627 | -#ifdef CONFIG_SMP |
628 | extern void __tlb_remove_table(void *_table); |
629 | -#endif |
630 | void pte_frag_destroy(void *pte_frag); |
631 | |
632 | static inline pgd_t *radix__pgd_alloc(struct mm_struct *mm) |
633 | diff --git a/arch/powerpc/include/asm/futex.h b/arch/powerpc/include/asm/futex.h |
634 | index eea28ca679db..bc7d9d06a6d9 100644 |
635 | --- a/arch/powerpc/include/asm/futex.h |
636 | +++ b/arch/powerpc/include/asm/futex.h |
637 | @@ -35,7 +35,7 @@ static inline int arch_futex_atomic_op_inuser(int op, int oparg, int *oval, |
638 | { |
639 | int oldval = 0, ret; |
640 | |
641 | - allow_write_to_user(uaddr, sizeof(*uaddr)); |
642 | + allow_read_write_user(uaddr, uaddr, sizeof(*uaddr)); |
643 | pagefault_disable(); |
644 | |
645 | switch (op) { |
646 | @@ -62,7 +62,7 @@ static inline int arch_futex_atomic_op_inuser(int op, int oparg, int *oval, |
647 | |
648 | *oval = oldval; |
649 | |
650 | - prevent_write_to_user(uaddr, sizeof(*uaddr)); |
651 | + prevent_read_write_user(uaddr, uaddr, sizeof(*uaddr)); |
652 | return ret; |
653 | } |
654 | |
655 | @@ -76,7 +76,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr, |
656 | if (!access_ok(uaddr, sizeof(u32))) |
657 | return -EFAULT; |
658 | |
659 | - allow_write_to_user(uaddr, sizeof(*uaddr)); |
660 | + allow_read_write_user(uaddr, uaddr, sizeof(*uaddr)); |
661 | + |
662 | __asm__ __volatile__ ( |
663 | PPC_ATOMIC_ENTRY_BARRIER |
664 | "1: lwarx %1,0,%3 # futex_atomic_cmpxchg_inatomic\n\ |
665 | @@ -97,7 +98,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr, |
666 | : "cc", "memory"); |
667 | |
668 | *uval = prev; |
669 | - prevent_write_to_user(uaddr, sizeof(*uaddr)); |
670 | + prevent_read_write_user(uaddr, uaddr, sizeof(*uaddr)); |
671 | + |
672 | return ret; |
673 | } |
674 | |
675 | diff --git a/arch/powerpc/include/asm/kup.h b/arch/powerpc/include/asm/kup.h |
676 | index 5b5e39643a27..94f24928916a 100644 |
677 | --- a/arch/powerpc/include/asm/kup.h |
678 | +++ b/arch/powerpc/include/asm/kup.h |
679 | @@ -2,6 +2,10 @@ |
680 | #ifndef _ASM_POWERPC_KUP_H_ |
681 | #define _ASM_POWERPC_KUP_H_ |
682 | |
683 | +#define KUAP_READ 1 |
684 | +#define KUAP_WRITE 2 |
685 | +#define KUAP_READ_WRITE (KUAP_READ | KUAP_WRITE) |
686 | + |
687 | #ifdef CONFIG_PPC64 |
688 | #include <asm/book3s/64/kup-radix.h> |
689 | #endif |
690 | @@ -42,32 +46,48 @@ void setup_kuap(bool disabled); |
691 | #else |
692 | static inline void setup_kuap(bool disabled) { } |
693 | static inline void allow_user_access(void __user *to, const void __user *from, |
694 | - unsigned long size) { } |
695 | + unsigned long size, unsigned long dir) { } |
696 | static inline void prevent_user_access(void __user *to, const void __user *from, |
697 | - unsigned long size) { } |
698 | -static inline bool bad_kuap_fault(struct pt_regs *regs, bool is_write) { return false; } |
699 | + unsigned long size, unsigned long dir) { } |
700 | +static inline bool |
701 | +bad_kuap_fault(struct pt_regs *regs, unsigned long address, bool is_write) |
702 | +{ |
703 | + return false; |
704 | +} |
705 | #endif /* CONFIG_PPC_KUAP */ |
706 | |
707 | static inline void allow_read_from_user(const void __user *from, unsigned long size) |
708 | { |
709 | - allow_user_access(NULL, from, size); |
710 | + allow_user_access(NULL, from, size, KUAP_READ); |
711 | } |
712 | |
713 | static inline void allow_write_to_user(void __user *to, unsigned long size) |
714 | { |
715 | - allow_user_access(to, NULL, size); |
716 | + allow_user_access(to, NULL, size, KUAP_WRITE); |
717 | +} |
718 | + |
719 | +static inline void allow_read_write_user(void __user *to, const void __user *from, |
720 | + unsigned long size) |
721 | +{ |
722 | + allow_user_access(to, from, size, KUAP_READ_WRITE); |
723 | } |
724 | |
725 | static inline void prevent_read_from_user(const void __user *from, unsigned long size) |
726 | { |
727 | - prevent_user_access(NULL, from, size); |
728 | + prevent_user_access(NULL, from, size, KUAP_READ); |
729 | } |
730 | |
731 | static inline void prevent_write_to_user(void __user *to, unsigned long size) |
732 | { |
733 | - prevent_user_access(to, NULL, size); |
734 | + prevent_user_access(to, NULL, size, KUAP_WRITE); |
735 | +} |
736 | + |
737 | +static inline void prevent_read_write_user(void __user *to, const void __user *from, |
738 | + unsigned long size) |
739 | +{ |
740 | + prevent_user_access(to, from, size, KUAP_READ_WRITE); |
741 | } |
742 | |
743 | #endif /* !__ASSEMBLY__ */ |
744 | |
745 | -#endif /* _ASM_POWERPC_KUP_H_ */ |
746 | +#endif /* _ASM_POWERPC_KUAP_H_ */ |
747 | diff --git a/arch/powerpc/include/asm/nohash/32/kup-8xx.h b/arch/powerpc/include/asm/nohash/32/kup-8xx.h |
748 | index 1c3133b5f86a..6fe97465e350 100644 |
749 | --- a/arch/powerpc/include/asm/nohash/32/kup-8xx.h |
750 | +++ b/arch/powerpc/include/asm/nohash/32/kup-8xx.h |
751 | @@ -34,18 +34,19 @@ |
752 | #include <asm/reg.h> |
753 | |
754 | static inline void allow_user_access(void __user *to, const void __user *from, |
755 | - unsigned long size) |
756 | + unsigned long size, unsigned long dir) |
757 | { |
758 | mtspr(SPRN_MD_AP, MD_APG_INIT); |
759 | } |
760 | |
761 | static inline void prevent_user_access(void __user *to, const void __user *from, |
762 | - unsigned long size) |
763 | + unsigned long size, unsigned long dir) |
764 | { |
765 | mtspr(SPRN_MD_AP, MD_APG_KUAP); |
766 | } |
767 | |
768 | -static inline bool bad_kuap_fault(struct pt_regs *regs, bool is_write) |
769 | +static inline bool |
770 | +bad_kuap_fault(struct pt_regs *regs, unsigned long address, bool is_write) |
771 | { |
772 | return WARN(!((regs->kuap ^ MD_APG_KUAP) & 0xf0000000), |
773 | "Bug: fault blocked by AP register !"); |
774 | diff --git a/arch/powerpc/include/asm/nohash/pgalloc.h b/arch/powerpc/include/asm/nohash/pgalloc.h |
775 | index 332b13b4ecdb..29c43665a753 100644 |
776 | --- a/arch/powerpc/include/asm/nohash/pgalloc.h |
777 | +++ b/arch/powerpc/include/asm/nohash/pgalloc.h |
778 | @@ -46,7 +46,6 @@ static inline void pgtable_free(void *table, int shift) |
779 | |
780 | #define get_hugepd_cache_index(x) (x) |
781 | |
782 | -#ifdef CONFIG_SMP |
783 | static inline void pgtable_free_tlb(struct mmu_gather *tlb, void *table, int shift) |
784 | { |
785 | unsigned long pgf = (unsigned long)table; |
786 | @@ -64,13 +63,6 @@ static inline void __tlb_remove_table(void *_table) |
787 | pgtable_free(table, shift); |
788 | } |
789 | |
790 | -#else |
791 | -static inline void pgtable_free_tlb(struct mmu_gather *tlb, void *table, int shift) |
792 | -{ |
793 | - pgtable_free(table, shift); |
794 | -} |
795 | -#endif |
796 | - |
797 | static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t table, |
798 | unsigned long address) |
799 | { |
800 | diff --git a/arch/powerpc/include/asm/tlb.h b/arch/powerpc/include/asm/tlb.h |
801 | index b2c0be93929d..7f3a8b902325 100644 |
802 | --- a/arch/powerpc/include/asm/tlb.h |
803 | +++ b/arch/powerpc/include/asm/tlb.h |
804 | @@ -26,6 +26,17 @@ |
805 | |
806 | #define tlb_flush tlb_flush |
807 | extern void tlb_flush(struct mmu_gather *tlb); |
808 | +/* |
809 | + * book3s: |
810 | + * Hash does not use the linux page-tables, so we can avoid |
811 | + * the TLB invalidate for page-table freeing, Radix otoh does use the |
812 | + * page-tables and needs the TLBI. |
813 | + * |
814 | + * nohash: |
815 | + * We still do TLB invalidate in the __pte_free_tlb routine before we |
816 | + * add the page table pages to mmu gather table batch. |
817 | + */ |
818 | +#define tlb_needs_table_invalidate() radix_enabled() |
819 | |
820 | /* Get the generic bits... */ |
821 | #include <asm-generic/tlb.h> |
822 | diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h |
823 | index c92fe7fe9692..cafad1960e76 100644 |
824 | --- a/arch/powerpc/include/asm/uaccess.h |
825 | +++ b/arch/powerpc/include/asm/uaccess.h |
826 | @@ -313,9 +313,9 @@ raw_copy_in_user(void __user *to, const void __user *from, unsigned long n) |
827 | unsigned long ret; |
828 | |
829 | barrier_nospec(); |
830 | - allow_user_access(to, from, n); |
831 | + allow_read_write_user(to, from, n); |
832 | ret = __copy_tofrom_user(to, from, n); |
833 | - prevent_user_access(to, from, n); |
834 | + prevent_read_write_user(to, from, n); |
835 | return ret; |
836 | } |
837 | #endif /* __powerpc64__ */ |
838 | diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S |
839 | index d60908ea37fb..59bb4f4ae316 100644 |
840 | --- a/arch/powerpc/kernel/entry_32.S |
841 | +++ b/arch/powerpc/kernel/entry_32.S |
842 | @@ -179,7 +179,7 @@ transfer_to_handler: |
843 | 2: /* if from kernel, check interrupted DOZE/NAP mode and |
844 | * check for stack overflow |
845 | */ |
846 | - kuap_save_and_lock r11, r12, r9, r2, r0 |
847 | + kuap_save_and_lock r11, r12, r9, r2, r6 |
848 | addi r2, r12, -THREAD |
849 | lwz r9,KSP_LIMIT(r12) |
850 | cmplw r1,r9 /* if r1 <= ksp_limit */ |
851 | @@ -284,6 +284,7 @@ reenable_mmu: |
852 | rlwinm r9,r9,0,~MSR_EE |
853 | lwz r12,_LINK(r11) /* and return to address in LR */ |
854 | kuap_restore r11, r2, r3, r4, r5 |
855 | + lwz r2, GPR2(r11) |
856 | b fast_exception_return |
857 | #endif |
858 | |
859 | diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c |
860 | index 709cf1fd4cf4..36abbe3c346d 100644 |
861 | --- a/arch/powerpc/kvm/book3s_hv.c |
862 | +++ b/arch/powerpc/kvm/book3s_hv.c |
863 | @@ -2354,7 +2354,7 @@ static struct kvm_vcpu *kvmppc_core_vcpu_create_hv(struct kvm *kvm, |
864 | mutex_unlock(&kvm->lock); |
865 | |
866 | if (!vcore) |
867 | - goto free_vcpu; |
868 | + goto uninit_vcpu; |
869 | |
870 | spin_lock(&vcore->lock); |
871 | ++vcore->num_threads; |
872 | @@ -2371,6 +2371,8 @@ static struct kvm_vcpu *kvmppc_core_vcpu_create_hv(struct kvm *kvm, |
873 | |
874 | return vcpu; |
875 | |
876 | +uninit_vcpu: |
877 | + kvm_vcpu_uninit(vcpu); |
878 | free_vcpu: |
879 | kmem_cache_free(kvm_vcpu_cache, vcpu); |
880 | out: |
881 | diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c |
882 | index cc65af8fe6f7..3f6ad3f58628 100644 |
883 | --- a/arch/powerpc/kvm/book3s_pr.c |
884 | +++ b/arch/powerpc/kvm/book3s_pr.c |
885 | @@ -1769,10 +1769,12 @@ static struct kvm_vcpu *kvmppc_core_vcpu_create_pr(struct kvm *kvm, |
886 | |
887 | err = kvmppc_mmu_init(vcpu); |
888 | if (err < 0) |
889 | - goto uninit_vcpu; |
890 | + goto free_shared_page; |
891 | |
892 | return vcpu; |
893 | |
894 | +free_shared_page: |
895 | + free_page((unsigned long)vcpu->arch.shared); |
896 | uninit_vcpu: |
897 | kvm_vcpu_uninit(vcpu); |
898 | free_shadow_vcpu: |
899 | diff --git a/arch/powerpc/kvm/book3s_xive_native.c b/arch/powerpc/kvm/book3s_xive_native.c |
900 | index 5a3373e06e60..235d57d6c205 100644 |
901 | --- a/arch/powerpc/kvm/book3s_xive_native.c |
902 | +++ b/arch/powerpc/kvm/book3s_xive_native.c |
903 | @@ -638,7 +638,7 @@ static int kvmppc_xive_native_set_queue_config(struct kvmppc_xive *xive, |
904 | srcu_idx = srcu_read_lock(&kvm->srcu); |
905 | gfn = gpa_to_gfn(kvm_eq.qaddr); |
906 | |
907 | - page_size = kvm_host_page_size(kvm, gfn); |
908 | + page_size = kvm_host_page_size(vcpu, gfn); |
909 | if (1ull << kvm_eq.qshift > page_size) { |
910 | srcu_read_unlock(&kvm->srcu, srcu_idx); |
911 | pr_warn("Incompatible host page size %lx!\n", page_size); |
912 | diff --git a/arch/powerpc/mm/book3s64/pgtable.c b/arch/powerpc/mm/book3s64/pgtable.c |
913 | index 75483b40fcb1..2bf7e1b4fd82 100644 |
914 | --- a/arch/powerpc/mm/book3s64/pgtable.c |
915 | +++ b/arch/powerpc/mm/book3s64/pgtable.c |
916 | @@ -378,7 +378,6 @@ static inline void pgtable_free(void *table, int index) |
917 | } |
918 | } |
919 | |
920 | -#ifdef CONFIG_SMP |
921 | void pgtable_free_tlb(struct mmu_gather *tlb, void *table, int index) |
922 | { |
923 | unsigned long pgf = (unsigned long)table; |
924 | @@ -395,12 +394,6 @@ void __tlb_remove_table(void *_table) |
925 | |
926 | return pgtable_free(table, index); |
927 | } |
928 | -#else |
929 | -void pgtable_free_tlb(struct mmu_gather *tlb, void *table, int index) |
930 | -{ |
931 | - return pgtable_free(table, index); |
932 | -} |
933 | -#endif |
934 | |
935 | #ifdef CONFIG_PROC_FS |
936 | atomic_long_t direct_pages_count[MMU_PAGE_COUNT]; |
937 | diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c |
938 | index 8432c281de92..9298905cfe74 100644 |
939 | --- a/arch/powerpc/mm/fault.c |
940 | +++ b/arch/powerpc/mm/fault.c |
941 | @@ -233,7 +233,7 @@ static bool bad_kernel_fault(struct pt_regs *regs, unsigned long error_code, |
942 | |
943 | // Read/write fault in a valid region (the exception table search passed |
944 | // above), but blocked by KUAP is bad, it can never succeed. |
945 | - if (bad_kuap_fault(regs, is_write)) |
946 | + if (bad_kuap_fault(regs, address, is_write)) |
947 | return true; |
948 | |
949 | // What's left? Kernel fault on user in well defined regions (extable |
950 | diff --git a/arch/powerpc/mm/ptdump/ptdump.c b/arch/powerpc/mm/ptdump/ptdump.c |
951 | index 2f9ddc29c535..c73205172447 100644 |
952 | --- a/arch/powerpc/mm/ptdump/ptdump.c |
953 | +++ b/arch/powerpc/mm/ptdump/ptdump.c |
954 | @@ -173,10 +173,12 @@ static void dump_addr(struct pg_state *st, unsigned long addr) |
955 | |
956 | static void note_prot_wx(struct pg_state *st, unsigned long addr) |
957 | { |
958 | + pte_t pte = __pte(st->current_flags); |
959 | + |
960 | if (!IS_ENABLED(CONFIG_PPC_DEBUG_WX) || !st->check_wx) |
961 | return; |
962 | |
963 | - if (!((st->current_flags & pgprot_val(PAGE_KERNEL_X)) == pgprot_val(PAGE_KERNEL_X))) |
964 | + if (!pte_write(pte) || !pte_exec(pte)) |
965 | return; |
966 | |
967 | WARN_ONCE(1, "powerpc/mm: Found insecure W+X mapping at address %p/%pS\n", |
968 | diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c |
969 | index 8e700390f3d6..4c3af2e9eb8e 100644 |
970 | --- a/arch/powerpc/platforms/pseries/hotplug-memory.c |
971 | +++ b/arch/powerpc/platforms/pseries/hotplug-memory.c |
972 | @@ -360,8 +360,10 @@ static bool lmb_is_removable(struct drmem_lmb *lmb) |
973 | |
974 | for (i = 0; i < scns_per_block; i++) { |
975 | pfn = PFN_DOWN(phys_addr); |
976 | - if (!pfn_present(pfn)) |
977 | + if (!pfn_present(pfn)) { |
978 | + phys_addr += MIN_MEMORY_BLOCK_SIZE; |
979 | continue; |
980 | + } |
981 | |
982 | rc &= is_mem_section_removable(pfn, PAGES_PER_SECTION); |
983 | phys_addr += MIN_MEMORY_BLOCK_SIZE; |
984 | diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c |
985 | index d83364ebc5c5..8057aafd5f5e 100644 |
986 | --- a/arch/powerpc/xmon/xmon.c |
987 | +++ b/arch/powerpc/xmon/xmon.c |
988 | @@ -1894,15 +1894,14 @@ static void dump_300_sprs(void) |
989 | |
990 | printf("pidr = %.16lx tidr = %.16lx\n", |
991 | mfspr(SPRN_PID), mfspr(SPRN_TIDR)); |
992 | - printf("asdr = %.16lx psscr = %.16lx\n", |
993 | - mfspr(SPRN_ASDR), hv ? mfspr(SPRN_PSSCR) |
994 | - : mfspr(SPRN_PSSCR_PR)); |
995 | + printf("psscr = %.16lx\n", |
996 | + hv ? mfspr(SPRN_PSSCR) : mfspr(SPRN_PSSCR_PR)); |
997 | |
998 | if (!hv) |
999 | return; |
1000 | |
1001 | - printf("ptcr = %.16lx\n", |
1002 | - mfspr(SPRN_PTCR)); |
1003 | + printf("ptcr = %.16lx asdr = %.16lx\n", |
1004 | + mfspr(SPRN_PTCR), mfspr(SPRN_ASDR)); |
1005 | #endif |
1006 | } |
1007 | |
1008 | diff --git a/arch/riscv/net/bpf_jit_comp.c b/arch/riscv/net/bpf_jit_comp.c |
1009 | index 7fbf56aab661..e2279fed8f56 100644 |
1010 | --- a/arch/riscv/net/bpf_jit_comp.c |
1011 | +++ b/arch/riscv/net/bpf_jit_comp.c |
1012 | @@ -120,6 +120,11 @@ static bool seen_reg(int reg, struct rv_jit_context *ctx) |
1013 | return false; |
1014 | } |
1015 | |
1016 | +static void mark_fp(struct rv_jit_context *ctx) |
1017 | +{ |
1018 | + __set_bit(RV_CTX_F_SEEN_S5, &ctx->flags); |
1019 | +} |
1020 | + |
1021 | static void mark_call(struct rv_jit_context *ctx) |
1022 | { |
1023 | __set_bit(RV_CTX_F_SEEN_CALL, &ctx->flags); |
1024 | @@ -596,7 +601,8 @@ static void __build_epilogue(u8 reg, struct rv_jit_context *ctx) |
1025 | |
1026 | emit(rv_addi(RV_REG_SP, RV_REG_SP, stack_adjust), ctx); |
1027 | /* Set return value. */ |
1028 | - emit(rv_addi(RV_REG_A0, RV_REG_A5, 0), ctx); |
1029 | + if (reg == RV_REG_RA) |
1030 | + emit(rv_addi(RV_REG_A0, RV_REG_A5, 0), ctx); |
1031 | emit(rv_jalr(RV_REG_ZERO, reg, 0), ctx); |
1032 | } |
1033 | |
1034 | @@ -1426,6 +1432,10 @@ static void build_prologue(struct rv_jit_context *ctx) |
1035 | { |
1036 | int stack_adjust = 0, store_offset, bpf_stack_adjust; |
1037 | |
1038 | + bpf_stack_adjust = round_up(ctx->prog->aux->stack_depth, 16); |
1039 | + if (bpf_stack_adjust) |
1040 | + mark_fp(ctx); |
1041 | + |
1042 | if (seen_reg(RV_REG_RA, ctx)) |
1043 | stack_adjust += 8; |
1044 | stack_adjust += 8; /* RV_REG_FP */ |
1045 | @@ -1443,7 +1453,6 @@ static void build_prologue(struct rv_jit_context *ctx) |
1046 | stack_adjust += 8; |
1047 | |
1048 | stack_adjust = round_up(stack_adjust, 16); |
1049 | - bpf_stack_adjust = round_up(ctx->prog->aux->stack_depth, 16); |
1050 | stack_adjust += bpf_stack_adjust; |
1051 | |
1052 | store_offset = stack_adjust - 8; |
1053 | diff --git a/arch/s390/include/asm/page.h b/arch/s390/include/asm/page.h |
1054 | index 823578c6b9e2..3f5cb55cde35 100644 |
1055 | --- a/arch/s390/include/asm/page.h |
1056 | +++ b/arch/s390/include/asm/page.h |
1057 | @@ -33,6 +33,8 @@ |
1058 | #define ARCH_HAS_PREPARE_HUGEPAGE |
1059 | #define ARCH_HAS_HUGEPAGE_CLEAR_FLUSH |
1060 | |
1061 | +#define HAVE_ARCH_HUGETLB_UNMAPPED_AREA |
1062 | + |
1063 | #include <asm/setup.h> |
1064 | #ifndef __ASSEMBLY__ |
1065 | |
1066 | diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c |
1067 | index d047e846e1b9..756c627f7e54 100644 |
1068 | --- a/arch/s390/kvm/kvm-s390.c |
1069 | +++ b/arch/s390/kvm/kvm-s390.c |
1070 | @@ -2863,9 +2863,7 @@ static void kvm_s390_vcpu_initial_reset(struct kvm_vcpu *vcpu) |
1071 | vcpu->arch.sie_block->gcr[14] = CR14_UNUSED_32 | |
1072 | CR14_UNUSED_33 | |
1073 | CR14_EXTERNAL_DAMAGE_SUBMASK; |
1074 | - /* make sure the new fpc will be lazily loaded */ |
1075 | - save_fpu_regs(); |
1076 | - current->thread.fpu.fpc = 0; |
1077 | + vcpu->run->s.regs.fpc = 0; |
1078 | vcpu->arch.sie_block->gbea = 1; |
1079 | vcpu->arch.sie_block->pp = 0; |
1080 | vcpu->arch.sie_block->fpf &= ~FPF_BPBC; |
1081 | @@ -4354,7 +4352,7 @@ long kvm_arch_vcpu_ioctl(struct file *filp, |
1082 | switch (ioctl) { |
1083 | case KVM_S390_STORE_STATUS: |
1084 | idx = srcu_read_lock(&vcpu->kvm->srcu); |
1085 | - r = kvm_s390_vcpu_store_status(vcpu, arg); |
1086 | + r = kvm_s390_store_status_unloaded(vcpu, arg); |
1087 | srcu_read_unlock(&vcpu->kvm->srcu, idx); |
1088 | break; |
1089 | case KVM_S390_SET_INITIAL_PSW: { |
1090 | diff --git a/arch/s390/mm/hugetlbpage.c b/arch/s390/mm/hugetlbpage.c |
1091 | index b0246c705a19..5674710a4841 100644 |
1092 | --- a/arch/s390/mm/hugetlbpage.c |
1093 | +++ b/arch/s390/mm/hugetlbpage.c |
1094 | @@ -2,7 +2,7 @@ |
1095 | /* |
1096 | * IBM System z Huge TLB Page Support for Kernel. |
1097 | * |
1098 | - * Copyright IBM Corp. 2007,2016 |
1099 | + * Copyright IBM Corp. 2007,2020 |
1100 | * Author(s): Gerald Schaefer <gerald.schaefer@de.ibm.com> |
1101 | */ |
1102 | |
1103 | @@ -11,6 +11,9 @@ |
1104 | |
1105 | #include <linux/mm.h> |
1106 | #include <linux/hugetlb.h> |
1107 | +#include <linux/mman.h> |
1108 | +#include <linux/sched/mm.h> |
1109 | +#include <linux/security.h> |
1110 | |
1111 | /* |
1112 | * If the bit selected by single-bit bitmask "a" is set within "x", move |
1113 | @@ -267,3 +270,98 @@ static __init int setup_hugepagesz(char *opt) |
1114 | return 1; |
1115 | } |
1116 | __setup("hugepagesz=", setup_hugepagesz); |
1117 | + |
1118 | +static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file, |
1119 | + unsigned long addr, unsigned long len, |
1120 | + unsigned long pgoff, unsigned long flags) |
1121 | +{ |
1122 | + struct hstate *h = hstate_file(file); |
1123 | + struct vm_unmapped_area_info info; |
1124 | + |
1125 | + info.flags = 0; |
1126 | + info.length = len; |
1127 | + info.low_limit = current->mm->mmap_base; |
1128 | + info.high_limit = TASK_SIZE; |
1129 | + info.align_mask = PAGE_MASK & ~huge_page_mask(h); |
1130 | + info.align_offset = 0; |
1131 | + return vm_unmapped_area(&info); |
1132 | +} |
1133 | + |
1134 | +static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file, |
1135 | + unsigned long addr0, unsigned long len, |
1136 | + unsigned long pgoff, unsigned long flags) |
1137 | +{ |
1138 | + struct hstate *h = hstate_file(file); |
1139 | + struct vm_unmapped_area_info info; |
1140 | + unsigned long addr; |
1141 | + |
1142 | + info.flags = VM_UNMAPPED_AREA_TOPDOWN; |
1143 | + info.length = len; |
1144 | + info.low_limit = max(PAGE_SIZE, mmap_min_addr); |
1145 | + info.high_limit = current->mm->mmap_base; |
1146 | + info.align_mask = PAGE_MASK & ~huge_page_mask(h); |
1147 | + info.align_offset = 0; |
1148 | + addr = vm_unmapped_area(&info); |
1149 | + |
1150 | + /* |
1151 | + * A failed mmap() very likely causes application failure, |
1152 | + * so fall back to the bottom-up function here. This scenario |
1153 | + * can happen with large stack limits and large mmap() |
1154 | + * allocations. |
1155 | + */ |
1156 | + if (addr & ~PAGE_MASK) { |
1157 | + VM_BUG_ON(addr != -ENOMEM); |
1158 | + info.flags = 0; |
1159 | + info.low_limit = TASK_UNMAPPED_BASE; |
1160 | + info.high_limit = TASK_SIZE; |
1161 | + addr = vm_unmapped_area(&info); |
1162 | + } |
1163 | + |
1164 | + return addr; |
1165 | +} |
1166 | + |
1167 | +unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, |
1168 | + unsigned long len, unsigned long pgoff, unsigned long flags) |
1169 | +{ |
1170 | + struct hstate *h = hstate_file(file); |
1171 | + struct mm_struct *mm = current->mm; |
1172 | + struct vm_area_struct *vma; |
1173 | + int rc; |
1174 | + |
1175 | + if (len & ~huge_page_mask(h)) |
1176 | + return -EINVAL; |
1177 | + if (len > TASK_SIZE - mmap_min_addr) |
1178 | + return -ENOMEM; |
1179 | + |
1180 | + if (flags & MAP_FIXED) { |
1181 | + if (prepare_hugepage_range(file, addr, len)) |
1182 | + return -EINVAL; |
1183 | + goto check_asce_limit; |
1184 | + } |
1185 | + |
1186 | + if (addr) { |
1187 | + addr = ALIGN(addr, huge_page_size(h)); |
1188 | + vma = find_vma(mm, addr); |
1189 | + if (TASK_SIZE - len >= addr && addr >= mmap_min_addr && |
1190 | + (!vma || addr + len <= vm_start_gap(vma))) |
1191 | + goto check_asce_limit; |
1192 | + } |
1193 | + |
1194 | + if (mm->get_unmapped_area == arch_get_unmapped_area) |
1195 | + addr = hugetlb_get_unmapped_area_bottomup(file, addr, len, |
1196 | + pgoff, flags); |
1197 | + else |
1198 | + addr = hugetlb_get_unmapped_area_topdown(file, addr, len, |
1199 | + pgoff, flags); |
1200 | + if (addr & ~PAGE_MASK) |
1201 | + return addr; |
1202 | + |
1203 | +check_asce_limit: |
1204 | + if (addr + len > current->mm->context.asce_limit && |
1205 | + addr + len <= TASK_SIZE) { |
1206 | + rc = crst_table_upgrade(mm, addr + len); |
1207 | + if (rc) |
1208 | + return (unsigned long) rc; |
1209 | + } |
1210 | + return addr; |
1211 | +} |
1212 | diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig |
1213 | index eb24cb1afc11..18e9fb6fcf1b 100644 |
1214 | --- a/arch/sparc/Kconfig |
1215 | +++ b/arch/sparc/Kconfig |
1216 | @@ -65,7 +65,6 @@ config SPARC64 |
1217 | select HAVE_KRETPROBES |
1218 | select HAVE_KPROBES |
1219 | select HAVE_RCU_TABLE_FREE if SMP |
1220 | - select HAVE_RCU_TABLE_NO_INVALIDATE if HAVE_RCU_TABLE_FREE |
1221 | select HAVE_MEMBLOCK_NODE_MAP |
1222 | select HAVE_ARCH_TRANSPARENT_HUGEPAGE |
1223 | select HAVE_DYNAMIC_FTRACE |
1224 | diff --git a/arch/sparc/include/asm/tlb_64.h b/arch/sparc/include/asm/tlb_64.h |
1225 | index a2f3fa61ee36..8cb8f3833239 100644 |
1226 | --- a/arch/sparc/include/asm/tlb_64.h |
1227 | +++ b/arch/sparc/include/asm/tlb_64.h |
1228 | @@ -28,6 +28,15 @@ void flush_tlb_pending(void); |
1229 | #define __tlb_remove_tlb_entry(tlb, ptep, address) do { } while (0) |
1230 | #define tlb_flush(tlb) flush_tlb_pending() |
1231 | |
1232 | +/* |
1233 | + * SPARC64's hardware TLB fill does not use the Linux page-tables |
1234 | + * and therefore we don't need a TLBI when freeing page-table pages. |
1235 | + */ |
1236 | + |
1237 | +#ifdef CONFIG_HAVE_RCU_TABLE_FREE |
1238 | +#define tlb_needs_table_invalidate() (false) |
1239 | +#endif |
1240 | + |
1241 | #include <asm-generic/tlb.h> |
1242 | |
1243 | #endif /* _SPARC64_TLB_H */ |
1244 | diff --git a/arch/sparc/include/uapi/asm/ipcbuf.h b/arch/sparc/include/uapi/asm/ipcbuf.h |
1245 | index 9d0d125500e2..084b8949ddff 100644 |
1246 | --- a/arch/sparc/include/uapi/asm/ipcbuf.h |
1247 | +++ b/arch/sparc/include/uapi/asm/ipcbuf.h |
1248 | @@ -15,19 +15,19 @@ |
1249 | |
1250 | struct ipc64_perm |
1251 | { |
1252 | - __kernel_key_t key; |
1253 | - __kernel_uid_t uid; |
1254 | - __kernel_gid_t gid; |
1255 | - __kernel_uid_t cuid; |
1256 | - __kernel_gid_t cgid; |
1257 | + __kernel_key_t key; |
1258 | + __kernel_uid32_t uid; |
1259 | + __kernel_gid32_t gid; |
1260 | + __kernel_uid32_t cuid; |
1261 | + __kernel_gid32_t cgid; |
1262 | #ifndef __arch64__ |
1263 | - unsigned short __pad0; |
1264 | + unsigned short __pad0; |
1265 | #endif |
1266 | - __kernel_mode_t mode; |
1267 | - unsigned short __pad1; |
1268 | - unsigned short seq; |
1269 | - unsigned long long __unused1; |
1270 | - unsigned long long __unused2; |
1271 | + __kernel_mode_t mode; |
1272 | + unsigned short __pad1; |
1273 | + unsigned short seq; |
1274 | + unsigned long long __unused1; |
1275 | + unsigned long long __unused2; |
1276 | }; |
1277 | |
1278 | #endif /* __SPARC_IPCBUF_H */ |
1279 | diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h |
1280 | index 2ebc17d9c72c..19e94af9cc5d 100644 |
1281 | --- a/arch/x86/include/asm/apic.h |
1282 | +++ b/arch/x86/include/asm/apic.h |
1283 | @@ -140,6 +140,7 @@ extern void apic_soft_disable(void); |
1284 | extern void lapic_shutdown(void); |
1285 | extern void sync_Arb_IDs(void); |
1286 | extern void init_bsp_APIC(void); |
1287 | +extern void apic_intr_mode_select(void); |
1288 | extern void apic_intr_mode_init(void); |
1289 | extern void init_apic_mappings(void); |
1290 | void register_lapic_address(unsigned long address); |
1291 | @@ -188,6 +189,7 @@ static inline void disable_local_APIC(void) { } |
1292 | # define setup_secondary_APIC_clock x86_init_noop |
1293 | static inline void lapic_update_tsc_freq(void) { } |
1294 | static inline void init_bsp_APIC(void) { } |
1295 | +static inline void apic_intr_mode_select(void) { } |
1296 | static inline void apic_intr_mode_init(void) { } |
1297 | static inline void lapic_assign_system_vectors(void) { } |
1298 | static inline void lapic_assign_legacy_vector(unsigned int i, bool r) { } |
1299 | @@ -452,6 +454,14 @@ static inline void ack_APIC_irq(void) |
1300 | apic_eoi(); |
1301 | } |
1302 | |
1303 | + |
1304 | +static inline bool lapic_vector_set_in_irr(unsigned int vector) |
1305 | +{ |
1306 | + u32 irr = apic_read(APIC_IRR + (vector / 32 * 0x10)); |
1307 | + |
1308 | + return !!(irr & (1U << (vector % 32))); |
1309 | +} |
1310 | + |
1311 | static inline unsigned default_get_apic_id(unsigned long x) |
1312 | { |
1313 | unsigned int ver = GET_APIC_VERSION(apic_read(APIC_LVR)); |
1314 | diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h |
1315 | index 4fc61483919a..c1ed054c103c 100644 |
1316 | --- a/arch/x86/include/asm/kvm_host.h |
1317 | +++ b/arch/x86/include/asm/kvm_host.h |
1318 | @@ -380,12 +380,12 @@ struct kvm_mmu { |
1319 | void (*set_cr3)(struct kvm_vcpu *vcpu, unsigned long root); |
1320 | unsigned long (*get_cr3)(struct kvm_vcpu *vcpu); |
1321 | u64 (*get_pdptr)(struct kvm_vcpu *vcpu, int index); |
1322 | - int (*page_fault)(struct kvm_vcpu *vcpu, gva_t gva, u32 err, |
1323 | + int (*page_fault)(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa, u32 err, |
1324 | bool prefault); |
1325 | void (*inject_page_fault)(struct kvm_vcpu *vcpu, |
1326 | struct x86_exception *fault); |
1327 | - gpa_t (*gva_to_gpa)(struct kvm_vcpu *vcpu, gva_t gva, u32 access, |
1328 | - struct x86_exception *exception); |
1329 | + gpa_t (*gva_to_gpa)(struct kvm_vcpu *vcpu, gpa_t gva_or_gpa, |
1330 | + u32 access, struct x86_exception *exception); |
1331 | gpa_t (*translate_gpa)(struct kvm_vcpu *vcpu, gpa_t gpa, u32 access, |
1332 | struct x86_exception *exception); |
1333 | int (*sync_page)(struct kvm_vcpu *vcpu, |
1334 | @@ -667,10 +667,10 @@ struct kvm_vcpu_arch { |
1335 | bool pvclock_set_guest_stopped_request; |
1336 | |
1337 | struct { |
1338 | + u8 preempted; |
1339 | u64 msr_val; |
1340 | u64 last_steal; |
1341 | - struct gfn_to_hva_cache stime; |
1342 | - struct kvm_steal_time steal; |
1343 | + struct gfn_to_pfn_cache cache; |
1344 | } st; |
1345 | |
1346 | u64 tsc_offset; |
1347 | @@ -1128,6 +1128,7 @@ struct kvm_x86_ops { |
1348 | bool (*xsaves_supported)(void); |
1349 | bool (*umip_emulated)(void); |
1350 | bool (*pt_supported)(void); |
1351 | + bool (*pku_supported)(void); |
1352 | |
1353 | int (*check_nested_events)(struct kvm_vcpu *vcpu, bool external_intr); |
1354 | void (*request_immediate_exit)(struct kvm_vcpu *vcpu); |
1355 | @@ -1450,7 +1451,7 @@ void kvm_vcpu_deactivate_apicv(struct kvm_vcpu *vcpu); |
1356 | |
1357 | int kvm_emulate_hypercall(struct kvm_vcpu *vcpu); |
1358 | |
1359 | -int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t gva, u64 error_code, |
1360 | +int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa, u64 error_code, |
1361 | void *insn, int insn_len); |
1362 | void kvm_mmu_invlpg(struct kvm_vcpu *vcpu, gva_t gva); |
1363 | void kvm_mmu_invpcid_gva(struct kvm_vcpu *vcpu, gva_t gva, unsigned long pcid); |
1364 | diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h |
1365 | index 19435858df5f..96d9cd208610 100644 |
1366 | --- a/arch/x86/include/asm/x86_init.h |
1367 | +++ b/arch/x86/include/asm/x86_init.h |
1368 | @@ -51,12 +51,14 @@ struct x86_init_resources { |
1369 | * are set up. |
1370 | * @intr_init: interrupt init code |
1371 | * @trap_init: platform specific trap setup |
1372 | + * @intr_mode_select: interrupt delivery mode selection |
1373 | * @intr_mode_init: interrupt delivery mode setup |
1374 | */ |
1375 | struct x86_init_irqs { |
1376 | void (*pre_vector_init)(void); |
1377 | void (*intr_init)(void); |
1378 | void (*trap_init)(void); |
1379 | + void (*intr_mode_select)(void); |
1380 | void (*intr_mode_init)(void); |
1381 | }; |
1382 | |
1383 | diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c |
1384 | index 2b0faf86da1b..df891f874614 100644 |
1385 | --- a/arch/x86/kernel/apic/apic.c |
1386 | +++ b/arch/x86/kernel/apic/apic.c |
1387 | @@ -830,8 +830,17 @@ bool __init apic_needs_pit(void) |
1388 | if (!tsc_khz || !cpu_khz) |
1389 | return true; |
1390 | |
1391 | - /* Is there an APIC at all? */ |
1392 | - if (!boot_cpu_has(X86_FEATURE_APIC)) |
1393 | + /* Is there an APIC at all or is it disabled? */ |
1394 | + if (!boot_cpu_has(X86_FEATURE_APIC) || disable_apic) |
1395 | + return true; |
1396 | + |
1397 | + /* |
1398 | + * If interrupt delivery mode is legacy PIC or virtual wire without |
1399 | + * configuration, the local APIC timer wont be set up. Make sure |
1400 | + * that the PIT is initialized. |
1401 | + */ |
1402 | + if (apic_intr_mode == APIC_PIC || |
1403 | + apic_intr_mode == APIC_VIRTUAL_WIRE_NO_CONFIG) |
1404 | return true; |
1405 | |
1406 | /* Virt guests may lack ARAT, but still have DEADLINE */ |
1407 | @@ -1322,7 +1331,7 @@ void __init sync_Arb_IDs(void) |
1408 | |
1409 | enum apic_intr_mode_id apic_intr_mode __ro_after_init; |
1410 | |
1411 | -static int __init apic_intr_mode_select(void) |
1412 | +static int __init __apic_intr_mode_select(void) |
1413 | { |
1414 | /* Check kernel option */ |
1415 | if (disable_apic) { |
1416 | @@ -1384,6 +1393,12 @@ static int __init apic_intr_mode_select(void) |
1417 | return APIC_SYMMETRIC_IO; |
1418 | } |
1419 | |
1420 | +/* Select the interrupt delivery mode for the BSP */ |
1421 | +void __init apic_intr_mode_select(void) |
1422 | +{ |
1423 | + apic_intr_mode = __apic_intr_mode_select(); |
1424 | +} |
1425 | + |
1426 | /* |
1427 | * An initial setup of the virtual wire mode. |
1428 | */ |
1429 | @@ -1440,8 +1455,6 @@ void __init apic_intr_mode_init(void) |
1430 | { |
1431 | bool upmode = IS_ENABLED(CONFIG_UP_LATE_INIT); |
1432 | |
1433 | - apic_intr_mode = apic_intr_mode_select(); |
1434 | - |
1435 | switch (apic_intr_mode) { |
1436 | case APIC_PIC: |
1437 | pr_info("APIC: Keep in PIC mode(8259)\n"); |
1438 | diff --git a/arch/x86/kernel/apic/msi.c b/arch/x86/kernel/apic/msi.c |
1439 | index 7f7533462474..159bd0cb8548 100644 |
1440 | --- a/arch/x86/kernel/apic/msi.c |
1441 | +++ b/arch/x86/kernel/apic/msi.c |
1442 | @@ -23,10 +23,8 @@ |
1443 | |
1444 | static struct irq_domain *msi_default_domain; |
1445 | |
1446 | -static void irq_msi_compose_msg(struct irq_data *data, struct msi_msg *msg) |
1447 | +static void __irq_msi_compose_msg(struct irq_cfg *cfg, struct msi_msg *msg) |
1448 | { |
1449 | - struct irq_cfg *cfg = irqd_cfg(data); |
1450 | - |
1451 | msg->address_hi = MSI_ADDR_BASE_HI; |
1452 | |
1453 | if (x2apic_enabled()) |
1454 | @@ -47,6 +45,127 @@ static void irq_msi_compose_msg(struct irq_data *data, struct msi_msg *msg) |
1455 | MSI_DATA_VECTOR(cfg->vector); |
1456 | } |
1457 | |
1458 | +static void irq_msi_compose_msg(struct irq_data *data, struct msi_msg *msg) |
1459 | +{ |
1460 | + __irq_msi_compose_msg(irqd_cfg(data), msg); |
1461 | +} |
1462 | + |
1463 | +static void irq_msi_update_msg(struct irq_data *irqd, struct irq_cfg *cfg) |
1464 | +{ |
1465 | + struct msi_msg msg[2] = { [1] = { }, }; |
1466 | + |
1467 | + __irq_msi_compose_msg(cfg, msg); |
1468 | + irq_data_get_irq_chip(irqd)->irq_write_msi_msg(irqd, msg); |
1469 | +} |
1470 | + |
1471 | +static int |
1472 | +msi_set_affinity(struct irq_data *irqd, const struct cpumask *mask, bool force) |
1473 | +{ |
1474 | + struct irq_cfg old_cfg, *cfg = irqd_cfg(irqd); |
1475 | + struct irq_data *parent = irqd->parent_data; |
1476 | + unsigned int cpu; |
1477 | + int ret; |
1478 | + |
1479 | + /* Save the current configuration */ |
1480 | + cpu = cpumask_first(irq_data_get_effective_affinity_mask(irqd)); |
1481 | + old_cfg = *cfg; |
1482 | + |
1483 | + /* Allocate a new target vector */ |
1484 | + ret = parent->chip->irq_set_affinity(parent, mask, force); |
1485 | + if (ret < 0 || ret == IRQ_SET_MASK_OK_DONE) |
1486 | + return ret; |
1487 | + |
1488 | + /* |
1489 | + * For non-maskable and non-remapped MSI interrupts the migration |
1490 | + * to a different destination CPU and a different vector has to be |
1491 | + * done careful to handle the possible stray interrupt which can be |
1492 | + * caused by the non-atomic update of the address/data pair. |
1493 | + * |
1494 | + * Direct update is possible when: |
1495 | + * - The MSI is maskable (remapped MSI does not use this code path)). |
1496 | + * The quirk bit is not set in this case. |
1497 | + * - The new vector is the same as the old vector |
1498 | + * - The old vector is MANAGED_IRQ_SHUTDOWN_VECTOR (interrupt starts up) |
1499 | + * - The new destination CPU is the same as the old destination CPU |
1500 | + */ |
1501 | + if (!irqd_msi_nomask_quirk(irqd) || |
1502 | + cfg->vector == old_cfg.vector || |
1503 | + old_cfg.vector == MANAGED_IRQ_SHUTDOWN_VECTOR || |
1504 | + cfg->dest_apicid == old_cfg.dest_apicid) { |
1505 | + irq_msi_update_msg(irqd, cfg); |
1506 | + return ret; |
1507 | + } |
1508 | + |
1509 | + /* |
1510 | + * Paranoia: Validate that the interrupt target is the local |
1511 | + * CPU. |
1512 | + */ |
1513 | + if (WARN_ON_ONCE(cpu != smp_processor_id())) { |
1514 | + irq_msi_update_msg(irqd, cfg); |
1515 | + return ret; |
1516 | + } |
1517 | + |
1518 | + /* |
1519 | + * Redirect the interrupt to the new vector on the current CPU |
1520 | + * first. This might cause a spurious interrupt on this vector if |
1521 | + * the device raises an interrupt right between this update and the |
1522 | + * update to the final destination CPU. |
1523 | + * |
1524 | + * If the vector is in use then the installed device handler will |
1525 | + * denote it as spurious which is no harm as this is a rare event |
1526 | + * and interrupt handlers have to cope with spurious interrupts |
1527 | + * anyway. If the vector is unused, then it is marked so it won't |
1528 | + * trigger the 'No irq handler for vector' warning in do_IRQ(). |
1529 | + * |
1530 | + * This requires to hold vector lock to prevent concurrent updates to |
1531 | + * the affected vector. |
1532 | + */ |
1533 | + lock_vector_lock(); |
1534 | + |
1535 | + /* |
1536 | + * Mark the new target vector on the local CPU if it is currently |
1537 | + * unused. Reuse the VECTOR_RETRIGGERED state which is also used in |
1538 | + * the CPU hotplug path for a similar purpose. This cannot be |
1539 | + * undone here as the current CPU has interrupts disabled and |
1540 | + * cannot handle the interrupt before the whole set_affinity() |
1541 | + * section is done. In the CPU unplug case, the current CPU is |
1542 | + * about to vanish and will not handle any interrupts anymore. The |
1543 | + * vector is cleaned up when the CPU comes online again. |
1544 | + */ |
1545 | + if (IS_ERR_OR_NULL(this_cpu_read(vector_irq[cfg->vector]))) |
1546 | + this_cpu_write(vector_irq[cfg->vector], VECTOR_RETRIGGERED); |
1547 | + |
1548 | + /* Redirect it to the new vector on the local CPU temporarily */ |
1549 | + old_cfg.vector = cfg->vector; |
1550 | + irq_msi_update_msg(irqd, &old_cfg); |
1551 | + |
1552 | + /* Now transition it to the target CPU */ |
1553 | + irq_msi_update_msg(irqd, cfg); |
1554 | + |
1555 | + /* |
1556 | + * All interrupts after this point are now targeted at the new |
1557 | + * vector/CPU. |
1558 | + * |
1559 | + * Drop vector lock before testing whether the temporary assignment |
1560 | + * to the local CPU was hit by an interrupt raised in the device, |
1561 | + * because the retrigger function acquires vector lock again. |
1562 | + */ |
1563 | + unlock_vector_lock(); |
1564 | + |
1565 | + /* |
1566 | + * Check whether the transition raced with a device interrupt and |
1567 | + * is pending in the local APICs IRR. It is safe to do this outside |
1568 | + * of vector lock as the irq_desc::lock of this interrupt is still |
1569 | + * held and interrupts are disabled: The check is not accessing the |
1570 | + * underlying vector store. It's just checking the local APIC's |
1571 | + * IRR. |
1572 | + */ |
1573 | + if (lapic_vector_set_in_irr(cfg->vector)) |
1574 | + irq_data_get_irq_chip(irqd)->irq_retrigger(irqd); |
1575 | + |
1576 | + return ret; |
1577 | +} |
1578 | + |
1579 | /* |
1580 | * IRQ Chip for MSI PCI/PCI-X/PCI-Express Devices, |
1581 | * which implement the MSI or MSI-X Capability Structure. |
1582 | @@ -58,6 +177,7 @@ static struct irq_chip pci_msi_controller = { |
1583 | .irq_ack = irq_chip_ack_parent, |
1584 | .irq_retrigger = irq_chip_retrigger_hierarchy, |
1585 | .irq_compose_msi_msg = irq_msi_compose_msg, |
1586 | + .irq_set_affinity = msi_set_affinity, |
1587 | .flags = IRQCHIP_SKIP_SET_WAKE, |
1588 | }; |
1589 | |
1590 | @@ -146,6 +266,8 @@ void __init arch_init_msi_domain(struct irq_domain *parent) |
1591 | } |
1592 | if (!msi_default_domain) |
1593 | pr_warn("failed to initialize irqdomain for MSI/MSI-x.\n"); |
1594 | + else |
1595 | + msi_default_domain->flags |= IRQ_DOMAIN_MSI_NOMASK_QUIRK; |
1596 | } |
1597 | |
1598 | #ifdef CONFIG_IRQ_REMAP |
1599 | diff --git a/arch/x86/kernel/cpu/tsx.c b/arch/x86/kernel/cpu/tsx.c |
1600 | index 3e20d322bc98..032509adf9de 100644 |
1601 | --- a/arch/x86/kernel/cpu/tsx.c |
1602 | +++ b/arch/x86/kernel/cpu/tsx.c |
1603 | @@ -115,11 +115,12 @@ void __init tsx_init(void) |
1604 | tsx_disable(); |
1605 | |
1606 | /* |
1607 | - * tsx_disable() will change the state of the |
1608 | - * RTM CPUID bit. Clear it here since it is now |
1609 | - * expected to be not set. |
1610 | + * tsx_disable() will change the state of the RTM and HLE CPUID |
1611 | + * bits. Clear them here since they are now expected to be not |
1612 | + * set. |
1613 | */ |
1614 | setup_clear_cpu_cap(X86_FEATURE_RTM); |
1615 | + setup_clear_cpu_cap(X86_FEATURE_HLE); |
1616 | } else if (tsx_ctrl_state == TSX_CTRL_ENABLE) { |
1617 | |
1618 | /* |
1619 | @@ -131,10 +132,10 @@ void __init tsx_init(void) |
1620 | tsx_enable(); |
1621 | |
1622 | /* |
1623 | - * tsx_enable() will change the state of the |
1624 | - * RTM CPUID bit. Force it here since it is now |
1625 | - * expected to be set. |
1626 | + * tsx_enable() will change the state of the RTM and HLE CPUID |
1627 | + * bits. Force them here since they are now expected to be set. |
1628 | */ |
1629 | setup_force_cpu_cap(X86_FEATURE_RTM); |
1630 | + setup_force_cpu_cap(X86_FEATURE_HLE); |
1631 | } |
1632 | } |
1633 | diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c |
1634 | index 7ce29cee9f9e..d8673d8a779b 100644 |
1635 | --- a/arch/x86/kernel/time.c |
1636 | +++ b/arch/x86/kernel/time.c |
1637 | @@ -91,10 +91,18 @@ void __init hpet_time_init(void) |
1638 | |
1639 | static __init void x86_late_time_init(void) |
1640 | { |
1641 | + /* |
1642 | + * Before PIT/HPET init, select the interrupt mode. This is required |
1643 | + * to make the decision whether PIT should be initialized correct. |
1644 | + */ |
1645 | + x86_init.irqs.intr_mode_select(); |
1646 | + |
1647 | + /* Setup the legacy timers */ |
1648 | x86_init.timers.timer_init(); |
1649 | + |
1650 | /* |
1651 | - * After PIT/HPET timers init, select and setup |
1652 | - * the final interrupt mode for delivering IRQs. |
1653 | + * After PIT/HPET timers init, set up the final interrupt mode for |
1654 | + * delivering IRQs. |
1655 | */ |
1656 | x86_init.irqs.intr_mode_init(); |
1657 | tsc_init(); |
1658 | diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c |
1659 | index 18a799c8fa28..1838b10a299c 100644 |
1660 | --- a/arch/x86/kernel/x86_init.c |
1661 | +++ b/arch/x86/kernel/x86_init.c |
1662 | @@ -58,6 +58,7 @@ struct x86_init_ops x86_init __initdata = { |
1663 | .pre_vector_init = init_ISA_irqs, |
1664 | .intr_init = native_init_IRQ, |
1665 | .trap_init = x86_init_noop, |
1666 | + .intr_mode_select = apic_intr_mode_select, |
1667 | .intr_mode_init = apic_intr_mode_init |
1668 | }, |
1669 | |
1670 | diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c |
1671 | index b1d5a8c94a57..6fa946f983c9 100644 |
1672 | --- a/arch/x86/kvm/cpuid.c |
1673 | +++ b/arch/x86/kvm/cpuid.c |
1674 | @@ -352,6 +352,7 @@ static inline void do_cpuid_7_mask(struct kvm_cpuid_entry2 *entry, int index) |
1675 | unsigned f_umip = kvm_x86_ops->umip_emulated() ? F(UMIP) : 0; |
1676 | unsigned f_intel_pt = kvm_x86_ops->pt_supported() ? F(INTEL_PT) : 0; |
1677 | unsigned f_la57; |
1678 | + unsigned f_pku = kvm_x86_ops->pku_supported() ? F(PKU) : 0; |
1679 | |
1680 | /* cpuid 7.0.ebx */ |
1681 | const u32 kvm_cpuid_7_0_ebx_x86_features = |
1682 | @@ -363,7 +364,7 @@ static inline void do_cpuid_7_mask(struct kvm_cpuid_entry2 *entry, int index) |
1683 | |
1684 | /* cpuid 7.0.ecx*/ |
1685 | const u32 kvm_cpuid_7_0_ecx_x86_features = |
1686 | - F(AVX512VBMI) | F(LA57) | F(PKU) | 0 /*OSPKE*/ | F(RDPID) | |
1687 | + F(AVX512VBMI) | F(LA57) | 0 /*PKU*/ | 0 /*OSPKE*/ | F(RDPID) | |
1688 | F(AVX512_VPOPCNTDQ) | F(UMIP) | F(AVX512_VBMI2) | F(GFNI) | |
1689 | F(VAES) | F(VPCLMULQDQ) | F(AVX512_VNNI) | F(AVX512_BITALG) | |
1690 | F(CLDEMOTE) | F(MOVDIRI) | F(MOVDIR64B) | 0 /*WAITPKG*/; |
1691 | @@ -392,6 +393,7 @@ static inline void do_cpuid_7_mask(struct kvm_cpuid_entry2 *entry, int index) |
1692 | /* Set LA57 based on hardware capability. */ |
1693 | entry->ecx |= f_la57; |
1694 | entry->ecx |= f_umip; |
1695 | + entry->ecx |= f_pku; |
1696 | /* PKU is not yet implemented for shadow paging. */ |
1697 | if (!tdp_enabled || !boot_cpu_has(X86_FEATURE_OSPKE)) |
1698 | entry->ecx &= ~F(PKU); |
1699 | diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c |
1700 | index 698efb8c3897..37aa9ce29b33 100644 |
1701 | --- a/arch/x86/kvm/emulate.c |
1702 | +++ b/arch/x86/kvm/emulate.c |
1703 | @@ -22,6 +22,7 @@ |
1704 | #include "kvm_cache_regs.h" |
1705 | #include <asm/kvm_emulate.h> |
1706 | #include <linux/stringify.h> |
1707 | +#include <asm/fpu/api.h> |
1708 | #include <asm/debugreg.h> |
1709 | #include <asm/nospec-branch.h> |
1710 | |
1711 | @@ -1075,8 +1076,23 @@ static void fetch_register_operand(struct operand *op) |
1712 | } |
1713 | } |
1714 | |
1715 | +static void emulator_get_fpu(void) |
1716 | +{ |
1717 | + fpregs_lock(); |
1718 | + |
1719 | + fpregs_assert_state_consistent(); |
1720 | + if (test_thread_flag(TIF_NEED_FPU_LOAD)) |
1721 | + switch_fpu_return(); |
1722 | +} |
1723 | + |
1724 | +static void emulator_put_fpu(void) |
1725 | +{ |
1726 | + fpregs_unlock(); |
1727 | +} |
1728 | + |
1729 | static void read_sse_reg(struct x86_emulate_ctxt *ctxt, sse128_t *data, int reg) |
1730 | { |
1731 | + emulator_get_fpu(); |
1732 | switch (reg) { |
1733 | case 0: asm("movdqa %%xmm0, %0" : "=m"(*data)); break; |
1734 | case 1: asm("movdqa %%xmm1, %0" : "=m"(*data)); break; |
1735 | @@ -1098,11 +1114,13 @@ static void read_sse_reg(struct x86_emulate_ctxt *ctxt, sse128_t *data, int reg) |
1736 | #endif |
1737 | default: BUG(); |
1738 | } |
1739 | + emulator_put_fpu(); |
1740 | } |
1741 | |
1742 | static void write_sse_reg(struct x86_emulate_ctxt *ctxt, sse128_t *data, |
1743 | int reg) |
1744 | { |
1745 | + emulator_get_fpu(); |
1746 | switch (reg) { |
1747 | case 0: asm("movdqa %0, %%xmm0" : : "m"(*data)); break; |
1748 | case 1: asm("movdqa %0, %%xmm1" : : "m"(*data)); break; |
1749 | @@ -1124,10 +1142,12 @@ static void write_sse_reg(struct x86_emulate_ctxt *ctxt, sse128_t *data, |
1750 | #endif |
1751 | default: BUG(); |
1752 | } |
1753 | + emulator_put_fpu(); |
1754 | } |
1755 | |
1756 | static void read_mmx_reg(struct x86_emulate_ctxt *ctxt, u64 *data, int reg) |
1757 | { |
1758 | + emulator_get_fpu(); |
1759 | switch (reg) { |
1760 | case 0: asm("movq %%mm0, %0" : "=m"(*data)); break; |
1761 | case 1: asm("movq %%mm1, %0" : "=m"(*data)); break; |
1762 | @@ -1139,10 +1159,12 @@ static void read_mmx_reg(struct x86_emulate_ctxt *ctxt, u64 *data, int reg) |
1763 | case 7: asm("movq %%mm7, %0" : "=m"(*data)); break; |
1764 | default: BUG(); |
1765 | } |
1766 | + emulator_put_fpu(); |
1767 | } |
1768 | |
1769 | static void write_mmx_reg(struct x86_emulate_ctxt *ctxt, u64 *data, int reg) |
1770 | { |
1771 | + emulator_get_fpu(); |
1772 | switch (reg) { |
1773 | case 0: asm("movq %0, %%mm0" : : "m"(*data)); break; |
1774 | case 1: asm("movq %0, %%mm1" : : "m"(*data)); break; |
1775 | @@ -1154,6 +1176,7 @@ static void write_mmx_reg(struct x86_emulate_ctxt *ctxt, u64 *data, int reg) |
1776 | case 7: asm("movq %0, %%mm7" : : "m"(*data)); break; |
1777 | default: BUG(); |
1778 | } |
1779 | + emulator_put_fpu(); |
1780 | } |
1781 | |
1782 | static int em_fninit(struct x86_emulate_ctxt *ctxt) |
1783 | @@ -1161,7 +1184,9 @@ static int em_fninit(struct x86_emulate_ctxt *ctxt) |
1784 | if (ctxt->ops->get_cr(ctxt, 0) & (X86_CR0_TS | X86_CR0_EM)) |
1785 | return emulate_nm(ctxt); |
1786 | |
1787 | + emulator_get_fpu(); |
1788 | asm volatile("fninit"); |
1789 | + emulator_put_fpu(); |
1790 | return X86EMUL_CONTINUE; |
1791 | } |
1792 | |
1793 | @@ -1172,7 +1197,9 @@ static int em_fnstcw(struct x86_emulate_ctxt *ctxt) |
1794 | if (ctxt->ops->get_cr(ctxt, 0) & (X86_CR0_TS | X86_CR0_EM)) |
1795 | return emulate_nm(ctxt); |
1796 | |
1797 | + emulator_get_fpu(); |
1798 | asm volatile("fnstcw %0": "+m"(fcw)); |
1799 | + emulator_put_fpu(); |
1800 | |
1801 | ctxt->dst.val = fcw; |
1802 | |
1803 | @@ -1186,7 +1213,9 @@ static int em_fnstsw(struct x86_emulate_ctxt *ctxt) |
1804 | if (ctxt->ops->get_cr(ctxt, 0) & (X86_CR0_TS | X86_CR0_EM)) |
1805 | return emulate_nm(ctxt); |
1806 | |
1807 | + emulator_get_fpu(); |
1808 | asm volatile("fnstsw %0": "+m"(fsw)); |
1809 | + emulator_put_fpu(); |
1810 | |
1811 | ctxt->dst.val = fsw; |
1812 | |
1813 | @@ -4094,8 +4123,12 @@ static int em_fxsave(struct x86_emulate_ctxt *ctxt) |
1814 | if (rc != X86EMUL_CONTINUE) |
1815 | return rc; |
1816 | |
1817 | + emulator_get_fpu(); |
1818 | + |
1819 | rc = asm_safe("fxsave %[fx]", , [fx] "+m"(fx_state)); |
1820 | |
1821 | + emulator_put_fpu(); |
1822 | + |
1823 | if (rc != X86EMUL_CONTINUE) |
1824 | return rc; |
1825 | |
1826 | @@ -4138,6 +4171,8 @@ static int em_fxrstor(struct x86_emulate_ctxt *ctxt) |
1827 | if (rc != X86EMUL_CONTINUE) |
1828 | return rc; |
1829 | |
1830 | + emulator_get_fpu(); |
1831 | + |
1832 | if (size < __fxstate_size(16)) { |
1833 | rc = fxregs_fixup(&fx_state, size); |
1834 | if (rc != X86EMUL_CONTINUE) |
1835 | @@ -4153,6 +4188,8 @@ static int em_fxrstor(struct x86_emulate_ctxt *ctxt) |
1836 | rc = asm_safe("fxrstor %[fx]", : [fx] "m"(fx_state)); |
1837 | |
1838 | out: |
1839 | + emulator_put_fpu(); |
1840 | + |
1841 | return rc; |
1842 | } |
1843 | |
1844 | @@ -5212,16 +5249,28 @@ int x86_decode_insn(struct x86_emulate_ctxt *ctxt, void *insn, int insn_len) |
1845 | ctxt->ad_bytes = def_ad_bytes ^ 6; |
1846 | break; |
1847 | case 0x26: /* ES override */ |
1848 | + has_seg_override = true; |
1849 | + ctxt->seg_override = VCPU_SREG_ES; |
1850 | + break; |
1851 | case 0x2e: /* CS override */ |
1852 | + has_seg_override = true; |
1853 | + ctxt->seg_override = VCPU_SREG_CS; |
1854 | + break; |
1855 | case 0x36: /* SS override */ |
1856 | + has_seg_override = true; |
1857 | + ctxt->seg_override = VCPU_SREG_SS; |
1858 | + break; |
1859 | case 0x3e: /* DS override */ |
1860 | has_seg_override = true; |
1861 | - ctxt->seg_override = (ctxt->b >> 3) & 3; |
1862 | + ctxt->seg_override = VCPU_SREG_DS; |
1863 | break; |
1864 | case 0x64: /* FS override */ |
1865 | + has_seg_override = true; |
1866 | + ctxt->seg_override = VCPU_SREG_FS; |
1867 | + break; |
1868 | case 0x65: /* GS override */ |
1869 | has_seg_override = true; |
1870 | - ctxt->seg_override = ctxt->b & 7; |
1871 | + ctxt->seg_override = VCPU_SREG_GS; |
1872 | break; |
1873 | case 0x40 ... 0x4f: /* REX */ |
1874 | if (mode != X86EMUL_MODE_PROT64) |
1875 | @@ -5305,10 +5354,15 @@ done_prefixes: |
1876 | } |
1877 | break; |
1878 | case Escape: |
1879 | - if (ctxt->modrm > 0xbf) |
1880 | - opcode = opcode.u.esc->high[ctxt->modrm - 0xc0]; |
1881 | - else |
1882 | + if (ctxt->modrm > 0xbf) { |
1883 | + size_t size = ARRAY_SIZE(opcode.u.esc->high); |
1884 | + u32 index = array_index_nospec( |
1885 | + ctxt->modrm - 0xc0, size); |
1886 | + |
1887 | + opcode = opcode.u.esc->high[index]; |
1888 | + } else { |
1889 | opcode = opcode.u.esc->op[(ctxt->modrm >> 3) & 7]; |
1890 | + } |
1891 | break; |
1892 | case InstrDual: |
1893 | if ((ctxt->modrm >> 6) == 3) |
1894 | @@ -5450,7 +5504,9 @@ static int flush_pending_x87_faults(struct x86_emulate_ctxt *ctxt) |
1895 | { |
1896 | int rc; |
1897 | |
1898 | + emulator_get_fpu(); |
1899 | rc = asm_safe("fwait"); |
1900 | + emulator_put_fpu(); |
1901 | |
1902 | if (unlikely(rc != X86EMUL_CONTINUE)) |
1903 | return emulate_exception(ctxt, MF_VECTOR, 0, false); |
1904 | diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c |
1905 | index 23ff65504d7e..26408434b9bc 100644 |
1906 | --- a/arch/x86/kvm/hyperv.c |
1907 | +++ b/arch/x86/kvm/hyperv.c |
1908 | @@ -809,11 +809,12 @@ static int kvm_hv_msr_get_crash_data(struct kvm_vcpu *vcpu, |
1909 | u32 index, u64 *pdata) |
1910 | { |
1911 | struct kvm_hv *hv = &vcpu->kvm->arch.hyperv; |
1912 | + size_t size = ARRAY_SIZE(hv->hv_crash_param); |
1913 | |
1914 | - if (WARN_ON_ONCE(index >= ARRAY_SIZE(hv->hv_crash_param))) |
1915 | + if (WARN_ON_ONCE(index >= size)) |
1916 | return -EINVAL; |
1917 | |
1918 | - *pdata = hv->hv_crash_param[index]; |
1919 | + *pdata = hv->hv_crash_param[array_index_nospec(index, size)]; |
1920 | return 0; |
1921 | } |
1922 | |
1923 | @@ -852,11 +853,12 @@ static int kvm_hv_msr_set_crash_data(struct kvm_vcpu *vcpu, |
1924 | u32 index, u64 data) |
1925 | { |
1926 | struct kvm_hv *hv = &vcpu->kvm->arch.hyperv; |
1927 | + size_t size = ARRAY_SIZE(hv->hv_crash_param); |
1928 | |
1929 | - if (WARN_ON_ONCE(index >= ARRAY_SIZE(hv->hv_crash_param))) |
1930 | + if (WARN_ON_ONCE(index >= size)) |
1931 | return -EINVAL; |
1932 | |
1933 | - hv->hv_crash_param[index] = data; |
1934 | + hv->hv_crash_param[array_index_nospec(index, size)] = data; |
1935 | return 0; |
1936 | } |
1937 | |
1938 | diff --git a/arch/x86/kvm/i8259.c b/arch/x86/kvm/i8259.c |
1939 | index 8b38bb4868a6..629a09ca9860 100644 |
1940 | --- a/arch/x86/kvm/i8259.c |
1941 | +++ b/arch/x86/kvm/i8259.c |
1942 | @@ -460,10 +460,14 @@ static int picdev_write(struct kvm_pic *s, |
1943 | switch (addr) { |
1944 | case 0x20: |
1945 | case 0x21: |
1946 | + pic_lock(s); |
1947 | + pic_ioport_write(&s->pics[0], addr, data); |
1948 | + pic_unlock(s); |
1949 | + break; |
1950 | case 0xa0: |
1951 | case 0xa1: |
1952 | pic_lock(s); |
1953 | - pic_ioport_write(&s->pics[addr >> 7], addr, data); |
1954 | + pic_ioport_write(&s->pics[1], addr, data); |
1955 | pic_unlock(s); |
1956 | break; |
1957 | case 0x4d0: |
1958 | diff --git a/arch/x86/kvm/ioapic.c b/arch/x86/kvm/ioapic.c |
1959 | index d859ae8890d0..24a6905d60ee 100644 |
1960 | --- a/arch/x86/kvm/ioapic.c |
1961 | +++ b/arch/x86/kvm/ioapic.c |
1962 | @@ -36,6 +36,7 @@ |
1963 | #include <linux/io.h> |
1964 | #include <linux/slab.h> |
1965 | #include <linux/export.h> |
1966 | +#include <linux/nospec.h> |
1967 | #include <asm/processor.h> |
1968 | #include <asm/page.h> |
1969 | #include <asm/current.h> |
1970 | @@ -68,13 +69,14 @@ static unsigned long ioapic_read_indirect(struct kvm_ioapic *ioapic, |
1971 | default: |
1972 | { |
1973 | u32 redir_index = (ioapic->ioregsel - 0x10) >> 1; |
1974 | - u64 redir_content; |
1975 | + u64 redir_content = ~0ULL; |
1976 | |
1977 | - if (redir_index < IOAPIC_NUM_PINS) |
1978 | - redir_content = |
1979 | - ioapic->redirtbl[redir_index].bits; |
1980 | - else |
1981 | - redir_content = ~0ULL; |
1982 | + if (redir_index < IOAPIC_NUM_PINS) { |
1983 | + u32 index = array_index_nospec( |
1984 | + redir_index, IOAPIC_NUM_PINS); |
1985 | + |
1986 | + redir_content = ioapic->redirtbl[index].bits; |
1987 | + } |
1988 | |
1989 | result = (ioapic->ioregsel & 0x1) ? |
1990 | (redir_content >> 32) & 0xffffffff : |
1991 | @@ -291,6 +293,7 @@ static void ioapic_write_indirect(struct kvm_ioapic *ioapic, u32 val) |
1992 | |
1993 | if (index >= IOAPIC_NUM_PINS) |
1994 | return; |
1995 | + index = array_index_nospec(index, IOAPIC_NUM_PINS); |
1996 | e = &ioapic->redirtbl[index]; |
1997 | mask_before = e->fields.mask; |
1998 | /* Preserve read-only fields */ |
1999 | diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c |
2000 | index b29d00b661ff..15728971a430 100644 |
2001 | --- a/arch/x86/kvm/lapic.c |
2002 | +++ b/arch/x86/kvm/lapic.c |
2003 | @@ -1926,15 +1926,20 @@ int kvm_lapic_reg_write(struct kvm_lapic *apic, u32 reg, u32 val) |
2004 | case APIC_LVTTHMR: |
2005 | case APIC_LVTPC: |
2006 | case APIC_LVT1: |
2007 | - case APIC_LVTERR: |
2008 | + case APIC_LVTERR: { |
2009 | /* TODO: Check vector */ |
2010 | + size_t size; |
2011 | + u32 index; |
2012 | + |
2013 | if (!kvm_apic_sw_enabled(apic)) |
2014 | val |= APIC_LVT_MASKED; |
2015 | - |
2016 | - val &= apic_lvt_mask[(reg - APIC_LVTT) >> 4]; |
2017 | + size = ARRAY_SIZE(apic_lvt_mask); |
2018 | + index = array_index_nospec( |
2019 | + (reg - APIC_LVTT) >> 4, size); |
2020 | + val &= apic_lvt_mask[index]; |
2021 | kvm_lapic_set_reg(apic, reg, val); |
2022 | - |
2023 | break; |
2024 | + } |
2025 | |
2026 | case APIC_LVTT: |
2027 | if (!kvm_apic_sw_enabled(apic)) |
2028 | diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c |
2029 | index 2ce9da58611e..518100ea5ef4 100644 |
2030 | --- a/arch/x86/kvm/mmu.c |
2031 | +++ b/arch/x86/kvm/mmu.c |
2032 | @@ -418,22 +418,24 @@ static inline bool is_access_track_spte(u64 spte) |
2033 | * requires a full MMU zap). The flag is instead explicitly queried when |
2034 | * checking for MMIO spte cache hits. |
2035 | */ |
2036 | -#define MMIO_SPTE_GEN_MASK GENMASK_ULL(18, 0) |
2037 | +#define MMIO_SPTE_GEN_MASK GENMASK_ULL(17, 0) |
2038 | |
2039 | #define MMIO_SPTE_GEN_LOW_START 3 |
2040 | #define MMIO_SPTE_GEN_LOW_END 11 |
2041 | #define MMIO_SPTE_GEN_LOW_MASK GENMASK_ULL(MMIO_SPTE_GEN_LOW_END, \ |
2042 | MMIO_SPTE_GEN_LOW_START) |
2043 | |
2044 | -#define MMIO_SPTE_GEN_HIGH_START 52 |
2045 | -#define MMIO_SPTE_GEN_HIGH_END 61 |
2046 | +#define MMIO_SPTE_GEN_HIGH_START PT64_SECOND_AVAIL_BITS_SHIFT |
2047 | +#define MMIO_SPTE_GEN_HIGH_END 62 |
2048 | #define MMIO_SPTE_GEN_HIGH_MASK GENMASK_ULL(MMIO_SPTE_GEN_HIGH_END, \ |
2049 | MMIO_SPTE_GEN_HIGH_START) |
2050 | + |
2051 | static u64 generation_mmio_spte_mask(u64 gen) |
2052 | { |
2053 | u64 mask; |
2054 | |
2055 | WARN_ON(gen & ~MMIO_SPTE_GEN_MASK); |
2056 | + BUILD_BUG_ON((MMIO_SPTE_GEN_HIGH_MASK | MMIO_SPTE_GEN_LOW_MASK) & SPTE_SPECIAL_MASK); |
2057 | |
2058 | mask = (gen << MMIO_SPTE_GEN_LOW_START) & MMIO_SPTE_GEN_LOW_MASK; |
2059 | mask |= (gen << MMIO_SPTE_GEN_HIGH_START) & MMIO_SPTE_GEN_HIGH_MASK; |
2060 | @@ -444,8 +446,6 @@ static u64 get_mmio_spte_generation(u64 spte) |
2061 | { |
2062 | u64 gen; |
2063 | |
2064 | - spte &= ~shadow_mmio_mask; |
2065 | - |
2066 | gen = (spte & MMIO_SPTE_GEN_LOW_MASK) >> MMIO_SPTE_GEN_LOW_START; |
2067 | gen |= (spte & MMIO_SPTE_GEN_HIGH_MASK) >> MMIO_SPTE_GEN_HIGH_START; |
2068 | return gen; |
2069 | @@ -538,16 +538,20 @@ EXPORT_SYMBOL_GPL(kvm_mmu_set_mask_ptes); |
2070 | static u8 kvm_get_shadow_phys_bits(void) |
2071 | { |
2072 | /* |
2073 | - * boot_cpu_data.x86_phys_bits is reduced when MKTME is detected |
2074 | - * in CPU detection code, but MKTME treats those reduced bits as |
2075 | - * 'keyID' thus they are not reserved bits. Therefore for MKTME |
2076 | - * we should still return physical address bits reported by CPUID. |
2077 | + * boot_cpu_data.x86_phys_bits is reduced when MKTME or SME are detected |
2078 | + * in CPU detection code, but the processor treats those reduced bits as |
2079 | + * 'keyID' thus they are not reserved bits. Therefore KVM needs to look at |
2080 | + * the physical address bits reported by CPUID. |
2081 | */ |
2082 | - if (!boot_cpu_has(X86_FEATURE_TME) || |
2083 | - WARN_ON_ONCE(boot_cpu_data.extended_cpuid_level < 0x80000008)) |
2084 | - return boot_cpu_data.x86_phys_bits; |
2085 | + if (likely(boot_cpu_data.extended_cpuid_level >= 0x80000008)) |
2086 | + return cpuid_eax(0x80000008) & 0xff; |
2087 | |
2088 | - return cpuid_eax(0x80000008) & 0xff; |
2089 | + /* |
2090 | + * Quite weird to have VMX or SVM but not MAXPHYADDR; probably a VM with |
2091 | + * custom CPUID. Proceed with whatever the kernel found since these features |
2092 | + * aren't virtualizable (SME/SEV also require CPUIDs higher than 0x80000008). |
2093 | + */ |
2094 | + return boot_cpu_data.x86_phys_bits; |
2095 | } |
2096 | |
2097 | static void kvm_mmu_reset_all_pte_masks(void) |
2098 | @@ -1282,12 +1286,12 @@ static bool mmu_gfn_lpage_is_disallowed(struct kvm_vcpu *vcpu, gfn_t gfn, |
2099 | return __mmu_gfn_lpage_is_disallowed(gfn, level, slot); |
2100 | } |
2101 | |
2102 | -static int host_mapping_level(struct kvm *kvm, gfn_t gfn) |
2103 | +static int host_mapping_level(struct kvm_vcpu *vcpu, gfn_t gfn) |
2104 | { |
2105 | unsigned long page_size; |
2106 | int i, ret = 0; |
2107 | |
2108 | - page_size = kvm_host_page_size(kvm, gfn); |
2109 | + page_size = kvm_host_page_size(vcpu, gfn); |
2110 | |
2111 | for (i = PT_PAGE_TABLE_LEVEL; i <= PT_MAX_HUGEPAGE_LEVEL; ++i) { |
2112 | if (page_size >= KVM_HPAGE_SIZE(i)) |
2113 | @@ -1337,7 +1341,7 @@ static int mapping_level(struct kvm_vcpu *vcpu, gfn_t large_gfn, |
2114 | if (unlikely(*force_pt_level)) |
2115 | return PT_PAGE_TABLE_LEVEL; |
2116 | |
2117 | - host_level = host_mapping_level(vcpu->kvm, large_gfn); |
2118 | + host_level = host_mapping_level(vcpu, large_gfn); |
2119 | |
2120 | if (host_level == PT_PAGE_TABLE_LEVEL) |
2121 | return host_level; |
2122 | @@ -3528,7 +3532,7 @@ static bool is_access_allowed(u32 fault_err_code, u64 spte) |
2123 | * - true: let the vcpu to access on the same address again. |
2124 | * - false: let the real page fault path to fix it. |
2125 | */ |
2126 | -static bool fast_page_fault(struct kvm_vcpu *vcpu, gva_t gva, int level, |
2127 | +static bool fast_page_fault(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa, int level, |
2128 | u32 error_code) |
2129 | { |
2130 | struct kvm_shadow_walk_iterator iterator; |
2131 | @@ -3548,7 +3552,7 @@ static bool fast_page_fault(struct kvm_vcpu *vcpu, gva_t gva, int level, |
2132 | do { |
2133 | u64 new_spte; |
2134 | |
2135 | - for_each_shadow_entry_lockless(vcpu, gva, iterator, spte) |
2136 | + for_each_shadow_entry_lockless(vcpu, cr2_or_gpa, iterator, spte) |
2137 | if (!is_shadow_present_pte(spte) || |
2138 | iterator.level < level) |
2139 | break; |
2140 | @@ -3626,7 +3630,7 @@ static bool fast_page_fault(struct kvm_vcpu *vcpu, gva_t gva, int level, |
2141 | |
2142 | } while (true); |
2143 | |
2144 | - trace_fast_page_fault(vcpu, gva, error_code, iterator.sptep, |
2145 | + trace_fast_page_fault(vcpu, cr2_or_gpa, error_code, iterator.sptep, |
2146 | spte, fault_handled); |
2147 | walk_shadow_page_lockless_end(vcpu); |
2148 | |
2149 | @@ -3634,10 +3638,11 @@ static bool fast_page_fault(struct kvm_vcpu *vcpu, gva_t gva, int level, |
2150 | } |
2151 | |
2152 | static bool try_async_pf(struct kvm_vcpu *vcpu, bool prefault, gfn_t gfn, |
2153 | - gva_t gva, kvm_pfn_t *pfn, bool write, bool *writable); |
2154 | + gpa_t cr2_or_gpa, kvm_pfn_t *pfn, bool write, |
2155 | + bool *writable); |
2156 | static int make_mmu_pages_available(struct kvm_vcpu *vcpu); |
2157 | |
2158 | -static int nonpaging_map(struct kvm_vcpu *vcpu, gva_t v, u32 error_code, |
2159 | +static int nonpaging_map(struct kvm_vcpu *vcpu, gpa_t gpa, u32 error_code, |
2160 | gfn_t gfn, bool prefault) |
2161 | { |
2162 | int r; |
2163 | @@ -3663,16 +3668,16 @@ static int nonpaging_map(struct kvm_vcpu *vcpu, gva_t v, u32 error_code, |
2164 | gfn &= ~(KVM_PAGES_PER_HPAGE(level) - 1); |
2165 | } |
2166 | |
2167 | - if (fast_page_fault(vcpu, v, level, error_code)) |
2168 | + if (fast_page_fault(vcpu, gpa, level, error_code)) |
2169 | return RET_PF_RETRY; |
2170 | |
2171 | mmu_seq = vcpu->kvm->mmu_notifier_seq; |
2172 | smp_rmb(); |
2173 | |
2174 | - if (try_async_pf(vcpu, prefault, gfn, v, &pfn, write, &map_writable)) |
2175 | + if (try_async_pf(vcpu, prefault, gfn, gpa, &pfn, write, &map_writable)) |
2176 | return RET_PF_RETRY; |
2177 | |
2178 | - if (handle_abnormal_pfn(vcpu, v, gfn, pfn, ACC_ALL, &r)) |
2179 | + if (handle_abnormal_pfn(vcpu, gpa, gfn, pfn, ACC_ALL, &r)) |
2180 | return r; |
2181 | |
2182 | r = RET_PF_RETRY; |
2183 | @@ -3683,7 +3688,7 @@ static int nonpaging_map(struct kvm_vcpu *vcpu, gva_t v, u32 error_code, |
2184 | goto out_unlock; |
2185 | if (likely(!force_pt_level)) |
2186 | transparent_hugepage_adjust(vcpu, gfn, &pfn, &level); |
2187 | - r = __direct_map(vcpu, v, write, map_writable, level, pfn, |
2188 | + r = __direct_map(vcpu, gpa, write, map_writable, level, pfn, |
2189 | prefault, false); |
2190 | out_unlock: |
2191 | spin_unlock(&vcpu->kvm->mmu_lock); |
2192 | @@ -3981,7 +3986,7 @@ void kvm_mmu_sync_roots(struct kvm_vcpu *vcpu) |
2193 | } |
2194 | EXPORT_SYMBOL_GPL(kvm_mmu_sync_roots); |
2195 | |
2196 | -static gpa_t nonpaging_gva_to_gpa(struct kvm_vcpu *vcpu, gva_t vaddr, |
2197 | +static gpa_t nonpaging_gva_to_gpa(struct kvm_vcpu *vcpu, gpa_t vaddr, |
2198 | u32 access, struct x86_exception *exception) |
2199 | { |
2200 | if (exception) |
2201 | @@ -3989,7 +3994,7 @@ static gpa_t nonpaging_gva_to_gpa(struct kvm_vcpu *vcpu, gva_t vaddr, |
2202 | return vaddr; |
2203 | } |
2204 | |
2205 | -static gpa_t nonpaging_gva_to_gpa_nested(struct kvm_vcpu *vcpu, gva_t vaddr, |
2206 | +static gpa_t nonpaging_gva_to_gpa_nested(struct kvm_vcpu *vcpu, gpa_t vaddr, |
2207 | u32 access, |
2208 | struct x86_exception *exception) |
2209 | { |
2210 | @@ -4149,13 +4154,14 @@ static void shadow_page_table_clear_flood(struct kvm_vcpu *vcpu, gva_t addr) |
2211 | walk_shadow_page_lockless_end(vcpu); |
2212 | } |
2213 | |
2214 | -static int nonpaging_page_fault(struct kvm_vcpu *vcpu, gva_t gva, |
2215 | +static int nonpaging_page_fault(struct kvm_vcpu *vcpu, gpa_t gpa, |
2216 | u32 error_code, bool prefault) |
2217 | { |
2218 | - gfn_t gfn = gva >> PAGE_SHIFT; |
2219 | + gfn_t gfn = gpa >> PAGE_SHIFT; |
2220 | int r; |
2221 | |
2222 | - pgprintk("%s: gva %lx error %x\n", __func__, gva, error_code); |
2223 | + /* Note, paging is disabled, ergo gva == gpa. */ |
2224 | + pgprintk("%s: gva %lx error %x\n", __func__, gpa, error_code); |
2225 | |
2226 | if (page_fault_handle_page_track(vcpu, error_code, gfn)) |
2227 | return RET_PF_EMULATE; |
2228 | @@ -4167,11 +4173,12 @@ static int nonpaging_page_fault(struct kvm_vcpu *vcpu, gva_t gva, |
2229 | MMU_WARN_ON(!VALID_PAGE(vcpu->arch.mmu->root_hpa)); |
2230 | |
2231 | |
2232 | - return nonpaging_map(vcpu, gva & PAGE_MASK, |
2233 | + return nonpaging_map(vcpu, gpa & PAGE_MASK, |
2234 | error_code, gfn, prefault); |
2235 | } |
2236 | |
2237 | -static int kvm_arch_setup_async_pf(struct kvm_vcpu *vcpu, gva_t gva, gfn_t gfn) |
2238 | +static int kvm_arch_setup_async_pf(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa, |
2239 | + gfn_t gfn) |
2240 | { |
2241 | struct kvm_arch_async_pf arch; |
2242 | |
2243 | @@ -4180,11 +4187,13 @@ static int kvm_arch_setup_async_pf(struct kvm_vcpu *vcpu, gva_t gva, gfn_t gfn) |
2244 | arch.direct_map = vcpu->arch.mmu->direct_map; |
2245 | arch.cr3 = vcpu->arch.mmu->get_cr3(vcpu); |
2246 | |
2247 | - return kvm_setup_async_pf(vcpu, gva, kvm_vcpu_gfn_to_hva(vcpu, gfn), &arch); |
2248 | + return kvm_setup_async_pf(vcpu, cr2_or_gpa, |
2249 | + kvm_vcpu_gfn_to_hva(vcpu, gfn), &arch); |
2250 | } |
2251 | |
2252 | static bool try_async_pf(struct kvm_vcpu *vcpu, bool prefault, gfn_t gfn, |
2253 | - gva_t gva, kvm_pfn_t *pfn, bool write, bool *writable) |
2254 | + gpa_t cr2_or_gpa, kvm_pfn_t *pfn, bool write, |
2255 | + bool *writable) |
2256 | { |
2257 | struct kvm_memory_slot *slot; |
2258 | bool async; |
2259 | @@ -4204,12 +4213,12 @@ static bool try_async_pf(struct kvm_vcpu *vcpu, bool prefault, gfn_t gfn, |
2260 | return false; /* *pfn has correct page already */ |
2261 | |
2262 | if (!prefault && kvm_can_do_async_pf(vcpu)) { |
2263 | - trace_kvm_try_async_get_page(gva, gfn); |
2264 | + trace_kvm_try_async_get_page(cr2_or_gpa, gfn); |
2265 | if (kvm_find_async_pf_gfn(vcpu, gfn)) { |
2266 | - trace_kvm_async_pf_doublefault(gva, gfn); |
2267 | + trace_kvm_async_pf_doublefault(cr2_or_gpa, gfn); |
2268 | kvm_make_request(KVM_REQ_APF_HALT, vcpu); |
2269 | return true; |
2270 | - } else if (kvm_arch_setup_async_pf(vcpu, gva, gfn)) |
2271 | + } else if (kvm_arch_setup_async_pf(vcpu, cr2_or_gpa, gfn)) |
2272 | return true; |
2273 | } |
2274 | |
2275 | @@ -4222,6 +4231,12 @@ int kvm_handle_page_fault(struct kvm_vcpu *vcpu, u64 error_code, |
2276 | { |
2277 | int r = 1; |
2278 | |
2279 | +#ifndef CONFIG_X86_64 |
2280 | + /* A 64-bit CR2 should be impossible on 32-bit KVM. */ |
2281 | + if (WARN_ON_ONCE(fault_address >> 32)) |
2282 | + return -EFAULT; |
2283 | +#endif |
2284 | + |
2285 | vcpu->arch.l1tf_flush_l1d = true; |
2286 | switch (vcpu->arch.apf.host_apf_reason) { |
2287 | default: |
2288 | @@ -4259,7 +4274,7 @@ check_hugepage_cache_consistency(struct kvm_vcpu *vcpu, gfn_t gfn, int level) |
2289 | return kvm_mtrr_check_gfn_range_consistency(vcpu, gfn, page_num); |
2290 | } |
2291 | |
2292 | -static int tdp_page_fault(struct kvm_vcpu *vcpu, gva_t gpa, u32 error_code, |
2293 | +static int tdp_page_fault(struct kvm_vcpu *vcpu, gpa_t gpa, u32 error_code, |
2294 | bool prefault) |
2295 | { |
2296 | kvm_pfn_t pfn; |
2297 | @@ -5516,7 +5531,7 @@ static int make_mmu_pages_available(struct kvm_vcpu *vcpu) |
2298 | return 0; |
2299 | } |
2300 | |
2301 | -int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t cr2, u64 error_code, |
2302 | +int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa, u64 error_code, |
2303 | void *insn, int insn_len) |
2304 | { |
2305 | int r, emulation_type = 0; |
2306 | @@ -5525,18 +5540,18 @@ int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t cr2, u64 error_code, |
2307 | /* With shadow page tables, fault_address contains a GVA or nGPA. */ |
2308 | if (vcpu->arch.mmu->direct_map) { |
2309 | vcpu->arch.gpa_available = true; |
2310 | - vcpu->arch.gpa_val = cr2; |
2311 | + vcpu->arch.gpa_val = cr2_or_gpa; |
2312 | } |
2313 | |
2314 | r = RET_PF_INVALID; |
2315 | if (unlikely(error_code & PFERR_RSVD_MASK)) { |
2316 | - r = handle_mmio_page_fault(vcpu, cr2, direct); |
2317 | + r = handle_mmio_page_fault(vcpu, cr2_or_gpa, direct); |
2318 | if (r == RET_PF_EMULATE) |
2319 | goto emulate; |
2320 | } |
2321 | |
2322 | if (r == RET_PF_INVALID) { |
2323 | - r = vcpu->arch.mmu->page_fault(vcpu, cr2, |
2324 | + r = vcpu->arch.mmu->page_fault(vcpu, cr2_or_gpa, |
2325 | lower_32_bits(error_code), |
2326 | false); |
2327 | WARN_ON(r == RET_PF_INVALID); |
2328 | @@ -5556,7 +5571,7 @@ int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t cr2, u64 error_code, |
2329 | */ |
2330 | if (vcpu->arch.mmu->direct_map && |
2331 | (error_code & PFERR_NESTED_GUEST_PAGE) == PFERR_NESTED_GUEST_PAGE) { |
2332 | - kvm_mmu_unprotect_page(vcpu->kvm, gpa_to_gfn(cr2)); |
2333 | + kvm_mmu_unprotect_page(vcpu->kvm, gpa_to_gfn(cr2_or_gpa)); |
2334 | return 1; |
2335 | } |
2336 | |
2337 | @@ -5571,7 +5586,7 @@ int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t cr2, u64 error_code, |
2338 | * explicitly shadowing L1's page tables, i.e. unprotecting something |
2339 | * for L1 isn't going to magically fix whatever issue cause L2 to fail. |
2340 | */ |
2341 | - if (!mmio_info_in_cache(vcpu, cr2, direct) && !is_guest_mode(vcpu)) |
2342 | + if (!mmio_info_in_cache(vcpu, cr2_or_gpa, direct) && !is_guest_mode(vcpu)) |
2343 | emulation_type = EMULTYPE_ALLOW_RETRY; |
2344 | emulate: |
2345 | /* |
2346 | @@ -5586,7 +5601,7 @@ emulate: |
2347 | return 1; |
2348 | } |
2349 | |
2350 | - return x86_emulate_instruction(vcpu, cr2, emulation_type, insn, |
2351 | + return x86_emulate_instruction(vcpu, cr2_or_gpa, emulation_type, insn, |
2352 | insn_len); |
2353 | } |
2354 | EXPORT_SYMBOL_GPL(kvm_mmu_page_fault); |
2355 | @@ -6249,7 +6264,7 @@ static void kvm_set_mmio_spte_mask(void) |
2356 | * If reserved bit is not supported, clear the present bit to disable |
2357 | * mmio page fault. |
2358 | */ |
2359 | - if (IS_ENABLED(CONFIG_X86_64) && shadow_phys_bits == 52) |
2360 | + if (shadow_phys_bits == 52) |
2361 | mask &= ~1ull; |
2362 | |
2363 | kvm_mmu_set_mmio_spte_mask(mask, mask, ACC_WRITE_MASK | ACC_USER_MASK); |
2364 | diff --git a/arch/x86/kvm/mmutrace.h b/arch/x86/kvm/mmutrace.h |
2365 | index 7ca8831c7d1a..3c6522b84ff1 100644 |
2366 | --- a/arch/x86/kvm/mmutrace.h |
2367 | +++ b/arch/x86/kvm/mmutrace.h |
2368 | @@ -249,13 +249,13 @@ TRACE_EVENT( |
2369 | |
2370 | TRACE_EVENT( |
2371 | fast_page_fault, |
2372 | - TP_PROTO(struct kvm_vcpu *vcpu, gva_t gva, u32 error_code, |
2373 | + TP_PROTO(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa, u32 error_code, |
2374 | u64 *sptep, u64 old_spte, bool retry), |
2375 | - TP_ARGS(vcpu, gva, error_code, sptep, old_spte, retry), |
2376 | + TP_ARGS(vcpu, cr2_or_gpa, error_code, sptep, old_spte, retry), |
2377 | |
2378 | TP_STRUCT__entry( |
2379 | __field(int, vcpu_id) |
2380 | - __field(gva_t, gva) |
2381 | + __field(gpa_t, cr2_or_gpa) |
2382 | __field(u32, error_code) |
2383 | __field(u64 *, sptep) |
2384 | __field(u64, old_spte) |
2385 | @@ -265,7 +265,7 @@ TRACE_EVENT( |
2386 | |
2387 | TP_fast_assign( |
2388 | __entry->vcpu_id = vcpu->vcpu_id; |
2389 | - __entry->gva = gva; |
2390 | + __entry->cr2_or_gpa = cr2_or_gpa; |
2391 | __entry->error_code = error_code; |
2392 | __entry->sptep = sptep; |
2393 | __entry->old_spte = old_spte; |
2394 | @@ -273,9 +273,9 @@ TRACE_EVENT( |
2395 | __entry->retry = retry; |
2396 | ), |
2397 | |
2398 | - TP_printk("vcpu %d gva %lx error_code %s sptep %p old %#llx" |
2399 | + TP_printk("vcpu %d gva %llx error_code %s sptep %p old %#llx" |
2400 | " new %llx spurious %d fixed %d", __entry->vcpu_id, |
2401 | - __entry->gva, __print_flags(__entry->error_code, "|", |
2402 | + __entry->cr2_or_gpa, __print_flags(__entry->error_code, "|", |
2403 | kvm_mmu_trace_pferr_flags), __entry->sptep, |
2404 | __entry->old_spte, __entry->new_spte, |
2405 | __spte_satisfied(old_spte), __spte_satisfied(new_spte) |
2406 | diff --git a/arch/x86/kvm/mtrr.c b/arch/x86/kvm/mtrr.c |
2407 | index 25ce3edd1872..7f0059aa30e1 100644 |
2408 | --- a/arch/x86/kvm/mtrr.c |
2409 | +++ b/arch/x86/kvm/mtrr.c |
2410 | @@ -192,11 +192,15 @@ static bool fixed_msr_to_seg_unit(u32 msr, int *seg, int *unit) |
2411 | break; |
2412 | case MSR_MTRRfix16K_80000 ... MSR_MTRRfix16K_A0000: |
2413 | *seg = 1; |
2414 | - *unit = msr - MSR_MTRRfix16K_80000; |
2415 | + *unit = array_index_nospec( |
2416 | + msr - MSR_MTRRfix16K_80000, |
2417 | + MSR_MTRRfix16K_A0000 - MSR_MTRRfix16K_80000 + 1); |
2418 | break; |
2419 | case MSR_MTRRfix4K_C0000 ... MSR_MTRRfix4K_F8000: |
2420 | *seg = 2; |
2421 | - *unit = msr - MSR_MTRRfix4K_C0000; |
2422 | + *unit = array_index_nospec( |
2423 | + msr - MSR_MTRRfix4K_C0000, |
2424 | + MSR_MTRRfix4K_F8000 - MSR_MTRRfix4K_C0000 + 1); |
2425 | break; |
2426 | default: |
2427 | return false; |
2428 | diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h |
2429 | index 97b21e7fd013..c1d7b866a03f 100644 |
2430 | --- a/arch/x86/kvm/paging_tmpl.h |
2431 | +++ b/arch/x86/kvm/paging_tmpl.h |
2432 | @@ -291,11 +291,11 @@ static inline unsigned FNAME(gpte_pkeys)(struct kvm_vcpu *vcpu, u64 gpte) |
2433 | } |
2434 | |
2435 | /* |
2436 | - * Fetch a guest pte for a guest virtual address |
2437 | + * Fetch a guest pte for a guest virtual address, or for an L2's GPA. |
2438 | */ |
2439 | static int FNAME(walk_addr_generic)(struct guest_walker *walker, |
2440 | struct kvm_vcpu *vcpu, struct kvm_mmu *mmu, |
2441 | - gva_t addr, u32 access) |
2442 | + gpa_t addr, u32 access) |
2443 | { |
2444 | int ret; |
2445 | pt_element_t pte; |
2446 | @@ -496,7 +496,7 @@ error: |
2447 | } |
2448 | |
2449 | static int FNAME(walk_addr)(struct guest_walker *walker, |
2450 | - struct kvm_vcpu *vcpu, gva_t addr, u32 access) |
2451 | + struct kvm_vcpu *vcpu, gpa_t addr, u32 access) |
2452 | { |
2453 | return FNAME(walk_addr_generic)(walker, vcpu, vcpu->arch.mmu, addr, |
2454 | access); |
2455 | @@ -611,7 +611,7 @@ static void FNAME(pte_prefetch)(struct kvm_vcpu *vcpu, struct guest_walker *gw, |
2456 | * If the guest tries to write a write-protected page, we need to |
2457 | * emulate this operation, return 1 to indicate this case. |
2458 | */ |
2459 | -static int FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr, |
2460 | +static int FNAME(fetch)(struct kvm_vcpu *vcpu, gpa_t addr, |
2461 | struct guest_walker *gw, |
2462 | int write_fault, int hlevel, |
2463 | kvm_pfn_t pfn, bool map_writable, bool prefault, |
2464 | @@ -765,7 +765,7 @@ FNAME(is_self_change_mapping)(struct kvm_vcpu *vcpu, |
2465 | * Returns: 1 if we need to emulate the instruction, 0 otherwise, or |
2466 | * a negative value on error. |
2467 | */ |
2468 | -static int FNAME(page_fault)(struct kvm_vcpu *vcpu, gva_t addr, u32 error_code, |
2469 | +static int FNAME(page_fault)(struct kvm_vcpu *vcpu, gpa_t addr, u32 error_code, |
2470 | bool prefault) |
2471 | { |
2472 | int write_fault = error_code & PFERR_WRITE_MASK; |
2473 | @@ -945,18 +945,19 @@ static void FNAME(invlpg)(struct kvm_vcpu *vcpu, gva_t gva, hpa_t root_hpa) |
2474 | spin_unlock(&vcpu->kvm->mmu_lock); |
2475 | } |
2476 | |
2477 | -static gpa_t FNAME(gva_to_gpa)(struct kvm_vcpu *vcpu, gva_t vaddr, u32 access, |
2478 | +/* Note, @addr is a GPA when gva_to_gpa() translates an L2 GPA to an L1 GPA. */ |
2479 | +static gpa_t FNAME(gva_to_gpa)(struct kvm_vcpu *vcpu, gpa_t addr, u32 access, |
2480 | struct x86_exception *exception) |
2481 | { |
2482 | struct guest_walker walker; |
2483 | gpa_t gpa = UNMAPPED_GVA; |
2484 | int r; |
2485 | |
2486 | - r = FNAME(walk_addr)(&walker, vcpu, vaddr, access); |
2487 | + r = FNAME(walk_addr)(&walker, vcpu, addr, access); |
2488 | |
2489 | if (r) { |
2490 | gpa = gfn_to_gpa(walker.gfn); |
2491 | - gpa |= vaddr & ~PAGE_MASK; |
2492 | + gpa |= addr & ~PAGE_MASK; |
2493 | } else if (exception) |
2494 | *exception = walker.fault; |
2495 | |
2496 | @@ -964,7 +965,8 @@ static gpa_t FNAME(gva_to_gpa)(struct kvm_vcpu *vcpu, gva_t vaddr, u32 access, |
2497 | } |
2498 | |
2499 | #if PTTYPE != PTTYPE_EPT |
2500 | -static gpa_t FNAME(gva_to_gpa_nested)(struct kvm_vcpu *vcpu, gva_t vaddr, |
2501 | +/* Note, gva_to_gpa_nested() is only used to translate L2 GVAs. */ |
2502 | +static gpa_t FNAME(gva_to_gpa_nested)(struct kvm_vcpu *vcpu, gpa_t vaddr, |
2503 | u32 access, |
2504 | struct x86_exception *exception) |
2505 | { |
2506 | @@ -972,6 +974,11 @@ static gpa_t FNAME(gva_to_gpa_nested)(struct kvm_vcpu *vcpu, gva_t vaddr, |
2507 | gpa_t gpa = UNMAPPED_GVA; |
2508 | int r; |
2509 | |
2510 | +#ifndef CONFIG_X86_64 |
2511 | + /* A 64-bit GVA should be impossible on 32-bit KVM. */ |
2512 | + WARN_ON_ONCE(vaddr >> 32); |
2513 | +#endif |
2514 | + |
2515 | r = FNAME(walk_addr_nested)(&walker, vcpu, vaddr, access); |
2516 | |
2517 | if (r) { |
2518 | diff --git a/arch/x86/kvm/pmu.h b/arch/x86/kvm/pmu.h |
2519 | index 58265f761c3b..3fc98afd72a8 100644 |
2520 | --- a/arch/x86/kvm/pmu.h |
2521 | +++ b/arch/x86/kvm/pmu.h |
2522 | @@ -2,6 +2,8 @@ |
2523 | #ifndef __KVM_X86_PMU_H |
2524 | #define __KVM_X86_PMU_H |
2525 | |
2526 | +#include <linux/nospec.h> |
2527 | + |
2528 | #define vcpu_to_pmu(vcpu) (&(vcpu)->arch.pmu) |
2529 | #define pmu_to_vcpu(pmu) (container_of((pmu), struct kvm_vcpu, arch.pmu)) |
2530 | #define pmc_to_pmu(pmc) (&(pmc)->vcpu->arch.pmu) |
2531 | @@ -86,8 +88,12 @@ static inline bool pmc_is_enabled(struct kvm_pmc *pmc) |
2532 | static inline struct kvm_pmc *get_gp_pmc(struct kvm_pmu *pmu, u32 msr, |
2533 | u32 base) |
2534 | { |
2535 | - if (msr >= base && msr < base + pmu->nr_arch_gp_counters) |
2536 | - return &pmu->gp_counters[msr - base]; |
2537 | + if (msr >= base && msr < base + pmu->nr_arch_gp_counters) { |
2538 | + u32 index = array_index_nospec(msr - base, |
2539 | + pmu->nr_arch_gp_counters); |
2540 | + |
2541 | + return &pmu->gp_counters[index]; |
2542 | + } |
2543 | |
2544 | return NULL; |
2545 | } |
2546 | @@ -97,8 +103,12 @@ static inline struct kvm_pmc *get_fixed_pmc(struct kvm_pmu *pmu, u32 msr) |
2547 | { |
2548 | int base = MSR_CORE_PERF_FIXED_CTR0; |
2549 | |
2550 | - if (msr >= base && msr < base + pmu->nr_arch_fixed_counters) |
2551 | - return &pmu->fixed_counters[msr - base]; |
2552 | + if (msr >= base && msr < base + pmu->nr_arch_fixed_counters) { |
2553 | + u32 index = array_index_nospec(msr - base, |
2554 | + pmu->nr_arch_fixed_counters); |
2555 | + |
2556 | + return &pmu->fixed_counters[index]; |
2557 | + } |
2558 | |
2559 | return NULL; |
2560 | } |
2561 | diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c |
2562 | index c5673bda4b66..8d1be7c61f10 100644 |
2563 | --- a/arch/x86/kvm/svm.c |
2564 | +++ b/arch/x86/kvm/svm.c |
2565 | @@ -5986,6 +5986,11 @@ static bool svm_has_wbinvd_exit(void) |
2566 | return true; |
2567 | } |
2568 | |
2569 | +static bool svm_pku_supported(void) |
2570 | +{ |
2571 | + return false; |
2572 | +} |
2573 | + |
2574 | #define PRE_EX(exit) { .exit_code = (exit), \ |
2575 | .stage = X86_ICPT_PRE_EXCEPT, } |
2576 | #define POST_EX(exit) { .exit_code = (exit), \ |
2577 | @@ -7278,6 +7283,7 @@ static struct kvm_x86_ops svm_x86_ops __ro_after_init = { |
2578 | .xsaves_supported = svm_xsaves_supported, |
2579 | .umip_emulated = svm_umip_emulated, |
2580 | .pt_supported = svm_pt_supported, |
2581 | + .pku_supported = svm_pku_supported, |
2582 | |
2583 | .set_supported_cpuid = svm_set_supported_cpuid, |
2584 | |
2585 | diff --git a/arch/x86/kvm/vmx/capabilities.h b/arch/x86/kvm/vmx/capabilities.h |
2586 | index 7aa69716d516..283bdb7071af 100644 |
2587 | --- a/arch/x86/kvm/vmx/capabilities.h |
2588 | +++ b/arch/x86/kvm/vmx/capabilities.h |
2589 | @@ -145,6 +145,11 @@ static inline bool vmx_umip_emulated(void) |
2590 | SECONDARY_EXEC_DESC; |
2591 | } |
2592 | |
2593 | +static inline bool vmx_pku_supported(void) |
2594 | +{ |
2595 | + return boot_cpu_has(X86_FEATURE_PKU); |
2596 | +} |
2597 | + |
2598 | static inline bool cpu_has_vmx_rdtscp(void) |
2599 | { |
2600 | return vmcs_config.cpu_based_2nd_exec_ctrl & |
2601 | diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c |
2602 | index d0523741fb03..931d3b5f3acd 100644 |
2603 | --- a/arch/x86/kvm/vmx/nested.c |
2604 | +++ b/arch/x86/kvm/vmx/nested.c |
2605 | @@ -4663,8 +4663,10 @@ static int handle_vmread(struct kvm_vcpu *vcpu) |
2606 | vmx_instruction_info, true, len, &gva)) |
2607 | return 1; |
2608 | /* _system ok, nested_vmx_check_permission has verified cpl=0 */ |
2609 | - if (kvm_write_guest_virt_system(vcpu, gva, &field_value, len, &e)) |
2610 | + if (kvm_write_guest_virt_system(vcpu, gva, &field_value, len, &e)) { |
2611 | kvm_inject_page_fault(vcpu, &e); |
2612 | + return 1; |
2613 | + } |
2614 | } |
2615 | |
2616 | return nested_vmx_succeed(vcpu); |
2617 | diff --git a/arch/x86/kvm/vmx/pmu_intel.c b/arch/x86/kvm/vmx/pmu_intel.c |
2618 | index 3e9c059099e9..f8998a7bc7d5 100644 |
2619 | --- a/arch/x86/kvm/vmx/pmu_intel.c |
2620 | +++ b/arch/x86/kvm/vmx/pmu_intel.c |
2621 | @@ -84,10 +84,14 @@ static unsigned intel_find_arch_event(struct kvm_pmu *pmu, |
2622 | |
2623 | static unsigned intel_find_fixed_event(int idx) |
2624 | { |
2625 | - if (idx >= ARRAY_SIZE(fixed_pmc_events)) |
2626 | + u32 event; |
2627 | + size_t size = ARRAY_SIZE(fixed_pmc_events); |
2628 | + |
2629 | + if (idx >= size) |
2630 | return PERF_COUNT_HW_MAX; |
2631 | |
2632 | - return intel_arch_events[fixed_pmc_events[idx]].event_type; |
2633 | + event = fixed_pmc_events[array_index_nospec(idx, size)]; |
2634 | + return intel_arch_events[event].event_type; |
2635 | } |
2636 | |
2637 | /* check if a PMC is enabled by comparing it with globl_ctrl bits. */ |
2638 | @@ -128,16 +132,20 @@ static struct kvm_pmc *intel_msr_idx_to_pmc(struct kvm_vcpu *vcpu, |
2639 | struct kvm_pmu *pmu = vcpu_to_pmu(vcpu); |
2640 | bool fixed = idx & (1u << 30); |
2641 | struct kvm_pmc *counters; |
2642 | + unsigned int num_counters; |
2643 | |
2644 | idx &= ~(3u << 30); |
2645 | - if (!fixed && idx >= pmu->nr_arch_gp_counters) |
2646 | - return NULL; |
2647 | - if (fixed && idx >= pmu->nr_arch_fixed_counters) |
2648 | + if (fixed) { |
2649 | + counters = pmu->fixed_counters; |
2650 | + num_counters = pmu->nr_arch_fixed_counters; |
2651 | + } else { |
2652 | + counters = pmu->gp_counters; |
2653 | + num_counters = pmu->nr_arch_gp_counters; |
2654 | + } |
2655 | + if (idx >= num_counters) |
2656 | return NULL; |
2657 | - counters = fixed ? pmu->fixed_counters : pmu->gp_counters; |
2658 | *mask &= pmu->counter_bitmask[fixed ? KVM_PMC_FIXED : KVM_PMC_GP]; |
2659 | - |
2660 | - return &counters[idx]; |
2661 | + return &counters[array_index_nospec(idx, num_counters)]; |
2662 | } |
2663 | |
2664 | static bool intel_is_valid_msr(struct kvm_vcpu *vcpu, u32 msr) |
2665 | diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c |
2666 | index f09a213fd5cb..dc7c166c4335 100644 |
2667 | --- a/arch/x86/kvm/vmx/vmx.c |
2668 | +++ b/arch/x86/kvm/vmx/vmx.c |
2669 | @@ -2140,6 +2140,8 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info) |
2670 | (index >= 2 * intel_pt_validate_cap(vmx->pt_desc.caps, |
2671 | PT_CAP_num_address_ranges))) |
2672 | return 1; |
2673 | + if (is_noncanonical_address(data, vcpu)) |
2674 | + return 1; |
2675 | if (index % 2) |
2676 | vmx->pt_desc.guest.addr_b[index / 2] = data; |
2677 | else |
2678 | @@ -7865,6 +7867,7 @@ static struct kvm_x86_ops vmx_x86_ops __ro_after_init = { |
2679 | .xsaves_supported = vmx_xsaves_supported, |
2680 | .umip_emulated = vmx_umip_emulated, |
2681 | .pt_supported = vmx_pt_supported, |
2682 | + .pku_supported = vmx_pku_supported, |
2683 | |
2684 | .request_immediate_exit = vmx_request_immediate_exit, |
2685 | |
2686 | diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c |
2687 | index 8d82ec0482fc..edde5ee8c6f5 100644 |
2688 | --- a/arch/x86/kvm/x86.c |
2689 | +++ b/arch/x86/kvm/x86.c |
2690 | @@ -92,6 +92,8 @@ u64 __read_mostly efer_reserved_bits = ~((u64)(EFER_SCE | EFER_LME | EFER_LMA)); |
2691 | static u64 __read_mostly efer_reserved_bits = ~((u64)EFER_SCE); |
2692 | #endif |
2693 | |
2694 | +static u64 __read_mostly cr4_reserved_bits = CR4_RESERVED_BITS; |
2695 | + |
2696 | #define VM_STAT(x, ...) offsetof(struct kvm, stat.x), KVM_STAT_VM, ## __VA_ARGS__ |
2697 | #define VCPU_STAT(x, ...) offsetof(struct kvm_vcpu, stat.x), KVM_STAT_VCPU, ## __VA_ARGS__ |
2698 | |
2699 | @@ -886,9 +888,38 @@ int kvm_set_xcr(struct kvm_vcpu *vcpu, u32 index, u64 xcr) |
2700 | } |
2701 | EXPORT_SYMBOL_GPL(kvm_set_xcr); |
2702 | |
2703 | +static u64 kvm_host_cr4_reserved_bits(struct cpuinfo_x86 *c) |
2704 | +{ |
2705 | + u64 reserved_bits = CR4_RESERVED_BITS; |
2706 | + |
2707 | + if (!cpu_has(c, X86_FEATURE_XSAVE)) |
2708 | + reserved_bits |= X86_CR4_OSXSAVE; |
2709 | + |
2710 | + if (!cpu_has(c, X86_FEATURE_SMEP)) |
2711 | + reserved_bits |= X86_CR4_SMEP; |
2712 | + |
2713 | + if (!cpu_has(c, X86_FEATURE_SMAP)) |
2714 | + reserved_bits |= X86_CR4_SMAP; |
2715 | + |
2716 | + if (!cpu_has(c, X86_FEATURE_FSGSBASE)) |
2717 | + reserved_bits |= X86_CR4_FSGSBASE; |
2718 | + |
2719 | + if (!cpu_has(c, X86_FEATURE_PKU)) |
2720 | + reserved_bits |= X86_CR4_PKE; |
2721 | + |
2722 | + if (!cpu_has(c, X86_FEATURE_LA57) && |
2723 | + !(cpuid_ecx(0x7) & bit(X86_FEATURE_LA57))) |
2724 | + reserved_bits |= X86_CR4_LA57; |
2725 | + |
2726 | + if (!cpu_has(c, X86_FEATURE_UMIP) && !kvm_x86_ops->umip_emulated()) |
2727 | + reserved_bits |= X86_CR4_UMIP; |
2728 | + |
2729 | + return reserved_bits; |
2730 | +} |
2731 | + |
2732 | static int kvm_valid_cr4(struct kvm_vcpu *vcpu, unsigned long cr4) |
2733 | { |
2734 | - if (cr4 & CR4_RESERVED_BITS) |
2735 | + if (cr4 & cr4_reserved_bits) |
2736 | return -EINVAL; |
2737 | |
2738 | if (!guest_cpuid_has(vcpu, X86_FEATURE_XSAVE) && (cr4 & X86_CR4_OSXSAVE)) |
2739 | @@ -1054,9 +1085,11 @@ static u64 kvm_dr6_fixed(struct kvm_vcpu *vcpu) |
2740 | |
2741 | static int __kvm_set_dr(struct kvm_vcpu *vcpu, int dr, unsigned long val) |
2742 | { |
2743 | + size_t size = ARRAY_SIZE(vcpu->arch.db); |
2744 | + |
2745 | switch (dr) { |
2746 | case 0 ... 3: |
2747 | - vcpu->arch.db[dr] = val; |
2748 | + vcpu->arch.db[array_index_nospec(dr, size)] = val; |
2749 | if (!(vcpu->guest_debug & KVM_GUESTDBG_USE_HW_BP)) |
2750 | vcpu->arch.eff_db[dr] = val; |
2751 | break; |
2752 | @@ -1093,9 +1126,11 @@ EXPORT_SYMBOL_GPL(kvm_set_dr); |
2753 | |
2754 | int kvm_get_dr(struct kvm_vcpu *vcpu, int dr, unsigned long *val) |
2755 | { |
2756 | + size_t size = ARRAY_SIZE(vcpu->arch.db); |
2757 | + |
2758 | switch (dr) { |
2759 | case 0 ... 3: |
2760 | - *val = vcpu->arch.db[dr]; |
2761 | + *val = vcpu->arch.db[array_index_nospec(dr, size)]; |
2762 | break; |
2763 | case 4: |
2764 | /* fall through */ |
2765 | @@ -2490,7 +2525,10 @@ static int set_msr_mce(struct kvm_vcpu *vcpu, struct msr_data *msr_info) |
2766 | default: |
2767 | if (msr >= MSR_IA32_MC0_CTL && |
2768 | msr < MSR_IA32_MCx_CTL(bank_num)) { |
2769 | - u32 offset = msr - MSR_IA32_MC0_CTL; |
2770 | + u32 offset = array_index_nospec( |
2771 | + msr - MSR_IA32_MC0_CTL, |
2772 | + MSR_IA32_MCx_CTL(bank_num) - MSR_IA32_MC0_CTL); |
2773 | + |
2774 | /* only 0 or all 1s can be written to IA32_MCi_CTL |
2775 | * some Linux kernels though clear bit 10 in bank 4 to |
2776 | * workaround a BIOS/GART TBL issue on AMD K8s, ignore |
2777 | @@ -2586,45 +2624,47 @@ static void kvm_vcpu_flush_tlb(struct kvm_vcpu *vcpu, bool invalidate_gpa) |
2778 | |
2779 | static void record_steal_time(struct kvm_vcpu *vcpu) |
2780 | { |
2781 | + struct kvm_host_map map; |
2782 | + struct kvm_steal_time *st; |
2783 | + |
2784 | if (!(vcpu->arch.st.msr_val & KVM_MSR_ENABLED)) |
2785 | return; |
2786 | |
2787 | - if (unlikely(kvm_read_guest_cached(vcpu->kvm, &vcpu->arch.st.stime, |
2788 | - &vcpu->arch.st.steal, sizeof(struct kvm_steal_time)))) |
2789 | + /* -EAGAIN is returned in atomic context so we can just return. */ |
2790 | + if (kvm_map_gfn(vcpu, vcpu->arch.st.msr_val >> PAGE_SHIFT, |
2791 | + &map, &vcpu->arch.st.cache, false)) |
2792 | return; |
2793 | |
2794 | + st = map.hva + |
2795 | + offset_in_page(vcpu->arch.st.msr_val & KVM_STEAL_VALID_BITS); |
2796 | + |
2797 | /* |
2798 | * Doing a TLB flush here, on the guest's behalf, can avoid |
2799 | * expensive IPIs. |
2800 | */ |
2801 | trace_kvm_pv_tlb_flush(vcpu->vcpu_id, |
2802 | - vcpu->arch.st.steal.preempted & KVM_VCPU_FLUSH_TLB); |
2803 | - if (xchg(&vcpu->arch.st.steal.preempted, 0) & KVM_VCPU_FLUSH_TLB) |
2804 | + st->preempted & KVM_VCPU_FLUSH_TLB); |
2805 | + if (xchg(&st->preempted, 0) & KVM_VCPU_FLUSH_TLB) |
2806 | kvm_vcpu_flush_tlb(vcpu, false); |
2807 | |
2808 | - if (vcpu->arch.st.steal.version & 1) |
2809 | - vcpu->arch.st.steal.version += 1; /* first time write, random junk */ |
2810 | + vcpu->arch.st.preempted = 0; |
2811 | |
2812 | - vcpu->arch.st.steal.version += 1; |
2813 | + if (st->version & 1) |
2814 | + st->version += 1; /* first time write, random junk */ |
2815 | |
2816 | - kvm_write_guest_cached(vcpu->kvm, &vcpu->arch.st.stime, |
2817 | - &vcpu->arch.st.steal, sizeof(struct kvm_steal_time)); |
2818 | + st->version += 1; |
2819 | |
2820 | smp_wmb(); |
2821 | |
2822 | - vcpu->arch.st.steal.steal += current->sched_info.run_delay - |
2823 | + st->steal += current->sched_info.run_delay - |
2824 | vcpu->arch.st.last_steal; |
2825 | vcpu->arch.st.last_steal = current->sched_info.run_delay; |
2826 | |
2827 | - kvm_write_guest_cached(vcpu->kvm, &vcpu->arch.st.stime, |
2828 | - &vcpu->arch.st.steal, sizeof(struct kvm_steal_time)); |
2829 | - |
2830 | smp_wmb(); |
2831 | |
2832 | - vcpu->arch.st.steal.version += 1; |
2833 | + st->version += 1; |
2834 | |
2835 | - kvm_write_guest_cached(vcpu->kvm, &vcpu->arch.st.stime, |
2836 | - &vcpu->arch.st.steal, sizeof(struct kvm_steal_time)); |
2837 | + kvm_unmap_gfn(vcpu, &map, &vcpu->arch.st.cache, true, false); |
2838 | } |
2839 | |
2840 | int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info) |
2841 | @@ -2777,11 +2817,6 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info) |
2842 | if (data & KVM_STEAL_RESERVED_MASK) |
2843 | return 1; |
2844 | |
2845 | - if (kvm_gfn_to_hva_cache_init(vcpu->kvm, &vcpu->arch.st.stime, |
2846 | - data & KVM_STEAL_VALID_BITS, |
2847 | - sizeof(struct kvm_steal_time))) |
2848 | - return 1; |
2849 | - |
2850 | vcpu->arch.st.msr_val = data; |
2851 | |
2852 | if (!(data & KVM_MSR_ENABLED)) |
2853 | @@ -2917,7 +2952,10 @@ static int get_msr_mce(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata, bool host) |
2854 | default: |
2855 | if (msr >= MSR_IA32_MC0_CTL && |
2856 | msr < MSR_IA32_MCx_CTL(bank_num)) { |
2857 | - u32 offset = msr - MSR_IA32_MC0_CTL; |
2858 | + u32 offset = array_index_nospec( |
2859 | + msr - MSR_IA32_MC0_CTL, |
2860 | + MSR_IA32_MCx_CTL(bank_num) - MSR_IA32_MC0_CTL); |
2861 | + |
2862 | data = vcpu->arch.mce_banks[offset]; |
2863 | break; |
2864 | } |
2865 | @@ -3443,10 +3481,6 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu) |
2866 | |
2867 | kvm_x86_ops->vcpu_load(vcpu, cpu); |
2868 | |
2869 | - fpregs_assert_state_consistent(); |
2870 | - if (test_thread_flag(TIF_NEED_FPU_LOAD)) |
2871 | - switch_fpu_return(); |
2872 | - |
2873 | /* Apply any externally detected TSC adjustments (due to suspend) */ |
2874 | if (unlikely(vcpu->arch.tsc_offset_adjustment)) { |
2875 | adjust_tsc_offset_host(vcpu, vcpu->arch.tsc_offset_adjustment); |
2876 | @@ -3486,15 +3520,25 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu) |
2877 | |
2878 | static void kvm_steal_time_set_preempted(struct kvm_vcpu *vcpu) |
2879 | { |
2880 | + struct kvm_host_map map; |
2881 | + struct kvm_steal_time *st; |
2882 | + |
2883 | if (!(vcpu->arch.st.msr_val & KVM_MSR_ENABLED)) |
2884 | return; |
2885 | |
2886 | - vcpu->arch.st.steal.preempted = KVM_VCPU_PREEMPTED; |
2887 | + if (vcpu->arch.st.preempted) |
2888 | + return; |
2889 | + |
2890 | + if (kvm_map_gfn(vcpu, vcpu->arch.st.msr_val >> PAGE_SHIFT, &map, |
2891 | + &vcpu->arch.st.cache, true)) |
2892 | + return; |
2893 | |
2894 | - kvm_write_guest_offset_cached(vcpu->kvm, &vcpu->arch.st.stime, |
2895 | - &vcpu->arch.st.steal.preempted, |
2896 | - offsetof(struct kvm_steal_time, preempted), |
2897 | - sizeof(vcpu->arch.st.steal.preempted)); |
2898 | + st = map.hva + |
2899 | + offset_in_page(vcpu->arch.st.msr_val & KVM_STEAL_VALID_BITS); |
2900 | + |
2901 | + st->preempted = vcpu->arch.st.preempted = KVM_VCPU_PREEMPTED; |
2902 | + |
2903 | + kvm_unmap_gfn(vcpu, &map, &vcpu->arch.st.cache, true, true); |
2904 | } |
2905 | |
2906 | void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu) |
2907 | @@ -6365,11 +6409,11 @@ static int handle_emulation_failure(struct kvm_vcpu *vcpu, int emulation_type) |
2908 | return 1; |
2909 | } |
2910 | |
2911 | -static bool reexecute_instruction(struct kvm_vcpu *vcpu, gva_t cr2, |
2912 | +static bool reexecute_instruction(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa, |
2913 | bool write_fault_to_shadow_pgtable, |
2914 | int emulation_type) |
2915 | { |
2916 | - gpa_t gpa = cr2; |
2917 | + gpa_t gpa = cr2_or_gpa; |
2918 | kvm_pfn_t pfn; |
2919 | |
2920 | if (!(emulation_type & EMULTYPE_ALLOW_RETRY)) |
2921 | @@ -6383,7 +6427,7 @@ static bool reexecute_instruction(struct kvm_vcpu *vcpu, gva_t cr2, |
2922 | * Write permission should be allowed since only |
2923 | * write access need to be emulated. |
2924 | */ |
2925 | - gpa = kvm_mmu_gva_to_gpa_write(vcpu, cr2, NULL); |
2926 | + gpa = kvm_mmu_gva_to_gpa_write(vcpu, cr2_or_gpa, NULL); |
2927 | |
2928 | /* |
2929 | * If the mapping is invalid in guest, let cpu retry |
2930 | @@ -6440,10 +6484,10 @@ static bool reexecute_instruction(struct kvm_vcpu *vcpu, gva_t cr2, |
2931 | } |
2932 | |
2933 | static bool retry_instruction(struct x86_emulate_ctxt *ctxt, |
2934 | - unsigned long cr2, int emulation_type) |
2935 | + gpa_t cr2_or_gpa, int emulation_type) |
2936 | { |
2937 | struct kvm_vcpu *vcpu = emul_to_vcpu(ctxt); |
2938 | - unsigned long last_retry_eip, last_retry_addr, gpa = cr2; |
2939 | + unsigned long last_retry_eip, last_retry_addr, gpa = cr2_or_gpa; |
2940 | |
2941 | last_retry_eip = vcpu->arch.last_retry_eip; |
2942 | last_retry_addr = vcpu->arch.last_retry_addr; |
2943 | @@ -6472,14 +6516,14 @@ static bool retry_instruction(struct x86_emulate_ctxt *ctxt, |
2944 | if (x86_page_table_writing_insn(ctxt)) |
2945 | return false; |
2946 | |
2947 | - if (ctxt->eip == last_retry_eip && last_retry_addr == cr2) |
2948 | + if (ctxt->eip == last_retry_eip && last_retry_addr == cr2_or_gpa) |
2949 | return false; |
2950 | |
2951 | vcpu->arch.last_retry_eip = ctxt->eip; |
2952 | - vcpu->arch.last_retry_addr = cr2; |
2953 | + vcpu->arch.last_retry_addr = cr2_or_gpa; |
2954 | |
2955 | if (!vcpu->arch.mmu->direct_map) |
2956 | - gpa = kvm_mmu_gva_to_gpa_write(vcpu, cr2, NULL); |
2957 | + gpa = kvm_mmu_gva_to_gpa_write(vcpu, cr2_or_gpa, NULL); |
2958 | |
2959 | kvm_mmu_unprotect_page(vcpu->kvm, gpa_to_gfn(gpa)); |
2960 | |
2961 | @@ -6625,11 +6669,8 @@ static bool is_vmware_backdoor_opcode(struct x86_emulate_ctxt *ctxt) |
2962 | return false; |
2963 | } |
2964 | |
2965 | -int x86_emulate_instruction(struct kvm_vcpu *vcpu, |
2966 | - unsigned long cr2, |
2967 | - int emulation_type, |
2968 | - void *insn, |
2969 | - int insn_len) |
2970 | +int x86_emulate_instruction(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa, |
2971 | + int emulation_type, void *insn, int insn_len) |
2972 | { |
2973 | int r; |
2974 | struct x86_emulate_ctxt *ctxt = &vcpu->arch.emulate_ctxt; |
2975 | @@ -6675,8 +6716,9 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu, |
2976 | kvm_queue_exception(vcpu, UD_VECTOR); |
2977 | return 1; |
2978 | } |
2979 | - if (reexecute_instruction(vcpu, cr2, write_fault_to_spt, |
2980 | - emulation_type)) |
2981 | + if (reexecute_instruction(vcpu, cr2_or_gpa, |
2982 | + write_fault_to_spt, |
2983 | + emulation_type)) |
2984 | return 1; |
2985 | if (ctxt->have_exception) { |
2986 | /* |
2987 | @@ -6710,7 +6752,7 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu, |
2988 | return 1; |
2989 | } |
2990 | |
2991 | - if (retry_instruction(ctxt, cr2, emulation_type)) |
2992 | + if (retry_instruction(ctxt, cr2_or_gpa, emulation_type)) |
2993 | return 1; |
2994 | |
2995 | /* this is needed for vmware backdoor interface to work since it |
2996 | @@ -6722,7 +6764,7 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu, |
2997 | |
2998 | restart: |
2999 | /* Save the faulting GPA (cr2) in the address field */ |
3000 | - ctxt->exception.address = cr2; |
3001 | + ctxt->exception.address = cr2_or_gpa; |
3002 | |
3003 | r = x86_emulate_insn(ctxt); |
3004 | |
3005 | @@ -6730,7 +6772,7 @@ restart: |
3006 | return 1; |
3007 | |
3008 | if (r == EMULATION_FAILED) { |
3009 | - if (reexecute_instruction(vcpu, cr2, write_fault_to_spt, |
3010 | + if (reexecute_instruction(vcpu, cr2_or_gpa, write_fault_to_spt, |
3011 | emulation_type)) |
3012 | return 1; |
3013 | |
3014 | @@ -8172,8 +8214,9 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu) |
3015 | trace_kvm_entry(vcpu->vcpu_id); |
3016 | guest_enter_irqoff(); |
3017 | |
3018 | - /* The preempt notifier should have taken care of the FPU already. */ |
3019 | - WARN_ON_ONCE(test_thread_flag(TIF_NEED_FPU_LOAD)); |
3020 | + fpregs_assert_state_consistent(); |
3021 | + if (test_thread_flag(TIF_NEED_FPU_LOAD)) |
3022 | + switch_fpu_return(); |
3023 | |
3024 | if (unlikely(vcpu->arch.switch_db_regs)) { |
3025 | set_debugreg(0, 7); |
3026 | @@ -8445,12 +8488,26 @@ static int complete_emulated_mmio(struct kvm_vcpu *vcpu) |
3027 | return 0; |
3028 | } |
3029 | |
3030 | +static void kvm_save_current_fpu(struct fpu *fpu) |
3031 | +{ |
3032 | + /* |
3033 | + * If the target FPU state is not resident in the CPU registers, just |
3034 | + * memcpy() from current, else save CPU state directly to the target. |
3035 | + */ |
3036 | + if (test_thread_flag(TIF_NEED_FPU_LOAD)) |
3037 | + memcpy(&fpu->state, ¤t->thread.fpu.state, |
3038 | + fpu_kernel_xstate_size); |
3039 | + else |
3040 | + copy_fpregs_to_fpstate(fpu); |
3041 | +} |
3042 | + |
3043 | /* Swap (qemu) user FPU context for the guest FPU context. */ |
3044 | static void kvm_load_guest_fpu(struct kvm_vcpu *vcpu) |
3045 | { |
3046 | fpregs_lock(); |
3047 | |
3048 | - copy_fpregs_to_fpstate(vcpu->arch.user_fpu); |
3049 | + kvm_save_current_fpu(vcpu->arch.user_fpu); |
3050 | + |
3051 | /* PKRU is separately restored in kvm_x86_ops->run. */ |
3052 | __copy_kernel_to_fpregs(&vcpu->arch.guest_fpu->state, |
3053 | ~XFEATURE_MASK_PKRU); |
3054 | @@ -8466,7 +8523,8 @@ static void kvm_put_guest_fpu(struct kvm_vcpu *vcpu) |
3055 | { |
3056 | fpregs_lock(); |
3057 | |
3058 | - copy_fpregs_to_fpstate(vcpu->arch.guest_fpu); |
3059 | + kvm_save_current_fpu(vcpu->arch.guest_fpu); |
3060 | + |
3061 | copy_kernel_to_fpregs(&vcpu->arch.user_fpu->state); |
3062 | |
3063 | fpregs_mark_activate(); |
3064 | @@ -8688,6 +8746,8 @@ int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu, |
3065 | struct kvm_mp_state *mp_state) |
3066 | { |
3067 | vcpu_load(vcpu); |
3068 | + if (kvm_mpx_supported()) |
3069 | + kvm_load_guest_fpu(vcpu); |
3070 | |
3071 | kvm_apic_accept_events(vcpu); |
3072 | if (vcpu->arch.mp_state == KVM_MP_STATE_HALTED && |
3073 | @@ -8696,6 +8756,8 @@ int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu, |
3074 | else |
3075 | mp_state->mp_state = vcpu->arch.mp_state; |
3076 | |
3077 | + if (kvm_mpx_supported()) |
3078 | + kvm_put_guest_fpu(vcpu); |
3079 | vcpu_put(vcpu); |
3080 | return 0; |
3081 | } |
3082 | @@ -9055,6 +9117,9 @@ static void fx_init(struct kvm_vcpu *vcpu) |
3083 | void kvm_arch_vcpu_free(struct kvm_vcpu *vcpu) |
3084 | { |
3085 | void *wbinvd_dirty_mask = vcpu->arch.wbinvd_dirty_mask; |
3086 | + struct gfn_to_pfn_cache *cache = &vcpu->arch.st.cache; |
3087 | + |
3088 | + kvm_release_pfn(cache->pfn, cache->dirty, cache); |
3089 | |
3090 | kvmclock_reset(vcpu); |
3091 | |
3092 | @@ -9125,7 +9190,7 @@ void kvm_arch_vcpu_destroy(struct kvm_vcpu *vcpu) |
3093 | kvm_mmu_unload(vcpu); |
3094 | vcpu_put(vcpu); |
3095 | |
3096 | - kvm_x86_ops->vcpu_free(vcpu); |
3097 | + kvm_arch_vcpu_free(vcpu); |
3098 | } |
3099 | |
3100 | void kvm_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event) |
3101 | @@ -9317,6 +9382,8 @@ int kvm_arch_hardware_setup(void) |
3102 | if (r != 0) |
3103 | return r; |
3104 | |
3105 | + cr4_reserved_bits = kvm_host_cr4_reserved_bits(&boot_cpu_data); |
3106 | + |
3107 | if (kvm_has_tsc_control) { |
3108 | /* |
3109 | * Make sure the user can only configure tsc_khz values that |
3110 | @@ -9719,11 +9786,18 @@ out_free: |
3111 | |
3112 | void kvm_arch_memslots_updated(struct kvm *kvm, u64 gen) |
3113 | { |
3114 | + struct kvm_vcpu *vcpu; |
3115 | + int i; |
3116 | + |
3117 | /* |
3118 | * memslots->generation has been incremented. |
3119 | * mmio generation may have reached its maximum value. |
3120 | */ |
3121 | kvm_mmu_invalidate_mmio_sptes(kvm, gen); |
3122 | + |
3123 | + /* Force re-initialization of steal_time cache */ |
3124 | + kvm_for_each_vcpu(i, vcpu, kvm) |
3125 | + kvm_vcpu_kick(vcpu); |
3126 | } |
3127 | |
3128 | int kvm_arch_prepare_memory_region(struct kvm *kvm, |
3129 | @@ -9975,7 +10049,7 @@ void kvm_arch_async_page_ready(struct kvm_vcpu *vcpu, struct kvm_async_pf *work) |
3130 | work->arch.cr3 != vcpu->arch.mmu->get_cr3(vcpu)) |
3131 | return; |
3132 | |
3133 | - vcpu->arch.mmu->page_fault(vcpu, work->gva, 0, true); |
3134 | + vcpu->arch.mmu->page_fault(vcpu, work->cr2_or_gpa, 0, true); |
3135 | } |
3136 | |
3137 | static inline u32 kvm_async_pf_hash_fn(gfn_t gfn) |
3138 | @@ -10088,7 +10162,7 @@ void kvm_arch_async_page_not_present(struct kvm_vcpu *vcpu, |
3139 | { |
3140 | struct x86_exception fault; |
3141 | |
3142 | - trace_kvm_async_pf_not_present(work->arch.token, work->gva); |
3143 | + trace_kvm_async_pf_not_present(work->arch.token, work->cr2_or_gpa); |
3144 | kvm_add_async_pf_gfn(vcpu, work->arch.gfn); |
3145 | |
3146 | if (kvm_can_deliver_async_pf(vcpu) && |
3147 | @@ -10123,7 +10197,7 @@ void kvm_arch_async_page_present(struct kvm_vcpu *vcpu, |
3148 | work->arch.token = ~0; /* broadcast wakeup */ |
3149 | else |
3150 | kvm_del_async_pf_gfn(vcpu, work->arch.gfn); |
3151 | - trace_kvm_async_pf_ready(work->arch.token, work->gva); |
3152 | + trace_kvm_async_pf_ready(work->arch.token, work->cr2_or_gpa); |
3153 | |
3154 | if (vcpu->arch.apf.msr_val & KVM_ASYNC_PF_ENABLED && |
3155 | !apf_get_user(vcpu, &val)) { |
3156 | diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h |
3157 | index dbf7442a822b..de6b55484876 100644 |
3158 | --- a/arch/x86/kvm/x86.h |
3159 | +++ b/arch/x86/kvm/x86.h |
3160 | @@ -286,7 +286,7 @@ int kvm_mtrr_get_msr(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata); |
3161 | bool kvm_mtrr_check_gfn_range_consistency(struct kvm_vcpu *vcpu, gfn_t gfn, |
3162 | int page_num); |
3163 | bool kvm_vector_hashing_enabled(void); |
3164 | -int x86_emulate_instruction(struct kvm_vcpu *vcpu, unsigned long cr2, |
3165 | +int x86_emulate_instruction(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa, |
3166 | int emulation_type, void *insn, int insn_len); |
3167 | |
3168 | #define KVM_SUPPORTED_XCR0 (XFEATURE_MASK_FP | XFEATURE_MASK_SSE \ |
3169 | diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c |
3170 | index 5bfea374a160..6ea215cdeada 100644 |
3171 | --- a/arch/x86/xen/enlighten_pv.c |
3172 | +++ b/arch/x86/xen/enlighten_pv.c |
3173 | @@ -1215,6 +1215,7 @@ asmlinkage __visible void __init xen_start_kernel(void) |
3174 | x86_platform.get_nmi_reason = xen_get_nmi_reason; |
3175 | |
3176 | x86_init.resources.memory_setup = xen_memory_setup; |
3177 | + x86_init.irqs.intr_mode_select = x86_init_noop; |
3178 | x86_init.irqs.intr_mode_init = x86_init_noop; |
3179 | x86_init.oem.arch_setup = xen_arch_setup; |
3180 | x86_init.oem.banner = xen_banner; |
3181 | diff --git a/crypto/algapi.c b/crypto/algapi.c |
3182 | index de30ddc952d8..bb8329e49956 100644 |
3183 | --- a/crypto/algapi.c |
3184 | +++ b/crypto/algapi.c |
3185 | @@ -257,6 +257,7 @@ void crypto_alg_tested(const char *name, int err) |
3186 | struct crypto_alg *alg; |
3187 | struct crypto_alg *q; |
3188 | LIST_HEAD(list); |
3189 | + bool best; |
3190 | |
3191 | down_write(&crypto_alg_sem); |
3192 | list_for_each_entry(q, &crypto_alg_list, cra_list) { |
3193 | @@ -280,6 +281,21 @@ found: |
3194 | |
3195 | alg->cra_flags |= CRYPTO_ALG_TESTED; |
3196 | |
3197 | + /* Only satisfy larval waiters if we are the best. */ |
3198 | + best = true; |
3199 | + list_for_each_entry(q, &crypto_alg_list, cra_list) { |
3200 | + if (crypto_is_moribund(q) || !crypto_is_larval(q)) |
3201 | + continue; |
3202 | + |
3203 | + if (strcmp(alg->cra_name, q->cra_name)) |
3204 | + continue; |
3205 | + |
3206 | + if (q->cra_priority > alg->cra_priority) { |
3207 | + best = false; |
3208 | + break; |
3209 | + } |
3210 | + } |
3211 | + |
3212 | list_for_each_entry(q, &crypto_alg_list, cra_list) { |
3213 | if (q == alg) |
3214 | continue; |
3215 | @@ -303,10 +319,12 @@ found: |
3216 | continue; |
3217 | if ((q->cra_flags ^ alg->cra_flags) & larval->mask) |
3218 | continue; |
3219 | - if (!crypto_mod_get(alg)) |
3220 | - continue; |
3221 | |
3222 | - larval->adult = alg; |
3223 | + if (best && crypto_mod_get(alg)) |
3224 | + larval->adult = alg; |
3225 | + else |
3226 | + larval->adult = ERR_PTR(-EAGAIN); |
3227 | + |
3228 | continue; |
3229 | } |
3230 | |
3231 | @@ -669,11 +687,9 @@ EXPORT_SYMBOL_GPL(crypto_grab_spawn); |
3232 | |
3233 | void crypto_drop_spawn(struct crypto_spawn *spawn) |
3234 | { |
3235 | - if (!spawn->alg) |
3236 | - return; |
3237 | - |
3238 | down_write(&crypto_alg_sem); |
3239 | - list_del(&spawn->list); |
3240 | + if (spawn->alg) |
3241 | + list_del(&spawn->list); |
3242 | up_write(&crypto_alg_sem); |
3243 | } |
3244 | EXPORT_SYMBOL_GPL(crypto_drop_spawn); |
3245 | @@ -681,22 +697,16 @@ EXPORT_SYMBOL_GPL(crypto_drop_spawn); |
3246 | static struct crypto_alg *crypto_spawn_alg(struct crypto_spawn *spawn) |
3247 | { |
3248 | struct crypto_alg *alg; |
3249 | - struct crypto_alg *alg2; |
3250 | |
3251 | down_read(&crypto_alg_sem); |
3252 | alg = spawn->alg; |
3253 | - alg2 = alg; |
3254 | - if (alg2) |
3255 | - alg2 = crypto_mod_get(alg2); |
3256 | - up_read(&crypto_alg_sem); |
3257 | - |
3258 | - if (!alg2) { |
3259 | - if (alg) |
3260 | - crypto_shoot_alg(alg); |
3261 | - return ERR_PTR(-EAGAIN); |
3262 | + if (alg && !crypto_mod_get(alg)) { |
3263 | + alg->cra_flags |= CRYPTO_ALG_DYING; |
3264 | + alg = NULL; |
3265 | } |
3266 | + up_read(&crypto_alg_sem); |
3267 | |
3268 | - return alg; |
3269 | + return alg ?: ERR_PTR(-EAGAIN); |
3270 | } |
3271 | |
3272 | struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn, u32 type, |
3273 | diff --git a/crypto/api.c b/crypto/api.c |
3274 | index d8ba54142620..eda0c56b8615 100644 |
3275 | --- a/crypto/api.c |
3276 | +++ b/crypto/api.c |
3277 | @@ -97,7 +97,7 @@ static void crypto_larval_destroy(struct crypto_alg *alg) |
3278 | struct crypto_larval *larval = (void *)alg; |
3279 | |
3280 | BUG_ON(!crypto_is_larval(alg)); |
3281 | - if (larval->adult) |
3282 | + if (!IS_ERR_OR_NULL(larval->adult)) |
3283 | crypto_mod_put(larval->adult); |
3284 | kfree(larval); |
3285 | } |
3286 | @@ -178,6 +178,8 @@ static struct crypto_alg *crypto_larval_wait(struct crypto_alg *alg) |
3287 | alg = ERR_PTR(-ETIMEDOUT); |
3288 | else if (!alg) |
3289 | alg = ERR_PTR(-ENOENT); |
3290 | + else if (IS_ERR(alg)) |
3291 | + ; |
3292 | else if (crypto_is_test_larval(larval) && |
3293 | !(alg->cra_flags & CRYPTO_ALG_TESTED)) |
3294 | alg = ERR_PTR(-EAGAIN); |
3295 | @@ -344,13 +346,12 @@ static unsigned int crypto_ctxsize(struct crypto_alg *alg, u32 type, u32 mask) |
3296 | return len; |
3297 | } |
3298 | |
3299 | -void crypto_shoot_alg(struct crypto_alg *alg) |
3300 | +static void crypto_shoot_alg(struct crypto_alg *alg) |
3301 | { |
3302 | down_write(&crypto_alg_sem); |
3303 | alg->cra_flags |= CRYPTO_ALG_DYING; |
3304 | up_write(&crypto_alg_sem); |
3305 | } |
3306 | -EXPORT_SYMBOL_GPL(crypto_shoot_alg); |
3307 | |
3308 | struct crypto_tfm *__crypto_alloc_tfm(struct crypto_alg *alg, u32 type, |
3309 | u32 mask) |
3310 | diff --git a/crypto/internal.h b/crypto/internal.h |
3311 | index 93df7bec844a..e506a57e2243 100644 |
3312 | --- a/crypto/internal.h |
3313 | +++ b/crypto/internal.h |
3314 | @@ -68,7 +68,6 @@ void crypto_alg_tested(const char *name, int err); |
3315 | void crypto_remove_spawns(struct crypto_alg *alg, struct list_head *list, |
3316 | struct crypto_alg *nalg); |
3317 | void crypto_remove_final(struct list_head *list); |
3318 | -void crypto_shoot_alg(struct crypto_alg *alg); |
3319 | struct crypto_tfm *__crypto_alloc_tfm(struct crypto_alg *alg, u32 type, |
3320 | u32 mask); |
3321 | void *crypto_create_tfm(struct crypto_alg *alg, |
3322 | diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c |
3323 | index 81bbea7f2ba6..a4f3b3f342c8 100644 |
3324 | --- a/crypto/pcrypt.c |
3325 | +++ b/crypto/pcrypt.c |
3326 | @@ -24,6 +24,8 @@ static struct kset *pcrypt_kset; |
3327 | |
3328 | struct pcrypt_instance_ctx { |
3329 | struct crypto_aead_spawn spawn; |
3330 | + struct padata_shell *psenc; |
3331 | + struct padata_shell *psdec; |
3332 | atomic_t tfm_count; |
3333 | }; |
3334 | |
3335 | @@ -32,6 +34,12 @@ struct pcrypt_aead_ctx { |
3336 | unsigned int cb_cpu; |
3337 | }; |
3338 | |
3339 | +static inline struct pcrypt_instance_ctx *pcrypt_tfm_ictx( |
3340 | + struct crypto_aead *tfm) |
3341 | +{ |
3342 | + return aead_instance_ctx(aead_alg_instance(tfm)); |
3343 | +} |
3344 | + |
3345 | static int pcrypt_aead_setkey(struct crypto_aead *parent, |
3346 | const u8 *key, unsigned int keylen) |
3347 | { |
3348 | @@ -63,7 +71,6 @@ static void pcrypt_aead_done(struct crypto_async_request *areq, int err) |
3349 | struct padata_priv *padata = pcrypt_request_padata(preq); |
3350 | |
3351 | padata->info = err; |
3352 | - req->base.flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP; |
3353 | |
3354 | padata_do_serial(padata); |
3355 | } |
3356 | @@ -90,6 +97,9 @@ static int pcrypt_aead_encrypt(struct aead_request *req) |
3357 | struct crypto_aead *aead = crypto_aead_reqtfm(req); |
3358 | struct pcrypt_aead_ctx *ctx = crypto_aead_ctx(aead); |
3359 | u32 flags = aead_request_flags(req); |
3360 | + struct pcrypt_instance_ctx *ictx; |
3361 | + |
3362 | + ictx = pcrypt_tfm_ictx(aead); |
3363 | |
3364 | memset(padata, 0, sizeof(struct padata_priv)); |
3365 | |
3366 | @@ -103,7 +113,7 @@ static int pcrypt_aead_encrypt(struct aead_request *req) |
3367 | req->cryptlen, req->iv); |
3368 | aead_request_set_ad(creq, req->assoclen); |
3369 | |
3370 | - err = padata_do_parallel(pencrypt, padata, &ctx->cb_cpu); |
3371 | + err = padata_do_parallel(ictx->psenc, padata, &ctx->cb_cpu); |
3372 | if (!err) |
3373 | return -EINPROGRESS; |
3374 | |
3375 | @@ -132,6 +142,9 @@ static int pcrypt_aead_decrypt(struct aead_request *req) |
3376 | struct crypto_aead *aead = crypto_aead_reqtfm(req); |
3377 | struct pcrypt_aead_ctx *ctx = crypto_aead_ctx(aead); |
3378 | u32 flags = aead_request_flags(req); |
3379 | + struct pcrypt_instance_ctx *ictx; |
3380 | + |
3381 | + ictx = pcrypt_tfm_ictx(aead); |
3382 | |
3383 | memset(padata, 0, sizeof(struct padata_priv)); |
3384 | |
3385 | @@ -145,7 +158,7 @@ static int pcrypt_aead_decrypt(struct aead_request *req) |
3386 | req->cryptlen, req->iv); |
3387 | aead_request_set_ad(creq, req->assoclen); |
3388 | |
3389 | - err = padata_do_parallel(pdecrypt, padata, &ctx->cb_cpu); |
3390 | + err = padata_do_parallel(ictx->psdec, padata, &ctx->cb_cpu); |
3391 | if (!err) |
3392 | return -EINPROGRESS; |
3393 | |
3394 | @@ -192,6 +205,8 @@ static void pcrypt_free(struct aead_instance *inst) |
3395 | struct pcrypt_instance_ctx *ctx = aead_instance_ctx(inst); |
3396 | |
3397 | crypto_drop_aead(&ctx->spawn); |
3398 | + padata_free_shell(ctx->psdec); |
3399 | + padata_free_shell(ctx->psenc); |
3400 | kfree(inst); |
3401 | } |
3402 | |
3403 | @@ -233,12 +248,22 @@ static int pcrypt_create_aead(struct crypto_template *tmpl, struct rtattr **tb, |
3404 | if (!inst) |
3405 | return -ENOMEM; |
3406 | |
3407 | + err = -ENOMEM; |
3408 | + |
3409 | ctx = aead_instance_ctx(inst); |
3410 | + ctx->psenc = padata_alloc_shell(pencrypt); |
3411 | + if (!ctx->psenc) |
3412 | + goto out_free_inst; |
3413 | + |
3414 | + ctx->psdec = padata_alloc_shell(pdecrypt); |
3415 | + if (!ctx->psdec) |
3416 | + goto out_free_psenc; |
3417 | + |
3418 | crypto_set_aead_spawn(&ctx->spawn, aead_crypto_instance(inst)); |
3419 | |
3420 | err = crypto_grab_aead(&ctx->spawn, name, 0, 0); |
3421 | if (err) |
3422 | - goto out_free_inst; |
3423 | + goto out_free_psdec; |
3424 | |
3425 | alg = crypto_spawn_aead_alg(&ctx->spawn); |
3426 | err = pcrypt_init_instance(aead_crypto_instance(inst), &alg->base); |
3427 | @@ -271,6 +296,10 @@ out: |
3428 | |
3429 | out_drop_aead: |
3430 | crypto_drop_aead(&ctx->spawn); |
3431 | +out_free_psdec: |
3432 | + padata_free_shell(ctx->psdec); |
3433 | +out_free_psenc: |
3434 | + padata_free_shell(ctx->psenc); |
3435 | out_free_inst: |
3436 | kfree(inst); |
3437 | goto out; |
3438 | diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c |
3439 | index 558fedf8a7a1..254a7d98b9d4 100644 |
3440 | --- a/drivers/acpi/battery.c |
3441 | +++ b/drivers/acpi/battery.c |
3442 | @@ -38,6 +38,8 @@ |
3443 | #define PREFIX "ACPI: " |
3444 | |
3445 | #define ACPI_BATTERY_VALUE_UNKNOWN 0xFFFFFFFF |
3446 | +#define ACPI_BATTERY_CAPACITY_VALID(capacity) \ |
3447 | + ((capacity) != 0 && (capacity) != ACPI_BATTERY_VALUE_UNKNOWN) |
3448 | |
3449 | #define ACPI_BATTERY_DEVICE_NAME "Battery" |
3450 | |
3451 | @@ -192,7 +194,8 @@ static int acpi_battery_is_charged(struct acpi_battery *battery) |
3452 | |
3453 | static bool acpi_battery_is_degraded(struct acpi_battery *battery) |
3454 | { |
3455 | - return battery->full_charge_capacity && battery->design_capacity && |
3456 | + return ACPI_BATTERY_CAPACITY_VALID(battery->full_charge_capacity) && |
3457 | + ACPI_BATTERY_CAPACITY_VALID(battery->design_capacity) && |
3458 | battery->full_charge_capacity < battery->design_capacity; |
3459 | } |
3460 | |
3461 | @@ -214,7 +217,7 @@ static int acpi_battery_get_property(struct power_supply *psy, |
3462 | enum power_supply_property psp, |
3463 | union power_supply_propval *val) |
3464 | { |
3465 | - int ret = 0; |
3466 | + int full_capacity = ACPI_BATTERY_VALUE_UNKNOWN, ret = 0; |
3467 | struct acpi_battery *battery = to_acpi_battery(psy); |
3468 | |
3469 | if (acpi_battery_present(battery)) { |
3470 | @@ -263,14 +266,14 @@ static int acpi_battery_get_property(struct power_supply *psy, |
3471 | break; |
3472 | case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN: |
3473 | case POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN: |
3474 | - if (battery->design_capacity == ACPI_BATTERY_VALUE_UNKNOWN) |
3475 | + if (!ACPI_BATTERY_CAPACITY_VALID(battery->design_capacity)) |
3476 | ret = -ENODEV; |
3477 | else |
3478 | val->intval = battery->design_capacity * 1000; |
3479 | break; |
3480 | case POWER_SUPPLY_PROP_CHARGE_FULL: |
3481 | case POWER_SUPPLY_PROP_ENERGY_FULL: |
3482 | - if (battery->full_charge_capacity == ACPI_BATTERY_VALUE_UNKNOWN) |
3483 | + if (!ACPI_BATTERY_CAPACITY_VALID(battery->full_charge_capacity)) |
3484 | ret = -ENODEV; |
3485 | else |
3486 | val->intval = battery->full_charge_capacity * 1000; |
3487 | @@ -283,11 +286,17 @@ static int acpi_battery_get_property(struct power_supply *psy, |
3488 | val->intval = battery->capacity_now * 1000; |
3489 | break; |
3490 | case POWER_SUPPLY_PROP_CAPACITY: |
3491 | - if (battery->capacity_now && battery->full_charge_capacity) |
3492 | - val->intval = battery->capacity_now * 100/ |
3493 | - battery->full_charge_capacity; |
3494 | + if (ACPI_BATTERY_CAPACITY_VALID(battery->full_charge_capacity)) |
3495 | + full_capacity = battery->full_charge_capacity; |
3496 | + else if (ACPI_BATTERY_CAPACITY_VALID(battery->design_capacity)) |
3497 | + full_capacity = battery->design_capacity; |
3498 | + |
3499 | + if (battery->capacity_now == ACPI_BATTERY_VALUE_UNKNOWN || |
3500 | + full_capacity == ACPI_BATTERY_VALUE_UNKNOWN) |
3501 | + ret = -ENODEV; |
3502 | else |
3503 | - val->intval = 0; |
3504 | + val->intval = battery->capacity_now * 100/ |
3505 | + full_capacity; |
3506 | break; |
3507 | case POWER_SUPPLY_PROP_CAPACITY_LEVEL: |
3508 | if (battery->state & ACPI_BATTERY_STATE_CRITICAL) |
3509 | @@ -333,6 +342,20 @@ static enum power_supply_property charge_battery_props[] = { |
3510 | POWER_SUPPLY_PROP_SERIAL_NUMBER, |
3511 | }; |
3512 | |
3513 | +static enum power_supply_property charge_battery_full_cap_broken_props[] = { |
3514 | + POWER_SUPPLY_PROP_STATUS, |
3515 | + POWER_SUPPLY_PROP_PRESENT, |
3516 | + POWER_SUPPLY_PROP_TECHNOLOGY, |
3517 | + POWER_SUPPLY_PROP_CYCLE_COUNT, |
3518 | + POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN, |
3519 | + POWER_SUPPLY_PROP_VOLTAGE_NOW, |
3520 | + POWER_SUPPLY_PROP_CURRENT_NOW, |
3521 | + POWER_SUPPLY_PROP_CHARGE_NOW, |
3522 | + POWER_SUPPLY_PROP_MODEL_NAME, |
3523 | + POWER_SUPPLY_PROP_MANUFACTURER, |
3524 | + POWER_SUPPLY_PROP_SERIAL_NUMBER, |
3525 | +}; |
3526 | + |
3527 | static enum power_supply_property energy_battery_props[] = { |
3528 | POWER_SUPPLY_PROP_STATUS, |
3529 | POWER_SUPPLY_PROP_PRESENT, |
3530 | @@ -794,20 +817,34 @@ static void __exit battery_hook_exit(void) |
3531 | static int sysfs_add_battery(struct acpi_battery *battery) |
3532 | { |
3533 | struct power_supply_config psy_cfg = { .drv_data = battery, }; |
3534 | + bool full_cap_broken = false; |
3535 | + |
3536 | + if (!ACPI_BATTERY_CAPACITY_VALID(battery->full_charge_capacity) && |
3537 | + !ACPI_BATTERY_CAPACITY_VALID(battery->design_capacity)) |
3538 | + full_cap_broken = true; |
3539 | |
3540 | if (battery->power_unit == ACPI_BATTERY_POWER_UNIT_MA) { |
3541 | - battery->bat_desc.properties = charge_battery_props; |
3542 | - battery->bat_desc.num_properties = |
3543 | - ARRAY_SIZE(charge_battery_props); |
3544 | - } else if (battery->full_charge_capacity == 0) { |
3545 | - battery->bat_desc.properties = |
3546 | - energy_battery_full_cap_broken_props; |
3547 | - battery->bat_desc.num_properties = |
3548 | - ARRAY_SIZE(energy_battery_full_cap_broken_props); |
3549 | + if (full_cap_broken) { |
3550 | + battery->bat_desc.properties = |
3551 | + charge_battery_full_cap_broken_props; |
3552 | + battery->bat_desc.num_properties = |
3553 | + ARRAY_SIZE(charge_battery_full_cap_broken_props); |
3554 | + } else { |
3555 | + battery->bat_desc.properties = charge_battery_props; |
3556 | + battery->bat_desc.num_properties = |
3557 | + ARRAY_SIZE(charge_battery_props); |
3558 | + } |
3559 | } else { |
3560 | - battery->bat_desc.properties = energy_battery_props; |
3561 | - battery->bat_desc.num_properties = |
3562 | - ARRAY_SIZE(energy_battery_props); |
3563 | + if (full_cap_broken) { |
3564 | + battery->bat_desc.properties = |
3565 | + energy_battery_full_cap_broken_props; |
3566 | + battery->bat_desc.num_properties = |
3567 | + ARRAY_SIZE(energy_battery_full_cap_broken_props); |
3568 | + } else { |
3569 | + battery->bat_desc.properties = energy_battery_props; |
3570 | + battery->bat_desc.num_properties = |
3571 | + ARRAY_SIZE(energy_battery_props); |
3572 | + } |
3573 | } |
3574 | |
3575 | battery->bat_desc.name = acpi_device_bid(battery->device); |
3576 | diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c |
3577 | index 31014c7d3793..e63fd7bfd3a5 100644 |
3578 | --- a/drivers/acpi/video_detect.c |
3579 | +++ b/drivers/acpi/video_detect.c |
3580 | @@ -336,6 +336,11 @@ static const struct dmi_system_id video_detect_dmi_table[] = { |
3581 | DMI_MATCH(DMI_PRODUCT_NAME, "Precision 7510"), |
3582 | }, |
3583 | }, |
3584 | + |
3585 | + /* |
3586 | + * Desktops which falsely report a backlight and which our heuristics |
3587 | + * for this do not catch. |
3588 | + */ |
3589 | { |
3590 | .callback = video_detect_force_none, |
3591 | .ident = "Dell OptiPlex 9020M", |
3592 | @@ -344,6 +349,14 @@ static const struct dmi_system_id video_detect_dmi_table[] = { |
3593 | DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 9020M"), |
3594 | }, |
3595 | }, |
3596 | + { |
3597 | + .callback = video_detect_force_none, |
3598 | + .ident = "MSI MS-7721", |
3599 | + .matches = { |
3600 | + DMI_MATCH(DMI_SYS_VENDOR, "MSI"), |
3601 | + DMI_MATCH(DMI_PRODUCT_NAME, "MS-7721"), |
3602 | + }, |
3603 | + }, |
3604 | { }, |
3605 | }; |
3606 | |
3607 | diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c |
3608 | index 134a8af51511..0e99a760aebd 100644 |
3609 | --- a/drivers/base/power/main.c |
3610 | +++ b/drivers/base/power/main.c |
3611 | @@ -273,10 +273,38 @@ static void dpm_wait_for_suppliers(struct device *dev, bool async) |
3612 | device_links_read_unlock(idx); |
3613 | } |
3614 | |
3615 | -static void dpm_wait_for_superior(struct device *dev, bool async) |
3616 | +static bool dpm_wait_for_superior(struct device *dev, bool async) |
3617 | { |
3618 | - dpm_wait(dev->parent, async); |
3619 | + struct device *parent; |
3620 | + |
3621 | + /* |
3622 | + * If the device is resumed asynchronously and the parent's callback |
3623 | + * deletes both the device and the parent itself, the parent object may |
3624 | + * be freed while this function is running, so avoid that by reference |
3625 | + * counting the parent once more unless the device has been deleted |
3626 | + * already (in which case return right away). |
3627 | + */ |
3628 | + mutex_lock(&dpm_list_mtx); |
3629 | + |
3630 | + if (!device_pm_initialized(dev)) { |
3631 | + mutex_unlock(&dpm_list_mtx); |
3632 | + return false; |
3633 | + } |
3634 | + |
3635 | + parent = get_device(dev->parent); |
3636 | + |
3637 | + mutex_unlock(&dpm_list_mtx); |
3638 | + |
3639 | + dpm_wait(parent, async); |
3640 | + put_device(parent); |
3641 | + |
3642 | dpm_wait_for_suppliers(dev, async); |
3643 | + |
3644 | + /* |
3645 | + * If the parent's callback has deleted the device, attempting to resume |
3646 | + * it would be invalid, so avoid doing that then. |
3647 | + */ |
3648 | + return device_pm_initialized(dev); |
3649 | } |
3650 | |
3651 | static void dpm_wait_for_consumers(struct device *dev, bool async) |
3652 | @@ -621,7 +649,8 @@ static int device_resume_noirq(struct device *dev, pm_message_t state, bool asyn |
3653 | if (!dev->power.is_noirq_suspended) |
3654 | goto Out; |
3655 | |
3656 | - dpm_wait_for_superior(dev, async); |
3657 | + if (!dpm_wait_for_superior(dev, async)) |
3658 | + goto Out; |
3659 | |
3660 | skip_resume = dev_pm_may_skip_resume(dev); |
3661 | |
3662 | @@ -829,7 +858,8 @@ static int device_resume_early(struct device *dev, pm_message_t state, bool asyn |
3663 | if (!dev->power.is_late_suspended) |
3664 | goto Out; |
3665 | |
3666 | - dpm_wait_for_superior(dev, async); |
3667 | + if (!dpm_wait_for_superior(dev, async)) |
3668 | + goto Out; |
3669 | |
3670 | callback = dpm_subsys_resume_early_cb(dev, state, &info); |
3671 | |
3672 | @@ -944,7 +974,9 @@ static int device_resume(struct device *dev, pm_message_t state, bool async) |
3673 | goto Complete; |
3674 | } |
3675 | |
3676 | - dpm_wait_for_superior(dev, async); |
3677 | + if (!dpm_wait_for_superior(dev, async)) |
3678 | + goto Complete; |
3679 | + |
3680 | dpm_watchdog_set(&wd, dev); |
3681 | device_lock(dev); |
3682 | |
3683 | diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c |
3684 | index 4e7ef35f1c8f..9c3b063e1a1f 100644 |
3685 | --- a/drivers/bluetooth/btusb.c |
3686 | +++ b/drivers/bluetooth/btusb.c |
3687 | @@ -2850,7 +2850,7 @@ static int btusb_mtk_setup_firmware(struct hci_dev *hdev, const char *fwname) |
3688 | err = btusb_mtk_hci_wmt_sync(hdev, &wmt_params); |
3689 | if (err < 0) { |
3690 | bt_dev_err(hdev, "Failed to send wmt rst (%d)", err); |
3691 | - return err; |
3692 | + goto err_release_fw; |
3693 | } |
3694 | |
3695 | /* Wait a few moments for firmware activation done */ |
3696 | @@ -3819,6 +3819,10 @@ static int btusb_probe(struct usb_interface *intf, |
3697 | * (DEVICE_REMOTE_WAKEUP) |
3698 | */ |
3699 | set_bit(BTUSB_WAKEUP_DISABLE, &data->flags); |
3700 | + |
3701 | + err = usb_autopm_get_interface(intf); |
3702 | + if (err < 0) |
3703 | + goto out_free_dev; |
3704 | } |
3705 | |
3706 | if (id->driver_info & BTUSB_AMP) { |
3707 | diff --git a/drivers/clk/tegra/clk-tegra-periph.c b/drivers/clk/tegra/clk-tegra-periph.c |
3708 | index 1ed85f120a1b..49b9f2f85bad 100644 |
3709 | --- a/drivers/clk/tegra/clk-tegra-periph.c |
3710 | +++ b/drivers/clk/tegra/clk-tegra-periph.c |
3711 | @@ -785,7 +785,11 @@ static struct tegra_periph_init_data gate_clks[] = { |
3712 | GATE("ahbdma", "hclk", 33, 0, tegra_clk_ahbdma, 0), |
3713 | GATE("apbdma", "pclk", 34, 0, tegra_clk_apbdma, 0), |
3714 | GATE("kbc", "clk_32k", 36, TEGRA_PERIPH_ON_APB | TEGRA_PERIPH_NO_RESET, tegra_clk_kbc, 0), |
3715 | - GATE("fuse", "clk_m", 39, TEGRA_PERIPH_ON_APB, tegra_clk_fuse, 0), |
3716 | + /* |
3717 | + * Critical for RAM re-repair operation, which must occur on resume |
3718 | + * from LP1 system suspend and as part of CCPLEX cluster switching. |
3719 | + */ |
3720 | + GATE("fuse", "clk_m", 39, TEGRA_PERIPH_ON_APB, tegra_clk_fuse, CLK_IS_CRITICAL), |
3721 | GATE("fuse_burn", "clk_m", 39, TEGRA_PERIPH_ON_APB, tegra_clk_fuse_burn, 0), |
3722 | GATE("kfuse", "clk_m", 40, TEGRA_PERIPH_ON_APB, tegra_clk_kfuse, 0), |
3723 | GATE("apbif", "clk_m", 107, TEGRA_PERIPH_ON_APB, tegra_clk_apbif, 0), |
3724 | diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c |
3725 | index 8d8da763adc5..8910fd1ae3c6 100644 |
3726 | --- a/drivers/cpufreq/cppc_cpufreq.c |
3727 | +++ b/drivers/cpufreq/cppc_cpufreq.c |
3728 | @@ -217,7 +217,7 @@ static int cppc_cpufreq_set_target(struct cpufreq_policy *policy, |
3729 | return ret; |
3730 | } |
3731 | |
3732 | -static int cppc_verify_policy(struct cpufreq_policy *policy) |
3733 | +static int cppc_verify_policy(struct cpufreq_policy_data *policy) |
3734 | { |
3735 | cpufreq_verify_within_cpu_limits(policy); |
3736 | return 0; |
3737 | diff --git a/drivers/cpufreq/cpufreq-nforce2.c b/drivers/cpufreq/cpufreq-nforce2.c |
3738 | index cd53272e2fa2..f7a7bcf6f52e 100644 |
3739 | --- a/drivers/cpufreq/cpufreq-nforce2.c |
3740 | +++ b/drivers/cpufreq/cpufreq-nforce2.c |
3741 | @@ -291,7 +291,7 @@ static int nforce2_target(struct cpufreq_policy *policy, |
3742 | * nforce2_verify - verifies a new CPUFreq policy |
3743 | * @policy: new policy |
3744 | */ |
3745 | -static int nforce2_verify(struct cpufreq_policy *policy) |
3746 | +static int nforce2_verify(struct cpufreq_policy_data *policy) |
3747 | { |
3748 | unsigned int fsb_pol_max; |
3749 | |
3750 | diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c |
3751 | index a7db4f22a077..7679f8a91745 100644 |
3752 | --- a/drivers/cpufreq/cpufreq.c |
3753 | +++ b/drivers/cpufreq/cpufreq.c |
3754 | @@ -74,6 +74,9 @@ static void cpufreq_exit_governor(struct cpufreq_policy *policy); |
3755 | static int cpufreq_start_governor(struct cpufreq_policy *policy); |
3756 | static void cpufreq_stop_governor(struct cpufreq_policy *policy); |
3757 | static void cpufreq_governor_limits(struct cpufreq_policy *policy); |
3758 | +static int cpufreq_set_policy(struct cpufreq_policy *policy, |
3759 | + struct cpufreq_governor *new_gov, |
3760 | + unsigned int new_pol); |
3761 | |
3762 | /** |
3763 | * Two notifier lists: the "policy" list is involved in the |
3764 | @@ -613,25 +616,22 @@ static struct cpufreq_governor *find_governor(const char *str_governor) |
3765 | return NULL; |
3766 | } |
3767 | |
3768 | -static int cpufreq_parse_policy(char *str_governor, |
3769 | - struct cpufreq_policy *policy) |
3770 | +static unsigned int cpufreq_parse_policy(char *str_governor) |
3771 | { |
3772 | - if (!strncasecmp(str_governor, "performance", CPUFREQ_NAME_LEN)) { |
3773 | - policy->policy = CPUFREQ_POLICY_PERFORMANCE; |
3774 | - return 0; |
3775 | - } |
3776 | - if (!strncasecmp(str_governor, "powersave", CPUFREQ_NAME_LEN)) { |
3777 | - policy->policy = CPUFREQ_POLICY_POWERSAVE; |
3778 | - return 0; |
3779 | - } |
3780 | - return -EINVAL; |
3781 | + if (!strncasecmp(str_governor, "performance", CPUFREQ_NAME_LEN)) |
3782 | + return CPUFREQ_POLICY_PERFORMANCE; |
3783 | + |
3784 | + if (!strncasecmp(str_governor, "powersave", CPUFREQ_NAME_LEN)) |
3785 | + return CPUFREQ_POLICY_POWERSAVE; |
3786 | + |
3787 | + return CPUFREQ_POLICY_UNKNOWN; |
3788 | } |
3789 | |
3790 | /** |
3791 | * cpufreq_parse_governor - parse a governor string only for has_target() |
3792 | + * @str_governor: Governor name. |
3793 | */ |
3794 | -static int cpufreq_parse_governor(char *str_governor, |
3795 | - struct cpufreq_policy *policy) |
3796 | +static struct cpufreq_governor *cpufreq_parse_governor(char *str_governor) |
3797 | { |
3798 | struct cpufreq_governor *t; |
3799 | |
3800 | @@ -645,7 +645,7 @@ static int cpufreq_parse_governor(char *str_governor, |
3801 | |
3802 | ret = request_module("cpufreq_%s", str_governor); |
3803 | if (ret) |
3804 | - return -EINVAL; |
3805 | + return NULL; |
3806 | |
3807 | mutex_lock(&cpufreq_governor_mutex); |
3808 | |
3809 | @@ -656,12 +656,7 @@ static int cpufreq_parse_governor(char *str_governor, |
3810 | |
3811 | mutex_unlock(&cpufreq_governor_mutex); |
3812 | |
3813 | - if (t) { |
3814 | - policy->governor = t; |
3815 | - return 0; |
3816 | - } |
3817 | - |
3818 | - return -EINVAL; |
3819 | + return t; |
3820 | } |
3821 | |
3822 | /** |
3823 | @@ -762,28 +757,33 @@ static ssize_t show_scaling_governor(struct cpufreq_policy *policy, char *buf) |
3824 | static ssize_t store_scaling_governor(struct cpufreq_policy *policy, |
3825 | const char *buf, size_t count) |
3826 | { |
3827 | + char str_governor[16]; |
3828 | int ret; |
3829 | - char str_governor[16]; |
3830 | - struct cpufreq_policy new_policy; |
3831 | - |
3832 | - memcpy(&new_policy, policy, sizeof(*policy)); |
3833 | |
3834 | ret = sscanf(buf, "%15s", str_governor); |
3835 | if (ret != 1) |
3836 | return -EINVAL; |
3837 | |
3838 | if (cpufreq_driver->setpolicy) { |
3839 | - if (cpufreq_parse_policy(str_governor, &new_policy)) |
3840 | + unsigned int new_pol; |
3841 | + |
3842 | + new_pol = cpufreq_parse_policy(str_governor); |
3843 | + if (!new_pol) |
3844 | return -EINVAL; |
3845 | + |
3846 | + ret = cpufreq_set_policy(policy, NULL, new_pol); |
3847 | } else { |
3848 | - if (cpufreq_parse_governor(str_governor, &new_policy)) |
3849 | + struct cpufreq_governor *new_gov; |
3850 | + |
3851 | + new_gov = cpufreq_parse_governor(str_governor); |
3852 | + if (!new_gov) |
3853 | return -EINVAL; |
3854 | - } |
3855 | |
3856 | - ret = cpufreq_set_policy(policy, &new_policy); |
3857 | + ret = cpufreq_set_policy(policy, new_gov, |
3858 | + CPUFREQ_POLICY_UNKNOWN); |
3859 | |
3860 | - if (new_policy.governor) |
3861 | - module_put(new_policy.governor->owner); |
3862 | + module_put(new_gov->owner); |
3863 | + } |
3864 | |
3865 | return ret ? ret : count; |
3866 | } |
3867 | @@ -1050,40 +1050,33 @@ __weak struct cpufreq_governor *cpufreq_default_governor(void) |
3868 | |
3869 | static int cpufreq_init_policy(struct cpufreq_policy *policy) |
3870 | { |
3871 | - struct cpufreq_governor *gov = NULL, *def_gov = NULL; |
3872 | - struct cpufreq_policy new_policy; |
3873 | - |
3874 | - memcpy(&new_policy, policy, sizeof(*policy)); |
3875 | - |
3876 | - def_gov = cpufreq_default_governor(); |
3877 | + struct cpufreq_governor *def_gov = cpufreq_default_governor(); |
3878 | + struct cpufreq_governor *gov = NULL; |
3879 | + unsigned int pol = CPUFREQ_POLICY_UNKNOWN; |
3880 | |
3881 | if (has_target()) { |
3882 | - /* |
3883 | - * Update governor of new_policy to the governor used before |
3884 | - * hotplug |
3885 | - */ |
3886 | + /* Update policy governor to the one used before hotplug. */ |
3887 | gov = find_governor(policy->last_governor); |
3888 | if (gov) { |
3889 | pr_debug("Restoring governor %s for cpu %d\n", |
3890 | - policy->governor->name, policy->cpu); |
3891 | - } else { |
3892 | - if (!def_gov) |
3893 | - return -ENODATA; |
3894 | + policy->governor->name, policy->cpu); |
3895 | + } else if (def_gov) { |
3896 | gov = def_gov; |
3897 | + } else { |
3898 | + return -ENODATA; |
3899 | } |
3900 | - new_policy.governor = gov; |
3901 | } else { |
3902 | /* Use the default policy if there is no last_policy. */ |
3903 | if (policy->last_policy) { |
3904 | - new_policy.policy = policy->last_policy; |
3905 | + pol = policy->last_policy; |
3906 | + } else if (def_gov) { |
3907 | + pol = cpufreq_parse_policy(def_gov->name); |
3908 | } else { |
3909 | - if (!def_gov) |
3910 | - return -ENODATA; |
3911 | - cpufreq_parse_policy(def_gov->name, &new_policy); |
3912 | + return -ENODATA; |
3913 | } |
3914 | } |
3915 | |
3916 | - return cpufreq_set_policy(policy, &new_policy); |
3917 | + return cpufreq_set_policy(policy, gov, pol); |
3918 | } |
3919 | |
3920 | static int cpufreq_add_policy_cpu(struct cpufreq_policy *policy, unsigned int cpu) |
3921 | @@ -1111,13 +1104,10 @@ static int cpufreq_add_policy_cpu(struct cpufreq_policy *policy, unsigned int cp |
3922 | |
3923 | void refresh_frequency_limits(struct cpufreq_policy *policy) |
3924 | { |
3925 | - struct cpufreq_policy new_policy; |
3926 | - |
3927 | if (!policy_is_inactive(policy)) { |
3928 | - new_policy = *policy; |
3929 | pr_debug("updating policy for CPU %u\n", policy->cpu); |
3930 | |
3931 | - cpufreq_set_policy(policy, &new_policy); |
3932 | + cpufreq_set_policy(policy, policy->governor, policy->policy); |
3933 | } |
3934 | } |
3935 | EXPORT_SYMBOL(refresh_frequency_limits); |
3936 | @@ -2361,43 +2351,46 @@ EXPORT_SYMBOL(cpufreq_get_policy); |
3937 | /** |
3938 | * cpufreq_set_policy - Modify cpufreq policy parameters. |
3939 | * @policy: Policy object to modify. |
3940 | - * @new_policy: New policy data. |
3941 | + * @new_gov: Policy governor pointer. |
3942 | + * @new_pol: Policy value (for drivers with built-in governors). |
3943 | * |
3944 | - * Pass @new_policy to the cpufreq driver's ->verify() callback. Next, copy the |
3945 | - * min and max parameters of @new_policy to @policy and either invoke the |
3946 | - * driver's ->setpolicy() callback (if present) or carry out a governor update |
3947 | - * for @policy. That is, run the current governor's ->limits() callback (if the |
3948 | - * governor field in @new_policy points to the same object as the one in |
3949 | - * @policy) or replace the governor for @policy with the new one stored in |
3950 | - * @new_policy. |
3951 | + * Invoke the cpufreq driver's ->verify() callback to sanity-check the frequency |
3952 | + * limits to be set for the policy, update @policy with the verified limits |
3953 | + * values and either invoke the driver's ->setpolicy() callback (if present) or |
3954 | + * carry out a governor update for @policy. That is, run the current governor's |
3955 | + * ->limits() callback (if @new_gov points to the same object as the one in |
3956 | + * @policy) or replace the governor for @policy with @new_gov. |
3957 | * |
3958 | * The cpuinfo part of @policy is not updated by this function. |
3959 | */ |
3960 | -int cpufreq_set_policy(struct cpufreq_policy *policy, |
3961 | - struct cpufreq_policy *new_policy) |
3962 | +static int cpufreq_set_policy(struct cpufreq_policy *policy, |
3963 | + struct cpufreq_governor *new_gov, |
3964 | + unsigned int new_pol) |
3965 | { |
3966 | + struct cpufreq_policy_data new_data; |
3967 | struct cpufreq_governor *old_gov; |
3968 | int ret; |
3969 | |
3970 | - pr_debug("setting new policy for CPU %u: %u - %u kHz\n", |
3971 | - new_policy->cpu, new_policy->min, new_policy->max); |
3972 | - |
3973 | - memcpy(&new_policy->cpuinfo, &policy->cpuinfo, sizeof(policy->cpuinfo)); |
3974 | - |
3975 | + memcpy(&new_data.cpuinfo, &policy->cpuinfo, sizeof(policy->cpuinfo)); |
3976 | + new_data.freq_table = policy->freq_table; |
3977 | + new_data.cpu = policy->cpu; |
3978 | /* |
3979 | * PM QoS framework collects all the requests from users and provide us |
3980 | * the final aggregated value here. |
3981 | */ |
3982 | - new_policy->min = freq_qos_read_value(&policy->constraints, FREQ_QOS_MIN); |
3983 | - new_policy->max = freq_qos_read_value(&policy->constraints, FREQ_QOS_MAX); |
3984 | + new_data.min = freq_qos_read_value(&policy->constraints, FREQ_QOS_MIN); |
3985 | + new_data.max = freq_qos_read_value(&policy->constraints, FREQ_QOS_MAX); |
3986 | + |
3987 | + pr_debug("setting new policy for CPU %u: %u - %u kHz\n", |
3988 | + new_data.cpu, new_data.min, new_data.max); |
3989 | |
3990 | /* verify the cpu speed can be set within this limit */ |
3991 | - ret = cpufreq_driver->verify(new_policy); |
3992 | + ret = cpufreq_driver->verify(&new_data); |
3993 | if (ret) |
3994 | return ret; |
3995 | |
3996 | - policy->min = new_policy->min; |
3997 | - policy->max = new_policy->max; |
3998 | + policy->min = new_data.min; |
3999 | + policy->max = new_data.max; |
4000 | trace_cpu_frequency_limits(policy); |
4001 | |
4002 | policy->cached_target_freq = UINT_MAX; |
4003 | @@ -2406,12 +2399,12 @@ int cpufreq_set_policy(struct cpufreq_policy *policy, |
4004 | policy->min, policy->max); |
4005 | |
4006 | if (cpufreq_driver->setpolicy) { |
4007 | - policy->policy = new_policy->policy; |
4008 | + policy->policy = new_pol; |
4009 | pr_debug("setting range\n"); |
4010 | return cpufreq_driver->setpolicy(policy); |
4011 | } |
4012 | |
4013 | - if (new_policy->governor == policy->governor) { |
4014 | + if (new_gov == policy->governor) { |
4015 | pr_debug("governor limits update\n"); |
4016 | cpufreq_governor_limits(policy); |
4017 | return 0; |
4018 | @@ -2428,7 +2421,7 @@ int cpufreq_set_policy(struct cpufreq_policy *policy, |
4019 | } |
4020 | |
4021 | /* start new governor */ |
4022 | - policy->governor = new_policy->governor; |
4023 | + policy->governor = new_gov; |
4024 | ret = cpufreq_init_governor(policy); |
4025 | if (!ret) { |
4026 | ret = cpufreq_start_governor(policy); |
4027 | diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c |
4028 | index ded427e0a488..e117b0059123 100644 |
4029 | --- a/drivers/cpufreq/freq_table.c |
4030 | +++ b/drivers/cpufreq/freq_table.c |
4031 | @@ -60,7 +60,7 @@ int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy, |
4032 | return 0; |
4033 | } |
4034 | |
4035 | -int cpufreq_frequency_table_verify(struct cpufreq_policy *policy, |
4036 | +int cpufreq_frequency_table_verify(struct cpufreq_policy_data *policy, |
4037 | struct cpufreq_frequency_table *table) |
4038 | { |
4039 | struct cpufreq_frequency_table *pos; |
4040 | @@ -100,7 +100,7 @@ EXPORT_SYMBOL_GPL(cpufreq_frequency_table_verify); |
4041 | * Generic routine to verify policy & frequency table, requires driver to set |
4042 | * policy->freq_table prior to it. |
4043 | */ |
4044 | -int cpufreq_generic_frequency_table_verify(struct cpufreq_policy *policy) |
4045 | +int cpufreq_generic_frequency_table_verify(struct cpufreq_policy_data *policy) |
4046 | { |
4047 | if (!policy->freq_table) |
4048 | return -ENODEV; |
4049 | diff --git a/drivers/cpufreq/gx-suspmod.c b/drivers/cpufreq/gx-suspmod.c |
4050 | index e97b5733aa24..75b3ef7ec679 100644 |
4051 | --- a/drivers/cpufreq/gx-suspmod.c |
4052 | +++ b/drivers/cpufreq/gx-suspmod.c |
4053 | @@ -328,7 +328,7 @@ static void gx_set_cpuspeed(struct cpufreq_policy *policy, unsigned int khz) |
4054 | * for the hardware supported by the driver. |
4055 | */ |
4056 | |
4057 | -static int cpufreq_gx_verify(struct cpufreq_policy *policy) |
4058 | +static int cpufreq_gx_verify(struct cpufreq_policy_data *policy) |
4059 | { |
4060 | unsigned int tmp_freq = 0; |
4061 | u8 tmp1, tmp2; |
4062 | diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c |
4063 | index 8ab31702cf6a..45499e0b9f2f 100644 |
4064 | --- a/drivers/cpufreq/intel_pstate.c |
4065 | +++ b/drivers/cpufreq/intel_pstate.c |
4066 | @@ -2036,8 +2036,9 @@ static int intel_pstate_get_max_freq(struct cpudata *cpu) |
4067 | cpu->pstate.max_freq : cpu->pstate.turbo_freq; |
4068 | } |
4069 | |
4070 | -static void intel_pstate_update_perf_limits(struct cpufreq_policy *policy, |
4071 | - struct cpudata *cpu) |
4072 | +static void intel_pstate_update_perf_limits(struct cpudata *cpu, |
4073 | + unsigned int policy_min, |
4074 | + unsigned int policy_max) |
4075 | { |
4076 | int max_freq = intel_pstate_get_max_freq(cpu); |
4077 | int32_t max_policy_perf, min_policy_perf; |
4078 | @@ -2056,18 +2057,17 @@ static void intel_pstate_update_perf_limits(struct cpufreq_policy *policy, |
4079 | turbo_max = cpu->pstate.turbo_pstate; |
4080 | } |
4081 | |
4082 | - max_policy_perf = max_state * policy->max / max_freq; |
4083 | - if (policy->max == policy->min) { |
4084 | + max_policy_perf = max_state * policy_max / max_freq; |
4085 | + if (policy_max == policy_min) { |
4086 | min_policy_perf = max_policy_perf; |
4087 | } else { |
4088 | - min_policy_perf = max_state * policy->min / max_freq; |
4089 | + min_policy_perf = max_state * policy_min / max_freq; |
4090 | min_policy_perf = clamp_t(int32_t, min_policy_perf, |
4091 | 0, max_policy_perf); |
4092 | } |
4093 | |
4094 | pr_debug("cpu:%d max_state %d min_policy_perf:%d max_policy_perf:%d\n", |
4095 | - policy->cpu, max_state, |
4096 | - min_policy_perf, max_policy_perf); |
4097 | + cpu->cpu, max_state, min_policy_perf, max_policy_perf); |
4098 | |
4099 | /* Normalize user input to [min_perf, max_perf] */ |
4100 | if (per_cpu_limits) { |
4101 | @@ -2081,7 +2081,7 @@ static void intel_pstate_update_perf_limits(struct cpufreq_policy *policy, |
4102 | global_min = DIV_ROUND_UP(turbo_max * global.min_perf_pct, 100); |
4103 | global_min = clamp_t(int32_t, global_min, 0, global_max); |
4104 | |
4105 | - pr_debug("cpu:%d global_min:%d global_max:%d\n", policy->cpu, |
4106 | + pr_debug("cpu:%d global_min:%d global_max:%d\n", cpu->cpu, |
4107 | global_min, global_max); |
4108 | |
4109 | cpu->min_perf_ratio = max(min_policy_perf, global_min); |
4110 | @@ -2094,7 +2094,7 @@ static void intel_pstate_update_perf_limits(struct cpufreq_policy *policy, |
4111 | cpu->max_perf_ratio); |
4112 | |
4113 | } |
4114 | - pr_debug("cpu:%d max_perf_ratio:%d min_perf_ratio:%d\n", policy->cpu, |
4115 | + pr_debug("cpu:%d max_perf_ratio:%d min_perf_ratio:%d\n", cpu->cpu, |
4116 | cpu->max_perf_ratio, |
4117 | cpu->min_perf_ratio); |
4118 | } |
4119 | @@ -2114,7 +2114,7 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy) |
4120 | |
4121 | mutex_lock(&intel_pstate_limits_lock); |
4122 | |
4123 | - intel_pstate_update_perf_limits(policy, cpu); |
4124 | + intel_pstate_update_perf_limits(cpu, policy->min, policy->max); |
4125 | |
4126 | if (cpu->policy == CPUFREQ_POLICY_PERFORMANCE) { |
4127 | /* |
4128 | @@ -2143,8 +2143,8 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy) |
4129 | return 0; |
4130 | } |
4131 | |
4132 | -static void intel_pstate_adjust_policy_max(struct cpufreq_policy *policy, |
4133 | - struct cpudata *cpu) |
4134 | +static void intel_pstate_adjust_policy_max(struct cpudata *cpu, |
4135 | + struct cpufreq_policy_data *policy) |
4136 | { |
4137 | if (!hwp_active && |
4138 | cpu->pstate.max_pstate_physical > cpu->pstate.max_pstate && |
4139 | @@ -2155,7 +2155,7 @@ static void intel_pstate_adjust_policy_max(struct cpufreq_policy *policy, |
4140 | } |
4141 | } |
4142 | |
4143 | -static int intel_pstate_verify_policy(struct cpufreq_policy *policy) |
4144 | +static int intel_pstate_verify_policy(struct cpufreq_policy_data *policy) |
4145 | { |
4146 | struct cpudata *cpu = all_cpu_data[policy->cpu]; |
4147 | |
4148 | @@ -2163,11 +2163,7 @@ static int intel_pstate_verify_policy(struct cpufreq_policy *policy) |
4149 | cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, |
4150 | intel_pstate_get_max_freq(cpu)); |
4151 | |
4152 | - if (policy->policy != CPUFREQ_POLICY_POWERSAVE && |
4153 | - policy->policy != CPUFREQ_POLICY_PERFORMANCE) |
4154 | - return -EINVAL; |
4155 | - |
4156 | - intel_pstate_adjust_policy_max(policy, cpu); |
4157 | + intel_pstate_adjust_policy_max(cpu, policy); |
4158 | |
4159 | return 0; |
4160 | } |
4161 | @@ -2268,7 +2264,7 @@ static struct cpufreq_driver intel_pstate = { |
4162 | .name = "intel_pstate", |
4163 | }; |
4164 | |
4165 | -static int intel_cpufreq_verify_policy(struct cpufreq_policy *policy) |
4166 | +static int intel_cpufreq_verify_policy(struct cpufreq_policy_data *policy) |
4167 | { |
4168 | struct cpudata *cpu = all_cpu_data[policy->cpu]; |
4169 | |
4170 | @@ -2276,9 +2272,9 @@ static int intel_cpufreq_verify_policy(struct cpufreq_policy *policy) |
4171 | cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, |
4172 | intel_pstate_get_max_freq(cpu)); |
4173 | |
4174 | - intel_pstate_adjust_policy_max(policy, cpu); |
4175 | + intel_pstate_adjust_policy_max(cpu, policy); |
4176 | |
4177 | - intel_pstate_update_perf_limits(policy, cpu); |
4178 | + intel_pstate_update_perf_limits(cpu, policy->min, policy->max); |
4179 | |
4180 | return 0; |
4181 | } |
4182 | diff --git a/drivers/cpufreq/longrun.c b/drivers/cpufreq/longrun.c |
4183 | index 64b8689f7a4a..0b08be8bff76 100644 |
4184 | --- a/drivers/cpufreq/longrun.c |
4185 | +++ b/drivers/cpufreq/longrun.c |
4186 | @@ -122,7 +122,7 @@ static int longrun_set_policy(struct cpufreq_policy *policy) |
4187 | * Validates a new CPUFreq policy. This function has to be called with |
4188 | * cpufreq_driver locked. |
4189 | */ |
4190 | -static int longrun_verify_policy(struct cpufreq_policy *policy) |
4191 | +static int longrun_verify_policy(struct cpufreq_policy_data *policy) |
4192 | { |
4193 | if (!policy) |
4194 | return -EINVAL; |
4195 | @@ -130,10 +130,6 @@ static int longrun_verify_policy(struct cpufreq_policy *policy) |
4196 | policy->cpu = 0; |
4197 | cpufreq_verify_within_cpu_limits(policy); |
4198 | |
4199 | - if ((policy->policy != CPUFREQ_POLICY_POWERSAVE) && |
4200 | - (policy->policy != CPUFREQ_POLICY_PERFORMANCE)) |
4201 | - return -EINVAL; |
4202 | - |
4203 | return 0; |
4204 | } |
4205 | |
4206 | diff --git a/drivers/cpufreq/pcc-cpufreq.c b/drivers/cpufreq/pcc-cpufreq.c |
4207 | index fdc767fdbe6a..f90273006553 100644 |
4208 | --- a/drivers/cpufreq/pcc-cpufreq.c |
4209 | +++ b/drivers/cpufreq/pcc-cpufreq.c |
4210 | @@ -109,7 +109,7 @@ struct pcc_cpu { |
4211 | |
4212 | static struct pcc_cpu __percpu *pcc_cpu_info; |
4213 | |
4214 | -static int pcc_cpufreq_verify(struct cpufreq_policy *policy) |
4215 | +static int pcc_cpufreq_verify(struct cpufreq_policy_data *policy) |
4216 | { |
4217 | cpufreq_verify_within_cpu_limits(policy); |
4218 | return 0; |
4219 | diff --git a/drivers/cpufreq/sh-cpufreq.c b/drivers/cpufreq/sh-cpufreq.c |
4220 | index 5096c0ab781b..0ac265d47ef0 100644 |
4221 | --- a/drivers/cpufreq/sh-cpufreq.c |
4222 | +++ b/drivers/cpufreq/sh-cpufreq.c |
4223 | @@ -87,7 +87,7 @@ static int sh_cpufreq_target(struct cpufreq_policy *policy, |
4224 | return work_on_cpu(policy->cpu, __sh_cpufreq_target, &data); |
4225 | } |
4226 | |
4227 | -static int sh_cpufreq_verify(struct cpufreq_policy *policy) |
4228 | +static int sh_cpufreq_verify(struct cpufreq_policy_data *policy) |
4229 | { |
4230 | struct clk *cpuclk = &per_cpu(sh_cpuclk, policy->cpu); |
4231 | struct cpufreq_frequency_table *freq_table; |
4232 | diff --git a/drivers/cpufreq/unicore2-cpufreq.c b/drivers/cpufreq/unicore2-cpufreq.c |
4233 | index 707dbc1b7ac8..98d392196df2 100644 |
4234 | --- a/drivers/cpufreq/unicore2-cpufreq.c |
4235 | +++ b/drivers/cpufreq/unicore2-cpufreq.c |
4236 | @@ -22,7 +22,7 @@ static struct cpufreq_driver ucv2_driver; |
4237 | /* make sure that only the "userspace" governor is run |
4238 | * -- anything else wouldn't make sense on this platform, anyway. |
4239 | */ |
4240 | -static int ucv2_verify_speed(struct cpufreq_policy *policy) |
4241 | +static int ucv2_verify_speed(struct cpufreq_policy_data *policy) |
4242 | { |
4243 | if (policy->cpu) |
4244 | return -EINVAL; |
4245 | diff --git a/drivers/crypto/atmel-aes.c b/drivers/crypto/atmel-aes.c |
4246 | index db99cee1991c..89f79d763ab8 100644 |
4247 | --- a/drivers/crypto/atmel-aes.c |
4248 | +++ b/drivers/crypto/atmel-aes.c |
4249 | @@ -88,7 +88,6 @@ |
4250 | struct atmel_aes_caps { |
4251 | bool has_dualbuff; |
4252 | bool has_cfb64; |
4253 | - bool has_ctr32; |
4254 | bool has_gcm; |
4255 | bool has_xts; |
4256 | bool has_authenc; |
4257 | @@ -1013,8 +1012,9 @@ static int atmel_aes_ctr_transfer(struct atmel_aes_dev *dd) |
4258 | struct atmel_aes_ctr_ctx *ctx = atmel_aes_ctr_ctx_cast(dd->ctx); |
4259 | struct ablkcipher_request *req = ablkcipher_request_cast(dd->areq); |
4260 | struct scatterlist *src, *dst; |
4261 | - u32 ctr, blocks; |
4262 | size_t datalen; |
4263 | + u32 ctr; |
4264 | + u16 blocks, start, end; |
4265 | bool use_dma, fragmented = false; |
4266 | |
4267 | /* Check for transfer completion. */ |
4268 | @@ -1026,27 +1026,17 @@ static int atmel_aes_ctr_transfer(struct atmel_aes_dev *dd) |
4269 | datalen = req->nbytes - ctx->offset; |
4270 | blocks = DIV_ROUND_UP(datalen, AES_BLOCK_SIZE); |
4271 | ctr = be32_to_cpu(ctx->iv[3]); |
4272 | - if (dd->caps.has_ctr32) { |
4273 | - /* Check 32bit counter overflow. */ |
4274 | - u32 start = ctr; |
4275 | - u32 end = start + blocks - 1; |
4276 | - |
4277 | - if (end < start) { |
4278 | - ctr |= 0xffffffff; |
4279 | - datalen = AES_BLOCK_SIZE * -start; |
4280 | - fragmented = true; |
4281 | - } |
4282 | - } else { |
4283 | - /* Check 16bit counter overflow. */ |
4284 | - u16 start = ctr & 0xffff; |
4285 | - u16 end = start + (u16)blocks - 1; |
4286 | - |
4287 | - if (blocks >> 16 || end < start) { |
4288 | - ctr |= 0xffff; |
4289 | - datalen = AES_BLOCK_SIZE * (0x10000-start); |
4290 | - fragmented = true; |
4291 | - } |
4292 | + |
4293 | + /* Check 16bit counter overflow. */ |
4294 | + start = ctr & 0xffff; |
4295 | + end = start + blocks - 1; |
4296 | + |
4297 | + if (blocks >> 16 || end < start) { |
4298 | + ctr |= 0xffff; |
4299 | + datalen = AES_BLOCK_SIZE * (0x10000 - start); |
4300 | + fragmented = true; |
4301 | } |
4302 | + |
4303 | use_dma = (datalen >= ATMEL_AES_DMA_THRESHOLD); |
4304 | |
4305 | /* Jump to offset. */ |
4306 | @@ -2550,7 +2540,6 @@ static void atmel_aes_get_cap(struct atmel_aes_dev *dd) |
4307 | { |
4308 | dd->caps.has_dualbuff = 0; |
4309 | dd->caps.has_cfb64 = 0; |
4310 | - dd->caps.has_ctr32 = 0; |
4311 | dd->caps.has_gcm = 0; |
4312 | dd->caps.has_xts = 0; |
4313 | dd->caps.has_authenc = 0; |
4314 | @@ -2561,7 +2550,6 @@ static void atmel_aes_get_cap(struct atmel_aes_dev *dd) |
4315 | case 0x500: |
4316 | dd->caps.has_dualbuff = 1; |
4317 | dd->caps.has_cfb64 = 1; |
4318 | - dd->caps.has_ctr32 = 1; |
4319 | dd->caps.has_gcm = 1; |
4320 | dd->caps.has_xts = 1; |
4321 | dd->caps.has_authenc = 1; |
4322 | @@ -2570,7 +2558,6 @@ static void atmel_aes_get_cap(struct atmel_aes_dev *dd) |
4323 | case 0x200: |
4324 | dd->caps.has_dualbuff = 1; |
4325 | dd->caps.has_cfb64 = 1; |
4326 | - dd->caps.has_ctr32 = 1; |
4327 | dd->caps.has_gcm = 1; |
4328 | dd->caps.max_burst_size = 4; |
4329 | break; |
4330 | diff --git a/drivers/crypto/ccp/ccp-dev-v3.c b/drivers/crypto/ccp/ccp-dev-v3.c |
4331 | index 0186b3df4c87..0d5576f6ad21 100644 |
4332 | --- a/drivers/crypto/ccp/ccp-dev-v3.c |
4333 | +++ b/drivers/crypto/ccp/ccp-dev-v3.c |
4334 | @@ -586,6 +586,7 @@ const struct ccp_vdata ccpv3_platform = { |
4335 | .setup = NULL, |
4336 | .perform = &ccp3_actions, |
4337 | .offset = 0, |
4338 | + .rsamax = CCP_RSA_MAX_WIDTH, |
4339 | }; |
4340 | |
4341 | const struct ccp_vdata ccpv3 = { |
4342 | diff --git a/drivers/crypto/ccree/cc_aead.c b/drivers/crypto/ccree/cc_aead.c |
4343 | index d3e8faa03f15..3d7c8d9e54b9 100644 |
4344 | --- a/drivers/crypto/ccree/cc_aead.c |
4345 | +++ b/drivers/crypto/ccree/cc_aead.c |
4346 | @@ -237,7 +237,7 @@ static void cc_aead_complete(struct device *dev, void *cc_req, int err) |
4347 | * revealed the decrypted message --> zero its memory. |
4348 | */ |
4349 | sg_zero_buffer(areq->dst, sg_nents(areq->dst), |
4350 | - areq->cryptlen, 0); |
4351 | + areq->cryptlen, areq->assoclen); |
4352 | err = -EBADMSG; |
4353 | } |
4354 | /*ENCRYPT*/ |
4355 | diff --git a/drivers/crypto/ccree/cc_cipher.c b/drivers/crypto/ccree/cc_cipher.c |
4356 | index 254b48797799..cd9c60268bf8 100644 |
4357 | --- a/drivers/crypto/ccree/cc_cipher.c |
4358 | +++ b/drivers/crypto/ccree/cc_cipher.c |
4359 | @@ -523,6 +523,7 @@ static void cc_setup_readiv_desc(struct crypto_tfm *tfm, |
4360 | } |
4361 | } |
4362 | |
4363 | + |
4364 | static void cc_setup_state_desc(struct crypto_tfm *tfm, |
4365 | struct cipher_req_ctx *req_ctx, |
4366 | unsigned int ivsize, unsigned int nbytes, |
4367 | @@ -534,8 +535,6 @@ static void cc_setup_state_desc(struct crypto_tfm *tfm, |
4368 | int cipher_mode = ctx_p->cipher_mode; |
4369 | int flow_mode = ctx_p->flow_mode; |
4370 | int direction = req_ctx->gen_ctx.op_type; |
4371 | - dma_addr_t key_dma_addr = ctx_p->user.key_dma_addr; |
4372 | - unsigned int key_len = ctx_p->keylen; |
4373 | dma_addr_t iv_dma_addr = req_ctx->gen_ctx.iv_dma_addr; |
4374 | unsigned int du_size = nbytes; |
4375 | |
4376 | @@ -570,6 +569,47 @@ static void cc_setup_state_desc(struct crypto_tfm *tfm, |
4377 | break; |
4378 | case DRV_CIPHER_XTS: |
4379 | case DRV_CIPHER_ESSIV: |
4380 | + case DRV_CIPHER_BITLOCKER: |
4381 | + break; |
4382 | + default: |
4383 | + dev_err(dev, "Unsupported cipher mode (%d)\n", cipher_mode); |
4384 | + } |
4385 | +} |
4386 | + |
4387 | + |
4388 | +static void cc_setup_xex_state_desc(struct crypto_tfm *tfm, |
4389 | + struct cipher_req_ctx *req_ctx, |
4390 | + unsigned int ivsize, unsigned int nbytes, |
4391 | + struct cc_hw_desc desc[], |
4392 | + unsigned int *seq_size) |
4393 | +{ |
4394 | + struct cc_cipher_ctx *ctx_p = crypto_tfm_ctx(tfm); |
4395 | + struct device *dev = drvdata_to_dev(ctx_p->drvdata); |
4396 | + int cipher_mode = ctx_p->cipher_mode; |
4397 | + int flow_mode = ctx_p->flow_mode; |
4398 | + int direction = req_ctx->gen_ctx.op_type; |
4399 | + dma_addr_t key_dma_addr = ctx_p->user.key_dma_addr; |
4400 | + unsigned int key_len = ctx_p->keylen; |
4401 | + dma_addr_t iv_dma_addr = req_ctx->gen_ctx.iv_dma_addr; |
4402 | + unsigned int du_size = nbytes; |
4403 | + |
4404 | + struct cc_crypto_alg *cc_alg = |
4405 | + container_of(tfm->__crt_alg, struct cc_crypto_alg, |
4406 | + skcipher_alg.base); |
4407 | + |
4408 | + if (cc_alg->data_unit) |
4409 | + du_size = cc_alg->data_unit; |
4410 | + |
4411 | + switch (cipher_mode) { |
4412 | + case DRV_CIPHER_ECB: |
4413 | + break; |
4414 | + case DRV_CIPHER_CBC: |
4415 | + case DRV_CIPHER_CBC_CTS: |
4416 | + case DRV_CIPHER_CTR: |
4417 | + case DRV_CIPHER_OFB: |
4418 | + break; |
4419 | + case DRV_CIPHER_XTS: |
4420 | + case DRV_CIPHER_ESSIV: |
4421 | case DRV_CIPHER_BITLOCKER: |
4422 | /* load XEX key */ |
4423 | hw_desc_init(&desc[*seq_size]); |
4424 | @@ -881,12 +921,14 @@ static int cc_cipher_process(struct skcipher_request *req, |
4425 | |
4426 | /* STAT_PHASE_2: Create sequence */ |
4427 | |
4428 | - /* Setup IV and XEX key used */ |
4429 | + /* Setup state (IV) */ |
4430 | cc_setup_state_desc(tfm, req_ctx, ivsize, nbytes, desc, &seq_len); |
4431 | /* Setup MLLI line, if needed */ |
4432 | cc_setup_mlli_desc(tfm, req_ctx, dst, src, nbytes, req, desc, &seq_len); |
4433 | /* Setup key */ |
4434 | cc_setup_key_desc(tfm, req_ctx, nbytes, desc, &seq_len); |
4435 | + /* Setup state (IV and XEX key) */ |
4436 | + cc_setup_xex_state_desc(tfm, req_ctx, ivsize, nbytes, desc, &seq_len); |
4437 | /* Data processing */ |
4438 | cc_setup_flow_desc(tfm, req_ctx, dst, src, nbytes, desc, &seq_len); |
4439 | /* Read next IV */ |
4440 | diff --git a/drivers/crypto/ccree/cc_driver.h b/drivers/crypto/ccree/cc_driver.h |
4441 | index ab31d4a68c80..7d2f7e2c0bb5 100644 |
4442 | --- a/drivers/crypto/ccree/cc_driver.h |
4443 | +++ b/drivers/crypto/ccree/cc_driver.h |
4444 | @@ -161,6 +161,7 @@ struct cc_drvdata { |
4445 | int std_bodies; |
4446 | bool sec_disabled; |
4447 | u32 comp_mask; |
4448 | + bool pm_on; |
4449 | }; |
4450 | |
4451 | struct cc_crypto_alg { |
4452 | diff --git a/drivers/crypto/ccree/cc_pm.c b/drivers/crypto/ccree/cc_pm.c |
4453 | index dbc508fb719b..452bd77a9ba0 100644 |
4454 | --- a/drivers/crypto/ccree/cc_pm.c |
4455 | +++ b/drivers/crypto/ccree/cc_pm.c |
4456 | @@ -22,14 +22,8 @@ const struct dev_pm_ops ccree_pm = { |
4457 | int cc_pm_suspend(struct device *dev) |
4458 | { |
4459 | struct cc_drvdata *drvdata = dev_get_drvdata(dev); |
4460 | - int rc; |
4461 | |
4462 | dev_dbg(dev, "set HOST_POWER_DOWN_EN\n"); |
4463 | - rc = cc_suspend_req_queue(drvdata); |
4464 | - if (rc) { |
4465 | - dev_err(dev, "cc_suspend_req_queue (%x)\n", rc); |
4466 | - return rc; |
4467 | - } |
4468 | fini_cc_regs(drvdata); |
4469 | cc_iowrite(drvdata, CC_REG(HOST_POWER_DOWN_EN), POWER_DOWN_ENABLE); |
4470 | cc_clk_off(drvdata); |
4471 | @@ -63,13 +57,6 @@ int cc_pm_resume(struct device *dev) |
4472 | /* check if tee fips error occurred during power down */ |
4473 | cc_tee_handle_fips_error(drvdata); |
4474 | |
4475 | - rc = cc_resume_req_queue(drvdata); |
4476 | - if (rc) { |
4477 | - dev_err(dev, "cc_resume_req_queue (%x)\n", rc); |
4478 | - return rc; |
4479 | - } |
4480 | - |
4481 | - /* must be after the queue resuming as it uses the HW queue*/ |
4482 | cc_init_hash_sram(drvdata); |
4483 | |
4484 | return 0; |
4485 | @@ -80,12 +67,10 @@ int cc_pm_get(struct device *dev) |
4486 | int rc = 0; |
4487 | struct cc_drvdata *drvdata = dev_get_drvdata(dev); |
4488 | |
4489 | - if (cc_req_queue_suspended(drvdata)) |
4490 | + if (drvdata->pm_on) |
4491 | rc = pm_runtime_get_sync(dev); |
4492 | - else |
4493 | - pm_runtime_get_noresume(dev); |
4494 | |
4495 | - return rc; |
4496 | + return (rc == 1 ? 0 : rc); |
4497 | } |
4498 | |
4499 | int cc_pm_put_suspend(struct device *dev) |
4500 | @@ -93,14 +78,11 @@ int cc_pm_put_suspend(struct device *dev) |
4501 | int rc = 0; |
4502 | struct cc_drvdata *drvdata = dev_get_drvdata(dev); |
4503 | |
4504 | - if (!cc_req_queue_suspended(drvdata)) { |
4505 | + if (drvdata->pm_on) { |
4506 | pm_runtime_mark_last_busy(dev); |
4507 | rc = pm_runtime_put_autosuspend(dev); |
4508 | - } else { |
4509 | - /* Something wrong happens*/ |
4510 | - dev_err(dev, "request to suspend already suspended queue"); |
4511 | - rc = -EBUSY; |
4512 | } |
4513 | + |
4514 | return rc; |
4515 | } |
4516 | |
4517 | @@ -117,7 +99,7 @@ int cc_pm_init(struct cc_drvdata *drvdata) |
4518 | /* must be before the enabling to avoid resdundent suspending */ |
4519 | pm_runtime_set_autosuspend_delay(dev, CC_SUSPEND_TIMEOUT); |
4520 | pm_runtime_use_autosuspend(dev); |
4521 | - /* activate the PM module */ |
4522 | + /* set us as active - note we won't do PM ops until cc_pm_go()! */ |
4523 | return pm_runtime_set_active(dev); |
4524 | } |
4525 | |
4526 | @@ -125,9 +107,11 @@ int cc_pm_init(struct cc_drvdata *drvdata) |
4527 | void cc_pm_go(struct cc_drvdata *drvdata) |
4528 | { |
4529 | pm_runtime_enable(drvdata_to_dev(drvdata)); |
4530 | + drvdata->pm_on = true; |
4531 | } |
4532 | |
4533 | void cc_pm_fini(struct cc_drvdata *drvdata) |
4534 | { |
4535 | pm_runtime_disable(drvdata_to_dev(drvdata)); |
4536 | + drvdata->pm_on = false; |
4537 | } |
4538 | diff --git a/drivers/crypto/ccree/cc_request_mgr.c b/drivers/crypto/ccree/cc_request_mgr.c |
4539 | index a947d5a2cf35..37e6fee37b13 100644 |
4540 | --- a/drivers/crypto/ccree/cc_request_mgr.c |
4541 | +++ b/drivers/crypto/ccree/cc_request_mgr.c |
4542 | @@ -41,7 +41,6 @@ struct cc_req_mgr_handle { |
4543 | #else |
4544 | struct tasklet_struct comptask; |
4545 | #endif |
4546 | - bool is_runtime_suspended; |
4547 | }; |
4548 | |
4549 | struct cc_bl_item { |
4550 | @@ -404,6 +403,7 @@ static void cc_proc_backlog(struct cc_drvdata *drvdata) |
4551 | spin_lock(&mgr->bl_lock); |
4552 | list_del(&bli->list); |
4553 | --mgr->bl_len; |
4554 | + kfree(bli); |
4555 | } |
4556 | |
4557 | spin_unlock(&mgr->bl_lock); |
4558 | @@ -677,52 +677,3 @@ static void comp_handler(unsigned long devarg) |
4559 | cc_proc_backlog(drvdata); |
4560 | dev_dbg(dev, "Comp. handler done.\n"); |
4561 | } |
4562 | - |
4563 | -/* |
4564 | - * resume the queue configuration - no need to take the lock as this happens |
4565 | - * inside the spin lock protection |
4566 | - */ |
4567 | -#if defined(CONFIG_PM) |
4568 | -int cc_resume_req_queue(struct cc_drvdata *drvdata) |
4569 | -{ |
4570 | - struct cc_req_mgr_handle *request_mgr_handle = |
4571 | - drvdata->request_mgr_handle; |
4572 | - |
4573 | - spin_lock_bh(&request_mgr_handle->hw_lock); |
4574 | - request_mgr_handle->is_runtime_suspended = false; |
4575 | - spin_unlock_bh(&request_mgr_handle->hw_lock); |
4576 | - |
4577 | - return 0; |
4578 | -} |
4579 | - |
4580 | -/* |
4581 | - * suspend the queue configuration. Since it is used for the runtime suspend |
4582 | - * only verify that the queue can be suspended. |
4583 | - */ |
4584 | -int cc_suspend_req_queue(struct cc_drvdata *drvdata) |
4585 | -{ |
4586 | - struct cc_req_mgr_handle *request_mgr_handle = |
4587 | - drvdata->request_mgr_handle; |
4588 | - |
4589 | - /* lock the send_request */ |
4590 | - spin_lock_bh(&request_mgr_handle->hw_lock); |
4591 | - if (request_mgr_handle->req_queue_head != |
4592 | - request_mgr_handle->req_queue_tail) { |
4593 | - spin_unlock_bh(&request_mgr_handle->hw_lock); |
4594 | - return -EBUSY; |
4595 | - } |
4596 | - request_mgr_handle->is_runtime_suspended = true; |
4597 | - spin_unlock_bh(&request_mgr_handle->hw_lock); |
4598 | - |
4599 | - return 0; |
4600 | -} |
4601 | - |
4602 | -bool cc_req_queue_suspended(struct cc_drvdata *drvdata) |
4603 | -{ |
4604 | - struct cc_req_mgr_handle *request_mgr_handle = |
4605 | - drvdata->request_mgr_handle; |
4606 | - |
4607 | - return request_mgr_handle->is_runtime_suspended; |
4608 | -} |
4609 | - |
4610 | -#endif |
4611 | diff --git a/drivers/crypto/ccree/cc_request_mgr.h b/drivers/crypto/ccree/cc_request_mgr.h |
4612 | index f46cf766fe4d..ff7746aaaf35 100644 |
4613 | --- a/drivers/crypto/ccree/cc_request_mgr.h |
4614 | +++ b/drivers/crypto/ccree/cc_request_mgr.h |
4615 | @@ -40,12 +40,4 @@ void complete_request(struct cc_drvdata *drvdata); |
4616 | |
4617 | void cc_req_mgr_fini(struct cc_drvdata *drvdata); |
4618 | |
4619 | -#if defined(CONFIG_PM) |
4620 | -int cc_resume_req_queue(struct cc_drvdata *drvdata); |
4621 | - |
4622 | -int cc_suspend_req_queue(struct cc_drvdata *drvdata); |
4623 | - |
4624 | -bool cc_req_queue_suspended(struct cc_drvdata *drvdata); |
4625 | -#endif |
4626 | - |
4627 | #endif /*__REQUEST_MGR_H__*/ |
4628 | diff --git a/drivers/crypto/hisilicon/Kconfig b/drivers/crypto/hisilicon/Kconfig |
4629 | index 504daff7687d..f7f0a1fb6895 100644 |
4630 | --- a/drivers/crypto/hisilicon/Kconfig |
4631 | +++ b/drivers/crypto/hisilicon/Kconfig |
4632 | @@ -35,6 +35,5 @@ config CRYPTO_DEV_HISI_ZIP |
4633 | depends on ARM64 && PCI && PCI_MSI |
4634 | select CRYPTO_DEV_HISI_QM |
4635 | select CRYPTO_HISI_SGL |
4636 | - select SG_SPLIT |
4637 | help |
4638 | Support for HiSilicon ZIP Driver |
4639 | diff --git a/drivers/crypto/hisilicon/zip/zip.h b/drivers/crypto/hisilicon/zip/zip.h |
4640 | index ffb00d987d02..99f21d848d4f 100644 |
4641 | --- a/drivers/crypto/hisilicon/zip/zip.h |
4642 | +++ b/drivers/crypto/hisilicon/zip/zip.h |
4643 | @@ -12,6 +12,10 @@ |
4644 | |
4645 | /* hisi_zip_sqe dw3 */ |
4646 | #define HZIP_BD_STATUS_M GENMASK(7, 0) |
4647 | +/* hisi_zip_sqe dw7 */ |
4648 | +#define HZIP_IN_SGE_DATA_OFFSET_M GENMASK(23, 0) |
4649 | +/* hisi_zip_sqe dw8 */ |
4650 | +#define HZIP_OUT_SGE_DATA_OFFSET_M GENMASK(23, 0) |
4651 | /* hisi_zip_sqe dw9 */ |
4652 | #define HZIP_REQ_TYPE_M GENMASK(7, 0) |
4653 | #define HZIP_ALG_TYPE_ZLIB 0x02 |
4654 | diff --git a/drivers/crypto/hisilicon/zip/zip_crypto.c b/drivers/crypto/hisilicon/zip/zip_crypto.c |
4655 | index 59023545a1c4..cf34bfdfb3e6 100644 |
4656 | --- a/drivers/crypto/hisilicon/zip/zip_crypto.c |
4657 | +++ b/drivers/crypto/hisilicon/zip/zip_crypto.c |
4658 | @@ -45,10 +45,8 @@ enum hisi_zip_alg_type { |
4659 | |
4660 | struct hisi_zip_req { |
4661 | struct acomp_req *req; |
4662 | - struct scatterlist *src; |
4663 | - struct scatterlist *dst; |
4664 | - size_t slen; |
4665 | - size_t dlen; |
4666 | + int sskip; |
4667 | + int dskip; |
4668 | struct hisi_acc_hw_sgl *hw_src; |
4669 | struct hisi_acc_hw_sgl *hw_dst; |
4670 | dma_addr_t dma_src; |
4671 | @@ -94,13 +92,15 @@ static void hisi_zip_config_tag(struct hisi_zip_sqe *sqe, u32 tag) |
4672 | |
4673 | static void hisi_zip_fill_sqe(struct hisi_zip_sqe *sqe, u8 req_type, |
4674 | dma_addr_t s_addr, dma_addr_t d_addr, u32 slen, |
4675 | - u32 dlen) |
4676 | + u32 dlen, int sskip, int dskip) |
4677 | { |
4678 | memset(sqe, 0, sizeof(struct hisi_zip_sqe)); |
4679 | |
4680 | - sqe->input_data_length = slen; |
4681 | + sqe->input_data_length = slen - sskip; |
4682 | + sqe->dw7 = FIELD_PREP(HZIP_IN_SGE_DATA_OFFSET_M, sskip); |
4683 | + sqe->dw8 = FIELD_PREP(HZIP_OUT_SGE_DATA_OFFSET_M, dskip); |
4684 | sqe->dw9 = FIELD_PREP(HZIP_REQ_TYPE_M, req_type); |
4685 | - sqe->dest_avail_out = dlen; |
4686 | + sqe->dest_avail_out = dlen - dskip; |
4687 | sqe->source_addr_l = lower_32_bits(s_addr); |
4688 | sqe->source_addr_h = upper_32_bits(s_addr); |
4689 | sqe->dest_addr_l = lower_32_bits(d_addr); |
4690 | @@ -301,11 +301,6 @@ static void hisi_zip_remove_req(struct hisi_zip_qp_ctx *qp_ctx, |
4691 | { |
4692 | struct hisi_zip_req_q *req_q = &qp_ctx->req_q; |
4693 | |
4694 | - if (qp_ctx->qp->alg_type == HZIP_ALG_TYPE_COMP) |
4695 | - kfree(req->dst); |
4696 | - else |
4697 | - kfree(req->src); |
4698 | - |
4699 | write_lock(&req_q->req_lock); |
4700 | clear_bit(req->req_id, req_q->req_bitmap); |
4701 | memset(req, 0, sizeof(struct hisi_zip_req)); |
4702 | @@ -333,8 +328,8 @@ static void hisi_zip_acomp_cb(struct hisi_qp *qp, void *data) |
4703 | } |
4704 | dlen = sqe->produced; |
4705 | |
4706 | - hisi_acc_sg_buf_unmap(dev, req->src, req->hw_src); |
4707 | - hisi_acc_sg_buf_unmap(dev, req->dst, req->hw_dst); |
4708 | + hisi_acc_sg_buf_unmap(dev, acomp_req->src, req->hw_src); |
4709 | + hisi_acc_sg_buf_unmap(dev, acomp_req->dst, req->hw_dst); |
4710 | |
4711 | head_size = (qp->alg_type == 0) ? TO_HEAD_SIZE(qp->req_type) : 0; |
4712 | acomp_req->dlen = dlen + head_size; |
4713 | @@ -428,20 +423,6 @@ static size_t get_comp_head_size(struct scatterlist *src, u8 req_type) |
4714 | } |
4715 | } |
4716 | |
4717 | -static int get_sg_skip_bytes(struct scatterlist *sgl, size_t bytes, |
4718 | - size_t remains, struct scatterlist **out) |
4719 | -{ |
4720 | -#define SPLIT_NUM 2 |
4721 | - size_t split_sizes[SPLIT_NUM]; |
4722 | - int out_mapped_nents[SPLIT_NUM]; |
4723 | - |
4724 | - split_sizes[0] = bytes; |
4725 | - split_sizes[1] = remains; |
4726 | - |
4727 | - return sg_split(sgl, 0, 0, SPLIT_NUM, split_sizes, out, |
4728 | - out_mapped_nents, GFP_KERNEL); |
4729 | -} |
4730 | - |
4731 | static struct hisi_zip_req *hisi_zip_create_req(struct acomp_req *req, |
4732 | struct hisi_zip_qp_ctx *qp_ctx, |
4733 | size_t head_size, bool is_comp) |
4734 | @@ -449,31 +430,7 @@ static struct hisi_zip_req *hisi_zip_create_req(struct acomp_req *req, |
4735 | struct hisi_zip_req_q *req_q = &qp_ctx->req_q; |
4736 | struct hisi_zip_req *q = req_q->q; |
4737 | struct hisi_zip_req *req_cache; |
4738 | - struct scatterlist *out[2]; |
4739 | - struct scatterlist *sgl; |
4740 | - size_t len; |
4741 | - int ret, req_id; |
4742 | - |
4743 | - /* |
4744 | - * remove/add zlib/gzip head, as hardware operations do not include |
4745 | - * comp head. so split req->src to get sgl without heads in acomp, or |
4746 | - * add comp head to req->dst ahead of that hardware output compressed |
4747 | - * data in sgl splited from req->dst without comp head. |
4748 | - */ |
4749 | - if (is_comp) { |
4750 | - sgl = req->dst; |
4751 | - len = req->dlen - head_size; |
4752 | - } else { |
4753 | - sgl = req->src; |
4754 | - len = req->slen - head_size; |
4755 | - } |
4756 | - |
4757 | - ret = get_sg_skip_bytes(sgl, head_size, len, out); |
4758 | - if (ret) |
4759 | - return ERR_PTR(ret); |
4760 | - |
4761 | - /* sgl for comp head is useless, so free it now */ |
4762 | - kfree(out[0]); |
4763 | + int req_id; |
4764 | |
4765 | write_lock(&req_q->req_lock); |
4766 | |
4767 | @@ -481,7 +438,6 @@ static struct hisi_zip_req *hisi_zip_create_req(struct acomp_req *req, |
4768 | if (req_id >= req_q->size) { |
4769 | write_unlock(&req_q->req_lock); |
4770 | dev_dbg(&qp_ctx->qp->qm->pdev->dev, "req cache is full!\n"); |
4771 | - kfree(out[1]); |
4772 | return ERR_PTR(-EBUSY); |
4773 | } |
4774 | set_bit(req_id, req_q->req_bitmap); |
4775 | @@ -489,16 +445,13 @@ static struct hisi_zip_req *hisi_zip_create_req(struct acomp_req *req, |
4776 | req_cache = q + req_id; |
4777 | req_cache->req_id = req_id; |
4778 | req_cache->req = req; |
4779 | + |
4780 | if (is_comp) { |
4781 | - req_cache->src = req->src; |
4782 | - req_cache->dst = out[1]; |
4783 | - req_cache->slen = req->slen; |
4784 | - req_cache->dlen = req->dlen - head_size; |
4785 | + req_cache->sskip = 0; |
4786 | + req_cache->dskip = head_size; |
4787 | } else { |
4788 | - req_cache->src = out[1]; |
4789 | - req_cache->dst = req->dst; |
4790 | - req_cache->slen = req->slen - head_size; |
4791 | - req_cache->dlen = req->dlen; |
4792 | + req_cache->sskip = head_size; |
4793 | + req_cache->dskip = 0; |
4794 | } |
4795 | |
4796 | write_unlock(&req_q->req_lock); |
4797 | @@ -510,6 +463,7 @@ static int hisi_zip_do_work(struct hisi_zip_req *req, |
4798 | struct hisi_zip_qp_ctx *qp_ctx) |
4799 | { |
4800 | struct hisi_zip_sqe *zip_sqe = &qp_ctx->zip_sqe; |
4801 | + struct acomp_req *a_req = req->req; |
4802 | struct hisi_qp *qp = qp_ctx->qp; |
4803 | struct device *dev = &qp->qm->pdev->dev; |
4804 | struct hisi_acc_sgl_pool *pool = &qp_ctx->sgl_pool; |
4805 | @@ -517,16 +471,16 @@ static int hisi_zip_do_work(struct hisi_zip_req *req, |
4806 | dma_addr_t output; |
4807 | int ret; |
4808 | |
4809 | - if (!req->src || !req->slen || !req->dst || !req->dlen) |
4810 | + if (!a_req->src || !a_req->slen || !a_req->dst || !a_req->dlen) |
4811 | return -EINVAL; |
4812 | |
4813 | - req->hw_src = hisi_acc_sg_buf_map_to_hw_sgl(dev, req->src, pool, |
4814 | + req->hw_src = hisi_acc_sg_buf_map_to_hw_sgl(dev, a_req->src, pool, |
4815 | req->req_id << 1, &input); |
4816 | if (IS_ERR(req->hw_src)) |
4817 | return PTR_ERR(req->hw_src); |
4818 | req->dma_src = input; |
4819 | |
4820 | - req->hw_dst = hisi_acc_sg_buf_map_to_hw_sgl(dev, req->dst, pool, |
4821 | + req->hw_dst = hisi_acc_sg_buf_map_to_hw_sgl(dev, a_req->dst, pool, |
4822 | (req->req_id << 1) + 1, |
4823 | &output); |
4824 | if (IS_ERR(req->hw_dst)) { |
4825 | @@ -535,8 +489,8 @@ static int hisi_zip_do_work(struct hisi_zip_req *req, |
4826 | } |
4827 | req->dma_dst = output; |
4828 | |
4829 | - hisi_zip_fill_sqe(zip_sqe, qp->req_type, input, output, req->slen, |
4830 | - req->dlen); |
4831 | + hisi_zip_fill_sqe(zip_sqe, qp->req_type, input, output, a_req->slen, |
4832 | + a_req->dlen, req->sskip, req->dskip); |
4833 | hisi_zip_config_buf_type(zip_sqe, HZIP_SGL); |
4834 | hisi_zip_config_tag(zip_sqe, req->req_id); |
4835 | |
4836 | @@ -548,9 +502,9 @@ static int hisi_zip_do_work(struct hisi_zip_req *req, |
4837 | return -EINPROGRESS; |
4838 | |
4839 | err_unmap_output: |
4840 | - hisi_acc_sg_buf_unmap(dev, req->dst, req->hw_dst); |
4841 | + hisi_acc_sg_buf_unmap(dev, a_req->dst, req->hw_dst); |
4842 | err_unmap_input: |
4843 | - hisi_acc_sg_buf_unmap(dev, req->src, req->hw_src); |
4844 | + hisi_acc_sg_buf_unmap(dev, a_req->src, req->hw_src); |
4845 | return ret; |
4846 | } |
4847 | |
4848 | diff --git a/drivers/crypto/picoxcell_crypto.c b/drivers/crypto/picoxcell_crypto.c |
4849 | index 3cbefb41b099..2680e1525db5 100644 |
4850 | --- a/drivers/crypto/picoxcell_crypto.c |
4851 | +++ b/drivers/crypto/picoxcell_crypto.c |
4852 | @@ -1613,6 +1613,11 @@ static const struct of_device_id spacc_of_id_table[] = { |
4853 | MODULE_DEVICE_TABLE(of, spacc_of_id_table); |
4854 | #endif /* CONFIG_OF */ |
4855 | |
4856 | +static void spacc_tasklet_kill(void *data) |
4857 | +{ |
4858 | + tasklet_kill(data); |
4859 | +} |
4860 | + |
4861 | static int spacc_probe(struct platform_device *pdev) |
4862 | { |
4863 | int i, err, ret; |
4864 | @@ -1655,6 +1660,14 @@ static int spacc_probe(struct platform_device *pdev) |
4865 | return -ENXIO; |
4866 | } |
4867 | |
4868 | + tasklet_init(&engine->complete, spacc_spacc_complete, |
4869 | + (unsigned long)engine); |
4870 | + |
4871 | + ret = devm_add_action(&pdev->dev, spacc_tasklet_kill, |
4872 | + &engine->complete); |
4873 | + if (ret) |
4874 | + return ret; |
4875 | + |
4876 | if (devm_request_irq(&pdev->dev, irq->start, spacc_spacc_irq, 0, |
4877 | engine->name, engine)) { |
4878 | dev_err(engine->dev, "failed to request IRQ\n"); |
4879 | @@ -1712,8 +1725,6 @@ static int spacc_probe(struct platform_device *pdev) |
4880 | INIT_LIST_HEAD(&engine->completed); |
4881 | INIT_LIST_HEAD(&engine->in_progress); |
4882 | engine->in_flight = 0; |
4883 | - tasklet_init(&engine->complete, spacc_spacc_complete, |
4884 | - (unsigned long)engine); |
4885 | |
4886 | platform_set_drvdata(pdev, engine); |
4887 | |
4888 | diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c |
4889 | index ee1dc75f5ddc..1d733b57e60f 100644 |
4890 | --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c |
4891 | +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c |
4892 | @@ -247,7 +247,8 @@ bool dm_helpers_dp_mst_write_payload_allocation_table( |
4893 | drm_dp_mst_reset_vcpi_slots(mst_mgr, mst_port); |
4894 | } |
4895 | |
4896 | - ret = drm_dp_update_payload_part1(mst_mgr); |
4897 | + /* It's OK for this to fail */ |
4898 | + drm_dp_update_payload_part1(mst_mgr); |
4899 | |
4900 | /* mst_mgr->->payloads are VC payload notify MST branch using DPCD or |
4901 | * AUX message. The sequence is slot 1-63 allocated sequence for each |
4902 | @@ -256,9 +257,6 @@ bool dm_helpers_dp_mst_write_payload_allocation_table( |
4903 | |
4904 | get_payload_table(aconnector, proposed_table); |
4905 | |
4906 | - if (ret) |
4907 | - return false; |
4908 | - |
4909 | return true; |
4910 | } |
4911 | |
4912 | @@ -316,7 +314,6 @@ bool dm_helpers_dp_mst_send_payload_allocation( |
4913 | struct amdgpu_dm_connector *aconnector; |
4914 | struct drm_dp_mst_topology_mgr *mst_mgr; |
4915 | struct drm_dp_mst_port *mst_port; |
4916 | - int ret; |
4917 | |
4918 | aconnector = (struct amdgpu_dm_connector *)stream->dm_stream_context; |
4919 | |
4920 | @@ -330,10 +327,8 @@ bool dm_helpers_dp_mst_send_payload_allocation( |
4921 | if (!mst_mgr->mst_state) |
4922 | return false; |
4923 | |
4924 | - ret = drm_dp_update_payload_part2(mst_mgr); |
4925 | - |
4926 | - if (ret) |
4927 | - return false; |
4928 | + /* It's OK for this to fail */ |
4929 | + drm_dp_update_payload_part2(mst_mgr); |
4930 | |
4931 | if (!enable) |
4932 | drm_dp_mst_deallocate_vcpi(mst_mgr, mst_port); |
4933 | diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c |
4934 | index f2e73e6d46b8..10985134ce0b 100644 |
4935 | --- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c |
4936 | +++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c |
4937 | @@ -73,7 +73,11 @@ static void atmel_hlcdc_crtc_mode_set_nofb(struct drm_crtc *c) |
4938 | unsigned long prate; |
4939 | unsigned int mask = ATMEL_HLCDC_CLKDIV_MASK | ATMEL_HLCDC_CLKPOL; |
4940 | unsigned int cfg = 0; |
4941 | - int div; |
4942 | + int div, ret; |
4943 | + |
4944 | + ret = clk_prepare_enable(crtc->dc->hlcdc->sys_clk); |
4945 | + if (ret) |
4946 | + return; |
4947 | |
4948 | vm.vfront_porch = adj->crtc_vsync_start - adj->crtc_vdisplay; |
4949 | vm.vback_porch = adj->crtc_vtotal - adj->crtc_vsync_end; |
4950 | @@ -95,14 +99,14 @@ static void atmel_hlcdc_crtc_mode_set_nofb(struct drm_crtc *c) |
4951 | (adj->crtc_hdisplay - 1) | |
4952 | ((adj->crtc_vdisplay - 1) << 16)); |
4953 | |
4954 | + prate = clk_get_rate(crtc->dc->hlcdc->sys_clk); |
4955 | + mode_rate = adj->crtc_clock * 1000; |
4956 | if (!crtc->dc->desc->fixed_clksrc) { |
4957 | + prate *= 2; |
4958 | cfg |= ATMEL_HLCDC_CLKSEL; |
4959 | mask |= ATMEL_HLCDC_CLKSEL; |
4960 | } |
4961 | |
4962 | - prate = 2 * clk_get_rate(crtc->dc->hlcdc->sys_clk); |
4963 | - mode_rate = adj->crtc_clock * 1000; |
4964 | - |
4965 | div = DIV_ROUND_UP(prate, mode_rate); |
4966 | if (div < 2) { |
4967 | div = 2; |
4968 | @@ -117,8 +121,8 @@ static void atmel_hlcdc_crtc_mode_set_nofb(struct drm_crtc *c) |
4969 | int div_low = prate / mode_rate; |
4970 | |
4971 | if (div_low >= 2 && |
4972 | - ((prate / div_low - mode_rate) < |
4973 | - 10 * (mode_rate - prate / div))) |
4974 | + (10 * (prate / div_low - mode_rate) < |
4975 | + (mode_rate - prate / div))) |
4976 | /* |
4977 | * At least 10 times better when using a higher |
4978 | * frequency than requested, instead of a lower. |
4979 | @@ -147,6 +151,8 @@ static void atmel_hlcdc_crtc_mode_set_nofb(struct drm_crtc *c) |
4980 | ATMEL_HLCDC_VSPSU | ATMEL_HLCDC_VSPHO | |
4981 | ATMEL_HLCDC_GUARDTIME_MASK | ATMEL_HLCDC_MODE_MASK, |
4982 | cfg); |
4983 | + |
4984 | + clk_disable_unprepare(crtc->dc->hlcdc->sys_clk); |
4985 | } |
4986 | |
4987 | static enum drm_mode_status |
4988 | diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c |
4989 | index a48a4c21b1b3..c5e9e2305fff 100644 |
4990 | --- a/drivers/gpu/drm/drm_dp_mst_topology.c |
4991 | +++ b/drivers/gpu/drm/drm_dp_mst_topology.c |
4992 | @@ -2694,6 +2694,7 @@ static bool drm_dp_get_vc_payload_bw(int dp_link_bw, |
4993 | int drm_dp_mst_topology_mgr_set_mst(struct drm_dp_mst_topology_mgr *mgr, bool mst_state) |
4994 | { |
4995 | int ret = 0; |
4996 | + int i = 0; |
4997 | struct drm_dp_mst_branch *mstb = NULL; |
4998 | |
4999 | mutex_lock(&mgr->lock); |
5000 | @@ -2754,10 +2755,21 @@ int drm_dp_mst_topology_mgr_set_mst(struct drm_dp_mst_topology_mgr *mgr, bool ms |
5001 | /* this can fail if the device is gone */ |
5002 | drm_dp_dpcd_writeb(mgr->aux, DP_MSTM_CTRL, 0); |
5003 | ret = 0; |
5004 | + mutex_lock(&mgr->payload_lock); |
5005 | memset(mgr->payloads, 0, mgr->max_payloads * sizeof(struct drm_dp_payload)); |
5006 | mgr->payload_mask = 0; |
5007 | set_bit(0, &mgr->payload_mask); |
5008 | + for (i = 0; i < mgr->max_payloads; i++) { |
5009 | + struct drm_dp_vcpi *vcpi = mgr->proposed_vcpis[i]; |
5010 | + |
5011 | + if (vcpi) { |
5012 | + vcpi->vcpi = 0; |
5013 | + vcpi->num_slots = 0; |
5014 | + } |
5015 | + mgr->proposed_vcpis[i] = NULL; |
5016 | + } |
5017 | mgr->vcpi_mask = 0; |
5018 | + mutex_unlock(&mgr->payload_lock); |
5019 | } |
5020 | |
5021 | out_unlock: |
5022 | diff --git a/drivers/gpu/drm/drm_rect.c b/drivers/gpu/drm/drm_rect.c |
5023 | index b8363aaa9032..818738e83d06 100644 |
5024 | --- a/drivers/gpu/drm/drm_rect.c |
5025 | +++ b/drivers/gpu/drm/drm_rect.c |
5026 | @@ -54,7 +54,12 @@ EXPORT_SYMBOL(drm_rect_intersect); |
5027 | |
5028 | static u32 clip_scaled(u32 src, u32 dst, u32 clip) |
5029 | { |
5030 | - u64 tmp = mul_u32_u32(src, dst - clip); |
5031 | + u64 tmp; |
5032 | + |
5033 | + if (dst == 0) |
5034 | + return 0; |
5035 | + |
5036 | + tmp = mul_u32_u32(src, dst - clip); |
5037 | |
5038 | /* |
5039 | * Round toward 1.0 when clipping so that we don't accidentally |
5040 | diff --git a/drivers/gpu/drm/msm/disp/mdp4/mdp4_dsi_encoder.c b/drivers/gpu/drm/msm/disp/mdp4/mdp4_dsi_encoder.c |
5041 | index 772f0753ed38..aaf2f26f8505 100644 |
5042 | --- a/drivers/gpu/drm/msm/disp/mdp4/mdp4_dsi_encoder.c |
5043 | +++ b/drivers/gpu/drm/msm/disp/mdp4/mdp4_dsi_encoder.c |
5044 | @@ -121,7 +121,7 @@ static void mdp4_dsi_encoder_enable(struct drm_encoder *encoder) |
5045 | if (mdp4_dsi_encoder->enabled) |
5046 | return; |
5047 | |
5048 | - mdp4_crtc_set_config(encoder->crtc, |
5049 | + mdp4_crtc_set_config(encoder->crtc, |
5050 | MDP4_DMA_CONFIG_PACK_ALIGN_MSB | |
5051 | MDP4_DMA_CONFIG_DEFLKR_EN | |
5052 | MDP4_DMA_CONFIG_DITHER_EN | |
5053 | diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c |
5054 | index 34bd73526afd..930674117533 100644 |
5055 | --- a/drivers/hv/hv_balloon.c |
5056 | +++ b/drivers/hv/hv_balloon.c |
5057 | @@ -1213,10 +1213,7 @@ static unsigned int alloc_balloon_pages(struct hv_dynmem_device *dm, |
5058 | unsigned int i, j; |
5059 | struct page *pg; |
5060 | |
5061 | - if (num_pages < alloc_unit) |
5062 | - return 0; |
5063 | - |
5064 | - for (i = 0; (i * alloc_unit) < num_pages; i++) { |
5065 | + for (i = 0; i < num_pages / alloc_unit; i++) { |
5066 | if (bl_resp->hdr.size + sizeof(union dm_mem_page_range) > |
5067 | PAGE_SIZE) |
5068 | return i * alloc_unit; |
5069 | @@ -1254,7 +1251,7 @@ static unsigned int alloc_balloon_pages(struct hv_dynmem_device *dm, |
5070 | |
5071 | } |
5072 | |
5073 | - return num_pages; |
5074 | + return i * alloc_unit; |
5075 | } |
5076 | |
5077 | static void balloon_up(struct work_struct *dummy) |
5078 | @@ -1269,9 +1266,6 @@ static void balloon_up(struct work_struct *dummy) |
5079 | long avail_pages; |
5080 | unsigned long floor; |
5081 | |
5082 | - /* The host balloons pages in 2M granularity. */ |
5083 | - WARN_ON_ONCE(num_pages % PAGES_IN_2M != 0); |
5084 | - |
5085 | /* |
5086 | * We will attempt 2M allocations. However, if we fail to |
5087 | * allocate 2M chunks, we will go back to 4k allocations. |
5088 | @@ -1281,14 +1275,13 @@ static void balloon_up(struct work_struct *dummy) |
5089 | avail_pages = si_mem_available(); |
5090 | floor = compute_balloon_floor(); |
5091 | |
5092 | - /* Refuse to balloon below the floor, keep the 2M granularity. */ |
5093 | + /* Refuse to balloon below the floor. */ |
5094 | if (avail_pages < num_pages || avail_pages - num_pages < floor) { |
5095 | pr_warn("Balloon request will be partially fulfilled. %s\n", |
5096 | avail_pages < num_pages ? "Not enough memory." : |
5097 | "Balloon floor reached."); |
5098 | |
5099 | num_pages = avail_pages > floor ? (avail_pages - floor) : 0; |
5100 | - num_pages -= num_pages % PAGES_IN_2M; |
5101 | } |
5102 | |
5103 | while (!done) { |
5104 | diff --git a/drivers/infiniband/core/umem_odp.c b/drivers/infiniband/core/umem_odp.c |
5105 | index 163ff7ba92b7..fedf6829cdec 100644 |
5106 | --- a/drivers/infiniband/core/umem_odp.c |
5107 | +++ b/drivers/infiniband/core/umem_odp.c |
5108 | @@ -632,7 +632,7 @@ int ib_umem_odp_map_dma_pages(struct ib_umem_odp *umem_odp, u64 user_virt, |
5109 | |
5110 | while (bcnt > 0) { |
5111 | const size_t gup_num_pages = min_t(size_t, |
5112 | - (bcnt + BIT(page_shift) - 1) >> page_shift, |
5113 | + ALIGN(bcnt, PAGE_SIZE) / PAGE_SIZE, |
5114 | PAGE_SIZE / sizeof(struct page *)); |
5115 | |
5116 | down_read(&owning_mm->mmap_sem); |
5117 | diff --git a/drivers/infiniband/hw/mlx5/gsi.c b/drivers/infiniband/hw/mlx5/gsi.c |
5118 | index 4950df3f71b6..5c73c0a790fa 100644 |
5119 | --- a/drivers/infiniband/hw/mlx5/gsi.c |
5120 | +++ b/drivers/infiniband/hw/mlx5/gsi.c |
5121 | @@ -507,8 +507,7 @@ int mlx5_ib_gsi_post_send(struct ib_qp *qp, const struct ib_send_wr *wr, |
5122 | ret = ib_post_send(tx_qp, &cur_wr.wr, bad_wr); |
5123 | if (ret) { |
5124 | /* Undo the effect of adding the outstanding wr */ |
5125 | - gsi->outstanding_pi = (gsi->outstanding_pi - 1) % |
5126 | - gsi->cap.max_send_wr; |
5127 | + gsi->outstanding_pi--; |
5128 | goto err; |
5129 | } |
5130 | spin_unlock_irqrestore(&gsi->lock, flags); |
5131 | diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h |
5132 | index deb924e1d790..3d2b63585da9 100644 |
5133 | --- a/drivers/md/bcache/bcache.h |
5134 | +++ b/drivers/md/bcache/bcache.h |
5135 | @@ -329,6 +329,9 @@ struct cached_dev { |
5136 | */ |
5137 | atomic_t has_dirty; |
5138 | |
5139 | +#define BCH_CACHE_READA_ALL 0 |
5140 | +#define BCH_CACHE_READA_META_ONLY 1 |
5141 | + unsigned int cache_readahead_policy; |
5142 | struct bch_ratelimit writeback_rate; |
5143 | struct delayed_work writeback_rate_update; |
5144 | |
5145 | diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c |
5146 | index 41adcd1546f1..4045ae748f17 100644 |
5147 | --- a/drivers/md/bcache/request.c |
5148 | +++ b/drivers/md/bcache/request.c |
5149 | @@ -391,13 +391,20 @@ static bool check_should_bypass(struct cached_dev *dc, struct bio *bio) |
5150 | goto skip; |
5151 | |
5152 | /* |
5153 | - * Flag for bypass if the IO is for read-ahead or background, |
5154 | - * unless the read-ahead request is for metadata |
5155 | + * If the bio is for read-ahead or background IO, bypass it or |
5156 | + * not depends on the following situations, |
5157 | + * - If the IO is for meta data, always cache it and no bypass |
5158 | + * - If the IO is not meta data, check dc->cache_reada_policy, |
5159 | + * BCH_CACHE_READA_ALL: cache it and not bypass |
5160 | + * BCH_CACHE_READA_META_ONLY: not cache it and bypass |
5161 | + * That is, read-ahead request for metadata always get cached |
5162 | * (eg, for gfs2 or xfs). |
5163 | */ |
5164 | - if (bio->bi_opf & (REQ_RAHEAD|REQ_BACKGROUND) && |
5165 | - !(bio->bi_opf & (REQ_META|REQ_PRIO))) |
5166 | - goto skip; |
5167 | + if ((bio->bi_opf & (REQ_RAHEAD|REQ_BACKGROUND))) { |
5168 | + if (!(bio->bi_opf & (REQ_META|REQ_PRIO)) && |
5169 | + (dc->cache_readahead_policy != BCH_CACHE_READA_ALL)) |
5170 | + goto skip; |
5171 | + } |
5172 | |
5173 | if (bio->bi_iter.bi_sector & (c->sb.block_size - 1) || |
5174 | bio_sectors(bio) & (c->sb.block_size - 1)) { |
5175 | diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c |
5176 | index 627dcea0f5b6..7f0fb4b5755a 100644 |
5177 | --- a/drivers/md/bcache/sysfs.c |
5178 | +++ b/drivers/md/bcache/sysfs.c |
5179 | @@ -27,6 +27,12 @@ static const char * const bch_cache_modes[] = { |
5180 | NULL |
5181 | }; |
5182 | |
5183 | +static const char * const bch_reada_cache_policies[] = { |
5184 | + "all", |
5185 | + "meta-only", |
5186 | + NULL |
5187 | +}; |
5188 | + |
5189 | /* Default is 0 ("auto") */ |
5190 | static const char * const bch_stop_on_failure_modes[] = { |
5191 | "auto", |
5192 | @@ -100,6 +106,7 @@ rw_attribute(congested_write_threshold_us); |
5193 | rw_attribute(sequential_cutoff); |
5194 | rw_attribute(data_csum); |
5195 | rw_attribute(cache_mode); |
5196 | +rw_attribute(readahead_cache_policy); |
5197 | rw_attribute(stop_when_cache_set_failed); |
5198 | rw_attribute(writeback_metadata); |
5199 | rw_attribute(writeback_running); |
5200 | @@ -167,6 +174,11 @@ SHOW(__bch_cached_dev) |
5201 | bch_cache_modes, |
5202 | BDEV_CACHE_MODE(&dc->sb)); |
5203 | |
5204 | + if (attr == &sysfs_readahead_cache_policy) |
5205 | + return bch_snprint_string_list(buf, PAGE_SIZE, |
5206 | + bch_reada_cache_policies, |
5207 | + dc->cache_readahead_policy); |
5208 | + |
5209 | if (attr == &sysfs_stop_when_cache_set_failed) |
5210 | return bch_snprint_string_list(buf, PAGE_SIZE, |
5211 | bch_stop_on_failure_modes, |
5212 | @@ -352,6 +364,15 @@ STORE(__cached_dev) |
5213 | } |
5214 | } |
5215 | |
5216 | + if (attr == &sysfs_readahead_cache_policy) { |
5217 | + v = __sysfs_match_string(bch_reada_cache_policies, -1, buf); |
5218 | + if (v < 0) |
5219 | + return v; |
5220 | + |
5221 | + if ((unsigned int) v != dc->cache_readahead_policy) |
5222 | + dc->cache_readahead_policy = v; |
5223 | + } |
5224 | + |
5225 | if (attr == &sysfs_stop_when_cache_set_failed) { |
5226 | v = __sysfs_match_string(bch_stop_on_failure_modes, -1, buf); |
5227 | if (v < 0) |
5228 | @@ -466,6 +487,7 @@ static struct attribute *bch_cached_dev_files[] = { |
5229 | &sysfs_data_csum, |
5230 | #endif |
5231 | &sysfs_cache_mode, |
5232 | + &sysfs_readahead_cache_policy, |
5233 | &sysfs_stop_when_cache_set_failed, |
5234 | &sysfs_writeback_metadata, |
5235 | &sysfs_writeback_running, |
5236 | diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c |
5237 | index eb9782fc93fe..492bbe0584d9 100644 |
5238 | --- a/drivers/md/dm-crypt.c |
5239 | +++ b/drivers/md/dm-crypt.c |
5240 | @@ -331,8 +331,14 @@ static int crypt_iv_essiv_gen(struct crypt_config *cc, u8 *iv, |
5241 | static int crypt_iv_benbi_ctr(struct crypt_config *cc, struct dm_target *ti, |
5242 | const char *opts) |
5243 | { |
5244 | - unsigned bs = crypto_skcipher_blocksize(any_tfm(cc)); |
5245 | - int log = ilog2(bs); |
5246 | + unsigned bs; |
5247 | + int log; |
5248 | + |
5249 | + if (test_bit(CRYPT_MODE_INTEGRITY_AEAD, &cc->cipher_flags)) |
5250 | + bs = crypto_aead_blocksize(any_tfm_aead(cc)); |
5251 | + else |
5252 | + bs = crypto_skcipher_blocksize(any_tfm(cc)); |
5253 | + log = ilog2(bs); |
5254 | |
5255 | /* we need to calculate how far we must shift the sector count |
5256 | * to get the cipher block count, we use this shift in _gen */ |
5257 | @@ -717,7 +723,7 @@ static int crypt_iv_eboiv_gen(struct crypt_config *cc, u8 *iv, |
5258 | struct crypto_wait wait; |
5259 | int err; |
5260 | |
5261 | - req = skcipher_request_alloc(any_tfm(cc), GFP_KERNEL | GFP_NOFS); |
5262 | + req = skcipher_request_alloc(any_tfm(cc), GFP_NOIO); |
5263 | if (!req) |
5264 | return -ENOMEM; |
5265 | |
5266 | diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c |
5267 | index b88d6d701f5b..8bb723f1a569 100644 |
5268 | --- a/drivers/md/dm-thin-metadata.c |
5269 | +++ b/drivers/md/dm-thin-metadata.c |
5270 | @@ -387,16 +387,15 @@ static int subtree_equal(void *context, const void *value1_le, const void *value |
5271 | * Variant that is used for in-core only changes or code that |
5272 | * shouldn't put the pool in service on its own (e.g. commit). |
5273 | */ |
5274 | -static inline void __pmd_write_lock(struct dm_pool_metadata *pmd) |
5275 | +static inline void pmd_write_lock_in_core(struct dm_pool_metadata *pmd) |
5276 | __acquires(pmd->root_lock) |
5277 | { |
5278 | down_write(&pmd->root_lock); |
5279 | } |
5280 | -#define pmd_write_lock_in_core(pmd) __pmd_write_lock((pmd)) |
5281 | |
5282 | static inline void pmd_write_lock(struct dm_pool_metadata *pmd) |
5283 | { |
5284 | - __pmd_write_lock(pmd); |
5285 | + pmd_write_lock_in_core(pmd); |
5286 | if (unlikely(!pmd->in_service)) |
5287 | pmd->in_service = true; |
5288 | } |
5289 | @@ -831,6 +830,7 @@ static int __commit_transaction(struct dm_pool_metadata *pmd) |
5290 | * We need to know if the thin_disk_superblock exceeds a 512-byte sector. |
5291 | */ |
5292 | BUILD_BUG_ON(sizeof(struct thin_disk_superblock) > 512); |
5293 | + BUG_ON(!rwsem_is_locked(&pmd->root_lock)); |
5294 | |
5295 | if (unlikely(!pmd->in_service)) |
5296 | return 0; |
5297 | @@ -953,6 +953,7 @@ int dm_pool_metadata_close(struct dm_pool_metadata *pmd) |
5298 | return -EBUSY; |
5299 | } |
5300 | |
5301 | + pmd_write_lock_in_core(pmd); |
5302 | if (!dm_bm_is_read_only(pmd->bm) && !pmd->fail_io) { |
5303 | r = __commit_transaction(pmd); |
5304 | if (r < 0) |
5305 | @@ -961,6 +962,7 @@ int dm_pool_metadata_close(struct dm_pool_metadata *pmd) |
5306 | } |
5307 | if (!pmd->fail_io) |
5308 | __destroy_persistent_data_objects(pmd); |
5309 | + pmd_write_unlock(pmd); |
5310 | |
5311 | kfree(pmd); |
5312 | return 0; |
5313 | @@ -1841,7 +1843,7 @@ int dm_pool_commit_metadata(struct dm_pool_metadata *pmd) |
5314 | * Care is taken to not have commit be what |
5315 | * triggers putting the thin-pool in-service. |
5316 | */ |
5317 | - __pmd_write_lock(pmd); |
5318 | + pmd_write_lock_in_core(pmd); |
5319 | if (pmd->fail_io) |
5320 | goto out; |
5321 | |
5322 | diff --git a/drivers/md/dm-writecache.c b/drivers/md/dm-writecache.c |
5323 | index 43d1af1d8173..07c1b0334f57 100644 |
5324 | --- a/drivers/md/dm-writecache.c |
5325 | +++ b/drivers/md/dm-writecache.c |
5326 | @@ -442,7 +442,13 @@ static void writecache_notify_io(unsigned long error, void *context) |
5327 | complete(&endio->c); |
5328 | } |
5329 | |
5330 | -static void ssd_commit_flushed(struct dm_writecache *wc) |
5331 | +static void writecache_wait_for_ios(struct dm_writecache *wc, int direction) |
5332 | +{ |
5333 | + wait_event(wc->bio_in_progress_wait[direction], |
5334 | + !atomic_read(&wc->bio_in_progress[direction])); |
5335 | +} |
5336 | + |
5337 | +static void ssd_commit_flushed(struct dm_writecache *wc, bool wait_for_ios) |
5338 | { |
5339 | struct dm_io_region region; |
5340 | struct dm_io_request req; |
5341 | @@ -488,17 +494,20 @@ static void ssd_commit_flushed(struct dm_writecache *wc) |
5342 | writecache_notify_io(0, &endio); |
5343 | wait_for_completion_io(&endio.c); |
5344 | |
5345 | + if (wait_for_ios) |
5346 | + writecache_wait_for_ios(wc, WRITE); |
5347 | + |
5348 | writecache_disk_flush(wc, wc->ssd_dev); |
5349 | |
5350 | memset(wc->dirty_bitmap, 0, wc->dirty_bitmap_size); |
5351 | } |
5352 | |
5353 | -static void writecache_commit_flushed(struct dm_writecache *wc) |
5354 | +static void writecache_commit_flushed(struct dm_writecache *wc, bool wait_for_ios) |
5355 | { |
5356 | if (WC_MODE_PMEM(wc)) |
5357 | wmb(); |
5358 | else |
5359 | - ssd_commit_flushed(wc); |
5360 | + ssd_commit_flushed(wc, wait_for_ios); |
5361 | } |
5362 | |
5363 | static void writecache_disk_flush(struct dm_writecache *wc, struct dm_dev *dev) |
5364 | @@ -522,12 +531,6 @@ static void writecache_disk_flush(struct dm_writecache *wc, struct dm_dev *dev) |
5365 | writecache_error(wc, r, "error flushing metadata: %d", r); |
5366 | } |
5367 | |
5368 | -static void writecache_wait_for_ios(struct dm_writecache *wc, int direction) |
5369 | -{ |
5370 | - wait_event(wc->bio_in_progress_wait[direction], |
5371 | - !atomic_read(&wc->bio_in_progress[direction])); |
5372 | -} |
5373 | - |
5374 | #define WFE_RETURN_FOLLOWING 1 |
5375 | #define WFE_LOWEST_SEQ 2 |
5376 | |
5377 | @@ -724,15 +727,12 @@ static void writecache_flush(struct dm_writecache *wc) |
5378 | e = e2; |
5379 | cond_resched(); |
5380 | } |
5381 | - writecache_commit_flushed(wc); |
5382 | - |
5383 | - if (!WC_MODE_PMEM(wc)) |
5384 | - writecache_wait_for_ios(wc, WRITE); |
5385 | + writecache_commit_flushed(wc, true); |
5386 | |
5387 | wc->seq_count++; |
5388 | pmem_assign(sb(wc)->seq_count, cpu_to_le64(wc->seq_count)); |
5389 | writecache_flush_region(wc, &sb(wc)->seq_count, sizeof sb(wc)->seq_count); |
5390 | - writecache_commit_flushed(wc); |
5391 | + writecache_commit_flushed(wc, false); |
5392 | |
5393 | wc->overwrote_committed = false; |
5394 | |
5395 | @@ -756,7 +756,7 @@ static void writecache_flush(struct dm_writecache *wc) |
5396 | } |
5397 | |
5398 | if (need_flush_after_free) |
5399 | - writecache_commit_flushed(wc); |
5400 | + writecache_commit_flushed(wc, false); |
5401 | } |
5402 | |
5403 | static void writecache_flush_work(struct work_struct *work) |
5404 | @@ -809,7 +809,7 @@ static void writecache_discard(struct dm_writecache *wc, sector_t start, sector_ |
5405 | } |
5406 | |
5407 | if (discarded_something) |
5408 | - writecache_commit_flushed(wc); |
5409 | + writecache_commit_flushed(wc, false); |
5410 | } |
5411 | |
5412 | static bool writecache_wait_for_writeback(struct dm_writecache *wc) |
5413 | @@ -958,7 +958,7 @@ erase_this: |
5414 | |
5415 | if (need_flush) { |
5416 | writecache_flush_all_metadata(wc); |
5417 | - writecache_commit_flushed(wc); |
5418 | + writecache_commit_flushed(wc, false); |
5419 | } |
5420 | |
5421 | wc_unlock(wc); |
5422 | @@ -1342,7 +1342,7 @@ static void __writecache_endio_pmem(struct dm_writecache *wc, struct list_head * |
5423 | wc->writeback_size--; |
5424 | n_walked++; |
5425 | if (unlikely(n_walked >= ENDIO_LATENCY)) { |
5426 | - writecache_commit_flushed(wc); |
5427 | + writecache_commit_flushed(wc, false); |
5428 | wc_unlock(wc); |
5429 | wc_lock(wc); |
5430 | n_walked = 0; |
5431 | @@ -1423,7 +1423,7 @@ pop_from_list: |
5432 | writecache_wait_for_ios(wc, READ); |
5433 | } |
5434 | |
5435 | - writecache_commit_flushed(wc); |
5436 | + writecache_commit_flushed(wc, false); |
5437 | |
5438 | wc_unlock(wc); |
5439 | } |
5440 | @@ -1766,10 +1766,10 @@ static int init_memory(struct dm_writecache *wc) |
5441 | write_original_sector_seq_count(wc, &wc->entries[b], -1, -1); |
5442 | |
5443 | writecache_flush_all_metadata(wc); |
5444 | - writecache_commit_flushed(wc); |
5445 | + writecache_commit_flushed(wc, false); |
5446 | pmem_assign(sb(wc)->magic, cpu_to_le32(MEMORY_SUPERBLOCK_MAGIC)); |
5447 | writecache_flush_region(wc, &sb(wc)->magic, sizeof sb(wc)->magic); |
5448 | - writecache_commit_flushed(wc); |
5449 | + writecache_commit_flushed(wc, false); |
5450 | |
5451 | return 0; |
5452 | } |
5453 | diff --git a/drivers/md/dm-zoned-metadata.c b/drivers/md/dm-zoned-metadata.c |
5454 | index ac1179ca80d9..5205cf9bbfd9 100644 |
5455 | --- a/drivers/md/dm-zoned-metadata.c |
5456 | +++ b/drivers/md/dm-zoned-metadata.c |
5457 | @@ -134,6 +134,7 @@ struct dmz_metadata { |
5458 | |
5459 | sector_t zone_bitmap_size; |
5460 | unsigned int zone_nr_bitmap_blocks; |
5461 | + unsigned int zone_bits_per_mblk; |
5462 | |
5463 | unsigned int nr_bitmap_blocks; |
5464 | unsigned int nr_map_blocks; |
5465 | @@ -1167,7 +1168,10 @@ static int dmz_init_zones(struct dmz_metadata *zmd) |
5466 | |
5467 | /* Init */ |
5468 | zmd->zone_bitmap_size = dev->zone_nr_blocks >> 3; |
5469 | - zmd->zone_nr_bitmap_blocks = zmd->zone_bitmap_size >> DMZ_BLOCK_SHIFT; |
5470 | + zmd->zone_nr_bitmap_blocks = |
5471 | + max_t(sector_t, 1, zmd->zone_bitmap_size >> DMZ_BLOCK_SHIFT); |
5472 | + zmd->zone_bits_per_mblk = min_t(sector_t, dev->zone_nr_blocks, |
5473 | + DMZ_BLOCK_SIZE_BITS); |
5474 | |
5475 | /* Allocate zone array */ |
5476 | zmd->zones = kcalloc(dev->nr_zones, sizeof(struct dm_zone), GFP_KERNEL); |
5477 | @@ -1991,7 +1995,7 @@ int dmz_copy_valid_blocks(struct dmz_metadata *zmd, struct dm_zone *from_zone, |
5478 | dmz_release_mblock(zmd, to_mblk); |
5479 | dmz_release_mblock(zmd, from_mblk); |
5480 | |
5481 | - chunk_block += DMZ_BLOCK_SIZE_BITS; |
5482 | + chunk_block += zmd->zone_bits_per_mblk; |
5483 | } |
5484 | |
5485 | to_zone->weight = from_zone->weight; |
5486 | @@ -2052,7 +2056,7 @@ int dmz_validate_blocks(struct dmz_metadata *zmd, struct dm_zone *zone, |
5487 | |
5488 | /* Set bits */ |
5489 | bit = chunk_block & DMZ_BLOCK_MASK_BITS; |
5490 | - nr_bits = min(nr_blocks, DMZ_BLOCK_SIZE_BITS - bit); |
5491 | + nr_bits = min(nr_blocks, zmd->zone_bits_per_mblk - bit); |
5492 | |
5493 | count = dmz_set_bits((unsigned long *)mblk->data, bit, nr_bits); |
5494 | if (count) { |
5495 | @@ -2131,7 +2135,7 @@ int dmz_invalidate_blocks(struct dmz_metadata *zmd, struct dm_zone *zone, |
5496 | |
5497 | /* Clear bits */ |
5498 | bit = chunk_block & DMZ_BLOCK_MASK_BITS; |
5499 | - nr_bits = min(nr_blocks, DMZ_BLOCK_SIZE_BITS - bit); |
5500 | + nr_bits = min(nr_blocks, zmd->zone_bits_per_mblk - bit); |
5501 | |
5502 | count = dmz_clear_bits((unsigned long *)mblk->data, |
5503 | bit, nr_bits); |
5504 | @@ -2191,6 +2195,7 @@ static int dmz_to_next_set_block(struct dmz_metadata *zmd, struct dm_zone *zone, |
5505 | { |
5506 | struct dmz_mblock *mblk; |
5507 | unsigned int bit, set_bit, nr_bits; |
5508 | + unsigned int zone_bits = zmd->zone_bits_per_mblk; |
5509 | unsigned long *bitmap; |
5510 | int n = 0; |
5511 | |
5512 | @@ -2205,15 +2210,15 @@ static int dmz_to_next_set_block(struct dmz_metadata *zmd, struct dm_zone *zone, |
5513 | /* Get offset */ |
5514 | bitmap = (unsigned long *) mblk->data; |
5515 | bit = chunk_block & DMZ_BLOCK_MASK_BITS; |
5516 | - nr_bits = min(nr_blocks, DMZ_BLOCK_SIZE_BITS - bit); |
5517 | + nr_bits = min(nr_blocks, zone_bits - bit); |
5518 | if (set) |
5519 | - set_bit = find_next_bit(bitmap, DMZ_BLOCK_SIZE_BITS, bit); |
5520 | + set_bit = find_next_bit(bitmap, zone_bits, bit); |
5521 | else |
5522 | - set_bit = find_next_zero_bit(bitmap, DMZ_BLOCK_SIZE_BITS, bit); |
5523 | + set_bit = find_next_zero_bit(bitmap, zone_bits, bit); |
5524 | dmz_release_mblock(zmd, mblk); |
5525 | |
5526 | n += set_bit - bit; |
5527 | - if (set_bit < DMZ_BLOCK_SIZE_BITS) |
5528 | + if (set_bit < zone_bits) |
5529 | break; |
5530 | |
5531 | nr_blocks -= nr_bits; |
5532 | @@ -2316,7 +2321,7 @@ static void dmz_get_zone_weight(struct dmz_metadata *zmd, struct dm_zone *zone) |
5533 | /* Count bits in this block */ |
5534 | bitmap = mblk->data; |
5535 | bit = chunk_block & DMZ_BLOCK_MASK_BITS; |
5536 | - nr_bits = min(nr_blocks, DMZ_BLOCK_SIZE_BITS - bit); |
5537 | + nr_bits = min(nr_blocks, zmd->zone_bits_per_mblk - bit); |
5538 | n += dmz_count_bits(bitmap, bit, nr_bits); |
5539 | |
5540 | dmz_release_mblock(zmd, mblk); |
5541 | diff --git a/drivers/md/dm.c b/drivers/md/dm.c |
5542 | index 1a5e328c443a..6d3cc235f842 100644 |
5543 | --- a/drivers/md/dm.c |
5544 | +++ b/drivers/md/dm.c |
5545 | @@ -1880,6 +1880,7 @@ static void dm_init_normal_md_queue(struct mapped_device *md) |
5546 | /* |
5547 | * Initialize aspects of queue that aren't relevant for blk-mq |
5548 | */ |
5549 | + md->queue->backing_dev_info->congested_data = md; |
5550 | md->queue->backing_dev_info->congested_fn = dm_any_congested; |
5551 | } |
5552 | |
5553 | @@ -1970,7 +1971,12 @@ static struct mapped_device *alloc_dev(int minor) |
5554 | if (!md->queue) |
5555 | goto bad; |
5556 | md->queue->queuedata = md; |
5557 | - md->queue->backing_dev_info->congested_data = md; |
5558 | + /* |
5559 | + * default to bio-based required ->make_request_fn until DM |
5560 | + * table is loaded and md->type established. If request-based |
5561 | + * table is loaded: blk-mq will override accordingly. |
5562 | + */ |
5563 | + blk_queue_make_request(md->queue, dm_make_request); |
5564 | |
5565 | md->disk = alloc_disk_node(1, md->numa_node_id); |
5566 | if (!md->disk) |
5567 | @@ -2285,7 +2291,6 @@ int dm_setup_md_queue(struct mapped_device *md, struct dm_table *t) |
5568 | case DM_TYPE_DAX_BIO_BASED: |
5569 | case DM_TYPE_NVME_BIO_BASED: |
5570 | dm_init_normal_md_queue(md); |
5571 | - blk_queue_make_request(md->queue, dm_make_request); |
5572 | break; |
5573 | case DM_TYPE_NONE: |
5574 | WARN_ON_ONCE(true); |
5575 | diff --git a/drivers/md/persistent-data/dm-space-map-common.c b/drivers/md/persistent-data/dm-space-map-common.c |
5576 | index bd68f6fef694..d8b4125e338c 100644 |
5577 | --- a/drivers/md/persistent-data/dm-space-map-common.c |
5578 | +++ b/drivers/md/persistent-data/dm-space-map-common.c |
5579 | @@ -380,6 +380,33 @@ int sm_ll_find_free_block(struct ll_disk *ll, dm_block_t begin, |
5580 | return -ENOSPC; |
5581 | } |
5582 | |
5583 | +int sm_ll_find_common_free_block(struct ll_disk *old_ll, struct ll_disk *new_ll, |
5584 | + dm_block_t begin, dm_block_t end, dm_block_t *b) |
5585 | +{ |
5586 | + int r; |
5587 | + uint32_t count; |
5588 | + |
5589 | + do { |
5590 | + r = sm_ll_find_free_block(new_ll, begin, new_ll->nr_blocks, b); |
5591 | + if (r) |
5592 | + break; |
5593 | + |
5594 | + /* double check this block wasn't used in the old transaction */ |
5595 | + if (*b >= old_ll->nr_blocks) |
5596 | + count = 0; |
5597 | + else { |
5598 | + r = sm_ll_lookup(old_ll, *b, &count); |
5599 | + if (r) |
5600 | + break; |
5601 | + |
5602 | + if (count) |
5603 | + begin = *b + 1; |
5604 | + } |
5605 | + } while (count); |
5606 | + |
5607 | + return r; |
5608 | +} |
5609 | + |
5610 | static int sm_ll_mutate(struct ll_disk *ll, dm_block_t b, |
5611 | int (*mutator)(void *context, uint32_t old, uint32_t *new), |
5612 | void *context, enum allocation_event *ev) |
5613 | diff --git a/drivers/md/persistent-data/dm-space-map-common.h b/drivers/md/persistent-data/dm-space-map-common.h |
5614 | index b3078d5eda0c..8de63ce39bdd 100644 |
5615 | --- a/drivers/md/persistent-data/dm-space-map-common.h |
5616 | +++ b/drivers/md/persistent-data/dm-space-map-common.h |
5617 | @@ -109,6 +109,8 @@ int sm_ll_lookup_bitmap(struct ll_disk *ll, dm_block_t b, uint32_t *result); |
5618 | int sm_ll_lookup(struct ll_disk *ll, dm_block_t b, uint32_t *result); |
5619 | int sm_ll_find_free_block(struct ll_disk *ll, dm_block_t begin, |
5620 | dm_block_t end, dm_block_t *result); |
5621 | +int sm_ll_find_common_free_block(struct ll_disk *old_ll, struct ll_disk *new_ll, |
5622 | + dm_block_t begin, dm_block_t end, dm_block_t *result); |
5623 | int sm_ll_insert(struct ll_disk *ll, dm_block_t b, uint32_t ref_count, enum allocation_event *ev); |
5624 | int sm_ll_inc(struct ll_disk *ll, dm_block_t b, enum allocation_event *ev); |
5625 | int sm_ll_dec(struct ll_disk *ll, dm_block_t b, enum allocation_event *ev); |
5626 | diff --git a/drivers/md/persistent-data/dm-space-map-disk.c b/drivers/md/persistent-data/dm-space-map-disk.c |
5627 | index 32adf6b4a9c7..bf4c5e2ccb6f 100644 |
5628 | --- a/drivers/md/persistent-data/dm-space-map-disk.c |
5629 | +++ b/drivers/md/persistent-data/dm-space-map-disk.c |
5630 | @@ -167,8 +167,10 @@ static int sm_disk_new_block(struct dm_space_map *sm, dm_block_t *b) |
5631 | enum allocation_event ev; |
5632 | struct sm_disk *smd = container_of(sm, struct sm_disk, sm); |
5633 | |
5634 | - /* FIXME: we should loop round a couple of times */ |
5635 | - r = sm_ll_find_free_block(&smd->old_ll, smd->begin, smd->old_ll.nr_blocks, b); |
5636 | + /* |
5637 | + * Any block we allocate has to be free in both the old and current ll. |
5638 | + */ |
5639 | + r = sm_ll_find_common_free_block(&smd->old_ll, &smd->ll, smd->begin, smd->ll.nr_blocks, b); |
5640 | if (r) |
5641 | return r; |
5642 | |
5643 | diff --git a/drivers/md/persistent-data/dm-space-map-metadata.c b/drivers/md/persistent-data/dm-space-map-metadata.c |
5644 | index 25328582cc48..9e3c64ec2026 100644 |
5645 | --- a/drivers/md/persistent-data/dm-space-map-metadata.c |
5646 | +++ b/drivers/md/persistent-data/dm-space-map-metadata.c |
5647 | @@ -448,7 +448,10 @@ static int sm_metadata_new_block_(struct dm_space_map *sm, dm_block_t *b) |
5648 | enum allocation_event ev; |
5649 | struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm); |
5650 | |
5651 | - r = sm_ll_find_free_block(&smm->old_ll, smm->begin, smm->old_ll.nr_blocks, b); |
5652 | + /* |
5653 | + * Any block we allocate has to be free in both the old and current ll. |
5654 | + */ |
5655 | + r = sm_ll_find_common_free_block(&smm->old_ll, &smm->ll, smm->begin, smm->ll.nr_blocks, b); |
5656 | if (r) |
5657 | return r; |
5658 | |
5659 | diff --git a/drivers/media/rc/iguanair.c b/drivers/media/rc/iguanair.c |
5660 | index 872d6441e512..a7deca1fefb7 100644 |
5661 | --- a/drivers/media/rc/iguanair.c |
5662 | +++ b/drivers/media/rc/iguanair.c |
5663 | @@ -413,7 +413,7 @@ static int iguanair_probe(struct usb_interface *intf, |
5664 | int ret, pipein, pipeout; |
5665 | struct usb_host_interface *idesc; |
5666 | |
5667 | - idesc = intf->altsetting; |
5668 | + idesc = intf->cur_altsetting; |
5669 | if (idesc->desc.bNumEndpoints < 2) |
5670 | return -ENODEV; |
5671 | |
5672 | diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c |
5673 | index 7741151606ef..6f80c251f641 100644 |
5674 | --- a/drivers/media/rc/rc-main.c |
5675 | +++ b/drivers/media/rc/rc-main.c |
5676 | @@ -1891,23 +1891,28 @@ int rc_register_device(struct rc_dev *dev) |
5677 | |
5678 | dev->registered = true; |
5679 | |
5680 | - if (dev->driver_type != RC_DRIVER_IR_RAW_TX) { |
5681 | - rc = rc_setup_rx_device(dev); |
5682 | - if (rc) |
5683 | - goto out_dev; |
5684 | - } |
5685 | - |
5686 | - /* Ensure that the lirc kfifo is setup before we start the thread */ |
5687 | + /* |
5688 | + * once the the input device is registered in rc_setup_rx_device, |
5689 | + * userspace can open the input device and rc_open() will be called |
5690 | + * as a result. This results in driver code being allowed to submit |
5691 | + * keycodes with rc_keydown, so lirc must be registered first. |
5692 | + */ |
5693 | if (dev->allowed_protocols != RC_PROTO_BIT_CEC) { |
5694 | rc = ir_lirc_register(dev); |
5695 | if (rc < 0) |
5696 | - goto out_rx; |
5697 | + goto out_dev; |
5698 | + } |
5699 | + |
5700 | + if (dev->driver_type != RC_DRIVER_IR_RAW_TX) { |
5701 | + rc = rc_setup_rx_device(dev); |
5702 | + if (rc) |
5703 | + goto out_lirc; |
5704 | } |
5705 | |
5706 | if (dev->driver_type == RC_DRIVER_IR_RAW) { |
5707 | rc = ir_raw_event_register(dev); |
5708 | if (rc < 0) |
5709 | - goto out_lirc; |
5710 | + goto out_rx; |
5711 | } |
5712 | |
5713 | dev_dbg(&dev->dev, "Registered rc%u (driver: %s)\n", dev->minor, |
5714 | @@ -1915,11 +1920,11 @@ int rc_register_device(struct rc_dev *dev) |
5715 | |
5716 | return 0; |
5717 | |
5718 | +out_rx: |
5719 | + rc_free_rx_device(dev); |
5720 | out_lirc: |
5721 | if (dev->allowed_protocols != RC_PROTO_BIT_CEC) |
5722 | ir_lirc_unregister(dev); |
5723 | -out_rx: |
5724 | - rc_free_rx_device(dev); |
5725 | out_dev: |
5726 | device_del(&dev->dev); |
5727 | out_rx_free: |
5728 | diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c |
5729 | index 428235ca2635..2b688cc39bb8 100644 |
5730 | --- a/drivers/media/usb/uvc/uvc_driver.c |
5731 | +++ b/drivers/media/usb/uvc/uvc_driver.c |
5732 | @@ -1493,6 +1493,11 @@ static int uvc_scan_chain_forward(struct uvc_video_chain *chain, |
5733 | break; |
5734 | if (forward == prev) |
5735 | continue; |
5736 | + if (forward->chain.next || forward->chain.prev) { |
5737 | + uvc_trace(UVC_TRACE_DESCR, "Found reference to " |
5738 | + "entity %d already in chain.\n", forward->id); |
5739 | + return -EINVAL; |
5740 | + } |
5741 | |
5742 | switch (UVC_ENTITY_TYPE(forward)) { |
5743 | case UVC_VC_EXTENSION_UNIT: |
5744 | @@ -1574,6 +1579,13 @@ static int uvc_scan_chain_backward(struct uvc_video_chain *chain, |
5745 | return -1; |
5746 | } |
5747 | |
5748 | + if (term->chain.next || term->chain.prev) { |
5749 | + uvc_trace(UVC_TRACE_DESCR, "Found reference to " |
5750 | + "entity %d already in chain.\n", |
5751 | + term->id); |
5752 | + return -EINVAL; |
5753 | + } |
5754 | + |
5755 | if (uvc_trace_param & UVC_TRACE_PROBE) |
5756 | printk(KERN_CONT " %d", term->id); |
5757 | |
5758 | diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c |
5759 | index e1eaf1135c7f..7ad6db8dd9f6 100644 |
5760 | --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c |
5761 | +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c |
5762 | @@ -1183,36 +1183,38 @@ static long do_video_ioctl(struct file *file, unsigned int cmd, unsigned long ar |
5763 | u32 aux_space; |
5764 | int compatible_arg = 1; |
5765 | long err = 0; |
5766 | + unsigned int ncmd; |
5767 | |
5768 | /* |
5769 | * 1. When struct size is different, converts the command. |
5770 | */ |
5771 | switch (cmd) { |
5772 | - case VIDIOC_G_FMT32: cmd = VIDIOC_G_FMT; break; |
5773 | - case VIDIOC_S_FMT32: cmd = VIDIOC_S_FMT; break; |
5774 | - case VIDIOC_QUERYBUF32: cmd = VIDIOC_QUERYBUF; break; |
5775 | - case VIDIOC_G_FBUF32: cmd = VIDIOC_G_FBUF; break; |
5776 | - case VIDIOC_S_FBUF32: cmd = VIDIOC_S_FBUF; break; |
5777 | - case VIDIOC_QBUF32: cmd = VIDIOC_QBUF; break; |
5778 | - case VIDIOC_DQBUF32: cmd = VIDIOC_DQBUF; break; |
5779 | - case VIDIOC_ENUMSTD32: cmd = VIDIOC_ENUMSTD; break; |
5780 | - case VIDIOC_ENUMINPUT32: cmd = VIDIOC_ENUMINPUT; break; |
5781 | - case VIDIOC_TRY_FMT32: cmd = VIDIOC_TRY_FMT; break; |
5782 | - case VIDIOC_G_EXT_CTRLS32: cmd = VIDIOC_G_EXT_CTRLS; break; |
5783 | - case VIDIOC_S_EXT_CTRLS32: cmd = VIDIOC_S_EXT_CTRLS; break; |
5784 | - case VIDIOC_TRY_EXT_CTRLS32: cmd = VIDIOC_TRY_EXT_CTRLS; break; |
5785 | - case VIDIOC_DQEVENT32: cmd = VIDIOC_DQEVENT; break; |
5786 | - case VIDIOC_OVERLAY32: cmd = VIDIOC_OVERLAY; break; |
5787 | - case VIDIOC_STREAMON32: cmd = VIDIOC_STREAMON; break; |
5788 | - case VIDIOC_STREAMOFF32: cmd = VIDIOC_STREAMOFF; break; |
5789 | - case VIDIOC_G_INPUT32: cmd = VIDIOC_G_INPUT; break; |
5790 | - case VIDIOC_S_INPUT32: cmd = VIDIOC_S_INPUT; break; |
5791 | - case VIDIOC_G_OUTPUT32: cmd = VIDIOC_G_OUTPUT; break; |
5792 | - case VIDIOC_S_OUTPUT32: cmd = VIDIOC_S_OUTPUT; break; |
5793 | - case VIDIOC_CREATE_BUFS32: cmd = VIDIOC_CREATE_BUFS; break; |
5794 | - case VIDIOC_PREPARE_BUF32: cmd = VIDIOC_PREPARE_BUF; break; |
5795 | - case VIDIOC_G_EDID32: cmd = VIDIOC_G_EDID; break; |
5796 | - case VIDIOC_S_EDID32: cmd = VIDIOC_S_EDID; break; |
5797 | + case VIDIOC_G_FMT32: ncmd = VIDIOC_G_FMT; break; |
5798 | + case VIDIOC_S_FMT32: ncmd = VIDIOC_S_FMT; break; |
5799 | + case VIDIOC_QUERYBUF32: ncmd = VIDIOC_QUERYBUF; break; |
5800 | + case VIDIOC_G_FBUF32: ncmd = VIDIOC_G_FBUF; break; |
5801 | + case VIDIOC_S_FBUF32: ncmd = VIDIOC_S_FBUF; break; |
5802 | + case VIDIOC_QBUF32: ncmd = VIDIOC_QBUF; break; |
5803 | + case VIDIOC_DQBUF32: ncmd = VIDIOC_DQBUF; break; |
5804 | + case VIDIOC_ENUMSTD32: ncmd = VIDIOC_ENUMSTD; break; |
5805 | + case VIDIOC_ENUMINPUT32: ncmd = VIDIOC_ENUMINPUT; break; |
5806 | + case VIDIOC_TRY_FMT32: ncmd = VIDIOC_TRY_FMT; break; |
5807 | + case VIDIOC_G_EXT_CTRLS32: ncmd = VIDIOC_G_EXT_CTRLS; break; |
5808 | + case VIDIOC_S_EXT_CTRLS32: ncmd = VIDIOC_S_EXT_CTRLS; break; |
5809 | + case VIDIOC_TRY_EXT_CTRLS32: ncmd = VIDIOC_TRY_EXT_CTRLS; break; |
5810 | + case VIDIOC_DQEVENT32: ncmd = VIDIOC_DQEVENT; break; |
5811 | + case VIDIOC_OVERLAY32: ncmd = VIDIOC_OVERLAY; break; |
5812 | + case VIDIOC_STREAMON32: ncmd = VIDIOC_STREAMON; break; |
5813 | + case VIDIOC_STREAMOFF32: ncmd = VIDIOC_STREAMOFF; break; |
5814 | + case VIDIOC_G_INPUT32: ncmd = VIDIOC_G_INPUT; break; |
5815 | + case VIDIOC_S_INPUT32: ncmd = VIDIOC_S_INPUT; break; |
5816 | + case VIDIOC_G_OUTPUT32: ncmd = VIDIOC_G_OUTPUT; break; |
5817 | + case VIDIOC_S_OUTPUT32: ncmd = VIDIOC_S_OUTPUT; break; |
5818 | + case VIDIOC_CREATE_BUFS32: ncmd = VIDIOC_CREATE_BUFS; break; |
5819 | + case VIDIOC_PREPARE_BUF32: ncmd = VIDIOC_PREPARE_BUF; break; |
5820 | + case VIDIOC_G_EDID32: ncmd = VIDIOC_G_EDID; break; |
5821 | + case VIDIOC_S_EDID32: ncmd = VIDIOC_S_EDID; break; |
5822 | + default: ncmd = cmd; break; |
5823 | } |
5824 | |
5825 | /* |
5826 | @@ -1221,11 +1223,11 @@ static long do_video_ioctl(struct file *file, unsigned int cmd, unsigned long ar |
5827 | * argument into it. |
5828 | */ |
5829 | switch (cmd) { |
5830 | - case VIDIOC_OVERLAY: |
5831 | - case VIDIOC_STREAMON: |
5832 | - case VIDIOC_STREAMOFF: |
5833 | - case VIDIOC_S_INPUT: |
5834 | - case VIDIOC_S_OUTPUT: |
5835 | + case VIDIOC_OVERLAY32: |
5836 | + case VIDIOC_STREAMON32: |
5837 | + case VIDIOC_STREAMOFF32: |
5838 | + case VIDIOC_S_INPUT32: |
5839 | + case VIDIOC_S_OUTPUT32: |
5840 | err = alloc_userspace(sizeof(unsigned int), 0, &new_p64); |
5841 | if (!err && assign_in_user((unsigned int __user *)new_p64, |
5842 | (compat_uint_t __user *)p32)) |
5843 | @@ -1233,23 +1235,23 @@ static long do_video_ioctl(struct file *file, unsigned int cmd, unsigned long ar |
5844 | compatible_arg = 0; |
5845 | break; |
5846 | |
5847 | - case VIDIOC_G_INPUT: |
5848 | - case VIDIOC_G_OUTPUT: |
5849 | + case VIDIOC_G_INPUT32: |
5850 | + case VIDIOC_G_OUTPUT32: |
5851 | err = alloc_userspace(sizeof(unsigned int), 0, &new_p64); |
5852 | compatible_arg = 0; |
5853 | break; |
5854 | |
5855 | - case VIDIOC_G_EDID: |
5856 | - case VIDIOC_S_EDID: |
5857 | + case VIDIOC_G_EDID32: |
5858 | + case VIDIOC_S_EDID32: |
5859 | err = alloc_userspace(sizeof(struct v4l2_edid), 0, &new_p64); |
5860 | if (!err) |
5861 | err = get_v4l2_edid32(new_p64, p32); |
5862 | compatible_arg = 0; |
5863 | break; |
5864 | |
5865 | - case VIDIOC_G_FMT: |
5866 | - case VIDIOC_S_FMT: |
5867 | - case VIDIOC_TRY_FMT: |
5868 | + case VIDIOC_G_FMT32: |
5869 | + case VIDIOC_S_FMT32: |
5870 | + case VIDIOC_TRY_FMT32: |
5871 | err = bufsize_v4l2_format(p32, &aux_space); |
5872 | if (!err) |
5873 | err = alloc_userspace(sizeof(struct v4l2_format), |
5874 | @@ -1262,7 +1264,7 @@ static long do_video_ioctl(struct file *file, unsigned int cmd, unsigned long ar |
5875 | compatible_arg = 0; |
5876 | break; |
5877 | |
5878 | - case VIDIOC_CREATE_BUFS: |
5879 | + case VIDIOC_CREATE_BUFS32: |
5880 | err = bufsize_v4l2_create(p32, &aux_space); |
5881 | if (!err) |
5882 | err = alloc_userspace(sizeof(struct v4l2_create_buffers), |
5883 | @@ -1275,10 +1277,10 @@ static long do_video_ioctl(struct file *file, unsigned int cmd, unsigned long ar |
5884 | compatible_arg = 0; |
5885 | break; |
5886 | |
5887 | - case VIDIOC_PREPARE_BUF: |
5888 | - case VIDIOC_QUERYBUF: |
5889 | - case VIDIOC_QBUF: |
5890 | - case VIDIOC_DQBUF: |
5891 | + case VIDIOC_PREPARE_BUF32: |
5892 | + case VIDIOC_QUERYBUF32: |
5893 | + case VIDIOC_QBUF32: |
5894 | + case VIDIOC_DQBUF32: |
5895 | err = bufsize_v4l2_buffer(p32, &aux_space); |
5896 | if (!err) |
5897 | err = alloc_userspace(sizeof(struct v4l2_buffer), |
5898 | @@ -1291,7 +1293,7 @@ static long do_video_ioctl(struct file *file, unsigned int cmd, unsigned long ar |
5899 | compatible_arg = 0; |
5900 | break; |
5901 | |
5902 | - case VIDIOC_S_FBUF: |
5903 | + case VIDIOC_S_FBUF32: |
5904 | err = alloc_userspace(sizeof(struct v4l2_framebuffer), 0, |
5905 | &new_p64); |
5906 | if (!err) |
5907 | @@ -1299,13 +1301,13 @@ static long do_video_ioctl(struct file *file, unsigned int cmd, unsigned long ar |
5908 | compatible_arg = 0; |
5909 | break; |
5910 | |
5911 | - case VIDIOC_G_FBUF: |
5912 | + case VIDIOC_G_FBUF32: |
5913 | err = alloc_userspace(sizeof(struct v4l2_framebuffer), 0, |
5914 | &new_p64); |
5915 | compatible_arg = 0; |
5916 | break; |
5917 | |
5918 | - case VIDIOC_ENUMSTD: |
5919 | + case VIDIOC_ENUMSTD32: |
5920 | err = alloc_userspace(sizeof(struct v4l2_standard), 0, |
5921 | &new_p64); |
5922 | if (!err) |
5923 | @@ -1313,16 +1315,16 @@ static long do_video_ioctl(struct file *file, unsigned int cmd, unsigned long ar |
5924 | compatible_arg = 0; |
5925 | break; |
5926 | |
5927 | - case VIDIOC_ENUMINPUT: |
5928 | + case VIDIOC_ENUMINPUT32: |
5929 | err = alloc_userspace(sizeof(struct v4l2_input), 0, &new_p64); |
5930 | if (!err) |
5931 | err = get_v4l2_input32(new_p64, p32); |
5932 | compatible_arg = 0; |
5933 | break; |
5934 | |
5935 | - case VIDIOC_G_EXT_CTRLS: |
5936 | - case VIDIOC_S_EXT_CTRLS: |
5937 | - case VIDIOC_TRY_EXT_CTRLS: |
5938 | + case VIDIOC_G_EXT_CTRLS32: |
5939 | + case VIDIOC_S_EXT_CTRLS32: |
5940 | + case VIDIOC_TRY_EXT_CTRLS32: |
5941 | err = bufsize_v4l2_ext_controls(p32, &aux_space); |
5942 | if (!err) |
5943 | err = alloc_userspace(sizeof(struct v4l2_ext_controls), |
5944 | @@ -1334,7 +1336,7 @@ static long do_video_ioctl(struct file *file, unsigned int cmd, unsigned long ar |
5945 | } |
5946 | compatible_arg = 0; |
5947 | break; |
5948 | - case VIDIOC_DQEVENT: |
5949 | + case VIDIOC_DQEVENT32: |
5950 | err = alloc_userspace(sizeof(struct v4l2_event), 0, &new_p64); |
5951 | compatible_arg = 0; |
5952 | break; |
5953 | @@ -1352,9 +1354,9 @@ static long do_video_ioctl(struct file *file, unsigned int cmd, unsigned long ar |
5954 | * Otherwise, it will pass the newly allocated @new_p64 argument. |
5955 | */ |
5956 | if (compatible_arg) |
5957 | - err = native_ioctl(file, cmd, (unsigned long)p32); |
5958 | + err = native_ioctl(file, ncmd, (unsigned long)p32); |
5959 | else |
5960 | - err = native_ioctl(file, cmd, (unsigned long)new_p64); |
5961 | + err = native_ioctl(file, ncmd, (unsigned long)new_p64); |
5962 | |
5963 | if (err == -ENOTTY) |
5964 | return err; |
5965 | @@ -1370,13 +1372,13 @@ static long do_video_ioctl(struct file *file, unsigned int cmd, unsigned long ar |
5966 | * the blocks to maximum allowed value. |
5967 | */ |
5968 | switch (cmd) { |
5969 | - case VIDIOC_G_EXT_CTRLS: |
5970 | - case VIDIOC_S_EXT_CTRLS: |
5971 | - case VIDIOC_TRY_EXT_CTRLS: |
5972 | + case VIDIOC_G_EXT_CTRLS32: |
5973 | + case VIDIOC_S_EXT_CTRLS32: |
5974 | + case VIDIOC_TRY_EXT_CTRLS32: |
5975 | if (put_v4l2_ext_controls32(file, new_p64, p32)) |
5976 | err = -EFAULT; |
5977 | break; |
5978 | - case VIDIOC_S_EDID: |
5979 | + case VIDIOC_S_EDID32: |
5980 | if (put_v4l2_edid32(new_p64, p32)) |
5981 | err = -EFAULT; |
5982 | break; |
5983 | @@ -1389,49 +1391,49 @@ static long do_video_ioctl(struct file *file, unsigned int cmd, unsigned long ar |
5984 | * the original 32 bits structure. |
5985 | */ |
5986 | switch (cmd) { |
5987 | - case VIDIOC_S_INPUT: |
5988 | - case VIDIOC_S_OUTPUT: |
5989 | - case VIDIOC_G_INPUT: |
5990 | - case VIDIOC_G_OUTPUT: |
5991 | + case VIDIOC_S_INPUT32: |
5992 | + case VIDIOC_S_OUTPUT32: |
5993 | + case VIDIOC_G_INPUT32: |
5994 | + case VIDIOC_G_OUTPUT32: |
5995 | if (assign_in_user((compat_uint_t __user *)p32, |
5996 | ((unsigned int __user *)new_p64))) |
5997 | err = -EFAULT; |
5998 | break; |
5999 | |
6000 | - case VIDIOC_G_FBUF: |
6001 | + case VIDIOC_G_FBUF32: |
6002 | err = put_v4l2_framebuffer32(new_p64, p32); |
6003 | break; |
6004 | |
6005 | - case VIDIOC_DQEVENT: |
6006 | + case VIDIOC_DQEVENT32: |
6007 | err = put_v4l2_event32(new_p64, p32); |
6008 | break; |
6009 | |
6010 | - case VIDIOC_G_EDID: |
6011 | + case VIDIOC_G_EDID32: |
6012 | err = put_v4l2_edid32(new_p64, p32); |
6013 | break; |
6014 | |
6015 | - case VIDIOC_G_FMT: |
6016 | - case VIDIOC_S_FMT: |
6017 | - case VIDIOC_TRY_FMT: |
6018 | + case VIDIOC_G_FMT32: |
6019 | + case VIDIOC_S_FMT32: |
6020 | + case VIDIOC_TRY_FMT32: |
6021 | err = put_v4l2_format32(new_p64, p32); |
6022 | break; |
6023 | |
6024 | - case VIDIOC_CREATE_BUFS: |
6025 | + case VIDIOC_CREATE_BUFS32: |
6026 | err = put_v4l2_create32(new_p64, p32); |
6027 | break; |
6028 | |
6029 | - case VIDIOC_PREPARE_BUF: |
6030 | - case VIDIOC_QUERYBUF: |
6031 | - case VIDIOC_QBUF: |
6032 | - case VIDIOC_DQBUF: |
6033 | + case VIDIOC_PREPARE_BUF32: |
6034 | + case VIDIOC_QUERYBUF32: |
6035 | + case VIDIOC_QBUF32: |
6036 | + case VIDIOC_DQBUF32: |
6037 | err = put_v4l2_buffer32(new_p64, p32); |
6038 | break; |
6039 | |
6040 | - case VIDIOC_ENUMSTD: |
6041 | + case VIDIOC_ENUMSTD32: |
6042 | err = put_v4l2_standard32(new_p64, p32); |
6043 | break; |
6044 | |
6045 | - case VIDIOC_ENUMINPUT: |
6046 | + case VIDIOC_ENUMINPUT32: |
6047 | err = put_v4l2_input32(new_p64, p32); |
6048 | break; |
6049 | } |
6050 | diff --git a/drivers/media/v4l2-core/videobuf-dma-sg.c b/drivers/media/v4l2-core/videobuf-dma-sg.c |
6051 | index 66a6c6c236a7..28262190c3ab 100644 |
6052 | --- a/drivers/media/v4l2-core/videobuf-dma-sg.c |
6053 | +++ b/drivers/media/v4l2-core/videobuf-dma-sg.c |
6054 | @@ -349,8 +349,11 @@ int videobuf_dma_free(struct videobuf_dmabuf *dma) |
6055 | BUG_ON(dma->sglen); |
6056 | |
6057 | if (dma->pages) { |
6058 | - for (i = 0; i < dma->nr_pages; i++) |
6059 | + for (i = 0; i < dma->nr_pages; i++) { |
6060 | + if (dma->direction == DMA_FROM_DEVICE) |
6061 | + set_page_dirty_lock(dma->pages[i]); |
6062 | put_page(dma->pages[i]); |
6063 | + } |
6064 | kfree(dma->pages); |
6065 | dma->pages = NULL; |
6066 | } |
6067 | diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c |
6068 | index a4aaadaa0cb0..aa59496e4376 100644 |
6069 | --- a/drivers/mfd/axp20x.c |
6070 | +++ b/drivers/mfd/axp20x.c |
6071 | @@ -126,7 +126,7 @@ static const struct regmap_range axp288_writeable_ranges[] = { |
6072 | static const struct regmap_range axp288_volatile_ranges[] = { |
6073 | regmap_reg_range(AXP20X_PWR_INPUT_STATUS, AXP288_POWER_REASON), |
6074 | regmap_reg_range(AXP288_BC_GLOBAL, AXP288_BC_GLOBAL), |
6075 | - regmap_reg_range(AXP288_BC_DET_STAT, AXP288_BC_DET_STAT), |
6076 | + regmap_reg_range(AXP288_BC_DET_STAT, AXP20X_VBUS_IPSOUT_MGMT), |
6077 | regmap_reg_range(AXP20X_CHRG_BAK_CTRL, AXP20X_CHRG_BAK_CTRL), |
6078 | regmap_reg_range(AXP20X_IRQ1_EN, AXP20X_IPSOUT_V_HIGH_L), |
6079 | regmap_reg_range(AXP20X_TIMER_CTRL, AXP20X_TIMER_CTRL), |
6080 | diff --git a/drivers/mfd/da9062-core.c b/drivers/mfd/da9062-core.c |
6081 | index e69626867c26..9143de7b77b8 100644 |
6082 | --- a/drivers/mfd/da9062-core.c |
6083 | +++ b/drivers/mfd/da9062-core.c |
6084 | @@ -248,7 +248,7 @@ static const struct mfd_cell da9062_devs[] = { |
6085 | .name = "da9062-watchdog", |
6086 | .num_resources = ARRAY_SIZE(da9062_wdt_resources), |
6087 | .resources = da9062_wdt_resources, |
6088 | - .of_compatible = "dlg,da9062-wdt", |
6089 | + .of_compatible = "dlg,da9062-watchdog", |
6090 | }, |
6091 | { |
6092 | .name = "da9062-thermal", |
6093 | diff --git a/drivers/mfd/dln2.c b/drivers/mfd/dln2.c |
6094 | index 381593fbe50f..7841c11411d0 100644 |
6095 | --- a/drivers/mfd/dln2.c |
6096 | +++ b/drivers/mfd/dln2.c |
6097 | @@ -722,6 +722,8 @@ static int dln2_probe(struct usb_interface *interface, |
6098 | const struct usb_device_id *usb_id) |
6099 | { |
6100 | struct usb_host_interface *hostif = interface->cur_altsetting; |
6101 | + struct usb_endpoint_descriptor *epin; |
6102 | + struct usb_endpoint_descriptor *epout; |
6103 | struct device *dev = &interface->dev; |
6104 | struct dln2_dev *dln2; |
6105 | int ret; |
6106 | @@ -731,12 +733,19 @@ static int dln2_probe(struct usb_interface *interface, |
6107 | hostif->desc.bNumEndpoints < 2) |
6108 | return -ENODEV; |
6109 | |
6110 | + epin = &hostif->endpoint[0].desc; |
6111 | + epout = &hostif->endpoint[1].desc; |
6112 | + if (!usb_endpoint_is_bulk_out(epout)) |
6113 | + return -ENODEV; |
6114 | + if (!usb_endpoint_is_bulk_in(epin)) |
6115 | + return -ENODEV; |
6116 | + |
6117 | dln2 = kzalloc(sizeof(*dln2), GFP_KERNEL); |
6118 | if (!dln2) |
6119 | return -ENOMEM; |
6120 | |
6121 | - dln2->ep_out = hostif->endpoint[0].desc.bEndpointAddress; |
6122 | - dln2->ep_in = hostif->endpoint[1].desc.bEndpointAddress; |
6123 | + dln2->ep_out = epout->bEndpointAddress; |
6124 | + dln2->ep_in = epin->bEndpointAddress; |
6125 | dln2->usb_dev = usb_get_dev(interface_to_usbdev(interface)); |
6126 | dln2->interface = interface; |
6127 | usb_set_intfdata(interface, dln2); |
6128 | diff --git a/drivers/mfd/rn5t618.c b/drivers/mfd/rn5t618.c |
6129 | index da5cd9c92a59..ead2e79036a9 100644 |
6130 | --- a/drivers/mfd/rn5t618.c |
6131 | +++ b/drivers/mfd/rn5t618.c |
6132 | @@ -26,6 +26,7 @@ static bool rn5t618_volatile_reg(struct device *dev, unsigned int reg) |
6133 | case RN5T618_WATCHDOGCNT: |
6134 | case RN5T618_DCIRQ: |
6135 | case RN5T618_ILIMDATAH ... RN5T618_AIN0DATAL: |
6136 | + case RN5T618_ADCCNT3: |
6137 | case RN5T618_IR_ADC1 ... RN5T618_IR_ADC3: |
6138 | case RN5T618_IR_GPR: |
6139 | case RN5T618_IR_GPF: |
6140 | diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c |
6141 | index 66e354d51ee9..7083d8ddd495 100644 |
6142 | --- a/drivers/mmc/host/mmc_spi.c |
6143 | +++ b/drivers/mmc/host/mmc_spi.c |
6144 | @@ -1134,17 +1134,22 @@ static void mmc_spi_initsequence(struct mmc_spi_host *host) |
6145 | * SPI protocol. Another is that when chipselect is released while |
6146 | * the card returns BUSY status, the clock must issue several cycles |
6147 | * with chipselect high before the card will stop driving its output. |
6148 | + * |
6149 | + * SPI_CS_HIGH means "asserted" here. In some cases like when using |
6150 | + * GPIOs for chip select, SPI_CS_HIGH is set but this will be logically |
6151 | + * inverted by gpiolib, so if we want to ascertain to drive it high |
6152 | + * we should toggle the default with an XOR as we do here. |
6153 | */ |
6154 | - host->spi->mode |= SPI_CS_HIGH; |
6155 | + host->spi->mode ^= SPI_CS_HIGH; |
6156 | if (spi_setup(host->spi) != 0) { |
6157 | /* Just warn; most cards work without it. */ |
6158 | dev_warn(&host->spi->dev, |
6159 | "can't change chip-select polarity\n"); |
6160 | - host->spi->mode &= ~SPI_CS_HIGH; |
6161 | + host->spi->mode ^= SPI_CS_HIGH; |
6162 | } else { |
6163 | mmc_spi_readbytes(host, 18); |
6164 | |
6165 | - host->spi->mode &= ~SPI_CS_HIGH; |
6166 | + host->spi->mode ^= SPI_CS_HIGH; |
6167 | if (spi_setup(host->spi) != 0) { |
6168 | /* Wot, we can't get the same setup we had before? */ |
6169 | dev_err(&host->spi->dev, |
6170 | diff --git a/drivers/mmc/host/sdhci-of-at91.c b/drivers/mmc/host/sdhci-of-at91.c |
6171 | index 0ae986c42bc8..9378d5dc86c8 100644 |
6172 | --- a/drivers/mmc/host/sdhci-of-at91.c |
6173 | +++ b/drivers/mmc/host/sdhci-of-at91.c |
6174 | @@ -324,19 +324,22 @@ static int sdhci_at91_probe(struct platform_device *pdev) |
6175 | priv->mainck = devm_clk_get(&pdev->dev, "baseclk"); |
6176 | if (IS_ERR(priv->mainck)) { |
6177 | dev_err(&pdev->dev, "failed to get baseclk\n"); |
6178 | - return PTR_ERR(priv->mainck); |
6179 | + ret = PTR_ERR(priv->mainck); |
6180 | + goto sdhci_pltfm_free; |
6181 | } |
6182 | |
6183 | priv->hclock = devm_clk_get(&pdev->dev, "hclock"); |
6184 | if (IS_ERR(priv->hclock)) { |
6185 | dev_err(&pdev->dev, "failed to get hclock\n"); |
6186 | - return PTR_ERR(priv->hclock); |
6187 | + ret = PTR_ERR(priv->hclock); |
6188 | + goto sdhci_pltfm_free; |
6189 | } |
6190 | |
6191 | priv->gck = devm_clk_get(&pdev->dev, "multclk"); |
6192 | if (IS_ERR(priv->gck)) { |
6193 | dev_err(&pdev->dev, "failed to get multclk\n"); |
6194 | - return PTR_ERR(priv->gck); |
6195 | + ret = PTR_ERR(priv->gck); |
6196 | + goto sdhci_pltfm_free; |
6197 | } |
6198 | |
6199 | ret = sdhci_at91_set_clks_presets(&pdev->dev); |
6200 | diff --git a/drivers/mmc/host/sdhci-pci-core.c b/drivers/mmc/host/sdhci-pci-core.c |
6201 | index c9ea365c248c..5091e2c1c0e5 100644 |
6202 | --- a/drivers/mmc/host/sdhci-pci-core.c |
6203 | +++ b/drivers/mmc/host/sdhci-pci-core.c |
6204 | @@ -1604,7 +1604,7 @@ static u32 sdhci_read_present_state(struct sdhci_host *host) |
6205 | return sdhci_readl(host, SDHCI_PRESENT_STATE); |
6206 | } |
6207 | |
6208 | -void amd_sdhci_reset(struct sdhci_host *host, u8 mask) |
6209 | +static void amd_sdhci_reset(struct sdhci_host *host, u8 mask) |
6210 | { |
6211 | struct sdhci_pci_slot *slot = sdhci_priv(host); |
6212 | struct pci_dev *pdev = slot->chip->pdev; |
6213 | diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c |
6214 | index 309c808351ac..f417fb680cd8 100644 |
6215 | --- a/drivers/mtd/spi-nor/spi-nor.c |
6216 | +++ b/drivers/mtd/spi-nor/spi-nor.c |
6217 | @@ -2310,15 +2310,16 @@ static const struct flash_info spi_nor_ids[] = { |
6218 | { "n25q256a", INFO(0x20ba19, 0, 64 * 1024, 512, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, |
6219 | { "n25q256ax1", INFO(0x20bb19, 0, 64 * 1024, 512, SECT_4K | SPI_NOR_QUAD_READ) }, |
6220 | { "n25q512ax3", INFO(0x20ba20, 0, 64 * 1024, 1024, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ) }, |
6221 | + { "mt25qu512a", INFO6(0x20bb20, 0x104400, 64 * 1024, 1024, |
6222 | + SECT_4K | USE_FSR | SPI_NOR_DUAL_READ | |
6223 | + SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) }, |
6224 | + { "n25q512a", INFO(0x20bb20, 0, 64 * 1024, 1024, SECT_4K | |
6225 | + SPI_NOR_QUAD_READ) }, |
6226 | { "n25q00", INFO(0x20ba21, 0, 64 * 1024, 2048, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ | NO_CHIP_ERASE) }, |
6227 | { "n25q00a", INFO(0x20bb21, 0, 64 * 1024, 2048, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ | NO_CHIP_ERASE) }, |
6228 | { "mt25ql02g", INFO(0x20ba22, 0, 64 * 1024, 4096, |
6229 | SECT_4K | USE_FSR | SPI_NOR_QUAD_READ | |
6230 | NO_CHIP_ERASE) }, |
6231 | - { "mt25qu512a (n25q512a)", INFO(0x20bb20, 0, 64 * 1024, 1024, |
6232 | - SECT_4K | USE_FSR | SPI_NOR_DUAL_READ | |
6233 | - SPI_NOR_QUAD_READ | |
6234 | - SPI_NOR_4B_OPCODES) }, |
6235 | { "mt25qu02g", INFO(0x20bb22, 0, 64 * 1024, 4096, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ | NO_CHIP_ERASE) }, |
6236 | |
6237 | /* Micron */ |
6238 | diff --git a/drivers/mtd/ubi/fastmap.c b/drivers/mtd/ubi/fastmap.c |
6239 | index 30621c67721a..604772fc4a96 100644 |
6240 | --- a/drivers/mtd/ubi/fastmap.c |
6241 | +++ b/drivers/mtd/ubi/fastmap.c |
6242 | @@ -64,7 +64,7 @@ static int self_check_seen(struct ubi_device *ubi, unsigned long *seen) |
6243 | return 0; |
6244 | |
6245 | for (pnum = 0; pnum < ubi->peb_count; pnum++) { |
6246 | - if (test_bit(pnum, seen) && ubi->lookuptbl[pnum]) { |
6247 | + if (!test_bit(pnum, seen) && ubi->lookuptbl[pnum]) { |
6248 | ubi_err(ubi, "self-check failed for PEB %d, fastmap didn't see it", pnum); |
6249 | ret = -EINVAL; |
6250 | } |
6251 | @@ -1137,7 +1137,7 @@ static int ubi_write_fastmap(struct ubi_device *ubi, |
6252 | struct rb_node *tmp_rb; |
6253 | int ret, i, j, free_peb_count, used_peb_count, vol_count; |
6254 | int scrub_peb_count, erase_peb_count; |
6255 | - unsigned long *seen_pebs = NULL; |
6256 | + unsigned long *seen_pebs; |
6257 | |
6258 | fm_raw = ubi->fm_buf; |
6259 | memset(ubi->fm_buf, 0, ubi->fm_size); |
6260 | @@ -1151,7 +1151,7 @@ static int ubi_write_fastmap(struct ubi_device *ubi, |
6261 | dvbuf = new_fm_vbuf(ubi, UBI_FM_DATA_VOLUME_ID); |
6262 | if (!dvbuf) { |
6263 | ret = -ENOMEM; |
6264 | - goto out_kfree; |
6265 | + goto out_free_avbuf; |
6266 | } |
6267 | |
6268 | avhdr = ubi_get_vid_hdr(avbuf); |
6269 | @@ -1160,7 +1160,7 @@ static int ubi_write_fastmap(struct ubi_device *ubi, |
6270 | seen_pebs = init_seen(ubi); |
6271 | if (IS_ERR(seen_pebs)) { |
6272 | ret = PTR_ERR(seen_pebs); |
6273 | - goto out_kfree; |
6274 | + goto out_free_dvbuf; |
6275 | } |
6276 | |
6277 | spin_lock(&ubi->volumes_lock); |
6278 | @@ -1328,7 +1328,7 @@ static int ubi_write_fastmap(struct ubi_device *ubi, |
6279 | ret = ubi_io_write_vid_hdr(ubi, new_fm->e[0]->pnum, avbuf); |
6280 | if (ret) { |
6281 | ubi_err(ubi, "unable to write vid_hdr to fastmap SB!"); |
6282 | - goto out_kfree; |
6283 | + goto out_free_seen; |
6284 | } |
6285 | |
6286 | for (i = 0; i < new_fm->used_blocks; i++) { |
6287 | @@ -1350,7 +1350,7 @@ static int ubi_write_fastmap(struct ubi_device *ubi, |
6288 | if (ret) { |
6289 | ubi_err(ubi, "unable to write vid_hdr to PEB %i!", |
6290 | new_fm->e[i]->pnum); |
6291 | - goto out_kfree; |
6292 | + goto out_free_seen; |
6293 | } |
6294 | } |
6295 | |
6296 | @@ -1360,7 +1360,7 @@ static int ubi_write_fastmap(struct ubi_device *ubi, |
6297 | if (ret) { |
6298 | ubi_err(ubi, "unable to write fastmap to PEB %i!", |
6299 | new_fm->e[i]->pnum); |
6300 | - goto out_kfree; |
6301 | + goto out_free_seen; |
6302 | } |
6303 | } |
6304 | |
6305 | @@ -1370,10 +1370,13 @@ static int ubi_write_fastmap(struct ubi_device *ubi, |
6306 | ret = self_check_seen(ubi, seen_pebs); |
6307 | dbg_bld("fastmap written!"); |
6308 | |
6309 | -out_kfree: |
6310 | - ubi_free_vid_buf(avbuf); |
6311 | - ubi_free_vid_buf(dvbuf); |
6312 | +out_free_seen: |
6313 | free_seen(seen_pebs); |
6314 | +out_free_dvbuf: |
6315 | + ubi_free_vid_buf(dvbuf); |
6316 | +out_free_avbuf: |
6317 | + ubi_free_vid_buf(avbuf); |
6318 | + |
6319 | out: |
6320 | return ret; |
6321 | } |
6322 | diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c |
6323 | index 4f2e6910c623..1cc2cd894f87 100644 |
6324 | --- a/drivers/net/bonding/bond_alb.c |
6325 | +++ b/drivers/net/bonding/bond_alb.c |
6326 | @@ -1383,26 +1383,31 @@ netdev_tx_t bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev) |
6327 | bool do_tx_balance = true; |
6328 | u32 hash_index = 0; |
6329 | const u8 *hash_start = NULL; |
6330 | - struct ipv6hdr *ip6hdr; |
6331 | |
6332 | skb_reset_mac_header(skb); |
6333 | eth_data = eth_hdr(skb); |
6334 | |
6335 | switch (ntohs(skb->protocol)) { |
6336 | case ETH_P_IP: { |
6337 | - const struct iphdr *iph = ip_hdr(skb); |
6338 | + const struct iphdr *iph; |
6339 | |
6340 | if (is_broadcast_ether_addr(eth_data->h_dest) || |
6341 | - iph->daddr == ip_bcast || |
6342 | - iph->protocol == IPPROTO_IGMP) { |
6343 | + !pskb_network_may_pull(skb, sizeof(*iph))) { |
6344 | + do_tx_balance = false; |
6345 | + break; |
6346 | + } |
6347 | + iph = ip_hdr(skb); |
6348 | + if (iph->daddr == ip_bcast || iph->protocol == IPPROTO_IGMP) { |
6349 | do_tx_balance = false; |
6350 | break; |
6351 | } |
6352 | hash_start = (char *)&(iph->daddr); |
6353 | hash_size = sizeof(iph->daddr); |
6354 | - } |
6355 | break; |
6356 | - case ETH_P_IPV6: |
6357 | + } |
6358 | + case ETH_P_IPV6: { |
6359 | + const struct ipv6hdr *ip6hdr; |
6360 | + |
6361 | /* IPv6 doesn't really use broadcast mac address, but leave |
6362 | * that here just in case. |
6363 | */ |
6364 | @@ -1419,7 +1424,11 @@ netdev_tx_t bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev) |
6365 | break; |
6366 | } |
6367 | |
6368 | - /* Additianally, DAD probes should not be tx-balanced as that |
6369 | + if (!pskb_network_may_pull(skb, sizeof(*ip6hdr))) { |
6370 | + do_tx_balance = false; |
6371 | + break; |
6372 | + } |
6373 | + /* Additionally, DAD probes should not be tx-balanced as that |
6374 | * will lead to false positives for duplicate addresses and |
6375 | * prevent address configuration from working. |
6376 | */ |
6377 | @@ -1429,17 +1438,26 @@ netdev_tx_t bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev) |
6378 | break; |
6379 | } |
6380 | |
6381 | - hash_start = (char *)&(ipv6_hdr(skb)->daddr); |
6382 | - hash_size = sizeof(ipv6_hdr(skb)->daddr); |
6383 | + hash_start = (char *)&ip6hdr->daddr; |
6384 | + hash_size = sizeof(ip6hdr->daddr); |
6385 | break; |
6386 | - case ETH_P_IPX: |
6387 | - if (ipx_hdr(skb)->ipx_checksum != IPX_NO_CHECKSUM) { |
6388 | + } |
6389 | + case ETH_P_IPX: { |
6390 | + const struct ipxhdr *ipxhdr; |
6391 | + |
6392 | + if (pskb_network_may_pull(skb, sizeof(*ipxhdr))) { |
6393 | + do_tx_balance = false; |
6394 | + break; |
6395 | + } |
6396 | + ipxhdr = (struct ipxhdr *)skb_network_header(skb); |
6397 | + |
6398 | + if (ipxhdr->ipx_checksum != IPX_NO_CHECKSUM) { |
6399 | /* something is wrong with this packet */ |
6400 | do_tx_balance = false; |
6401 | break; |
6402 | } |
6403 | |
6404 | - if (ipx_hdr(skb)->ipx_type != IPX_TYPE_NCP) { |
6405 | + if (ipxhdr->ipx_type != IPX_TYPE_NCP) { |
6406 | /* The only protocol worth balancing in |
6407 | * this family since it has an "ARP" like |
6408 | * mechanism |
6409 | @@ -1448,9 +1466,11 @@ netdev_tx_t bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev) |
6410 | break; |
6411 | } |
6412 | |
6413 | + eth_data = eth_hdr(skb); |
6414 | hash_start = (char *)eth_data->h_dest; |
6415 | hash_size = ETH_ALEN; |
6416 | break; |
6417 | + } |
6418 | case ETH_P_ARP: |
6419 | do_tx_balance = false; |
6420 | if (bond_info->rlb_enabled) |
6421 | diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c |
6422 | index a7132c1593c3..7ed667b304d1 100644 |
6423 | --- a/drivers/net/dsa/b53/b53_common.c |
6424 | +++ b/drivers/net/dsa/b53/b53_common.c |
6425 | @@ -680,7 +680,7 @@ int b53_configure_vlan(struct dsa_switch *ds) |
6426 | b53_do_vlan_op(dev, VTA_CMD_CLEAR); |
6427 | } |
6428 | |
6429 | - b53_enable_vlan(dev, false, ds->vlan_filtering); |
6430 | + b53_enable_vlan(dev, dev->vlan_enabled, ds->vlan_filtering); |
6431 | |
6432 | b53_for_each_port(dev, i) |
6433 | b53_write16(dev, B53_VLAN_PAGE, |
6434 | diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c |
6435 | index 47b21096b577..fecd5e674e04 100644 |
6436 | --- a/drivers/net/dsa/bcm_sf2.c |
6437 | +++ b/drivers/net/dsa/bcm_sf2.c |
6438 | @@ -68,7 +68,9 @@ static void bcm_sf2_imp_setup(struct dsa_switch *ds, int port) |
6439 | |
6440 | /* Force link status for IMP port */ |
6441 | reg = core_readl(priv, offset); |
6442 | - reg |= (MII_SW_OR | LINK_STS | GMII_SPEED_UP_2G); |
6443 | + reg |= (MII_SW_OR | LINK_STS); |
6444 | + if (priv->type == BCM7278_DEVICE_ID) |
6445 | + reg |= GMII_SPEED_UP_2G; |
6446 | core_writel(priv, reg, offset); |
6447 | |
6448 | /* Enable Broadcast, Multicast, Unicast forwarding to IMP port */ |
6449 | diff --git a/drivers/net/dsa/microchip/ksz9477_spi.c b/drivers/net/dsa/microchip/ksz9477_spi.c |
6450 | index c5f64959a184..1142768969c2 100644 |
6451 | --- a/drivers/net/dsa/microchip/ksz9477_spi.c |
6452 | +++ b/drivers/net/dsa/microchip/ksz9477_spi.c |
6453 | @@ -101,6 +101,12 @@ static struct spi_driver ksz9477_spi_driver = { |
6454 | |
6455 | module_spi_driver(ksz9477_spi_driver); |
6456 | |
6457 | +MODULE_ALIAS("spi:ksz9477"); |
6458 | +MODULE_ALIAS("spi:ksz9897"); |
6459 | +MODULE_ALIAS("spi:ksz9893"); |
6460 | +MODULE_ALIAS("spi:ksz9563"); |
6461 | +MODULE_ALIAS("spi:ksz8563"); |
6462 | +MODULE_ALIAS("spi:ksz9567"); |
6463 | MODULE_AUTHOR("Woojung Huh <Woojung.Huh@microchip.com>"); |
6464 | MODULE_DESCRIPTION("Microchip KSZ9477 Series Switch SPI access Driver"); |
6465 | MODULE_LICENSE("GPL"); |
6466 | diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c |
6467 | index b4c664957266..4a27577e137b 100644 |
6468 | --- a/drivers/net/ethernet/broadcom/bcmsysport.c |
6469 | +++ b/drivers/net/ethernet/broadcom/bcmsysport.c |
6470 | @@ -2728,6 +2728,9 @@ static int __maybe_unused bcm_sysport_resume(struct device *d) |
6471 | |
6472 | umac_reset(priv); |
6473 | |
6474 | + /* Disable the UniMAC RX/TX */ |
6475 | + umac_enable_set(priv, CMD_RX_EN | CMD_TX_EN, 0); |
6476 | + |
6477 | /* We may have been suspended and never received a WOL event that |
6478 | * would turn off MPD detection, take care of that now |
6479 | */ |
6480 | diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c |
6481 | index cf292f7c3d3c..41297533b4a8 100644 |
6482 | --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c |
6483 | +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c |
6484 | @@ -7873,7 +7873,7 @@ static void bnxt_setup_msix(struct bnxt *bp) |
6485 | int tcs, i; |
6486 | |
6487 | tcs = netdev_get_num_tc(dev); |
6488 | - if (tcs > 1) { |
6489 | + if (tcs) { |
6490 | int i, off, count; |
6491 | |
6492 | for (i = 0; i < tcs; i++) { |
6493 | @@ -9273,10 +9273,6 @@ static void __bnxt_close_nic(struct bnxt *bp, bool irq_re_init, |
6494 | bnxt_debug_dev_exit(bp); |
6495 | bnxt_disable_napi(bp); |
6496 | del_timer_sync(&bp->timer); |
6497 | - if (test_bit(BNXT_STATE_IN_FW_RESET, &bp->state) && |
6498 | - pci_is_enabled(bp->pdev)) |
6499 | - pci_disable_device(bp->pdev); |
6500 | - |
6501 | bnxt_free_skbs(bp); |
6502 | |
6503 | /* Save ring stats before shutdown */ |
6504 | @@ -10052,8 +10048,15 @@ static void bnxt_fw_reset_close(struct bnxt *bp) |
6505 | { |
6506 | __bnxt_close_nic(bp, true, false); |
6507 | bnxt_ulp_irq_stop(bp); |
6508 | + /* When firmware is fatal state, disable PCI device to prevent |
6509 | + * any potential bad DMAs before freeing kernel memory. |
6510 | + */ |
6511 | + if (test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state)) |
6512 | + pci_disable_device(bp->pdev); |
6513 | bnxt_clear_int_mode(bp); |
6514 | bnxt_hwrm_func_drv_unrgtr(bp); |
6515 | + if (pci_is_enabled(bp->pdev)) |
6516 | + pci_disable_device(bp->pdev); |
6517 | bnxt_free_ctx_mem(bp); |
6518 | kfree(bp->ctx); |
6519 | bp->ctx = NULL; |
6520 | @@ -11359,9 +11362,9 @@ static void bnxt_remove_one(struct pci_dev *pdev) |
6521 | bnxt_sriov_disable(bp); |
6522 | |
6523 | bnxt_dl_fw_reporters_destroy(bp, true); |
6524 | - bnxt_dl_unregister(bp); |
6525 | pci_disable_pcie_error_reporting(pdev); |
6526 | unregister_netdev(dev); |
6527 | + bnxt_dl_unregister(bp); |
6528 | bnxt_shutdown_tc(bp); |
6529 | bnxt_cancel_sp_work(bp); |
6530 | bp->sp_event = 0; |
6531 | @@ -11850,11 +11853,14 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) |
6532 | bnxt_init_tc(bp); |
6533 | } |
6534 | |
6535 | + bnxt_dl_register(bp); |
6536 | + |
6537 | rc = register_netdev(dev); |
6538 | if (rc) |
6539 | - goto init_err_cleanup_tc; |
6540 | + goto init_err_cleanup; |
6541 | |
6542 | - bnxt_dl_register(bp); |
6543 | + if (BNXT_PF(bp)) |
6544 | + devlink_port_type_eth_set(&bp->dl_port, bp->dev); |
6545 | bnxt_dl_fw_reporters_create(bp); |
6546 | |
6547 | netdev_info(dev, "%s found at mem %lx, node addr %pM\n", |
6548 | @@ -11864,7 +11870,8 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) |
6549 | |
6550 | return 0; |
6551 | |
6552 | -init_err_cleanup_tc: |
6553 | +init_err_cleanup: |
6554 | + bnxt_dl_unregister(bp); |
6555 | bnxt_shutdown_tc(bp); |
6556 | bnxt_clear_int_mode(bp); |
6557 | |
6558 | diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c |
6559 | index 1e236e74ff2f..2d817ba0602c 100644 |
6560 | --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c |
6561 | +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c |
6562 | @@ -482,7 +482,6 @@ int bnxt_dl_register(struct bnxt *bp) |
6563 | netdev_err(bp->dev, "devlink_port_register failed"); |
6564 | goto err_dl_param_unreg; |
6565 | } |
6566 | - devlink_port_type_eth_set(&bp->dl_port, bp->dev); |
6567 | |
6568 | rc = devlink_port_params_register(&bp->dl_port, bnxt_dl_port_params, |
6569 | ARRAY_SIZE(bnxt_dl_port_params)); |
6570 | diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c |
6571 | index f496b248bda3..95a94507cec1 100644 |
6572 | --- a/drivers/net/ethernet/cadence/macb_main.c |
6573 | +++ b/drivers/net/ethernet/cadence/macb_main.c |
6574 | @@ -73,7 +73,11 @@ struct sifive_fu540_macb_mgmt { |
6575 | /* Max length of transmit frame must be a multiple of 8 bytes */ |
6576 | #define MACB_TX_LEN_ALIGN 8 |
6577 | #define MACB_MAX_TX_LEN ((unsigned int)((1 << MACB_TX_FRMLEN_SIZE) - 1) & ~((unsigned int)(MACB_TX_LEN_ALIGN - 1))) |
6578 | -#define GEM_MAX_TX_LEN ((unsigned int)((1 << GEM_TX_FRMLEN_SIZE) - 1) & ~((unsigned int)(MACB_TX_LEN_ALIGN - 1))) |
6579 | +/* Limit maximum TX length as per Cadence TSO errata. This is to avoid a |
6580 | + * false amba_error in TX path from the DMA assuming there is not enough |
6581 | + * space in the SRAM (16KB) even when there is. |
6582 | + */ |
6583 | +#define GEM_MAX_TX_LEN (unsigned int)(0x3FC0) |
6584 | |
6585 | #define GEM_MTU_MIN_SIZE ETH_MIN_MTU |
6586 | #define MACB_NETIF_LSO NETIF_F_TSO |
6587 | @@ -1664,16 +1668,14 @@ static netdev_features_t macb_features_check(struct sk_buff *skb, |
6588 | |
6589 | /* Validate LSO compatibility */ |
6590 | |
6591 | - /* there is only one buffer */ |
6592 | - if (!skb_is_nonlinear(skb)) |
6593 | + /* there is only one buffer or protocol is not UDP */ |
6594 | + if (!skb_is_nonlinear(skb) || (ip_hdr(skb)->protocol != IPPROTO_UDP)) |
6595 | return features; |
6596 | |
6597 | /* length of header */ |
6598 | hdrlen = skb_transport_offset(skb); |
6599 | - if (ip_hdr(skb)->protocol == IPPROTO_TCP) |
6600 | - hdrlen += tcp_hdrlen(skb); |
6601 | |
6602 | - /* For LSO: |
6603 | + /* For UFO only: |
6604 | * When software supplies two or more payload buffers all payload buffers |
6605 | * apart from the last must be a multiple of 8 bytes in size. |
6606 | */ |
6607 | diff --git a/drivers/net/ethernet/dec/tulip/dmfe.c b/drivers/net/ethernet/dec/tulip/dmfe.c |
6608 | index 0efdbd1a4a6f..32d470d4122a 100644 |
6609 | --- a/drivers/net/ethernet/dec/tulip/dmfe.c |
6610 | +++ b/drivers/net/ethernet/dec/tulip/dmfe.c |
6611 | @@ -2214,15 +2214,16 @@ static int __init dmfe_init_module(void) |
6612 | if (cr6set) |
6613 | dmfe_cr6_user_set = cr6set; |
6614 | |
6615 | - switch(mode) { |
6616 | - case DMFE_10MHF: |
6617 | + switch (mode) { |
6618 | + case DMFE_10MHF: |
6619 | case DMFE_100MHF: |
6620 | case DMFE_10MFD: |
6621 | case DMFE_100MFD: |
6622 | case DMFE_1M_HPNA: |
6623 | dmfe_media_mode = mode; |
6624 | break; |
6625 | - default:dmfe_media_mode = DMFE_AUTO; |
6626 | + default: |
6627 | + dmfe_media_mode = DMFE_AUTO; |
6628 | break; |
6629 | } |
6630 | |
6631 | diff --git a/drivers/net/ethernet/dec/tulip/uli526x.c b/drivers/net/ethernet/dec/tulip/uli526x.c |
6632 | index b1f30b194300..117ffe08800d 100644 |
6633 | --- a/drivers/net/ethernet/dec/tulip/uli526x.c |
6634 | +++ b/drivers/net/ethernet/dec/tulip/uli526x.c |
6635 | @@ -1809,8 +1809,8 @@ static int __init uli526x_init_module(void) |
6636 | if (cr6set) |
6637 | uli526x_cr6_user_set = cr6set; |
6638 | |
6639 | - switch (mode) { |
6640 | - case ULI526X_10MHF: |
6641 | + switch (mode) { |
6642 | + case ULI526X_10MHF: |
6643 | case ULI526X_100MHF: |
6644 | case ULI526X_10MFD: |
6645 | case ULI526X_100MFD: |
6646 | diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c |
6647 | index fcbe01f61aa4..e130233b5085 100644 |
6648 | --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c |
6649 | +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c |
6650 | @@ -2483,6 +2483,9 @@ static void dpaa_adjust_link(struct net_device *net_dev) |
6651 | mac_dev->adjust_link(mac_dev); |
6652 | } |
6653 | |
6654 | +/* The Aquantia PHYs are capable of performing rate adaptation */ |
6655 | +#define PHY_VEND_AQUANTIA 0x03a1b400 |
6656 | + |
6657 | static int dpaa_phy_init(struct net_device *net_dev) |
6658 | { |
6659 | __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, }; |
6660 | @@ -2501,9 +2504,14 @@ static int dpaa_phy_init(struct net_device *net_dev) |
6661 | return -ENODEV; |
6662 | } |
6663 | |
6664 | - /* Remove any features not supported by the controller */ |
6665 | - ethtool_convert_legacy_u32_to_link_mode(mask, mac_dev->if_support); |
6666 | - linkmode_and(phy_dev->supported, phy_dev->supported, mask); |
6667 | + /* Unless the PHY is capable of rate adaptation */ |
6668 | + if (mac_dev->phy_if != PHY_INTERFACE_MODE_XGMII || |
6669 | + ((phy_dev->drv->phy_id & GENMASK(31, 10)) != PHY_VEND_AQUANTIA)) { |
6670 | + /* remove any features not supported by the controller */ |
6671 | + ethtool_convert_legacy_u32_to_link_mode(mask, |
6672 | + mac_dev->if_support); |
6673 | + linkmode_and(phy_dev->supported, phy_dev->supported, mask); |
6674 | + } |
6675 | |
6676 | phy_support_asym_pause(phy_dev); |
6677 | |
6678 | diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c |
6679 | index e49820675c8c..6b1a81df1465 100644 |
6680 | --- a/drivers/net/ethernet/marvell/mvneta.c |
6681 | +++ b/drivers/net/ethernet/marvell/mvneta.c |
6682 | @@ -388,6 +388,8 @@ struct mvneta_pcpu_stats { |
6683 | struct u64_stats_sync syncp; |
6684 | u64 rx_packets; |
6685 | u64 rx_bytes; |
6686 | + u64 rx_dropped; |
6687 | + u64 rx_errors; |
6688 | u64 tx_packets; |
6689 | u64 tx_bytes; |
6690 | }; |
6691 | @@ -706,6 +708,8 @@ mvneta_get_stats64(struct net_device *dev, |
6692 | struct mvneta_pcpu_stats *cpu_stats; |
6693 | u64 rx_packets; |
6694 | u64 rx_bytes; |
6695 | + u64 rx_dropped; |
6696 | + u64 rx_errors; |
6697 | u64 tx_packets; |
6698 | u64 tx_bytes; |
6699 | |
6700 | @@ -714,19 +718,20 @@ mvneta_get_stats64(struct net_device *dev, |
6701 | start = u64_stats_fetch_begin_irq(&cpu_stats->syncp); |
6702 | rx_packets = cpu_stats->rx_packets; |
6703 | rx_bytes = cpu_stats->rx_bytes; |
6704 | + rx_dropped = cpu_stats->rx_dropped; |
6705 | + rx_errors = cpu_stats->rx_errors; |
6706 | tx_packets = cpu_stats->tx_packets; |
6707 | tx_bytes = cpu_stats->tx_bytes; |
6708 | } while (u64_stats_fetch_retry_irq(&cpu_stats->syncp, start)); |
6709 | |
6710 | stats->rx_packets += rx_packets; |
6711 | stats->rx_bytes += rx_bytes; |
6712 | + stats->rx_dropped += rx_dropped; |
6713 | + stats->rx_errors += rx_errors; |
6714 | stats->tx_packets += tx_packets; |
6715 | stats->tx_bytes += tx_bytes; |
6716 | } |
6717 | |
6718 | - stats->rx_errors = dev->stats.rx_errors; |
6719 | - stats->rx_dropped = dev->stats.rx_dropped; |
6720 | - |
6721 | stats->tx_dropped = dev->stats.tx_dropped; |
6722 | } |
6723 | |
6724 | @@ -1703,8 +1708,14 @@ static u32 mvneta_txq_desc_csum(int l3_offs, int l3_proto, |
6725 | static void mvneta_rx_error(struct mvneta_port *pp, |
6726 | struct mvneta_rx_desc *rx_desc) |
6727 | { |
6728 | + struct mvneta_pcpu_stats *stats = this_cpu_ptr(pp->stats); |
6729 | u32 status = rx_desc->status; |
6730 | |
6731 | + /* update per-cpu counter */ |
6732 | + u64_stats_update_begin(&stats->syncp); |
6733 | + stats->rx_errors++; |
6734 | + u64_stats_update_end(&stats->syncp); |
6735 | + |
6736 | switch (status & MVNETA_RXD_ERR_CODE_MASK) { |
6737 | case MVNETA_RXD_ERR_CRC: |
6738 | netdev_err(pp->dev, "bad rx status %08x (crc error), size=%d\n", |
6739 | @@ -1965,7 +1976,6 @@ static int mvneta_rx_swbm(struct napi_struct *napi, |
6740 | /* Check errors only for FIRST descriptor */ |
6741 | if (rx_status & MVNETA_RXD_ERR_SUMMARY) { |
6742 | mvneta_rx_error(pp, rx_desc); |
6743 | - dev->stats.rx_errors++; |
6744 | /* leave the descriptor untouched */ |
6745 | continue; |
6746 | } |
6747 | @@ -1976,11 +1986,17 @@ static int mvneta_rx_swbm(struct napi_struct *napi, |
6748 | skb_size = max(rx_copybreak, rx_header_size); |
6749 | rxq->skb = netdev_alloc_skb_ip_align(dev, skb_size); |
6750 | if (unlikely(!rxq->skb)) { |
6751 | + struct mvneta_pcpu_stats *stats = this_cpu_ptr(pp->stats); |
6752 | + |
6753 | netdev_err(dev, |
6754 | "Can't allocate skb on queue %d\n", |
6755 | rxq->id); |
6756 | - dev->stats.rx_dropped++; |
6757 | + |
6758 | rxq->skb_alloc_err++; |
6759 | + |
6760 | + u64_stats_update_begin(&stats->syncp); |
6761 | + stats->rx_dropped++; |
6762 | + u64_stats_update_end(&stats->syncp); |
6763 | continue; |
6764 | } |
6765 | copy_size = min(skb_size, rx_bytes); |
6766 | @@ -2137,7 +2153,6 @@ err_drop_frame_ret_pool: |
6767 | mvneta_bm_pool_put_bp(pp->bm_priv, bm_pool, |
6768 | rx_desc->buf_phys_addr); |
6769 | err_drop_frame: |
6770 | - dev->stats.rx_errors++; |
6771 | mvneta_rx_error(pp, rx_desc); |
6772 | /* leave the descriptor untouched */ |
6773 | continue; |
6774 | diff --git a/drivers/net/ethernet/mellanox/mlx5/core/accel/tls.h b/drivers/net/ethernet/mellanox/mlx5/core/accel/tls.h |
6775 | index d787bc0a4155..e09bc3858d57 100644 |
6776 | --- a/drivers/net/ethernet/mellanox/mlx5/core/accel/tls.h |
6777 | +++ b/drivers/net/ethernet/mellanox/mlx5/core/accel/tls.h |
6778 | @@ -45,7 +45,7 @@ void mlx5_ktls_destroy_key(struct mlx5_core_dev *mdev, u32 key_id); |
6779 | |
6780 | static inline bool mlx5_accel_is_ktls_device(struct mlx5_core_dev *mdev) |
6781 | { |
6782 | - if (!MLX5_CAP_GEN(mdev, tls)) |
6783 | + if (!MLX5_CAP_GEN(mdev, tls_tx)) |
6784 | return false; |
6785 | |
6786 | if (!MLX5_CAP_GEN(mdev, log_max_dek)) |
6787 | diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/tls_rxtx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/tls_rxtx.c |
6788 | index 71384ad1a443..ef1ed15a53b4 100644 |
6789 | --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/tls_rxtx.c |
6790 | +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/tls_rxtx.c |
6791 | @@ -269,7 +269,7 @@ struct sk_buff *mlx5e_tls_handle_tx_skb(struct net_device *netdev, |
6792 | int datalen; |
6793 | u32 skb_seq; |
6794 | |
6795 | - if (MLX5_CAP_GEN(sq->channel->mdev, tls)) { |
6796 | + if (MLX5_CAP_GEN(sq->channel->mdev, tls_tx)) { |
6797 | skb = mlx5e_ktls_handle_tx_skb(netdev, sq, skb, wqe, pi); |
6798 | goto out; |
6799 | } |
6800 | diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c b/drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c |
6801 | index c76da309506b..72232e570af7 100644 |
6802 | --- a/drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c |
6803 | +++ b/drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c |
6804 | @@ -850,6 +850,7 @@ void mlx5_fpga_ipsec_delete_sa_ctx(void *context) |
6805 | mutex_lock(&fpga_xfrm->lock); |
6806 | if (!--fpga_xfrm->num_rules) { |
6807 | mlx5_fpga_ipsec_release_sa_ctx(fpga_xfrm->sa_ctx); |
6808 | + kfree(fpga_xfrm->sa_ctx); |
6809 | fpga_xfrm->sa_ctx = NULL; |
6810 | } |
6811 | mutex_unlock(&fpga_xfrm->lock); |
6812 | @@ -1478,7 +1479,7 @@ int mlx5_fpga_esp_modify_xfrm(struct mlx5_accel_esp_xfrm *xfrm, |
6813 | if (!memcmp(&xfrm->attrs, attrs, sizeof(xfrm->attrs))) |
6814 | return 0; |
6815 | |
6816 | - if (!mlx5_fpga_esp_validate_xfrm_attrs(mdev, attrs)) { |
6817 | + if (mlx5_fpga_esp_validate_xfrm_attrs(mdev, attrs)) { |
6818 | mlx5_core_warn(mdev, "Tried to create an esp with unsupported attrs\n"); |
6819 | return -EOPNOTSUPP; |
6820 | } |
6821 | diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c |
6822 | index 791e14ac26f4..86e6bbb57482 100644 |
6823 | --- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c |
6824 | +++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.c |
6825 | @@ -1555,16 +1555,16 @@ struct match_list_head { |
6826 | struct match_list first; |
6827 | }; |
6828 | |
6829 | -static void free_match_list(struct match_list_head *head) |
6830 | +static void free_match_list(struct match_list_head *head, bool ft_locked) |
6831 | { |
6832 | if (!list_empty(&head->list)) { |
6833 | struct match_list *iter, *match_tmp; |
6834 | |
6835 | list_del(&head->first.list); |
6836 | - tree_put_node(&head->first.g->node, false); |
6837 | + tree_put_node(&head->first.g->node, ft_locked); |
6838 | list_for_each_entry_safe(iter, match_tmp, &head->list, |
6839 | list) { |
6840 | - tree_put_node(&iter->g->node, false); |
6841 | + tree_put_node(&iter->g->node, ft_locked); |
6842 | list_del(&iter->list); |
6843 | kfree(iter); |
6844 | } |
6845 | @@ -1573,7 +1573,8 @@ static void free_match_list(struct match_list_head *head) |
6846 | |
6847 | static int build_match_list(struct match_list_head *match_head, |
6848 | struct mlx5_flow_table *ft, |
6849 | - const struct mlx5_flow_spec *spec) |
6850 | + const struct mlx5_flow_spec *spec, |
6851 | + bool ft_locked) |
6852 | { |
6853 | struct rhlist_head *tmp, *list; |
6854 | struct mlx5_flow_group *g; |
6855 | @@ -1598,7 +1599,7 @@ static int build_match_list(struct match_list_head *match_head, |
6856 | |
6857 | curr_match = kmalloc(sizeof(*curr_match), GFP_ATOMIC); |
6858 | if (!curr_match) { |
6859 | - free_match_list(match_head); |
6860 | + free_match_list(match_head, ft_locked); |
6861 | err = -ENOMEM; |
6862 | goto out; |
6863 | } |
6864 | @@ -1778,7 +1779,7 @@ search_again_locked: |
6865 | version = atomic_read(&ft->node.version); |
6866 | |
6867 | /* Collect all fgs which has a matching match_criteria */ |
6868 | - err = build_match_list(&match_head, ft, spec); |
6869 | + err = build_match_list(&match_head, ft, spec, take_write); |
6870 | if (err) { |
6871 | if (take_write) |
6872 | up_write_ref_node(&ft->node, false); |
6873 | @@ -1792,7 +1793,7 @@ search_again_locked: |
6874 | |
6875 | rule = try_add_to_existing_fg(ft, &match_head.list, spec, flow_act, dest, |
6876 | dest_num, version); |
6877 | - free_match_list(&match_head); |
6878 | + free_match_list(&match_head, take_write); |
6879 | if (!IS_ERR(rule) || |
6880 | (PTR_ERR(rule) != -ENOENT && PTR_ERR(rule) != -EAGAIN)) { |
6881 | if (take_write) |
6882 | diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fw.c b/drivers/net/ethernet/mellanox/mlx5/core/fw.c |
6883 | index a19790dee7b2..13e86f0b42f5 100644 |
6884 | --- a/drivers/net/ethernet/mellanox/mlx5/core/fw.c |
6885 | +++ b/drivers/net/ethernet/mellanox/mlx5/core/fw.c |
6886 | @@ -239,7 +239,7 @@ int mlx5_query_hca_caps(struct mlx5_core_dev *dev) |
6887 | return err; |
6888 | } |
6889 | |
6890 | - if (MLX5_CAP_GEN(dev, tls)) { |
6891 | + if (MLX5_CAP_GEN(dev, tls_tx)) { |
6892 | err = mlx5_core_get_caps(dev, MLX5_CAP_TLS); |
6893 | if (err) |
6894 | return err; |
6895 | diff --git a/drivers/net/ethernet/pensando/ionic/ionic_if.h b/drivers/net/ethernet/pensando/ionic/ionic_if.h |
6896 | index 5bfdda19f64d..d8745f87f065 100644 |
6897 | --- a/drivers/net/ethernet/pensando/ionic/ionic_if.h |
6898 | +++ b/drivers/net/ethernet/pensando/ionic/ionic_if.h |
6899 | @@ -862,7 +862,7 @@ struct ionic_rxq_comp { |
6900 | #define IONIC_RXQ_COMP_CSUM_F_VLAN 0x40 |
6901 | #define IONIC_RXQ_COMP_CSUM_F_CALC 0x80 |
6902 | u8 pkt_type_color; |
6903 | -#define IONIC_RXQ_COMP_PKT_TYPE_MASK 0x0f |
6904 | +#define IONIC_RXQ_COMP_PKT_TYPE_MASK 0x7f |
6905 | }; |
6906 | |
6907 | enum ionic_pkt_type { |
6908 | diff --git a/drivers/net/ethernet/qlogic/qed/qed_ptp.c b/drivers/net/ethernet/qlogic/qed/qed_ptp.c |
6909 | index 0dacf2c18c09..3e613058e225 100644 |
6910 | --- a/drivers/net/ethernet/qlogic/qed/qed_ptp.c |
6911 | +++ b/drivers/net/ethernet/qlogic/qed/qed_ptp.c |
6912 | @@ -44,8 +44,8 @@ |
6913 | /* Add/subtract the Adjustment_Value when making a Drift adjustment */ |
6914 | #define QED_DRIFT_CNTR_DIRECTION_SHIFT 31 |
6915 | #define QED_TIMESTAMP_MASK BIT(16) |
6916 | -/* Param mask for Hardware to detect/timestamp the unicast PTP packets */ |
6917 | -#define QED_PTP_UCAST_PARAM_MASK 0xF |
6918 | +/* Param mask for Hardware to detect/timestamp the L2/L4 unicast PTP packets */ |
6919 | +#define QED_PTP_UCAST_PARAM_MASK 0x70F |
6920 | |
6921 | static enum qed_resc_lock qed_ptcdev_to_resc(struct qed_hwfn *p_hwfn) |
6922 | { |
6923 | diff --git a/drivers/net/ethernet/smsc/smc911x.c b/drivers/net/ethernet/smsc/smc911x.c |
6924 | index 8d88e4083456..7b65e79d6ae9 100644 |
6925 | --- a/drivers/net/ethernet/smsc/smc911x.c |
6926 | +++ b/drivers/net/ethernet/smsc/smc911x.c |
6927 | @@ -936,7 +936,7 @@ static void smc911x_phy_configure(struct work_struct *work) |
6928 | if (lp->ctl_rspeed != 100) |
6929 | my_ad_caps &= ~(ADVERTISE_100BASE4|ADVERTISE_100FULL|ADVERTISE_100HALF); |
6930 | |
6931 | - if (!lp->ctl_rfduplx) |
6932 | + if (!lp->ctl_rfduplx) |
6933 | my_ad_caps &= ~(ADVERTISE_100FULL|ADVERTISE_10FULL); |
6934 | |
6935 | /* Update our Auto-Neg Advertisement Register */ |
6936 | diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c |
6937 | index 7ec895407d23..e0a5fe83d8e0 100644 |
6938 | --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c |
6939 | +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c |
6940 | @@ -413,6 +413,7 @@ static int ethqos_configure(struct qcom_ethqos *ethqos) |
6941 | dll_lock = rgmii_readl(ethqos, SDC4_STATUS); |
6942 | if (dll_lock & SDC4_STATUS_DLL_LOCK) |
6943 | break; |
6944 | + retry--; |
6945 | } while (retry > 0); |
6946 | if (!retry) |
6947 | dev_err(ðqos->pdev->dev, |
6948 | diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c |
6949 | index 06dd65c419c4..582176d869c3 100644 |
6950 | --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c |
6951 | +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c |
6952 | @@ -4763,6 +4763,7 @@ int stmmac_suspend(struct device *dev) |
6953 | { |
6954 | struct net_device *ndev = dev_get_drvdata(dev); |
6955 | struct stmmac_priv *priv = netdev_priv(ndev); |
6956 | + u32 chan; |
6957 | |
6958 | if (!ndev || !netif_running(ndev)) |
6959 | return 0; |
6960 | @@ -4776,6 +4777,9 @@ int stmmac_suspend(struct device *dev) |
6961 | |
6962 | stmmac_disable_all_queues(priv); |
6963 | |
6964 | + for (chan = 0; chan < priv->plat->tx_queues_to_use; chan++) |
6965 | + del_timer_sync(&priv->tx_queue[chan].txtimer); |
6966 | + |
6967 | /* Stop TX/RX DMA */ |
6968 | stmmac_stop_all_dma(priv); |
6969 | |
6970 | diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c |
6971 | index 9b3ba98726d7..3a53d222bfcc 100644 |
6972 | --- a/drivers/net/gtp.c |
6973 | +++ b/drivers/net/gtp.c |
6974 | @@ -767,12 +767,12 @@ static int gtp_hashtable_new(struct gtp_dev *gtp, int hsize) |
6975 | int i; |
6976 | |
6977 | gtp->addr_hash = kmalloc_array(hsize, sizeof(struct hlist_head), |
6978 | - GFP_KERNEL); |
6979 | + GFP_KERNEL | __GFP_NOWARN); |
6980 | if (gtp->addr_hash == NULL) |
6981 | return -ENOMEM; |
6982 | |
6983 | gtp->tid_hash = kmalloc_array(hsize, sizeof(struct hlist_head), |
6984 | - GFP_KERNEL); |
6985 | + GFP_KERNEL | __GFP_NOWARN); |
6986 | if (gtp->tid_hash == NULL) |
6987 | goto err1; |
6988 | |
6989 | diff --git a/drivers/net/netdevsim/dev.c b/drivers/net/netdevsim/dev.c |
6990 | index 44c2d857a7fa..91b302f0192f 100644 |
6991 | --- a/drivers/net/netdevsim/dev.c |
6992 | +++ b/drivers/net/netdevsim/dev.c |
6993 | @@ -73,7 +73,7 @@ static const struct file_operations nsim_dev_take_snapshot_fops = { |
6994 | |
6995 | static int nsim_dev_debugfs_init(struct nsim_dev *nsim_dev) |
6996 | { |
6997 | - char dev_ddir_name[16]; |
6998 | + char dev_ddir_name[sizeof(DRV_NAME) + 10]; |
6999 | |
7000 | sprintf(dev_ddir_name, DRV_NAME "%u", nsim_dev->nsim_bus_dev->dev.id); |
7001 | nsim_dev->ddir = debugfs_create_dir(dev_ddir_name, nsim_dev_ddir); |
7002 | diff --git a/drivers/net/ppp/ppp_async.c b/drivers/net/ppp/ppp_async.c |
7003 | index a7b9cf3269bf..29a0917a81e6 100644 |
7004 | --- a/drivers/net/ppp/ppp_async.c |
7005 | +++ b/drivers/net/ppp/ppp_async.c |
7006 | @@ -874,15 +874,15 @@ ppp_async_input(struct asyncppp *ap, const unsigned char *buf, |
7007 | skb = dev_alloc_skb(ap->mru + PPP_HDRLEN + 2); |
7008 | if (!skb) |
7009 | goto nomem; |
7010 | - ap->rpkt = skb; |
7011 | - } |
7012 | - if (skb->len == 0) { |
7013 | - /* Try to get the payload 4-byte aligned. |
7014 | - * This should match the |
7015 | - * PPP_ALLSTATIONS/PPP_UI/compressed tests in |
7016 | - * process_input_packet, but we do not have |
7017 | - * enough chars here to test buf[1] and buf[2]. |
7018 | - */ |
7019 | + ap->rpkt = skb; |
7020 | + } |
7021 | + if (skb->len == 0) { |
7022 | + /* Try to get the payload 4-byte aligned. |
7023 | + * This should match the |
7024 | + * PPP_ALLSTATIONS/PPP_UI/compressed tests in |
7025 | + * process_input_packet, but we do not have |
7026 | + * enough chars here to test buf[1] and buf[2]. |
7027 | + */ |
7028 | if (buf[0] != PPP_ALLSTATIONS) |
7029 | skb_reserve(skb, 2 + (buf[0] & 1)); |
7030 | } |
7031 | diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c |
7032 | index 7cdfde9b3dea..575ed19e9195 100644 |
7033 | --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c |
7034 | +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c |
7035 | @@ -430,6 +430,7 @@ fail: |
7036 | usb_free_urb(req->urb); |
7037 | list_del(q->next); |
7038 | } |
7039 | + kfree(reqs); |
7040 | return NULL; |
7041 | |
7042 | } |
7043 | diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c |
7044 | index b3768d5d852a..8ad2d889179c 100644 |
7045 | --- a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c |
7046 | +++ b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c |
7047 | @@ -3321,6 +3321,10 @@ static int iwl_mvm_send_sta_igtk(struct iwl_mvm *mvm, |
7048 | igtk_cmd.sta_id = cpu_to_le32(sta_id); |
7049 | |
7050 | if (remove_key) { |
7051 | + /* This is a valid situation for IGTK */ |
7052 | + if (sta_id == IWL_MVM_INVALID_STA) |
7053 | + return 0; |
7054 | + |
7055 | igtk_cmd.ctrl_flags |= cpu_to_le32(STA_KEY_NOT_VALID); |
7056 | } else { |
7057 | struct ieee80211_key_seq seq; |
7058 | @@ -3575,9 +3579,9 @@ int iwl_mvm_remove_sta_key(struct iwl_mvm *mvm, |
7059 | IWL_DEBUG_WEP(mvm, "mvm remove dynamic key: idx=%d sta=%d\n", |
7060 | keyconf->keyidx, sta_id); |
7061 | |
7062 | - if (mvm_sta && (keyconf->cipher == WLAN_CIPHER_SUITE_AES_CMAC || |
7063 | - keyconf->cipher == WLAN_CIPHER_SUITE_BIP_GMAC_128 || |
7064 | - keyconf->cipher == WLAN_CIPHER_SUITE_BIP_GMAC_256)) |
7065 | + if (keyconf->cipher == WLAN_CIPHER_SUITE_AES_CMAC || |
7066 | + keyconf->cipher == WLAN_CIPHER_SUITE_BIP_GMAC_128 || |
7067 | + keyconf->cipher == WLAN_CIPHER_SUITE_BIP_GMAC_256) |
7068 | return iwl_mvm_send_sta_igtk(mvm, keyconf, sta_id, true); |
7069 | |
7070 | if (!__test_and_clear_bit(keyconf->hw_key_idx, mvm->fw_key_table)) { |
7071 | diff --git a/drivers/net/wireless/marvell/mwifiex/sta_ioctl.c b/drivers/net/wireless/marvell/mwifiex/sta_ioctl.c |
7072 | index 6dd835f1efc2..fbfa0b15d0c8 100644 |
7073 | --- a/drivers/net/wireless/marvell/mwifiex/sta_ioctl.c |
7074 | +++ b/drivers/net/wireless/marvell/mwifiex/sta_ioctl.c |
7075 | @@ -232,6 +232,7 @@ static int mwifiex_process_country_ie(struct mwifiex_private *priv, |
7076 | |
7077 | if (country_ie_len > |
7078 | (IEEE80211_COUNTRY_STRING_LEN + MWIFIEX_MAX_TRIPLET_802_11D)) { |
7079 | + rcu_read_unlock(); |
7080 | mwifiex_dbg(priv->adapter, ERROR, |
7081 | "11D: country_ie_len overflow!, deauth AP\n"); |
7082 | return -EINVAL; |
7083 | diff --git a/drivers/nfc/pn544/pn544.c b/drivers/nfc/pn544/pn544.c |
7084 | index cda996f6954e..2b83156efe3f 100644 |
7085 | --- a/drivers/nfc/pn544/pn544.c |
7086 | +++ b/drivers/nfc/pn544/pn544.c |
7087 | @@ -693,7 +693,7 @@ static int pn544_hci_check_presence(struct nfc_hci_dev *hdev, |
7088 | target->nfcid1_len != 10) |
7089 | return -EOPNOTSUPP; |
7090 | |
7091 | - return nfc_hci_send_cmd(hdev, NFC_HCI_RF_READER_A_GATE, |
7092 | + return nfc_hci_send_cmd(hdev, NFC_HCI_RF_READER_A_GATE, |
7093 | PN544_RF_READER_CMD_ACTIVATE_NEXT, |
7094 | target->nfcid1, target->nfcid1_len, NULL); |
7095 | } else if (target->supported_protocols & (NFC_PROTO_JEWEL_MASK | |
7096 | diff --git a/drivers/nvme/target/fabrics-cmd.c b/drivers/nvme/target/fabrics-cmd.c |
7097 | index d16b55ffe79f..4e9004fe5c6f 100644 |
7098 | --- a/drivers/nvme/target/fabrics-cmd.c |
7099 | +++ b/drivers/nvme/target/fabrics-cmd.c |
7100 | @@ -105,6 +105,7 @@ static u16 nvmet_install_queue(struct nvmet_ctrl *ctrl, struct nvmet_req *req) |
7101 | u16 qid = le16_to_cpu(c->qid); |
7102 | u16 sqsize = le16_to_cpu(c->sqsize); |
7103 | struct nvmet_ctrl *old; |
7104 | + u16 ret; |
7105 | |
7106 | old = cmpxchg(&req->sq->ctrl, NULL, ctrl); |
7107 | if (old) { |
7108 | @@ -115,7 +116,8 @@ static u16 nvmet_install_queue(struct nvmet_ctrl *ctrl, struct nvmet_req *req) |
7109 | if (!sqsize) { |
7110 | pr_warn("queue size zero!\n"); |
7111 | req->error_loc = offsetof(struct nvmf_connect_command, sqsize); |
7112 | - return NVME_SC_CONNECT_INVALID_PARAM | NVME_SC_DNR; |
7113 | + ret = NVME_SC_CONNECT_INVALID_PARAM | NVME_SC_DNR; |
7114 | + goto err; |
7115 | } |
7116 | |
7117 | /* note: convert queue size from 0's-based value to 1's-based value */ |
7118 | @@ -128,16 +130,19 @@ static u16 nvmet_install_queue(struct nvmet_ctrl *ctrl, struct nvmet_req *req) |
7119 | } |
7120 | |
7121 | if (ctrl->ops->install_queue) { |
7122 | - u16 ret = ctrl->ops->install_queue(req->sq); |
7123 | - |
7124 | + ret = ctrl->ops->install_queue(req->sq); |
7125 | if (ret) { |
7126 | pr_err("failed to install queue %d cntlid %d ret %x\n", |
7127 | - qid, ret, ctrl->cntlid); |
7128 | - return ret; |
7129 | + qid, ctrl->cntlid, ret); |
7130 | + goto err; |
7131 | } |
7132 | } |
7133 | |
7134 | return 0; |
7135 | + |
7136 | +err: |
7137 | + req->sq->ctrl = NULL; |
7138 | + return ret; |
7139 | } |
7140 | |
7141 | static void nvmet_execute_admin_connect(struct nvmet_req *req) |
7142 | diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c |
7143 | index 057d1ff87d5d..960542dea5ad 100644 |
7144 | --- a/drivers/nvmem/core.c |
7145 | +++ b/drivers/nvmem/core.c |
7146 | @@ -110,7 +110,7 @@ static void nvmem_cell_drop(struct nvmem_cell *cell) |
7147 | list_del(&cell->node); |
7148 | mutex_unlock(&nvmem_mutex); |
7149 | of_node_put(cell->np); |
7150 | - kfree(cell->name); |
7151 | + kfree_const(cell->name); |
7152 | kfree(cell); |
7153 | } |
7154 | |
7155 | @@ -137,7 +137,9 @@ static int nvmem_cell_info_to_nvmem_cell(struct nvmem_device *nvmem, |
7156 | cell->nvmem = nvmem; |
7157 | cell->offset = info->offset; |
7158 | cell->bytes = info->bytes; |
7159 | - cell->name = info->name; |
7160 | + cell->name = kstrdup_const(info->name, GFP_KERNEL); |
7161 | + if (!cell->name) |
7162 | + return -ENOMEM; |
7163 | |
7164 | cell->bit_offset = info->bit_offset; |
7165 | cell->nbits = info->nbits; |
7166 | @@ -327,7 +329,7 @@ static int nvmem_add_cells_from_of(struct nvmem_device *nvmem) |
7167 | dev_err(dev, "cell %s unaligned to nvmem stride %d\n", |
7168 | cell->name, nvmem->stride); |
7169 | /* Cells already added will be freed later. */ |
7170 | - kfree(cell->name); |
7171 | + kfree_const(cell->name); |
7172 | kfree(cell); |
7173 | return -EINVAL; |
7174 | } |
7175 | diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig |
7176 | index 37c2ccbefecd..d91618641be6 100644 |
7177 | --- a/drivers/of/Kconfig |
7178 | +++ b/drivers/of/Kconfig |
7179 | @@ -103,4 +103,8 @@ config OF_OVERLAY |
7180 | config OF_NUMA |
7181 | bool |
7182 | |
7183 | +config OF_DMA_DEFAULT_COHERENT |
7184 | + # arches should select this if DMA is coherent by default for OF devices |
7185 | + bool |
7186 | + |
7187 | endif # OF |
7188 | diff --git a/drivers/of/address.c b/drivers/of/address.c |
7189 | index 978427a9d5e6..8f74c4626e0e 100644 |
7190 | --- a/drivers/of/address.c |
7191 | +++ b/drivers/of/address.c |
7192 | @@ -998,12 +998,16 @@ EXPORT_SYMBOL_GPL(of_dma_get_range); |
7193 | * @np: device node |
7194 | * |
7195 | * It returns true if "dma-coherent" property was found |
7196 | - * for this device in DT. |
7197 | + * for this device in the DT, or if DMA is coherent by |
7198 | + * default for OF devices on the current platform. |
7199 | */ |
7200 | bool of_dma_is_coherent(struct device_node *np) |
7201 | { |
7202 | struct device_node *node = of_node_get(np); |
7203 | |
7204 | + if (IS_ENABLED(CONFIG_OF_DMA_DEFAULT_COHERENT)) |
7205 | + return true; |
7206 | + |
7207 | while (node) { |
7208 | if (of_property_read_bool(node, "dma-coherent")) { |
7209 | of_node_put(node); |
7210 | diff --git a/drivers/pci/controller/dwc/pci-keystone.c b/drivers/pci/controller/dwc/pci-keystone.c |
7211 | index af677254a072..c8c702c494a2 100644 |
7212 | --- a/drivers/pci/controller/dwc/pci-keystone.c |
7213 | +++ b/drivers/pci/controller/dwc/pci-keystone.c |
7214 | @@ -422,7 +422,7 @@ static void ks_pcie_setup_rc_app_regs(struct keystone_pcie *ks_pcie) |
7215 | lower_32_bits(start) | OB_ENABLEN); |
7216 | ks_pcie_app_writel(ks_pcie, OB_OFFSET_HI(i), |
7217 | upper_32_bits(start)); |
7218 | - start += OB_WIN_SIZE; |
7219 | + start += OB_WIN_SIZE * SZ_1M; |
7220 | } |
7221 | |
7222 | val = ks_pcie_app_readl(ks_pcie, CMD_STATUS); |
7223 | @@ -510,7 +510,7 @@ static void ks_pcie_stop_link(struct dw_pcie *pci) |
7224 | /* Disable Link training */ |
7225 | val = ks_pcie_app_readl(ks_pcie, CMD_STATUS); |
7226 | val &= ~LTSSM_EN_VAL; |
7227 | - ks_pcie_app_writel(ks_pcie, CMD_STATUS, LTSSM_EN_VAL | val); |
7228 | + ks_pcie_app_writel(ks_pcie, CMD_STATUS, val); |
7229 | } |
7230 | |
7231 | static int ks_pcie_start_link(struct dw_pcie *pci) |
7232 | @@ -1354,7 +1354,7 @@ static int __init ks_pcie_probe(struct platform_device *pdev) |
7233 | ret = of_property_read_u32(np, "num-viewport", &num_viewport); |
7234 | if (ret < 0) { |
7235 | dev_err(dev, "unable to read *num-viewport* property\n"); |
7236 | - return ret; |
7237 | + goto err_get_sync; |
7238 | } |
7239 | |
7240 | /* |
7241 | diff --git a/drivers/pci/controller/pci-tegra.c b/drivers/pci/controller/pci-tegra.c |
7242 | index 673a1725ef38..090b632965e2 100644 |
7243 | --- a/drivers/pci/controller/pci-tegra.c |
7244 | +++ b/drivers/pci/controller/pci-tegra.c |
7245 | @@ -2798,7 +2798,7 @@ static int tegra_pcie_probe(struct platform_device *pdev) |
7246 | |
7247 | pm_runtime_enable(pcie->dev); |
7248 | err = pm_runtime_get_sync(pcie->dev); |
7249 | - if (err) { |
7250 | + if (err < 0) { |
7251 | dev_err(dev, "fail to enable pcie controller: %d\n", err); |
7252 | goto teardown_msi; |
7253 | } |
7254 | diff --git a/drivers/phy/qualcomm/phy-qcom-apq8064-sata.c b/drivers/phy/qualcomm/phy-qcom-apq8064-sata.c |
7255 | index 42bc5150dd92..febe0aef68d4 100644 |
7256 | --- a/drivers/phy/qualcomm/phy-qcom-apq8064-sata.c |
7257 | +++ b/drivers/phy/qualcomm/phy-qcom-apq8064-sata.c |
7258 | @@ -80,7 +80,7 @@ static int read_poll_timeout(void __iomem *addr, u32 mask) |
7259 | if (readl_relaxed(addr) & mask) |
7260 | return 0; |
7261 | |
7262 | - usleep_range(DELAY_INTERVAL_US, DELAY_INTERVAL_US + 50); |
7263 | + usleep_range(DELAY_INTERVAL_US, DELAY_INTERVAL_US + 50); |
7264 | } while (!time_after(jiffies, timeout)); |
7265 | |
7266 | return (readl_relaxed(addr) & mask) ? 0 : -ETIMEDOUT; |
7267 | diff --git a/drivers/platform/x86/intel_scu_ipc.c b/drivers/platform/x86/intel_scu_ipc.c |
7268 | index cdab916fbf92..e330ec73c465 100644 |
7269 | --- a/drivers/platform/x86/intel_scu_ipc.c |
7270 | +++ b/drivers/platform/x86/intel_scu_ipc.c |
7271 | @@ -67,26 +67,22 @@ |
7272 | struct intel_scu_ipc_pdata_t { |
7273 | u32 i2c_base; |
7274 | u32 i2c_len; |
7275 | - u8 irq_mode; |
7276 | }; |
7277 | |
7278 | static const struct intel_scu_ipc_pdata_t intel_scu_ipc_lincroft_pdata = { |
7279 | .i2c_base = 0xff12b000, |
7280 | .i2c_len = 0x10, |
7281 | - .irq_mode = 0, |
7282 | }; |
7283 | |
7284 | /* Penwell and Cloverview */ |
7285 | static const struct intel_scu_ipc_pdata_t intel_scu_ipc_penwell_pdata = { |
7286 | .i2c_base = 0xff12b000, |
7287 | .i2c_len = 0x10, |
7288 | - .irq_mode = 1, |
7289 | }; |
7290 | |
7291 | static const struct intel_scu_ipc_pdata_t intel_scu_ipc_tangier_pdata = { |
7292 | .i2c_base = 0xff00d000, |
7293 | .i2c_len = 0x10, |
7294 | - .irq_mode = 0, |
7295 | }; |
7296 | |
7297 | struct intel_scu_ipc_dev { |
7298 | @@ -99,6 +95,9 @@ struct intel_scu_ipc_dev { |
7299 | |
7300 | static struct intel_scu_ipc_dev ipcdev; /* Only one for now */ |
7301 | |
7302 | +#define IPC_STATUS 0x04 |
7303 | +#define IPC_STATUS_IRQ BIT(2) |
7304 | + |
7305 | /* |
7306 | * IPC Read Buffer (Read Only): |
7307 | * 16 byte buffer for receiving data from SCU, if IPC command |
7308 | @@ -120,11 +119,8 @@ static DEFINE_MUTEX(ipclock); /* lock used to prevent multiple call to SCU */ |
7309 | */ |
7310 | static inline void ipc_command(struct intel_scu_ipc_dev *scu, u32 cmd) |
7311 | { |
7312 | - if (scu->irq_mode) { |
7313 | - reinit_completion(&scu->cmd_complete); |
7314 | - writel(cmd | IPC_IOC, scu->ipc_base); |
7315 | - } |
7316 | - writel(cmd, scu->ipc_base); |
7317 | + reinit_completion(&scu->cmd_complete); |
7318 | + writel(cmd | IPC_IOC, scu->ipc_base); |
7319 | } |
7320 | |
7321 | /* |
7322 | @@ -610,9 +606,10 @@ EXPORT_SYMBOL(intel_scu_ipc_i2c_cntrl); |
7323 | static irqreturn_t ioc(int irq, void *dev_id) |
7324 | { |
7325 | struct intel_scu_ipc_dev *scu = dev_id; |
7326 | + int status = ipc_read_status(scu); |
7327 | |
7328 | - if (scu->irq_mode) |
7329 | - complete(&scu->cmd_complete); |
7330 | + writel(status | IPC_STATUS_IRQ, scu->ipc_base + IPC_STATUS); |
7331 | + complete(&scu->cmd_complete); |
7332 | |
7333 | return IRQ_HANDLED; |
7334 | } |
7335 | @@ -638,8 +635,6 @@ static int ipc_probe(struct pci_dev *pdev, const struct pci_device_id *id) |
7336 | if (!pdata) |
7337 | return -ENODEV; |
7338 | |
7339 | - scu->irq_mode = pdata->irq_mode; |
7340 | - |
7341 | err = pcim_enable_device(pdev); |
7342 | if (err) |
7343 | return err; |
7344 | diff --git a/drivers/power/supply/axp20x_ac_power.c b/drivers/power/supply/axp20x_ac_power.c |
7345 | index 0d34a932b6d5..f74b0556bb6b 100644 |
7346 | --- a/drivers/power/supply/axp20x_ac_power.c |
7347 | +++ b/drivers/power/supply/axp20x_ac_power.c |
7348 | @@ -23,6 +23,8 @@ |
7349 | #define AXP20X_PWR_STATUS_ACIN_PRESENT BIT(7) |
7350 | #define AXP20X_PWR_STATUS_ACIN_AVAIL BIT(6) |
7351 | |
7352 | +#define AXP813_ACIN_PATH_SEL BIT(7) |
7353 | + |
7354 | #define AXP813_VHOLD_MASK GENMASK(5, 3) |
7355 | #define AXP813_VHOLD_UV_TO_BIT(x) ((((x) / 100000) - 40) << 3) |
7356 | #define AXP813_VHOLD_REG_TO_UV(x) \ |
7357 | @@ -40,6 +42,7 @@ struct axp20x_ac_power { |
7358 | struct power_supply *supply; |
7359 | struct iio_channel *acin_v; |
7360 | struct iio_channel *acin_i; |
7361 | + bool has_acin_path_sel; |
7362 | }; |
7363 | |
7364 | static irqreturn_t axp20x_ac_power_irq(int irq, void *devid) |
7365 | @@ -86,6 +89,17 @@ static int axp20x_ac_power_get_property(struct power_supply *psy, |
7366 | return ret; |
7367 | |
7368 | val->intval = !!(reg & AXP20X_PWR_STATUS_ACIN_AVAIL); |
7369 | + |
7370 | + /* ACIN_PATH_SEL disables ACIN even if ACIN_AVAIL is set. */ |
7371 | + if (val->intval && power->has_acin_path_sel) { |
7372 | + ret = regmap_read(power->regmap, AXP813_ACIN_PATH_CTRL, |
7373 | + ®); |
7374 | + if (ret) |
7375 | + return ret; |
7376 | + |
7377 | + val->intval = !!(reg & AXP813_ACIN_PATH_SEL); |
7378 | + } |
7379 | + |
7380 | return 0; |
7381 | |
7382 | case POWER_SUPPLY_PROP_VOLTAGE_NOW: |
7383 | @@ -224,21 +238,25 @@ static const struct power_supply_desc axp813_ac_power_desc = { |
7384 | struct axp_data { |
7385 | const struct power_supply_desc *power_desc; |
7386 | bool acin_adc; |
7387 | + bool acin_path_sel; |
7388 | }; |
7389 | |
7390 | static const struct axp_data axp20x_data = { |
7391 | - .power_desc = &axp20x_ac_power_desc, |
7392 | - .acin_adc = true, |
7393 | + .power_desc = &axp20x_ac_power_desc, |
7394 | + .acin_adc = true, |
7395 | + .acin_path_sel = false, |
7396 | }; |
7397 | |
7398 | static const struct axp_data axp22x_data = { |
7399 | - .power_desc = &axp22x_ac_power_desc, |
7400 | - .acin_adc = false, |
7401 | + .power_desc = &axp22x_ac_power_desc, |
7402 | + .acin_adc = false, |
7403 | + .acin_path_sel = false, |
7404 | }; |
7405 | |
7406 | static const struct axp_data axp813_data = { |
7407 | - .power_desc = &axp813_ac_power_desc, |
7408 | - .acin_adc = false, |
7409 | + .power_desc = &axp813_ac_power_desc, |
7410 | + .acin_adc = false, |
7411 | + .acin_path_sel = true, |
7412 | }; |
7413 | |
7414 | static int axp20x_ac_power_probe(struct platform_device *pdev) |
7415 | @@ -282,6 +300,7 @@ static int axp20x_ac_power_probe(struct platform_device *pdev) |
7416 | } |
7417 | |
7418 | power->regmap = dev_get_regmap(pdev->dev.parent, NULL); |
7419 | + power->has_acin_path_sel = axp_data->acin_path_sel; |
7420 | |
7421 | platform_set_drvdata(pdev, power); |
7422 | |
7423 | diff --git a/drivers/power/supply/ltc2941-battery-gauge.c b/drivers/power/supply/ltc2941-battery-gauge.c |
7424 | index da49436176cd..30a9014b2f95 100644 |
7425 | --- a/drivers/power/supply/ltc2941-battery-gauge.c |
7426 | +++ b/drivers/power/supply/ltc2941-battery-gauge.c |
7427 | @@ -449,7 +449,7 @@ static int ltc294x_i2c_remove(struct i2c_client *client) |
7428 | { |
7429 | struct ltc294x_info *info = i2c_get_clientdata(client); |
7430 | |
7431 | - cancel_delayed_work(&info->work); |
7432 | + cancel_delayed_work_sync(&info->work); |
7433 | power_supply_unregister(info->supply); |
7434 | return 0; |
7435 | } |
7436 | diff --git a/drivers/regulator/helpers.c b/drivers/regulator/helpers.c |
7437 | index ca3dc3f3bb29..bb16c465426e 100644 |
7438 | --- a/drivers/regulator/helpers.c |
7439 | +++ b/drivers/regulator/helpers.c |
7440 | @@ -13,6 +13,8 @@ |
7441 | #include <linux/regulator/driver.h> |
7442 | #include <linux/module.h> |
7443 | |
7444 | +#include "internal.h" |
7445 | + |
7446 | /** |
7447 | * regulator_is_enabled_regmap - standard is_enabled() for regmap users |
7448 | * |
7449 | @@ -881,3 +883,15 @@ void regulator_bulk_set_supply_names(struct regulator_bulk_data *consumers, |
7450 | consumers[i].supply = supply_names[i]; |
7451 | } |
7452 | EXPORT_SYMBOL_GPL(regulator_bulk_set_supply_names); |
7453 | + |
7454 | +/** |
7455 | + * regulator_is_equal - test whether two regulators are the same |
7456 | + * |
7457 | + * @reg1: first regulator to operate on |
7458 | + * @reg2: second regulator to operate on |
7459 | + */ |
7460 | +bool regulator_is_equal(struct regulator *reg1, struct regulator *reg2) |
7461 | +{ |
7462 | + return reg1->rdev == reg2->rdev; |
7463 | +} |
7464 | +EXPORT_SYMBOL_GPL(regulator_is_equal); |
7465 | diff --git a/drivers/scsi/csiostor/csio_scsi.c b/drivers/scsi/csiostor/csio_scsi.c |
7466 | index 469d0bc9f5fe..00cf33573136 100644 |
7467 | --- a/drivers/scsi/csiostor/csio_scsi.c |
7468 | +++ b/drivers/scsi/csiostor/csio_scsi.c |
7469 | @@ -1383,7 +1383,7 @@ csio_device_reset(struct device *dev, |
7470 | return -EINVAL; |
7471 | |
7472 | /* Delete NPIV lnodes */ |
7473 | - csio_lnodes_exit(hw, 1); |
7474 | + csio_lnodes_exit(hw, 1); |
7475 | |
7476 | /* Block upper IOs */ |
7477 | csio_lnodes_block_request(hw); |
7478 | diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c |
7479 | index 42cf38c1ea99..0cbe6740e0c9 100644 |
7480 | --- a/drivers/scsi/megaraid/megaraid_sas_base.c |
7481 | +++ b/drivers/scsi/megaraid/megaraid_sas_base.c |
7482 | @@ -4392,7 +4392,8 @@ dcmd_timeout_ocr_possible(struct megasas_instance *instance) { |
7483 | if (instance->adapter_type == MFI_SERIES) |
7484 | return KILL_ADAPTER; |
7485 | else if (instance->unload || |
7486 | - test_bit(MEGASAS_FUSION_IN_RESET, &instance->reset_flags)) |
7487 | + test_bit(MEGASAS_FUSION_OCR_NOT_POSSIBLE, |
7488 | + &instance->reset_flags)) |
7489 | return IGNORE_TIMEOUT; |
7490 | else |
7491 | return INITIATE_OCR; |
7492 | diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c |
7493 | index e301458bcbae..46bc062d873e 100644 |
7494 | --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c |
7495 | +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c |
7496 | @@ -4847,6 +4847,7 @@ int megasas_reset_fusion(struct Scsi_Host *shost, int reason) |
7497 | if (instance->requestorId && !instance->skip_heartbeat_timer_del) |
7498 | del_timer_sync(&instance->sriov_heartbeat_timer); |
7499 | set_bit(MEGASAS_FUSION_IN_RESET, &instance->reset_flags); |
7500 | + set_bit(MEGASAS_FUSION_OCR_NOT_POSSIBLE, &instance->reset_flags); |
7501 | atomic_set(&instance->adprecovery, MEGASAS_ADPRESET_SM_POLLING); |
7502 | instance->instancet->disable_intr(instance); |
7503 | megasas_sync_irqs((unsigned long)instance); |
7504 | @@ -5046,7 +5047,7 @@ kill_hba: |
7505 | instance->skip_heartbeat_timer_del = 1; |
7506 | retval = FAILED; |
7507 | out: |
7508 | - clear_bit(MEGASAS_FUSION_IN_RESET, &instance->reset_flags); |
7509 | + clear_bit(MEGASAS_FUSION_OCR_NOT_POSSIBLE, &instance->reset_flags); |
7510 | mutex_unlock(&instance->reset_mutex); |
7511 | return retval; |
7512 | } |
7513 | diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.h b/drivers/scsi/megaraid/megaraid_sas_fusion.h |
7514 | index c013c80fe4e6..dd2e37e40d6b 100644 |
7515 | --- a/drivers/scsi/megaraid/megaraid_sas_fusion.h |
7516 | +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.h |
7517 | @@ -89,6 +89,7 @@ enum MR_RAID_FLAGS_IO_SUB_TYPE { |
7518 | |
7519 | #define MEGASAS_FP_CMD_LEN 16 |
7520 | #define MEGASAS_FUSION_IN_RESET 0 |
7521 | +#define MEGASAS_FUSION_OCR_NOT_POSSIBLE 1 |
7522 | #define RAID_1_PEER_CMDS 2 |
7523 | #define JBOD_MAPS_COUNT 2 |
7524 | #define MEGASAS_REDUCE_QD_COUNT 64 |
7525 | diff --git a/drivers/scsi/qla2xxx/qla_dbg.c b/drivers/scsi/qla2xxx/qla_dbg.c |
7526 | index 30afc59c1870..7bbff91f8883 100644 |
7527 | --- a/drivers/scsi/qla2xxx/qla_dbg.c |
7528 | +++ b/drivers/scsi/qla2xxx/qla_dbg.c |
7529 | @@ -2519,12 +2519,6 @@ qla83xx_fw_dump_failed: |
7530 | /* Driver Debug Functions. */ |
7531 | /****************************************************************************/ |
7532 | |
7533 | -static inline int |
7534 | -ql_mask_match(uint level) |
7535 | -{ |
7536 | - return (level & ql2xextended_error_logging) == level; |
7537 | -} |
7538 | - |
7539 | /* |
7540 | * This function is for formatting and logging debug information. |
7541 | * It is to be used when vha is available. It formats the message |
7542 | diff --git a/drivers/scsi/qla2xxx/qla_dbg.h b/drivers/scsi/qla2xxx/qla_dbg.h |
7543 | index bb01b680ce9f..433e95502808 100644 |
7544 | --- a/drivers/scsi/qla2xxx/qla_dbg.h |
7545 | +++ b/drivers/scsi/qla2xxx/qla_dbg.h |
7546 | @@ -374,3 +374,9 @@ extern int qla24xx_dump_ram(struct qla_hw_data *, uint32_t, uint32_t *, |
7547 | extern void qla24xx_pause_risc(struct device_reg_24xx __iomem *, |
7548 | struct qla_hw_data *); |
7549 | extern int qla24xx_soft_reset(struct qla_hw_data *); |
7550 | + |
7551 | +static inline int |
7552 | +ql_mask_match(uint level) |
7553 | +{ |
7554 | + return (level & ql2xextended_error_logging) == level; |
7555 | +} |
7556 | diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h |
7557 | index 1eb3fe281cc3..c57b95a20688 100644 |
7558 | --- a/drivers/scsi/qla2xxx/qla_def.h |
7559 | +++ b/drivers/scsi/qla2xxx/qla_def.h |
7560 | @@ -2402,6 +2402,7 @@ typedef struct fc_port { |
7561 | unsigned int scan_needed:1; |
7562 | unsigned int n2n_flag:1; |
7563 | unsigned int explicit_logout:1; |
7564 | + unsigned int prli_pend_timer:1; |
7565 | |
7566 | struct completion nvme_del_done; |
7567 | uint32_t nvme_prli_service_param; |
7568 | @@ -2428,6 +2429,7 @@ typedef struct fc_port { |
7569 | struct work_struct free_work; |
7570 | struct work_struct reg_work; |
7571 | uint64_t jiffies_at_registration; |
7572 | + unsigned long prli_expired; |
7573 | struct qlt_plogi_ack_t *plogi_link[QLT_PLOGI_LINK_MAX]; |
7574 | |
7575 | uint16_t tgt_id; |
7576 | @@ -4821,6 +4823,9 @@ struct sff_8247_a0 { |
7577 | ha->current_topology == ISP_CFG_N || \ |
7578 | !ha->current_topology) |
7579 | |
7580 | +#define PRLI_PHASE(_cls) \ |
7581 | + ((_cls == DSC_LS_PRLI_PEND) || (_cls == DSC_LS_PRLI_COMP)) |
7582 | + |
7583 | #include "qla_target.h" |
7584 | #include "qla_gbl.h" |
7585 | #include "qla_dbg.h" |
7586 | diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c |
7587 | index 9ffaa920fc8f..ac4c47fc5f4c 100644 |
7588 | --- a/drivers/scsi/qla2xxx/qla_init.c |
7589 | +++ b/drivers/scsi/qla2xxx/qla_init.c |
7590 | @@ -686,7 +686,7 @@ static void qla24xx_handle_gnl_done_event(scsi_qla_host_t *vha, |
7591 | port_id_t id; |
7592 | u64 wwn; |
7593 | u16 data[2]; |
7594 | - u8 current_login_state; |
7595 | + u8 current_login_state, nvme_cls; |
7596 | |
7597 | fcport = ea->fcport; |
7598 | ql_dbg(ql_dbg_disc, vha, 0xffff, |
7599 | @@ -745,10 +745,17 @@ static void qla24xx_handle_gnl_done_event(scsi_qla_host_t *vha, |
7600 | |
7601 | loop_id = le16_to_cpu(e->nport_handle); |
7602 | loop_id = (loop_id & 0x7fff); |
7603 | - if (fcport->fc4f_nvme) |
7604 | - current_login_state = e->current_login_state >> 4; |
7605 | - else |
7606 | - current_login_state = e->current_login_state & 0xf; |
7607 | + nvme_cls = e->current_login_state >> 4; |
7608 | + current_login_state = e->current_login_state & 0xf; |
7609 | + |
7610 | + if (PRLI_PHASE(nvme_cls)) { |
7611 | + current_login_state = nvme_cls; |
7612 | + fcport->fc4_type &= ~FS_FC4TYPE_FCP; |
7613 | + fcport->fc4_type |= FS_FC4TYPE_NVME; |
7614 | + } else if (PRLI_PHASE(current_login_state)) { |
7615 | + fcport->fc4_type |= FS_FC4TYPE_FCP; |
7616 | + fcport->fc4_type &= ~FS_FC4TYPE_NVME; |
7617 | + } |
7618 | |
7619 | |
7620 | ql_dbg(ql_dbg_disc, vha, 0x20e2, |
7621 | @@ -1219,12 +1226,19 @@ qla24xx_async_prli(struct scsi_qla_host *vha, fc_port_t *fcport) |
7622 | struct srb_iocb *lio; |
7623 | int rval = QLA_FUNCTION_FAILED; |
7624 | |
7625 | - if (!vha->flags.online) |
7626 | + if (!vha->flags.online) { |
7627 | + ql_dbg(ql_dbg_disc, vha, 0xffff, "%s %d %8phC exit\n", |
7628 | + __func__, __LINE__, fcport->port_name); |
7629 | return rval; |
7630 | + } |
7631 | |
7632 | - if (fcport->fw_login_state == DSC_LS_PLOGI_PEND || |
7633 | - fcport->fw_login_state == DSC_LS_PRLI_PEND) |
7634 | + if ((fcport->fw_login_state == DSC_LS_PLOGI_PEND || |
7635 | + fcport->fw_login_state == DSC_LS_PRLI_PEND) && |
7636 | + qla_dual_mode_enabled(vha)) { |
7637 | + ql_dbg(ql_dbg_disc, vha, 0xffff, "%s %d %8phC exit\n", |
7638 | + __func__, __LINE__, fcport->port_name); |
7639 | return rval; |
7640 | + } |
7641 | |
7642 | sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL); |
7643 | if (!sp) |
7644 | @@ -1602,6 +1616,10 @@ int qla24xx_fcport_handle_login(struct scsi_qla_host *vha, fc_port_t *fcport) |
7645 | break; |
7646 | default: |
7647 | if (fcport->login_pause) { |
7648 | + ql_dbg(ql_dbg_disc, vha, 0x20d8, |
7649 | + "%s %d %8phC exit\n", |
7650 | + __func__, __LINE__, |
7651 | + fcport->port_name); |
7652 | fcport->last_rscn_gen = fcport->rscn_gen; |
7653 | fcport->last_login_gen = fcport->login_gen; |
7654 | set_bit(RELOGIN_NEEDED, &vha->dpc_flags); |
7655 | diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c |
7656 | index 7c5f2736ebee..3e9c5768815e 100644 |
7657 | --- a/drivers/scsi/qla2xxx/qla_isr.c |
7658 | +++ b/drivers/scsi/qla2xxx/qla_isr.c |
7659 | @@ -1897,6 +1897,18 @@ static void qla24xx_nvme_iocb_entry(scsi_qla_host_t *vha, struct req_que *req, |
7660 | inbuf = (uint32_t *)&sts->nvme_ersp_data; |
7661 | outbuf = (uint32_t *)fd->rspaddr; |
7662 | iocb->u.nvme.rsp_pyld_len = le16_to_cpu(sts->nvme_rsp_pyld_len); |
7663 | + if (unlikely(iocb->u.nvme.rsp_pyld_len > |
7664 | + sizeof(struct nvme_fc_ersp_iu))) { |
7665 | + if (ql_mask_match(ql_dbg_io)) { |
7666 | + WARN_ONCE(1, "Unexpected response payload length %u.\n", |
7667 | + iocb->u.nvme.rsp_pyld_len); |
7668 | + ql_log(ql_log_warn, fcport->vha, 0x5100, |
7669 | + "Unexpected response payload length %u.\n", |
7670 | + iocb->u.nvme.rsp_pyld_len); |
7671 | + } |
7672 | + iocb->u.nvme.rsp_pyld_len = |
7673 | + sizeof(struct nvme_fc_ersp_iu); |
7674 | + } |
7675 | iter = iocb->u.nvme.rsp_pyld_len >> 2; |
7676 | for (; iter; iter--) |
7677 | *outbuf++ = swab32(*inbuf++); |
7678 | diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c |
7679 | index eac76e934cbe..1ef8907314e5 100644 |
7680 | --- a/drivers/scsi/qla2xxx/qla_mbx.c |
7681 | +++ b/drivers/scsi/qla2xxx/qla_mbx.c |
7682 | @@ -6151,9 +6151,8 @@ qla2x00_dump_mctp_data(scsi_qla_host_t *vha, dma_addr_t req_dma, uint32_t addr, |
7683 | mcp->mb[7] = LSW(MSD(req_dma)); |
7684 | mcp->mb[8] = MSW(addr); |
7685 | /* Setting RAM ID to valid */ |
7686 | - mcp->mb[10] |= BIT_7; |
7687 | /* For MCTP RAM ID is 0x40 */ |
7688 | - mcp->mb[10] |= 0x40; |
7689 | + mcp->mb[10] = BIT_7 | 0x40; |
7690 | |
7691 | mcp->out_mb |= MBX_10|MBX_8|MBX_7|MBX_6|MBX_5|MBX_4|MBX_3|MBX_2|MBX_1| |
7692 | MBX_0; |
7693 | diff --git a/drivers/scsi/qla2xxx/qla_nx.c b/drivers/scsi/qla2xxx/qla_nx.c |
7694 | index 2b2028f2383e..c855d013ba8a 100644 |
7695 | --- a/drivers/scsi/qla2xxx/qla_nx.c |
7696 | +++ b/drivers/scsi/qla2xxx/qla_nx.c |
7697 | @@ -1612,8 +1612,7 @@ qla82xx_get_bootld_offset(struct qla_hw_data *ha) |
7698 | return (u8 *)&ha->hablob->fw->data[offset]; |
7699 | } |
7700 | |
7701 | -static __le32 |
7702 | -qla82xx_get_fw_size(struct qla_hw_data *ha) |
7703 | +static u32 qla82xx_get_fw_size(struct qla_hw_data *ha) |
7704 | { |
7705 | struct qla82xx_uri_data_desc *uri_desc = NULL; |
7706 | |
7707 | @@ -1624,7 +1623,7 @@ qla82xx_get_fw_size(struct qla_hw_data *ha) |
7708 | return cpu_to_le32(uri_desc->size); |
7709 | } |
7710 | |
7711 | - return cpu_to_le32(*(u32 *)&ha->hablob->fw->data[FW_SIZE_OFFSET]); |
7712 | + return get_unaligned_le32(&ha->hablob->fw->data[FW_SIZE_OFFSET]); |
7713 | } |
7714 | |
7715 | static u8 * |
7716 | @@ -1816,7 +1815,7 @@ qla82xx_fw_load_from_blob(struct qla_hw_data *ha) |
7717 | } |
7718 | |
7719 | flashaddr = FLASH_ADDR_START; |
7720 | - size = (__force u32)qla82xx_get_fw_size(ha) / 8; |
7721 | + size = qla82xx_get_fw_size(ha) / 8; |
7722 | ptr64 = (u64 *)qla82xx_get_fw_offs(ha); |
7723 | |
7724 | for (i = 0; i < size; i++) { |
7725 | diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c |
7726 | index 74a378a91b71..cb8a892e2d39 100644 |
7727 | --- a/drivers/scsi/qla2xxx/qla_target.c |
7728 | +++ b/drivers/scsi/qla2xxx/qla_target.c |
7729 | @@ -1257,6 +1257,7 @@ void qlt_schedule_sess_for_deletion(struct fc_port *sess) |
7730 | sess->deleted = QLA_SESS_DELETION_IN_PROGRESS; |
7731 | spin_unlock_irqrestore(&sess->vha->work_lock, flags); |
7732 | |
7733 | + sess->prli_pend_timer = 0; |
7734 | sess->disc_state = DSC_DELETE_PEND; |
7735 | |
7736 | qla24xx_chk_fcp_state(sess); |
7737 | diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c |
7738 | index 2323432a0edb..5504ab11decc 100644 |
7739 | --- a/drivers/scsi/qla4xxx/ql4_os.c |
7740 | +++ b/drivers/scsi/qla4xxx/ql4_os.c |
7741 | @@ -4145,7 +4145,7 @@ static void qla4xxx_mem_free(struct scsi_qla_host *ha) |
7742 | dma_free_coherent(&ha->pdev->dev, ha->queues_len, ha->queues, |
7743 | ha->queues_dma); |
7744 | |
7745 | - if (ha->fw_dump) |
7746 | + if (ha->fw_dump) |
7747 | vfree(ha->fw_dump); |
7748 | |
7749 | ha->queues_len = 0; |
7750 | diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c |
7751 | index 1e38bb967871..0d41a7dc1d6b 100644 |
7752 | --- a/drivers/scsi/ufs/ufshcd.c |
7753 | +++ b/drivers/scsi/ufs/ufshcd.c |
7754 | @@ -5023,6 +5023,7 @@ static int ufshcd_disable_auto_bkops(struct ufs_hba *hba) |
7755 | |
7756 | hba->auto_bkops_enabled = false; |
7757 | trace_ufshcd_auto_bkops_state(dev_name(hba->dev), "Disabled"); |
7758 | + hba->is_urgent_bkops_lvl_checked = false; |
7759 | out: |
7760 | return err; |
7761 | } |
7762 | @@ -5047,6 +5048,7 @@ static void ufshcd_force_reset_auto_bkops(struct ufs_hba *hba) |
7763 | hba->ee_ctrl_mask &= ~MASK_EE_URGENT_BKOPS; |
7764 | ufshcd_disable_auto_bkops(hba); |
7765 | } |
7766 | + hba->is_urgent_bkops_lvl_checked = false; |
7767 | } |
7768 | |
7769 | static inline int ufshcd_get_bkops_status(struct ufs_hba *hba, u32 *status) |
7770 | @@ -5093,6 +5095,7 @@ static int ufshcd_bkops_ctrl(struct ufs_hba *hba, |
7771 | err = ufshcd_enable_auto_bkops(hba); |
7772 | else |
7773 | err = ufshcd_disable_auto_bkops(hba); |
7774 | + hba->urgent_bkops_lvl = curr_status; |
7775 | out: |
7776 | return err; |
7777 | } |
7778 | diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h |
7779 | index 1c8b349379af..77c4a9abe365 100644 |
7780 | --- a/drivers/usb/dwc3/core.h |
7781 | +++ b/drivers/usb/dwc3/core.h |
7782 | @@ -688,7 +688,9 @@ struct dwc3_ep { |
7783 | #define DWC3_EP_STALL BIT(1) |
7784 | #define DWC3_EP_WEDGE BIT(2) |
7785 | #define DWC3_EP_TRANSFER_STARTED BIT(3) |
7786 | +#define DWC3_EP_END_TRANSFER_PENDING BIT(4) |
7787 | #define DWC3_EP_PENDING_REQUEST BIT(5) |
7788 | +#define DWC3_EP_DELAY_START BIT(6) |
7789 | |
7790 | /* This last one is specific to EP0 */ |
7791 | #define DWC3_EP0_DIR_IN BIT(31) |
7792 | diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c |
7793 | index fd1b100d2927..6dee4dabc0a4 100644 |
7794 | --- a/drivers/usb/dwc3/ep0.c |
7795 | +++ b/drivers/usb/dwc3/ep0.c |
7796 | @@ -1136,8 +1136,10 @@ void dwc3_ep0_interrupt(struct dwc3 *dwc, |
7797 | case DWC3_DEPEVT_EPCMDCMPLT: |
7798 | cmd = DEPEVT_PARAMETER_CMD(event->parameters); |
7799 | |
7800 | - if (cmd == DWC3_DEPCMD_ENDTRANSFER) |
7801 | + if (cmd == DWC3_DEPCMD_ENDTRANSFER) { |
7802 | + dep->flags &= ~DWC3_EP_END_TRANSFER_PENDING; |
7803 | dep->flags &= ~DWC3_EP_TRANSFER_STARTED; |
7804 | + } |
7805 | break; |
7806 | } |
7807 | } |
7808 | diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c |
7809 | index 154f3f3e8cff..8b95be897078 100644 |
7810 | --- a/drivers/usb/dwc3/gadget.c |
7811 | +++ b/drivers/usb/dwc3/gadget.c |
7812 | @@ -1447,6 +1447,12 @@ static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req) |
7813 | list_add_tail(&req->list, &dep->pending_list); |
7814 | req->status = DWC3_REQUEST_STATUS_QUEUED; |
7815 | |
7816 | + /* Start the transfer only after the END_TRANSFER is completed */ |
7817 | + if (dep->flags & DWC3_EP_END_TRANSFER_PENDING) { |
7818 | + dep->flags |= DWC3_EP_DELAY_START; |
7819 | + return 0; |
7820 | + } |
7821 | + |
7822 | /* |
7823 | * NOTICE: Isochronous endpoints should NEVER be prestarted. We must |
7824 | * wait for a XferNotReady event so we will know what's the current |
7825 | @@ -2625,8 +2631,14 @@ static void dwc3_endpoint_interrupt(struct dwc3 *dwc, |
7826 | cmd = DEPEVT_PARAMETER_CMD(event->parameters); |
7827 | |
7828 | if (cmd == DWC3_DEPCMD_ENDTRANSFER) { |
7829 | + dep->flags &= ~DWC3_EP_END_TRANSFER_PENDING; |
7830 | dep->flags &= ~DWC3_EP_TRANSFER_STARTED; |
7831 | dwc3_gadget_ep_cleanup_cancelled_requests(dep); |
7832 | + if ((dep->flags & DWC3_EP_DELAY_START) && |
7833 | + !usb_endpoint_xfer_isoc(dep->endpoint.desc)) |
7834 | + __dwc3_gadget_kick_transfer(dep); |
7835 | + |
7836 | + dep->flags &= ~DWC3_EP_DELAY_START; |
7837 | } |
7838 | break; |
7839 | case DWC3_DEPEVT_STREAMEVT: |
7840 | @@ -2683,7 +2695,8 @@ static void dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force, |
7841 | u32 cmd; |
7842 | int ret; |
7843 | |
7844 | - if (!(dep->flags & DWC3_EP_TRANSFER_STARTED)) |
7845 | + if (!(dep->flags & DWC3_EP_TRANSFER_STARTED) || |
7846 | + (dep->flags & DWC3_EP_END_TRANSFER_PENDING)) |
7847 | return; |
7848 | |
7849 | /* |
7850 | @@ -2728,6 +2741,8 @@ static void dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force, |
7851 | |
7852 | if (!interrupt) |
7853 | dep->flags &= ~DWC3_EP_TRANSFER_STARTED; |
7854 | + else |
7855 | + dep->flags |= DWC3_EP_END_TRANSFER_PENDING; |
7856 | |
7857 | if (dwc3_is_usb31(dwc) || dwc->revision < DWC3_REVISION_310A) |
7858 | udelay(100); |
7859 | diff --git a/drivers/usb/gadget/function/f_ecm.c b/drivers/usb/gadget/function/f_ecm.c |
7860 | index 460d5d7c984f..7f5cf488b2b1 100644 |
7861 | --- a/drivers/usb/gadget/function/f_ecm.c |
7862 | +++ b/drivers/usb/gadget/function/f_ecm.c |
7863 | @@ -52,6 +52,7 @@ struct f_ecm { |
7864 | struct usb_ep *notify; |
7865 | struct usb_request *notify_req; |
7866 | u8 notify_state; |
7867 | + atomic_t notify_count; |
7868 | bool is_open; |
7869 | |
7870 | /* FIXME is_open needs some irq-ish locking |
7871 | @@ -380,7 +381,7 @@ static void ecm_do_notify(struct f_ecm *ecm) |
7872 | int status; |
7873 | |
7874 | /* notification already in flight? */ |
7875 | - if (!req) |
7876 | + if (atomic_read(&ecm->notify_count)) |
7877 | return; |
7878 | |
7879 | event = req->buf; |
7880 | @@ -420,10 +421,10 @@ static void ecm_do_notify(struct f_ecm *ecm) |
7881 | event->bmRequestType = 0xA1; |
7882 | event->wIndex = cpu_to_le16(ecm->ctrl_id); |
7883 | |
7884 | - ecm->notify_req = NULL; |
7885 | + atomic_inc(&ecm->notify_count); |
7886 | status = usb_ep_queue(ecm->notify, req, GFP_ATOMIC); |
7887 | if (status < 0) { |
7888 | - ecm->notify_req = req; |
7889 | + atomic_dec(&ecm->notify_count); |
7890 | DBG(cdev, "notify --> %d\n", status); |
7891 | } |
7892 | } |
7893 | @@ -448,17 +449,19 @@ static void ecm_notify_complete(struct usb_ep *ep, struct usb_request *req) |
7894 | switch (req->status) { |
7895 | case 0: |
7896 | /* no fault */ |
7897 | + atomic_dec(&ecm->notify_count); |
7898 | break; |
7899 | case -ECONNRESET: |
7900 | case -ESHUTDOWN: |
7901 | + atomic_set(&ecm->notify_count, 0); |
7902 | ecm->notify_state = ECM_NOTIFY_NONE; |
7903 | break; |
7904 | default: |
7905 | DBG(cdev, "event %02x --> %d\n", |
7906 | event->bNotificationType, req->status); |
7907 | + atomic_dec(&ecm->notify_count); |
7908 | break; |
7909 | } |
7910 | - ecm->notify_req = req; |
7911 | ecm_do_notify(ecm); |
7912 | } |
7913 | |
7914 | @@ -907,6 +910,11 @@ static void ecm_unbind(struct usb_configuration *c, struct usb_function *f) |
7915 | |
7916 | usb_free_all_descriptors(f); |
7917 | |
7918 | + if (atomic_read(&ecm->notify_count)) { |
7919 | + usb_ep_dequeue(ecm->notify, ecm->notify_req); |
7920 | + atomic_set(&ecm->notify_count, 0); |
7921 | + } |
7922 | + |
7923 | kfree(ecm->notify_req->buf); |
7924 | usb_ep_free_request(ecm->notify, ecm->notify_req); |
7925 | } |
7926 | diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c |
7927 | index 59d9d512dcda..ced2581cf99f 100644 |
7928 | --- a/drivers/usb/gadget/function/f_fs.c |
7929 | +++ b/drivers/usb/gadget/function/f_fs.c |
7930 | @@ -1062,6 +1062,7 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data) |
7931 | req->num_sgs = io_data->sgt.nents; |
7932 | } else { |
7933 | req->buf = data; |
7934 | + req->num_sgs = 0; |
7935 | } |
7936 | req->length = data_len; |
7937 | |
7938 | @@ -1105,6 +1106,7 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data) |
7939 | req->num_sgs = io_data->sgt.nents; |
7940 | } else { |
7941 | req->buf = data; |
7942 | + req->num_sgs = 0; |
7943 | } |
7944 | req->length = data_len; |
7945 | |
7946 | diff --git a/drivers/usb/gadget/function/f_ncm.c b/drivers/usb/gadget/function/f_ncm.c |
7947 | index 2d6e76e4cffa..1d900081b1f0 100644 |
7948 | --- a/drivers/usb/gadget/function/f_ncm.c |
7949 | +++ b/drivers/usb/gadget/function/f_ncm.c |
7950 | @@ -53,6 +53,7 @@ struct f_ncm { |
7951 | struct usb_ep *notify; |
7952 | struct usb_request *notify_req; |
7953 | u8 notify_state; |
7954 | + atomic_t notify_count; |
7955 | bool is_open; |
7956 | |
7957 | const struct ndp_parser_opts *parser_opts; |
7958 | @@ -547,7 +548,7 @@ static void ncm_do_notify(struct f_ncm *ncm) |
7959 | int status; |
7960 | |
7961 | /* notification already in flight? */ |
7962 | - if (!req) |
7963 | + if (atomic_read(&ncm->notify_count)) |
7964 | return; |
7965 | |
7966 | event = req->buf; |
7967 | @@ -587,7 +588,8 @@ static void ncm_do_notify(struct f_ncm *ncm) |
7968 | event->bmRequestType = 0xA1; |
7969 | event->wIndex = cpu_to_le16(ncm->ctrl_id); |
7970 | |
7971 | - ncm->notify_req = NULL; |
7972 | + atomic_inc(&ncm->notify_count); |
7973 | + |
7974 | /* |
7975 | * In double buffering if there is a space in FIFO, |
7976 | * completion callback can be called right after the call, |
7977 | @@ -597,7 +599,7 @@ static void ncm_do_notify(struct f_ncm *ncm) |
7978 | status = usb_ep_queue(ncm->notify, req, GFP_ATOMIC); |
7979 | spin_lock(&ncm->lock); |
7980 | if (status < 0) { |
7981 | - ncm->notify_req = req; |
7982 | + atomic_dec(&ncm->notify_count); |
7983 | DBG(cdev, "notify --> %d\n", status); |
7984 | } |
7985 | } |
7986 | @@ -632,17 +634,19 @@ static void ncm_notify_complete(struct usb_ep *ep, struct usb_request *req) |
7987 | case 0: |
7988 | VDBG(cdev, "Notification %02x sent\n", |
7989 | event->bNotificationType); |
7990 | + atomic_dec(&ncm->notify_count); |
7991 | break; |
7992 | case -ECONNRESET: |
7993 | case -ESHUTDOWN: |
7994 | + atomic_set(&ncm->notify_count, 0); |
7995 | ncm->notify_state = NCM_NOTIFY_NONE; |
7996 | break; |
7997 | default: |
7998 | DBG(cdev, "event %02x --> %d\n", |
7999 | event->bNotificationType, req->status); |
8000 | + atomic_dec(&ncm->notify_count); |
8001 | break; |
8002 | } |
8003 | - ncm->notify_req = req; |
8004 | ncm_do_notify(ncm); |
8005 | spin_unlock(&ncm->lock); |
8006 | } |
8007 | @@ -1649,6 +1653,11 @@ static void ncm_unbind(struct usb_configuration *c, struct usb_function *f) |
8008 | ncm_string_defs[0].id = 0; |
8009 | usb_free_all_descriptors(f); |
8010 | |
8011 | + if (atomic_read(&ncm->notify_count)) { |
8012 | + usb_ep_dequeue(ncm->notify, ncm->notify_req); |
8013 | + atomic_set(&ncm->notify_count, 0); |
8014 | + } |
8015 | + |
8016 | kfree(ncm->notify_req->buf); |
8017 | usb_ep_free_request(ncm->notify, ncm->notify_req); |
8018 | } |
8019 | diff --git a/drivers/usb/gadget/legacy/cdc2.c b/drivers/usb/gadget/legacy/cdc2.c |
8020 | index da1c37933ca1..8d7a556ece30 100644 |
8021 | --- a/drivers/usb/gadget/legacy/cdc2.c |
8022 | +++ b/drivers/usb/gadget/legacy/cdc2.c |
8023 | @@ -225,7 +225,7 @@ static struct usb_composite_driver cdc_driver = { |
8024 | .name = "g_cdc", |
8025 | .dev = &device_desc, |
8026 | .strings = dev_strings, |
8027 | - .max_speed = USB_SPEED_HIGH, |
8028 | + .max_speed = USB_SPEED_SUPER, |
8029 | .bind = cdc_bind, |
8030 | .unbind = cdc_unbind, |
8031 | }; |
8032 | diff --git a/drivers/usb/gadget/legacy/g_ffs.c b/drivers/usb/gadget/legacy/g_ffs.c |
8033 | index b640ed3fcf70..ae6d8f7092b8 100644 |
8034 | --- a/drivers/usb/gadget/legacy/g_ffs.c |
8035 | +++ b/drivers/usb/gadget/legacy/g_ffs.c |
8036 | @@ -149,7 +149,7 @@ static struct usb_composite_driver gfs_driver = { |
8037 | .name = DRIVER_NAME, |
8038 | .dev = &gfs_dev_desc, |
8039 | .strings = gfs_dev_strings, |
8040 | - .max_speed = USB_SPEED_HIGH, |
8041 | + .max_speed = USB_SPEED_SUPER, |
8042 | .bind = gfs_bind, |
8043 | .unbind = gfs_unbind, |
8044 | }; |
8045 | diff --git a/drivers/usb/gadget/legacy/multi.c b/drivers/usb/gadget/legacy/multi.c |
8046 | index 50515f9e1022..ec9749845660 100644 |
8047 | --- a/drivers/usb/gadget/legacy/multi.c |
8048 | +++ b/drivers/usb/gadget/legacy/multi.c |
8049 | @@ -482,7 +482,7 @@ static struct usb_composite_driver multi_driver = { |
8050 | .name = "g_multi", |
8051 | .dev = &device_desc, |
8052 | .strings = dev_strings, |
8053 | - .max_speed = USB_SPEED_HIGH, |
8054 | + .max_speed = USB_SPEED_SUPER, |
8055 | .bind = multi_bind, |
8056 | .unbind = multi_unbind, |
8057 | .needs_serial = 1, |
8058 | diff --git a/drivers/usb/gadget/legacy/ncm.c b/drivers/usb/gadget/legacy/ncm.c |
8059 | index 8465f081e921..c61e71ba7045 100644 |
8060 | --- a/drivers/usb/gadget/legacy/ncm.c |
8061 | +++ b/drivers/usb/gadget/legacy/ncm.c |
8062 | @@ -197,7 +197,7 @@ static struct usb_composite_driver ncm_driver = { |
8063 | .name = "g_ncm", |
8064 | .dev = &device_desc, |
8065 | .strings = dev_strings, |
8066 | - .max_speed = USB_SPEED_HIGH, |
8067 | + .max_speed = USB_SPEED_SUPER, |
8068 | .bind = gncm_bind, |
8069 | .unbind = gncm_unbind, |
8070 | }; |
8071 | diff --git a/drivers/usb/typec/tcpm/tcpci.c b/drivers/usb/typec/tcpm/tcpci.c |
8072 | index 8b4ff9fff340..753645bb2527 100644 |
8073 | --- a/drivers/usb/typec/tcpm/tcpci.c |
8074 | +++ b/drivers/usb/typec/tcpm/tcpci.c |
8075 | @@ -591,6 +591,12 @@ static int tcpci_probe(struct i2c_client *client, |
8076 | static int tcpci_remove(struct i2c_client *client) |
8077 | { |
8078 | struct tcpci_chip *chip = i2c_get_clientdata(client); |
8079 | + int err; |
8080 | + |
8081 | + /* Disable chip interrupts before unregistering port */ |
8082 | + err = tcpci_write16(chip->tcpci, TCPC_ALERT_MASK, 0); |
8083 | + if (err < 0) |
8084 | + return err; |
8085 | |
8086 | tcpci_unregister_port(chip->tcpci); |
8087 | |
8088 | diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c |
8089 | index 9f4117766bb1..c962d9b370c6 100644 |
8090 | --- a/drivers/virtio/virtio_balloon.c |
8091 | +++ b/drivers/virtio/virtio_balloon.c |
8092 | @@ -474,7 +474,9 @@ static int init_vqs(struct virtio_balloon *vb) |
8093 | names[VIRTIO_BALLOON_VQ_INFLATE] = "inflate"; |
8094 | callbacks[VIRTIO_BALLOON_VQ_DEFLATE] = balloon_ack; |
8095 | names[VIRTIO_BALLOON_VQ_DEFLATE] = "deflate"; |
8096 | + callbacks[VIRTIO_BALLOON_VQ_STATS] = NULL; |
8097 | names[VIRTIO_BALLOON_VQ_STATS] = NULL; |
8098 | + callbacks[VIRTIO_BALLOON_VQ_FREE_PAGE] = NULL; |
8099 | names[VIRTIO_BALLOON_VQ_FREE_PAGE] = NULL; |
8100 | |
8101 | if (virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_STATS_VQ)) { |
8102 | @@ -898,8 +900,7 @@ static int virtballoon_probe(struct virtio_device *vdev) |
8103 | vb->vb_dev_info.inode = alloc_anon_inode(balloon_mnt->mnt_sb); |
8104 | if (IS_ERR(vb->vb_dev_info.inode)) { |
8105 | err = PTR_ERR(vb->vb_dev_info.inode); |
8106 | - kern_unmount(balloon_mnt); |
8107 | - goto out_del_vqs; |
8108 | + goto out_kern_unmount; |
8109 | } |
8110 | vb->vb_dev_info.inode->i_mapping->a_ops = &balloon_aops; |
8111 | #endif |
8112 | @@ -910,13 +911,13 @@ static int virtballoon_probe(struct virtio_device *vdev) |
8113 | */ |
8114 | if (virtqueue_get_vring_size(vb->free_page_vq) < 2) { |
8115 | err = -ENOSPC; |
8116 | - goto out_del_vqs; |
8117 | + goto out_iput; |
8118 | } |
8119 | vb->balloon_wq = alloc_workqueue("balloon-wq", |
8120 | WQ_FREEZABLE | WQ_CPU_INTENSIVE, 0); |
8121 | if (!vb->balloon_wq) { |
8122 | err = -ENOMEM; |
8123 | - goto out_del_vqs; |
8124 | + goto out_iput; |
8125 | } |
8126 | INIT_WORK(&vb->report_free_page_work, report_free_page_func); |
8127 | vb->cmd_id_received_cache = VIRTIO_BALLOON_CMD_ID_STOP; |
8128 | @@ -950,6 +951,12 @@ static int virtballoon_probe(struct virtio_device *vdev) |
8129 | out_del_balloon_wq: |
8130 | if (virtio_has_feature(vdev, VIRTIO_BALLOON_F_FREE_PAGE_HINT)) |
8131 | destroy_workqueue(vb->balloon_wq); |
8132 | +out_iput: |
8133 | +#ifdef CONFIG_BALLOON_COMPACTION |
8134 | + iput(vb->vb_dev_info.inode); |
8135 | +out_kern_unmount: |
8136 | + kern_unmount(balloon_mnt); |
8137 | +#endif |
8138 | out_del_vqs: |
8139 | vdev->config->del_vqs(vdev); |
8140 | out_free_vb: |
8141 | @@ -965,6 +972,10 @@ static void remove_common(struct virtio_balloon *vb) |
8142 | leak_balloon(vb, vb->num_pages); |
8143 | update_balloon_size(vb); |
8144 | |
8145 | + /* There might be free pages that are being reported: release them. */ |
8146 | + if (virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_FREE_PAGE_HINT)) |
8147 | + return_free_pages_to_mm(vb, ULONG_MAX); |
8148 | + |
8149 | /* Now we reset the device so we can clean up the queues. */ |
8150 | vb->vdev->config->reset(vb->vdev); |
8151 | |
8152 | diff --git a/drivers/virtio/virtio_pci_common.c b/drivers/virtio/virtio_pci_common.c |
8153 | index f2862f66c2ac..222d630c41fc 100644 |
8154 | --- a/drivers/virtio/virtio_pci_common.c |
8155 | +++ b/drivers/virtio/virtio_pci_common.c |
8156 | @@ -294,7 +294,7 @@ static int vp_find_vqs_msix(struct virtio_device *vdev, unsigned nvqs, |
8157 | /* Best option: one for change interrupt, one per vq. */ |
8158 | nvectors = 1; |
8159 | for (i = 0; i < nvqs; ++i) |
8160 | - if (callbacks[i]) |
8161 | + if (names[i] && callbacks[i]) |
8162 | ++nvectors; |
8163 | } else { |
8164 | /* Second best: one for change, shared for all vqs. */ |
8165 | diff --git a/drivers/watchdog/watchdog_core.c b/drivers/watchdog/watchdog_core.c |
8166 | index 21e8085b848b..861daf4f37b2 100644 |
8167 | --- a/drivers/watchdog/watchdog_core.c |
8168 | +++ b/drivers/watchdog/watchdog_core.c |
8169 | @@ -147,6 +147,25 @@ int watchdog_init_timeout(struct watchdog_device *wdd, |
8170 | } |
8171 | EXPORT_SYMBOL_GPL(watchdog_init_timeout); |
8172 | |
8173 | +static int watchdog_reboot_notifier(struct notifier_block *nb, |
8174 | + unsigned long code, void *data) |
8175 | +{ |
8176 | + struct watchdog_device *wdd; |
8177 | + |
8178 | + wdd = container_of(nb, struct watchdog_device, reboot_nb); |
8179 | + if (code == SYS_DOWN || code == SYS_HALT) { |
8180 | + if (watchdog_active(wdd)) { |
8181 | + int ret; |
8182 | + |
8183 | + ret = wdd->ops->stop(wdd); |
8184 | + if (ret) |
8185 | + return NOTIFY_BAD; |
8186 | + } |
8187 | + } |
8188 | + |
8189 | + return NOTIFY_DONE; |
8190 | +} |
8191 | + |
8192 | static int watchdog_restart_notifier(struct notifier_block *nb, |
8193 | unsigned long action, void *data) |
8194 | { |
8195 | @@ -235,6 +254,19 @@ static int __watchdog_register_device(struct watchdog_device *wdd) |
8196 | } |
8197 | } |
8198 | |
8199 | + if (test_bit(WDOG_STOP_ON_REBOOT, &wdd->status)) { |
8200 | + wdd->reboot_nb.notifier_call = watchdog_reboot_notifier; |
8201 | + |
8202 | + ret = register_reboot_notifier(&wdd->reboot_nb); |
8203 | + if (ret) { |
8204 | + pr_err("watchdog%d: Cannot register reboot notifier (%d)\n", |
8205 | + wdd->id, ret); |
8206 | + watchdog_dev_unregister(wdd); |
8207 | + ida_simple_remove(&watchdog_ida, id); |
8208 | + return ret; |
8209 | + } |
8210 | + } |
8211 | + |
8212 | if (wdd->ops->restart) { |
8213 | wdd->restart_nb.notifier_call = watchdog_restart_notifier; |
8214 | |
8215 | @@ -289,6 +321,9 @@ static void __watchdog_unregister_device(struct watchdog_device *wdd) |
8216 | if (wdd->ops->restart) |
8217 | unregister_restart_handler(&wdd->restart_nb); |
8218 | |
8219 | + if (test_bit(WDOG_STOP_ON_REBOOT, &wdd->status)) |
8220 | + unregister_reboot_notifier(&wdd->reboot_nb); |
8221 | + |
8222 | watchdog_dev_unregister(wdd); |
8223 | ida_simple_remove(&watchdog_ida, wdd->id); |
8224 | } |
8225 | diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c |
8226 | index 62483a99105c..ce04edc69e5f 100644 |
8227 | --- a/drivers/watchdog/watchdog_dev.c |
8228 | +++ b/drivers/watchdog/watchdog_dev.c |
8229 | @@ -38,7 +38,6 @@ |
8230 | #include <linux/miscdevice.h> /* For handling misc devices */ |
8231 | #include <linux/module.h> /* For module stuff/... */ |
8232 | #include <linux/mutex.h> /* For mutexes */ |
8233 | -#include <linux/reboot.h> /* For reboot notifier */ |
8234 | #include <linux/slab.h> /* For memory functions */ |
8235 | #include <linux/types.h> /* For standard types (like size_t) */ |
8236 | #include <linux/watchdog.h> /* For watchdog specific items */ |
8237 | @@ -1077,25 +1076,6 @@ static void watchdog_cdev_unregister(struct watchdog_device *wdd) |
8238 | put_device(&wd_data->dev); |
8239 | } |
8240 | |
8241 | -static int watchdog_reboot_notifier(struct notifier_block *nb, |
8242 | - unsigned long code, void *data) |
8243 | -{ |
8244 | - struct watchdog_device *wdd; |
8245 | - |
8246 | - wdd = container_of(nb, struct watchdog_device, reboot_nb); |
8247 | - if (code == SYS_DOWN || code == SYS_HALT) { |
8248 | - if (watchdog_active(wdd)) { |
8249 | - int ret; |
8250 | - |
8251 | - ret = wdd->ops->stop(wdd); |
8252 | - if (ret) |
8253 | - return NOTIFY_BAD; |
8254 | - } |
8255 | - } |
8256 | - |
8257 | - return NOTIFY_DONE; |
8258 | -} |
8259 | - |
8260 | /* |
8261 | * watchdog_dev_register: register a watchdog device |
8262 | * @wdd: watchdog device |
8263 | @@ -1114,22 +1094,8 @@ int watchdog_dev_register(struct watchdog_device *wdd) |
8264 | return ret; |
8265 | |
8266 | ret = watchdog_register_pretimeout(wdd); |
8267 | - if (ret) { |
8268 | + if (ret) |
8269 | watchdog_cdev_unregister(wdd); |
8270 | - return ret; |
8271 | - } |
8272 | - |
8273 | - if (test_bit(WDOG_STOP_ON_REBOOT, &wdd->status)) { |
8274 | - wdd->reboot_nb.notifier_call = watchdog_reboot_notifier; |
8275 | - |
8276 | - ret = devm_register_reboot_notifier(&wdd->wd_data->dev, |
8277 | - &wdd->reboot_nb); |
8278 | - if (ret) { |
8279 | - pr_err("watchdog%d: Cannot register reboot notifier (%d)\n", |
8280 | - wdd->id, ret); |
8281 | - watchdog_dev_unregister(wdd); |
8282 | - } |
8283 | - } |
8284 | |
8285 | return ret; |
8286 | } |
8287 | diff --git a/drivers/xen/xen-balloon.c b/drivers/xen/xen-balloon.c |
8288 | index 6d12fc368210..a8d24433c8e9 100644 |
8289 | --- a/drivers/xen/xen-balloon.c |
8290 | +++ b/drivers/xen/xen-balloon.c |
8291 | @@ -94,7 +94,7 @@ static void watch_target(struct xenbus_watch *watch, |
8292 | "%llu", &static_max) == 1)) |
8293 | static_max >>= PAGE_SHIFT - 10; |
8294 | else |
8295 | - static_max = new_target; |
8296 | + static_max = balloon_stats.current_pages; |
8297 | |
8298 | target_diff = (xen_pv_domain() || xen_initial_domain()) ? 0 |
8299 | : static_max - balloon_stats.target_pages; |
8300 | diff --git a/fs/aio.c b/fs/aio.c |
8301 | index 0d9a559d488c..4115d5ad6b90 100644 |
8302 | --- a/fs/aio.c |
8303 | +++ b/fs/aio.c |
8304 | @@ -1610,6 +1610,14 @@ static int aio_fsync(struct fsync_iocb *req, const struct iocb *iocb, |
8305 | return 0; |
8306 | } |
8307 | |
8308 | +static void aio_poll_put_work(struct work_struct *work) |
8309 | +{ |
8310 | + struct poll_iocb *req = container_of(work, struct poll_iocb, work); |
8311 | + struct aio_kiocb *iocb = container_of(req, struct aio_kiocb, poll); |
8312 | + |
8313 | + iocb_put(iocb); |
8314 | +} |
8315 | + |
8316 | static void aio_poll_complete_work(struct work_struct *work) |
8317 | { |
8318 | struct poll_iocb *req = container_of(work, struct poll_iocb, work); |
8319 | @@ -1674,6 +1682,8 @@ static int aio_poll_wake(struct wait_queue_entry *wait, unsigned mode, int sync, |
8320 | list_del_init(&req->wait.entry); |
8321 | |
8322 | if (mask && spin_trylock_irqsave(&iocb->ki_ctx->ctx_lock, flags)) { |
8323 | + struct kioctx *ctx = iocb->ki_ctx; |
8324 | + |
8325 | /* |
8326 | * Try to complete the iocb inline if we can. Use |
8327 | * irqsave/irqrestore because not all filesystems (e.g. fuse) |
8328 | @@ -1683,8 +1693,14 @@ static int aio_poll_wake(struct wait_queue_entry *wait, unsigned mode, int sync, |
8329 | list_del(&iocb->ki_list); |
8330 | iocb->ki_res.res = mangle_poll(mask); |
8331 | req->done = true; |
8332 | - spin_unlock_irqrestore(&iocb->ki_ctx->ctx_lock, flags); |
8333 | - iocb_put(iocb); |
8334 | + if (iocb->ki_eventfd && eventfd_signal_count()) { |
8335 | + iocb = NULL; |
8336 | + INIT_WORK(&req->work, aio_poll_put_work); |
8337 | + schedule_work(&req->work); |
8338 | + } |
8339 | + spin_unlock_irqrestore(&ctx->ctx_lock, flags); |
8340 | + if (iocb) |
8341 | + iocb_put(iocb); |
8342 | } else { |
8343 | schedule_work(&req->work); |
8344 | } |
8345 | diff --git a/fs/attr.c b/fs/attr.c |
8346 | index df28035aa23e..b4bbdbd4c8ca 100644 |
8347 | --- a/fs/attr.c |
8348 | +++ b/fs/attr.c |
8349 | @@ -183,18 +183,12 @@ void setattr_copy(struct inode *inode, const struct iattr *attr) |
8350 | inode->i_uid = attr->ia_uid; |
8351 | if (ia_valid & ATTR_GID) |
8352 | inode->i_gid = attr->ia_gid; |
8353 | - if (ia_valid & ATTR_ATIME) { |
8354 | - inode->i_atime = timestamp_truncate(attr->ia_atime, |
8355 | - inode); |
8356 | - } |
8357 | - if (ia_valid & ATTR_MTIME) { |
8358 | - inode->i_mtime = timestamp_truncate(attr->ia_mtime, |
8359 | - inode); |
8360 | - } |
8361 | - if (ia_valid & ATTR_CTIME) { |
8362 | - inode->i_ctime = timestamp_truncate(attr->ia_ctime, |
8363 | - inode); |
8364 | - } |
8365 | + if (ia_valid & ATTR_ATIME) |
8366 | + inode->i_atime = attr->ia_atime; |
8367 | + if (ia_valid & ATTR_MTIME) |
8368 | + inode->i_mtime = attr->ia_mtime; |
8369 | + if (ia_valid & ATTR_CTIME) |
8370 | + inode->i_ctime = attr->ia_ctime; |
8371 | if (ia_valid & ATTR_MODE) { |
8372 | umode_t mode = attr->ia_mode; |
8373 | |
8374 | @@ -268,8 +262,13 @@ int notify_change(struct dentry * dentry, struct iattr * attr, struct inode **de |
8375 | attr->ia_ctime = now; |
8376 | if (!(ia_valid & ATTR_ATIME_SET)) |
8377 | attr->ia_atime = now; |
8378 | + else |
8379 | + attr->ia_atime = timestamp_truncate(attr->ia_atime, inode); |
8380 | if (!(ia_valid & ATTR_MTIME_SET)) |
8381 | attr->ia_mtime = now; |
8382 | + else |
8383 | + attr->ia_mtime = timestamp_truncate(attr->ia_mtime, inode); |
8384 | + |
8385 | if (ia_valid & ATTR_KILL_PRIV) { |
8386 | error = security_inode_need_killpriv(dentry); |
8387 | if (error < 0) |
8388 | diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c |
8389 | index da9b0f060a9d..a989105d39c8 100644 |
8390 | --- a/fs/btrfs/ctree.c |
8391 | +++ b/fs/btrfs/ctree.c |
8392 | @@ -330,12 +330,10 @@ u64 btrfs_get_tree_mod_seq(struct btrfs_fs_info *fs_info, |
8393 | struct seq_list *elem) |
8394 | { |
8395 | write_lock(&fs_info->tree_mod_log_lock); |
8396 | - spin_lock(&fs_info->tree_mod_seq_lock); |
8397 | if (!elem->seq) { |
8398 | elem->seq = btrfs_inc_tree_mod_seq(fs_info); |
8399 | list_add_tail(&elem->list, &fs_info->tree_mod_seq_list); |
8400 | } |
8401 | - spin_unlock(&fs_info->tree_mod_seq_lock); |
8402 | write_unlock(&fs_info->tree_mod_log_lock); |
8403 | |
8404 | return elem->seq; |
8405 | @@ -355,7 +353,7 @@ void btrfs_put_tree_mod_seq(struct btrfs_fs_info *fs_info, |
8406 | if (!seq_putting) |
8407 | return; |
8408 | |
8409 | - spin_lock(&fs_info->tree_mod_seq_lock); |
8410 | + write_lock(&fs_info->tree_mod_log_lock); |
8411 | list_del(&elem->list); |
8412 | elem->seq = 0; |
8413 | |
8414 | @@ -366,19 +364,17 @@ void btrfs_put_tree_mod_seq(struct btrfs_fs_info *fs_info, |
8415 | * blocker with lower sequence number exists, we |
8416 | * cannot remove anything from the log |
8417 | */ |
8418 | - spin_unlock(&fs_info->tree_mod_seq_lock); |
8419 | + write_unlock(&fs_info->tree_mod_log_lock); |
8420 | return; |
8421 | } |
8422 | min_seq = cur_elem->seq; |
8423 | } |
8424 | } |
8425 | - spin_unlock(&fs_info->tree_mod_seq_lock); |
8426 | |
8427 | /* |
8428 | * anything that's lower than the lowest existing (read: blocked) |
8429 | * sequence number can be removed from the tree. |
8430 | */ |
8431 | - write_lock(&fs_info->tree_mod_log_lock); |
8432 | tm_root = &fs_info->tree_mod_log; |
8433 | for (node = rb_first(tm_root); node; node = next) { |
8434 | next = rb_next(node); |
8435 | diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h |
8436 | index 5e9f80b28fcf..290ca193c6c0 100644 |
8437 | --- a/fs/btrfs/ctree.h |
8438 | +++ b/fs/btrfs/ctree.h |
8439 | @@ -671,14 +671,12 @@ struct btrfs_fs_info { |
8440 | atomic_t nr_delayed_iputs; |
8441 | wait_queue_head_t delayed_iputs_wait; |
8442 | |
8443 | - /* this protects tree_mod_seq_list */ |
8444 | - spinlock_t tree_mod_seq_lock; |
8445 | atomic64_t tree_mod_seq; |
8446 | - struct list_head tree_mod_seq_list; |
8447 | |
8448 | - /* this protects tree_mod_log */ |
8449 | + /* this protects tree_mod_log and tree_mod_seq_list */ |
8450 | rwlock_t tree_mod_log_lock; |
8451 | struct rb_root tree_mod_log; |
8452 | + struct list_head tree_mod_seq_list; |
8453 | |
8454 | atomic_t async_delalloc_pages; |
8455 | |
8456 | diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c |
8457 | index df3bd880061d..dfdb7d4f8406 100644 |
8458 | --- a/fs/btrfs/delayed-ref.c |
8459 | +++ b/fs/btrfs/delayed-ref.c |
8460 | @@ -492,7 +492,7 @@ void btrfs_merge_delayed_refs(struct btrfs_trans_handle *trans, |
8461 | if (head->is_data) |
8462 | return; |
8463 | |
8464 | - spin_lock(&fs_info->tree_mod_seq_lock); |
8465 | + read_lock(&fs_info->tree_mod_log_lock); |
8466 | if (!list_empty(&fs_info->tree_mod_seq_list)) { |
8467 | struct seq_list *elem; |
8468 | |
8469 | @@ -500,7 +500,7 @@ void btrfs_merge_delayed_refs(struct btrfs_trans_handle *trans, |
8470 | struct seq_list, list); |
8471 | seq = elem->seq; |
8472 | } |
8473 | - spin_unlock(&fs_info->tree_mod_seq_lock); |
8474 | + read_unlock(&fs_info->tree_mod_log_lock); |
8475 | |
8476 | again: |
8477 | for (node = rb_first_cached(&head->ref_tree); node; |
8478 | @@ -518,7 +518,7 @@ int btrfs_check_delayed_seq(struct btrfs_fs_info *fs_info, u64 seq) |
8479 | struct seq_list *elem; |
8480 | int ret = 0; |
8481 | |
8482 | - spin_lock(&fs_info->tree_mod_seq_lock); |
8483 | + read_lock(&fs_info->tree_mod_log_lock); |
8484 | if (!list_empty(&fs_info->tree_mod_seq_list)) { |
8485 | elem = list_first_entry(&fs_info->tree_mod_seq_list, |
8486 | struct seq_list, list); |
8487 | @@ -531,7 +531,7 @@ int btrfs_check_delayed_seq(struct btrfs_fs_info *fs_info, u64 seq) |
8488 | } |
8489 | } |
8490 | |
8491 | - spin_unlock(&fs_info->tree_mod_seq_lock); |
8492 | + read_unlock(&fs_info->tree_mod_log_lock); |
8493 | return ret; |
8494 | } |
8495 | |
8496 | diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c |
8497 | index bae334212ee2..7becc5e96f92 100644 |
8498 | --- a/fs/btrfs/disk-io.c |
8499 | +++ b/fs/btrfs/disk-io.c |
8500 | @@ -2016,7 +2016,7 @@ static void free_root_extent_buffers(struct btrfs_root *root) |
8501 | } |
8502 | |
8503 | /* helper to cleanup tree roots */ |
8504 | -static void free_root_pointers(struct btrfs_fs_info *info, int chunk_root) |
8505 | +static void free_root_pointers(struct btrfs_fs_info *info, bool free_chunk_root) |
8506 | { |
8507 | free_root_extent_buffers(info->tree_root); |
8508 | |
8509 | @@ -2025,7 +2025,7 @@ static void free_root_pointers(struct btrfs_fs_info *info, int chunk_root) |
8510 | free_root_extent_buffers(info->csum_root); |
8511 | free_root_extent_buffers(info->quota_root); |
8512 | free_root_extent_buffers(info->uuid_root); |
8513 | - if (chunk_root) |
8514 | + if (free_chunk_root) |
8515 | free_root_extent_buffers(info->chunk_root); |
8516 | free_root_extent_buffers(info->free_space_root); |
8517 | } |
8518 | @@ -2652,7 +2652,6 @@ int open_ctree(struct super_block *sb, |
8519 | spin_lock_init(&fs_info->fs_roots_radix_lock); |
8520 | spin_lock_init(&fs_info->delayed_iput_lock); |
8521 | spin_lock_init(&fs_info->defrag_inodes_lock); |
8522 | - spin_lock_init(&fs_info->tree_mod_seq_lock); |
8523 | spin_lock_init(&fs_info->super_lock); |
8524 | spin_lock_init(&fs_info->buffer_lock); |
8525 | spin_lock_init(&fs_info->unused_bgs_lock); |
8526 | @@ -3324,7 +3323,7 @@ fail_block_groups: |
8527 | btrfs_put_block_group_cache(fs_info); |
8528 | |
8529 | fail_tree_roots: |
8530 | - free_root_pointers(fs_info, 1); |
8531 | + free_root_pointers(fs_info, true); |
8532 | invalidate_inode_pages2(fs_info->btree_inode->i_mapping); |
8533 | |
8534 | fail_sb_buffer: |
8535 | @@ -3356,7 +3355,7 @@ recovery_tree_root: |
8536 | if (!btrfs_test_opt(fs_info, USEBACKUPROOT)) |
8537 | goto fail_tree_roots; |
8538 | |
8539 | - free_root_pointers(fs_info, 0); |
8540 | + free_root_pointers(fs_info, false); |
8541 | |
8542 | /* don't use the log in recovery mode, it won't be valid */ |
8543 | btrfs_set_super_log_root(disk_super, 0); |
8544 | @@ -4047,10 +4046,17 @@ void close_ctree(struct btrfs_fs_info *fs_info) |
8545 | invalidate_inode_pages2(fs_info->btree_inode->i_mapping); |
8546 | btrfs_stop_all_workers(fs_info); |
8547 | |
8548 | - btrfs_free_block_groups(fs_info); |
8549 | - |
8550 | clear_bit(BTRFS_FS_OPEN, &fs_info->flags); |
8551 | - free_root_pointers(fs_info, 1); |
8552 | + free_root_pointers(fs_info, true); |
8553 | + |
8554 | + /* |
8555 | + * We must free the block groups after dropping the fs_roots as we could |
8556 | + * have had an IO error and have left over tree log blocks that aren't |
8557 | + * cleaned up until the fs roots are freed. This makes the block group |
8558 | + * accounting appear to be wrong because there's pending reserved bytes, |
8559 | + * so make sure we do the block group cleanup afterwards. |
8560 | + */ |
8561 | + btrfs_free_block_groups(fs_info); |
8562 | |
8563 | iput(fs_info->btree_inode); |
8564 | |
8565 | diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c |
8566 | index 33c6b191ca59..284540cdbbd9 100644 |
8567 | --- a/fs/btrfs/extent_io.c |
8568 | +++ b/fs/btrfs/extent_io.c |
8569 | @@ -1583,21 +1583,25 @@ void find_first_clear_extent_bit(struct extent_io_tree *tree, u64 start, |
8570 | /* Find first extent with bits cleared */ |
8571 | while (1) { |
8572 | node = __etree_search(tree, start, &next, &prev, NULL, NULL); |
8573 | - if (!node) { |
8574 | + if (!node && !next && !prev) { |
8575 | + /* |
8576 | + * Tree is completely empty, send full range and let |
8577 | + * caller deal with it |
8578 | + */ |
8579 | + *start_ret = 0; |
8580 | + *end_ret = -1; |
8581 | + goto out; |
8582 | + } else if (!node && !next) { |
8583 | + /* |
8584 | + * We are past the last allocated chunk, set start at |
8585 | + * the end of the last extent. |
8586 | + */ |
8587 | + state = rb_entry(prev, struct extent_state, rb_node); |
8588 | + *start_ret = state->end + 1; |
8589 | + *end_ret = -1; |
8590 | + goto out; |
8591 | + } else if (!node) { |
8592 | node = next; |
8593 | - if (!node) { |
8594 | - /* |
8595 | - * We are past the last allocated chunk, |
8596 | - * set start at the end of the last extent. The |
8597 | - * device alloc tree should never be empty so |
8598 | - * prev is always set. |
8599 | - */ |
8600 | - ASSERT(prev); |
8601 | - state = rb_entry(prev, struct extent_state, rb_node); |
8602 | - *start_ret = state->end + 1; |
8603 | - *end_ret = -1; |
8604 | - goto out; |
8605 | - } |
8606 | } |
8607 | /* |
8608 | * At this point 'node' either contains 'start' or start is |
8609 | @@ -3938,6 +3942,11 @@ int btree_write_cache_pages(struct address_space *mapping, |
8610 | if (wbc->range_cyclic) { |
8611 | index = mapping->writeback_index; /* Start from prev offset */ |
8612 | end = -1; |
8613 | + /* |
8614 | + * Start from the beginning does not need to cycle over the |
8615 | + * range, mark it as scanned. |
8616 | + */ |
8617 | + scanned = (index == 0); |
8618 | } else { |
8619 | index = wbc->range_start >> PAGE_SHIFT; |
8620 | end = wbc->range_end >> PAGE_SHIFT; |
8621 | @@ -3955,7 +3964,6 @@ retry: |
8622 | tag))) { |
8623 | unsigned i; |
8624 | |
8625 | - scanned = 1; |
8626 | for (i = 0; i < nr_pages; i++) { |
8627 | struct page *page = pvec.pages[i]; |
8628 | |
8629 | @@ -4084,6 +4092,11 @@ static int extent_write_cache_pages(struct address_space *mapping, |
8630 | if (wbc->range_cyclic) { |
8631 | index = mapping->writeback_index; /* Start from prev offset */ |
8632 | end = -1; |
8633 | + /* |
8634 | + * Start from the beginning does not need to cycle over the |
8635 | + * range, mark it as scanned. |
8636 | + */ |
8637 | + scanned = (index == 0); |
8638 | } else { |
8639 | index = wbc->range_start >> PAGE_SHIFT; |
8640 | end = wbc->range_end >> PAGE_SHIFT; |
8641 | @@ -4117,7 +4130,6 @@ retry: |
8642 | &index, end, tag))) { |
8643 | unsigned i; |
8644 | |
8645 | - scanned = 1; |
8646 | for (i = 0; i < nr_pages; i++) { |
8647 | struct page *page = pvec.pages[i]; |
8648 | |
8649 | @@ -4177,7 +4189,16 @@ retry: |
8650 | */ |
8651 | scanned = 1; |
8652 | index = 0; |
8653 | - goto retry; |
8654 | + |
8655 | + /* |
8656 | + * If we're looping we could run into a page that is locked by a |
8657 | + * writer and that writer could be waiting on writeback for a |
8658 | + * page in our current bio, and thus deadlock, so flush the |
8659 | + * write bio here. |
8660 | + */ |
8661 | + ret = flush_write_bio(epd); |
8662 | + if (!ret) |
8663 | + goto retry; |
8664 | } |
8665 | |
8666 | if (wbc->range_cyclic || (wbc->nr_to_write > 0 && range_whole)) |
8667 | diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c |
8668 | index 8e86b2d700c4..d88b8d8897cc 100644 |
8669 | --- a/fs/btrfs/ioctl.c |
8670 | +++ b/fs/btrfs/ioctl.c |
8671 | @@ -3244,6 +3244,7 @@ static void btrfs_double_extent_lock(struct inode *inode1, u64 loff1, |
8672 | static int btrfs_extent_same_range(struct inode *src, u64 loff, u64 len, |
8673 | struct inode *dst, u64 dst_loff) |
8674 | { |
8675 | + const u64 bs = BTRFS_I(src)->root->fs_info->sb->s_blocksize; |
8676 | int ret; |
8677 | |
8678 | /* |
8679 | @@ -3251,7 +3252,7 @@ static int btrfs_extent_same_range(struct inode *src, u64 loff, u64 len, |
8680 | * source range to serialize with relocation. |
8681 | */ |
8682 | btrfs_double_extent_lock(src, loff, dst, dst_loff, len); |
8683 | - ret = btrfs_clone(src, dst, loff, len, len, dst_loff, 1); |
8684 | + ret = btrfs_clone(src, dst, loff, len, ALIGN(len, bs), dst_loff, 1); |
8685 | btrfs_double_extent_unlock(src, loff, dst, dst_loff, len); |
8686 | |
8687 | return ret; |
8688 | diff --git a/fs/btrfs/tests/btrfs-tests.c b/fs/btrfs/tests/btrfs-tests.c |
8689 | index 99fe9bf3fdac..98f9684e7ffc 100644 |
8690 | --- a/fs/btrfs/tests/btrfs-tests.c |
8691 | +++ b/fs/btrfs/tests/btrfs-tests.c |
8692 | @@ -121,7 +121,6 @@ struct btrfs_fs_info *btrfs_alloc_dummy_fs_info(u32 nodesize, u32 sectorsize) |
8693 | spin_lock_init(&fs_info->qgroup_lock); |
8694 | spin_lock_init(&fs_info->super_lock); |
8695 | spin_lock_init(&fs_info->fs_roots_radix_lock); |
8696 | - spin_lock_init(&fs_info->tree_mod_seq_lock); |
8697 | mutex_init(&fs_info->qgroup_ioctl_lock); |
8698 | mutex_init(&fs_info->qgroup_rescan_lock); |
8699 | rwlock_init(&fs_info->tree_mod_log_lock); |
8700 | diff --git a/fs/btrfs/tests/extent-io-tests.c b/fs/btrfs/tests/extent-io-tests.c |
8701 | index 123d9a614357..df7ce874a74b 100644 |
8702 | --- a/fs/btrfs/tests/extent-io-tests.c |
8703 | +++ b/fs/btrfs/tests/extent-io-tests.c |
8704 | @@ -441,8 +441,17 @@ static int test_find_first_clear_extent_bit(void) |
8705 | int ret = -EINVAL; |
8706 | |
8707 | test_msg("running find_first_clear_extent_bit test"); |
8708 | + |
8709 | extent_io_tree_init(NULL, &tree, IO_TREE_SELFTEST, NULL); |
8710 | |
8711 | + /* Test correct handling of empty tree */ |
8712 | + find_first_clear_extent_bit(&tree, 0, &start, &end, CHUNK_TRIMMED); |
8713 | + if (start != 0 || end != -1) { |
8714 | + test_err( |
8715 | + "error getting a range from completely empty tree: start %llu end %llu", |
8716 | + start, end); |
8717 | + goto out; |
8718 | + } |
8719 | /* |
8720 | * Set 1M-4M alloc/discard and 32M-64M thus leaving a hole between |
8721 | * 4M-32M |
8722 | diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c |
8723 | index 8624bdee8c5b..ceffec752234 100644 |
8724 | --- a/fs/btrfs/transaction.c |
8725 | +++ b/fs/btrfs/transaction.c |
8726 | @@ -77,13 +77,14 @@ void btrfs_put_transaction(struct btrfs_transaction *transaction) |
8727 | } |
8728 | } |
8729 | |
8730 | -static noinline void switch_commit_roots(struct btrfs_transaction *trans) |
8731 | +static noinline void switch_commit_roots(struct btrfs_trans_handle *trans) |
8732 | { |
8733 | + struct btrfs_transaction *cur_trans = trans->transaction; |
8734 | struct btrfs_fs_info *fs_info = trans->fs_info; |
8735 | struct btrfs_root *root, *tmp; |
8736 | |
8737 | down_write(&fs_info->commit_root_sem); |
8738 | - list_for_each_entry_safe(root, tmp, &trans->switch_commits, |
8739 | + list_for_each_entry_safe(root, tmp, &cur_trans->switch_commits, |
8740 | dirty_list) { |
8741 | list_del_init(&root->dirty_list); |
8742 | free_extent_buffer(root->commit_root); |
8743 | @@ -95,16 +96,17 @@ static noinline void switch_commit_roots(struct btrfs_transaction *trans) |
8744 | } |
8745 | |
8746 | /* We can free old roots now. */ |
8747 | - spin_lock(&trans->dropped_roots_lock); |
8748 | - while (!list_empty(&trans->dropped_roots)) { |
8749 | - root = list_first_entry(&trans->dropped_roots, |
8750 | + spin_lock(&cur_trans->dropped_roots_lock); |
8751 | + while (!list_empty(&cur_trans->dropped_roots)) { |
8752 | + root = list_first_entry(&cur_trans->dropped_roots, |
8753 | struct btrfs_root, root_list); |
8754 | list_del_init(&root->root_list); |
8755 | - spin_unlock(&trans->dropped_roots_lock); |
8756 | + spin_unlock(&cur_trans->dropped_roots_lock); |
8757 | + btrfs_free_log(trans, root); |
8758 | btrfs_drop_and_free_fs_root(fs_info, root); |
8759 | - spin_lock(&trans->dropped_roots_lock); |
8760 | + spin_lock(&cur_trans->dropped_roots_lock); |
8761 | } |
8762 | - spin_unlock(&trans->dropped_roots_lock); |
8763 | + spin_unlock(&cur_trans->dropped_roots_lock); |
8764 | up_write(&fs_info->commit_root_sem); |
8765 | } |
8766 | |
8767 | @@ -1359,7 +1361,7 @@ static int qgroup_account_snapshot(struct btrfs_trans_handle *trans, |
8768 | ret = commit_cowonly_roots(trans); |
8769 | if (ret) |
8770 | goto out; |
8771 | - switch_commit_roots(trans->transaction); |
8772 | + switch_commit_roots(trans); |
8773 | ret = btrfs_write_and_wait_transaction(trans); |
8774 | if (ret) |
8775 | btrfs_handle_fs_error(fs_info, ret, |
8776 | @@ -1949,6 +1951,14 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans) |
8777 | struct btrfs_transaction *prev_trans = NULL; |
8778 | int ret; |
8779 | |
8780 | + /* |
8781 | + * Some places just start a transaction to commit it. We need to make |
8782 | + * sure that if this commit fails that the abort code actually marks the |
8783 | + * transaction as failed, so set trans->dirty to make the abort code do |
8784 | + * the right thing. |
8785 | + */ |
8786 | + trans->dirty = true; |
8787 | + |
8788 | /* Stop the commit early if ->aborted is set */ |
8789 | if (unlikely(READ_ONCE(cur_trans->aborted))) { |
8790 | ret = cur_trans->aborted; |
8791 | @@ -2237,7 +2247,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans) |
8792 | list_add_tail(&fs_info->chunk_root->dirty_list, |
8793 | &cur_trans->switch_commits); |
8794 | |
8795 | - switch_commit_roots(cur_trans); |
8796 | + switch_commit_roots(trans); |
8797 | |
8798 | ASSERT(list_empty(&cur_trans->dirty_bgs)); |
8799 | ASSERT(list_empty(&cur_trans->io_bgs)); |
8800 | diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c |
8801 | index ab27e6cd9b3e..6f2178618c22 100644 |
8802 | --- a/fs/btrfs/tree-log.c |
8803 | +++ b/fs/btrfs/tree-log.c |
8804 | @@ -3953,7 +3953,7 @@ static int log_csums(struct btrfs_trans_handle *trans, |
8805 | static noinline int copy_items(struct btrfs_trans_handle *trans, |
8806 | struct btrfs_inode *inode, |
8807 | struct btrfs_path *dst_path, |
8808 | - struct btrfs_path *src_path, u64 *last_extent, |
8809 | + struct btrfs_path *src_path, |
8810 | int start_slot, int nr, int inode_only, |
8811 | u64 logged_isize) |
8812 | { |
8813 | @@ -3964,7 +3964,6 @@ static noinline int copy_items(struct btrfs_trans_handle *trans, |
8814 | struct btrfs_file_extent_item *extent; |
8815 | struct btrfs_inode_item *inode_item; |
8816 | struct extent_buffer *src = src_path->nodes[0]; |
8817 | - struct btrfs_key first_key, last_key, key; |
8818 | int ret; |
8819 | struct btrfs_key *ins_keys; |
8820 | u32 *ins_sizes; |
8821 | @@ -3972,9 +3971,6 @@ static noinline int copy_items(struct btrfs_trans_handle *trans, |
8822 | int i; |
8823 | struct list_head ordered_sums; |
8824 | int skip_csum = inode->flags & BTRFS_INODE_NODATASUM; |
8825 | - bool has_extents = false; |
8826 | - bool need_find_last_extent = true; |
8827 | - bool done = false; |
8828 | |
8829 | INIT_LIST_HEAD(&ordered_sums); |
8830 | |
8831 | @@ -3983,8 +3979,6 @@ static noinline int copy_items(struct btrfs_trans_handle *trans, |
8832 | if (!ins_data) |
8833 | return -ENOMEM; |
8834 | |
8835 | - first_key.objectid = (u64)-1; |
8836 | - |
8837 | ins_sizes = (u32 *)ins_data; |
8838 | ins_keys = (struct btrfs_key *)(ins_data + nr * sizeof(u32)); |
8839 | |
8840 | @@ -4005,9 +3999,6 @@ static noinline int copy_items(struct btrfs_trans_handle *trans, |
8841 | |
8842 | src_offset = btrfs_item_ptr_offset(src, start_slot + i); |
8843 | |
8844 | - if (i == nr - 1) |
8845 | - last_key = ins_keys[i]; |
8846 | - |
8847 | if (ins_keys[i].type == BTRFS_INODE_ITEM_KEY) { |
8848 | inode_item = btrfs_item_ptr(dst_path->nodes[0], |
8849 | dst_path->slots[0], |
8850 | @@ -4021,20 +4012,6 @@ static noinline int copy_items(struct btrfs_trans_handle *trans, |
8851 | src_offset, ins_sizes[i]); |
8852 | } |
8853 | |
8854 | - /* |
8855 | - * We set need_find_last_extent here in case we know we were |
8856 | - * processing other items and then walk into the first extent in |
8857 | - * the inode. If we don't hit an extent then nothing changes, |
8858 | - * we'll do the last search the next time around. |
8859 | - */ |
8860 | - if (ins_keys[i].type == BTRFS_EXTENT_DATA_KEY) { |
8861 | - has_extents = true; |
8862 | - if (first_key.objectid == (u64)-1) |
8863 | - first_key = ins_keys[i]; |
8864 | - } else { |
8865 | - need_find_last_extent = false; |
8866 | - } |
8867 | - |
8868 | /* take a reference on file data extents so that truncates |
8869 | * or deletes of this inode don't have to relog the inode |
8870 | * again |
8871 | @@ -4100,167 +4077,6 @@ static noinline int copy_items(struct btrfs_trans_handle *trans, |
8872 | kfree(sums); |
8873 | } |
8874 | |
8875 | - if (!has_extents) |
8876 | - return ret; |
8877 | - |
8878 | - if (need_find_last_extent && *last_extent == first_key.offset) { |
8879 | - /* |
8880 | - * We don't have any leafs between our current one and the one |
8881 | - * we processed before that can have file extent items for our |
8882 | - * inode (and have a generation number smaller than our current |
8883 | - * transaction id). |
8884 | - */ |
8885 | - need_find_last_extent = false; |
8886 | - } |
8887 | - |
8888 | - /* |
8889 | - * Because we use btrfs_search_forward we could skip leaves that were |
8890 | - * not modified and then assume *last_extent is valid when it really |
8891 | - * isn't. So back up to the previous leaf and read the end of the last |
8892 | - * extent before we go and fill in holes. |
8893 | - */ |
8894 | - if (need_find_last_extent) { |
8895 | - u64 len; |
8896 | - |
8897 | - ret = btrfs_prev_leaf(inode->root, src_path); |
8898 | - if (ret < 0) |
8899 | - return ret; |
8900 | - if (ret) |
8901 | - goto fill_holes; |
8902 | - if (src_path->slots[0]) |
8903 | - src_path->slots[0]--; |
8904 | - src = src_path->nodes[0]; |
8905 | - btrfs_item_key_to_cpu(src, &key, src_path->slots[0]); |
8906 | - if (key.objectid != btrfs_ino(inode) || |
8907 | - key.type != BTRFS_EXTENT_DATA_KEY) |
8908 | - goto fill_holes; |
8909 | - extent = btrfs_item_ptr(src, src_path->slots[0], |
8910 | - struct btrfs_file_extent_item); |
8911 | - if (btrfs_file_extent_type(src, extent) == |
8912 | - BTRFS_FILE_EXTENT_INLINE) { |
8913 | - len = btrfs_file_extent_ram_bytes(src, extent); |
8914 | - *last_extent = ALIGN(key.offset + len, |
8915 | - fs_info->sectorsize); |
8916 | - } else { |
8917 | - len = btrfs_file_extent_num_bytes(src, extent); |
8918 | - *last_extent = key.offset + len; |
8919 | - } |
8920 | - } |
8921 | -fill_holes: |
8922 | - /* So we did prev_leaf, now we need to move to the next leaf, but a few |
8923 | - * things could have happened |
8924 | - * |
8925 | - * 1) A merge could have happened, so we could currently be on a leaf |
8926 | - * that holds what we were copying in the first place. |
8927 | - * 2) A split could have happened, and now not all of the items we want |
8928 | - * are on the same leaf. |
8929 | - * |
8930 | - * So we need to adjust how we search for holes, we need to drop the |
8931 | - * path and re-search for the first extent key we found, and then walk |
8932 | - * forward until we hit the last one we copied. |
8933 | - */ |
8934 | - if (need_find_last_extent) { |
8935 | - /* btrfs_prev_leaf could return 1 without releasing the path */ |
8936 | - btrfs_release_path(src_path); |
8937 | - ret = btrfs_search_slot(NULL, inode->root, &first_key, |
8938 | - src_path, 0, 0); |
8939 | - if (ret < 0) |
8940 | - return ret; |
8941 | - ASSERT(ret == 0); |
8942 | - src = src_path->nodes[0]; |
8943 | - i = src_path->slots[0]; |
8944 | - } else { |
8945 | - i = start_slot; |
8946 | - } |
8947 | - |
8948 | - /* |
8949 | - * Ok so here we need to go through and fill in any holes we may have |
8950 | - * to make sure that holes are punched for those areas in case they had |
8951 | - * extents previously. |
8952 | - */ |
8953 | - while (!done) { |
8954 | - u64 offset, len; |
8955 | - u64 extent_end; |
8956 | - |
8957 | - if (i >= btrfs_header_nritems(src_path->nodes[0])) { |
8958 | - ret = btrfs_next_leaf(inode->root, src_path); |
8959 | - if (ret < 0) |
8960 | - return ret; |
8961 | - ASSERT(ret == 0); |
8962 | - src = src_path->nodes[0]; |
8963 | - i = 0; |
8964 | - need_find_last_extent = true; |
8965 | - } |
8966 | - |
8967 | - btrfs_item_key_to_cpu(src, &key, i); |
8968 | - if (!btrfs_comp_cpu_keys(&key, &last_key)) |
8969 | - done = true; |
8970 | - if (key.objectid != btrfs_ino(inode) || |
8971 | - key.type != BTRFS_EXTENT_DATA_KEY) { |
8972 | - i++; |
8973 | - continue; |
8974 | - } |
8975 | - extent = btrfs_item_ptr(src, i, struct btrfs_file_extent_item); |
8976 | - if (btrfs_file_extent_type(src, extent) == |
8977 | - BTRFS_FILE_EXTENT_INLINE) { |
8978 | - len = btrfs_file_extent_ram_bytes(src, extent); |
8979 | - extent_end = ALIGN(key.offset + len, |
8980 | - fs_info->sectorsize); |
8981 | - } else { |
8982 | - len = btrfs_file_extent_num_bytes(src, extent); |
8983 | - extent_end = key.offset + len; |
8984 | - } |
8985 | - i++; |
8986 | - |
8987 | - if (*last_extent == key.offset) { |
8988 | - *last_extent = extent_end; |
8989 | - continue; |
8990 | - } |
8991 | - offset = *last_extent; |
8992 | - len = key.offset - *last_extent; |
8993 | - ret = btrfs_insert_file_extent(trans, log, btrfs_ino(inode), |
8994 | - offset, 0, 0, len, 0, len, 0, 0, 0); |
8995 | - if (ret) |
8996 | - break; |
8997 | - *last_extent = extent_end; |
8998 | - } |
8999 | - |
9000 | - /* |
9001 | - * Check if there is a hole between the last extent found in our leaf |
9002 | - * and the first extent in the next leaf. If there is one, we need to |
9003 | - * log an explicit hole so that at replay time we can punch the hole. |
9004 | - */ |
9005 | - if (ret == 0 && |
9006 | - key.objectid == btrfs_ino(inode) && |
9007 | - key.type == BTRFS_EXTENT_DATA_KEY && |
9008 | - i == btrfs_header_nritems(src_path->nodes[0])) { |
9009 | - ret = btrfs_next_leaf(inode->root, src_path); |
9010 | - need_find_last_extent = true; |
9011 | - if (ret > 0) { |
9012 | - ret = 0; |
9013 | - } else if (ret == 0) { |
9014 | - btrfs_item_key_to_cpu(src_path->nodes[0], &key, |
9015 | - src_path->slots[0]); |
9016 | - if (key.objectid == btrfs_ino(inode) && |
9017 | - key.type == BTRFS_EXTENT_DATA_KEY && |
9018 | - *last_extent < key.offset) { |
9019 | - const u64 len = key.offset - *last_extent; |
9020 | - |
9021 | - ret = btrfs_insert_file_extent(trans, log, |
9022 | - btrfs_ino(inode), |
9023 | - *last_extent, 0, |
9024 | - 0, len, 0, len, |
9025 | - 0, 0, 0); |
9026 | - *last_extent += len; |
9027 | - } |
9028 | - } |
9029 | - } |
9030 | - /* |
9031 | - * Need to let the callers know we dropped the path so they should |
9032 | - * re-search. |
9033 | - */ |
9034 | - if (!ret && need_find_last_extent) |
9035 | - ret = 1; |
9036 | return ret; |
9037 | } |
9038 | |
9039 | @@ -4425,7 +4241,7 @@ static int btrfs_log_prealloc_extents(struct btrfs_trans_handle *trans, |
9040 | const u64 i_size = i_size_read(&inode->vfs_inode); |
9041 | const u64 ino = btrfs_ino(inode); |
9042 | struct btrfs_path *dst_path = NULL; |
9043 | - u64 last_extent = (u64)-1; |
9044 | + bool dropped_extents = false; |
9045 | int ins_nr = 0; |
9046 | int start_slot; |
9047 | int ret; |
9048 | @@ -4447,8 +4263,7 @@ static int btrfs_log_prealloc_extents(struct btrfs_trans_handle *trans, |
9049 | if (slot >= btrfs_header_nritems(leaf)) { |
9050 | if (ins_nr > 0) { |
9051 | ret = copy_items(trans, inode, dst_path, path, |
9052 | - &last_extent, start_slot, |
9053 | - ins_nr, 1, 0); |
9054 | + start_slot, ins_nr, 1, 0); |
9055 | if (ret < 0) |
9056 | goto out; |
9057 | ins_nr = 0; |
9058 | @@ -4472,8 +4287,7 @@ static int btrfs_log_prealloc_extents(struct btrfs_trans_handle *trans, |
9059 | path->slots[0]++; |
9060 | continue; |
9061 | } |
9062 | - if (last_extent == (u64)-1) { |
9063 | - last_extent = key.offset; |
9064 | + if (!dropped_extents) { |
9065 | /* |
9066 | * Avoid logging extent items logged in past fsync calls |
9067 | * and leading to duplicate keys in the log tree. |
9068 | @@ -4487,6 +4301,7 @@ static int btrfs_log_prealloc_extents(struct btrfs_trans_handle *trans, |
9069 | } while (ret == -EAGAIN); |
9070 | if (ret) |
9071 | goto out; |
9072 | + dropped_extents = true; |
9073 | } |
9074 | if (ins_nr == 0) |
9075 | start_slot = slot; |
9076 | @@ -4501,7 +4316,7 @@ static int btrfs_log_prealloc_extents(struct btrfs_trans_handle *trans, |
9077 | } |
9078 | } |
9079 | if (ins_nr > 0) { |
9080 | - ret = copy_items(trans, inode, dst_path, path, &last_extent, |
9081 | + ret = copy_items(trans, inode, dst_path, path, |
9082 | start_slot, ins_nr, 1, 0); |
9083 | if (ret > 0) |
9084 | ret = 0; |
9085 | @@ -4688,13 +4503,8 @@ static int btrfs_log_all_xattrs(struct btrfs_trans_handle *trans, |
9086 | |
9087 | if (slot >= nritems) { |
9088 | if (ins_nr > 0) { |
9089 | - u64 last_extent = 0; |
9090 | - |
9091 | ret = copy_items(trans, inode, dst_path, path, |
9092 | - &last_extent, start_slot, |
9093 | - ins_nr, 1, 0); |
9094 | - /* can't be 1, extent items aren't processed */ |
9095 | - ASSERT(ret <= 0); |
9096 | + start_slot, ins_nr, 1, 0); |
9097 | if (ret < 0) |
9098 | return ret; |
9099 | ins_nr = 0; |
9100 | @@ -4718,13 +4528,8 @@ static int btrfs_log_all_xattrs(struct btrfs_trans_handle *trans, |
9101 | cond_resched(); |
9102 | } |
9103 | if (ins_nr > 0) { |
9104 | - u64 last_extent = 0; |
9105 | - |
9106 | ret = copy_items(trans, inode, dst_path, path, |
9107 | - &last_extent, start_slot, |
9108 | - ins_nr, 1, 0); |
9109 | - /* can't be 1, extent items aren't processed */ |
9110 | - ASSERT(ret <= 0); |
9111 | + start_slot, ins_nr, 1, 0); |
9112 | if (ret < 0) |
9113 | return ret; |
9114 | } |
9115 | @@ -4733,100 +4538,119 @@ static int btrfs_log_all_xattrs(struct btrfs_trans_handle *trans, |
9116 | } |
9117 | |
9118 | /* |
9119 | - * If the no holes feature is enabled we need to make sure any hole between the |
9120 | - * last extent and the i_size of our inode is explicitly marked in the log. This |
9121 | - * is to make sure that doing something like: |
9122 | - * |
9123 | - * 1) create file with 128Kb of data |
9124 | - * 2) truncate file to 64Kb |
9125 | - * 3) truncate file to 256Kb |
9126 | - * 4) fsync file |
9127 | - * 5) <crash/power failure> |
9128 | - * 6) mount fs and trigger log replay |
9129 | - * |
9130 | - * Will give us a file with a size of 256Kb, the first 64Kb of data match what |
9131 | - * the file had in its first 64Kb of data at step 1 and the last 192Kb of the |
9132 | - * file correspond to a hole. The presence of explicit holes in a log tree is |
9133 | - * what guarantees that log replay will remove/adjust file extent items in the |
9134 | - * fs/subvol tree. |
9135 | - * |
9136 | - * Here we do not need to care about holes between extents, that is already done |
9137 | - * by copy_items(). We also only need to do this in the full sync path, where we |
9138 | - * lookup for extents from the fs/subvol tree only. In the fast path case, we |
9139 | - * lookup the list of modified extent maps and if any represents a hole, we |
9140 | - * insert a corresponding extent representing a hole in the log tree. |
9141 | + * When using the NO_HOLES feature if we punched a hole that causes the |
9142 | + * deletion of entire leafs or all the extent items of the first leaf (the one |
9143 | + * that contains the inode item and references) we may end up not processing |
9144 | + * any extents, because there are no leafs with a generation matching the |
9145 | + * current transaction that have extent items for our inode. So we need to find |
9146 | + * if any holes exist and then log them. We also need to log holes after any |
9147 | + * truncate operation that changes the inode's size. |
9148 | */ |
9149 | -static int btrfs_log_trailing_hole(struct btrfs_trans_handle *trans, |
9150 | - struct btrfs_root *root, |
9151 | - struct btrfs_inode *inode, |
9152 | - struct btrfs_path *path) |
9153 | +static int btrfs_log_holes(struct btrfs_trans_handle *trans, |
9154 | + struct btrfs_root *root, |
9155 | + struct btrfs_inode *inode, |
9156 | + struct btrfs_path *path) |
9157 | { |
9158 | struct btrfs_fs_info *fs_info = root->fs_info; |
9159 | - int ret; |
9160 | struct btrfs_key key; |
9161 | - u64 hole_start; |
9162 | - u64 hole_size; |
9163 | - struct extent_buffer *leaf; |
9164 | - struct btrfs_root *log = root->log_root; |
9165 | const u64 ino = btrfs_ino(inode); |
9166 | const u64 i_size = i_size_read(&inode->vfs_inode); |
9167 | + u64 prev_extent_end = 0; |
9168 | + int ret; |
9169 | |
9170 | - if (!btrfs_fs_incompat(fs_info, NO_HOLES)) |
9171 | + if (!btrfs_fs_incompat(fs_info, NO_HOLES) || i_size == 0) |
9172 | return 0; |
9173 | |
9174 | key.objectid = ino; |
9175 | key.type = BTRFS_EXTENT_DATA_KEY; |
9176 | - key.offset = (u64)-1; |
9177 | + key.offset = 0; |
9178 | |
9179 | ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); |
9180 | - ASSERT(ret != 0); |
9181 | if (ret < 0) |
9182 | return ret; |
9183 | |
9184 | - ASSERT(path->slots[0] > 0); |
9185 | - path->slots[0]--; |
9186 | - leaf = path->nodes[0]; |
9187 | - btrfs_item_key_to_cpu(leaf, &key, path->slots[0]); |
9188 | - |
9189 | - if (key.objectid != ino || key.type != BTRFS_EXTENT_DATA_KEY) { |
9190 | - /* inode does not have any extents */ |
9191 | - hole_start = 0; |
9192 | - hole_size = i_size; |
9193 | - } else { |
9194 | + while (true) { |
9195 | struct btrfs_file_extent_item *extent; |
9196 | + struct extent_buffer *leaf = path->nodes[0]; |
9197 | u64 len; |
9198 | |
9199 | - /* |
9200 | - * If there's an extent beyond i_size, an explicit hole was |
9201 | - * already inserted by copy_items(). |
9202 | - */ |
9203 | - if (key.offset >= i_size) |
9204 | - return 0; |
9205 | + if (path->slots[0] >= btrfs_header_nritems(path->nodes[0])) { |
9206 | + ret = btrfs_next_leaf(root, path); |
9207 | + if (ret < 0) |
9208 | + return ret; |
9209 | + if (ret > 0) { |
9210 | + ret = 0; |
9211 | + break; |
9212 | + } |
9213 | + leaf = path->nodes[0]; |
9214 | + } |
9215 | + |
9216 | + btrfs_item_key_to_cpu(leaf, &key, path->slots[0]); |
9217 | + if (key.objectid != ino || key.type != BTRFS_EXTENT_DATA_KEY) |
9218 | + break; |
9219 | + |
9220 | + /* We have a hole, log it. */ |
9221 | + if (prev_extent_end < key.offset) { |
9222 | + const u64 hole_len = key.offset - prev_extent_end; |
9223 | + |
9224 | + /* |
9225 | + * Release the path to avoid deadlocks with other code |
9226 | + * paths that search the root while holding locks on |
9227 | + * leafs from the log root. |
9228 | + */ |
9229 | + btrfs_release_path(path); |
9230 | + ret = btrfs_insert_file_extent(trans, root->log_root, |
9231 | + ino, prev_extent_end, 0, |
9232 | + 0, hole_len, 0, hole_len, |
9233 | + 0, 0, 0); |
9234 | + if (ret < 0) |
9235 | + return ret; |
9236 | + |
9237 | + /* |
9238 | + * Search for the same key again in the root. Since it's |
9239 | + * an extent item and we are holding the inode lock, the |
9240 | + * key must still exist. If it doesn't just emit warning |
9241 | + * and return an error to fall back to a transaction |
9242 | + * commit. |
9243 | + */ |
9244 | + ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); |
9245 | + if (ret < 0) |
9246 | + return ret; |
9247 | + if (WARN_ON(ret > 0)) |
9248 | + return -ENOENT; |
9249 | + leaf = path->nodes[0]; |
9250 | + } |
9251 | |
9252 | extent = btrfs_item_ptr(leaf, path->slots[0], |
9253 | struct btrfs_file_extent_item); |
9254 | - |
9255 | if (btrfs_file_extent_type(leaf, extent) == |
9256 | - BTRFS_FILE_EXTENT_INLINE) |
9257 | - return 0; |
9258 | + BTRFS_FILE_EXTENT_INLINE) { |
9259 | + len = btrfs_file_extent_ram_bytes(leaf, extent); |
9260 | + prev_extent_end = ALIGN(key.offset + len, |
9261 | + fs_info->sectorsize); |
9262 | + } else { |
9263 | + len = btrfs_file_extent_num_bytes(leaf, extent); |
9264 | + prev_extent_end = key.offset + len; |
9265 | + } |
9266 | |
9267 | - len = btrfs_file_extent_num_bytes(leaf, extent); |
9268 | - /* Last extent goes beyond i_size, no need to log a hole. */ |
9269 | - if (key.offset + len > i_size) |
9270 | - return 0; |
9271 | - hole_start = key.offset + len; |
9272 | - hole_size = i_size - hole_start; |
9273 | + path->slots[0]++; |
9274 | + cond_resched(); |
9275 | } |
9276 | - btrfs_release_path(path); |
9277 | |
9278 | - /* Last extent ends at i_size. */ |
9279 | - if (hole_size == 0) |
9280 | - return 0; |
9281 | + if (prev_extent_end < i_size) { |
9282 | + u64 hole_len; |
9283 | |
9284 | - hole_size = ALIGN(hole_size, fs_info->sectorsize); |
9285 | - ret = btrfs_insert_file_extent(trans, log, ino, hole_start, 0, 0, |
9286 | - hole_size, 0, hole_size, 0, 0, 0); |
9287 | - return ret; |
9288 | + btrfs_release_path(path); |
9289 | + hole_len = ALIGN(i_size - prev_extent_end, fs_info->sectorsize); |
9290 | + ret = btrfs_insert_file_extent(trans, root->log_root, |
9291 | + ino, prev_extent_end, 0, 0, |
9292 | + hole_len, 0, hole_len, |
9293 | + 0, 0, 0); |
9294 | + if (ret < 0) |
9295 | + return ret; |
9296 | + } |
9297 | + |
9298 | + return 0; |
9299 | } |
9300 | |
9301 | /* |
9302 | @@ -5030,6 +4854,50 @@ static int log_conflicting_inodes(struct btrfs_trans_handle *trans, |
9303 | } |
9304 | continue; |
9305 | } |
9306 | + /* |
9307 | + * If the inode was already logged skip it - otherwise we can |
9308 | + * hit an infinite loop. Example: |
9309 | + * |
9310 | + * From the commit root (previous transaction) we have the |
9311 | + * following inodes: |
9312 | + * |
9313 | + * inode 257 a directory |
9314 | + * inode 258 with references "zz" and "zz_link" on inode 257 |
9315 | + * inode 259 with reference "a" on inode 257 |
9316 | + * |
9317 | + * And in the current (uncommitted) transaction we have: |
9318 | + * |
9319 | + * inode 257 a directory, unchanged |
9320 | + * inode 258 with references "a" and "a2" on inode 257 |
9321 | + * inode 259 with reference "zz_link" on inode 257 |
9322 | + * inode 261 with reference "zz" on inode 257 |
9323 | + * |
9324 | + * When logging inode 261 the following infinite loop could |
9325 | + * happen if we don't skip already logged inodes: |
9326 | + * |
9327 | + * - we detect inode 258 as a conflicting inode, with inode 261 |
9328 | + * on reference "zz", and log it; |
9329 | + * |
9330 | + * - we detect inode 259 as a conflicting inode, with inode 258 |
9331 | + * on reference "a", and log it; |
9332 | + * |
9333 | + * - we detect inode 258 as a conflicting inode, with inode 259 |
9334 | + * on reference "zz_link", and log it - again! After this we |
9335 | + * repeat the above steps forever. |
9336 | + */ |
9337 | + spin_lock(&BTRFS_I(inode)->lock); |
9338 | + /* |
9339 | + * Check the inode's logged_trans only instead of |
9340 | + * btrfs_inode_in_log(). This is because the last_log_commit of |
9341 | + * the inode is not updated when we only log that it exists and |
9342 | + * and it has the full sync bit set (see btrfs_log_inode()). |
9343 | + */ |
9344 | + if (BTRFS_I(inode)->logged_trans == trans->transid) { |
9345 | + spin_unlock(&BTRFS_I(inode)->lock); |
9346 | + btrfs_add_delayed_iput(inode); |
9347 | + continue; |
9348 | + } |
9349 | + spin_unlock(&BTRFS_I(inode)->lock); |
9350 | /* |
9351 | * We are safe logging the other inode without acquiring its |
9352 | * lock as long as we log with the LOG_INODE_EXISTS mode. We |
9353 | @@ -5129,7 +4997,6 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans, |
9354 | struct btrfs_key min_key; |
9355 | struct btrfs_key max_key; |
9356 | struct btrfs_root *log = root->log_root; |
9357 | - u64 last_extent = 0; |
9358 | int err = 0; |
9359 | int ret; |
9360 | int nritems; |
9361 | @@ -5307,7 +5174,7 @@ again: |
9362 | ins_start_slot = path->slots[0]; |
9363 | } |
9364 | ret = copy_items(trans, inode, dst_path, path, |
9365 | - &last_extent, ins_start_slot, |
9366 | + ins_start_slot, |
9367 | ins_nr, inode_only, |
9368 | logged_isize); |
9369 | if (ret < 0) { |
9370 | @@ -5330,17 +5197,13 @@ again: |
9371 | if (ins_nr == 0) |
9372 | goto next_slot; |
9373 | ret = copy_items(trans, inode, dst_path, path, |
9374 | - &last_extent, ins_start_slot, |
9375 | + ins_start_slot, |
9376 | ins_nr, inode_only, logged_isize); |
9377 | if (ret < 0) { |
9378 | err = ret; |
9379 | goto out_unlock; |
9380 | } |
9381 | ins_nr = 0; |
9382 | - if (ret) { |
9383 | - btrfs_release_path(path); |
9384 | - continue; |
9385 | - } |
9386 | goto next_slot; |
9387 | } |
9388 | |
9389 | @@ -5353,18 +5216,13 @@ again: |
9390 | goto next_slot; |
9391 | } |
9392 | |
9393 | - ret = copy_items(trans, inode, dst_path, path, &last_extent, |
9394 | + ret = copy_items(trans, inode, dst_path, path, |
9395 | ins_start_slot, ins_nr, inode_only, |
9396 | logged_isize); |
9397 | if (ret < 0) { |
9398 | err = ret; |
9399 | goto out_unlock; |
9400 | } |
9401 | - if (ret) { |
9402 | - ins_nr = 0; |
9403 | - btrfs_release_path(path); |
9404 | - continue; |
9405 | - } |
9406 | ins_nr = 1; |
9407 | ins_start_slot = path->slots[0]; |
9408 | next_slot: |
9409 | @@ -5378,13 +5236,12 @@ next_slot: |
9410 | } |
9411 | if (ins_nr) { |
9412 | ret = copy_items(trans, inode, dst_path, path, |
9413 | - &last_extent, ins_start_slot, |
9414 | + ins_start_slot, |
9415 | ins_nr, inode_only, logged_isize); |
9416 | if (ret < 0) { |
9417 | err = ret; |
9418 | goto out_unlock; |
9419 | } |
9420 | - ret = 0; |
9421 | ins_nr = 0; |
9422 | } |
9423 | btrfs_release_path(path); |
9424 | @@ -5399,14 +5256,13 @@ next_key: |
9425 | } |
9426 | } |
9427 | if (ins_nr) { |
9428 | - ret = copy_items(trans, inode, dst_path, path, &last_extent, |
9429 | + ret = copy_items(trans, inode, dst_path, path, |
9430 | ins_start_slot, ins_nr, inode_only, |
9431 | logged_isize); |
9432 | if (ret < 0) { |
9433 | err = ret; |
9434 | goto out_unlock; |
9435 | } |
9436 | - ret = 0; |
9437 | ins_nr = 0; |
9438 | } |
9439 | |
9440 | @@ -5419,7 +5275,7 @@ next_key: |
9441 | if (max_key.type >= BTRFS_EXTENT_DATA_KEY && !fast_search) { |
9442 | btrfs_release_path(path); |
9443 | btrfs_release_path(dst_path); |
9444 | - err = btrfs_log_trailing_hole(trans, root, inode, path); |
9445 | + err = btrfs_log_holes(trans, root, inode, path); |
9446 | if (err) |
9447 | goto out_unlock; |
9448 | } |
9449 | diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c |
9450 | index 97f1ba7c18b2..f7d9fc1a6fc2 100644 |
9451 | --- a/fs/btrfs/volumes.c |
9452 | +++ b/fs/btrfs/volumes.c |
9453 | @@ -881,17 +881,28 @@ static struct btrfs_fs_devices *find_fsid_changed( |
9454 | /* |
9455 | * Handles the case where scanned device is part of an fs that had |
9456 | * multiple successful changes of FSID but curently device didn't |
9457 | - * observe it. Meaning our fsid will be different than theirs. |
9458 | + * observe it. Meaning our fsid will be different than theirs. We need |
9459 | + * to handle two subcases : |
9460 | + * 1 - The fs still continues to have different METADATA/FSID uuids. |
9461 | + * 2 - The fs is switched back to its original FSID (METADATA/FSID |
9462 | + * are equal). |
9463 | */ |
9464 | list_for_each_entry(fs_devices, &fs_uuids, fs_list) { |
9465 | + /* Changed UUIDs */ |
9466 | if (memcmp(fs_devices->metadata_uuid, fs_devices->fsid, |
9467 | BTRFS_FSID_SIZE) != 0 && |
9468 | memcmp(fs_devices->metadata_uuid, disk_super->metadata_uuid, |
9469 | BTRFS_FSID_SIZE) == 0 && |
9470 | memcmp(fs_devices->fsid, disk_super->fsid, |
9471 | - BTRFS_FSID_SIZE) != 0) { |
9472 | + BTRFS_FSID_SIZE) != 0) |
9473 | + return fs_devices; |
9474 | + |
9475 | + /* Unchanged UUIDs */ |
9476 | + if (memcmp(fs_devices->metadata_uuid, fs_devices->fsid, |
9477 | + BTRFS_FSID_SIZE) == 0 && |
9478 | + memcmp(fs_devices->fsid, disk_super->metadata_uuid, |
9479 | + BTRFS_FSID_SIZE) == 0) |
9480 | return fs_devices; |
9481 | - } |
9482 | } |
9483 | |
9484 | return NULL; |
9485 | diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c |
9486 | index e1cac715d19e..06d932ed097e 100644 |
9487 | --- a/fs/cifs/smb2pdu.c |
9488 | +++ b/fs/cifs/smb2pdu.c |
9489 | @@ -350,9 +350,14 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon) |
9490 | } |
9491 | |
9492 | rc = cifs_negotiate_protocol(0, tcon->ses); |
9493 | - if (!rc && tcon->ses->need_reconnect) |
9494 | + if (!rc && tcon->ses->need_reconnect) { |
9495 | rc = cifs_setup_session(0, tcon->ses, nls_codepage); |
9496 | - |
9497 | + if ((rc == -EACCES) && !tcon->retry) { |
9498 | + rc = -EHOSTDOWN; |
9499 | + mutex_unlock(&tcon->ses->session_mutex); |
9500 | + goto failed; |
9501 | + } |
9502 | + } |
9503 | if (rc || !tcon->need_reconnect) { |
9504 | mutex_unlock(&tcon->ses->session_mutex); |
9505 | goto out; |
9506 | @@ -397,6 +402,7 @@ out: |
9507 | case SMB2_SET_INFO: |
9508 | rc = -EAGAIN; |
9509 | } |
9510 | +failed: |
9511 | unload_nls(nls_codepage); |
9512 | return rc; |
9513 | } |
9514 | diff --git a/fs/configfs/inode.c b/fs/configfs/inode.c |
9515 | index 680aba9c00d5..fd0b5dd68f9e 100644 |
9516 | --- a/fs/configfs/inode.c |
9517 | +++ b/fs/configfs/inode.c |
9518 | @@ -76,14 +76,11 @@ int configfs_setattr(struct dentry * dentry, struct iattr * iattr) |
9519 | if (ia_valid & ATTR_GID) |
9520 | sd_iattr->ia_gid = iattr->ia_gid; |
9521 | if (ia_valid & ATTR_ATIME) |
9522 | - sd_iattr->ia_atime = timestamp_truncate(iattr->ia_atime, |
9523 | - inode); |
9524 | + sd_iattr->ia_atime = iattr->ia_atime; |
9525 | if (ia_valid & ATTR_MTIME) |
9526 | - sd_iattr->ia_mtime = timestamp_truncate(iattr->ia_mtime, |
9527 | - inode); |
9528 | + sd_iattr->ia_mtime = iattr->ia_mtime; |
9529 | if (ia_valid & ATTR_CTIME) |
9530 | - sd_iattr->ia_ctime = timestamp_truncate(iattr->ia_ctime, |
9531 | - inode); |
9532 | + sd_iattr->ia_ctime = iattr->ia_ctime; |
9533 | if (ia_valid & ATTR_MODE) { |
9534 | umode_t mode = iattr->ia_mode; |
9535 | |
9536 | diff --git a/fs/crypto/keyring.c b/fs/crypto/keyring.c |
9537 | index c34fa7c61b43..4ee65b2b6247 100644 |
9538 | --- a/fs/crypto/keyring.c |
9539 | +++ b/fs/crypto/keyring.c |
9540 | @@ -664,9 +664,6 @@ static int check_for_busy_inodes(struct super_block *sb, |
9541 | struct list_head *pos; |
9542 | size_t busy_count = 0; |
9543 | unsigned long ino; |
9544 | - struct dentry *dentry; |
9545 | - char _path[256]; |
9546 | - char *path = NULL; |
9547 | |
9548 | spin_lock(&mk->mk_decrypted_inodes_lock); |
9549 | |
9550 | @@ -685,22 +682,14 @@ static int check_for_busy_inodes(struct super_block *sb, |
9551 | struct fscrypt_info, |
9552 | ci_master_key_link)->ci_inode; |
9553 | ino = inode->i_ino; |
9554 | - dentry = d_find_alias(inode); |
9555 | } |
9556 | spin_unlock(&mk->mk_decrypted_inodes_lock); |
9557 | |
9558 | - if (dentry) { |
9559 | - path = dentry_path(dentry, _path, sizeof(_path)); |
9560 | - dput(dentry); |
9561 | - } |
9562 | - if (IS_ERR_OR_NULL(path)) |
9563 | - path = "(unknown)"; |
9564 | - |
9565 | fscrypt_warn(NULL, |
9566 | - "%s: %zu inode(s) still busy after removing key with %s %*phN, including ino %lu (%s)", |
9567 | + "%s: %zu inode(s) still busy after removing key with %s %*phN, including ino %lu", |
9568 | sb->s_id, busy_count, master_key_spec_type(&mk->mk_spec), |
9569 | master_key_spec_len(&mk->mk_spec), (u8 *)&mk->mk_spec.u, |
9570 | - ino, path); |
9571 | + ino); |
9572 | return -EBUSY; |
9573 | } |
9574 | |
9575 | diff --git a/fs/erofs/decompressor.c b/fs/erofs/decompressor.c |
9576 | index 19f89f9fb10c..23b74b8e8f96 100644 |
9577 | --- a/fs/erofs/decompressor.c |
9578 | +++ b/fs/erofs/decompressor.c |
9579 | @@ -306,24 +306,22 @@ static int z_erofs_shifted_transform(const struct z_erofs_decompress_req *rq, |
9580 | } |
9581 | |
9582 | src = kmap_atomic(*rq->in); |
9583 | - if (!rq->out[0]) { |
9584 | - dst = NULL; |
9585 | - } else { |
9586 | + if (rq->out[0]) { |
9587 | dst = kmap_atomic(rq->out[0]); |
9588 | memcpy(dst + rq->pageofs_out, src, righthalf); |
9589 | + kunmap_atomic(dst); |
9590 | } |
9591 | |
9592 | - if (rq->out[1] == *rq->in) { |
9593 | - memmove(src, src + righthalf, rq->pageofs_out); |
9594 | - } else if (nrpages_out == 2) { |
9595 | - if (dst) |
9596 | - kunmap_atomic(dst); |
9597 | + if (nrpages_out == 2) { |
9598 | DBG_BUGON(!rq->out[1]); |
9599 | - dst = kmap_atomic(rq->out[1]); |
9600 | - memcpy(dst, src + righthalf, rq->pageofs_out); |
9601 | + if (rq->out[1] == *rq->in) { |
9602 | + memmove(src, src + righthalf, rq->pageofs_out); |
9603 | + } else { |
9604 | + dst = kmap_atomic(rq->out[1]); |
9605 | + memcpy(dst, src + righthalf, rq->pageofs_out); |
9606 | + kunmap_atomic(dst); |
9607 | + } |
9608 | } |
9609 | - if (dst) |
9610 | - kunmap_atomic(dst); |
9611 | kunmap_atomic(src); |
9612 | return 0; |
9613 | } |
9614 | diff --git a/fs/eventfd.c b/fs/eventfd.c |
9615 | index 8aa0ea8c55e8..78e41c7c3d05 100644 |
9616 | --- a/fs/eventfd.c |
9617 | +++ b/fs/eventfd.c |
9618 | @@ -24,6 +24,8 @@ |
9619 | #include <linux/seq_file.h> |
9620 | #include <linux/idr.h> |
9621 | |
9622 | +DEFINE_PER_CPU(int, eventfd_wake_count); |
9623 | + |
9624 | static DEFINE_IDA(eventfd_ida); |
9625 | |
9626 | struct eventfd_ctx { |
9627 | @@ -60,12 +62,25 @@ __u64 eventfd_signal(struct eventfd_ctx *ctx, __u64 n) |
9628 | { |
9629 | unsigned long flags; |
9630 | |
9631 | + /* |
9632 | + * Deadlock or stack overflow issues can happen if we recurse here |
9633 | + * through waitqueue wakeup handlers. If the caller users potentially |
9634 | + * nested waitqueues with custom wakeup handlers, then it should |
9635 | + * check eventfd_signal_count() before calling this function. If |
9636 | + * it returns true, the eventfd_signal() call should be deferred to a |
9637 | + * safe context. |
9638 | + */ |
9639 | + if (WARN_ON_ONCE(this_cpu_read(eventfd_wake_count))) |
9640 | + return 0; |
9641 | + |
9642 | spin_lock_irqsave(&ctx->wqh.lock, flags); |
9643 | + this_cpu_inc(eventfd_wake_count); |
9644 | if (ULLONG_MAX - ctx->count < n) |
9645 | n = ULLONG_MAX - ctx->count; |
9646 | ctx->count += n; |
9647 | if (waitqueue_active(&ctx->wqh)) |
9648 | wake_up_locked_poll(&ctx->wqh, EPOLLIN); |
9649 | + this_cpu_dec(eventfd_wake_count); |
9650 | spin_unlock_irqrestore(&ctx->wqh.lock, flags); |
9651 | |
9652 | return n; |
9653 | diff --git a/fs/ext2/super.c b/fs/ext2/super.c |
9654 | index 30c630d73f0f..065cd2d1bdc6 100644 |
9655 | --- a/fs/ext2/super.c |
9656 | +++ b/fs/ext2/super.c |
9657 | @@ -1082,9 +1082,9 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) |
9658 | |
9659 | if (EXT2_BLOCKS_PER_GROUP(sb) == 0) |
9660 | goto cantfind_ext2; |
9661 | - sbi->s_groups_count = ((le32_to_cpu(es->s_blocks_count) - |
9662 | - le32_to_cpu(es->s_first_data_block) - 1) |
9663 | - / EXT2_BLOCKS_PER_GROUP(sb)) + 1; |
9664 | + sbi->s_groups_count = ((le32_to_cpu(es->s_blocks_count) - |
9665 | + le32_to_cpu(es->s_first_data_block) - 1) |
9666 | + / EXT2_BLOCKS_PER_GROUP(sb)) + 1; |
9667 | db_count = (sbi->s_groups_count + EXT2_DESC_PER_BLOCK(sb) - 1) / |
9668 | EXT2_DESC_PER_BLOCK(sb); |
9669 | sbi->s_group_desc = kmalloc_array (db_count, |
9670 | diff --git a/fs/ext4/dir.c b/fs/ext4/dir.c |
9671 | index 6305d5ec25af..5ef8d7ae231b 100644 |
9672 | --- a/fs/ext4/dir.c |
9673 | +++ b/fs/ext4/dir.c |
9674 | @@ -673,9 +673,11 @@ static int ext4_d_compare(const struct dentry *dentry, unsigned int len, |
9675 | const char *str, const struct qstr *name) |
9676 | { |
9677 | struct qstr qstr = {.name = str, .len = len }; |
9678 | - struct inode *inode = dentry->d_parent->d_inode; |
9679 | + const struct dentry *parent = READ_ONCE(dentry->d_parent); |
9680 | + const struct inode *inode = READ_ONCE(parent->d_inode); |
9681 | |
9682 | - if (!IS_CASEFOLDED(inode) || !EXT4_SB(inode->i_sb)->s_encoding) { |
9683 | + if (!inode || !IS_CASEFOLDED(inode) || |
9684 | + !EXT4_SB(inode->i_sb)->s_encoding) { |
9685 | if (len != name->len) |
9686 | return -1; |
9687 | return memcmp(str, name->name, len); |
9688 | @@ -688,10 +690,11 @@ static int ext4_d_hash(const struct dentry *dentry, struct qstr *str) |
9689 | { |
9690 | const struct ext4_sb_info *sbi = EXT4_SB(dentry->d_sb); |
9691 | const struct unicode_map *um = sbi->s_encoding; |
9692 | + const struct inode *inode = READ_ONCE(dentry->d_inode); |
9693 | unsigned char *norm; |
9694 | int len, ret = 0; |
9695 | |
9696 | - if (!IS_CASEFOLDED(dentry->d_inode) || !um) |
9697 | + if (!inode || !IS_CASEFOLDED(inode) || !um) |
9698 | return 0; |
9699 | |
9700 | norm = kmalloc(PATH_MAX, GFP_ATOMIC); |
9701 | diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c |
9702 | index 12ceadef32c5..2cc9f2168b9e 100644 |
9703 | --- a/fs/ext4/page-io.c |
9704 | +++ b/fs/ext4/page-io.c |
9705 | @@ -478,17 +478,26 @@ int ext4_bio_write_page(struct ext4_io_submit *io, |
9706 | gfp_t gfp_flags = GFP_NOFS; |
9707 | unsigned int enc_bytes = round_up(len, i_blocksize(inode)); |
9708 | |
9709 | + /* |
9710 | + * Since bounce page allocation uses a mempool, we can only use |
9711 | + * a waiting mask (i.e. request guaranteed allocation) on the |
9712 | + * first page of the bio. Otherwise it can deadlock. |
9713 | + */ |
9714 | + if (io->io_bio) |
9715 | + gfp_flags = GFP_NOWAIT | __GFP_NOWARN; |
9716 | retry_encrypt: |
9717 | bounce_page = fscrypt_encrypt_pagecache_blocks(page, enc_bytes, |
9718 | 0, gfp_flags); |
9719 | if (IS_ERR(bounce_page)) { |
9720 | ret = PTR_ERR(bounce_page); |
9721 | - if (ret == -ENOMEM && wbc->sync_mode == WB_SYNC_ALL) { |
9722 | - if (io->io_bio) { |
9723 | + if (ret == -ENOMEM && |
9724 | + (io->io_bio || wbc->sync_mode == WB_SYNC_ALL)) { |
9725 | + gfp_flags = GFP_NOFS; |
9726 | + if (io->io_bio) |
9727 | ext4_io_submit(io); |
9728 | - congestion_wait(BLK_RW_ASYNC, HZ/50); |
9729 | - } |
9730 | - gfp_flags |= __GFP_NOFAIL; |
9731 | + else |
9732 | + gfp_flags |= __GFP_NOFAIL; |
9733 | + congestion_wait(BLK_RW_ASYNC, HZ/50); |
9734 | goto retry_encrypt; |
9735 | } |
9736 | bounce_page = NULL; |
9737 | diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c |
9738 | index 4033778bcbbf..84280ad3786c 100644 |
9739 | --- a/fs/f2fs/dir.c |
9740 | +++ b/fs/f2fs/dir.c |
9741 | @@ -1068,24 +1068,27 @@ static int f2fs_d_compare(const struct dentry *dentry, unsigned int len, |
9742 | const char *str, const struct qstr *name) |
9743 | { |
9744 | struct qstr qstr = {.name = str, .len = len }; |
9745 | + const struct dentry *parent = READ_ONCE(dentry->d_parent); |
9746 | + const struct inode *inode = READ_ONCE(parent->d_inode); |
9747 | |
9748 | - if (!IS_CASEFOLDED(dentry->d_parent->d_inode)) { |
9749 | + if (!inode || !IS_CASEFOLDED(inode)) { |
9750 | if (len != name->len) |
9751 | return -1; |
9752 | - return memcmp(str, name, len); |
9753 | + return memcmp(str, name->name, len); |
9754 | } |
9755 | |
9756 | - return f2fs_ci_compare(dentry->d_parent->d_inode, name, &qstr, false); |
9757 | + return f2fs_ci_compare(inode, name, &qstr, false); |
9758 | } |
9759 | |
9760 | static int f2fs_d_hash(const struct dentry *dentry, struct qstr *str) |
9761 | { |
9762 | struct f2fs_sb_info *sbi = F2FS_SB(dentry->d_sb); |
9763 | const struct unicode_map *um = sbi->s_encoding; |
9764 | + const struct inode *inode = READ_ONCE(dentry->d_inode); |
9765 | unsigned char *norm; |
9766 | int len, ret = 0; |
9767 | |
9768 | - if (!IS_CASEFOLDED(dentry->d_inode)) |
9769 | + if (!inode || !IS_CASEFOLDED(inode)) |
9770 | return 0; |
9771 | |
9772 | norm = f2fs_kmalloc(sbi, PATH_MAX, GFP_ATOMIC); |
9773 | diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c |
9774 | index fae665691481..72f308790a8e 100644 |
9775 | --- a/fs/f2fs/file.c |
9776 | +++ b/fs/f2fs/file.c |
9777 | @@ -751,18 +751,12 @@ static void __setattr_copy(struct inode *inode, const struct iattr *attr) |
9778 | inode->i_uid = attr->ia_uid; |
9779 | if (ia_valid & ATTR_GID) |
9780 | inode->i_gid = attr->ia_gid; |
9781 | - if (ia_valid & ATTR_ATIME) { |
9782 | - inode->i_atime = timestamp_truncate(attr->ia_atime, |
9783 | - inode); |
9784 | - } |
9785 | - if (ia_valid & ATTR_MTIME) { |
9786 | - inode->i_mtime = timestamp_truncate(attr->ia_mtime, |
9787 | - inode); |
9788 | - } |
9789 | - if (ia_valid & ATTR_CTIME) { |
9790 | - inode->i_ctime = timestamp_truncate(attr->ia_ctime, |
9791 | - inode); |
9792 | - } |
9793 | + if (ia_valid & ATTR_ATIME) |
9794 | + inode->i_atime = attr->ia_atime; |
9795 | + if (ia_valid & ATTR_MTIME) |
9796 | + inode->i_mtime = attr->ia_mtime; |
9797 | + if (ia_valid & ATTR_CTIME) |
9798 | + inode->i_ctime = attr->ia_ctime; |
9799 | if (ia_valid & ATTR_MODE) { |
9800 | umode_t mode = attr->ia_mode; |
9801 | |
9802 | diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c |
9803 | index 1443cee15863..ea8dbf1458c9 100644 |
9804 | --- a/fs/f2fs/super.c |
9805 | +++ b/fs/f2fs/super.c |
9806 | @@ -1213,9 +1213,11 @@ static int f2fs_statfs_project(struct super_block *sb, |
9807 | return PTR_ERR(dquot); |
9808 | spin_lock(&dquot->dq_dqb_lock); |
9809 | |
9810 | - limit = (dquot->dq_dqb.dqb_bsoftlimit ? |
9811 | - dquot->dq_dqb.dqb_bsoftlimit : |
9812 | - dquot->dq_dqb.dqb_bhardlimit) >> sb->s_blocksize_bits; |
9813 | + limit = min_not_zero(dquot->dq_dqb.dqb_bsoftlimit, |
9814 | + dquot->dq_dqb.dqb_bhardlimit); |
9815 | + if (limit) |
9816 | + limit >>= sb->s_blocksize_bits; |
9817 | + |
9818 | if (limit && buf->f_blocks > limit) { |
9819 | curblock = dquot->dq_dqb.dqb_curspace >> sb->s_blocksize_bits; |
9820 | buf->f_blocks = limit; |
9821 | @@ -1224,9 +1226,9 @@ static int f2fs_statfs_project(struct super_block *sb, |
9822 | (buf->f_blocks - curblock) : 0; |
9823 | } |
9824 | |
9825 | - limit = dquot->dq_dqb.dqb_isoftlimit ? |
9826 | - dquot->dq_dqb.dqb_isoftlimit : |
9827 | - dquot->dq_dqb.dqb_ihardlimit; |
9828 | + limit = min_not_zero(dquot->dq_dqb.dqb_isoftlimit, |
9829 | + dquot->dq_dqb.dqb_ihardlimit); |
9830 | + |
9831 | if (limit && buf->f_files > limit) { |
9832 | buf->f_files = limit; |
9833 | buf->f_ffree = |
9834 | diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c |
9835 | index 335607b8c5c0..76ac9c7d32ec 100644 |
9836 | --- a/fs/fs-writeback.c |
9837 | +++ b/fs/fs-writeback.c |
9838 | @@ -2063,7 +2063,7 @@ void wb_workfn(struct work_struct *work) |
9839 | struct bdi_writeback, dwork); |
9840 | long pages_written; |
9841 | |
9842 | - set_worker_desc("flush-%s", dev_name(wb->bdi->dev)); |
9843 | + set_worker_desc("flush-%s", bdi_dev_name(wb->bdi)); |
9844 | current->flags |= PF_SWAPWRITE; |
9845 | |
9846 | if (likely(!current_is_workqueue_rescuer() || |
9847 | diff --git a/fs/fuse/file.c b/fs/fuse/file.c |
9848 | index ce715380143c..695369f46f92 100644 |
9849 | --- a/fs/fuse/file.c |
9850 | +++ b/fs/fuse/file.c |
9851 | @@ -1465,6 +1465,7 @@ ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter, |
9852 | } |
9853 | ia = NULL; |
9854 | if (nres < 0) { |
9855 | + iov_iter_revert(iter, nbytes); |
9856 | err = nres; |
9857 | break; |
9858 | } |
9859 | @@ -1473,8 +1474,10 @@ ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter, |
9860 | count -= nres; |
9861 | res += nres; |
9862 | pos += nres; |
9863 | - if (nres != nbytes) |
9864 | + if (nres != nbytes) { |
9865 | + iov_iter_revert(iter, nbytes - nres); |
9866 | break; |
9867 | + } |
9868 | if (count) { |
9869 | max_pages = iov_iter_npages(iter, fc->max_pages); |
9870 | ia = fuse_io_alloc(io, max_pages); |
9871 | diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c |
9872 | index 01ff37b76652..4a10b4e7092a 100644 |
9873 | --- a/fs/gfs2/file.c |
9874 | +++ b/fs/gfs2/file.c |
9875 | @@ -833,7 +833,7 @@ static ssize_t gfs2_file_write_iter(struct kiocb *iocb, struct iov_iter *from) |
9876 | struct file *file = iocb->ki_filp; |
9877 | struct inode *inode = file_inode(file); |
9878 | struct gfs2_inode *ip = GFS2_I(inode); |
9879 | - ssize_t written = 0, ret; |
9880 | + ssize_t ret; |
9881 | |
9882 | ret = gfs2_rsqa_alloc(ip); |
9883 | if (ret) |
9884 | @@ -853,68 +853,58 @@ static ssize_t gfs2_file_write_iter(struct kiocb *iocb, struct iov_iter *from) |
9885 | inode_lock(inode); |
9886 | ret = generic_write_checks(iocb, from); |
9887 | if (ret <= 0) |
9888 | - goto out; |
9889 | - |
9890 | - /* We can write back this queue in page reclaim */ |
9891 | - current->backing_dev_info = inode_to_bdi(inode); |
9892 | + goto out_unlock; |
9893 | |
9894 | ret = file_remove_privs(file); |
9895 | if (ret) |
9896 | - goto out2; |
9897 | + goto out_unlock; |
9898 | |
9899 | ret = file_update_time(file); |
9900 | if (ret) |
9901 | - goto out2; |
9902 | + goto out_unlock; |
9903 | |
9904 | if (iocb->ki_flags & IOCB_DIRECT) { |
9905 | struct address_space *mapping = file->f_mapping; |
9906 | - loff_t pos, endbyte; |
9907 | - ssize_t buffered; |
9908 | + ssize_t buffered, ret2; |
9909 | |
9910 | - written = gfs2_file_direct_write(iocb, from); |
9911 | - if (written < 0 || !iov_iter_count(from)) |
9912 | - goto out2; |
9913 | + ret = gfs2_file_direct_write(iocb, from); |
9914 | + if (ret < 0 || !iov_iter_count(from)) |
9915 | + goto out_unlock; |
9916 | |
9917 | - ret = iomap_file_buffered_write(iocb, from, &gfs2_iomap_ops); |
9918 | - if (unlikely(ret < 0)) |
9919 | - goto out2; |
9920 | - buffered = ret; |
9921 | + iocb->ki_flags |= IOCB_DSYNC; |
9922 | + current->backing_dev_info = inode_to_bdi(inode); |
9923 | + buffered = iomap_file_buffered_write(iocb, from, &gfs2_iomap_ops); |
9924 | + current->backing_dev_info = NULL; |
9925 | + if (unlikely(buffered <= 0)) |
9926 | + goto out_unlock; |
9927 | |
9928 | /* |
9929 | * We need to ensure that the page cache pages are written to |
9930 | * disk and invalidated to preserve the expected O_DIRECT |
9931 | - * semantics. |
9932 | + * semantics. If the writeback or invalidate fails, only report |
9933 | + * the direct I/O range as we don't know if the buffered pages |
9934 | + * made it to disk. |
9935 | */ |
9936 | - pos = iocb->ki_pos; |
9937 | - endbyte = pos + buffered - 1; |
9938 | - ret = filemap_write_and_wait_range(mapping, pos, endbyte); |
9939 | - if (!ret) { |
9940 | - iocb->ki_pos += buffered; |
9941 | - written += buffered; |
9942 | - invalidate_mapping_pages(mapping, |
9943 | - pos >> PAGE_SHIFT, |
9944 | - endbyte >> PAGE_SHIFT); |
9945 | - } else { |
9946 | - /* |
9947 | - * We don't know how much we wrote, so just return |
9948 | - * the number of bytes which were direct-written |
9949 | - */ |
9950 | - } |
9951 | + iocb->ki_pos += buffered; |
9952 | + ret2 = generic_write_sync(iocb, buffered); |
9953 | + invalidate_mapping_pages(mapping, |
9954 | + (iocb->ki_pos - buffered) >> PAGE_SHIFT, |
9955 | + (iocb->ki_pos - 1) >> PAGE_SHIFT); |
9956 | + if (!ret || ret2 > 0) |
9957 | + ret += ret2; |
9958 | } else { |
9959 | + current->backing_dev_info = inode_to_bdi(inode); |
9960 | ret = iomap_file_buffered_write(iocb, from, &gfs2_iomap_ops); |
9961 | - if (likely(ret > 0)) |
9962 | + current->backing_dev_info = NULL; |
9963 | + if (likely(ret > 0)) { |
9964 | iocb->ki_pos += ret; |
9965 | + ret = generic_write_sync(iocb, ret); |
9966 | + } |
9967 | } |
9968 | |
9969 | -out2: |
9970 | - current->backing_dev_info = NULL; |
9971 | -out: |
9972 | +out_unlock: |
9973 | inode_unlock(inode); |
9974 | - if (likely(ret > 0)) { |
9975 | - /* Handle various SYNC-type writes */ |
9976 | - ret = generic_write_sync(iocb, ret); |
9977 | - } |
9978 | - return written ? written : ret; |
9979 | + return ret; |
9980 | } |
9981 | |
9982 | static int fallocate_chunk(struct inode *inode, loff_t offset, loff_t len, |
9983 | diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c |
9984 | index e7b9d39955d4..7ca84be20cf6 100644 |
9985 | --- a/fs/gfs2/lops.c |
9986 | +++ b/fs/gfs2/lops.c |
9987 | @@ -421,7 +421,7 @@ static bool gfs2_jhead_pg_srch(struct gfs2_jdesc *jd, |
9988 | |
9989 | for (offset = 0; offset < PAGE_SIZE; offset += sdp->sd_sb.sb_bsize) { |
9990 | if (!__get_log_header(sdp, kaddr + offset, 0, &lh)) { |
9991 | - if (lh.lh_sequence > head->lh_sequence) |
9992 | + if (lh.lh_sequence >= head->lh_sequence) |
9993 | *head = lh; |
9994 | else { |
9995 | ret = true; |
9996 | diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c |
9997 | index 1c58859aa592..ef485f892d1b 100644 |
9998 | --- a/fs/jbd2/journal.c |
9999 | +++ b/fs/jbd2/journal.c |
10000 | @@ -981,6 +981,7 @@ static void *jbd2_seq_info_start(struct seq_file *seq, loff_t *pos) |
10001 | |
10002 | static void *jbd2_seq_info_next(struct seq_file *seq, void *v, loff_t *pos) |
10003 | { |
10004 | + (*pos)++; |
10005 | return NULL; |
10006 | } |
10007 | |
10008 | diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c |
10009 | index e180033e35cf..05ed7be8a634 100644 |
10010 | --- a/fs/nfs/dir.c |
10011 | +++ b/fs/nfs/dir.c |
10012 | @@ -162,6 +162,17 @@ typedef struct { |
10013 | bool eof; |
10014 | } nfs_readdir_descriptor_t; |
10015 | |
10016 | +static |
10017 | +void nfs_readdir_init_array(struct page *page) |
10018 | +{ |
10019 | + struct nfs_cache_array *array; |
10020 | + |
10021 | + array = kmap_atomic(page); |
10022 | + memset(array, 0, sizeof(struct nfs_cache_array)); |
10023 | + array->eof_index = -1; |
10024 | + kunmap_atomic(array); |
10025 | +} |
10026 | + |
10027 | /* |
10028 | * we are freeing strings created by nfs_add_to_readdir_array() |
10029 | */ |
10030 | @@ -174,6 +185,7 @@ void nfs_readdir_clear_array(struct page *page) |
10031 | array = kmap_atomic(page); |
10032 | for (i = 0; i < array->size; i++) |
10033 | kfree(array->array[i].string.name); |
10034 | + array->size = 0; |
10035 | kunmap_atomic(array); |
10036 | } |
10037 | |
10038 | @@ -610,6 +622,8 @@ int nfs_readdir_xdr_to_array(nfs_readdir_descriptor_t *desc, struct page *page, |
10039 | int status = -ENOMEM; |
10040 | unsigned int array_size = ARRAY_SIZE(pages); |
10041 | |
10042 | + nfs_readdir_init_array(page); |
10043 | + |
10044 | entry.prev_cookie = 0; |
10045 | entry.cookie = desc->last_cookie; |
10046 | entry.eof = 0; |
10047 | @@ -626,8 +640,6 @@ int nfs_readdir_xdr_to_array(nfs_readdir_descriptor_t *desc, struct page *page, |
10048 | } |
10049 | |
10050 | array = kmap(page); |
10051 | - memset(array, 0, sizeof(struct nfs_cache_array)); |
10052 | - array->eof_index = -1; |
10053 | |
10054 | status = nfs_readdir_alloc_pages(pages, array_size); |
10055 | if (status < 0) |
10056 | @@ -682,6 +694,7 @@ int nfs_readdir_filler(void *data, struct page* page) |
10057 | unlock_page(page); |
10058 | return 0; |
10059 | error: |
10060 | + nfs_readdir_clear_array(page); |
10061 | unlock_page(page); |
10062 | return ret; |
10063 | } |
10064 | @@ -689,8 +702,6 @@ int nfs_readdir_filler(void *data, struct page* page) |
10065 | static |
10066 | void cache_page_release(nfs_readdir_descriptor_t *desc) |
10067 | { |
10068 | - if (!desc->page->mapping) |
10069 | - nfs_readdir_clear_array(desc->page); |
10070 | put_page(desc->page); |
10071 | desc->page = NULL; |
10072 | } |
10073 | @@ -704,19 +715,28 @@ struct page *get_cache_page(nfs_readdir_descriptor_t *desc) |
10074 | |
10075 | /* |
10076 | * Returns 0 if desc->dir_cookie was found on page desc->page_index |
10077 | + * and locks the page to prevent removal from the page cache. |
10078 | */ |
10079 | static |
10080 | -int find_cache_page(nfs_readdir_descriptor_t *desc) |
10081 | +int find_and_lock_cache_page(nfs_readdir_descriptor_t *desc) |
10082 | { |
10083 | int res; |
10084 | |
10085 | desc->page = get_cache_page(desc); |
10086 | if (IS_ERR(desc->page)) |
10087 | return PTR_ERR(desc->page); |
10088 | - |
10089 | - res = nfs_readdir_search_array(desc); |
10090 | + res = lock_page_killable(desc->page); |
10091 | if (res != 0) |
10092 | - cache_page_release(desc); |
10093 | + goto error; |
10094 | + res = -EAGAIN; |
10095 | + if (desc->page->mapping != NULL) { |
10096 | + res = nfs_readdir_search_array(desc); |
10097 | + if (res == 0) |
10098 | + return 0; |
10099 | + } |
10100 | + unlock_page(desc->page); |
10101 | +error: |
10102 | + cache_page_release(desc); |
10103 | return res; |
10104 | } |
10105 | |
10106 | @@ -731,7 +751,7 @@ int readdir_search_pagecache(nfs_readdir_descriptor_t *desc) |
10107 | desc->last_cookie = 0; |
10108 | } |
10109 | do { |
10110 | - res = find_cache_page(desc); |
10111 | + res = find_and_lock_cache_page(desc); |
10112 | } while (res == -EAGAIN); |
10113 | return res; |
10114 | } |
10115 | @@ -770,7 +790,6 @@ int nfs_do_filldir(nfs_readdir_descriptor_t *desc) |
10116 | desc->eof = true; |
10117 | |
10118 | kunmap(desc->page); |
10119 | - cache_page_release(desc); |
10120 | dfprintk(DIRCACHE, "NFS: nfs_do_filldir() filling ended @ cookie %Lu; returning = %d\n", |
10121 | (unsigned long long)*desc->dir_cookie, res); |
10122 | return res; |
10123 | @@ -816,13 +835,13 @@ int uncached_readdir(nfs_readdir_descriptor_t *desc) |
10124 | |
10125 | status = nfs_do_filldir(desc); |
10126 | |
10127 | + out_release: |
10128 | + nfs_readdir_clear_array(desc->page); |
10129 | + cache_page_release(desc); |
10130 | out: |
10131 | dfprintk(DIRCACHE, "NFS: %s: returns %d\n", |
10132 | __func__, status); |
10133 | return status; |
10134 | - out_release: |
10135 | - cache_page_release(desc); |
10136 | - goto out; |
10137 | } |
10138 | |
10139 | /* The file offset position represents the dirent entry number. A |
10140 | @@ -887,6 +906,8 @@ static int nfs_readdir(struct file *file, struct dir_context *ctx) |
10141 | break; |
10142 | |
10143 | res = nfs_do_filldir(desc); |
10144 | + unlock_page(desc->page); |
10145 | + cache_page_release(desc); |
10146 | if (res < 0) |
10147 | break; |
10148 | } while (!desc->eof); |
10149 | diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c |
10150 | index ef55e9b1cd4e..3007b8945d38 100644 |
10151 | --- a/fs/nfsd/filecache.c |
10152 | +++ b/fs/nfsd/filecache.c |
10153 | @@ -791,6 +791,7 @@ nfsd_file_acquire(struct svc_rqst *rqstp, struct svc_fh *fhp, |
10154 | struct nfsd_file *nf, *new; |
10155 | struct inode *inode; |
10156 | unsigned int hashval; |
10157 | + bool retry = true; |
10158 | |
10159 | /* FIXME: skip this if fh_dentry is already set? */ |
10160 | status = fh_verify(rqstp, fhp, S_IFREG, |
10161 | @@ -826,6 +827,11 @@ wait_for_construction: |
10162 | |
10163 | /* Did construction of this file fail? */ |
10164 | if (!test_bit(NFSD_FILE_HASHED, &nf->nf_flags)) { |
10165 | + if (!retry) { |
10166 | + status = nfserr_jukebox; |
10167 | + goto out; |
10168 | + } |
10169 | + retry = false; |
10170 | nfsd_file_put_noref(nf); |
10171 | goto retry; |
10172 | } |
10173 | diff --git a/fs/nfsd/nfs4layouts.c b/fs/nfsd/nfs4layouts.c |
10174 | index 2681c70283ce..e12409eca7cc 100644 |
10175 | --- a/fs/nfsd/nfs4layouts.c |
10176 | +++ b/fs/nfsd/nfs4layouts.c |
10177 | @@ -675,7 +675,7 @@ nfsd4_cb_layout_done(struct nfsd4_callback *cb, struct rpc_task *task) |
10178 | |
10179 | /* Client gets 2 lease periods to return it */ |
10180 | cutoff = ktime_add_ns(task->tk_start, |
10181 | - nn->nfsd4_lease * NSEC_PER_SEC * 2); |
10182 | + (u64)nn->nfsd4_lease * NSEC_PER_SEC * 2); |
10183 | |
10184 | if (ktime_before(now, cutoff)) { |
10185 | rpc_delay(task, HZ/100); /* 10 mili-seconds */ |
10186 | diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c |
10187 | index 08f6eb2b73f8..1c82d7dd54df 100644 |
10188 | --- a/fs/nfsd/nfs4state.c |
10189 | +++ b/fs/nfsd/nfs4state.c |
10190 | @@ -6550,7 +6550,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, |
10191 | } |
10192 | |
10193 | if (fl_flags & FL_SLEEP) { |
10194 | - nbl->nbl_time = jiffies; |
10195 | + nbl->nbl_time = get_seconds(); |
10196 | spin_lock(&nn->blocked_locks_lock); |
10197 | list_add_tail(&nbl->nbl_list, &lock_sop->lo_blocked); |
10198 | list_add_tail(&nbl->nbl_lru, &nn->blocked_locks_lru); |
10199 | diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h |
10200 | index 46f56afb6cb8..a080789b4d13 100644 |
10201 | --- a/fs/nfsd/state.h |
10202 | +++ b/fs/nfsd/state.h |
10203 | @@ -605,7 +605,7 @@ static inline bool nfsd4_stateid_generation_after(stateid_t *a, stateid_t *b) |
10204 | struct nfsd4_blocked_lock { |
10205 | struct list_head nbl_list; |
10206 | struct list_head nbl_lru; |
10207 | - unsigned long nbl_time; |
10208 | + time_t nbl_time; |
10209 | struct file_lock nbl_lock; |
10210 | struct knfsd_fh nbl_fh; |
10211 | struct nfsd4_callback nbl_cb; |
10212 | diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c |
10213 | index cf423fea0c6f..fc38b9fe4549 100644 |
10214 | --- a/fs/nfsd/vfs.c |
10215 | +++ b/fs/nfsd/vfs.c |
10216 | @@ -975,6 +975,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file, |
10217 | host_err = vfs_iter_write(file, &iter, &pos, flags); |
10218 | if (host_err < 0) |
10219 | goto out_nfserr; |
10220 | + *cnt = host_err; |
10221 | nfsdstats.io_write += *cnt; |
10222 | fsnotify_modify(file); |
10223 | |
10224 | diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c |
10225 | index 6c7388430ad3..d4359a1df3d5 100644 |
10226 | --- a/fs/ntfs/inode.c |
10227 | +++ b/fs/ntfs/inode.c |
10228 | @@ -2899,18 +2899,12 @@ int ntfs_setattr(struct dentry *dentry, struct iattr *attr) |
10229 | ia_valid |= ATTR_MTIME | ATTR_CTIME; |
10230 | } |
10231 | } |
10232 | - if (ia_valid & ATTR_ATIME) { |
10233 | - vi->i_atime = timestamp_truncate(attr->ia_atime, |
10234 | - vi); |
10235 | - } |
10236 | - if (ia_valid & ATTR_MTIME) { |
10237 | - vi->i_mtime = timestamp_truncate(attr->ia_mtime, |
10238 | - vi); |
10239 | - } |
10240 | - if (ia_valid & ATTR_CTIME) { |
10241 | - vi->i_ctime = timestamp_truncate(attr->ia_ctime, |
10242 | - vi); |
10243 | - } |
10244 | + if (ia_valid & ATTR_ATIME) |
10245 | + vi->i_atime = attr->ia_atime; |
10246 | + if (ia_valid & ATTR_MTIME) |
10247 | + vi->i_mtime = attr->ia_mtime; |
10248 | + if (ia_valid & ATTR_CTIME) |
10249 | + vi->i_ctime = attr->ia_ctime; |
10250 | mark_inode_dirty(vi); |
10251 | out: |
10252 | return err; |
10253 | diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c |
10254 | index 9876db52913a..6cd5e4924e4d 100644 |
10255 | --- a/fs/ocfs2/file.c |
10256 | +++ b/fs/ocfs2/file.c |
10257 | @@ -2101,17 +2101,15 @@ static int ocfs2_is_io_unaligned(struct inode *inode, size_t count, loff_t pos) |
10258 | static int ocfs2_inode_lock_for_extent_tree(struct inode *inode, |
10259 | struct buffer_head **di_bh, |
10260 | int meta_level, |
10261 | - int overwrite_io, |
10262 | int write_sem, |
10263 | int wait) |
10264 | { |
10265 | int ret = 0; |
10266 | |
10267 | if (wait) |
10268 | - ret = ocfs2_inode_lock(inode, NULL, meta_level); |
10269 | + ret = ocfs2_inode_lock(inode, di_bh, meta_level); |
10270 | else |
10271 | - ret = ocfs2_try_inode_lock(inode, |
10272 | - overwrite_io ? NULL : di_bh, meta_level); |
10273 | + ret = ocfs2_try_inode_lock(inode, di_bh, meta_level); |
10274 | if (ret < 0) |
10275 | goto out; |
10276 | |
10277 | @@ -2136,6 +2134,7 @@ static int ocfs2_inode_lock_for_extent_tree(struct inode *inode, |
10278 | |
10279 | out_unlock: |
10280 | brelse(*di_bh); |
10281 | + *di_bh = NULL; |
10282 | ocfs2_inode_unlock(inode, meta_level); |
10283 | out: |
10284 | return ret; |
10285 | @@ -2177,7 +2176,6 @@ static int ocfs2_prepare_inode_for_write(struct file *file, |
10286 | ret = ocfs2_inode_lock_for_extent_tree(inode, |
10287 | &di_bh, |
10288 | meta_level, |
10289 | - overwrite_io, |
10290 | write_sem, |
10291 | wait); |
10292 | if (ret < 0) { |
10293 | @@ -2233,13 +2231,13 @@ static int ocfs2_prepare_inode_for_write(struct file *file, |
10294 | &di_bh, |
10295 | meta_level, |
10296 | write_sem); |
10297 | + meta_level = 1; |
10298 | + write_sem = 1; |
10299 | ret = ocfs2_inode_lock_for_extent_tree(inode, |
10300 | &di_bh, |
10301 | meta_level, |
10302 | - overwrite_io, |
10303 | - 1, |
10304 | + write_sem, |
10305 | wait); |
10306 | - write_sem = 1; |
10307 | if (ret < 0) { |
10308 | if (ret != -EAGAIN) |
10309 | mlog_errno(ret); |
10310 | diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c |
10311 | index e235a635d9ec..15e4fa288475 100644 |
10312 | --- a/fs/overlayfs/file.c |
10313 | +++ b/fs/overlayfs/file.c |
10314 | @@ -146,7 +146,7 @@ static loff_t ovl_llseek(struct file *file, loff_t offset, int whence) |
10315 | struct inode *inode = file_inode(file); |
10316 | struct fd real; |
10317 | const struct cred *old_cred; |
10318 | - ssize_t ret; |
10319 | + loff_t ret; |
10320 | |
10321 | /* |
10322 | * The two special cases below do not need to involve real fs, |
10323 | diff --git a/fs/overlayfs/readdir.c b/fs/overlayfs/readdir.c |
10324 | index 47a91c9733a5..7255e6a5838f 100644 |
10325 | --- a/fs/overlayfs/readdir.c |
10326 | +++ b/fs/overlayfs/readdir.c |
10327 | @@ -504,7 +504,13 @@ get: |
10328 | if (err) |
10329 | goto fail; |
10330 | |
10331 | - WARN_ON_ONCE(dir->d_sb->s_dev != stat.dev); |
10332 | + /* |
10333 | + * Directory inode is always on overlay st_dev. |
10334 | + * Non-dir with ovl_same_dev() could be on pseudo st_dev in case |
10335 | + * of xino bits overflow. |
10336 | + */ |
10337 | + WARN_ON_ONCE(S_ISDIR(stat.mode) && |
10338 | + dir->d_sb->s_dev != stat.dev); |
10339 | ino = stat.ino; |
10340 | } else if (xinobits && !OVL_TYPE_UPPER(type)) { |
10341 | ino = ovl_remap_lower_ino(ino, xinobits, |
10342 | diff --git a/fs/read_write.c b/fs/read_write.c |
10343 | index 5bbf587f5bc1..7458fccc59e1 100644 |
10344 | --- a/fs/read_write.c |
10345 | +++ b/fs/read_write.c |
10346 | @@ -1777,10 +1777,9 @@ static int remap_verify_area(struct file *file, loff_t pos, loff_t len, |
10347 | * else. Assume that the offsets have already been checked for block |
10348 | * alignment. |
10349 | * |
10350 | - * For deduplication we always scale down to the previous block because we |
10351 | - * can't meaningfully compare post-EOF contents. |
10352 | - * |
10353 | - * For clone we only link a partial EOF block above the destination file's EOF. |
10354 | + * For clone we only link a partial EOF block above or at the destination file's |
10355 | + * EOF. For deduplication we accept a partial EOF block only if it ends at the |
10356 | + * destination file's EOF (can not link it into the middle of a file). |
10357 | * |
10358 | * Shorten the request if possible. |
10359 | */ |
10360 | @@ -1796,8 +1795,7 @@ static int generic_remap_check_len(struct inode *inode_in, |
10361 | if ((*len & blkmask) == 0) |
10362 | return 0; |
10363 | |
10364 | - if ((remap_flags & REMAP_FILE_DEDUP) || |
10365 | - pos_out + *len < i_size_read(inode_out)) |
10366 | + if (pos_out + *len < i_size_read(inode_out)) |
10367 | new_len &= ~blkmask; |
10368 | |
10369 | if (new_len == *len) |
10370 | diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c |
10371 | index 0b98e3c8b461..6c0e19f7a21f 100644 |
10372 | --- a/fs/ubifs/dir.c |
10373 | +++ b/fs/ubifs/dir.c |
10374 | @@ -228,6 +228,8 @@ static struct dentry *ubifs_lookup(struct inode *dir, struct dentry *dentry, |
10375 | if (nm.hash) { |
10376 | ubifs_assert(c, fname_len(&nm) == 0); |
10377 | ubifs_assert(c, fname_name(&nm) == NULL); |
10378 | + if (nm.hash & ~UBIFS_S_KEY_HASH_MASK) |
10379 | + goto done; /* ENOENT */ |
10380 | dent_key_init_hash(c, &key, dir->i_ino, nm.hash); |
10381 | err = ubifs_tnc_lookup_dh(c, &key, dent, nm.minor_hash); |
10382 | } else { |
10383 | diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c |
10384 | index cd52585c8f4f..a771273fba7e 100644 |
10385 | --- a/fs/ubifs/file.c |
10386 | +++ b/fs/ubifs/file.c |
10387 | @@ -786,7 +786,9 @@ static int ubifs_do_bulk_read(struct ubifs_info *c, struct bu_info *bu, |
10388 | |
10389 | if (page_offset > end_index) |
10390 | break; |
10391 | - page = find_or_create_page(mapping, page_offset, ra_gfp_mask); |
10392 | + page = pagecache_get_page(mapping, page_offset, |
10393 | + FGP_LOCK|FGP_ACCESSED|FGP_CREAT|FGP_NOWAIT, |
10394 | + ra_gfp_mask); |
10395 | if (!page) |
10396 | break; |
10397 | if (!PageUptodate(page)) |
10398 | @@ -1078,18 +1080,12 @@ static void do_attr_changes(struct inode *inode, const struct iattr *attr) |
10399 | inode->i_uid = attr->ia_uid; |
10400 | if (attr->ia_valid & ATTR_GID) |
10401 | inode->i_gid = attr->ia_gid; |
10402 | - if (attr->ia_valid & ATTR_ATIME) { |
10403 | - inode->i_atime = timestamp_truncate(attr->ia_atime, |
10404 | - inode); |
10405 | - } |
10406 | - if (attr->ia_valid & ATTR_MTIME) { |
10407 | - inode->i_mtime = timestamp_truncate(attr->ia_mtime, |
10408 | - inode); |
10409 | - } |
10410 | - if (attr->ia_valid & ATTR_CTIME) { |
10411 | - inode->i_ctime = timestamp_truncate(attr->ia_ctime, |
10412 | - inode); |
10413 | - } |
10414 | + if (attr->ia_valid & ATTR_ATIME) |
10415 | + inode->i_atime = attr->ia_atime; |
10416 | + if (attr->ia_valid & ATTR_MTIME) |
10417 | + inode->i_mtime = attr->ia_mtime; |
10418 | + if (attr->ia_valid & ATTR_CTIME) |
10419 | + inode->i_ctime = attr->ia_ctime; |
10420 | if (attr->ia_valid & ATTR_MODE) { |
10421 | umode_t mode = attr->ia_mode; |
10422 | |
10423 | diff --git a/fs/ubifs/ioctl.c b/fs/ubifs/ioctl.c |
10424 | index 5dc5abca11c7..eeb1be259888 100644 |
10425 | --- a/fs/ubifs/ioctl.c |
10426 | +++ b/fs/ubifs/ioctl.c |
10427 | @@ -113,7 +113,8 @@ static int setflags(struct inode *inode, int flags) |
10428 | if (err) |
10429 | goto out_unlock; |
10430 | |
10431 | - ui->flags = ioctl2ubifs(flags); |
10432 | + ui->flags &= ~ioctl2ubifs(UBIFS_SUPPORTED_IOCTL_FLAGS); |
10433 | + ui->flags |= ioctl2ubifs(flags); |
10434 | ubifs_set_inode_flags(inode); |
10435 | inode->i_ctime = current_time(inode); |
10436 | release = ui->dirty; |
10437 | diff --git a/fs/ubifs/sb.c b/fs/ubifs/sb.c |
10438 | index a551eb3e9b89..6681c18e52b8 100644 |
10439 | --- a/fs/ubifs/sb.c |
10440 | +++ b/fs/ubifs/sb.c |
10441 | @@ -161,7 +161,7 @@ static int create_default_filesystem(struct ubifs_info *c) |
10442 | sup = kzalloc(ALIGN(UBIFS_SB_NODE_SZ, c->min_io_size), GFP_KERNEL); |
10443 | mst = kzalloc(c->mst_node_alsz, GFP_KERNEL); |
10444 | idx_node_size = ubifs_idx_node_sz(c, 1); |
10445 | - idx = kzalloc(ALIGN(tmp, c->min_io_size), GFP_KERNEL); |
10446 | + idx = kzalloc(ALIGN(idx_node_size, c->min_io_size), GFP_KERNEL); |
10447 | ino = kzalloc(ALIGN(UBIFS_INO_NODE_SZ, c->min_io_size), GFP_KERNEL); |
10448 | cs = kzalloc(ALIGN(UBIFS_CS_NODE_SZ, c->min_io_size), GFP_KERNEL); |
10449 | |
10450 | diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c |
10451 | index 5e1e8ec0589e..7fc2f3f07c16 100644 |
10452 | --- a/fs/ubifs/super.c |
10453 | +++ b/fs/ubifs/super.c |
10454 | @@ -1599,6 +1599,7 @@ out_free: |
10455 | vfree(c->ileb_buf); |
10456 | vfree(c->sbuf); |
10457 | kfree(c->bottom_up_buf); |
10458 | + kfree(c->sup_node); |
10459 | ubifs_debugging_exit(c); |
10460 | return err; |
10461 | } |
10462 | @@ -1641,6 +1642,7 @@ static void ubifs_umount(struct ubifs_info *c) |
10463 | vfree(c->ileb_buf); |
10464 | vfree(c->sbuf); |
10465 | kfree(c->bottom_up_buf); |
10466 | + kfree(c->sup_node); |
10467 | ubifs_debugging_exit(c); |
10468 | } |
10469 | |
10470 | diff --git a/fs/utimes.c b/fs/utimes.c |
10471 | index 1ba3f7883870..090739322463 100644 |
10472 | --- a/fs/utimes.c |
10473 | +++ b/fs/utimes.c |
10474 | @@ -36,14 +36,14 @@ static int utimes_common(const struct path *path, struct timespec64 *times) |
10475 | if (times[0].tv_nsec == UTIME_OMIT) |
10476 | newattrs.ia_valid &= ~ATTR_ATIME; |
10477 | else if (times[0].tv_nsec != UTIME_NOW) { |
10478 | - newattrs.ia_atime = timestamp_truncate(times[0], inode); |
10479 | + newattrs.ia_atime = times[0]; |
10480 | newattrs.ia_valid |= ATTR_ATIME_SET; |
10481 | } |
10482 | |
10483 | if (times[1].tv_nsec == UTIME_OMIT) |
10484 | newattrs.ia_valid &= ~ATTR_MTIME; |
10485 | else if (times[1].tv_nsec != UTIME_NOW) { |
10486 | - newattrs.ia_mtime = timestamp_truncate(times[1], inode); |
10487 | + newattrs.ia_mtime = times[1]; |
10488 | newattrs.ia_valid |= ATTR_MTIME_SET; |
10489 | } |
10490 | /* |
10491 | diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h |
10492 | index 04c0644006fd..c716ea81e653 100644 |
10493 | --- a/include/asm-generic/tlb.h |
10494 | +++ b/include/asm-generic/tlb.h |
10495 | @@ -137,13 +137,6 @@ |
10496 | * When used, an architecture is expected to provide __tlb_remove_table() |
10497 | * which does the actual freeing of these pages. |
10498 | * |
10499 | - * HAVE_RCU_TABLE_NO_INVALIDATE |
10500 | - * |
10501 | - * This makes HAVE_RCU_TABLE_FREE avoid calling tlb_flush_mmu_tlbonly() before |
10502 | - * freeing the page-table pages. This can be avoided if you use |
10503 | - * HAVE_RCU_TABLE_FREE and your architecture does _NOT_ use the Linux |
10504 | - * page-tables natively. |
10505 | - * |
10506 | * MMU_GATHER_NO_RANGE |
10507 | * |
10508 | * Use this if your architecture lacks an efficient flush_tlb_range(). |
10509 | @@ -189,8 +182,23 @@ struct mmu_table_batch { |
10510 | |
10511 | extern void tlb_remove_table(struct mmu_gather *tlb, void *table); |
10512 | |
10513 | +/* |
10514 | + * This allows an architecture that does not use the linux page-tables for |
10515 | + * hardware to skip the TLBI when freeing page tables. |
10516 | + */ |
10517 | +#ifndef tlb_needs_table_invalidate |
10518 | +#define tlb_needs_table_invalidate() (true) |
10519 | +#endif |
10520 | + |
10521 | +#else |
10522 | + |
10523 | +#ifdef tlb_needs_table_invalidate |
10524 | +#error tlb_needs_table_invalidate() requires HAVE_RCU_TABLE_FREE |
10525 | #endif |
10526 | |
10527 | +#endif /* CONFIG_HAVE_RCU_TABLE_FREE */ |
10528 | + |
10529 | + |
10530 | #ifndef CONFIG_HAVE_MMU_GATHER_NO_GATHER |
10531 | /* |
10532 | * If we can't allocate a page to make a big batch of page pointers |
10533 | diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h |
10534 | index 97967ce06de3..f88197c1ffc2 100644 |
10535 | --- a/include/linux/backing-dev.h |
10536 | +++ b/include/linux/backing-dev.h |
10537 | @@ -13,6 +13,7 @@ |
10538 | #include <linux/fs.h> |
10539 | #include <linux/sched.h> |
10540 | #include <linux/blkdev.h> |
10541 | +#include <linux/device.h> |
10542 | #include <linux/writeback.h> |
10543 | #include <linux/blk-cgroup.h> |
10544 | #include <linux/backing-dev-defs.h> |
10545 | @@ -504,4 +505,13 @@ static inline int bdi_rw_congested(struct backing_dev_info *bdi) |
10546 | (1 << WB_async_congested)); |
10547 | } |
10548 | |
10549 | +extern const char *bdi_unknown_name; |
10550 | + |
10551 | +static inline const char *bdi_dev_name(struct backing_dev_info *bdi) |
10552 | +{ |
10553 | + if (!bdi || !bdi->dev) |
10554 | + return bdi_unknown_name; |
10555 | + return dev_name(bdi->dev); |
10556 | +} |
10557 | + |
10558 | #endif /* _LINUX_BACKING_DEV_H */ |
10559 | diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h |
10560 | index 31b1b0e03df8..018dce868de6 100644 |
10561 | --- a/include/linux/cpufreq.h |
10562 | +++ b/include/linux/cpufreq.h |
10563 | @@ -148,6 +148,20 @@ struct cpufreq_policy { |
10564 | struct notifier_block nb_max; |
10565 | }; |
10566 | |
10567 | +/* |
10568 | + * Used for passing new cpufreq policy data to the cpufreq driver's ->verify() |
10569 | + * callback for sanitization. That callback is only expected to modify the min |
10570 | + * and max values, if necessary, and specifically it must not update the |
10571 | + * frequency table. |
10572 | + */ |
10573 | +struct cpufreq_policy_data { |
10574 | + struct cpufreq_cpuinfo cpuinfo; |
10575 | + struct cpufreq_frequency_table *freq_table; |
10576 | + unsigned int cpu; |
10577 | + unsigned int min; /* in kHz */ |
10578 | + unsigned int max; /* in kHz */ |
10579 | +}; |
10580 | + |
10581 | struct cpufreq_freqs { |
10582 | struct cpufreq_policy *policy; |
10583 | unsigned int old; |
10584 | @@ -201,8 +215,6 @@ u64 get_cpu_idle_time(unsigned int cpu, u64 *wall, int io_busy); |
10585 | struct cpufreq_policy *cpufreq_cpu_acquire(unsigned int cpu); |
10586 | void cpufreq_cpu_release(struct cpufreq_policy *policy); |
10587 | int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu); |
10588 | -int cpufreq_set_policy(struct cpufreq_policy *policy, |
10589 | - struct cpufreq_policy *new_policy); |
10590 | void refresh_frequency_limits(struct cpufreq_policy *policy); |
10591 | void cpufreq_update_policy(unsigned int cpu); |
10592 | void cpufreq_update_limits(unsigned int cpu); |
10593 | @@ -284,7 +296,7 @@ struct cpufreq_driver { |
10594 | |
10595 | /* needed by all drivers */ |
10596 | int (*init)(struct cpufreq_policy *policy); |
10597 | - int (*verify)(struct cpufreq_policy *policy); |
10598 | + int (*verify)(struct cpufreq_policy_data *policy); |
10599 | |
10600 | /* define one out of two */ |
10601 | int (*setpolicy)(struct cpufreq_policy *policy); |
10602 | @@ -415,8 +427,9 @@ static inline int cpufreq_thermal_control_enabled(struct cpufreq_driver *drv) |
10603 | (drv->flags & CPUFREQ_IS_COOLING_DEV); |
10604 | } |
10605 | |
10606 | -static inline void cpufreq_verify_within_limits(struct cpufreq_policy *policy, |
10607 | - unsigned int min, unsigned int max) |
10608 | +static inline void cpufreq_verify_within_limits(struct cpufreq_policy_data *policy, |
10609 | + unsigned int min, |
10610 | + unsigned int max) |
10611 | { |
10612 | if (policy->min < min) |
10613 | policy->min = min; |
10614 | @@ -432,10 +445,10 @@ static inline void cpufreq_verify_within_limits(struct cpufreq_policy *policy, |
10615 | } |
10616 | |
10617 | static inline void |
10618 | -cpufreq_verify_within_cpu_limits(struct cpufreq_policy *policy) |
10619 | +cpufreq_verify_within_cpu_limits(struct cpufreq_policy_data *policy) |
10620 | { |
10621 | cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, |
10622 | - policy->cpuinfo.max_freq); |
10623 | + policy->cpuinfo.max_freq); |
10624 | } |
10625 | |
10626 | #ifdef CONFIG_CPU_FREQ |
10627 | @@ -513,6 +526,7 @@ static inline unsigned long cpufreq_scale(unsigned long old, u_int div, |
10628 | * CPUFREQ GOVERNORS * |
10629 | *********************************************************************/ |
10630 | |
10631 | +#define CPUFREQ_POLICY_UNKNOWN (0) |
10632 | /* |
10633 | * If (cpufreq_driver->target) exists, the ->governor decides what frequency |
10634 | * within the limits is used. If (cpufreq_driver->setpolicy> exists, these |
10635 | @@ -684,9 +698,9 @@ static inline void dev_pm_opp_free_cpufreq_table(struct device *dev, |
10636 | int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy, |
10637 | struct cpufreq_frequency_table *table); |
10638 | |
10639 | -int cpufreq_frequency_table_verify(struct cpufreq_policy *policy, |
10640 | +int cpufreq_frequency_table_verify(struct cpufreq_policy_data *policy, |
10641 | struct cpufreq_frequency_table *table); |
10642 | -int cpufreq_generic_frequency_table_verify(struct cpufreq_policy *policy); |
10643 | +int cpufreq_generic_frequency_table_verify(struct cpufreq_policy_data *policy); |
10644 | |
10645 | int cpufreq_table_index_unsorted(struct cpufreq_policy *policy, |
10646 | unsigned int target_freq, |
10647 | diff --git a/include/linux/eventfd.h b/include/linux/eventfd.h |
10648 | index ffcc7724ca21..dc4fd8a6644d 100644 |
10649 | --- a/include/linux/eventfd.h |
10650 | +++ b/include/linux/eventfd.h |
10651 | @@ -12,6 +12,8 @@ |
10652 | #include <linux/fcntl.h> |
10653 | #include <linux/wait.h> |
10654 | #include <linux/err.h> |
10655 | +#include <linux/percpu-defs.h> |
10656 | +#include <linux/percpu.h> |
10657 | |
10658 | /* |
10659 | * CAREFUL: Check include/uapi/asm-generic/fcntl.h when defining |
10660 | @@ -40,6 +42,13 @@ __u64 eventfd_signal(struct eventfd_ctx *ctx, __u64 n); |
10661 | int eventfd_ctx_remove_wait_queue(struct eventfd_ctx *ctx, wait_queue_entry_t *wait, |
10662 | __u64 *cnt); |
10663 | |
10664 | +DECLARE_PER_CPU(int, eventfd_wake_count); |
10665 | + |
10666 | +static inline bool eventfd_signal_count(void) |
10667 | +{ |
10668 | + return this_cpu_read(eventfd_wake_count); |
10669 | +} |
10670 | + |
10671 | #else /* CONFIG_EVENTFD */ |
10672 | |
10673 | /* |
10674 | @@ -68,6 +77,11 @@ static inline int eventfd_ctx_remove_wait_queue(struct eventfd_ctx *ctx, |
10675 | return -ENOSYS; |
10676 | } |
10677 | |
10678 | +static inline bool eventfd_signal_count(void) |
10679 | +{ |
10680 | + return false; |
10681 | +} |
10682 | + |
10683 | #endif |
10684 | |
10685 | #endif /* _LINUX_EVENTFD_H */ |
10686 | diff --git a/include/linux/irq.h b/include/linux/irq.h |
10687 | index fb301cf29148..f8755e5fcd74 100644 |
10688 | --- a/include/linux/irq.h |
10689 | +++ b/include/linux/irq.h |
10690 | @@ -209,6 +209,8 @@ struct irq_data { |
10691 | * IRQD_SINGLE_TARGET - IRQ allows only a single affinity target |
10692 | * IRQD_DEFAULT_TRIGGER_SET - Expected trigger already been set |
10693 | * IRQD_CAN_RESERVE - Can use reservation mode |
10694 | + * IRQD_MSI_NOMASK_QUIRK - Non-maskable MSI quirk for affinity change |
10695 | + * required |
10696 | */ |
10697 | enum { |
10698 | IRQD_TRIGGER_MASK = 0xf, |
10699 | @@ -231,6 +233,7 @@ enum { |
10700 | IRQD_SINGLE_TARGET = (1 << 24), |
10701 | IRQD_DEFAULT_TRIGGER_SET = (1 << 25), |
10702 | IRQD_CAN_RESERVE = (1 << 26), |
10703 | + IRQD_MSI_NOMASK_QUIRK = (1 << 27), |
10704 | }; |
10705 | |
10706 | #define __irqd_to_state(d) ACCESS_PRIVATE((d)->common, state_use_accessors) |
10707 | @@ -390,6 +393,21 @@ static inline bool irqd_can_reserve(struct irq_data *d) |
10708 | return __irqd_to_state(d) & IRQD_CAN_RESERVE; |
10709 | } |
10710 | |
10711 | +static inline void irqd_set_msi_nomask_quirk(struct irq_data *d) |
10712 | +{ |
10713 | + __irqd_to_state(d) |= IRQD_MSI_NOMASK_QUIRK; |
10714 | +} |
10715 | + |
10716 | +static inline void irqd_clr_msi_nomask_quirk(struct irq_data *d) |
10717 | +{ |
10718 | + __irqd_to_state(d) &= ~IRQD_MSI_NOMASK_QUIRK; |
10719 | +} |
10720 | + |
10721 | +static inline bool irqd_msi_nomask_quirk(struct irq_data *d) |
10722 | +{ |
10723 | + return __irqd_to_state(d) & IRQD_MSI_NOMASK_QUIRK; |
10724 | +} |
10725 | + |
10726 | #undef __irqd_to_state |
10727 | |
10728 | static inline irq_hw_number_t irqd_to_hwirq(struct irq_data *d) |
10729 | diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h |
10730 | index 583e7abd07f9..aba5ada373d6 100644 |
10731 | --- a/include/linux/irqdomain.h |
10732 | +++ b/include/linux/irqdomain.h |
10733 | @@ -205,6 +205,13 @@ enum { |
10734 | /* Irq domain implements MSI remapping */ |
10735 | IRQ_DOMAIN_FLAG_MSI_REMAP = (1 << 5), |
10736 | |
10737 | + /* |
10738 | + * Quirk to handle MSI implementations which do not provide |
10739 | + * masking. Currently known to affect x86, but partially |
10740 | + * handled in core code. |
10741 | + */ |
10742 | + IRQ_DOMAIN_MSI_NOMASK_QUIRK = (1 << 6), |
10743 | + |
10744 | /* |
10745 | * Flags starting from IRQ_DOMAIN_FLAG_NONCORE are reserved |
10746 | * for implementation specific purposes and ignored by the |
10747 | diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h |
10748 | index d41c521a39da..b81f0f1ded5f 100644 |
10749 | --- a/include/linux/kvm_host.h |
10750 | +++ b/include/linux/kvm_host.h |
10751 | @@ -204,7 +204,7 @@ struct kvm_async_pf { |
10752 | struct list_head queue; |
10753 | struct kvm_vcpu *vcpu; |
10754 | struct mm_struct *mm; |
10755 | - gva_t gva; |
10756 | + gpa_t cr2_or_gpa; |
10757 | unsigned long addr; |
10758 | struct kvm_arch_async_pf arch; |
10759 | bool wakeup_all; |
10760 | @@ -212,8 +212,8 @@ struct kvm_async_pf { |
10761 | |
10762 | void kvm_clear_async_pf_completion_queue(struct kvm_vcpu *vcpu); |
10763 | void kvm_check_async_pf_completion(struct kvm_vcpu *vcpu); |
10764 | -int kvm_setup_async_pf(struct kvm_vcpu *vcpu, gva_t gva, unsigned long hva, |
10765 | - struct kvm_arch_async_pf *arch); |
10766 | +int kvm_setup_async_pf(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa, |
10767 | + unsigned long hva, struct kvm_arch_async_pf *arch); |
10768 | int kvm_async_pf_wakeup_all(struct kvm_vcpu *vcpu); |
10769 | #endif |
10770 | |
10771 | @@ -728,6 +728,7 @@ void kvm_set_pfn_dirty(kvm_pfn_t pfn); |
10772 | void kvm_set_pfn_accessed(kvm_pfn_t pfn); |
10773 | void kvm_get_pfn(kvm_pfn_t pfn); |
10774 | |
10775 | +void kvm_release_pfn(kvm_pfn_t pfn, bool dirty, struct gfn_to_pfn_cache *cache); |
10776 | int kvm_read_guest_page(struct kvm *kvm, gfn_t gfn, void *data, int offset, |
10777 | int len); |
10778 | int kvm_read_guest_atomic(struct kvm *kvm, gpa_t gpa, void *data, |
10779 | @@ -750,7 +751,7 @@ int kvm_clear_guest_page(struct kvm *kvm, gfn_t gfn, int offset, int len); |
10780 | int kvm_clear_guest(struct kvm *kvm, gpa_t gpa, unsigned long len); |
10781 | struct kvm_memory_slot *gfn_to_memslot(struct kvm *kvm, gfn_t gfn); |
10782 | bool kvm_is_visible_gfn(struct kvm *kvm, gfn_t gfn); |
10783 | -unsigned long kvm_host_page_size(struct kvm *kvm, gfn_t gfn); |
10784 | +unsigned long kvm_host_page_size(struct kvm_vcpu *vcpu, gfn_t gfn); |
10785 | void mark_page_dirty(struct kvm *kvm, gfn_t gfn); |
10786 | |
10787 | struct kvm_memslots *kvm_vcpu_memslots(struct kvm_vcpu *vcpu); |
10788 | @@ -758,8 +759,12 @@ struct kvm_memory_slot *kvm_vcpu_gfn_to_memslot(struct kvm_vcpu *vcpu, gfn_t gfn |
10789 | kvm_pfn_t kvm_vcpu_gfn_to_pfn_atomic(struct kvm_vcpu *vcpu, gfn_t gfn); |
10790 | kvm_pfn_t kvm_vcpu_gfn_to_pfn(struct kvm_vcpu *vcpu, gfn_t gfn); |
10791 | int kvm_vcpu_map(struct kvm_vcpu *vcpu, gpa_t gpa, struct kvm_host_map *map); |
10792 | +int kvm_map_gfn(struct kvm_vcpu *vcpu, gfn_t gfn, struct kvm_host_map *map, |
10793 | + struct gfn_to_pfn_cache *cache, bool atomic); |
10794 | struct page *kvm_vcpu_gfn_to_page(struct kvm_vcpu *vcpu, gfn_t gfn); |
10795 | void kvm_vcpu_unmap(struct kvm_vcpu *vcpu, struct kvm_host_map *map, bool dirty); |
10796 | +int kvm_unmap_gfn(struct kvm_vcpu *vcpu, struct kvm_host_map *map, |
10797 | + struct gfn_to_pfn_cache *cache, bool dirty, bool atomic); |
10798 | unsigned long kvm_vcpu_gfn_to_hva(struct kvm_vcpu *vcpu, gfn_t gfn); |
10799 | unsigned long kvm_vcpu_gfn_to_hva_prot(struct kvm_vcpu *vcpu, gfn_t gfn, bool *writable); |
10800 | int kvm_vcpu_read_guest_page(struct kvm_vcpu *vcpu, gfn_t gfn, void *data, int offset, |
10801 | diff --git a/include/linux/kvm_types.h b/include/linux/kvm_types.h |
10802 | index bde5374ae021..2382cb58969d 100644 |
10803 | --- a/include/linux/kvm_types.h |
10804 | +++ b/include/linux/kvm_types.h |
10805 | @@ -18,7 +18,7 @@ struct kvm_memslots; |
10806 | |
10807 | enum kvm_mr_change; |
10808 | |
10809 | -#include <asm/types.h> |
10810 | +#include <linux/types.h> |
10811 | |
10812 | /* |
10813 | * Address types: |
10814 | @@ -49,4 +49,11 @@ struct gfn_to_hva_cache { |
10815 | struct kvm_memory_slot *memslot; |
10816 | }; |
10817 | |
10818 | +struct gfn_to_pfn_cache { |
10819 | + u64 generation; |
10820 | + gfn_t gfn; |
10821 | + kvm_pfn_t pfn; |
10822 | + bool dirty; |
10823 | +}; |
10824 | + |
10825 | #endif /* __KVM_TYPES_H__ */ |
10826 | diff --git a/include/linux/mfd/rohm-bd70528.h b/include/linux/mfd/rohm-bd70528.h |
10827 | index 1013e60c5b25..b0109ee6dae2 100644 |
10828 | --- a/include/linux/mfd/rohm-bd70528.h |
10829 | +++ b/include/linux/mfd/rohm-bd70528.h |
10830 | @@ -317,7 +317,7 @@ enum { |
10831 | #define BD70528_MASK_RTC_MINUTE 0x7f |
10832 | #define BD70528_MASK_RTC_HOUR_24H 0x80 |
10833 | #define BD70528_MASK_RTC_HOUR_PM 0x20 |
10834 | -#define BD70528_MASK_RTC_HOUR 0x1f |
10835 | +#define BD70528_MASK_RTC_HOUR 0x3f |
10836 | #define BD70528_MASK_RTC_DAY 0x3f |
10837 | #define BD70528_MASK_RTC_WEEK 0x07 |
10838 | #define BD70528_MASK_RTC_MONTH 0x1f |
10839 | diff --git a/include/linux/mlx5/mlx5_ifc.h b/include/linux/mlx5/mlx5_ifc.h |
10840 | index 0836fe232f97..0cdc8d12785a 100644 |
10841 | --- a/include/linux/mlx5/mlx5_ifc.h |
10842 | +++ b/include/linux/mlx5/mlx5_ifc.h |
10843 | @@ -1417,14 +1417,15 @@ struct mlx5_ifc_cmd_hca_cap_bits { |
10844 | |
10845 | u8 reserved_at_440[0x20]; |
10846 | |
10847 | - u8 tls[0x1]; |
10848 | - u8 reserved_at_461[0x2]; |
10849 | + u8 reserved_at_460[0x3]; |
10850 | u8 log_max_uctx[0x5]; |
10851 | u8 reserved_at_468[0x3]; |
10852 | u8 log_max_umem[0x5]; |
10853 | u8 max_num_eqs[0x10]; |
10854 | |
10855 | - u8 reserved_at_480[0x3]; |
10856 | + u8 reserved_at_480[0x1]; |
10857 | + u8 tls_tx[0x1]; |
10858 | + u8 reserved_at_482[0x1]; |
10859 | u8 log_max_l2_table[0x5]; |
10860 | u8 reserved_at_488[0x8]; |
10861 | u8 log_uar_page_sz[0x10]; |
10862 | diff --git a/include/linux/padata.h b/include/linux/padata.h |
10863 | index 23717eeaad23..cccab7a59787 100644 |
10864 | --- a/include/linux/padata.h |
10865 | +++ b/include/linux/padata.h |
10866 | @@ -9,6 +9,7 @@ |
10867 | #ifndef PADATA_H |
10868 | #define PADATA_H |
10869 | |
10870 | +#include <linux/compiler_types.h> |
10871 | #include <linux/workqueue.h> |
10872 | #include <linux/spinlock.h> |
10873 | #include <linux/list.h> |
10874 | @@ -98,7 +99,7 @@ struct padata_cpumask { |
10875 | * struct parallel_data - Internal control structure, covers everything |
10876 | * that depends on the cpumask in use. |
10877 | * |
10878 | - * @pinst: padata instance. |
10879 | + * @sh: padata_shell object. |
10880 | * @pqueue: percpu padata queues used for parallelization. |
10881 | * @squeue: percpu padata queues used for serialuzation. |
10882 | * @reorder_objects: Number of objects waiting in the reorder queues. |
10883 | @@ -111,7 +112,7 @@ struct padata_cpumask { |
10884 | * @lock: Reorder lock. |
10885 | */ |
10886 | struct parallel_data { |
10887 | - struct padata_instance *pinst; |
10888 | + struct padata_shell *ps; |
10889 | struct padata_parallel_queue __percpu *pqueue; |
10890 | struct padata_serial_queue __percpu *squeue; |
10891 | atomic_t reorder_objects; |
10892 | @@ -124,14 +125,33 @@ struct parallel_data { |
10893 | spinlock_t lock ____cacheline_aligned; |
10894 | }; |
10895 | |
10896 | +/** |
10897 | + * struct padata_shell - Wrapper around struct parallel_data, its |
10898 | + * purpose is to allow the underlying control structure to be replaced |
10899 | + * on the fly using RCU. |
10900 | + * |
10901 | + * @pinst: padat instance. |
10902 | + * @pd: Actual parallel_data structure which may be substituted on the fly. |
10903 | + * @opd: Pointer to old pd to be freed by padata_replace. |
10904 | + * @list: List entry in padata_instance list. |
10905 | + */ |
10906 | +struct padata_shell { |
10907 | + struct padata_instance *pinst; |
10908 | + struct parallel_data __rcu *pd; |
10909 | + struct parallel_data *opd; |
10910 | + struct list_head list; |
10911 | +}; |
10912 | + |
10913 | /** |
10914 | * struct padata_instance - The overall control structure. |
10915 | * |
10916 | * @cpu_notifier: cpu hotplug notifier. |
10917 | * @parallel_wq: The workqueue used for parallel work. |
10918 | * @serial_wq: The workqueue used for serial work. |
10919 | - * @pd: The internal control structure. |
10920 | + * @pslist: List of padata_shell objects attached to this instance. |
10921 | * @cpumask: User supplied cpumasks for parallel and serial works. |
10922 | + * @rcpumask: Actual cpumasks based on user cpumask and cpu_online_mask. |
10923 | + * @omask: Temporary storage used to compute the notification mask. |
10924 | * @cpumask_change_notifier: Notifiers chain for user-defined notify |
10925 | * callbacks that will be called when either @pcpu or @cbcpu |
10926 | * or both cpumasks change. |
10927 | @@ -143,8 +163,10 @@ struct padata_instance { |
10928 | struct hlist_node node; |
10929 | struct workqueue_struct *parallel_wq; |
10930 | struct workqueue_struct *serial_wq; |
10931 | - struct parallel_data *pd; |
10932 | + struct list_head pslist; |
10933 | struct padata_cpumask cpumask; |
10934 | + struct padata_cpumask rcpumask; |
10935 | + cpumask_var_t omask; |
10936 | struct blocking_notifier_head cpumask_change_notifier; |
10937 | struct kobject kobj; |
10938 | struct mutex lock; |
10939 | @@ -156,7 +178,9 @@ struct padata_instance { |
10940 | |
10941 | extern struct padata_instance *padata_alloc_possible(const char *name); |
10942 | extern void padata_free(struct padata_instance *pinst); |
10943 | -extern int padata_do_parallel(struct padata_instance *pinst, |
10944 | +extern struct padata_shell *padata_alloc_shell(struct padata_instance *pinst); |
10945 | +extern void padata_free_shell(struct padata_shell *ps); |
10946 | +extern int padata_do_parallel(struct padata_shell *ps, |
10947 | struct padata_priv *padata, int *cb_cpu); |
10948 | extern void padata_do_serial(struct padata_priv *padata); |
10949 | extern int padata_set_cpumask(struct padata_instance *pinst, int cpumask_type, |
10950 | diff --git a/include/linux/percpu-defs.h b/include/linux/percpu-defs.h |
10951 | index a6fabd865211..176bfbd52d97 100644 |
10952 | --- a/include/linux/percpu-defs.h |
10953 | +++ b/include/linux/percpu-defs.h |
10954 | @@ -175,8 +175,7 @@ |
10955 | * Declaration/definition used for per-CPU variables that should be accessed |
10956 | * as decrypted when memory encryption is enabled in the guest. |
10957 | */ |
10958 | -#if defined(CONFIG_VIRTUALIZATION) && defined(CONFIG_AMD_MEM_ENCRYPT) |
10959 | - |
10960 | +#ifdef CONFIG_AMD_MEM_ENCRYPT |
10961 | #define DECLARE_PER_CPU_DECRYPTED(type, name) \ |
10962 | DECLARE_PER_CPU_SECTION(type, name, "..decrypted") |
10963 | |
10964 | diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h |
10965 | index 337a46391527..6a92fd3105a3 100644 |
10966 | --- a/include/linux/regulator/consumer.h |
10967 | +++ b/include/linux/regulator/consumer.h |
10968 | @@ -287,6 +287,8 @@ void regulator_bulk_set_supply_names(struct regulator_bulk_data *consumers, |
10969 | const char *const *supply_names, |
10970 | unsigned int num_supplies); |
10971 | |
10972 | +bool regulator_is_equal(struct regulator *reg1, struct regulator *reg2); |
10973 | + |
10974 | #else |
10975 | |
10976 | /* |
10977 | @@ -593,6 +595,11 @@ regulator_bulk_set_supply_names(struct regulator_bulk_data *consumers, |
10978 | { |
10979 | } |
10980 | |
10981 | +static inline bool |
10982 | +regulator_is_equal(struct regulator *reg1, struct regulator *reg2) |
10983 | +{ |
10984 | + return false; |
10985 | +} |
10986 | #endif |
10987 | |
10988 | static inline int regulator_set_voltage_triplet(struct regulator *regulator, |
10989 | diff --git a/include/media/v4l2-rect.h b/include/media/v4l2-rect.h |
10990 | index c86474dc7b55..8800a640c224 100644 |
10991 | --- a/include/media/v4l2-rect.h |
10992 | +++ b/include/media/v4l2-rect.h |
10993 | @@ -63,10 +63,10 @@ static inline void v4l2_rect_map_inside(struct v4l2_rect *r, |
10994 | r->left = boundary->left; |
10995 | if (r->top < boundary->top) |
10996 | r->top = boundary->top; |
10997 | - if (r->left + r->width > boundary->width) |
10998 | - r->left = boundary->width - r->width; |
10999 | - if (r->top + r->height > boundary->height) |
11000 | - r->top = boundary->height - r->height; |
11001 | + if (r->left + r->width > boundary->left + boundary->width) |
11002 | + r->left = boundary->left + boundary->width - r->width; |
11003 | + if (r->top + r->height > boundary->top + boundary->height) |
11004 | + r->top = boundary->top + boundary->height - r->height; |
11005 | } |
11006 | |
11007 | /** |
11008 | diff --git a/include/net/ipx.h b/include/net/ipx.h |
11009 | index baf090390998..9d1342807b59 100644 |
11010 | --- a/include/net/ipx.h |
11011 | +++ b/include/net/ipx.h |
11012 | @@ -47,11 +47,6 @@ struct ipxhdr { |
11013 | /* From af_ipx.c */ |
11014 | extern int sysctl_ipx_pprop_broadcasting; |
11015 | |
11016 | -static __inline__ struct ipxhdr *ipx_hdr(struct sk_buff *skb) |
11017 | -{ |
11018 | - return (struct ipxhdr *)skb_transport_header(skb); |
11019 | -} |
11020 | - |
11021 | struct ipx_interface { |
11022 | /* IPX address */ |
11023 | __be32 if_netnum; |
11024 | diff --git a/include/sound/hdaudio.h b/include/sound/hdaudio.h |
11025 | index e05b95e83d5a..fb9dce4c6928 100644 |
11026 | --- a/include/sound/hdaudio.h |
11027 | +++ b/include/sound/hdaudio.h |
11028 | @@ -8,6 +8,7 @@ |
11029 | |
11030 | #include <linux/device.h> |
11031 | #include <linux/interrupt.h> |
11032 | +#include <linux/io.h> |
11033 | #include <linux/pm_runtime.h> |
11034 | #include <linux/timecounter.h> |
11035 | #include <sound/core.h> |
11036 | @@ -330,6 +331,7 @@ struct hdac_bus { |
11037 | bool chip_init:1; /* h/w initialized */ |
11038 | |
11039 | /* behavior flags */ |
11040 | + bool aligned_mmio:1; /* aligned MMIO access */ |
11041 | bool sync_write:1; /* sync after verb write */ |
11042 | bool use_posbuf:1; /* use position buffer */ |
11043 | bool snoop:1; /* enable snooping */ |
11044 | @@ -405,34 +407,61 @@ void snd_hdac_bus_free_stream_pages(struct hdac_bus *bus); |
11045 | unsigned int snd_hdac_aligned_read(void __iomem *addr, unsigned int mask); |
11046 | void snd_hdac_aligned_write(unsigned int val, void __iomem *addr, |
11047 | unsigned int mask); |
11048 | -#define snd_hdac_reg_writeb(v, addr) snd_hdac_aligned_write(v, addr, 0xff) |
11049 | -#define snd_hdac_reg_writew(v, addr) snd_hdac_aligned_write(v, addr, 0xffff) |
11050 | -#define snd_hdac_reg_readb(addr) snd_hdac_aligned_read(addr, 0xff) |
11051 | -#define snd_hdac_reg_readw(addr) snd_hdac_aligned_read(addr, 0xffff) |
11052 | -#else /* CONFIG_SND_HDA_ALIGNED_MMIO */ |
11053 | -#define snd_hdac_reg_writeb(val, addr) writeb(val, addr) |
11054 | -#define snd_hdac_reg_writew(val, addr) writew(val, addr) |
11055 | -#define snd_hdac_reg_readb(addr) readb(addr) |
11056 | -#define snd_hdac_reg_readw(addr) readw(addr) |
11057 | -#endif /* CONFIG_SND_HDA_ALIGNED_MMIO */ |
11058 | -#define snd_hdac_reg_writel(val, addr) writel(val, addr) |
11059 | -#define snd_hdac_reg_readl(addr) readl(addr) |
11060 | +#define snd_hdac_aligned_mmio(bus) (bus)->aligned_mmio |
11061 | +#else |
11062 | +#define snd_hdac_aligned_mmio(bus) false |
11063 | +#define snd_hdac_aligned_read(addr, mask) 0 |
11064 | +#define snd_hdac_aligned_write(val, addr, mask) do {} while (0) |
11065 | +#endif |
11066 | + |
11067 | +static inline void snd_hdac_reg_writeb(struct hdac_bus *bus, void __iomem *addr, |
11068 | + u8 val) |
11069 | +{ |
11070 | + if (snd_hdac_aligned_mmio(bus)) |
11071 | + snd_hdac_aligned_write(val, addr, 0xff); |
11072 | + else |
11073 | + writeb(val, addr); |
11074 | +} |
11075 | + |
11076 | +static inline void snd_hdac_reg_writew(struct hdac_bus *bus, void __iomem *addr, |
11077 | + u16 val) |
11078 | +{ |
11079 | + if (snd_hdac_aligned_mmio(bus)) |
11080 | + snd_hdac_aligned_write(val, addr, 0xffff); |
11081 | + else |
11082 | + writew(val, addr); |
11083 | +} |
11084 | + |
11085 | +static inline u8 snd_hdac_reg_readb(struct hdac_bus *bus, void __iomem *addr) |
11086 | +{ |
11087 | + return snd_hdac_aligned_mmio(bus) ? |
11088 | + snd_hdac_aligned_read(addr, 0xff) : readb(addr); |
11089 | +} |
11090 | + |
11091 | +static inline u16 snd_hdac_reg_readw(struct hdac_bus *bus, void __iomem *addr) |
11092 | +{ |
11093 | + return snd_hdac_aligned_mmio(bus) ? |
11094 | + snd_hdac_aligned_read(addr, 0xffff) : readw(addr); |
11095 | +} |
11096 | + |
11097 | +#define snd_hdac_reg_writel(bus, addr, val) writel(val, addr) |
11098 | +#define snd_hdac_reg_readl(bus, addr) readl(addr) |
11099 | |
11100 | /* |
11101 | * macros for easy use |
11102 | */ |
11103 | #define _snd_hdac_chip_writeb(chip, reg, value) \ |
11104 | - snd_hdac_reg_writeb(value, (chip)->remap_addr + (reg)) |
11105 | + snd_hdac_reg_writeb(chip, (chip)->remap_addr + (reg), value) |
11106 | #define _snd_hdac_chip_readb(chip, reg) \ |
11107 | - snd_hdac_reg_readb((chip)->remap_addr + (reg)) |
11108 | + snd_hdac_reg_readb(chip, (chip)->remap_addr + (reg)) |
11109 | #define _snd_hdac_chip_writew(chip, reg, value) \ |
11110 | - snd_hdac_reg_writew(value, (chip)->remap_addr + (reg)) |
11111 | + snd_hdac_reg_writew(chip, (chip)->remap_addr + (reg), value) |
11112 | #define _snd_hdac_chip_readw(chip, reg) \ |
11113 | - snd_hdac_reg_readw((chip)->remap_addr + (reg)) |
11114 | + snd_hdac_reg_readw(chip, (chip)->remap_addr + (reg)) |
11115 | #define _snd_hdac_chip_writel(chip, reg, value) \ |
11116 | - snd_hdac_reg_writel(value, (chip)->remap_addr + (reg)) |
11117 | + snd_hdac_reg_writel(chip, (chip)->remap_addr + (reg), value) |
11118 | #define _snd_hdac_chip_readl(chip, reg) \ |
11119 | - snd_hdac_reg_readl((chip)->remap_addr + (reg)) |
11120 | + snd_hdac_reg_readl(chip, (chip)->remap_addr + (reg)) |
11121 | |
11122 | /* read/write a register, pass without AZX_REG_ prefix */ |
11123 | #define snd_hdac_chip_writel(chip, reg, value) \ |
11124 | @@ -540,17 +569,17 @@ int snd_hdac_get_stream_stripe_ctl(struct hdac_bus *bus, |
11125 | */ |
11126 | /* read/write a register, pass without AZX_REG_ prefix */ |
11127 | #define snd_hdac_stream_writel(dev, reg, value) \ |
11128 | - snd_hdac_reg_writel(value, (dev)->sd_addr + AZX_REG_ ## reg) |
11129 | + snd_hdac_reg_writel((dev)->bus, (dev)->sd_addr + AZX_REG_ ## reg, value) |
11130 | #define snd_hdac_stream_writew(dev, reg, value) \ |
11131 | - snd_hdac_reg_writew(value, (dev)->sd_addr + AZX_REG_ ## reg) |
11132 | + snd_hdac_reg_writew((dev)->bus, (dev)->sd_addr + AZX_REG_ ## reg, value) |
11133 | #define snd_hdac_stream_writeb(dev, reg, value) \ |
11134 | - snd_hdac_reg_writeb(value, (dev)->sd_addr + AZX_REG_ ## reg) |
11135 | + snd_hdac_reg_writeb((dev)->bus, (dev)->sd_addr + AZX_REG_ ## reg, value) |
11136 | #define snd_hdac_stream_readl(dev, reg) \ |
11137 | - snd_hdac_reg_readl((dev)->sd_addr + AZX_REG_ ## reg) |
11138 | + snd_hdac_reg_readl((dev)->bus, (dev)->sd_addr + AZX_REG_ ## reg) |
11139 | #define snd_hdac_stream_readw(dev, reg) \ |
11140 | - snd_hdac_reg_readw((dev)->sd_addr + AZX_REG_ ## reg) |
11141 | + snd_hdac_reg_readw((dev)->bus, (dev)->sd_addr + AZX_REG_ ## reg) |
11142 | #define snd_hdac_stream_readb(dev, reg) \ |
11143 | - snd_hdac_reg_readb((dev)->sd_addr + AZX_REG_ ## reg) |
11144 | + snd_hdac_reg_readb((dev)->bus, (dev)->sd_addr + AZX_REG_ ## reg) |
11145 | |
11146 | /* update a register, pass without AZX_REG_ prefix */ |
11147 | #define snd_hdac_stream_updatel(dev, reg, mask, val) \ |
11148 | diff --git a/include/trace/events/writeback.h b/include/trace/events/writeback.h |
11149 | index c2ce6480b4b1..66282552db20 100644 |
11150 | --- a/include/trace/events/writeback.h |
11151 | +++ b/include/trace/events/writeback.h |
11152 | @@ -67,8 +67,8 @@ DECLARE_EVENT_CLASS(writeback_page_template, |
11153 | |
11154 | TP_fast_assign( |
11155 | strscpy_pad(__entry->name, |
11156 | - mapping ? dev_name(inode_to_bdi(mapping->host)->dev) : "(unknown)", |
11157 | - 32); |
11158 | + bdi_dev_name(mapping ? inode_to_bdi(mapping->host) : |
11159 | + NULL), 32); |
11160 | __entry->ino = mapping ? mapping->host->i_ino : 0; |
11161 | __entry->index = page->index; |
11162 | ), |
11163 | @@ -111,8 +111,7 @@ DECLARE_EVENT_CLASS(writeback_dirty_inode_template, |
11164 | struct backing_dev_info *bdi = inode_to_bdi(inode); |
11165 | |
11166 | /* may be called for files on pseudo FSes w/ unregistered bdi */ |
11167 | - strscpy_pad(__entry->name, |
11168 | - bdi->dev ? dev_name(bdi->dev) : "(unknown)", 32); |
11169 | + strscpy_pad(__entry->name, bdi_dev_name(bdi), 32); |
11170 | __entry->ino = inode->i_ino; |
11171 | __entry->state = inode->i_state; |
11172 | __entry->flags = flags; |
11173 | @@ -193,7 +192,7 @@ TRACE_EVENT(inode_foreign_history, |
11174 | ), |
11175 | |
11176 | TP_fast_assign( |
11177 | - strncpy(__entry->name, dev_name(inode_to_bdi(inode)->dev), 32); |
11178 | + strncpy(__entry->name, bdi_dev_name(inode_to_bdi(inode)), 32); |
11179 | __entry->ino = inode->i_ino; |
11180 | __entry->cgroup_ino = __trace_wbc_assign_cgroup(wbc); |
11181 | __entry->history = history; |
11182 | @@ -222,7 +221,7 @@ TRACE_EVENT(inode_switch_wbs, |
11183 | ), |
11184 | |
11185 | TP_fast_assign( |
11186 | - strncpy(__entry->name, dev_name(old_wb->bdi->dev), 32); |
11187 | + strncpy(__entry->name, bdi_dev_name(old_wb->bdi), 32); |
11188 | __entry->ino = inode->i_ino; |
11189 | __entry->old_cgroup_ino = __trace_wb_assign_cgroup(old_wb); |
11190 | __entry->new_cgroup_ino = __trace_wb_assign_cgroup(new_wb); |
11191 | @@ -255,7 +254,7 @@ TRACE_EVENT(track_foreign_dirty, |
11192 | struct address_space *mapping = page_mapping(page); |
11193 | struct inode *inode = mapping ? mapping->host : NULL; |
11194 | |
11195 | - strncpy(__entry->name, dev_name(wb->bdi->dev), 32); |
11196 | + strncpy(__entry->name, bdi_dev_name(wb->bdi), 32); |
11197 | __entry->bdi_id = wb->bdi->id; |
11198 | __entry->ino = inode ? inode->i_ino : 0; |
11199 | __entry->memcg_id = wb->memcg_css->id; |
11200 | @@ -288,7 +287,7 @@ TRACE_EVENT(flush_foreign, |
11201 | ), |
11202 | |
11203 | TP_fast_assign( |
11204 | - strncpy(__entry->name, dev_name(wb->bdi->dev), 32); |
11205 | + strncpy(__entry->name, bdi_dev_name(wb->bdi), 32); |
11206 | __entry->cgroup_ino = __trace_wb_assign_cgroup(wb); |
11207 | __entry->frn_bdi_id = frn_bdi_id; |
11208 | __entry->frn_memcg_id = frn_memcg_id; |
11209 | @@ -318,7 +317,7 @@ DECLARE_EVENT_CLASS(writeback_write_inode_template, |
11210 | |
11211 | TP_fast_assign( |
11212 | strscpy_pad(__entry->name, |
11213 | - dev_name(inode_to_bdi(inode)->dev), 32); |
11214 | + bdi_dev_name(inode_to_bdi(inode)), 32); |
11215 | __entry->ino = inode->i_ino; |
11216 | __entry->sync_mode = wbc->sync_mode; |
11217 | __entry->cgroup_ino = __trace_wbc_assign_cgroup(wbc); |
11218 | @@ -361,9 +360,7 @@ DECLARE_EVENT_CLASS(writeback_work_class, |
11219 | __field(unsigned int, cgroup_ino) |
11220 | ), |
11221 | TP_fast_assign( |
11222 | - strscpy_pad(__entry->name, |
11223 | - wb->bdi->dev ? dev_name(wb->bdi->dev) : |
11224 | - "(unknown)", 32); |
11225 | + strscpy_pad(__entry->name, bdi_dev_name(wb->bdi), 32); |
11226 | __entry->nr_pages = work->nr_pages; |
11227 | __entry->sb_dev = work->sb ? work->sb->s_dev : 0; |
11228 | __entry->sync_mode = work->sync_mode; |
11229 | @@ -416,7 +413,7 @@ DECLARE_EVENT_CLASS(writeback_class, |
11230 | __field(unsigned int, cgroup_ino) |
11231 | ), |
11232 | TP_fast_assign( |
11233 | - strscpy_pad(__entry->name, dev_name(wb->bdi->dev), 32); |
11234 | + strscpy_pad(__entry->name, bdi_dev_name(wb->bdi), 32); |
11235 | __entry->cgroup_ino = __trace_wb_assign_cgroup(wb); |
11236 | ), |
11237 | TP_printk("bdi %s: cgroup_ino=%u", |
11238 | @@ -438,7 +435,7 @@ TRACE_EVENT(writeback_bdi_register, |
11239 | __array(char, name, 32) |
11240 | ), |
11241 | TP_fast_assign( |
11242 | - strscpy_pad(__entry->name, dev_name(bdi->dev), 32); |
11243 | + strscpy_pad(__entry->name, bdi_dev_name(bdi), 32); |
11244 | ), |
11245 | TP_printk("bdi %s", |
11246 | __entry->name |
11247 | @@ -463,7 +460,7 @@ DECLARE_EVENT_CLASS(wbc_class, |
11248 | ), |
11249 | |
11250 | TP_fast_assign( |
11251 | - strscpy_pad(__entry->name, dev_name(bdi->dev), 32); |
11252 | + strscpy_pad(__entry->name, bdi_dev_name(bdi), 32); |
11253 | __entry->nr_to_write = wbc->nr_to_write; |
11254 | __entry->pages_skipped = wbc->pages_skipped; |
11255 | __entry->sync_mode = wbc->sync_mode; |
11256 | @@ -514,7 +511,7 @@ TRACE_EVENT(writeback_queue_io, |
11257 | ), |
11258 | TP_fast_assign( |
11259 | unsigned long *older_than_this = work->older_than_this; |
11260 | - strscpy_pad(__entry->name, dev_name(wb->bdi->dev), 32); |
11261 | + strscpy_pad(__entry->name, bdi_dev_name(wb->bdi), 32); |
11262 | __entry->older = older_than_this ? *older_than_this : 0; |
11263 | __entry->age = older_than_this ? |
11264 | (jiffies - *older_than_this) * 1000 / HZ : -1; |
11265 | @@ -600,7 +597,7 @@ TRACE_EVENT(bdi_dirty_ratelimit, |
11266 | ), |
11267 | |
11268 | TP_fast_assign( |
11269 | - strscpy_pad(__entry->bdi, dev_name(wb->bdi->dev), 32); |
11270 | + strscpy_pad(__entry->bdi, bdi_dev_name(wb->bdi), 32); |
11271 | __entry->write_bw = KBps(wb->write_bandwidth); |
11272 | __entry->avg_write_bw = KBps(wb->avg_write_bandwidth); |
11273 | __entry->dirty_rate = KBps(dirty_rate); |
11274 | @@ -665,7 +662,7 @@ TRACE_EVENT(balance_dirty_pages, |
11275 | |
11276 | TP_fast_assign( |
11277 | unsigned long freerun = (thresh + bg_thresh) / 2; |
11278 | - strscpy_pad(__entry->bdi, dev_name(wb->bdi->dev), 32); |
11279 | + strscpy_pad(__entry->bdi, bdi_dev_name(wb->bdi), 32); |
11280 | |
11281 | __entry->limit = global_wb_domain.dirty_limit; |
11282 | __entry->setpoint = (global_wb_domain.dirty_limit + |
11283 | @@ -726,7 +723,7 @@ TRACE_EVENT(writeback_sb_inodes_requeue, |
11284 | |
11285 | TP_fast_assign( |
11286 | strscpy_pad(__entry->name, |
11287 | - dev_name(inode_to_bdi(inode)->dev), 32); |
11288 | + bdi_dev_name(inode_to_bdi(inode)), 32); |
11289 | __entry->ino = inode->i_ino; |
11290 | __entry->state = inode->i_state; |
11291 | __entry->dirtied_when = inode->dirtied_when; |
11292 | @@ -800,7 +797,7 @@ DECLARE_EVENT_CLASS(writeback_single_inode_template, |
11293 | |
11294 | TP_fast_assign( |
11295 | strscpy_pad(__entry->name, |
11296 | - dev_name(inode_to_bdi(inode)->dev), 32); |
11297 | + bdi_dev_name(inode_to_bdi(inode)), 32); |
11298 | __entry->ino = inode->i_ino; |
11299 | __entry->state = inode->i_state; |
11300 | __entry->dirtied_when = inode->dirtied_when; |
11301 | diff --git a/ipc/msg.c b/ipc/msg.c |
11302 | index 8dec945fa030..767587ab45a3 100644 |
11303 | --- a/ipc/msg.c |
11304 | +++ b/ipc/msg.c |
11305 | @@ -377,7 +377,7 @@ copy_msqid_from_user(struct msqid64_ds *out, void __user *buf, int version) |
11306 | * NOTE: no locks must be held, the rwsem is taken inside this function. |
11307 | */ |
11308 | static int msgctl_down(struct ipc_namespace *ns, int msqid, int cmd, |
11309 | - struct msqid64_ds *msqid64) |
11310 | + struct ipc64_perm *perm, int msg_qbytes) |
11311 | { |
11312 | struct kern_ipc_perm *ipcp; |
11313 | struct msg_queue *msq; |
11314 | @@ -387,7 +387,7 @@ static int msgctl_down(struct ipc_namespace *ns, int msqid, int cmd, |
11315 | rcu_read_lock(); |
11316 | |
11317 | ipcp = ipcctl_obtain_check(ns, &msg_ids(ns), msqid, cmd, |
11318 | - &msqid64->msg_perm, msqid64->msg_qbytes); |
11319 | + perm, msg_qbytes); |
11320 | if (IS_ERR(ipcp)) { |
11321 | err = PTR_ERR(ipcp); |
11322 | goto out_unlock1; |
11323 | @@ -409,18 +409,18 @@ static int msgctl_down(struct ipc_namespace *ns, int msqid, int cmd, |
11324 | { |
11325 | DEFINE_WAKE_Q(wake_q); |
11326 | |
11327 | - if (msqid64->msg_qbytes > ns->msg_ctlmnb && |
11328 | + if (msg_qbytes > ns->msg_ctlmnb && |
11329 | !capable(CAP_SYS_RESOURCE)) { |
11330 | err = -EPERM; |
11331 | goto out_unlock1; |
11332 | } |
11333 | |
11334 | ipc_lock_object(&msq->q_perm); |
11335 | - err = ipc_update_perm(&msqid64->msg_perm, ipcp); |
11336 | + err = ipc_update_perm(perm, ipcp); |
11337 | if (err) |
11338 | goto out_unlock0; |
11339 | |
11340 | - msq->q_qbytes = msqid64->msg_qbytes; |
11341 | + msq->q_qbytes = msg_qbytes; |
11342 | |
11343 | msq->q_ctime = ktime_get_real_seconds(); |
11344 | /* |
11345 | @@ -601,9 +601,10 @@ static long ksys_msgctl(int msqid, int cmd, struct msqid_ds __user *buf, int ver |
11346 | case IPC_SET: |
11347 | if (copy_msqid_from_user(&msqid64, buf, version)) |
11348 | return -EFAULT; |
11349 | - /* fallthru */ |
11350 | + return msgctl_down(ns, msqid, cmd, &msqid64.msg_perm, |
11351 | + msqid64.msg_qbytes); |
11352 | case IPC_RMID: |
11353 | - return msgctl_down(ns, msqid, cmd, &msqid64); |
11354 | + return msgctl_down(ns, msqid, cmd, NULL, 0); |
11355 | default: |
11356 | return -EINVAL; |
11357 | } |
11358 | @@ -735,9 +736,9 @@ static long compat_ksys_msgctl(int msqid, int cmd, void __user *uptr, int versio |
11359 | case IPC_SET: |
11360 | if (copy_compat_msqid_from_user(&msqid64, uptr, version)) |
11361 | return -EFAULT; |
11362 | - /* fallthru */ |
11363 | + return msgctl_down(ns, msqid, cmd, &msqid64.msg_perm, msqid64.msg_qbytes); |
11364 | case IPC_RMID: |
11365 | - return msgctl_down(ns, msqid, cmd, &msqid64); |
11366 | + return msgctl_down(ns, msqid, cmd, NULL, 0); |
11367 | default: |
11368 | return -EINVAL; |
11369 | } |
11370 | diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c |
11371 | index 3d3d61b5985b..b4b6b77f309c 100644 |
11372 | --- a/kernel/bpf/devmap.c |
11373 | +++ b/kernel/bpf/devmap.c |
11374 | @@ -293,7 +293,8 @@ struct bpf_dtab_netdev *__dev_map_hash_lookup_elem(struct bpf_map *map, u32 key) |
11375 | struct hlist_head *head = dev_map_index_hash(dtab, key); |
11376 | struct bpf_dtab_netdev *dev; |
11377 | |
11378 | - hlist_for_each_entry_rcu(dev, head, index_hlist) |
11379 | + hlist_for_each_entry_rcu(dev, head, index_hlist, |
11380 | + lockdep_is_held(&dtab->index_lock)) |
11381 | if (dev->idx == key) |
11382 | return dev; |
11383 | |
11384 | diff --git a/kernel/events/core.c b/kernel/events/core.c |
11385 | index 6c829e22bad3..15b123bdcaf5 100644 |
11386 | --- a/kernel/events/core.c |
11387 | +++ b/kernel/events/core.c |
11388 | @@ -5823,7 +5823,15 @@ accounting: |
11389 | */ |
11390 | user_lock_limit *= num_online_cpus(); |
11391 | |
11392 | - user_locked = atomic_long_read(&user->locked_vm) + user_extra; |
11393 | + user_locked = atomic_long_read(&user->locked_vm); |
11394 | + |
11395 | + /* |
11396 | + * sysctl_perf_event_mlock may have changed, so that |
11397 | + * user->locked_vm > user_lock_limit |
11398 | + */ |
11399 | + if (user_locked > user_lock_limit) |
11400 | + user_locked = user_lock_limit; |
11401 | + user_locked += user_extra; |
11402 | |
11403 | if (user_locked <= user_lock_limit) { |
11404 | /* charge all to locked_vm */ |
11405 | diff --git a/kernel/irq/debugfs.c b/kernel/irq/debugfs.c |
11406 | index c1eccd4f6520..a949bd39e343 100644 |
11407 | --- a/kernel/irq/debugfs.c |
11408 | +++ b/kernel/irq/debugfs.c |
11409 | @@ -114,6 +114,7 @@ static const struct irq_bit_descr irqdata_states[] = { |
11410 | BIT_MASK_DESCR(IRQD_AFFINITY_MANAGED), |
11411 | BIT_MASK_DESCR(IRQD_MANAGED_SHUTDOWN), |
11412 | BIT_MASK_DESCR(IRQD_CAN_RESERVE), |
11413 | + BIT_MASK_DESCR(IRQD_MSI_NOMASK_QUIRK), |
11414 | |
11415 | BIT_MASK_DESCR(IRQD_FORWARDED_TO_VCPU), |
11416 | |
11417 | diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c |
11418 | index dd822fd8a7d5..480df3659720 100644 |
11419 | --- a/kernel/irq/irqdomain.c |
11420 | +++ b/kernel/irq/irqdomain.c |
11421 | @@ -1459,6 +1459,7 @@ int irq_domain_push_irq(struct irq_domain *domain, int virq, void *arg) |
11422 | if (rv) { |
11423 | /* Restore the original irq_data. */ |
11424 | *root_irq_data = *child_irq_data; |
11425 | + kfree(child_irq_data); |
11426 | goto error; |
11427 | } |
11428 | |
11429 | diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c |
11430 | index ad26fbcfbfc8..eb95f6106a1e 100644 |
11431 | --- a/kernel/irq/msi.c |
11432 | +++ b/kernel/irq/msi.c |
11433 | @@ -453,8 +453,11 @@ int msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev, |
11434 | continue; |
11435 | |
11436 | irq_data = irq_domain_get_irq_data(domain, desc->irq); |
11437 | - if (!can_reserve) |
11438 | + if (!can_reserve) { |
11439 | irqd_clr_can_reserve(irq_data); |
11440 | + if (domain->flags & IRQ_DOMAIN_MSI_NOMASK_QUIRK) |
11441 | + irqd_set_msi_nomask_quirk(irq_data); |
11442 | + } |
11443 | ret = irq_domain_activate_irq(irq_data, can_reserve); |
11444 | if (ret) |
11445 | goto cleanup; |
11446 | diff --git a/kernel/padata.c b/kernel/padata.c |
11447 | index c3fec1413295..9c82ee4a9732 100644 |
11448 | --- a/kernel/padata.c |
11449 | +++ b/kernel/padata.c |
11450 | @@ -35,6 +35,8 @@ |
11451 | |
11452 | #define MAX_OBJ_NUM 1000 |
11453 | |
11454 | +static void padata_free_pd(struct parallel_data *pd); |
11455 | + |
11456 | static int padata_index_to_cpu(struct parallel_data *pd, int cpu_index) |
11457 | { |
11458 | int cpu, target_cpu; |
11459 | @@ -87,7 +89,7 @@ static void padata_parallel_worker(struct work_struct *parallel_work) |
11460 | /** |
11461 | * padata_do_parallel - padata parallelization function |
11462 | * |
11463 | - * @pinst: padata instance |
11464 | + * @ps: padatashell |
11465 | * @padata: object to be parallelized |
11466 | * @cb_cpu: pointer to the CPU that the serialization callback function should |
11467 | * run on. If it's not in the serial cpumask of @pinst |
11468 | @@ -98,16 +100,17 @@ static void padata_parallel_worker(struct work_struct *parallel_work) |
11469 | * Note: Every object which is parallelized by padata_do_parallel |
11470 | * must be seen by padata_do_serial. |
11471 | */ |
11472 | -int padata_do_parallel(struct padata_instance *pinst, |
11473 | +int padata_do_parallel(struct padata_shell *ps, |
11474 | struct padata_priv *padata, int *cb_cpu) |
11475 | { |
11476 | + struct padata_instance *pinst = ps->pinst; |
11477 | int i, cpu, cpu_index, target_cpu, err; |
11478 | struct padata_parallel_queue *queue; |
11479 | struct parallel_data *pd; |
11480 | |
11481 | rcu_read_lock_bh(); |
11482 | |
11483 | - pd = rcu_dereference_bh(pinst->pd); |
11484 | + pd = rcu_dereference_bh(ps->pd); |
11485 | |
11486 | err = -EINVAL; |
11487 | if (!(pinst->flags & PADATA_INIT) || pinst->flags & PADATA_INVALID) |
11488 | @@ -210,10 +213,10 @@ static struct padata_priv *padata_find_next(struct parallel_data *pd, |
11489 | |
11490 | static void padata_reorder(struct parallel_data *pd) |
11491 | { |
11492 | + struct padata_instance *pinst = pd->ps->pinst; |
11493 | int cb_cpu; |
11494 | struct padata_priv *padata; |
11495 | struct padata_serial_queue *squeue; |
11496 | - struct padata_instance *pinst = pd->pinst; |
11497 | struct padata_parallel_queue *next_queue; |
11498 | |
11499 | /* |
11500 | @@ -283,6 +286,7 @@ static void padata_serial_worker(struct work_struct *serial_work) |
11501 | struct padata_serial_queue *squeue; |
11502 | struct parallel_data *pd; |
11503 | LIST_HEAD(local_list); |
11504 | + int cnt; |
11505 | |
11506 | local_bh_disable(); |
11507 | squeue = container_of(serial_work, struct padata_serial_queue, work); |
11508 | @@ -292,6 +296,8 @@ static void padata_serial_worker(struct work_struct *serial_work) |
11509 | list_replace_init(&squeue->serial.list, &local_list); |
11510 | spin_unlock(&squeue->serial.lock); |
11511 | |
11512 | + cnt = 0; |
11513 | + |
11514 | while (!list_empty(&local_list)) { |
11515 | struct padata_priv *padata; |
11516 | |
11517 | @@ -301,9 +307,12 @@ static void padata_serial_worker(struct work_struct *serial_work) |
11518 | list_del_init(&padata->list); |
11519 | |
11520 | padata->serial(padata); |
11521 | - atomic_dec(&pd->refcnt); |
11522 | + cnt++; |
11523 | } |
11524 | local_bh_enable(); |
11525 | + |
11526 | + if (atomic_sub_and_test(cnt, &pd->refcnt)) |
11527 | + padata_free_pd(pd); |
11528 | } |
11529 | |
11530 | /** |
11531 | @@ -341,36 +350,39 @@ void padata_do_serial(struct padata_priv *padata) |
11532 | } |
11533 | EXPORT_SYMBOL(padata_do_serial); |
11534 | |
11535 | -static int padata_setup_cpumasks(struct parallel_data *pd, |
11536 | - const struct cpumask *pcpumask, |
11537 | - const struct cpumask *cbcpumask) |
11538 | +static int padata_setup_cpumasks(struct padata_instance *pinst) |
11539 | { |
11540 | struct workqueue_attrs *attrs; |
11541 | + int err; |
11542 | + |
11543 | + attrs = alloc_workqueue_attrs(); |
11544 | + if (!attrs) |
11545 | + return -ENOMEM; |
11546 | + |
11547 | + /* Restrict parallel_wq workers to pd->cpumask.pcpu. */ |
11548 | + cpumask_copy(attrs->cpumask, pinst->cpumask.pcpu); |
11549 | + err = apply_workqueue_attrs(pinst->parallel_wq, attrs); |
11550 | + free_workqueue_attrs(attrs); |
11551 | + |
11552 | + return err; |
11553 | +} |
11554 | + |
11555 | +static int pd_setup_cpumasks(struct parallel_data *pd, |
11556 | + const struct cpumask *pcpumask, |
11557 | + const struct cpumask *cbcpumask) |
11558 | +{ |
11559 | int err = -ENOMEM; |
11560 | |
11561 | if (!alloc_cpumask_var(&pd->cpumask.pcpu, GFP_KERNEL)) |
11562 | goto out; |
11563 | - cpumask_and(pd->cpumask.pcpu, pcpumask, cpu_online_mask); |
11564 | - |
11565 | if (!alloc_cpumask_var(&pd->cpumask.cbcpu, GFP_KERNEL)) |
11566 | goto free_pcpu_mask; |
11567 | - cpumask_and(pd->cpumask.cbcpu, cbcpumask, cpu_online_mask); |
11568 | - |
11569 | - attrs = alloc_workqueue_attrs(); |
11570 | - if (!attrs) |
11571 | - goto free_cbcpu_mask; |
11572 | |
11573 | - /* Restrict parallel_wq workers to pd->cpumask.pcpu. */ |
11574 | - cpumask_copy(attrs->cpumask, pd->cpumask.pcpu); |
11575 | - err = apply_workqueue_attrs(pd->pinst->parallel_wq, attrs); |
11576 | - free_workqueue_attrs(attrs); |
11577 | - if (err < 0) |
11578 | - goto free_cbcpu_mask; |
11579 | + cpumask_copy(pd->cpumask.pcpu, pcpumask); |
11580 | + cpumask_copy(pd->cpumask.cbcpu, cbcpumask); |
11581 | |
11582 | return 0; |
11583 | |
11584 | -free_cbcpu_mask: |
11585 | - free_cpumask_var(pd->cpumask.cbcpu); |
11586 | free_pcpu_mask: |
11587 | free_cpumask_var(pd->cpumask.pcpu); |
11588 | out: |
11589 | @@ -414,12 +426,16 @@ static void padata_init_pqueues(struct parallel_data *pd) |
11590 | } |
11591 | |
11592 | /* Allocate and initialize the internal cpumask dependend resources. */ |
11593 | -static struct parallel_data *padata_alloc_pd(struct padata_instance *pinst, |
11594 | - const struct cpumask *pcpumask, |
11595 | - const struct cpumask *cbcpumask) |
11596 | +static struct parallel_data *padata_alloc_pd(struct padata_shell *ps) |
11597 | { |
11598 | + struct padata_instance *pinst = ps->pinst; |
11599 | + const struct cpumask *cbcpumask; |
11600 | + const struct cpumask *pcpumask; |
11601 | struct parallel_data *pd; |
11602 | |
11603 | + cbcpumask = pinst->rcpumask.cbcpu; |
11604 | + pcpumask = pinst->rcpumask.pcpu; |
11605 | + |
11606 | pd = kzalloc(sizeof(struct parallel_data), GFP_KERNEL); |
11607 | if (!pd) |
11608 | goto err; |
11609 | @@ -432,15 +448,15 @@ static struct parallel_data *padata_alloc_pd(struct padata_instance *pinst, |
11610 | if (!pd->squeue) |
11611 | goto err_free_pqueue; |
11612 | |
11613 | - pd->pinst = pinst; |
11614 | - if (padata_setup_cpumasks(pd, pcpumask, cbcpumask) < 0) |
11615 | + pd->ps = ps; |
11616 | + if (pd_setup_cpumasks(pd, pcpumask, cbcpumask)) |
11617 | goto err_free_squeue; |
11618 | |
11619 | padata_init_pqueues(pd); |
11620 | padata_init_squeues(pd); |
11621 | atomic_set(&pd->seq_nr, -1); |
11622 | atomic_set(&pd->reorder_objects, 0); |
11623 | - atomic_set(&pd->refcnt, 0); |
11624 | + atomic_set(&pd->refcnt, 1); |
11625 | spin_lock_init(&pd->lock); |
11626 | pd->cpu = cpumask_first(pd->cpumask.pcpu); |
11627 | INIT_WORK(&pd->reorder_work, invoke_padata_reorder); |
11628 | @@ -466,29 +482,6 @@ static void padata_free_pd(struct parallel_data *pd) |
11629 | kfree(pd); |
11630 | } |
11631 | |
11632 | -/* Flush all objects out of the padata queues. */ |
11633 | -static void padata_flush_queues(struct parallel_data *pd) |
11634 | -{ |
11635 | - int cpu; |
11636 | - struct padata_parallel_queue *pqueue; |
11637 | - struct padata_serial_queue *squeue; |
11638 | - |
11639 | - for_each_cpu(cpu, pd->cpumask.pcpu) { |
11640 | - pqueue = per_cpu_ptr(pd->pqueue, cpu); |
11641 | - flush_work(&pqueue->work); |
11642 | - } |
11643 | - |
11644 | - if (atomic_read(&pd->reorder_objects)) |
11645 | - padata_reorder(pd); |
11646 | - |
11647 | - for_each_cpu(cpu, pd->cpumask.cbcpu) { |
11648 | - squeue = per_cpu_ptr(pd->squeue, cpu); |
11649 | - flush_work(&squeue->work); |
11650 | - } |
11651 | - |
11652 | - BUG_ON(atomic_read(&pd->refcnt) != 0); |
11653 | -} |
11654 | - |
11655 | static void __padata_start(struct padata_instance *pinst) |
11656 | { |
11657 | pinst->flags |= PADATA_INIT; |
11658 | @@ -502,39 +495,67 @@ static void __padata_stop(struct padata_instance *pinst) |
11659 | pinst->flags &= ~PADATA_INIT; |
11660 | |
11661 | synchronize_rcu(); |
11662 | - |
11663 | - get_online_cpus(); |
11664 | - padata_flush_queues(pinst->pd); |
11665 | - put_online_cpus(); |
11666 | } |
11667 | |
11668 | /* Replace the internal control structure with a new one. */ |
11669 | -static void padata_replace(struct padata_instance *pinst, |
11670 | - struct parallel_data *pd_new) |
11671 | +static int padata_replace_one(struct padata_shell *ps) |
11672 | { |
11673 | - struct parallel_data *pd_old = pinst->pd; |
11674 | - int notification_mask = 0; |
11675 | + struct parallel_data *pd_new; |
11676 | |
11677 | - pinst->flags |= PADATA_RESET; |
11678 | + pd_new = padata_alloc_pd(ps); |
11679 | + if (!pd_new) |
11680 | + return -ENOMEM; |
11681 | |
11682 | - rcu_assign_pointer(pinst->pd, pd_new); |
11683 | + ps->opd = rcu_dereference_protected(ps->pd, 1); |
11684 | + rcu_assign_pointer(ps->pd, pd_new); |
11685 | |
11686 | - synchronize_rcu(); |
11687 | + return 0; |
11688 | +} |
11689 | + |
11690 | +static int padata_replace(struct padata_instance *pinst, int cpu) |
11691 | +{ |
11692 | + int notification_mask = 0; |
11693 | + struct padata_shell *ps; |
11694 | + int err; |
11695 | + |
11696 | + pinst->flags |= PADATA_RESET; |
11697 | |
11698 | - if (!cpumask_equal(pd_old->cpumask.pcpu, pd_new->cpumask.pcpu)) |
11699 | + cpumask_copy(pinst->omask, pinst->rcpumask.pcpu); |
11700 | + cpumask_and(pinst->rcpumask.pcpu, pinst->cpumask.pcpu, |
11701 | + cpu_online_mask); |
11702 | + if (cpu >= 0) |
11703 | + cpumask_clear_cpu(cpu, pinst->rcpumask.pcpu); |
11704 | + if (!cpumask_equal(pinst->omask, pinst->rcpumask.pcpu)) |
11705 | notification_mask |= PADATA_CPU_PARALLEL; |
11706 | - if (!cpumask_equal(pd_old->cpumask.cbcpu, pd_new->cpumask.cbcpu)) |
11707 | + |
11708 | + cpumask_copy(pinst->omask, pinst->rcpumask.cbcpu); |
11709 | + cpumask_and(pinst->rcpumask.cbcpu, pinst->cpumask.cbcpu, |
11710 | + cpu_online_mask); |
11711 | + if (cpu >= 0) |
11712 | + cpumask_clear_cpu(cpu, pinst->rcpumask.cbcpu); |
11713 | + if (!cpumask_equal(pinst->omask, pinst->rcpumask.cbcpu)) |
11714 | notification_mask |= PADATA_CPU_SERIAL; |
11715 | |
11716 | - padata_flush_queues(pd_old); |
11717 | - padata_free_pd(pd_old); |
11718 | + list_for_each_entry(ps, &pinst->pslist, list) { |
11719 | + err = padata_replace_one(ps); |
11720 | + if (err) |
11721 | + break; |
11722 | + } |
11723 | + |
11724 | + synchronize_rcu(); |
11725 | + |
11726 | + list_for_each_entry_continue_reverse(ps, &pinst->pslist, list) |
11727 | + if (atomic_dec_and_test(&ps->opd->refcnt)) |
11728 | + padata_free_pd(ps->opd); |
11729 | |
11730 | if (notification_mask) |
11731 | blocking_notifier_call_chain(&pinst->cpumask_change_notifier, |
11732 | notification_mask, |
11733 | - &pd_new->cpumask); |
11734 | + &pinst->cpumask); |
11735 | |
11736 | pinst->flags &= ~PADATA_RESET; |
11737 | + |
11738 | + return err; |
11739 | } |
11740 | |
11741 | /** |
11742 | @@ -587,7 +608,7 @@ static int __padata_set_cpumasks(struct padata_instance *pinst, |
11743 | cpumask_var_t cbcpumask) |
11744 | { |
11745 | int valid; |
11746 | - struct parallel_data *pd; |
11747 | + int err; |
11748 | |
11749 | valid = padata_validate_cpumask(pinst, pcpumask); |
11750 | if (!valid) { |
11751 | @@ -600,19 +621,15 @@ static int __padata_set_cpumasks(struct padata_instance *pinst, |
11752 | __padata_stop(pinst); |
11753 | |
11754 | out_replace: |
11755 | - pd = padata_alloc_pd(pinst, pcpumask, cbcpumask); |
11756 | - if (!pd) |
11757 | - return -ENOMEM; |
11758 | - |
11759 | cpumask_copy(pinst->cpumask.pcpu, pcpumask); |
11760 | cpumask_copy(pinst->cpumask.cbcpu, cbcpumask); |
11761 | |
11762 | - padata_replace(pinst, pd); |
11763 | + err = padata_setup_cpumasks(pinst) ?: padata_replace(pinst, -1); |
11764 | |
11765 | if (valid) |
11766 | __padata_start(pinst); |
11767 | |
11768 | - return 0; |
11769 | + return err; |
11770 | } |
11771 | |
11772 | /** |
11773 | @@ -695,46 +712,32 @@ EXPORT_SYMBOL(padata_stop); |
11774 | |
11775 | static int __padata_add_cpu(struct padata_instance *pinst, int cpu) |
11776 | { |
11777 | - struct parallel_data *pd; |
11778 | + int err = 0; |
11779 | |
11780 | if (cpumask_test_cpu(cpu, cpu_online_mask)) { |
11781 | - pd = padata_alloc_pd(pinst, pinst->cpumask.pcpu, |
11782 | - pinst->cpumask.cbcpu); |
11783 | - if (!pd) |
11784 | - return -ENOMEM; |
11785 | - |
11786 | - padata_replace(pinst, pd); |
11787 | + err = padata_replace(pinst, -1); |
11788 | |
11789 | if (padata_validate_cpumask(pinst, pinst->cpumask.pcpu) && |
11790 | padata_validate_cpumask(pinst, pinst->cpumask.cbcpu)) |
11791 | __padata_start(pinst); |
11792 | } |
11793 | |
11794 | - return 0; |
11795 | + return err; |
11796 | } |
11797 | |
11798 | static int __padata_remove_cpu(struct padata_instance *pinst, int cpu) |
11799 | { |
11800 | - struct parallel_data *pd = NULL; |
11801 | + int err = 0; |
11802 | |
11803 | if (cpumask_test_cpu(cpu, cpu_online_mask)) { |
11804 | - |
11805 | if (!padata_validate_cpumask(pinst, pinst->cpumask.pcpu) || |
11806 | !padata_validate_cpumask(pinst, pinst->cpumask.cbcpu)) |
11807 | __padata_stop(pinst); |
11808 | |
11809 | - pd = padata_alloc_pd(pinst, pinst->cpumask.pcpu, |
11810 | - pinst->cpumask.cbcpu); |
11811 | - if (!pd) |
11812 | - return -ENOMEM; |
11813 | - |
11814 | - padata_replace(pinst, pd); |
11815 | - |
11816 | - cpumask_clear_cpu(cpu, pd->cpumask.cbcpu); |
11817 | - cpumask_clear_cpu(cpu, pd->cpumask.pcpu); |
11818 | + err = padata_replace(pinst, cpu); |
11819 | } |
11820 | |
11821 | - return 0; |
11822 | + return err; |
11823 | } |
11824 | |
11825 | /** |
11826 | @@ -817,8 +820,12 @@ static void __padata_free(struct padata_instance *pinst) |
11827 | cpuhp_state_remove_instance_nocalls(hp_online, &pinst->node); |
11828 | #endif |
11829 | |
11830 | + WARN_ON(!list_empty(&pinst->pslist)); |
11831 | + |
11832 | padata_stop(pinst); |
11833 | - padata_free_pd(pinst->pd); |
11834 | + free_cpumask_var(pinst->omask); |
11835 | + free_cpumask_var(pinst->rcpumask.cbcpu); |
11836 | + free_cpumask_var(pinst->rcpumask.pcpu); |
11837 | free_cpumask_var(pinst->cpumask.pcpu); |
11838 | free_cpumask_var(pinst->cpumask.cbcpu); |
11839 | destroy_workqueue(pinst->serial_wq); |
11840 | @@ -965,7 +972,6 @@ static struct padata_instance *padata_alloc(const char *name, |
11841 | const struct cpumask *cbcpumask) |
11842 | { |
11843 | struct padata_instance *pinst; |
11844 | - struct parallel_data *pd = NULL; |
11845 | |
11846 | pinst = kzalloc(sizeof(struct padata_instance), GFP_KERNEL); |
11847 | if (!pinst) |
11848 | @@ -993,14 +999,22 @@ static struct padata_instance *padata_alloc(const char *name, |
11849 | !padata_validate_cpumask(pinst, cbcpumask)) |
11850 | goto err_free_masks; |
11851 | |
11852 | - pd = padata_alloc_pd(pinst, pcpumask, cbcpumask); |
11853 | - if (!pd) |
11854 | + if (!alloc_cpumask_var(&pinst->rcpumask.pcpu, GFP_KERNEL)) |
11855 | goto err_free_masks; |
11856 | + if (!alloc_cpumask_var(&pinst->rcpumask.cbcpu, GFP_KERNEL)) |
11857 | + goto err_free_rcpumask_pcpu; |
11858 | + if (!alloc_cpumask_var(&pinst->omask, GFP_KERNEL)) |
11859 | + goto err_free_rcpumask_cbcpu; |
11860 | |
11861 | - rcu_assign_pointer(pinst->pd, pd); |
11862 | + INIT_LIST_HEAD(&pinst->pslist); |
11863 | |
11864 | cpumask_copy(pinst->cpumask.pcpu, pcpumask); |
11865 | cpumask_copy(pinst->cpumask.cbcpu, cbcpumask); |
11866 | + cpumask_and(pinst->rcpumask.pcpu, pcpumask, cpu_online_mask); |
11867 | + cpumask_and(pinst->rcpumask.cbcpu, cbcpumask, cpu_online_mask); |
11868 | + |
11869 | + if (padata_setup_cpumasks(pinst)) |
11870 | + goto err_free_omask; |
11871 | |
11872 | pinst->flags = 0; |
11873 | |
11874 | @@ -1016,6 +1030,12 @@ static struct padata_instance *padata_alloc(const char *name, |
11875 | |
11876 | return pinst; |
11877 | |
11878 | +err_free_omask: |
11879 | + free_cpumask_var(pinst->omask); |
11880 | +err_free_rcpumask_cbcpu: |
11881 | + free_cpumask_var(pinst->rcpumask.cbcpu); |
11882 | +err_free_rcpumask_pcpu: |
11883 | + free_cpumask_var(pinst->rcpumask.pcpu); |
11884 | err_free_masks: |
11885 | free_cpumask_var(pinst->cpumask.pcpu); |
11886 | free_cpumask_var(pinst->cpumask.cbcpu); |
11887 | @@ -1054,6 +1074,61 @@ void padata_free(struct padata_instance *pinst) |
11888 | } |
11889 | EXPORT_SYMBOL(padata_free); |
11890 | |
11891 | +/** |
11892 | + * padata_alloc_shell - Allocate and initialize padata shell. |
11893 | + * |
11894 | + * @pinst: Parent padata_instance object. |
11895 | + */ |
11896 | +struct padata_shell *padata_alloc_shell(struct padata_instance *pinst) |
11897 | +{ |
11898 | + struct parallel_data *pd; |
11899 | + struct padata_shell *ps; |
11900 | + |
11901 | + ps = kzalloc(sizeof(*ps), GFP_KERNEL); |
11902 | + if (!ps) |
11903 | + goto out; |
11904 | + |
11905 | + ps->pinst = pinst; |
11906 | + |
11907 | + get_online_cpus(); |
11908 | + pd = padata_alloc_pd(ps); |
11909 | + put_online_cpus(); |
11910 | + |
11911 | + if (!pd) |
11912 | + goto out_free_ps; |
11913 | + |
11914 | + mutex_lock(&pinst->lock); |
11915 | + RCU_INIT_POINTER(ps->pd, pd); |
11916 | + list_add(&ps->list, &pinst->pslist); |
11917 | + mutex_unlock(&pinst->lock); |
11918 | + |
11919 | + return ps; |
11920 | + |
11921 | +out_free_ps: |
11922 | + kfree(ps); |
11923 | +out: |
11924 | + return NULL; |
11925 | +} |
11926 | +EXPORT_SYMBOL(padata_alloc_shell); |
11927 | + |
11928 | +/** |
11929 | + * padata_free_shell - free a padata shell |
11930 | + * |
11931 | + * @ps: padata shell to free |
11932 | + */ |
11933 | +void padata_free_shell(struct padata_shell *ps) |
11934 | +{ |
11935 | + struct padata_instance *pinst = ps->pinst; |
11936 | + |
11937 | + mutex_lock(&pinst->lock); |
11938 | + list_del(&ps->list); |
11939 | + padata_free_pd(rcu_dereference_protected(ps->pd, 1)); |
11940 | + mutex_unlock(&pinst->lock); |
11941 | + |
11942 | + kfree(ps); |
11943 | +} |
11944 | +EXPORT_SYMBOL(padata_free_shell); |
11945 | + |
11946 | #ifdef CONFIG_HOTPLUG_CPU |
11947 | |
11948 | static __init int padata_driver_init(void) |
11949 | diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c |
11950 | index 5dffade2d7cd..21acdff3bd27 100644 |
11951 | --- a/kernel/rcu/srcutree.c |
11952 | +++ b/kernel/rcu/srcutree.c |
11953 | @@ -530,7 +530,7 @@ static void srcu_gp_end(struct srcu_struct *ssp) |
11954 | idx = rcu_seq_state(ssp->srcu_gp_seq); |
11955 | WARN_ON_ONCE(idx != SRCU_STATE_SCAN2); |
11956 | cbdelay = srcu_get_delay(ssp); |
11957 | - ssp->srcu_last_gp_end = ktime_get_mono_fast_ns(); |
11958 | + WRITE_ONCE(ssp->srcu_last_gp_end, ktime_get_mono_fast_ns()); |
11959 | rcu_seq_end(&ssp->srcu_gp_seq); |
11960 | gpseq = rcu_seq_current(&ssp->srcu_gp_seq); |
11961 | if (ULONG_CMP_LT(ssp->srcu_gp_seq_needed_exp, gpseq)) |
11962 | @@ -762,6 +762,7 @@ static bool srcu_might_be_idle(struct srcu_struct *ssp) |
11963 | unsigned long flags; |
11964 | struct srcu_data *sdp; |
11965 | unsigned long t; |
11966 | + unsigned long tlast; |
11967 | |
11968 | /* If the local srcu_data structure has callbacks, not idle. */ |
11969 | local_irq_save(flags); |
11970 | @@ -780,9 +781,9 @@ static bool srcu_might_be_idle(struct srcu_struct *ssp) |
11971 | |
11972 | /* First, see if enough time has passed since the last GP. */ |
11973 | t = ktime_get_mono_fast_ns(); |
11974 | + tlast = READ_ONCE(ssp->srcu_last_gp_end); |
11975 | if (exp_holdoff == 0 || |
11976 | - time_in_range_open(t, ssp->srcu_last_gp_end, |
11977 | - ssp->srcu_last_gp_end + exp_holdoff)) |
11978 | + time_in_range_open(t, tlast, tlast + exp_holdoff)) |
11979 | return false; /* Too soon after last GP. */ |
11980 | |
11981 | /* Next, check for probable idleness. */ |
11982 | diff --git a/kernel/rcu/tree_exp.h b/kernel/rcu/tree_exp.h |
11983 | index d632cd019597..69c5aa64fcfd 100644 |
11984 | --- a/kernel/rcu/tree_exp.h |
11985 | +++ b/kernel/rcu/tree_exp.h |
11986 | @@ -134,7 +134,7 @@ static void __maybe_unused sync_exp_reset_tree(void) |
11987 | rcu_for_each_node_breadth_first(rnp) { |
11988 | raw_spin_lock_irqsave_rcu_node(rnp, flags); |
11989 | WARN_ON_ONCE(rnp->expmask); |
11990 | - rnp->expmask = rnp->expmaskinit; |
11991 | + WRITE_ONCE(rnp->expmask, rnp->expmaskinit); |
11992 | raw_spin_unlock_irqrestore_rcu_node(rnp, flags); |
11993 | } |
11994 | } |
11995 | @@ -211,7 +211,7 @@ static void __rcu_report_exp_rnp(struct rcu_node *rnp, |
11996 | rnp = rnp->parent; |
11997 | raw_spin_lock_rcu_node(rnp); /* irqs already disabled */ |
11998 | WARN_ON_ONCE(!(rnp->expmask & mask)); |
11999 | - rnp->expmask &= ~mask; |
12000 | + WRITE_ONCE(rnp->expmask, rnp->expmask & ~mask); |
12001 | } |
12002 | } |
12003 | |
12004 | @@ -241,7 +241,7 @@ static void rcu_report_exp_cpu_mult(struct rcu_node *rnp, |
12005 | raw_spin_unlock_irqrestore_rcu_node(rnp, flags); |
12006 | return; |
12007 | } |
12008 | - rnp->expmask &= ~mask; |
12009 | + WRITE_ONCE(rnp->expmask, rnp->expmask & ~mask); |
12010 | __rcu_report_exp_rnp(rnp, wake, flags); /* Releases rnp->lock. */ |
12011 | } |
12012 | |
12013 | @@ -372,12 +372,10 @@ static void sync_rcu_exp_select_node_cpus(struct work_struct *wp) |
12014 | raw_spin_unlock_irqrestore_rcu_node(rnp, flags); |
12015 | |
12016 | /* IPI the remaining CPUs for expedited quiescent state. */ |
12017 | - for_each_leaf_node_cpu_mask(rnp, cpu, rnp->expmask) { |
12018 | + for_each_leaf_node_cpu_mask(rnp, cpu, mask_ofl_ipi) { |
12019 | unsigned long mask = leaf_node_cpu_bit(rnp, cpu); |
12020 | struct rcu_data *rdp = per_cpu_ptr(&rcu_data, cpu); |
12021 | |
12022 | - if (!(mask_ofl_ipi & mask)) |
12023 | - continue; |
12024 | retry_ipi: |
12025 | if (rcu_dynticks_in_eqs_since(rdp, rdp->exp_dynticks_snap)) { |
12026 | mask_ofl_test |= mask; |
12027 | @@ -491,7 +489,7 @@ static void synchronize_sched_expedited_wait(void) |
12028 | struct rcu_data *rdp; |
12029 | |
12030 | mask = leaf_node_cpu_bit(rnp, cpu); |
12031 | - if (!(rnp->expmask & mask)) |
12032 | + if (!(READ_ONCE(rnp->expmask) & mask)) |
12033 | continue; |
12034 | ndetected++; |
12035 | rdp = per_cpu_ptr(&rcu_data, cpu); |
12036 | @@ -503,7 +501,8 @@ static void synchronize_sched_expedited_wait(void) |
12037 | } |
12038 | pr_cont(" } %lu jiffies s: %lu root: %#lx/%c\n", |
12039 | jiffies - jiffies_start, rcu_state.expedited_sequence, |
12040 | - rnp_root->expmask, ".T"[!!rnp_root->exp_tasks]); |
12041 | + READ_ONCE(rnp_root->expmask), |
12042 | + ".T"[!!rnp_root->exp_tasks]); |
12043 | if (ndetected) { |
12044 | pr_err("blocking rcu_node structures:"); |
12045 | rcu_for_each_node_breadth_first(rnp) { |
12046 | @@ -513,7 +512,7 @@ static void synchronize_sched_expedited_wait(void) |
12047 | continue; |
12048 | pr_cont(" l=%u:%d-%d:%#lx/%c", |
12049 | rnp->level, rnp->grplo, rnp->grphi, |
12050 | - rnp->expmask, |
12051 | + READ_ONCE(rnp->expmask), |
12052 | ".T"[!!rnp->exp_tasks]); |
12053 | } |
12054 | pr_cont("\n"); |
12055 | @@ -521,7 +520,7 @@ static void synchronize_sched_expedited_wait(void) |
12056 | rcu_for_each_leaf_node(rnp) { |
12057 | for_each_leaf_node_possible_cpu(rnp, cpu) { |
12058 | mask = leaf_node_cpu_bit(rnp, cpu); |
12059 | - if (!(rnp->expmask & mask)) |
12060 | + if (!(READ_ONCE(rnp->expmask) & mask)) |
12061 | continue; |
12062 | dump_cpu_task(cpu); |
12063 | } |
12064 | diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h |
12065 | index fa08d55f7040..f849e7429816 100644 |
12066 | --- a/kernel/rcu/tree_plugin.h |
12067 | +++ b/kernel/rcu/tree_plugin.h |
12068 | @@ -220,7 +220,7 @@ static void rcu_preempt_ctxt_queue(struct rcu_node *rnp, struct rcu_data *rdp) |
12069 | * blocked tasks. |
12070 | */ |
12071 | if (!rnp->gp_tasks && (blkd_state & RCU_GP_BLKD)) { |
12072 | - rnp->gp_tasks = &t->rcu_node_entry; |
12073 | + WRITE_ONCE(rnp->gp_tasks, &t->rcu_node_entry); |
12074 | WARN_ON_ONCE(rnp->completedqs == rnp->gp_seq); |
12075 | } |
12076 | if (!rnp->exp_tasks && (blkd_state & RCU_EXP_BLKD)) |
12077 | @@ -340,7 +340,7 @@ EXPORT_SYMBOL_GPL(rcu_note_context_switch); |
12078 | */ |
12079 | static int rcu_preempt_blocked_readers_cgp(struct rcu_node *rnp) |
12080 | { |
12081 | - return rnp->gp_tasks != NULL; |
12082 | + return READ_ONCE(rnp->gp_tasks) != NULL; |
12083 | } |
12084 | |
12085 | /* Bias and limit values for ->rcu_read_lock_nesting. */ |
12086 | @@ -493,7 +493,7 @@ rcu_preempt_deferred_qs_irqrestore(struct task_struct *t, unsigned long flags) |
12087 | trace_rcu_unlock_preempted_task(TPS("rcu_preempt"), |
12088 | rnp->gp_seq, t->pid); |
12089 | if (&t->rcu_node_entry == rnp->gp_tasks) |
12090 | - rnp->gp_tasks = np; |
12091 | + WRITE_ONCE(rnp->gp_tasks, np); |
12092 | if (&t->rcu_node_entry == rnp->exp_tasks) |
12093 | rnp->exp_tasks = np; |
12094 | if (IS_ENABLED(CONFIG_RCU_BOOST)) { |
12095 | @@ -612,7 +612,7 @@ static void rcu_read_unlock_special(struct task_struct *t) |
12096 | |
12097 | t->rcu_read_unlock_special.b.exp_hint = false; |
12098 | exp = (t->rcu_blocked_node && t->rcu_blocked_node->exp_tasks) || |
12099 | - (rdp->grpmask & rnp->expmask) || |
12100 | + (rdp->grpmask & READ_ONCE(rnp->expmask)) || |
12101 | tick_nohz_full_cpu(rdp->cpu); |
12102 | // Need to defer quiescent state until everything is enabled. |
12103 | if (irqs_were_disabled && use_softirq && |
12104 | @@ -663,7 +663,7 @@ static void rcu_preempt_check_blocked_tasks(struct rcu_node *rnp) |
12105 | dump_blkd_tasks(rnp, 10); |
12106 | if (rcu_preempt_has_tasks(rnp) && |
12107 | (rnp->qsmaskinit || rnp->wait_blkd_tasks)) { |
12108 | - rnp->gp_tasks = rnp->blkd_tasks.next; |
12109 | + WRITE_ONCE(rnp->gp_tasks, rnp->blkd_tasks.next); |
12110 | t = container_of(rnp->gp_tasks, struct task_struct, |
12111 | rcu_node_entry); |
12112 | trace_rcu_unlock_preempted_task(TPS("rcu_preempt-GPS"), |
12113 | @@ -757,7 +757,8 @@ dump_blkd_tasks(struct rcu_node *rnp, int ncheck) |
12114 | pr_info("%s: %d:%d ->qsmask %#lx ->qsmaskinit %#lx ->qsmaskinitnext %#lx\n", |
12115 | __func__, rnp1->grplo, rnp1->grphi, rnp1->qsmask, rnp1->qsmaskinit, rnp1->qsmaskinitnext); |
12116 | pr_info("%s: ->gp_tasks %p ->boost_tasks %p ->exp_tasks %p\n", |
12117 | - __func__, rnp->gp_tasks, rnp->boost_tasks, rnp->exp_tasks); |
12118 | + __func__, READ_ONCE(rnp->gp_tasks), rnp->boost_tasks, |
12119 | + rnp->exp_tasks); |
12120 | pr_info("%s: ->blkd_tasks", __func__); |
12121 | i = 0; |
12122 | list_for_each(lhp, &rnp->blkd_tasks) { |
12123 | diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c |
12124 | index 451f9d05ccfe..4b11f0309eee 100644 |
12125 | --- a/kernel/time/alarmtimer.c |
12126 | +++ b/kernel/time/alarmtimer.c |
12127 | @@ -88,6 +88,7 @@ static int alarmtimer_rtc_add_device(struct device *dev, |
12128 | unsigned long flags; |
12129 | struct rtc_device *rtc = to_rtc_device(dev); |
12130 | struct wakeup_source *__ws; |
12131 | + int ret = 0; |
12132 | |
12133 | if (rtcdev) |
12134 | return -EBUSY; |
12135 | @@ -102,8 +103,8 @@ static int alarmtimer_rtc_add_device(struct device *dev, |
12136 | spin_lock_irqsave(&rtcdev_lock, flags); |
12137 | if (!rtcdev) { |
12138 | if (!try_module_get(rtc->owner)) { |
12139 | - spin_unlock_irqrestore(&rtcdev_lock, flags); |
12140 | - return -1; |
12141 | + ret = -1; |
12142 | + goto unlock; |
12143 | } |
12144 | |
12145 | rtcdev = rtc; |
12146 | @@ -112,11 +113,12 @@ static int alarmtimer_rtc_add_device(struct device *dev, |
12147 | ws = __ws; |
12148 | __ws = NULL; |
12149 | } |
12150 | +unlock: |
12151 | spin_unlock_irqrestore(&rtcdev_lock, flags); |
12152 | |
12153 | wakeup_source_unregister(__ws); |
12154 | |
12155 | - return 0; |
12156 | + return ret; |
12157 | } |
12158 | |
12159 | static inline void alarmtimer_rtc_timer_init(void) |
12160 | diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c |
12161 | index fff5f64981c6..428beb69426a 100644 |
12162 | --- a/kernel/time/clocksource.c |
12163 | +++ b/kernel/time/clocksource.c |
12164 | @@ -293,8 +293,15 @@ static void clocksource_watchdog(struct timer_list *unused) |
12165 | next_cpu = cpumask_next(raw_smp_processor_id(), cpu_online_mask); |
12166 | if (next_cpu >= nr_cpu_ids) |
12167 | next_cpu = cpumask_first(cpu_online_mask); |
12168 | - watchdog_timer.expires += WATCHDOG_INTERVAL; |
12169 | - add_timer_on(&watchdog_timer, next_cpu); |
12170 | + |
12171 | + /* |
12172 | + * Arm timer if not already pending: could race with concurrent |
12173 | + * pair clocksource_stop_watchdog() clocksource_start_watchdog(). |
12174 | + */ |
12175 | + if (!timer_pending(&watchdog_timer)) { |
12176 | + watchdog_timer.expires += WATCHDOG_INTERVAL; |
12177 | + add_timer_on(&watchdog_timer, next_cpu); |
12178 | + } |
12179 | out: |
12180 | spin_unlock(&watchdog_lock); |
12181 | } |
12182 | diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c |
12183 | index 0708a41cfe2d..407d8bf4ed93 100644 |
12184 | --- a/kernel/trace/ftrace.c |
12185 | +++ b/kernel/trace/ftrace.c |
12186 | @@ -5102,8 +5102,8 @@ static const struct file_operations ftrace_notrace_fops = { |
12187 | |
12188 | static DEFINE_MUTEX(graph_lock); |
12189 | |
12190 | -struct ftrace_hash *ftrace_graph_hash = EMPTY_HASH; |
12191 | -struct ftrace_hash *ftrace_graph_notrace_hash = EMPTY_HASH; |
12192 | +struct ftrace_hash __rcu *ftrace_graph_hash = EMPTY_HASH; |
12193 | +struct ftrace_hash __rcu *ftrace_graph_notrace_hash = EMPTY_HASH; |
12194 | |
12195 | enum graph_filter_type { |
12196 | GRAPH_FILTER_NOTRACE = 0, |
12197 | @@ -5378,8 +5378,15 @@ ftrace_graph_release(struct inode *inode, struct file *file) |
12198 | |
12199 | mutex_unlock(&graph_lock); |
12200 | |
12201 | - /* Wait till all users are no longer using the old hash */ |
12202 | - synchronize_rcu(); |
12203 | + /* |
12204 | + * We need to do a hard force of sched synchronization. |
12205 | + * This is because we use preempt_disable() to do RCU, but |
12206 | + * the function tracers can be called where RCU is not watching |
12207 | + * (like before user_exit()). We can not rely on the RCU |
12208 | + * infrastructure to do the synchronization, thus we must do it |
12209 | + * ourselves. |
12210 | + */ |
12211 | + schedule_on_each_cpu(ftrace_sync); |
12212 | |
12213 | free_ftrace_hash(old_hash); |
12214 | } |
12215 | diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h |
12216 | index d685c61085c0..a3c29d5fcc61 100644 |
12217 | --- a/kernel/trace/trace.h |
12218 | +++ b/kernel/trace/trace.h |
12219 | @@ -932,22 +932,31 @@ extern void __trace_graph_return(struct trace_array *tr, |
12220 | unsigned long flags, int pc); |
12221 | |
12222 | #ifdef CONFIG_DYNAMIC_FTRACE |
12223 | -extern struct ftrace_hash *ftrace_graph_hash; |
12224 | -extern struct ftrace_hash *ftrace_graph_notrace_hash; |
12225 | +extern struct ftrace_hash __rcu *ftrace_graph_hash; |
12226 | +extern struct ftrace_hash __rcu *ftrace_graph_notrace_hash; |
12227 | |
12228 | static inline int ftrace_graph_addr(struct ftrace_graph_ent *trace) |
12229 | { |
12230 | unsigned long addr = trace->func; |
12231 | int ret = 0; |
12232 | + struct ftrace_hash *hash; |
12233 | |
12234 | preempt_disable_notrace(); |
12235 | |
12236 | - if (ftrace_hash_empty(ftrace_graph_hash)) { |
12237 | + /* |
12238 | + * Have to open code "rcu_dereference_sched()" because the |
12239 | + * function graph tracer can be called when RCU is not |
12240 | + * "watching". |
12241 | + * Protected with schedule_on_each_cpu(ftrace_sync) |
12242 | + */ |
12243 | + hash = rcu_dereference_protected(ftrace_graph_hash, !preemptible()); |
12244 | + |
12245 | + if (ftrace_hash_empty(hash)) { |
12246 | ret = 1; |
12247 | goto out; |
12248 | } |
12249 | |
12250 | - if (ftrace_lookup_ip(ftrace_graph_hash, addr)) { |
12251 | + if (ftrace_lookup_ip(hash, addr)) { |
12252 | |
12253 | /* |
12254 | * This needs to be cleared on the return functions |
12255 | @@ -983,10 +992,20 @@ static inline void ftrace_graph_addr_finish(struct ftrace_graph_ret *trace) |
12256 | static inline int ftrace_graph_notrace_addr(unsigned long addr) |
12257 | { |
12258 | int ret = 0; |
12259 | + struct ftrace_hash *notrace_hash; |
12260 | |
12261 | preempt_disable_notrace(); |
12262 | |
12263 | - if (ftrace_lookup_ip(ftrace_graph_notrace_hash, addr)) |
12264 | + /* |
12265 | + * Have to open code "rcu_dereference_sched()" because the |
12266 | + * function graph tracer can be called when RCU is not |
12267 | + * "watching". |
12268 | + * Protected with schedule_on_each_cpu(ftrace_sync) |
12269 | + */ |
12270 | + notrace_hash = rcu_dereference_protected(ftrace_graph_notrace_hash, |
12271 | + !preemptible()); |
12272 | + |
12273 | + if (ftrace_lookup_ip(notrace_hash, addr)) |
12274 | ret = 1; |
12275 | |
12276 | preempt_enable_notrace(); |
12277 | diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c |
12278 | index 205692181e7b..4be7fc84d6b6 100644 |
12279 | --- a/kernel/trace/trace_events_hist.c |
12280 | +++ b/kernel/trace/trace_events_hist.c |
12281 | @@ -470,11 +470,12 @@ struct action_data { |
12282 | * When a histogram trigger is hit, the values of any |
12283 | * references to variables, including variables being passed |
12284 | * as parameters to synthetic events, are collected into a |
12285 | - * var_ref_vals array. This var_ref_idx is the index of the |
12286 | - * first param in the array to be passed to the synthetic |
12287 | - * event invocation. |
12288 | + * var_ref_vals array. This var_ref_idx array is an array of |
12289 | + * indices into the var_ref_vals array, one for each synthetic |
12290 | + * event param, and is passed to the synthetic event |
12291 | + * invocation. |
12292 | */ |
12293 | - unsigned int var_ref_idx; |
12294 | + unsigned int var_ref_idx[TRACING_MAP_VARS_MAX]; |
12295 | struct synth_event *synth_event; |
12296 | bool use_trace_keyword; |
12297 | char *synth_event_name; |
12298 | @@ -875,14 +876,14 @@ static struct trace_event_functions synth_event_funcs = { |
12299 | |
12300 | static notrace void trace_event_raw_event_synth(void *__data, |
12301 | u64 *var_ref_vals, |
12302 | - unsigned int var_ref_idx) |
12303 | + unsigned int *var_ref_idx) |
12304 | { |
12305 | struct trace_event_file *trace_file = __data; |
12306 | struct synth_trace_event *entry; |
12307 | struct trace_event_buffer fbuffer; |
12308 | struct ring_buffer *buffer; |
12309 | struct synth_event *event; |
12310 | - unsigned int i, n_u64; |
12311 | + unsigned int i, n_u64, val_idx; |
12312 | int fields_size = 0; |
12313 | |
12314 | event = trace_file->event_call->data; |
12315 | @@ -905,15 +906,16 @@ static notrace void trace_event_raw_event_synth(void *__data, |
12316 | goto out; |
12317 | |
12318 | for (i = 0, n_u64 = 0; i < event->n_fields; i++) { |
12319 | + val_idx = var_ref_idx[i]; |
12320 | if (event->fields[i]->is_string) { |
12321 | - char *str_val = (char *)(long)var_ref_vals[var_ref_idx + i]; |
12322 | + char *str_val = (char *)(long)var_ref_vals[val_idx]; |
12323 | char *str_field = (char *)&entry->fields[n_u64]; |
12324 | |
12325 | strscpy(str_field, str_val, STR_VAR_LEN_MAX); |
12326 | n_u64 += STR_VAR_LEN_MAX / sizeof(u64); |
12327 | } else { |
12328 | struct synth_field *field = event->fields[i]; |
12329 | - u64 val = var_ref_vals[var_ref_idx + i]; |
12330 | + u64 val = var_ref_vals[val_idx]; |
12331 | |
12332 | switch (field->size) { |
12333 | case 1: |
12334 | @@ -1113,10 +1115,10 @@ static struct tracepoint *alloc_synth_tracepoint(char *name) |
12335 | } |
12336 | |
12337 | typedef void (*synth_probe_func_t) (void *__data, u64 *var_ref_vals, |
12338 | - unsigned int var_ref_idx); |
12339 | + unsigned int *var_ref_idx); |
12340 | |
12341 | static inline void trace_synth(struct synth_event *event, u64 *var_ref_vals, |
12342 | - unsigned int var_ref_idx) |
12343 | + unsigned int *var_ref_idx) |
12344 | { |
12345 | struct tracepoint *tp = event->tp; |
12346 | |
12347 | @@ -2655,6 +2657,22 @@ static int init_var_ref(struct hist_field *ref_field, |
12348 | goto out; |
12349 | } |
12350 | |
12351 | +static int find_var_ref_idx(struct hist_trigger_data *hist_data, |
12352 | + struct hist_field *var_field) |
12353 | +{ |
12354 | + struct hist_field *ref_field; |
12355 | + int i; |
12356 | + |
12357 | + for (i = 0; i < hist_data->n_var_refs; i++) { |
12358 | + ref_field = hist_data->var_refs[i]; |
12359 | + if (ref_field->var.idx == var_field->var.idx && |
12360 | + ref_field->var.hist_data == var_field->hist_data) |
12361 | + return i; |
12362 | + } |
12363 | + |
12364 | + return -ENOENT; |
12365 | +} |
12366 | + |
12367 | /** |
12368 | * create_var_ref - Create a variable reference and attach it to trigger |
12369 | * @hist_data: The trigger that will be referencing the variable |
12370 | @@ -4228,11 +4246,11 @@ static int trace_action_create(struct hist_trigger_data *hist_data, |
12371 | struct trace_array *tr = hist_data->event_file->tr; |
12372 | char *event_name, *param, *system = NULL; |
12373 | struct hist_field *hist_field, *var_ref; |
12374 | - unsigned int i, var_ref_idx; |
12375 | + unsigned int i; |
12376 | unsigned int field_pos = 0; |
12377 | struct synth_event *event; |
12378 | char *synth_event_name; |
12379 | - int ret = 0; |
12380 | + int var_ref_idx, ret = 0; |
12381 | |
12382 | lockdep_assert_held(&event_mutex); |
12383 | |
12384 | @@ -4249,8 +4267,6 @@ static int trace_action_create(struct hist_trigger_data *hist_data, |
12385 | |
12386 | event->ref++; |
12387 | |
12388 | - var_ref_idx = hist_data->n_var_refs; |
12389 | - |
12390 | for (i = 0; i < data->n_params; i++) { |
12391 | char *p; |
12392 | |
12393 | @@ -4299,6 +4315,14 @@ static int trace_action_create(struct hist_trigger_data *hist_data, |
12394 | goto err; |
12395 | } |
12396 | |
12397 | + var_ref_idx = find_var_ref_idx(hist_data, var_ref); |
12398 | + if (WARN_ON(var_ref_idx < 0)) { |
12399 | + ret = var_ref_idx; |
12400 | + goto err; |
12401 | + } |
12402 | + |
12403 | + data->var_ref_idx[i] = var_ref_idx; |
12404 | + |
12405 | field_pos++; |
12406 | kfree(p); |
12407 | continue; |
12408 | @@ -4317,7 +4341,6 @@ static int trace_action_create(struct hist_trigger_data *hist_data, |
12409 | } |
12410 | |
12411 | data->synth_event = event; |
12412 | - data->var_ref_idx = var_ref_idx; |
12413 | out: |
12414 | return ret; |
12415 | err: |
12416 | diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c |
12417 | index 9ae87be422f2..ab8b6436d53f 100644 |
12418 | --- a/kernel/trace/trace_probe.c |
12419 | +++ b/kernel/trace/trace_probe.c |
12420 | @@ -876,7 +876,8 @@ static int __set_print_fmt(struct trace_probe *tp, char *buf, int len, |
12421 | for (i = 0; i < tp->nr_args; i++) { |
12422 | parg = tp->args + i; |
12423 | if (parg->count) { |
12424 | - if (strcmp(parg->type->name, "string") == 0) |
12425 | + if ((strcmp(parg->type->name, "string") == 0) || |
12426 | + (strcmp(parg->type->name, "ustring") == 0)) |
12427 | fmt = ", __get_str(%s[%d])"; |
12428 | else |
12429 | fmt = ", REC->%s[%d]"; |
12430 | @@ -884,7 +885,8 @@ static int __set_print_fmt(struct trace_probe *tp, char *buf, int len, |
12431 | pos += snprintf(buf + pos, LEN_OR_ZERO, |
12432 | fmt, parg->name, j); |
12433 | } else { |
12434 | - if (strcmp(parg->type->name, "string") == 0) |
12435 | + if ((strcmp(parg->type->name, "string") == 0) || |
12436 | + (strcmp(parg->type->name, "ustring") == 0)) |
12437 | fmt = ", __get_str(%s)"; |
12438 | else |
12439 | fmt = ", REC->%s"; |
12440 | diff --git a/kernel/trace/trace_sched_switch.c b/kernel/trace/trace_sched_switch.c |
12441 | index e288168661e1..e304196d7c28 100644 |
12442 | --- a/kernel/trace/trace_sched_switch.c |
12443 | +++ b/kernel/trace/trace_sched_switch.c |
12444 | @@ -89,8 +89,10 @@ static void tracing_sched_unregister(void) |
12445 | |
12446 | static void tracing_start_sched_switch(int ops) |
12447 | { |
12448 | - bool sched_register = (!sched_cmdline_ref && !sched_tgid_ref); |
12449 | + bool sched_register; |
12450 | + |
12451 | mutex_lock(&sched_register_mutex); |
12452 | + sched_register = (!sched_cmdline_ref && !sched_tgid_ref); |
12453 | |
12454 | switch (ops) { |
12455 | case RECORD_CMDLINE: |
12456 | diff --git a/lib/test_kasan.c b/lib/test_kasan.c |
12457 | index 49cc4d570a40..bd3d9ef7d39e 100644 |
12458 | --- a/lib/test_kasan.c |
12459 | +++ b/lib/test_kasan.c |
12460 | @@ -157,6 +157,7 @@ static noinline void __init kmalloc_oob_krealloc_more(void) |
12461 | if (!ptr1 || !ptr2) { |
12462 | pr_err("Allocation failed\n"); |
12463 | kfree(ptr1); |
12464 | + kfree(ptr2); |
12465 | return; |
12466 | } |
12467 | |
12468 | diff --git a/mm/backing-dev.c b/mm/backing-dev.c |
12469 | index c360f6a6c844..62f05f605fb5 100644 |
12470 | --- a/mm/backing-dev.c |
12471 | +++ b/mm/backing-dev.c |
12472 | @@ -21,6 +21,7 @@ struct backing_dev_info noop_backing_dev_info = { |
12473 | EXPORT_SYMBOL_GPL(noop_backing_dev_info); |
12474 | |
12475 | static struct class *bdi_class; |
12476 | +const char *bdi_unknown_name = "(unknown)"; |
12477 | |
12478 | /* |
12479 | * bdi_lock protects bdi_tree and updates to bdi_list. bdi_list has RCU |
12480 | diff --git a/mm/memcontrol.c b/mm/memcontrol.c |
12481 | index ef4e9eb572a4..b5b4e310fe70 100644 |
12482 | --- a/mm/memcontrol.c |
12483 | +++ b/mm/memcontrol.c |
12484 | @@ -5465,14 +5465,6 @@ static int mem_cgroup_move_account(struct page *page, |
12485 | __mod_lruvec_state(to_vec, NR_WRITEBACK, nr_pages); |
12486 | } |
12487 | |
12488 | -#ifdef CONFIG_TRANSPARENT_HUGEPAGE |
12489 | - if (compound && !list_empty(page_deferred_list(page))) { |
12490 | - spin_lock(&from->deferred_split_queue.split_queue_lock); |
12491 | - list_del_init(page_deferred_list(page)); |
12492 | - from->deferred_split_queue.split_queue_len--; |
12493 | - spin_unlock(&from->deferred_split_queue.split_queue_lock); |
12494 | - } |
12495 | -#endif |
12496 | /* |
12497 | * It is safe to change page->mem_cgroup here because the page |
12498 | * is referenced, charged, and isolated - we can't race with |
12499 | @@ -5482,16 +5474,6 @@ static int mem_cgroup_move_account(struct page *page, |
12500 | /* caller should have done css_get */ |
12501 | page->mem_cgroup = to; |
12502 | |
12503 | -#ifdef CONFIG_TRANSPARENT_HUGEPAGE |
12504 | - if (compound && list_empty(page_deferred_list(page))) { |
12505 | - spin_lock(&to->deferred_split_queue.split_queue_lock); |
12506 | - list_add_tail(page_deferred_list(page), |
12507 | - &to->deferred_split_queue.split_queue); |
12508 | - to->deferred_split_queue.split_queue_len++; |
12509 | - spin_unlock(&to->deferred_split_queue.split_queue_lock); |
12510 | - } |
12511 | -#endif |
12512 | - |
12513 | spin_unlock_irqrestore(&from->move_lock, flags); |
12514 | |
12515 | ret = 0; |
12516 | diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c |
12517 | index fab540685279..0aa154be3a52 100644 |
12518 | --- a/mm/memory_hotplug.c |
12519 | +++ b/mm/memory_hotplug.c |
12520 | @@ -1738,8 +1738,6 @@ static int __ref try_remove_memory(int nid, u64 start, u64 size) |
12521 | |
12522 | BUG_ON(check_hotplug_memory_range(start, size)); |
12523 | |
12524 | - mem_hotplug_begin(); |
12525 | - |
12526 | /* |
12527 | * All memory blocks must be offlined before removing memory. Check |
12528 | * whether all memory blocks in question are offline and return error |
12529 | @@ -1754,9 +1752,14 @@ static int __ref try_remove_memory(int nid, u64 start, u64 size) |
12530 | memblock_free(start, size); |
12531 | memblock_remove(start, size); |
12532 | |
12533 | - /* remove memory block devices before removing memory */ |
12534 | + /* |
12535 | + * Memory block device removal under the device_hotplug_lock is |
12536 | + * a barrier against racing online attempts. |
12537 | + */ |
12538 | remove_memory_block_devices(start, size); |
12539 | |
12540 | + mem_hotplug_begin(); |
12541 | + |
12542 | arch_remove_memory(nid, start, size, NULL); |
12543 | __release_memory_resource(start, size); |
12544 | |
12545 | diff --git a/mm/migrate.c b/mm/migrate.c |
12546 | index 6956627ebf8b..c4c313e47f12 100644 |
12547 | --- a/mm/migrate.c |
12548 | +++ b/mm/migrate.c |
12549 | @@ -1631,8 +1631,19 @@ static int do_pages_move(struct mm_struct *mm, nodemask_t task_nodes, |
12550 | start = i; |
12551 | } else if (node != current_node) { |
12552 | err = do_move_pages_to_node(mm, &pagelist, current_node); |
12553 | - if (err) |
12554 | + if (err) { |
12555 | + /* |
12556 | + * Positive err means the number of failed |
12557 | + * pages to migrate. Since we are going to |
12558 | + * abort and return the number of non-migrated |
12559 | + * pages, so need to incude the rest of the |
12560 | + * nr_pages that have not been attempted as |
12561 | + * well. |
12562 | + */ |
12563 | + if (err > 0) |
12564 | + err += nr_pages - i - 1; |
12565 | goto out; |
12566 | + } |
12567 | err = store_status(status, start, current_node, i - start); |
12568 | if (err) |
12569 | goto out; |
12570 | @@ -1663,8 +1674,11 @@ static int do_pages_move(struct mm_struct *mm, nodemask_t task_nodes, |
12571 | goto out_flush; |
12572 | |
12573 | err = do_move_pages_to_node(mm, &pagelist, current_node); |
12574 | - if (err) |
12575 | + if (err) { |
12576 | + if (err > 0) |
12577 | + err += nr_pages - i - 1; |
12578 | goto out; |
12579 | + } |
12580 | if (i > start) { |
12581 | err = store_status(status, start, current_node, i - start); |
12582 | if (err) |
12583 | @@ -1678,6 +1692,13 @@ out_flush: |
12584 | |
12585 | /* Make sure we do not overwrite the existing error */ |
12586 | err1 = do_move_pages_to_node(mm, &pagelist, current_node); |
12587 | + /* |
12588 | + * Don't have to report non-attempted pages here since: |
12589 | + * - If the above loop is done gracefully all pages have been |
12590 | + * attempted. |
12591 | + * - If the above loop is aborted it means a fatal error |
12592 | + * happened, should return ret. |
12593 | + */ |
12594 | if (!err1) |
12595 | err1 = store_status(status, start, current_node, i - start); |
12596 | if (err >= 0) |
12597 | diff --git a/mm/mmu_gather.c b/mm/mmu_gather.c |
12598 | index 7d70e5c78f97..7c1b8f67af7b 100644 |
12599 | --- a/mm/mmu_gather.c |
12600 | +++ b/mm/mmu_gather.c |
12601 | @@ -102,14 +102,14 @@ bool __tlb_remove_page_size(struct mmu_gather *tlb, struct page *page, int page_ |
12602 | */ |
12603 | static inline void tlb_table_invalidate(struct mmu_gather *tlb) |
12604 | { |
12605 | -#ifndef CONFIG_HAVE_RCU_TABLE_NO_INVALIDATE |
12606 | - /* |
12607 | - * Invalidate page-table caches used by hardware walkers. Then we still |
12608 | - * need to RCU-sched wait while freeing the pages because software |
12609 | - * walkers can still be in-flight. |
12610 | - */ |
12611 | - tlb_flush_mmu_tlbonly(tlb); |
12612 | -#endif |
12613 | + if (tlb_needs_table_invalidate()) { |
12614 | + /* |
12615 | + * Invalidate page-table caches used by hardware walkers. Then |
12616 | + * we still need to RCU-sched wait while freeing the pages |
12617 | + * because software walkers can still be in-flight. |
12618 | + */ |
12619 | + tlb_flush_mmu_tlbonly(tlb); |
12620 | + } |
12621 | } |
12622 | |
12623 | static void tlb_remove_table_smp_sync(void *arg) |
12624 | diff --git a/mm/page_alloc.c b/mm/page_alloc.c |
12625 | index 45e39131a716..d387ca74cb5a 100644 |
12626 | --- a/mm/page_alloc.c |
12627 | +++ b/mm/page_alloc.c |
12628 | @@ -6933,7 +6933,8 @@ static u64 zero_pfn_range(unsigned long spfn, unsigned long epfn) |
12629 | * This function also addresses a similar issue where struct pages are left |
12630 | * uninitialized because the physical address range is not covered by |
12631 | * memblock.memory or memblock.reserved. That could happen when memblock |
12632 | - * layout is manually configured via memmap=. |
12633 | + * layout is manually configured via memmap=, or when the highest physical |
12634 | + * address (max_pfn) does not end on a section boundary. |
12635 | */ |
12636 | void __init zero_resv_unavail(void) |
12637 | { |
12638 | @@ -6951,7 +6952,16 @@ void __init zero_resv_unavail(void) |
12639 | pgcnt += zero_pfn_range(PFN_DOWN(next), PFN_UP(start)); |
12640 | next = end; |
12641 | } |
12642 | - pgcnt += zero_pfn_range(PFN_DOWN(next), max_pfn); |
12643 | + |
12644 | + /* |
12645 | + * Early sections always have a fully populated memmap for the whole |
12646 | + * section - see pfn_valid(). If the last section has holes at the |
12647 | + * end and that section is marked "online", the memmap will be |
12648 | + * considered initialized. Make sure that memmap has a well defined |
12649 | + * state. |
12650 | + */ |
12651 | + pgcnt += zero_pfn_range(PFN_DOWN(next), |
12652 | + round_up(max_pfn, PAGES_PER_SECTION)); |
12653 | |
12654 | /* |
12655 | * Struct pages that do not have backing memory. This could be because |
12656 | diff --git a/mm/sparse.c b/mm/sparse.c |
12657 | index 1100fdb9649c..69b41b6046a5 100644 |
12658 | --- a/mm/sparse.c |
12659 | +++ b/mm/sparse.c |
12660 | @@ -787,7 +787,7 @@ static void section_deactivate(unsigned long pfn, unsigned long nr_pages, |
12661 | ms->usage = NULL; |
12662 | } |
12663 | memmap = sparse_decode_mem_map(ms->section_mem_map, section_nr); |
12664 | - ms->section_mem_map = sparse_encode_mem_map(NULL, section_nr); |
12665 | + ms->section_mem_map = (unsigned long)NULL; |
12666 | } |
12667 | |
12668 | if (section_is_early && memmap) |
12669 | diff --git a/net/core/devlink.c b/net/core/devlink.c |
12670 | index ae614965c8c2..61bc67047f56 100644 |
12671 | --- a/net/core/devlink.c |
12672 | +++ b/net/core/devlink.c |
12673 | @@ -3863,6 +3863,12 @@ static int devlink_nl_cmd_region_read_dumpit(struct sk_buff *skb, |
12674 | goto out_unlock; |
12675 | } |
12676 | |
12677 | + /* return 0 if there is no further data to read */ |
12678 | + if (start_offset >= region->size) { |
12679 | + err = 0; |
12680 | + goto out_unlock; |
12681 | + } |
12682 | + |
12683 | hdr = genlmsg_put(skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq, |
12684 | &devlink_nl_family, NLM_F_ACK | NLM_F_MULTI, |
12685 | DEVLINK_CMD_REGION_READ); |
12686 | diff --git a/net/core/drop_monitor.c b/net/core/drop_monitor.c |
12687 | index 536e032d95c8..246a258b1fac 100644 |
12688 | --- a/net/core/drop_monitor.c |
12689 | +++ b/net/core/drop_monitor.c |
12690 | @@ -1004,8 +1004,10 @@ static void net_dm_hw_monitor_stop(struct netlink_ext_ack *extack) |
12691 | { |
12692 | int cpu; |
12693 | |
12694 | - if (!monitor_hw) |
12695 | + if (!monitor_hw) { |
12696 | NL_SET_ERR_MSG_MOD(extack, "Hardware monitoring already disabled"); |
12697 | + return; |
12698 | + } |
12699 | |
12700 | monitor_hw = false; |
12701 | |
12702 | diff --git a/net/hsr/hsr_slave.c b/net/hsr/hsr_slave.c |
12703 | index ee561297d8a7..fbfd0db182b7 100644 |
12704 | --- a/net/hsr/hsr_slave.c |
12705 | +++ b/net/hsr/hsr_slave.c |
12706 | @@ -27,6 +27,8 @@ static rx_handler_result_t hsr_handle_frame(struct sk_buff **pskb) |
12707 | |
12708 | rcu_read_lock(); /* hsr->node_db, hsr->ports */ |
12709 | port = hsr_port_get_rcu(skb->dev); |
12710 | + if (!port) |
12711 | + goto finish_pass; |
12712 | |
12713 | if (hsr_addr_is_self(port->hsr, eth_hdr(skb)->h_source)) { |
12714 | /* Directly kill frames sent by ourselves */ |
12715 | diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c |
12716 | index 3640e8563a10..deb466fc3d1f 100644 |
12717 | --- a/net/ipv4/tcp.c |
12718 | +++ b/net/ipv4/tcp.c |
12719 | @@ -2618,10 +2618,12 @@ int tcp_disconnect(struct sock *sk, int flags) |
12720 | tp->snd_cwnd = TCP_INIT_CWND; |
12721 | tp->snd_cwnd_cnt = 0; |
12722 | tp->window_clamp = 0; |
12723 | + tp->delivered = 0; |
12724 | tp->delivered_ce = 0; |
12725 | tcp_set_ca_state(sk, TCP_CA_Open); |
12726 | tp->is_sack_reneg = 0; |
12727 | tcp_clear_retrans(tp); |
12728 | + tp->total_retrans = 0; |
12729 | inet_csk_delack_init(sk); |
12730 | /* Initialize rcv_mss to TCP_MIN_MSS to avoid division by 0 |
12731 | * issue in __tcp_select_window() |
12732 | @@ -2633,10 +2635,14 @@ int tcp_disconnect(struct sock *sk, int flags) |
12733 | sk->sk_rx_dst = NULL; |
12734 | tcp_saved_syn_free(tp); |
12735 | tp->compressed_ack = 0; |
12736 | + tp->segs_in = 0; |
12737 | + tp->segs_out = 0; |
12738 | tp->bytes_sent = 0; |
12739 | tp->bytes_acked = 0; |
12740 | tp->bytes_received = 0; |
12741 | tp->bytes_retrans = 0; |
12742 | + tp->data_segs_in = 0; |
12743 | + tp->data_segs_out = 0; |
12744 | tp->duplicate_sack[0].start_seq = 0; |
12745 | tp->duplicate_sack[0].end_seq = 0; |
12746 | tp->dsack_dups = 0; |
12747 | diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c |
12748 | index f9b5690e94fd..b11ccb53c7e0 100644 |
12749 | --- a/net/ipv6/addrconf.c |
12750 | +++ b/net/ipv6/addrconf.c |
12751 | @@ -5719,6 +5719,9 @@ static int inet6_set_link_af(struct net_device *dev, const struct nlattr *nla) |
12752 | struct nlattr *tb[IFLA_INET6_MAX + 1]; |
12753 | int err; |
12754 | |
12755 | + if (!idev) |
12756 | + return -EAFNOSUPPORT; |
12757 | + |
12758 | if (nla_parse_nested_deprecated(tb, IFLA_INET6_MAX, nla, NULL, NULL) < 0) |
12759 | BUG(); |
12760 | |
12761 | diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c |
12762 | index f82ea12bac37..425b95eb7e87 100644 |
12763 | --- a/net/l2tp/l2tp_core.c |
12764 | +++ b/net/l2tp/l2tp_core.c |
12765 | @@ -322,8 +322,13 @@ int l2tp_session_register(struct l2tp_session *session, |
12766 | |
12767 | spin_lock_bh(&pn->l2tp_session_hlist_lock); |
12768 | |
12769 | + /* IP encap expects session IDs to be globally unique, while |
12770 | + * UDP encap doesn't. |
12771 | + */ |
12772 | hlist_for_each_entry(session_walk, g_head, global_hlist) |
12773 | - if (session_walk->session_id == session->session_id) { |
12774 | + if (session_walk->session_id == session->session_id && |
12775 | + (session_walk->tunnel->encap == L2TP_ENCAPTYPE_IP || |
12776 | + tunnel->encap == L2TP_ENCAPTYPE_IP)) { |
12777 | err = -EEXIST; |
12778 | goto err_tlock_pnlock; |
12779 | } |
12780 | diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c |
12781 | index d8143a8c034d..a9df9dac57b2 100644 |
12782 | --- a/net/netfilter/ipset/ip_set_core.c |
12783 | +++ b/net/netfilter/ipset/ip_set_core.c |
12784 | @@ -1293,31 +1293,34 @@ ip_set_dump_policy[IPSET_ATTR_CMD_MAX + 1] = { |
12785 | }; |
12786 | |
12787 | static int |
12788 | -dump_init(struct netlink_callback *cb, struct ip_set_net *inst) |
12789 | +ip_set_dump_start(struct netlink_callback *cb) |
12790 | { |
12791 | struct nlmsghdr *nlh = nlmsg_hdr(cb->skb); |
12792 | int min_len = nlmsg_total_size(sizeof(struct nfgenmsg)); |
12793 | struct nlattr *cda[IPSET_ATTR_CMD_MAX + 1]; |
12794 | struct nlattr *attr = (void *)nlh + min_len; |
12795 | + struct sk_buff *skb = cb->skb; |
12796 | + struct ip_set_net *inst = ip_set_pernet(sock_net(skb->sk)); |
12797 | u32 dump_type; |
12798 | - ip_set_id_t index; |
12799 | int ret; |
12800 | |
12801 | ret = nla_parse(cda, IPSET_ATTR_CMD_MAX, attr, |
12802 | nlh->nlmsg_len - min_len, |
12803 | ip_set_dump_policy, NULL); |
12804 | if (ret) |
12805 | - return ret; |
12806 | + goto error; |
12807 | |
12808 | cb->args[IPSET_CB_PROTO] = nla_get_u8(cda[IPSET_ATTR_PROTOCOL]); |
12809 | if (cda[IPSET_ATTR_SETNAME]) { |
12810 | + ip_set_id_t index; |
12811 | struct ip_set *set; |
12812 | |
12813 | set = find_set_and_id(inst, nla_data(cda[IPSET_ATTR_SETNAME]), |
12814 | &index); |
12815 | - if (!set) |
12816 | - return -ENOENT; |
12817 | - |
12818 | + if (!set) { |
12819 | + ret = -ENOENT; |
12820 | + goto error; |
12821 | + } |
12822 | dump_type = DUMP_ONE; |
12823 | cb->args[IPSET_CB_INDEX] = index; |
12824 | } else { |
12825 | @@ -1333,10 +1336,17 @@ dump_init(struct netlink_callback *cb, struct ip_set_net *inst) |
12826 | cb->args[IPSET_CB_DUMP] = dump_type; |
12827 | |
12828 | return 0; |
12829 | + |
12830 | +error: |
12831 | + /* We have to create and send the error message manually :-( */ |
12832 | + if (nlh->nlmsg_flags & NLM_F_ACK) { |
12833 | + netlink_ack(cb->skb, nlh, ret, NULL); |
12834 | + } |
12835 | + return ret; |
12836 | } |
12837 | |
12838 | static int |
12839 | -ip_set_dump_start(struct sk_buff *skb, struct netlink_callback *cb) |
12840 | +ip_set_dump_do(struct sk_buff *skb, struct netlink_callback *cb) |
12841 | { |
12842 | ip_set_id_t index = IPSET_INVALID_ID, max; |
12843 | struct ip_set *set = NULL; |
12844 | @@ -1347,18 +1357,8 @@ ip_set_dump_start(struct sk_buff *skb, struct netlink_callback *cb) |
12845 | bool is_destroyed; |
12846 | int ret = 0; |
12847 | |
12848 | - if (!cb->args[IPSET_CB_DUMP]) { |
12849 | - ret = dump_init(cb, inst); |
12850 | - if (ret < 0) { |
12851 | - nlh = nlmsg_hdr(cb->skb); |
12852 | - /* We have to create and send the error message |
12853 | - * manually :-( |
12854 | - */ |
12855 | - if (nlh->nlmsg_flags & NLM_F_ACK) |
12856 | - netlink_ack(cb->skb, nlh, ret, NULL); |
12857 | - return ret; |
12858 | - } |
12859 | - } |
12860 | + if (!cb->args[IPSET_CB_DUMP]) |
12861 | + return -EINVAL; |
12862 | |
12863 | if (cb->args[IPSET_CB_INDEX] >= inst->ip_set_max) |
12864 | goto out; |
12865 | @@ -1494,7 +1494,8 @@ static int ip_set_dump(struct net *net, struct sock *ctnl, struct sk_buff *skb, |
12866 | |
12867 | { |
12868 | struct netlink_dump_control c = { |
12869 | - .dump = ip_set_dump_start, |
12870 | + .start = ip_set_dump_start, |
12871 | + .dump = ip_set_dump_do, |
12872 | .done = ip_set_dump_done, |
12873 | }; |
12874 | return netlink_dump_start(ctnl, skb, nlh, &c); |
12875 | diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c |
12876 | index d72ddb67bb74..4a6ca9723a12 100644 |
12877 | --- a/net/rxrpc/af_rxrpc.c |
12878 | +++ b/net/rxrpc/af_rxrpc.c |
12879 | @@ -194,6 +194,7 @@ static int rxrpc_bind(struct socket *sock, struct sockaddr *saddr, int len) |
12880 | service_in_use: |
12881 | write_unlock(&local->services_lock); |
12882 | rxrpc_unuse_local(local); |
12883 | + rxrpc_put_local(local); |
12884 | ret = -EADDRINUSE; |
12885 | error_unlock: |
12886 | release_sock(&rx->sk); |
12887 | @@ -899,6 +900,7 @@ static int rxrpc_release_sock(struct sock *sk) |
12888 | rxrpc_purge_queue(&sk->sk_receive_queue); |
12889 | |
12890 | rxrpc_unuse_local(rx->local); |
12891 | + rxrpc_put_local(rx->local); |
12892 | rx->local = NULL; |
12893 | key_put(rx->key); |
12894 | rx->key = NULL; |
12895 | diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h |
12896 | index 5e99df80e80a..7d730c438404 100644 |
12897 | --- a/net/rxrpc/ar-internal.h |
12898 | +++ b/net/rxrpc/ar-internal.h |
12899 | @@ -490,6 +490,7 @@ enum rxrpc_call_flag { |
12900 | RXRPC_CALL_RX_HEARD, /* The peer responded at least once to this call */ |
12901 | RXRPC_CALL_RX_UNDERRUN, /* Got data underrun */ |
12902 | RXRPC_CALL_IS_INTR, /* The call is interruptible */ |
12903 | + RXRPC_CALL_DISCONNECTED, /* The call has been disconnected */ |
12904 | }; |
12905 | |
12906 | /* |
12907 | @@ -1021,6 +1022,16 @@ void rxrpc_unuse_local(struct rxrpc_local *); |
12908 | void rxrpc_queue_local(struct rxrpc_local *); |
12909 | void rxrpc_destroy_all_locals(struct rxrpc_net *); |
12910 | |
12911 | +static inline bool __rxrpc_unuse_local(struct rxrpc_local *local) |
12912 | +{ |
12913 | + return atomic_dec_return(&local->active_users) == 0; |
12914 | +} |
12915 | + |
12916 | +static inline bool __rxrpc_use_local(struct rxrpc_local *local) |
12917 | +{ |
12918 | + return atomic_fetch_add_unless(&local->active_users, 1, 0) != 0; |
12919 | +} |
12920 | + |
12921 | /* |
12922 | * misc.c |
12923 | */ |
12924 | diff --git a/net/rxrpc/call_object.c b/net/rxrpc/call_object.c |
12925 | index a31c18c09894..dbdbc4f18b5e 100644 |
12926 | --- a/net/rxrpc/call_object.c |
12927 | +++ b/net/rxrpc/call_object.c |
12928 | @@ -493,7 +493,7 @@ void rxrpc_release_call(struct rxrpc_sock *rx, struct rxrpc_call *call) |
12929 | |
12930 | _debug("RELEASE CALL %p (%d CONN %p)", call, call->debug_id, conn); |
12931 | |
12932 | - if (conn) |
12933 | + if (conn && !test_bit(RXRPC_CALL_DISCONNECTED, &call->flags)) |
12934 | rxrpc_disconnect_call(call); |
12935 | if (call->security) |
12936 | call->security->free_call_crypto(call); |
12937 | @@ -569,6 +569,7 @@ static void rxrpc_rcu_destroy_call(struct rcu_head *rcu) |
12938 | struct rxrpc_call *call = container_of(rcu, struct rxrpc_call, rcu); |
12939 | struct rxrpc_net *rxnet = call->rxnet; |
12940 | |
12941 | + rxrpc_put_connection(call->conn); |
12942 | rxrpc_put_peer(call->peer); |
12943 | kfree(call->rxtx_buffer); |
12944 | kfree(call->rxtx_annotations); |
12945 | @@ -590,7 +591,6 @@ void rxrpc_cleanup_call(struct rxrpc_call *call) |
12946 | |
12947 | ASSERTCMP(call->state, ==, RXRPC_CALL_COMPLETE); |
12948 | ASSERT(test_bit(RXRPC_CALL_RELEASED, &call->flags)); |
12949 | - ASSERTCMP(call->conn, ==, NULL); |
12950 | |
12951 | rxrpc_cleanup_ring(call); |
12952 | rxrpc_free_skb(call->tx_pending, rxrpc_skb_cleaned); |
12953 | diff --git a/net/rxrpc/conn_client.c b/net/rxrpc/conn_client.c |
12954 | index 376370cd9285..ea7d4c21f889 100644 |
12955 | --- a/net/rxrpc/conn_client.c |
12956 | +++ b/net/rxrpc/conn_client.c |
12957 | @@ -785,6 +785,7 @@ void rxrpc_disconnect_client_call(struct rxrpc_call *call) |
12958 | u32 cid; |
12959 | |
12960 | spin_lock(&conn->channel_lock); |
12961 | + set_bit(RXRPC_CALL_DISCONNECTED, &call->flags); |
12962 | |
12963 | cid = call->cid; |
12964 | if (cid) { |
12965 | @@ -792,7 +793,6 @@ void rxrpc_disconnect_client_call(struct rxrpc_call *call) |
12966 | chan = &conn->channels[channel]; |
12967 | } |
12968 | trace_rxrpc_client(conn, channel, rxrpc_client_chan_disconnect); |
12969 | - call->conn = NULL; |
12970 | |
12971 | /* Calls that have never actually been assigned a channel can simply be |
12972 | * discarded. If the conn didn't get used either, it will follow |
12973 | @@ -908,7 +908,6 @@ out: |
12974 | spin_unlock(&rxnet->client_conn_cache_lock); |
12975 | out_2: |
12976 | spin_unlock(&conn->channel_lock); |
12977 | - rxrpc_put_connection(conn); |
12978 | _leave(""); |
12979 | return; |
12980 | |
12981 | diff --git a/net/rxrpc/conn_event.c b/net/rxrpc/conn_event.c |
12982 | index 808a4723f868..06fcff2ebbba 100644 |
12983 | --- a/net/rxrpc/conn_event.c |
12984 | +++ b/net/rxrpc/conn_event.c |
12985 | @@ -438,16 +438,12 @@ again: |
12986 | /* |
12987 | * connection-level event processor |
12988 | */ |
12989 | -void rxrpc_process_connection(struct work_struct *work) |
12990 | +static void rxrpc_do_process_connection(struct rxrpc_connection *conn) |
12991 | { |
12992 | - struct rxrpc_connection *conn = |
12993 | - container_of(work, struct rxrpc_connection, processor); |
12994 | struct sk_buff *skb; |
12995 | u32 abort_code = RX_PROTOCOL_ERROR; |
12996 | int ret; |
12997 | |
12998 | - rxrpc_see_connection(conn); |
12999 | - |
13000 | if (test_and_clear_bit(RXRPC_CONN_EV_CHALLENGE, &conn->events)) |
13001 | rxrpc_secure_connection(conn); |
13002 | |
13003 | @@ -475,18 +471,32 @@ void rxrpc_process_connection(struct work_struct *work) |
13004 | } |
13005 | } |
13006 | |
13007 | -out: |
13008 | - rxrpc_put_connection(conn); |
13009 | - _leave(""); |
13010 | return; |
13011 | |
13012 | requeue_and_leave: |
13013 | skb_queue_head(&conn->rx_queue, skb); |
13014 | - goto out; |
13015 | + return; |
13016 | |
13017 | protocol_error: |
13018 | if (rxrpc_abort_connection(conn, ret, abort_code) < 0) |
13019 | goto requeue_and_leave; |
13020 | rxrpc_free_skb(skb, rxrpc_skb_freed); |
13021 | - goto out; |
13022 | + return; |
13023 | +} |
13024 | + |
13025 | +void rxrpc_process_connection(struct work_struct *work) |
13026 | +{ |
13027 | + struct rxrpc_connection *conn = |
13028 | + container_of(work, struct rxrpc_connection, processor); |
13029 | + |
13030 | + rxrpc_see_connection(conn); |
13031 | + |
13032 | + if (__rxrpc_use_local(conn->params.local)) { |
13033 | + rxrpc_do_process_connection(conn); |
13034 | + rxrpc_unuse_local(conn->params.local); |
13035 | + } |
13036 | + |
13037 | + rxrpc_put_connection(conn); |
13038 | + _leave(""); |
13039 | + return; |
13040 | } |
13041 | diff --git a/net/rxrpc/conn_object.c b/net/rxrpc/conn_object.c |
13042 | index 38d718e90dc6..19e141eeed17 100644 |
13043 | --- a/net/rxrpc/conn_object.c |
13044 | +++ b/net/rxrpc/conn_object.c |
13045 | @@ -223,9 +223,8 @@ void rxrpc_disconnect_call(struct rxrpc_call *call) |
13046 | __rxrpc_disconnect_call(conn, call); |
13047 | spin_unlock(&conn->channel_lock); |
13048 | |
13049 | - call->conn = NULL; |
13050 | + set_bit(RXRPC_CALL_DISCONNECTED, &call->flags); |
13051 | conn->idle_timestamp = jiffies; |
13052 | - rxrpc_put_connection(conn); |
13053 | } |
13054 | |
13055 | /* |
13056 | diff --git a/net/rxrpc/input.c b/net/rxrpc/input.c |
13057 | index 96d54e5bf7bc..ef10fbf71b15 100644 |
13058 | --- a/net/rxrpc/input.c |
13059 | +++ b/net/rxrpc/input.c |
13060 | @@ -599,10 +599,8 @@ ack: |
13061 | false, true, |
13062 | rxrpc_propose_ack_input_data); |
13063 | |
13064 | - if (seq0 == READ_ONCE(call->rx_hard_ack) + 1) { |
13065 | - trace_rxrpc_notify_socket(call->debug_id, serial); |
13066 | - rxrpc_notify_socket(call); |
13067 | - } |
13068 | + trace_rxrpc_notify_socket(call->debug_id, serial); |
13069 | + rxrpc_notify_socket(call); |
13070 | |
13071 | unlock: |
13072 | spin_unlock(&call->input_lock); |
13073 | diff --git a/net/rxrpc/local_object.c b/net/rxrpc/local_object.c |
13074 | index 36587260cabd..a6c1349e965d 100644 |
13075 | --- a/net/rxrpc/local_object.c |
13076 | +++ b/net/rxrpc/local_object.c |
13077 | @@ -364,11 +364,14 @@ void rxrpc_queue_local(struct rxrpc_local *local) |
13078 | void rxrpc_put_local(struct rxrpc_local *local) |
13079 | { |
13080 | const void *here = __builtin_return_address(0); |
13081 | + unsigned int debug_id; |
13082 | int n; |
13083 | |
13084 | if (local) { |
13085 | + debug_id = local->debug_id; |
13086 | + |
13087 | n = atomic_dec_return(&local->usage); |
13088 | - trace_rxrpc_local(local->debug_id, rxrpc_local_put, n, here); |
13089 | + trace_rxrpc_local(debug_id, rxrpc_local_put, n, here); |
13090 | |
13091 | if (n == 0) |
13092 | call_rcu(&local->rcu, rxrpc_local_rcu); |
13093 | @@ -380,14 +383,11 @@ void rxrpc_put_local(struct rxrpc_local *local) |
13094 | */ |
13095 | struct rxrpc_local *rxrpc_use_local(struct rxrpc_local *local) |
13096 | { |
13097 | - unsigned int au; |
13098 | - |
13099 | local = rxrpc_get_local_maybe(local); |
13100 | if (!local) |
13101 | return NULL; |
13102 | |
13103 | - au = atomic_fetch_add_unless(&local->active_users, 1, 0); |
13104 | - if (au == 0) { |
13105 | + if (!__rxrpc_use_local(local)) { |
13106 | rxrpc_put_local(local); |
13107 | return NULL; |
13108 | } |
13109 | @@ -401,14 +401,11 @@ struct rxrpc_local *rxrpc_use_local(struct rxrpc_local *local) |
13110 | */ |
13111 | void rxrpc_unuse_local(struct rxrpc_local *local) |
13112 | { |
13113 | - unsigned int au; |
13114 | - |
13115 | if (local) { |
13116 | - au = atomic_dec_return(&local->active_users); |
13117 | - if (au == 0) |
13118 | + if (__rxrpc_unuse_local(local)) { |
13119 | + rxrpc_get_local(local); |
13120 | rxrpc_queue_local(local); |
13121 | - else |
13122 | - rxrpc_put_local(local); |
13123 | + } |
13124 | } |
13125 | } |
13126 | |
13127 | @@ -465,7 +462,7 @@ static void rxrpc_local_processor(struct work_struct *work) |
13128 | |
13129 | do { |
13130 | again = false; |
13131 | - if (atomic_read(&local->active_users) == 0) { |
13132 | + if (!__rxrpc_use_local(local)) { |
13133 | rxrpc_local_destroyer(local); |
13134 | break; |
13135 | } |
13136 | @@ -479,6 +476,8 @@ static void rxrpc_local_processor(struct work_struct *work) |
13137 | rxrpc_process_local_events(local); |
13138 | again = true; |
13139 | } |
13140 | + |
13141 | + __rxrpc_unuse_local(local); |
13142 | } while (again); |
13143 | |
13144 | rxrpc_put_local(local); |
13145 | diff --git a/net/rxrpc/output.c b/net/rxrpc/output.c |
13146 | index 935bb60fff56..bad3d2420344 100644 |
13147 | --- a/net/rxrpc/output.c |
13148 | +++ b/net/rxrpc/output.c |
13149 | @@ -129,7 +129,7 @@ static size_t rxrpc_fill_out_ack(struct rxrpc_connection *conn, |
13150 | int rxrpc_send_ack_packet(struct rxrpc_call *call, bool ping, |
13151 | rxrpc_serial_t *_serial) |
13152 | { |
13153 | - struct rxrpc_connection *conn = NULL; |
13154 | + struct rxrpc_connection *conn; |
13155 | struct rxrpc_ack_buffer *pkt; |
13156 | struct msghdr msg; |
13157 | struct kvec iov[2]; |
13158 | @@ -139,18 +139,14 @@ int rxrpc_send_ack_packet(struct rxrpc_call *call, bool ping, |
13159 | int ret; |
13160 | u8 reason; |
13161 | |
13162 | - spin_lock_bh(&call->lock); |
13163 | - if (call->conn) |
13164 | - conn = rxrpc_get_connection_maybe(call->conn); |
13165 | - spin_unlock_bh(&call->lock); |
13166 | - if (!conn) |
13167 | + if (test_bit(RXRPC_CALL_DISCONNECTED, &call->flags)) |
13168 | return -ECONNRESET; |
13169 | |
13170 | pkt = kzalloc(sizeof(*pkt), GFP_KERNEL); |
13171 | - if (!pkt) { |
13172 | - rxrpc_put_connection(conn); |
13173 | + if (!pkt) |
13174 | return -ENOMEM; |
13175 | - } |
13176 | + |
13177 | + conn = call->conn; |
13178 | |
13179 | msg.msg_name = &call->peer->srx.transport; |
13180 | msg.msg_namelen = call->peer->srx.transport_len; |
13181 | @@ -244,7 +240,6 @@ int rxrpc_send_ack_packet(struct rxrpc_call *call, bool ping, |
13182 | } |
13183 | |
13184 | out: |
13185 | - rxrpc_put_connection(conn); |
13186 | kfree(pkt); |
13187 | return ret; |
13188 | } |
13189 | @@ -254,7 +249,7 @@ out: |
13190 | */ |
13191 | int rxrpc_send_abort_packet(struct rxrpc_call *call) |
13192 | { |
13193 | - struct rxrpc_connection *conn = NULL; |
13194 | + struct rxrpc_connection *conn; |
13195 | struct rxrpc_abort_buffer pkt; |
13196 | struct msghdr msg; |
13197 | struct kvec iov[1]; |
13198 | @@ -271,13 +266,11 @@ int rxrpc_send_abort_packet(struct rxrpc_call *call) |
13199 | test_bit(RXRPC_CALL_TX_LAST, &call->flags)) |
13200 | return 0; |
13201 | |
13202 | - spin_lock_bh(&call->lock); |
13203 | - if (call->conn) |
13204 | - conn = rxrpc_get_connection_maybe(call->conn); |
13205 | - spin_unlock_bh(&call->lock); |
13206 | - if (!conn) |
13207 | + if (test_bit(RXRPC_CALL_DISCONNECTED, &call->flags)) |
13208 | return -ECONNRESET; |
13209 | |
13210 | + conn = call->conn; |
13211 | + |
13212 | msg.msg_name = &call->peer->srx.transport; |
13213 | msg.msg_namelen = call->peer->srx.transport_len; |
13214 | msg.msg_control = NULL; |
13215 | @@ -312,8 +305,6 @@ int rxrpc_send_abort_packet(struct rxrpc_call *call) |
13216 | trace_rxrpc_tx_packet(call->debug_id, &pkt.whdr, |
13217 | rxrpc_tx_point_call_abort); |
13218 | rxrpc_tx_backoff(call, ret); |
13219 | - |
13220 | - rxrpc_put_connection(conn); |
13221 | return ret; |
13222 | } |
13223 | |
13224 | diff --git a/net/rxrpc/peer_event.c b/net/rxrpc/peer_event.c |
13225 | index 48f67a9b1037..923b263c401b 100644 |
13226 | --- a/net/rxrpc/peer_event.c |
13227 | +++ b/net/rxrpc/peer_event.c |
13228 | @@ -364,27 +364,31 @@ static void rxrpc_peer_keepalive_dispatch(struct rxrpc_net *rxnet, |
13229 | if (!rxrpc_get_peer_maybe(peer)) |
13230 | continue; |
13231 | |
13232 | - spin_unlock_bh(&rxnet->peer_hash_lock); |
13233 | - |
13234 | - keepalive_at = peer->last_tx_at + RXRPC_KEEPALIVE_TIME; |
13235 | - slot = keepalive_at - base; |
13236 | - _debug("%02x peer %u t=%d {%pISp}", |
13237 | - cursor, peer->debug_id, slot, &peer->srx.transport); |
13238 | + if (__rxrpc_use_local(peer->local)) { |
13239 | + spin_unlock_bh(&rxnet->peer_hash_lock); |
13240 | + |
13241 | + keepalive_at = peer->last_tx_at + RXRPC_KEEPALIVE_TIME; |
13242 | + slot = keepalive_at - base; |
13243 | + _debug("%02x peer %u t=%d {%pISp}", |
13244 | + cursor, peer->debug_id, slot, &peer->srx.transport); |
13245 | + |
13246 | + if (keepalive_at <= base || |
13247 | + keepalive_at > base + RXRPC_KEEPALIVE_TIME) { |
13248 | + rxrpc_send_keepalive(peer); |
13249 | + slot = RXRPC_KEEPALIVE_TIME; |
13250 | + } |
13251 | |
13252 | - if (keepalive_at <= base || |
13253 | - keepalive_at > base + RXRPC_KEEPALIVE_TIME) { |
13254 | - rxrpc_send_keepalive(peer); |
13255 | - slot = RXRPC_KEEPALIVE_TIME; |
13256 | + /* A transmission to this peer occurred since last we |
13257 | + * examined it so put it into the appropriate future |
13258 | + * bucket. |
13259 | + */ |
13260 | + slot += cursor; |
13261 | + slot &= mask; |
13262 | + spin_lock_bh(&rxnet->peer_hash_lock); |
13263 | + list_add_tail(&peer->keepalive_link, |
13264 | + &rxnet->peer_keepalive[slot & mask]); |
13265 | + rxrpc_unuse_local(peer->local); |
13266 | } |
13267 | - |
13268 | - /* A transmission to this peer occurred since last we examined |
13269 | - * it so put it into the appropriate future bucket. |
13270 | - */ |
13271 | - slot += cursor; |
13272 | - slot &= mask; |
13273 | - spin_lock_bh(&rxnet->peer_hash_lock); |
13274 | - list_add_tail(&peer->keepalive_link, |
13275 | - &rxnet->peer_keepalive[slot & mask]); |
13276 | rxrpc_put_peer_locked(peer); |
13277 | } |
13278 | |
13279 | diff --git a/net/sched/cls_rsvp.h b/net/sched/cls_rsvp.h |
13280 | index c22624131949..d36949d9382c 100644 |
13281 | --- a/net/sched/cls_rsvp.h |
13282 | +++ b/net/sched/cls_rsvp.h |
13283 | @@ -463,10 +463,8 @@ static u32 gen_tunnel(struct rsvp_head *data) |
13284 | |
13285 | static const struct nla_policy rsvp_policy[TCA_RSVP_MAX + 1] = { |
13286 | [TCA_RSVP_CLASSID] = { .type = NLA_U32 }, |
13287 | - [TCA_RSVP_DST] = { .type = NLA_BINARY, |
13288 | - .len = RSVP_DST_LEN * sizeof(u32) }, |
13289 | - [TCA_RSVP_SRC] = { .type = NLA_BINARY, |
13290 | - .len = RSVP_DST_LEN * sizeof(u32) }, |
13291 | + [TCA_RSVP_DST] = { .len = RSVP_DST_LEN * sizeof(u32) }, |
13292 | + [TCA_RSVP_SRC] = { .len = RSVP_DST_LEN * sizeof(u32) }, |
13293 | [TCA_RSVP_PINFO] = { .len = sizeof(struct tc_rsvp_pinfo) }, |
13294 | }; |
13295 | |
13296 | diff --git a/net/sched/cls_tcindex.c b/net/sched/cls_tcindex.c |
13297 | index 3d4a1280352f..09b7dc5fe7e0 100644 |
13298 | --- a/net/sched/cls_tcindex.c |
13299 | +++ b/net/sched/cls_tcindex.c |
13300 | @@ -333,12 +333,31 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base, |
13301 | cp->fall_through = p->fall_through; |
13302 | cp->tp = tp; |
13303 | |
13304 | + if (tb[TCA_TCINDEX_HASH]) |
13305 | + cp->hash = nla_get_u32(tb[TCA_TCINDEX_HASH]); |
13306 | + |
13307 | + if (tb[TCA_TCINDEX_MASK]) |
13308 | + cp->mask = nla_get_u16(tb[TCA_TCINDEX_MASK]); |
13309 | + |
13310 | + if (tb[TCA_TCINDEX_SHIFT]) |
13311 | + cp->shift = nla_get_u32(tb[TCA_TCINDEX_SHIFT]); |
13312 | + |
13313 | + if (!cp->hash) { |
13314 | + /* Hash not specified, use perfect hash if the upper limit |
13315 | + * of the hashing index is below the threshold. |
13316 | + */ |
13317 | + if ((cp->mask >> cp->shift) < PERFECT_HASH_THRESHOLD) |
13318 | + cp->hash = (cp->mask >> cp->shift) + 1; |
13319 | + else |
13320 | + cp->hash = DEFAULT_HASH_SIZE; |
13321 | + } |
13322 | + |
13323 | if (p->perfect) { |
13324 | int i; |
13325 | |
13326 | if (tcindex_alloc_perfect_hash(net, cp) < 0) |
13327 | goto errout; |
13328 | - for (i = 0; i < cp->hash; i++) |
13329 | + for (i = 0; i < min(cp->hash, p->hash); i++) |
13330 | cp->perfect[i].res = p->perfect[i].res; |
13331 | balloc = 1; |
13332 | } |
13333 | @@ -346,19 +365,10 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base, |
13334 | |
13335 | err = tcindex_filter_result_init(&new_filter_result, net); |
13336 | if (err < 0) |
13337 | - goto errout1; |
13338 | + goto errout_alloc; |
13339 | if (old_r) |
13340 | cr = r->res; |
13341 | |
13342 | - if (tb[TCA_TCINDEX_HASH]) |
13343 | - cp->hash = nla_get_u32(tb[TCA_TCINDEX_HASH]); |
13344 | - |
13345 | - if (tb[TCA_TCINDEX_MASK]) |
13346 | - cp->mask = nla_get_u16(tb[TCA_TCINDEX_MASK]); |
13347 | - |
13348 | - if (tb[TCA_TCINDEX_SHIFT]) |
13349 | - cp->shift = nla_get_u32(tb[TCA_TCINDEX_SHIFT]); |
13350 | - |
13351 | err = -EBUSY; |
13352 | |
13353 | /* Hash already allocated, make sure that we still meet the |
13354 | @@ -376,16 +386,6 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base, |
13355 | if (tb[TCA_TCINDEX_FALL_THROUGH]) |
13356 | cp->fall_through = nla_get_u32(tb[TCA_TCINDEX_FALL_THROUGH]); |
13357 | |
13358 | - if (!cp->hash) { |
13359 | - /* Hash not specified, use perfect hash if the upper limit |
13360 | - * of the hashing index is below the threshold. |
13361 | - */ |
13362 | - if ((cp->mask >> cp->shift) < PERFECT_HASH_THRESHOLD) |
13363 | - cp->hash = (cp->mask >> cp->shift) + 1; |
13364 | - else |
13365 | - cp->hash = DEFAULT_HASH_SIZE; |
13366 | - } |
13367 | - |
13368 | if (!cp->perfect && !cp->h) |
13369 | cp->alloc_hash = cp->hash; |
13370 | |
13371 | @@ -484,7 +484,6 @@ errout_alloc: |
13372 | tcindex_free_perfect_hash(cp); |
13373 | else if (balloc == 2) |
13374 | kfree(cp->h); |
13375 | -errout1: |
13376 | tcf_exts_destroy(&new_filter_result.exts); |
13377 | errout: |
13378 | kfree(cp); |
13379 | diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c |
13380 | index c609373c8661..660fc45ee40f 100644 |
13381 | --- a/net/sched/sch_taprio.c |
13382 | +++ b/net/sched/sch_taprio.c |
13383 | @@ -31,6 +31,7 @@ static DEFINE_SPINLOCK(taprio_list_lock); |
13384 | |
13385 | #define TXTIME_ASSIST_IS_ENABLED(flags) ((flags) & TCA_TAPRIO_ATTR_FLAG_TXTIME_ASSIST) |
13386 | #define FULL_OFFLOAD_IS_ENABLED(flags) ((flags) & TCA_TAPRIO_ATTR_FLAG_FULL_OFFLOAD) |
13387 | +#define TAPRIO_FLAGS_INVALID U32_MAX |
13388 | |
13389 | struct sched_entry { |
13390 | struct list_head list; |
13391 | @@ -766,6 +767,7 @@ static const struct nla_policy taprio_policy[TCA_TAPRIO_ATTR_MAX + 1] = { |
13392 | [TCA_TAPRIO_ATTR_SCHED_CLOCKID] = { .type = NLA_S32 }, |
13393 | [TCA_TAPRIO_ATTR_SCHED_CYCLE_TIME] = { .type = NLA_S64 }, |
13394 | [TCA_TAPRIO_ATTR_SCHED_CYCLE_TIME_EXTENSION] = { .type = NLA_S64 }, |
13395 | + [TCA_TAPRIO_ATTR_FLAGS] = { .type = NLA_U32 }, |
13396 | }; |
13397 | |
13398 | static int fill_sched_entry(struct nlattr **tb, struct sched_entry *entry, |
13399 | @@ -1367,6 +1369,33 @@ static int taprio_mqprio_cmp(const struct net_device *dev, |
13400 | return 0; |
13401 | } |
13402 | |
13403 | +/* The semantics of the 'flags' argument in relation to 'change()' |
13404 | + * requests, are interpreted following two rules (which are applied in |
13405 | + * this order): (1) an omitted 'flags' argument is interpreted as |
13406 | + * zero; (2) the 'flags' of a "running" taprio instance cannot be |
13407 | + * changed. |
13408 | + */ |
13409 | +static int taprio_new_flags(const struct nlattr *attr, u32 old, |
13410 | + struct netlink_ext_ack *extack) |
13411 | +{ |
13412 | + u32 new = 0; |
13413 | + |
13414 | + if (attr) |
13415 | + new = nla_get_u32(attr); |
13416 | + |
13417 | + if (old != TAPRIO_FLAGS_INVALID && old != new) { |
13418 | + NL_SET_ERR_MSG_MOD(extack, "Changing 'flags' of a running schedule is not supported"); |
13419 | + return -EOPNOTSUPP; |
13420 | + } |
13421 | + |
13422 | + if (!taprio_flags_valid(new)) { |
13423 | + NL_SET_ERR_MSG_MOD(extack, "Specified 'flags' are not valid"); |
13424 | + return -EINVAL; |
13425 | + } |
13426 | + |
13427 | + return new; |
13428 | +} |
13429 | + |
13430 | static int taprio_change(struct Qdisc *sch, struct nlattr *opt, |
13431 | struct netlink_ext_ack *extack) |
13432 | { |
13433 | @@ -1375,7 +1404,6 @@ static int taprio_change(struct Qdisc *sch, struct nlattr *opt, |
13434 | struct taprio_sched *q = qdisc_priv(sch); |
13435 | struct net_device *dev = qdisc_dev(sch); |
13436 | struct tc_mqprio_qopt *mqprio = NULL; |
13437 | - u32 taprio_flags = 0; |
13438 | unsigned long flags; |
13439 | ktime_t start; |
13440 | int i, err; |
13441 | @@ -1388,21 +1416,14 @@ static int taprio_change(struct Qdisc *sch, struct nlattr *opt, |
13442 | if (tb[TCA_TAPRIO_ATTR_PRIOMAP]) |
13443 | mqprio = nla_data(tb[TCA_TAPRIO_ATTR_PRIOMAP]); |
13444 | |
13445 | - if (tb[TCA_TAPRIO_ATTR_FLAGS]) { |
13446 | - taprio_flags = nla_get_u32(tb[TCA_TAPRIO_ATTR_FLAGS]); |
13447 | - |
13448 | - if (q->flags != 0 && q->flags != taprio_flags) { |
13449 | - NL_SET_ERR_MSG_MOD(extack, "Changing 'flags' of a running schedule is not supported"); |
13450 | - return -EOPNOTSUPP; |
13451 | - } else if (!taprio_flags_valid(taprio_flags)) { |
13452 | - NL_SET_ERR_MSG_MOD(extack, "Specified 'flags' are not valid"); |
13453 | - return -EINVAL; |
13454 | - } |
13455 | + err = taprio_new_flags(tb[TCA_TAPRIO_ATTR_FLAGS], |
13456 | + q->flags, extack); |
13457 | + if (err < 0) |
13458 | + return err; |
13459 | |
13460 | - q->flags = taprio_flags; |
13461 | - } |
13462 | + q->flags = err; |
13463 | |
13464 | - err = taprio_parse_mqprio_opt(dev, mqprio, extack, taprio_flags); |
13465 | + err = taprio_parse_mqprio_opt(dev, mqprio, extack, q->flags); |
13466 | if (err < 0) |
13467 | return err; |
13468 | |
13469 | @@ -1444,7 +1465,20 @@ static int taprio_change(struct Qdisc *sch, struct nlattr *opt, |
13470 | |
13471 | taprio_set_picos_per_byte(dev, q); |
13472 | |
13473 | - if (FULL_OFFLOAD_IS_ENABLED(taprio_flags)) |
13474 | + if (mqprio) { |
13475 | + netdev_set_num_tc(dev, mqprio->num_tc); |
13476 | + for (i = 0; i < mqprio->num_tc; i++) |
13477 | + netdev_set_tc_queue(dev, i, |
13478 | + mqprio->count[i], |
13479 | + mqprio->offset[i]); |
13480 | + |
13481 | + /* Always use supplied priority mappings */ |
13482 | + for (i = 0; i <= TC_BITMASK; i++) |
13483 | + netdev_set_prio_tc_map(dev, i, |
13484 | + mqprio->prio_tc_map[i]); |
13485 | + } |
13486 | + |
13487 | + if (FULL_OFFLOAD_IS_ENABLED(q->flags)) |
13488 | err = taprio_enable_offload(dev, mqprio, q, new_admin, extack); |
13489 | else |
13490 | err = taprio_disable_offload(dev, q, extack); |
13491 | @@ -1464,27 +1498,14 @@ static int taprio_change(struct Qdisc *sch, struct nlattr *opt, |
13492 | q->txtime_delay = nla_get_u32(tb[TCA_TAPRIO_ATTR_TXTIME_DELAY]); |
13493 | } |
13494 | |
13495 | - if (!TXTIME_ASSIST_IS_ENABLED(taprio_flags) && |
13496 | - !FULL_OFFLOAD_IS_ENABLED(taprio_flags) && |
13497 | + if (!TXTIME_ASSIST_IS_ENABLED(q->flags) && |
13498 | + !FULL_OFFLOAD_IS_ENABLED(q->flags) && |
13499 | !hrtimer_active(&q->advance_timer)) { |
13500 | hrtimer_init(&q->advance_timer, q->clockid, HRTIMER_MODE_ABS); |
13501 | q->advance_timer.function = advance_sched; |
13502 | } |
13503 | |
13504 | - if (mqprio) { |
13505 | - netdev_set_num_tc(dev, mqprio->num_tc); |
13506 | - for (i = 0; i < mqprio->num_tc; i++) |
13507 | - netdev_set_tc_queue(dev, i, |
13508 | - mqprio->count[i], |
13509 | - mqprio->offset[i]); |
13510 | - |
13511 | - /* Always use supplied priority mappings */ |
13512 | - for (i = 0; i <= TC_BITMASK; i++) |
13513 | - netdev_set_prio_tc_map(dev, i, |
13514 | - mqprio->prio_tc_map[i]); |
13515 | - } |
13516 | - |
13517 | - if (FULL_OFFLOAD_IS_ENABLED(taprio_flags)) { |
13518 | + if (FULL_OFFLOAD_IS_ENABLED(q->flags)) { |
13519 | q->dequeue = taprio_dequeue_offload; |
13520 | q->peek = taprio_peek_offload; |
13521 | } else { |
13522 | @@ -1501,9 +1522,9 @@ static int taprio_change(struct Qdisc *sch, struct nlattr *opt, |
13523 | goto unlock; |
13524 | } |
13525 | |
13526 | - if (TXTIME_ASSIST_IS_ENABLED(taprio_flags)) { |
13527 | - setup_txtime(q, new_admin, start); |
13528 | + setup_txtime(q, new_admin, start); |
13529 | |
13530 | + if (TXTIME_ASSIST_IS_ENABLED(q->flags)) { |
13531 | if (!oper) { |
13532 | rcu_assign_pointer(q->oper_sched, new_admin); |
13533 | err = 0; |
13534 | @@ -1528,7 +1549,7 @@ static int taprio_change(struct Qdisc *sch, struct nlattr *opt, |
13535 | |
13536 | spin_unlock_irqrestore(&q->current_entry_lock, flags); |
13537 | |
13538 | - if (FULL_OFFLOAD_IS_ENABLED(taprio_flags)) |
13539 | + if (FULL_OFFLOAD_IS_ENABLED(q->flags)) |
13540 | taprio_offload_config_changed(q); |
13541 | } |
13542 | |
13543 | @@ -1567,7 +1588,7 @@ static void taprio_destroy(struct Qdisc *sch) |
13544 | } |
13545 | q->qdiscs = NULL; |
13546 | |
13547 | - netdev_set_num_tc(dev, 0); |
13548 | + netdev_reset_tc(dev); |
13549 | |
13550 | if (q->oper_sched) |
13551 | call_rcu(&q->oper_sched->rcu, taprio_free_sched_cb); |
13552 | @@ -1597,6 +1618,7 @@ static int taprio_init(struct Qdisc *sch, struct nlattr *opt, |
13553 | * and get the valid one on taprio_change(). |
13554 | */ |
13555 | q->clockid = -1; |
13556 | + q->flags = TAPRIO_FLAGS_INVALID; |
13557 | |
13558 | spin_lock(&taprio_list_lock); |
13559 | list_add(&q->taprio_list, &taprio_list); |
13560 | diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c |
13561 | index 908b60a72d95..ed20fa8a6f70 100644 |
13562 | --- a/net/sunrpc/auth_gss/svcauth_gss.c |
13563 | +++ b/net/sunrpc/auth_gss/svcauth_gss.c |
13564 | @@ -1245,6 +1245,7 @@ static int gss_proxy_save_rsc(struct cache_detail *cd, |
13565 | dprintk("RPC: No creds found!\n"); |
13566 | goto out; |
13567 | } else { |
13568 | + struct timespec64 boot; |
13569 | |
13570 | /* steal creds */ |
13571 | rsci.cred = ud->creds; |
13572 | @@ -1265,6 +1266,9 @@ static int gss_proxy_save_rsc(struct cache_detail *cd, |
13573 | &expiry, GFP_KERNEL); |
13574 | if (status) |
13575 | goto out; |
13576 | + |
13577 | + getboottime64(&boot); |
13578 | + expiry -= boot.tv_sec; |
13579 | } |
13580 | |
13581 | rsci.h.expiry_time = expiry; |
13582 | diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile |
13583 | index 42b571cde177..e7ad48c605e0 100644 |
13584 | --- a/samples/bpf/Makefile |
13585 | +++ b/samples/bpf/Makefile |
13586 | @@ -236,7 +236,7 @@ all: |
13587 | |
13588 | clean: |
13589 | $(MAKE) -C ../../ M=$(CURDIR) clean |
13590 | - @rm -f *~ |
13591 | + @find $(CURDIR) -type f -name '*~' -delete |
13592 | |
13593 | $(LIBBPF): FORCE |
13594 | # Fix up variables inherited from Kbuild that tools/ build system won't like |
13595 | diff --git a/samples/bpf/xdp_redirect_cpu_user.c b/samples/bpf/xdp_redirect_cpu_user.c |
13596 | index 0da6e9e7132e..8b862a7a6c6a 100644 |
13597 | --- a/samples/bpf/xdp_redirect_cpu_user.c |
13598 | +++ b/samples/bpf/xdp_redirect_cpu_user.c |
13599 | @@ -16,6 +16,10 @@ static const char *__doc__ = |
13600 | #include <getopt.h> |
13601 | #include <net/if.h> |
13602 | #include <time.h> |
13603 | +#include <linux/limits.h> |
13604 | + |
13605 | +#define __must_check |
13606 | +#include <linux/err.h> |
13607 | |
13608 | #include <arpa/inet.h> |
13609 | #include <linux/if_link.h> |
13610 | @@ -46,6 +50,10 @@ static int cpus_count_map_fd; |
13611 | static int cpus_iterator_map_fd; |
13612 | static int exception_cnt_map_fd; |
13613 | |
13614 | +#define NUM_TP 5 |
13615 | +struct bpf_link *tp_links[NUM_TP] = { 0 }; |
13616 | +static int tp_cnt = 0; |
13617 | + |
13618 | /* Exit return codes */ |
13619 | #define EXIT_OK 0 |
13620 | #define EXIT_FAIL 1 |
13621 | @@ -88,6 +96,10 @@ static void int_exit(int sig) |
13622 | printf("program on interface changed, not removing\n"); |
13623 | } |
13624 | } |
13625 | + /* Detach tracepoints */ |
13626 | + while (tp_cnt) |
13627 | + bpf_link__destroy(tp_links[--tp_cnt]); |
13628 | + |
13629 | exit(EXIT_OK); |
13630 | } |
13631 | |
13632 | @@ -588,23 +600,61 @@ static void stats_poll(int interval, bool use_separators, char *prog_name, |
13633 | free_stats_record(prev); |
13634 | } |
13635 | |
13636 | +static struct bpf_link * attach_tp(struct bpf_object *obj, |
13637 | + const char *tp_category, |
13638 | + const char* tp_name) |
13639 | +{ |
13640 | + struct bpf_program *prog; |
13641 | + struct bpf_link *link; |
13642 | + char sec_name[PATH_MAX]; |
13643 | + int len; |
13644 | + |
13645 | + len = snprintf(sec_name, PATH_MAX, "tracepoint/%s/%s", |
13646 | + tp_category, tp_name); |
13647 | + if (len < 0) |
13648 | + exit(EXIT_FAIL); |
13649 | + |
13650 | + prog = bpf_object__find_program_by_title(obj, sec_name); |
13651 | + if (!prog) { |
13652 | + fprintf(stderr, "ERR: finding progsec: %s\n", sec_name); |
13653 | + exit(EXIT_FAIL_BPF); |
13654 | + } |
13655 | + |
13656 | + link = bpf_program__attach_tracepoint(prog, tp_category, tp_name); |
13657 | + if (IS_ERR(link)) |
13658 | + exit(EXIT_FAIL_BPF); |
13659 | + |
13660 | + return link; |
13661 | +} |
13662 | + |
13663 | +static void init_tracepoints(struct bpf_object *obj) { |
13664 | + tp_links[tp_cnt++] = attach_tp(obj, "xdp", "xdp_redirect_err"); |
13665 | + tp_links[tp_cnt++] = attach_tp(obj, "xdp", "xdp_redirect_map_err"); |
13666 | + tp_links[tp_cnt++] = attach_tp(obj, "xdp", "xdp_exception"); |
13667 | + tp_links[tp_cnt++] = attach_tp(obj, "xdp", "xdp_cpumap_enqueue"); |
13668 | + tp_links[tp_cnt++] = attach_tp(obj, "xdp", "xdp_cpumap_kthread"); |
13669 | +} |
13670 | + |
13671 | static int init_map_fds(struct bpf_object *obj) |
13672 | { |
13673 | - cpu_map_fd = bpf_object__find_map_fd_by_name(obj, "cpu_map"); |
13674 | - rx_cnt_map_fd = bpf_object__find_map_fd_by_name(obj, "rx_cnt"); |
13675 | + /* Maps updated by tracepoints */ |
13676 | redirect_err_cnt_map_fd = |
13677 | bpf_object__find_map_fd_by_name(obj, "redirect_err_cnt"); |
13678 | + exception_cnt_map_fd = |
13679 | + bpf_object__find_map_fd_by_name(obj, "exception_cnt"); |
13680 | cpumap_enqueue_cnt_map_fd = |
13681 | bpf_object__find_map_fd_by_name(obj, "cpumap_enqueue_cnt"); |
13682 | cpumap_kthread_cnt_map_fd = |
13683 | bpf_object__find_map_fd_by_name(obj, "cpumap_kthread_cnt"); |
13684 | + |
13685 | + /* Maps used by XDP */ |
13686 | + rx_cnt_map_fd = bpf_object__find_map_fd_by_name(obj, "rx_cnt"); |
13687 | + cpu_map_fd = bpf_object__find_map_fd_by_name(obj, "cpu_map"); |
13688 | cpus_available_map_fd = |
13689 | bpf_object__find_map_fd_by_name(obj, "cpus_available"); |
13690 | cpus_count_map_fd = bpf_object__find_map_fd_by_name(obj, "cpus_count"); |
13691 | cpus_iterator_map_fd = |
13692 | bpf_object__find_map_fd_by_name(obj, "cpus_iterator"); |
13693 | - exception_cnt_map_fd = |
13694 | - bpf_object__find_map_fd_by_name(obj, "exception_cnt"); |
13695 | |
13696 | if (cpu_map_fd < 0 || rx_cnt_map_fd < 0 || |
13697 | redirect_err_cnt_map_fd < 0 || cpumap_enqueue_cnt_map_fd < 0 || |
13698 | @@ -662,6 +712,7 @@ int main(int argc, char **argv) |
13699 | strerror(errno)); |
13700 | return EXIT_FAIL; |
13701 | } |
13702 | + init_tracepoints(obj); |
13703 | if (init_map_fds(obj) < 0) { |
13704 | fprintf(stderr, "bpf_object__find_map_fd_by_name failed\n"); |
13705 | return EXIT_FAIL; |
13706 | diff --git a/scripts/find-unused-docs.sh b/scripts/find-unused-docs.sh |
13707 | index 3f46f8977dc4..ee6a50e33aba 100755 |
13708 | --- a/scripts/find-unused-docs.sh |
13709 | +++ b/scripts/find-unused-docs.sh |
13710 | @@ -54,7 +54,7 @@ for file in `find $1 -name '*.c'`; do |
13711 | if [[ ${FILES_INCLUDED[$file]+_} ]]; then |
13712 | continue; |
13713 | fi |
13714 | - str=$(scripts/kernel-doc -text -export "$file" 2>/dev/null) |
13715 | + str=$(scripts/kernel-doc -export "$file" 2>/dev/null) |
13716 | if [[ -n "$str" ]]; then |
13717 | echo "$file" |
13718 | fi |
13719 | diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c |
13720 | index abeb09c30633..ad22066eba04 100644 |
13721 | --- a/security/smack/smack_lsm.c |
13722 | +++ b/security/smack/smack_lsm.c |
13723 | @@ -2832,42 +2832,39 @@ static int smack_socket_connect(struct socket *sock, struct sockaddr *sap, |
13724 | int addrlen) |
13725 | { |
13726 | int rc = 0; |
13727 | -#if IS_ENABLED(CONFIG_IPV6) |
13728 | - struct sockaddr_in6 *sip = (struct sockaddr_in6 *)sap; |
13729 | -#endif |
13730 | -#ifdef SMACK_IPV6_SECMARK_LABELING |
13731 | - struct smack_known *rsp; |
13732 | - struct socket_smack *ssp; |
13733 | -#endif |
13734 | |
13735 | if (sock->sk == NULL) |
13736 | return 0; |
13737 | - |
13738 | + if (sock->sk->sk_family != PF_INET && |
13739 | + (!IS_ENABLED(CONFIG_IPV6) || sock->sk->sk_family != PF_INET6)) |
13740 | + return 0; |
13741 | + if (addrlen < offsetofend(struct sockaddr, sa_family)) |
13742 | + return 0; |
13743 | + if (IS_ENABLED(CONFIG_IPV6) && sap->sa_family == AF_INET6) { |
13744 | + struct sockaddr_in6 *sip = (struct sockaddr_in6 *)sap; |
13745 | #ifdef SMACK_IPV6_SECMARK_LABELING |
13746 | - ssp = sock->sk->sk_security; |
13747 | + struct smack_known *rsp; |
13748 | #endif |
13749 | |
13750 | - switch (sock->sk->sk_family) { |
13751 | - case PF_INET: |
13752 | - if (addrlen < sizeof(struct sockaddr_in) || |
13753 | - sap->sa_family != AF_INET) |
13754 | - return -EINVAL; |
13755 | - rc = smack_netlabel_send(sock->sk, (struct sockaddr_in *)sap); |
13756 | - break; |
13757 | - case PF_INET6: |
13758 | - if (addrlen < SIN6_LEN_RFC2133 || sap->sa_family != AF_INET6) |
13759 | - return -EINVAL; |
13760 | + if (addrlen < SIN6_LEN_RFC2133) |
13761 | + return 0; |
13762 | #ifdef SMACK_IPV6_SECMARK_LABELING |
13763 | rsp = smack_ipv6host_label(sip); |
13764 | - if (rsp != NULL) |
13765 | + if (rsp != NULL) { |
13766 | + struct socket_smack *ssp = sock->sk->sk_security; |
13767 | + |
13768 | rc = smk_ipv6_check(ssp->smk_out, rsp, sip, |
13769 | - SMK_CONNECTING); |
13770 | + SMK_CONNECTING); |
13771 | + } |
13772 | #endif |
13773 | #ifdef SMACK_IPV6_PORT_LABELING |
13774 | rc = smk_ipv6_port_check(sock->sk, sip, SMK_CONNECTING); |
13775 | #endif |
13776 | - break; |
13777 | + return rc; |
13778 | } |
13779 | + if (sap->sa_family != AF_INET || addrlen < sizeof(struct sockaddr_in)) |
13780 | + return 0; |
13781 | + rc = smack_netlabel_send(sock->sk, (struct sockaddr_in *)sap); |
13782 | return rc; |
13783 | } |
13784 | |
13785 | diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c |
13786 | index aee7c04d49e5..b61ba0321a72 100644 |
13787 | --- a/sound/drivers/dummy.c |
13788 | +++ b/sound/drivers/dummy.c |
13789 | @@ -915,7 +915,7 @@ static void print_formats(struct snd_dummy *dummy, |
13790 | { |
13791 | int i; |
13792 | |
13793 | - for (i = 0; i < SNDRV_PCM_FORMAT_LAST; i++) { |
13794 | + for (i = 0; i <= SNDRV_PCM_FORMAT_LAST; i++) { |
13795 | if (dummy->pcm_hw.formats & (1ULL << i)) |
13796 | snd_iprintf(buffer, " %s", snd_pcm_format_name(i)); |
13797 | } |
13798 | diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c |
13799 | index f6cbb831b86a..85beb172d810 100644 |
13800 | --- a/sound/pci/hda/hda_intel.c |
13801 | +++ b/sound/pci/hda/hda_intel.c |
13802 | @@ -2156,6 +2156,8 @@ static struct snd_pci_quirk power_save_blacklist[] = { |
13803 | /* https://bugzilla.redhat.com/show_bug.cgi?id=1581607 */ |
13804 | SND_PCI_QUIRK(0x1558, 0x3501, "Clevo W35xSS_370SS", 0), |
13805 | /* https://bugzilla.redhat.com/show_bug.cgi?id=1525104 */ |
13806 | + SND_PCI_QUIRK(0x1558, 0x6504, "Clevo W65_67SB", 0), |
13807 | + /* https://bugzilla.redhat.com/show_bug.cgi?id=1525104 */ |
13808 | SND_PCI_QUIRK(0x1028, 0x0497, "Dell Precision T3600", 0), |
13809 | /* https://bugzilla.redhat.com/show_bug.cgi?id=1525104 */ |
13810 | /* Note the P55A-UD3 and Z87-D3HP share the subsys id for the HDA dev */ |
13811 | @@ -2415,6 +2417,8 @@ static const struct pci_device_id azx_ids[] = { |
13812 | /* Jasperlake */ |
13813 | { PCI_DEVICE(0x8086, 0x38c8), |
13814 | .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_SKYLAKE}, |
13815 | + { PCI_DEVICE(0x8086, 0x4dc8), |
13816 | + .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_SKYLAKE}, |
13817 | /* Tigerlake */ |
13818 | { PCI_DEVICE(0x8086, 0xa0c8), |
13819 | .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_SKYLAKE}, |
13820 | diff --git a/sound/pci/hda/hda_tegra.c b/sound/pci/hda/hda_tegra.c |
13821 | index 8350954b7986..e5191584638a 100644 |
13822 | --- a/sound/pci/hda/hda_tegra.c |
13823 | +++ b/sound/pci/hda/hda_tegra.c |
13824 | @@ -398,6 +398,7 @@ static int hda_tegra_create(struct snd_card *card, |
13825 | return err; |
13826 | |
13827 | chip->bus.needs_damn_long_delay = 1; |
13828 | + chip->bus.core.aligned_mmio = 1; |
13829 | |
13830 | err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); |
13831 | if (err < 0) { |
13832 | diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c |
13833 | index 488c17c9f375..8ac805a634f4 100644 |
13834 | --- a/sound/pci/hda/patch_hdmi.c |
13835 | +++ b/sound/pci/hda/patch_hdmi.c |
13836 | @@ -4153,6 +4153,7 @@ HDA_CODEC_ENTRY(0x8086280c, "Cannonlake HDMI", patch_i915_glk_hdmi), |
13837 | HDA_CODEC_ENTRY(0x8086280d, "Geminilake HDMI", patch_i915_glk_hdmi), |
13838 | HDA_CODEC_ENTRY(0x8086280f, "Icelake HDMI", patch_i915_icl_hdmi), |
13839 | HDA_CODEC_ENTRY(0x80862812, "Tigerlake HDMI", patch_i915_tgl_hdmi), |
13840 | +HDA_CODEC_ENTRY(0x8086281a, "Jasperlake HDMI", patch_i915_icl_hdmi), |
13841 | HDA_CODEC_ENTRY(0x80862880, "CedarTrail HDMI", patch_generic_hdmi), |
13842 | HDA_CODEC_ENTRY(0x80862882, "Valleyview2 HDMI", patch_i915_byt_hdmi), |
13843 | HDA_CODEC_ENTRY(0x80862883, "Braswell HDMI", patch_i915_byt_hdmi), |
13844 | diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c |
13845 | index aa1f9637d895..e949b372cead 100644 |
13846 | --- a/sound/soc/codecs/sgtl5000.c |
13847 | +++ b/sound/soc/codecs/sgtl5000.c |
13848 | @@ -1344,7 +1344,8 @@ static int sgtl5000_set_power_regs(struct snd_soc_component *component) |
13849 | * if vddio == vdda the source of charge pump should be |
13850 | * assigned manually to VDDIO |
13851 | */ |
13852 | - if (vddio == vdda) { |
13853 | + if (regulator_is_equal(sgtl5000->supplies[VDDA].consumer, |
13854 | + sgtl5000->supplies[VDDIO].consumer)) { |
13855 | lreg_ctrl |= SGTL5000_VDDC_ASSN_OVRD; |
13856 | lreg_ctrl |= SGTL5000_VDDC_MAN_ASSN_VDDIO << |
13857 | SGTL5000_VDDC_MAN_ASSN_SHIFT; |
13858 | diff --git a/sound/soc/intel/boards/skl_hda_dsp_common.c b/sound/soc/intel/boards/skl_hda_dsp_common.c |
13859 | index 58409b6e476e..e3d405e57c5f 100644 |
13860 | --- a/sound/soc/intel/boards/skl_hda_dsp_common.c |
13861 | +++ b/sound/soc/intel/boards/skl_hda_dsp_common.c |
13862 | @@ -38,16 +38,19 @@ int skl_hda_hdmi_add_pcm(struct snd_soc_card *card, int device) |
13863 | return 0; |
13864 | } |
13865 | |
13866 | -SND_SOC_DAILINK_DEFS(idisp1, |
13867 | - DAILINK_COMP_ARRAY(COMP_CPU("iDisp1 Pin")), |
13868 | +SND_SOC_DAILINK_DEF(idisp1_cpu, |
13869 | + DAILINK_COMP_ARRAY(COMP_CPU("iDisp1 Pin"))); |
13870 | +SND_SOC_DAILINK_DEF(idisp1_codec, |
13871 | DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi1"))); |
13872 | |
13873 | -SND_SOC_DAILINK_DEFS(idisp2, |
13874 | - DAILINK_COMP_ARRAY(COMP_CPU("iDisp2 Pin")), |
13875 | +SND_SOC_DAILINK_DEF(idisp2_cpu, |
13876 | + DAILINK_COMP_ARRAY(COMP_CPU("iDisp2 Pin"))); |
13877 | +SND_SOC_DAILINK_DEF(idisp2_codec, |
13878 | DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi2"))); |
13879 | |
13880 | -SND_SOC_DAILINK_DEFS(idisp3, |
13881 | - DAILINK_COMP_ARRAY(COMP_CPU("iDisp3 Pin")), |
13882 | +SND_SOC_DAILINK_DEF(idisp3_cpu, |
13883 | + DAILINK_COMP_ARRAY(COMP_CPU("iDisp3 Pin"))); |
13884 | +SND_SOC_DAILINK_DEF(idisp3_codec, |
13885 | DAILINK_COMP_ARRAY(COMP_CODEC("ehdaudio0D2", "intel-hdmi-hifi3"))); |
13886 | |
13887 | SND_SOC_DAILINK_DEF(analog_cpu, |
13888 | @@ -80,21 +83,21 @@ struct snd_soc_dai_link skl_hda_be_dai_links[HDA_DSP_MAX_BE_DAI_LINKS] = { |
13889 | .id = 1, |
13890 | .dpcm_playback = 1, |
13891 | .no_pcm = 1, |
13892 | - SND_SOC_DAILINK_REG(idisp1), |
13893 | + SND_SOC_DAILINK_REG(idisp1_cpu, idisp1_codec, platform), |
13894 | }, |
13895 | { |
13896 | .name = "iDisp2", |
13897 | .id = 2, |
13898 | .dpcm_playback = 1, |
13899 | .no_pcm = 1, |
13900 | - SND_SOC_DAILINK_REG(idisp2), |
13901 | + SND_SOC_DAILINK_REG(idisp2_cpu, idisp2_codec, platform), |
13902 | }, |
13903 | { |
13904 | .name = "iDisp3", |
13905 | .id = 3, |
13906 | .dpcm_playback = 1, |
13907 | .no_pcm = 1, |
13908 | - SND_SOC_DAILINK_REG(idisp3), |
13909 | + SND_SOC_DAILINK_REG(idisp3_cpu, idisp3_codec, platform), |
13910 | }, |
13911 | { |
13912 | .name = "Analog Playback and Capture", |
13913 | diff --git a/sound/soc/meson/axg-fifo.c b/sound/soc/meson/axg-fifo.c |
13914 | index 5a3749938900..d286dff3171d 100644 |
13915 | --- a/sound/soc/meson/axg-fifo.c |
13916 | +++ b/sound/soc/meson/axg-fifo.c |
13917 | @@ -108,10 +108,12 @@ static int axg_fifo_pcm_hw_params(struct snd_pcm_substream *ss, |
13918 | { |
13919 | struct snd_pcm_runtime *runtime = ss->runtime; |
13920 | struct axg_fifo *fifo = axg_fifo_data(ss); |
13921 | + unsigned int burst_num, period, threshold; |
13922 | dma_addr_t end_ptr; |
13923 | - unsigned int burst_num; |
13924 | int ret; |
13925 | |
13926 | + period = params_period_bytes(params); |
13927 | + |
13928 | ret = snd_pcm_lib_malloc_pages(ss, params_buffer_bytes(params)); |
13929 | if (ret < 0) |
13930 | return ret; |
13931 | @@ -122,9 +124,25 @@ static int axg_fifo_pcm_hw_params(struct snd_pcm_substream *ss, |
13932 | regmap_write(fifo->map, FIFO_FINISH_ADDR, end_ptr); |
13933 | |
13934 | /* Setup interrupt periodicity */ |
13935 | - burst_num = params_period_bytes(params) / AXG_FIFO_BURST; |
13936 | + burst_num = period / AXG_FIFO_BURST; |
13937 | regmap_write(fifo->map, FIFO_INT_ADDR, burst_num); |
13938 | |
13939 | + /* |
13940 | + * Start the fifo request on the smallest of the following: |
13941 | + * - Half the fifo size |
13942 | + * - Half the period size |
13943 | + */ |
13944 | + threshold = min(period / 2, |
13945 | + (unsigned int)AXG_FIFO_MIN_DEPTH / 2); |
13946 | + |
13947 | + /* |
13948 | + * With the threshold in bytes, register value is: |
13949 | + * V = (threshold / burst) - 1 |
13950 | + */ |
13951 | + threshold /= AXG_FIFO_BURST; |
13952 | + regmap_field_write(fifo->field_threshold, |
13953 | + threshold ? threshold - 1 : 0); |
13954 | + |
13955 | /* Enable block count irq */ |
13956 | regmap_update_bits(fifo->map, FIFO_CTRL0, |
13957 | CTRL0_INT_EN(FIFO_INT_COUNT_REPEAT), |
13958 | @@ -360,6 +378,11 @@ int axg_fifo_probe(struct platform_device *pdev) |
13959 | return fifo->irq; |
13960 | } |
13961 | |
13962 | + fifo->field_threshold = |
13963 | + devm_regmap_field_alloc(dev, fifo->map, data->field_threshold); |
13964 | + if (IS_ERR(fifo->field_threshold)) |
13965 | + return PTR_ERR(fifo->field_threshold); |
13966 | + |
13967 | return devm_snd_soc_register_component(dev, data->component_drv, |
13968 | data->dai_drv, 1); |
13969 | } |
13970 | diff --git a/sound/soc/meson/axg-fifo.h b/sound/soc/meson/axg-fifo.h |
13971 | index bb1e2ce50256..ab546a3cf940 100644 |
13972 | --- a/sound/soc/meson/axg-fifo.h |
13973 | +++ b/sound/soc/meson/axg-fifo.h |
13974 | @@ -9,7 +9,9 @@ |
13975 | |
13976 | struct clk; |
13977 | struct platform_device; |
13978 | +struct reg_field; |
13979 | struct regmap; |
13980 | +struct regmap_field; |
13981 | struct reset_control; |
13982 | |
13983 | struct snd_soc_component_driver; |
13984 | @@ -50,8 +52,6 @@ struct snd_soc_pcm_runtime; |
13985 | #define CTRL1_STATUS2_SEL_MASK GENMASK(11, 8) |
13986 | #define CTRL1_STATUS2_SEL(x) ((x) << 8) |
13987 | #define STATUS2_SEL_DDR_READ 0 |
13988 | -#define CTRL1_THRESHOLD_MASK GENMASK(23, 16) |
13989 | -#define CTRL1_THRESHOLD(x) ((x) << 16) |
13990 | #define CTRL1_FRDDR_DEPTH_MASK GENMASK(31, 24) |
13991 | #define CTRL1_FRDDR_DEPTH(x) ((x) << 24) |
13992 | #define FIFO_START_ADDR 0x08 |
13993 | @@ -67,12 +67,14 @@ struct axg_fifo { |
13994 | struct regmap *map; |
13995 | struct clk *pclk; |
13996 | struct reset_control *arb; |
13997 | + struct regmap_field *field_threshold; |
13998 | int irq; |
13999 | }; |
14000 | |
14001 | struct axg_fifo_match_data { |
14002 | const struct snd_soc_component_driver *component_drv; |
14003 | struct snd_soc_dai_driver *dai_drv; |
14004 | + struct reg_field field_threshold; |
14005 | }; |
14006 | |
14007 | extern const struct snd_pcm_ops axg_fifo_pcm_ops; |
14008 | diff --git a/sound/soc/meson/axg-frddr.c b/sound/soc/meson/axg-frddr.c |
14009 | index 6ab111c31b28..09773a9ae964 100644 |
14010 | --- a/sound/soc/meson/axg-frddr.c |
14011 | +++ b/sound/soc/meson/axg-frddr.c |
14012 | @@ -50,7 +50,7 @@ static int axg_frddr_dai_startup(struct snd_pcm_substream *substream, |
14013 | struct snd_soc_dai *dai) |
14014 | { |
14015 | struct axg_fifo *fifo = snd_soc_dai_get_drvdata(dai); |
14016 | - unsigned int fifo_depth, fifo_threshold; |
14017 | + unsigned int fifo_depth; |
14018 | int ret; |
14019 | |
14020 | /* Enable pclk to access registers and clock the fifo ip */ |
14021 | @@ -68,11 +68,8 @@ static int axg_frddr_dai_startup(struct snd_pcm_substream *substream, |
14022 | * Depth and threshold are zero based. |
14023 | */ |
14024 | fifo_depth = AXG_FIFO_MIN_CNT - 1; |
14025 | - fifo_threshold = (AXG_FIFO_MIN_CNT / 2) - 1; |
14026 | - regmap_update_bits(fifo->map, FIFO_CTRL1, |
14027 | - CTRL1_FRDDR_DEPTH_MASK | CTRL1_THRESHOLD_MASK, |
14028 | - CTRL1_FRDDR_DEPTH(fifo_depth) | |
14029 | - CTRL1_THRESHOLD(fifo_threshold)); |
14030 | + regmap_update_bits(fifo->map, FIFO_CTRL1, CTRL1_FRDDR_DEPTH_MASK, |
14031 | + CTRL1_FRDDR_DEPTH(fifo_depth)); |
14032 | |
14033 | return 0; |
14034 | } |
14035 | @@ -153,8 +150,9 @@ static const struct snd_soc_component_driver axg_frddr_component_drv = { |
14036 | }; |
14037 | |
14038 | static const struct axg_fifo_match_data axg_frddr_match_data = { |
14039 | - .component_drv = &axg_frddr_component_drv, |
14040 | - .dai_drv = &axg_frddr_dai_drv |
14041 | + .field_threshold = REG_FIELD(FIFO_CTRL1, 16, 23), |
14042 | + .component_drv = &axg_frddr_component_drv, |
14043 | + .dai_drv = &axg_frddr_dai_drv |
14044 | }; |
14045 | |
14046 | static const struct snd_soc_dai_ops g12a_frddr_ops = { |
14047 | @@ -271,8 +269,9 @@ static const struct snd_soc_component_driver g12a_frddr_component_drv = { |
14048 | }; |
14049 | |
14050 | static const struct axg_fifo_match_data g12a_frddr_match_data = { |
14051 | - .component_drv = &g12a_frddr_component_drv, |
14052 | - .dai_drv = &g12a_frddr_dai_drv |
14053 | + .field_threshold = REG_FIELD(FIFO_CTRL1, 16, 23), |
14054 | + .component_drv = &g12a_frddr_component_drv, |
14055 | + .dai_drv = &g12a_frddr_dai_drv |
14056 | }; |
14057 | |
14058 | /* On SM1, the output selection in on CTRL2 */ |
14059 | @@ -335,8 +334,9 @@ static const struct snd_soc_component_driver sm1_frddr_component_drv = { |
14060 | }; |
14061 | |
14062 | static const struct axg_fifo_match_data sm1_frddr_match_data = { |
14063 | - .component_drv = &sm1_frddr_component_drv, |
14064 | - .dai_drv = &g12a_frddr_dai_drv |
14065 | + .field_threshold = REG_FIELD(FIFO_CTRL1, 16, 23), |
14066 | + .component_drv = &sm1_frddr_component_drv, |
14067 | + .dai_drv = &g12a_frddr_dai_drv |
14068 | }; |
14069 | |
14070 | static const struct of_device_id axg_frddr_of_match[] = { |
14071 | diff --git a/sound/soc/meson/axg-toddr.c b/sound/soc/meson/axg-toddr.c |
14072 | index c8ea2145f576..ecf41c7549a6 100644 |
14073 | --- a/sound/soc/meson/axg-toddr.c |
14074 | +++ b/sound/soc/meson/axg-toddr.c |
14075 | @@ -89,7 +89,6 @@ static int axg_toddr_dai_startup(struct snd_pcm_substream *substream, |
14076 | struct snd_soc_dai *dai) |
14077 | { |
14078 | struct axg_fifo *fifo = snd_soc_dai_get_drvdata(dai); |
14079 | - unsigned int fifo_threshold; |
14080 | int ret; |
14081 | |
14082 | /* Enable pclk to access registers and clock the fifo ip */ |
14083 | @@ -107,11 +106,6 @@ static int axg_toddr_dai_startup(struct snd_pcm_substream *substream, |
14084 | /* Apply single buffer mode to the interface */ |
14085 | regmap_update_bits(fifo->map, FIFO_CTRL0, CTRL0_TODDR_PP_MODE, 0); |
14086 | |
14087 | - /* TODDR does not have a configurable fifo depth */ |
14088 | - fifo_threshold = AXG_FIFO_MIN_CNT - 1; |
14089 | - regmap_update_bits(fifo->map, FIFO_CTRL1, CTRL1_THRESHOLD_MASK, |
14090 | - CTRL1_THRESHOLD(fifo_threshold)); |
14091 | - |
14092 | return 0; |
14093 | } |
14094 | |
14095 | @@ -185,8 +179,9 @@ static const struct snd_soc_component_driver axg_toddr_component_drv = { |
14096 | }; |
14097 | |
14098 | static const struct axg_fifo_match_data axg_toddr_match_data = { |
14099 | - .component_drv = &axg_toddr_component_drv, |
14100 | - .dai_drv = &axg_toddr_dai_drv |
14101 | + .field_threshold = REG_FIELD(FIFO_CTRL1, 16, 23), |
14102 | + .component_drv = &axg_toddr_component_drv, |
14103 | + .dai_drv = &axg_toddr_dai_drv |
14104 | }; |
14105 | |
14106 | static const struct snd_soc_dai_ops g12a_toddr_ops = { |
14107 | @@ -218,8 +213,9 @@ static const struct snd_soc_component_driver g12a_toddr_component_drv = { |
14108 | }; |
14109 | |
14110 | static const struct axg_fifo_match_data g12a_toddr_match_data = { |
14111 | - .component_drv = &g12a_toddr_component_drv, |
14112 | - .dai_drv = &g12a_toddr_dai_drv |
14113 | + .field_threshold = REG_FIELD(FIFO_CTRL1, 16, 23), |
14114 | + .component_drv = &g12a_toddr_component_drv, |
14115 | + .dai_drv = &g12a_toddr_dai_drv |
14116 | }; |
14117 | |
14118 | static const char * const sm1_toddr_sel_texts[] = { |
14119 | @@ -282,8 +278,9 @@ static const struct snd_soc_component_driver sm1_toddr_component_drv = { |
14120 | }; |
14121 | |
14122 | static const struct axg_fifo_match_data sm1_toddr_match_data = { |
14123 | - .component_drv = &sm1_toddr_component_drv, |
14124 | - .dai_drv = &g12a_toddr_dai_drv |
14125 | + .field_threshold = REG_FIELD(FIFO_CTRL1, 12, 23), |
14126 | + .component_drv = &sm1_toddr_component_drv, |
14127 | + .dai_drv = &g12a_toddr_dai_drv |
14128 | }; |
14129 | |
14130 | static const struct of_device_id axg_toddr_of_match[] = { |
14131 | diff --git a/sound/soc/sof/core.c b/sound/soc/sof/core.c |
14132 | index 81f28f7ff1a0..12aec140819a 100644 |
14133 | --- a/sound/soc/sof/core.c |
14134 | +++ b/sound/soc/sof/core.c |
14135 | @@ -288,6 +288,46 @@ static int sof_machine_check(struct snd_sof_dev *sdev) |
14136 | #endif |
14137 | } |
14138 | |
14139 | +/* |
14140 | + * FW Boot State Transition Diagram |
14141 | + * |
14142 | + * +-----------------------------------------------------------------------+ |
14143 | + * | | |
14144 | + * ------------------ ------------------ | |
14145 | + * | | | | | |
14146 | + * | BOOT_FAILED | | READY_FAILED |-------------------------+ | |
14147 | + * | | | | | | |
14148 | + * ------------------ ------------------ | | |
14149 | + * ^ ^ | | |
14150 | + * | | | | |
14151 | + * (FW Boot Timeout) (FW_READY FAIL) | | |
14152 | + * | | | | |
14153 | + * | | | | |
14154 | + * ------------------ | ------------------ | | |
14155 | + * | | | | | | | |
14156 | + * | IN_PROGRESS |---------------+------------->| COMPLETE | | | |
14157 | + * | | (FW Boot OK) (FW_READY OK) | | | | |
14158 | + * ------------------ ------------------ | | |
14159 | + * ^ | | | |
14160 | + * | | | | |
14161 | + * (FW Loading OK) (System Suspend/Runtime Suspend) |
14162 | + * | | | | |
14163 | + * | | | | |
14164 | + * ------------------ ------------------ | | | |
14165 | + * | | | |<-----+ | | |
14166 | + * | PREPARE | | NOT_STARTED |<---------------------+ | |
14167 | + * | | | |<---------------------------+ |
14168 | + * ------------------ ------------------ |
14169 | + * | ^ | ^ |
14170 | + * | | | | |
14171 | + * | +-----------------------+ | |
14172 | + * | (DSP Probe OK) | |
14173 | + * | | |
14174 | + * | | |
14175 | + * +------------------------------------+ |
14176 | + * (System Suspend/Runtime Suspend) |
14177 | + */ |
14178 | + |
14179 | static int sof_probe_continue(struct snd_sof_dev *sdev) |
14180 | { |
14181 | struct snd_sof_pdata *plat_data = sdev->pdata; |
14182 | @@ -303,6 +343,8 @@ static int sof_probe_continue(struct snd_sof_dev *sdev) |
14183 | return ret; |
14184 | } |
14185 | |
14186 | + sdev->fw_state = SOF_FW_BOOT_PREPARE; |
14187 | + |
14188 | /* check machine info */ |
14189 | ret = sof_machine_check(sdev); |
14190 | if (ret < 0) { |
14191 | @@ -342,7 +384,12 @@ static int sof_probe_continue(struct snd_sof_dev *sdev) |
14192 | goto fw_load_err; |
14193 | } |
14194 | |
14195 | - /* boot the firmware */ |
14196 | + sdev->fw_state = SOF_FW_BOOT_IN_PROGRESS; |
14197 | + |
14198 | + /* |
14199 | + * Boot the firmware. The FW boot status will be modified |
14200 | + * in snd_sof_run_firmware() depending on the outcome. |
14201 | + */ |
14202 | ret = snd_sof_run_firmware(sdev); |
14203 | if (ret < 0) { |
14204 | dev_err(sdev->dev, "error: failed to boot DSP firmware %d\n", |
14205 | @@ -368,7 +415,7 @@ static int sof_probe_continue(struct snd_sof_dev *sdev) |
14206 | if (ret < 0) { |
14207 | dev_err(sdev->dev, |
14208 | "error: failed to register DSP DAI driver %d\n", ret); |
14209 | - goto fw_run_err; |
14210 | + goto fw_trace_err; |
14211 | } |
14212 | |
14213 | drv_name = plat_data->machine->drv_name; |
14214 | @@ -382,7 +429,7 @@ static int sof_probe_continue(struct snd_sof_dev *sdev) |
14215 | |
14216 | if (IS_ERR(plat_data->pdev_mach)) { |
14217 | ret = PTR_ERR(plat_data->pdev_mach); |
14218 | - goto fw_run_err; |
14219 | + goto fw_trace_err; |
14220 | } |
14221 | |
14222 | dev_dbg(sdev->dev, "created machine %s\n", |
14223 | @@ -393,7 +440,8 @@ static int sof_probe_continue(struct snd_sof_dev *sdev) |
14224 | |
14225 | return 0; |
14226 | |
14227 | -#if !IS_ENABLED(CONFIG_SND_SOC_SOF_PROBE_WORK_QUEUE) |
14228 | +fw_trace_err: |
14229 | + snd_sof_free_trace(sdev); |
14230 | fw_run_err: |
14231 | snd_sof_fw_unload(sdev); |
14232 | fw_load_err: |
14233 | @@ -402,21 +450,10 @@ ipc_err: |
14234 | snd_sof_free_debug(sdev); |
14235 | dbg_err: |
14236 | snd_sof_remove(sdev); |
14237 | -#else |
14238 | - |
14239 | - /* |
14240 | - * when the probe_continue is handled in a work queue, the |
14241 | - * probe does not fail so we don't release resources here. |
14242 | - * They will be released with an explicit call to |
14243 | - * snd_sof_device_remove() when the PCI/ACPI device is removed |
14244 | - */ |
14245 | |
14246 | -fw_run_err: |
14247 | -fw_load_err: |
14248 | -ipc_err: |
14249 | -dbg_err: |
14250 | - |
14251 | -#endif |
14252 | + /* all resources freed, update state to match */ |
14253 | + sdev->fw_state = SOF_FW_BOOT_NOT_STARTED; |
14254 | + sdev->first_boot = true; |
14255 | |
14256 | return ret; |
14257 | } |
14258 | @@ -447,6 +484,7 @@ int snd_sof_device_probe(struct device *dev, struct snd_sof_pdata *plat_data) |
14259 | |
14260 | sdev->pdata = plat_data; |
14261 | sdev->first_boot = true; |
14262 | + sdev->fw_state = SOF_FW_BOOT_NOT_STARTED; |
14263 | dev_set_drvdata(dev, sdev); |
14264 | |
14265 | /* check all mandatory ops */ |
14266 | @@ -494,10 +532,12 @@ int snd_sof_device_remove(struct device *dev) |
14267 | if (IS_ENABLED(CONFIG_SND_SOC_SOF_PROBE_WORK_QUEUE)) |
14268 | cancel_work_sync(&sdev->probe_work); |
14269 | |
14270 | - snd_sof_fw_unload(sdev); |
14271 | - snd_sof_ipc_free(sdev); |
14272 | - snd_sof_free_debug(sdev); |
14273 | - snd_sof_free_trace(sdev); |
14274 | + if (sdev->fw_state > SOF_FW_BOOT_NOT_STARTED) { |
14275 | + snd_sof_fw_unload(sdev); |
14276 | + snd_sof_ipc_free(sdev); |
14277 | + snd_sof_free_debug(sdev); |
14278 | + snd_sof_free_trace(sdev); |
14279 | + } |
14280 | |
14281 | /* |
14282 | * Unregister machine driver. This will unbind the snd_card which |
14283 | @@ -513,7 +553,8 @@ int snd_sof_device_remove(struct device *dev) |
14284 | * scheduled on, when they are unloaded. Therefore, the DSP must be |
14285 | * removed only after the topology has been unloaded. |
14286 | */ |
14287 | - snd_sof_remove(sdev); |
14288 | + if (sdev->fw_state > SOF_FW_BOOT_NOT_STARTED) |
14289 | + snd_sof_remove(sdev); |
14290 | |
14291 | /* release firmware */ |
14292 | release_firmware(pdata->fw); |
14293 | diff --git a/sound/soc/sof/intel/hda-loader.c b/sound/soc/sof/intel/hda-loader.c |
14294 | index 65c2af3fcaab..356bb134ae93 100644 |
14295 | --- a/sound/soc/sof/intel/hda-loader.c |
14296 | +++ b/sound/soc/sof/intel/hda-loader.c |
14297 | @@ -278,7 +278,6 @@ int hda_dsp_cl_boot_firmware(struct snd_sof_dev *sdev) |
14298 | |
14299 | /* init for booting wait */ |
14300 | init_waitqueue_head(&sdev->boot_wait); |
14301 | - sdev->boot_complete = false; |
14302 | |
14303 | /* prepare DMA for code loader stream */ |
14304 | tag = cl_stream_prepare(sdev, 0x40, stripped_firmware.size, |
14305 | diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c |
14306 | index 5a5163eef2ef..3c4b604412f0 100644 |
14307 | --- a/sound/soc/sof/intel/hda.c |
14308 | +++ b/sound/soc/sof/intel/hda.c |
14309 | @@ -166,7 +166,7 @@ void hda_dsp_dump_skl(struct snd_sof_dev *sdev, u32 flags) |
14310 | panic = snd_sof_dsp_read(sdev, HDA_DSP_BAR, |
14311 | HDA_ADSP_ERROR_CODE_SKL + 0x4); |
14312 | |
14313 | - if (sdev->boot_complete) { |
14314 | + if (sdev->fw_state == SOF_FW_BOOT_COMPLETE) { |
14315 | hda_dsp_get_registers(sdev, &xoops, &panic_info, stack, |
14316 | HDA_DSP_STACK_DUMP_SIZE); |
14317 | snd_sof_get_status(sdev, status, panic, &xoops, &panic_info, |
14318 | @@ -193,7 +193,7 @@ void hda_dsp_dump(struct snd_sof_dev *sdev, u32 flags) |
14319 | HDA_DSP_SRAM_REG_FW_STATUS); |
14320 | panic = snd_sof_dsp_read(sdev, HDA_DSP_BAR, HDA_DSP_SRAM_REG_FW_TRACEP); |
14321 | |
14322 | - if (sdev->boot_complete) { |
14323 | + if (sdev->fw_state == SOF_FW_BOOT_COMPLETE) { |
14324 | hda_dsp_get_registers(sdev, &xoops, &panic_info, stack, |
14325 | HDA_DSP_STACK_DUMP_SIZE); |
14326 | snd_sof_get_status(sdev, status, panic, &xoops, &panic_info, |
14327 | diff --git a/sound/soc/sof/ipc.c b/sound/soc/sof/ipc.c |
14328 | index 7b6d69783e16..8984d965037d 100644 |
14329 | --- a/sound/soc/sof/ipc.c |
14330 | +++ b/sound/soc/sof/ipc.c |
14331 | @@ -348,19 +348,12 @@ void snd_sof_ipc_msgs_rx(struct snd_sof_dev *sdev) |
14332 | break; |
14333 | case SOF_IPC_FW_READY: |
14334 | /* check for FW boot completion */ |
14335 | - if (!sdev->boot_complete) { |
14336 | + if (sdev->fw_state == SOF_FW_BOOT_IN_PROGRESS) { |
14337 | err = sof_ops(sdev)->fw_ready(sdev, cmd); |
14338 | - if (err < 0) { |
14339 | - /* |
14340 | - * this indicates a mismatch in ABI |
14341 | - * between the driver and fw |
14342 | - */ |
14343 | - dev_err(sdev->dev, "error: ABI mismatch %d\n", |
14344 | - err); |
14345 | - } else { |
14346 | - /* firmware boot completed OK */ |
14347 | - sdev->boot_complete = true; |
14348 | - } |
14349 | + if (err < 0) |
14350 | + sdev->fw_state = SOF_FW_BOOT_READY_FAILED; |
14351 | + else |
14352 | + sdev->fw_state = SOF_FW_BOOT_COMPLETE; |
14353 | |
14354 | /* wake up firmware loader */ |
14355 | wake_up(&sdev->boot_wait); |
14356 | diff --git a/sound/soc/sof/loader.c b/sound/soc/sof/loader.c |
14357 | index a041adf0669d..ce114df5e4fc 100644 |
14358 | --- a/sound/soc/sof/loader.c |
14359 | +++ b/sound/soc/sof/loader.c |
14360 | @@ -511,7 +511,6 @@ int snd_sof_run_firmware(struct snd_sof_dev *sdev) |
14361 | int init_core_mask; |
14362 | |
14363 | init_waitqueue_head(&sdev->boot_wait); |
14364 | - sdev->boot_complete = false; |
14365 | |
14366 | /* create read-only fw_version debugfs to store boot version info */ |
14367 | if (sdev->first_boot) { |
14368 | @@ -543,19 +542,27 @@ int snd_sof_run_firmware(struct snd_sof_dev *sdev) |
14369 | |
14370 | init_core_mask = ret; |
14371 | |
14372 | - /* now wait for the DSP to boot */ |
14373 | - ret = wait_event_timeout(sdev->boot_wait, sdev->boot_complete, |
14374 | + /* |
14375 | + * now wait for the DSP to boot. There are 3 possible outcomes: |
14376 | + * 1. Boot wait times out indicating FW boot failure. |
14377 | + * 2. FW boots successfully and fw_ready op succeeds. |
14378 | + * 3. FW boots but fw_ready op fails. |
14379 | + */ |
14380 | + ret = wait_event_timeout(sdev->boot_wait, |
14381 | + sdev->fw_state > SOF_FW_BOOT_IN_PROGRESS, |
14382 | msecs_to_jiffies(sdev->boot_timeout)); |
14383 | if (ret == 0) { |
14384 | dev_err(sdev->dev, "error: firmware boot failure\n"); |
14385 | snd_sof_dsp_dbg_dump(sdev, SOF_DBG_REGS | SOF_DBG_MBOX | |
14386 | SOF_DBG_TEXT | SOF_DBG_PCI); |
14387 | - /* after this point FW_READY msg should be ignored */ |
14388 | - sdev->boot_complete = true; |
14389 | + sdev->fw_state = SOF_FW_BOOT_FAILED; |
14390 | return -EIO; |
14391 | } |
14392 | |
14393 | - dev_info(sdev->dev, "firmware boot complete\n"); |
14394 | + if (sdev->fw_state == SOF_FW_BOOT_COMPLETE) |
14395 | + dev_info(sdev->dev, "firmware boot complete\n"); |
14396 | + else |
14397 | + return -EIO; /* FW boots but fw_ready op failed */ |
14398 | |
14399 | /* perform post fw run operations */ |
14400 | ret = snd_sof_dsp_post_fw_run(sdev); |
14401 | diff --git a/sound/soc/sof/pm.c b/sound/soc/sof/pm.c |
14402 | index e23beaeefe00..195af259e78e 100644 |
14403 | --- a/sound/soc/sof/pm.c |
14404 | +++ b/sound/soc/sof/pm.c |
14405 | @@ -269,6 +269,10 @@ static int sof_resume(struct device *dev, bool runtime_resume) |
14406 | if (!sof_ops(sdev)->resume || !sof_ops(sdev)->runtime_resume) |
14407 | return 0; |
14408 | |
14409 | + /* DSP was never successfully started, nothing to resume */ |
14410 | + if (sdev->first_boot) |
14411 | + return 0; |
14412 | + |
14413 | /* |
14414 | * if the runtime_resume flag is set, call the runtime_resume routine |
14415 | * or else call the system resume routine |
14416 | @@ -283,6 +287,8 @@ static int sof_resume(struct device *dev, bool runtime_resume) |
14417 | return ret; |
14418 | } |
14419 | |
14420 | + sdev->fw_state = SOF_FW_BOOT_PREPARE; |
14421 | + |
14422 | /* load the firmware */ |
14423 | ret = snd_sof_load_firmware(sdev); |
14424 | if (ret < 0) { |
14425 | @@ -292,7 +298,12 @@ static int sof_resume(struct device *dev, bool runtime_resume) |
14426 | return ret; |
14427 | } |
14428 | |
14429 | - /* boot the firmware */ |
14430 | + sdev->fw_state = SOF_FW_BOOT_IN_PROGRESS; |
14431 | + |
14432 | + /* |
14433 | + * Boot the firmware. The FW boot status will be modified |
14434 | + * in snd_sof_run_firmware() depending on the outcome. |
14435 | + */ |
14436 | ret = snd_sof_run_firmware(sdev); |
14437 | if (ret < 0) { |
14438 | dev_err(sdev->dev, |
14439 | @@ -338,6 +349,9 @@ static int sof_suspend(struct device *dev, bool runtime_suspend) |
14440 | if (!sof_ops(sdev)->suspend) |
14441 | return 0; |
14442 | |
14443 | + if (sdev->fw_state != SOF_FW_BOOT_COMPLETE) |
14444 | + goto power_down; |
14445 | + |
14446 | /* release trace */ |
14447 | snd_sof_release_trace(sdev); |
14448 | |
14449 | @@ -375,6 +389,12 @@ static int sof_suspend(struct device *dev, bool runtime_suspend) |
14450 | ret); |
14451 | } |
14452 | |
14453 | +power_down: |
14454 | + |
14455 | + /* return if the DSP was not probed successfully */ |
14456 | + if (sdev->fw_state == SOF_FW_BOOT_NOT_STARTED) |
14457 | + return 0; |
14458 | + |
14459 | /* power down all DSP cores */ |
14460 | if (runtime_suspend) |
14461 | ret = snd_sof_dsp_runtime_suspend(sdev); |
14462 | @@ -385,6 +405,9 @@ static int sof_suspend(struct device *dev, bool runtime_suspend) |
14463 | "error: failed to power down DSP during suspend %d\n", |
14464 | ret); |
14465 | |
14466 | + /* reset FW state */ |
14467 | + sdev->fw_state = SOF_FW_BOOT_NOT_STARTED; |
14468 | + |
14469 | return ret; |
14470 | } |
14471 | |
14472 | diff --git a/sound/soc/sof/sof-priv.h b/sound/soc/sof/sof-priv.h |
14473 | index 730f3259dd02..7b329bd99674 100644 |
14474 | --- a/sound/soc/sof/sof-priv.h |
14475 | +++ b/sound/soc/sof/sof-priv.h |
14476 | @@ -356,6 +356,15 @@ struct snd_sof_dai { |
14477 | struct list_head list; /* list in sdev dai list */ |
14478 | }; |
14479 | |
14480 | +enum snd_sof_fw_state { |
14481 | + SOF_FW_BOOT_NOT_STARTED = 0, |
14482 | + SOF_FW_BOOT_PREPARE, |
14483 | + SOF_FW_BOOT_IN_PROGRESS, |
14484 | + SOF_FW_BOOT_FAILED, |
14485 | + SOF_FW_BOOT_READY_FAILED, /* firmware booted but fw_ready op failed */ |
14486 | + SOF_FW_BOOT_COMPLETE, |
14487 | +}; |
14488 | + |
14489 | /* |
14490 | * SOF Device Level. |
14491 | */ |
14492 | @@ -372,7 +381,7 @@ struct snd_sof_dev { |
14493 | |
14494 | /* DSP firmware boot */ |
14495 | wait_queue_head_t boot_wait; |
14496 | - u32 boot_complete; |
14497 | + enum snd_sof_fw_state fw_state; |
14498 | u32 first_boot; |
14499 | |
14500 | /* work queue in case the probe is implemented in two steps */ |
14501 | diff --git a/sound/usb/mixer_scarlett_gen2.c b/sound/usb/mixer_scarlett_gen2.c |
14502 | index 94b903d95afa..74c00c905d24 100644 |
14503 | --- a/sound/usb/mixer_scarlett_gen2.c |
14504 | +++ b/sound/usb/mixer_scarlett_gen2.c |
14505 | @@ -558,11 +558,11 @@ static const struct scarlett2_config |
14506 | |
14507 | /* proprietary request/response format */ |
14508 | struct scarlett2_usb_packet { |
14509 | - u32 cmd; |
14510 | - u16 size; |
14511 | - u16 seq; |
14512 | - u32 error; |
14513 | - u32 pad; |
14514 | + __le32 cmd; |
14515 | + __le16 size; |
14516 | + __le16 seq; |
14517 | + __le32 error; |
14518 | + __le32 pad; |
14519 | u8 data[]; |
14520 | }; |
14521 | |
14522 | @@ -664,11 +664,11 @@ static int scarlett2_usb( |
14523 | "Scarlett Gen 2 USB invalid response; " |
14524 | "cmd tx/rx %d/%d seq %d/%d size %d/%d " |
14525 | "error %d pad %d\n", |
14526 | - le16_to_cpu(req->cmd), le16_to_cpu(resp->cmd), |
14527 | + le32_to_cpu(req->cmd), le32_to_cpu(resp->cmd), |
14528 | le16_to_cpu(req->seq), le16_to_cpu(resp->seq), |
14529 | resp_size, le16_to_cpu(resp->size), |
14530 | - le16_to_cpu(resp->error), |
14531 | - le16_to_cpu(resp->pad)); |
14532 | + le32_to_cpu(resp->error), |
14533 | + le32_to_cpu(resp->pad)); |
14534 | err = -EINVAL; |
14535 | goto unlock; |
14536 | } |
14537 | @@ -687,7 +687,7 @@ error: |
14538 | /* Send SCARLETT2_USB_DATA_CMD SCARLETT2_USB_CONFIG_SAVE */ |
14539 | static void scarlett2_config_save(struct usb_mixer_interface *mixer) |
14540 | { |
14541 | - u32 req = cpu_to_le32(SCARLETT2_USB_CONFIG_SAVE); |
14542 | + __le32 req = cpu_to_le32(SCARLETT2_USB_CONFIG_SAVE); |
14543 | |
14544 | scarlett2_usb(mixer, SCARLETT2_USB_DATA_CMD, |
14545 | &req, sizeof(u32), |
14546 | @@ -713,11 +713,11 @@ static int scarlett2_usb_set_config( |
14547 | const struct scarlett2_config config_item = |
14548 | scarlett2_config_items[config_item_num]; |
14549 | struct { |
14550 | - u32 offset; |
14551 | - u32 bytes; |
14552 | - s32 value; |
14553 | + __le32 offset; |
14554 | + __le32 bytes; |
14555 | + __le32 value; |
14556 | } __packed req; |
14557 | - u32 req2; |
14558 | + __le32 req2; |
14559 | int err; |
14560 | struct scarlett2_mixer_data *private = mixer->private_data; |
14561 | |
14562 | @@ -753,8 +753,8 @@ static int scarlett2_usb_get( |
14563 | int offset, void *buf, int size) |
14564 | { |
14565 | struct { |
14566 | - u32 offset; |
14567 | - u32 size; |
14568 | + __le32 offset; |
14569 | + __le32 size; |
14570 | } __packed req; |
14571 | |
14572 | req.offset = cpu_to_le32(offset); |
14573 | @@ -794,8 +794,8 @@ static int scarlett2_usb_set_mix(struct usb_mixer_interface *mixer, |
14574 | const struct scarlett2_device_info *info = private->info; |
14575 | |
14576 | struct { |
14577 | - u16 mix_num; |
14578 | - u16 data[SCARLETT2_INPUT_MIX_MAX]; |
14579 | + __le16 mix_num; |
14580 | + __le16 data[SCARLETT2_INPUT_MIX_MAX]; |
14581 | } __packed req; |
14582 | |
14583 | int i, j; |
14584 | @@ -850,9 +850,9 @@ static int scarlett2_usb_set_mux(struct usb_mixer_interface *mixer) |
14585 | }; |
14586 | |
14587 | struct { |
14588 | - u16 pad; |
14589 | - u16 num; |
14590 | - u32 data[SCARLETT2_MUX_MAX]; |
14591 | + __le16 pad; |
14592 | + __le16 num; |
14593 | + __le32 data[SCARLETT2_MUX_MAX]; |
14594 | } __packed req; |
14595 | |
14596 | req.pad = 0; |
14597 | @@ -911,9 +911,9 @@ static int scarlett2_usb_get_meter_levels(struct usb_mixer_interface *mixer, |
14598 | u16 *levels) |
14599 | { |
14600 | struct { |
14601 | - u16 pad; |
14602 | - u16 num_meters; |
14603 | - u32 magic; |
14604 | + __le16 pad; |
14605 | + __le16 num_meters; |
14606 | + __le32 magic; |
14607 | } __packed req; |
14608 | u32 resp[SCARLETT2_NUM_METERS]; |
14609 | int i, err; |
14610 | diff --git a/sound/usb/validate.c b/sound/usb/validate.c |
14611 | index 389e8657434a..5a3c4f7882b0 100644 |
14612 | --- a/sound/usb/validate.c |
14613 | +++ b/sound/usb/validate.c |
14614 | @@ -110,7 +110,7 @@ static bool validate_processing_unit(const void *p, |
14615 | default: |
14616 | if (v->type == UAC1_EXTENSION_UNIT) |
14617 | return true; /* OK */ |
14618 | - switch (d->wProcessType) { |
14619 | + switch (le16_to_cpu(d->wProcessType)) { |
14620 | case UAC_PROCESS_UP_DOWNMIX: |
14621 | case UAC_PROCESS_DOLBY_PROLOGIC: |
14622 | if (d->bLength < len + 1) /* bNrModes */ |
14623 | @@ -125,7 +125,7 @@ static bool validate_processing_unit(const void *p, |
14624 | case UAC_VERSION_2: |
14625 | if (v->type == UAC2_EXTENSION_UNIT_V2) |
14626 | return true; /* OK */ |
14627 | - switch (d->wProcessType) { |
14628 | + switch (le16_to_cpu(d->wProcessType)) { |
14629 | case UAC2_PROCESS_UP_DOWNMIX: |
14630 | case UAC2_PROCESS_DOLBY_PROLOCIC: /* SiC! */ |
14631 | if (d->bLength < len + 1) /* bNrModes */ |
14632 | @@ -142,7 +142,7 @@ static bool validate_processing_unit(const void *p, |
14633 | len += 2; /* wClusterDescrID */ |
14634 | break; |
14635 | } |
14636 | - switch (d->wProcessType) { |
14637 | + switch (le16_to_cpu(d->wProcessType)) { |
14638 | case UAC3_PROCESS_UP_DOWNMIX: |
14639 | if (d->bLength < len + 1) /* bNrModes */ |
14640 | return false; |
14641 | diff --git a/tools/kvm/kvm_stat/kvm_stat b/tools/kvm/kvm_stat/kvm_stat |
14642 | index ad1b9e646c49..4cf93110c259 100755 |
14643 | --- a/tools/kvm/kvm_stat/kvm_stat |
14644 | +++ b/tools/kvm/kvm_stat/kvm_stat |
14645 | @@ -270,6 +270,7 @@ class ArchX86(Arch): |
14646 | def __init__(self, exit_reasons): |
14647 | self.sc_perf_evt_open = 298 |
14648 | self.ioctl_numbers = IOCTL_NUMBERS |
14649 | + self.exit_reason_field = 'exit_reason' |
14650 | self.exit_reasons = exit_reasons |
14651 | |
14652 | def debugfs_is_child(self, field): |
14653 | @@ -289,6 +290,7 @@ class ArchPPC(Arch): |
14654 | # numbers depend on the wordsize. |
14655 | char_ptr_size = ctypes.sizeof(ctypes.c_char_p) |
14656 | self.ioctl_numbers['SET_FILTER'] = 0x80002406 | char_ptr_size << 16 |
14657 | + self.exit_reason_field = 'exit_nr' |
14658 | self.exit_reasons = {} |
14659 | |
14660 | def debugfs_is_child(self, field): |
14661 | @@ -300,6 +302,7 @@ class ArchA64(Arch): |
14662 | def __init__(self): |
14663 | self.sc_perf_evt_open = 241 |
14664 | self.ioctl_numbers = IOCTL_NUMBERS |
14665 | + self.exit_reason_field = 'esr_ec' |
14666 | self.exit_reasons = AARCH64_EXIT_REASONS |
14667 | |
14668 | def debugfs_is_child(self, field): |
14669 | @@ -311,6 +314,7 @@ class ArchS390(Arch): |
14670 | def __init__(self): |
14671 | self.sc_perf_evt_open = 331 |
14672 | self.ioctl_numbers = IOCTL_NUMBERS |
14673 | + self.exit_reason_field = None |
14674 | self.exit_reasons = None |
14675 | |
14676 | def debugfs_is_child(self, field): |
14677 | @@ -541,8 +545,8 @@ class TracepointProvider(Provider): |
14678 | """ |
14679 | filters = {} |
14680 | filters['kvm_userspace_exit'] = ('reason', USERSPACE_EXIT_REASONS) |
14681 | - if ARCH.exit_reasons: |
14682 | - filters['kvm_exit'] = ('exit_reason', ARCH.exit_reasons) |
14683 | + if ARCH.exit_reason_field and ARCH.exit_reasons: |
14684 | + filters['kvm_exit'] = (ARCH.exit_reason_field, ARCH.exit_reasons) |
14685 | return filters |
14686 | |
14687 | def _get_available_fields(self): |
14688 | diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c |
14689 | index d98838c5820c..b6403712c2f4 100644 |
14690 | --- a/tools/lib/bpf/libbpf.c |
14691 | +++ b/tools/lib/bpf/libbpf.c |
14692 | @@ -2541,7 +2541,9 @@ static struct ids_vec *bpf_core_find_cands(const struct btf *local_btf, |
14693 | if (strncmp(local_name, targ_name, local_essent_len) == 0) { |
14694 | pr_debug("[%d] %s: found candidate [%d] %s\n", |
14695 | local_type_id, local_name, i, targ_name); |
14696 | - new_ids = realloc(cand_ids->data, cand_ids->len + 1); |
14697 | + new_ids = reallocarray(cand_ids->data, |
14698 | + cand_ids->len + 1, |
14699 | + sizeof(*cand_ids->data)); |
14700 | if (!new_ids) { |
14701 | err = -ENOMEM; |
14702 | goto err_out; |
14703 | diff --git a/tools/objtool/sync-check.sh b/tools/objtool/sync-check.sh |
14704 | index 0a832e265a50..c3ae1e8ae119 100755 |
14705 | --- a/tools/objtool/sync-check.sh |
14706 | +++ b/tools/objtool/sync-check.sh |
14707 | @@ -47,5 +47,3 @@ check arch/x86/include/asm/inat.h '-I "^#include [\"<]\(asm/\)*inat_types.h[ |
14708 | check arch/x86/include/asm/insn.h '-I "^#include [\"<]\(asm/\)*inat.h[\">]"' |
14709 | check arch/x86/lib/inat.c '-I "^#include [\"<]\(../include/\)*asm/insn.h[\">]"' |
14710 | check arch/x86/lib/insn.c '-I "^#include [\"<]\(../include/\)*asm/in\(at\|sn\).h[\">]"' |
14711 | - |
14712 | -cd - |
14713 | diff --git a/tools/power/cpupower/lib/cpufreq.c b/tools/power/cpupower/lib/cpufreq.c |
14714 | index 2f55d4d23446..6e04304560ca 100644 |
14715 | --- a/tools/power/cpupower/lib/cpufreq.c |
14716 | +++ b/tools/power/cpupower/lib/cpufreq.c |
14717 | @@ -332,21 +332,74 @@ void cpufreq_put_available_governors(struct cpufreq_available_governors *any) |
14718 | } |
14719 | |
14720 | |
14721 | -struct cpufreq_frequencies |
14722 | -*cpufreq_get_frequencies(const char *type, unsigned int cpu) |
14723 | +struct cpufreq_available_frequencies |
14724 | +*cpufreq_get_available_frequencies(unsigned int cpu) |
14725 | { |
14726 | - struct cpufreq_frequencies *first = NULL; |
14727 | - struct cpufreq_frequencies *current = NULL; |
14728 | + struct cpufreq_available_frequencies *first = NULL; |
14729 | + struct cpufreq_available_frequencies *current = NULL; |
14730 | char one_value[SYSFS_PATH_MAX]; |
14731 | char linebuf[MAX_LINE_LEN]; |
14732 | - char fname[MAX_LINE_LEN]; |
14733 | unsigned int pos, i; |
14734 | unsigned int len; |
14735 | |
14736 | - snprintf(fname, MAX_LINE_LEN, "scaling_%s_frequencies", type); |
14737 | + len = sysfs_cpufreq_read_file(cpu, "scaling_available_frequencies", |
14738 | + linebuf, sizeof(linebuf)); |
14739 | + if (len == 0) |
14740 | + return NULL; |
14741 | |
14742 | - len = sysfs_cpufreq_read_file(cpu, fname, |
14743 | - linebuf, sizeof(linebuf)); |
14744 | + pos = 0; |
14745 | + for (i = 0; i < len; i++) { |
14746 | + if (linebuf[i] == ' ' || linebuf[i] == '\n') { |
14747 | + if (i - pos < 2) |
14748 | + continue; |
14749 | + if (i - pos >= SYSFS_PATH_MAX) |
14750 | + goto error_out; |
14751 | + if (current) { |
14752 | + current->next = malloc(sizeof(*current)); |
14753 | + if (!current->next) |
14754 | + goto error_out; |
14755 | + current = current->next; |
14756 | + } else { |
14757 | + first = malloc(sizeof(*first)); |
14758 | + if (!first) |
14759 | + goto error_out; |
14760 | + current = first; |
14761 | + } |
14762 | + current->first = first; |
14763 | + current->next = NULL; |
14764 | + |
14765 | + memcpy(one_value, linebuf + pos, i - pos); |
14766 | + one_value[i - pos] = '\0'; |
14767 | + if (sscanf(one_value, "%lu", ¤t->frequency) != 1) |
14768 | + goto error_out; |
14769 | + |
14770 | + pos = i + 1; |
14771 | + } |
14772 | + } |
14773 | + |
14774 | + return first; |
14775 | + |
14776 | + error_out: |
14777 | + while (first) { |
14778 | + current = first->next; |
14779 | + free(first); |
14780 | + first = current; |
14781 | + } |
14782 | + return NULL; |
14783 | +} |
14784 | + |
14785 | +struct cpufreq_available_frequencies |
14786 | +*cpufreq_get_boost_frequencies(unsigned int cpu) |
14787 | +{ |
14788 | + struct cpufreq_available_frequencies *first = NULL; |
14789 | + struct cpufreq_available_frequencies *current = NULL; |
14790 | + char one_value[SYSFS_PATH_MAX]; |
14791 | + char linebuf[MAX_LINE_LEN]; |
14792 | + unsigned int pos, i; |
14793 | + unsigned int len; |
14794 | + |
14795 | + len = sysfs_cpufreq_read_file(cpu, "scaling_boost_frequencies", |
14796 | + linebuf, sizeof(linebuf)); |
14797 | if (len == 0) |
14798 | return NULL; |
14799 | |
14800 | @@ -391,9 +444,9 @@ struct cpufreq_frequencies |
14801 | return NULL; |
14802 | } |
14803 | |
14804 | -void cpufreq_put_frequencies(struct cpufreq_frequencies *any) |
14805 | +void cpufreq_put_available_frequencies(struct cpufreq_available_frequencies *any) |
14806 | { |
14807 | - struct cpufreq_frequencies *tmp, *next; |
14808 | + struct cpufreq_available_frequencies *tmp, *next; |
14809 | |
14810 | if (!any) |
14811 | return; |
14812 | @@ -406,6 +459,11 @@ void cpufreq_put_frequencies(struct cpufreq_frequencies *any) |
14813 | } |
14814 | } |
14815 | |
14816 | +void cpufreq_put_boost_frequencies(struct cpufreq_available_frequencies *any) |
14817 | +{ |
14818 | + cpufreq_put_available_frequencies(any); |
14819 | +} |
14820 | + |
14821 | static struct cpufreq_affected_cpus *sysfs_get_cpu_list(unsigned int cpu, |
14822 | const char *file) |
14823 | { |
14824 | diff --git a/tools/power/cpupower/lib/cpufreq.h b/tools/power/cpupower/lib/cpufreq.h |
14825 | index a55f0d19215b..95f4fd9e2656 100644 |
14826 | --- a/tools/power/cpupower/lib/cpufreq.h |
14827 | +++ b/tools/power/cpupower/lib/cpufreq.h |
14828 | @@ -20,10 +20,10 @@ struct cpufreq_available_governors { |
14829 | struct cpufreq_available_governors *first; |
14830 | }; |
14831 | |
14832 | -struct cpufreq_frequencies { |
14833 | +struct cpufreq_available_frequencies { |
14834 | unsigned long frequency; |
14835 | - struct cpufreq_frequencies *next; |
14836 | - struct cpufreq_frequencies *first; |
14837 | + struct cpufreq_available_frequencies *next; |
14838 | + struct cpufreq_available_frequencies *first; |
14839 | }; |
14840 | |
14841 | |
14842 | @@ -124,11 +124,17 @@ void cpufreq_put_available_governors( |
14843 | * cpufreq_put_frequencies after use. |
14844 | */ |
14845 | |
14846 | -struct cpufreq_frequencies |
14847 | -*cpufreq_get_frequencies(const char *type, unsigned int cpu); |
14848 | +struct cpufreq_available_frequencies |
14849 | +*cpufreq_get_available_frequencies(unsigned int cpu); |
14850 | |
14851 | -void cpufreq_put_frequencies( |
14852 | - struct cpufreq_frequencies *first); |
14853 | +void cpufreq_put_available_frequencies( |
14854 | + struct cpufreq_available_frequencies *first); |
14855 | + |
14856 | +struct cpufreq_available_frequencies |
14857 | +*cpufreq_get_boost_frequencies(unsigned int cpu); |
14858 | + |
14859 | +void cpufreq_put_boost_frequencies( |
14860 | + struct cpufreq_available_frequencies *first); |
14861 | |
14862 | |
14863 | /* determine affected CPUs |
14864 | diff --git a/tools/power/cpupower/utils/cpufreq-info.c b/tools/power/cpupower/utils/cpufreq-info.c |
14865 | index e63cf55f81cf..6efc0f6b1b11 100644 |
14866 | --- a/tools/power/cpupower/utils/cpufreq-info.c |
14867 | +++ b/tools/power/cpupower/utils/cpufreq-info.c |
14868 | @@ -244,14 +244,14 @@ static int get_boost_mode_x86(unsigned int cpu) |
14869 | |
14870 | static int get_boost_mode(unsigned int cpu) |
14871 | { |
14872 | - struct cpufreq_frequencies *freqs; |
14873 | + struct cpufreq_available_frequencies *freqs; |
14874 | |
14875 | if (cpupower_cpu_info.vendor == X86_VENDOR_AMD || |
14876 | cpupower_cpu_info.vendor == X86_VENDOR_HYGON || |
14877 | cpupower_cpu_info.vendor == X86_VENDOR_INTEL) |
14878 | return get_boost_mode_x86(cpu); |
14879 | |
14880 | - freqs = cpufreq_get_frequencies("boost", cpu); |
14881 | + freqs = cpufreq_get_boost_frequencies(cpu); |
14882 | if (freqs) { |
14883 | printf(_(" boost frequency steps: ")); |
14884 | while (freqs->next) { |
14885 | @@ -261,7 +261,7 @@ static int get_boost_mode(unsigned int cpu) |
14886 | } |
14887 | print_speed(freqs->frequency); |
14888 | printf("\n"); |
14889 | - cpufreq_put_frequencies(freqs); |
14890 | + cpufreq_put_available_frequencies(freqs); |
14891 | } |
14892 | |
14893 | return 0; |
14894 | @@ -475,7 +475,7 @@ static int get_latency(unsigned int cpu, unsigned int human) |
14895 | |
14896 | static void debug_output_one(unsigned int cpu) |
14897 | { |
14898 | - struct cpufreq_frequencies *freqs; |
14899 | + struct cpufreq_available_frequencies *freqs; |
14900 | |
14901 | get_driver(cpu); |
14902 | get_related_cpus(cpu); |
14903 | @@ -483,7 +483,7 @@ static void debug_output_one(unsigned int cpu) |
14904 | get_latency(cpu, 1); |
14905 | get_hardware_limits(cpu, 1); |
14906 | |
14907 | - freqs = cpufreq_get_frequencies("available", cpu); |
14908 | + freqs = cpufreq_get_available_frequencies(cpu); |
14909 | if (freqs) { |
14910 | printf(_(" available frequency steps: ")); |
14911 | while (freqs->next) { |
14912 | @@ -493,7 +493,7 @@ static void debug_output_one(unsigned int cpu) |
14913 | } |
14914 | print_speed(freqs->frequency); |
14915 | printf("\n"); |
14916 | - cpufreq_put_frequencies(freqs); |
14917 | + cpufreq_put_available_frequencies(freqs); |
14918 | } |
14919 | |
14920 | get_available_governors(cpu); |
14921 | diff --git a/tools/testing/selftests/bpf/prog_tests/attach_probe.c b/tools/testing/selftests/bpf/prog_tests/attach_probe.c |
14922 | index 5ecc267d98b0..fad615c22e4d 100644 |
14923 | --- a/tools/testing/selftests/bpf/prog_tests/attach_probe.c |
14924 | +++ b/tools/testing/selftests/bpf/prog_tests/attach_probe.c |
14925 | @@ -2,7 +2,7 @@ |
14926 | #include <test_progs.h> |
14927 | |
14928 | ssize_t get_base_addr() { |
14929 | - size_t start; |
14930 | + size_t start, offset; |
14931 | char buf[256]; |
14932 | FILE *f; |
14933 | |
14934 | @@ -10,10 +10,11 @@ ssize_t get_base_addr() { |
14935 | if (!f) |
14936 | return -errno; |
14937 | |
14938 | - while (fscanf(f, "%zx-%*x %s %*s\n", &start, buf) == 2) { |
14939 | + while (fscanf(f, "%zx-%*x %s %zx %*[^\n]\n", |
14940 | + &start, buf, &offset) == 3) { |
14941 | if (strcmp(buf, "r-xp") == 0) { |
14942 | fclose(f); |
14943 | - return start; |
14944 | + return start - offset; |
14945 | } |
14946 | } |
14947 | |
14948 | diff --git a/tools/testing/selftests/bpf/prog_tests/perf_buffer.c b/tools/testing/selftests/bpf/prog_tests/perf_buffer.c |
14949 | index 3003fddc0613..cf6c87936c69 100644 |
14950 | --- a/tools/testing/selftests/bpf/prog_tests/perf_buffer.c |
14951 | +++ b/tools/testing/selftests/bpf/prog_tests/perf_buffer.c |
14952 | @@ -4,6 +4,7 @@ |
14953 | #include <sched.h> |
14954 | #include <sys/socket.h> |
14955 | #include <test_progs.h> |
14956 | +#include "libbpf_internal.h" |
14957 | |
14958 | static void on_sample(void *ctx, int cpu, void *data, __u32 size) |
14959 | { |
14960 | @@ -19,7 +20,7 @@ static void on_sample(void *ctx, int cpu, void *data, __u32 size) |
14961 | |
14962 | void test_perf_buffer(void) |
14963 | { |
14964 | - int err, prog_fd, nr_cpus, i, duration = 0; |
14965 | + int err, prog_fd, on_len, nr_on_cpus = 0, nr_cpus, i, duration = 0; |
14966 | const char *prog_name = "kprobe/sys_nanosleep"; |
14967 | const char *file = "./test_perf_buffer.o"; |
14968 | struct perf_buffer_opts pb_opts = {}; |
14969 | @@ -29,15 +30,27 @@ void test_perf_buffer(void) |
14970 | struct bpf_object *obj; |
14971 | struct perf_buffer *pb; |
14972 | struct bpf_link *link; |
14973 | + bool *online; |
14974 | |
14975 | nr_cpus = libbpf_num_possible_cpus(); |
14976 | if (CHECK(nr_cpus < 0, "nr_cpus", "err %d\n", nr_cpus)) |
14977 | return; |
14978 | |
14979 | + err = parse_cpu_mask_file("/sys/devices/system/cpu/online", |
14980 | + &online, &on_len); |
14981 | + if (CHECK(err, "nr_on_cpus", "err %d\n", err)) |
14982 | + return; |
14983 | + |
14984 | + for (i = 0; i < on_len; i++) |
14985 | + if (online[i]) |
14986 | + nr_on_cpus++; |
14987 | + |
14988 | /* load program */ |
14989 | err = bpf_prog_load(file, BPF_PROG_TYPE_KPROBE, &obj, &prog_fd); |
14990 | - if (CHECK(err, "obj_load", "err %d errno %d\n", err, errno)) |
14991 | - return; |
14992 | + if (CHECK(err, "obj_load", "err %d errno %d\n", err, errno)) { |
14993 | + obj = NULL; |
14994 | + goto out_close; |
14995 | + } |
14996 | |
14997 | prog = bpf_object__find_program_by_title(obj, prog_name); |
14998 | if (CHECK(!prog, "find_probe", "prog '%s' not found\n", prog_name)) |
14999 | @@ -64,6 +77,11 @@ void test_perf_buffer(void) |
15000 | /* trigger kprobe on every CPU */ |
15001 | CPU_ZERO(&cpu_seen); |
15002 | for (i = 0; i < nr_cpus; i++) { |
15003 | + if (i >= on_len || !online[i]) { |
15004 | + printf("skipping offline CPU #%d\n", i); |
15005 | + continue; |
15006 | + } |
15007 | + |
15008 | CPU_ZERO(&cpu_set); |
15009 | CPU_SET(i, &cpu_set); |
15010 | |
15011 | @@ -81,8 +99,8 @@ void test_perf_buffer(void) |
15012 | if (CHECK(err < 0, "perf_buffer__poll", "err %d\n", err)) |
15013 | goto out_free_pb; |
15014 | |
15015 | - if (CHECK(CPU_COUNT(&cpu_seen) != nr_cpus, "seen_cpu_cnt", |
15016 | - "expect %d, seen %d\n", nr_cpus, CPU_COUNT(&cpu_seen))) |
15017 | + if (CHECK(CPU_COUNT(&cpu_seen) != nr_on_cpus, "seen_cpu_cnt", |
15018 | + "expect %d, seen %d\n", nr_on_cpus, CPU_COUNT(&cpu_seen))) |
15019 | goto out_free_pb; |
15020 | |
15021 | out_free_pb: |
15022 | @@ -91,4 +109,5 @@ out_detach: |
15023 | bpf_link__destroy(link); |
15024 | out_close: |
15025 | bpf_object__close(obj); |
15026 | + free(online); |
15027 | } |
15028 | diff --git a/tools/testing/selftests/bpf/prog_tests/stacktrace_build_id_nmi.c b/tools/testing/selftests/bpf/prog_tests/stacktrace_build_id_nmi.c |
15029 | index f62aa0eb959b..1735faf17536 100644 |
15030 | --- a/tools/testing/selftests/bpf/prog_tests/stacktrace_build_id_nmi.c |
15031 | +++ b/tools/testing/selftests/bpf/prog_tests/stacktrace_build_id_nmi.c |
15032 | @@ -49,8 +49,12 @@ retry: |
15033 | pmu_fd = syscall(__NR_perf_event_open, &attr, -1 /* pid */, |
15034 | 0 /* cpu 0 */, -1 /* group id */, |
15035 | 0 /* flags */); |
15036 | - if (CHECK(pmu_fd < 0, "perf_event_open", |
15037 | - "err %d errno %d. Does the test host support PERF_COUNT_HW_CPU_CYCLES?\n", |
15038 | + if (pmu_fd < 0 && errno == ENOENT) { |
15039 | + printf("%s:SKIP:no PERF_COUNT_HW_CPU_CYCLES\n", __func__); |
15040 | + test__skip(); |
15041 | + goto cleanup; |
15042 | + } |
15043 | + if (CHECK(pmu_fd < 0, "perf_event_open", "err %d errno %d\n", |
15044 | pmu_fd, errno)) |
15045 | goto close_prog; |
15046 | |
15047 | diff --git a/tools/testing/selftests/bpf/progs/test_select_reuseport_kern.c b/tools/testing/selftests/bpf/progs/test_select_reuseport_kern.c |
15048 | index ea7d84f01235..e6be383a003f 100644 |
15049 | --- a/tools/testing/selftests/bpf/progs/test_select_reuseport_kern.c |
15050 | +++ b/tools/testing/selftests/bpf/progs/test_select_reuseport_kern.c |
15051 | @@ -113,6 +113,12 @@ int _select_by_skb_data(struct sk_reuseport_md *reuse_md) |
15052 | data_check.skb_ports[0] = th->source; |
15053 | data_check.skb_ports[1] = th->dest; |
15054 | |
15055 | + if (th->fin) |
15056 | + /* The connection is being torn down at the end of a |
15057 | + * test. It can't contain a cmd, so return early. |
15058 | + */ |
15059 | + return SK_PASS; |
15060 | + |
15061 | if ((th->doff << 2) + sizeof(*cmd) > data_check.len) |
15062 | GOTO_DONE(DROP_ERR_SKB_DATA); |
15063 | if (bpf_skb_load_bytes(reuse_md, th->doff << 2, &cmd_copy, |
15064 | diff --git a/tools/testing/selftests/bpf/test_sockmap.c b/tools/testing/selftests/bpf/test_sockmap.c |
15065 | index 4a851513c842..779e11da979c 100644 |
15066 | --- a/tools/testing/selftests/bpf/test_sockmap.c |
15067 | +++ b/tools/testing/selftests/bpf/test_sockmap.c |
15068 | @@ -331,7 +331,7 @@ static int msg_loop_sendpage(int fd, int iov_length, int cnt, |
15069 | FILE *file; |
15070 | int i, fp; |
15071 | |
15072 | - file = fopen(".sendpage_tst.tmp", "w+"); |
15073 | + file = tmpfile(); |
15074 | if (!file) { |
15075 | perror("create file for sendpage"); |
15076 | return 1; |
15077 | @@ -340,13 +340,8 @@ static int msg_loop_sendpage(int fd, int iov_length, int cnt, |
15078 | fwrite(&k, sizeof(char), 1, file); |
15079 | fflush(file); |
15080 | fseek(file, 0, SEEK_SET); |
15081 | - fclose(file); |
15082 | |
15083 | - fp = open(".sendpage_tst.tmp", O_RDONLY); |
15084 | - if (fp < 0) { |
15085 | - perror("reopen file for sendpage"); |
15086 | - return 1; |
15087 | - } |
15088 | + fp = fileno(file); |
15089 | |
15090 | clock_gettime(CLOCK_MONOTONIC, &s->start); |
15091 | for (i = 0; i < cnt; i++) { |
15092 | @@ -354,11 +349,11 @@ static int msg_loop_sendpage(int fd, int iov_length, int cnt, |
15093 | |
15094 | if (!drop && sent < 0) { |
15095 | perror("send loop error"); |
15096 | - close(fp); |
15097 | + fclose(file); |
15098 | return sent; |
15099 | } else if (drop && sent >= 0) { |
15100 | printf("sendpage loop error expected: %i\n", sent); |
15101 | - close(fp); |
15102 | + fclose(file); |
15103 | return -EIO; |
15104 | } |
15105 | |
15106 | @@ -366,7 +361,7 @@ static int msg_loop_sendpage(int fd, int iov_length, int cnt, |
15107 | s->bytes_sent += sent; |
15108 | } |
15109 | clock_gettime(CLOCK_MONOTONIC, &s->end); |
15110 | - close(fp); |
15111 | + fclose(file); |
15112 | return 0; |
15113 | } |
15114 | |
15115 | diff --git a/tools/testing/selftests/tc-testing/plugin-lib/buildebpfPlugin.py b/tools/testing/selftests/tc-testing/plugin-lib/buildebpfPlugin.py |
15116 | index e98c36750fae..d34fe06268d2 100644 |
15117 | --- a/tools/testing/selftests/tc-testing/plugin-lib/buildebpfPlugin.py |
15118 | +++ b/tools/testing/selftests/tc-testing/plugin-lib/buildebpfPlugin.py |
15119 | @@ -54,7 +54,7 @@ class SubPlugin(TdcPlugin): |
15120 | shell=True, |
15121 | stdout=subprocess.PIPE, |
15122 | stderr=subprocess.PIPE, |
15123 | - env=ENVIR) |
15124 | + env=os.environ.copy()) |
15125 | (rawout, serr) = proc.communicate() |
15126 | |
15127 | if proc.returncode != 0 and len(serr) > 0: |
15128 | diff --git a/virt/kvm/arm/aarch32.c b/virt/kvm/arm/aarch32.c |
15129 | index c4c57ba99e90..631d397ac81b 100644 |
15130 | --- a/virt/kvm/arm/aarch32.c |
15131 | +++ b/virt/kvm/arm/aarch32.c |
15132 | @@ -10,6 +10,7 @@ |
15133 | * Author: Christoffer Dall <c.dall@virtualopensystems.com> |
15134 | */ |
15135 | |
15136 | +#include <linux/bits.h> |
15137 | #include <linux/kvm_host.h> |
15138 | #include <asm/kvm_emulate.h> |
15139 | #include <asm/kvm_hyp.h> |
15140 | @@ -28,25 +29,115 @@ static const u8 return_offsets[8][2] = { |
15141 | [7] = { 4, 4 }, /* FIQ, unused */ |
15142 | }; |
15143 | |
15144 | +/* |
15145 | + * When an exception is taken, most CPSR fields are left unchanged in the |
15146 | + * handler. However, some are explicitly overridden (e.g. M[4:0]). |
15147 | + * |
15148 | + * The SPSR/SPSR_ELx layouts differ, and the below is intended to work with |
15149 | + * either format. Note: SPSR.J bit doesn't exist in SPSR_ELx, but this bit was |
15150 | + * obsoleted by the ARMv7 virtualization extensions and is RES0. |
15151 | + * |
15152 | + * For the SPSR layout seen from AArch32, see: |
15153 | + * - ARM DDI 0406C.d, page B1-1148 |
15154 | + * - ARM DDI 0487E.a, page G8-6264 |
15155 | + * |
15156 | + * For the SPSR_ELx layout for AArch32 seen from AArch64, see: |
15157 | + * - ARM DDI 0487E.a, page C5-426 |
15158 | + * |
15159 | + * Here we manipulate the fields in order of the AArch32 SPSR_ELx layout, from |
15160 | + * MSB to LSB. |
15161 | + */ |
15162 | +static unsigned long get_except32_cpsr(struct kvm_vcpu *vcpu, u32 mode) |
15163 | +{ |
15164 | + u32 sctlr = vcpu_cp15(vcpu, c1_SCTLR); |
15165 | + unsigned long old, new; |
15166 | + |
15167 | + old = *vcpu_cpsr(vcpu); |
15168 | + new = 0; |
15169 | + |
15170 | + new |= (old & PSR_AA32_N_BIT); |
15171 | + new |= (old & PSR_AA32_Z_BIT); |
15172 | + new |= (old & PSR_AA32_C_BIT); |
15173 | + new |= (old & PSR_AA32_V_BIT); |
15174 | + new |= (old & PSR_AA32_Q_BIT); |
15175 | + |
15176 | + // CPSR.IT[7:0] are set to zero upon any exception |
15177 | + // See ARM DDI 0487E.a, section G1.12.3 |
15178 | + // See ARM DDI 0406C.d, section B1.8.3 |
15179 | + |
15180 | + new |= (old & PSR_AA32_DIT_BIT); |
15181 | + |
15182 | + // CPSR.SSBS is set to SCTLR.DSSBS upon any exception |
15183 | + // See ARM DDI 0487E.a, page G8-6244 |
15184 | + if (sctlr & BIT(31)) |
15185 | + new |= PSR_AA32_SSBS_BIT; |
15186 | + |
15187 | + // CPSR.PAN is unchanged unless SCTLR.SPAN == 0b0 |
15188 | + // SCTLR.SPAN is RES1 when ARMv8.1-PAN is not implemented |
15189 | + // See ARM DDI 0487E.a, page G8-6246 |
15190 | + new |= (old & PSR_AA32_PAN_BIT); |
15191 | + if (!(sctlr & BIT(23))) |
15192 | + new |= PSR_AA32_PAN_BIT; |
15193 | + |
15194 | + // SS does not exist in AArch32, so ignore |
15195 | + |
15196 | + // CPSR.IL is set to zero upon any exception |
15197 | + // See ARM DDI 0487E.a, page G1-5527 |
15198 | + |
15199 | + new |= (old & PSR_AA32_GE_MASK); |
15200 | + |
15201 | + // CPSR.IT[7:0] are set to zero upon any exception |
15202 | + // See prior comment above |
15203 | + |
15204 | + // CPSR.E is set to SCTLR.EE upon any exception |
15205 | + // See ARM DDI 0487E.a, page G8-6245 |
15206 | + // See ARM DDI 0406C.d, page B4-1701 |
15207 | + if (sctlr & BIT(25)) |
15208 | + new |= PSR_AA32_E_BIT; |
15209 | + |
15210 | + // CPSR.A is unchanged upon an exception to Undefined, Supervisor |
15211 | + // CPSR.A is set upon an exception to other modes |
15212 | + // See ARM DDI 0487E.a, pages G1-5515 to G1-5516 |
15213 | + // See ARM DDI 0406C.d, page B1-1182 |
15214 | + new |= (old & PSR_AA32_A_BIT); |
15215 | + if (mode != PSR_AA32_MODE_UND && mode != PSR_AA32_MODE_SVC) |
15216 | + new |= PSR_AA32_A_BIT; |
15217 | + |
15218 | + // CPSR.I is set upon any exception |
15219 | + // See ARM DDI 0487E.a, pages G1-5515 to G1-5516 |
15220 | + // See ARM DDI 0406C.d, page B1-1182 |
15221 | + new |= PSR_AA32_I_BIT; |
15222 | + |
15223 | + // CPSR.F is set upon an exception to FIQ |
15224 | + // CPSR.F is unchanged upon an exception to other modes |
15225 | + // See ARM DDI 0487E.a, pages G1-5515 to G1-5516 |
15226 | + // See ARM DDI 0406C.d, page B1-1182 |
15227 | + new |= (old & PSR_AA32_F_BIT); |
15228 | + if (mode == PSR_AA32_MODE_FIQ) |
15229 | + new |= PSR_AA32_F_BIT; |
15230 | + |
15231 | + // CPSR.T is set to SCTLR.TE upon any exception |
15232 | + // See ARM DDI 0487E.a, page G8-5514 |
15233 | + // See ARM DDI 0406C.d, page B1-1181 |
15234 | + if (sctlr & BIT(30)) |
15235 | + new |= PSR_AA32_T_BIT; |
15236 | + |
15237 | + new |= mode; |
15238 | + |
15239 | + return new; |
15240 | +} |
15241 | + |
15242 | static void prepare_fault32(struct kvm_vcpu *vcpu, u32 mode, u32 vect_offset) |
15243 | { |
15244 | - unsigned long cpsr; |
15245 | - unsigned long new_spsr_value = *vcpu_cpsr(vcpu); |
15246 | - bool is_thumb = (new_spsr_value & PSR_AA32_T_BIT); |
15247 | + unsigned long spsr = *vcpu_cpsr(vcpu); |
15248 | + bool is_thumb = (spsr & PSR_AA32_T_BIT); |
15249 | u32 return_offset = return_offsets[vect_offset >> 2][is_thumb]; |
15250 | u32 sctlr = vcpu_cp15(vcpu, c1_SCTLR); |
15251 | |
15252 | - cpsr = mode | PSR_AA32_I_BIT; |
15253 | - |
15254 | - if (sctlr & (1 << 30)) |
15255 | - cpsr |= PSR_AA32_T_BIT; |
15256 | - if (sctlr & (1 << 25)) |
15257 | - cpsr |= PSR_AA32_E_BIT; |
15258 | - |
15259 | - *vcpu_cpsr(vcpu) = cpsr; |
15260 | + *vcpu_cpsr(vcpu) = get_except32_cpsr(vcpu, mode); |
15261 | |
15262 | /* Note: These now point to the banked copies */ |
15263 | - vcpu_write_spsr(vcpu, new_spsr_value); |
15264 | + vcpu_write_spsr(vcpu, host_spsr_to_spsr32(spsr)); |
15265 | *vcpu_reg32(vcpu, 14) = *vcpu_pc(vcpu) + return_offset; |
15266 | |
15267 | /* Branch to exception vector */ |
15268 | @@ -84,7 +175,7 @@ static void inject_abt32(struct kvm_vcpu *vcpu, bool is_pabt, |
15269 | fsr = &vcpu_cp15(vcpu, c5_DFSR); |
15270 | } |
15271 | |
15272 | - prepare_fault32(vcpu, PSR_AA32_MODE_ABT | PSR_AA32_A_BIT, vect_offset); |
15273 | + prepare_fault32(vcpu, PSR_AA32_MODE_ABT, vect_offset); |
15274 | |
15275 | *far = addr; |
15276 | |
15277 | diff --git a/virt/kvm/arm/mmio.c b/virt/kvm/arm/mmio.c |
15278 | index 6af5c91337f2..f274fabb4301 100644 |
15279 | --- a/virt/kvm/arm/mmio.c |
15280 | +++ b/virt/kvm/arm/mmio.c |
15281 | @@ -105,6 +105,9 @@ int kvm_handle_mmio_return(struct kvm_vcpu *vcpu, struct kvm_run *run) |
15282 | data = (data ^ mask) - mask; |
15283 | } |
15284 | |
15285 | + if (!vcpu->arch.mmio_decode.sixty_four) |
15286 | + data = data & 0xffffffff; |
15287 | + |
15288 | trace_kvm_mmio(KVM_TRACE_MMIO_READ, len, run->mmio.phys_addr, |
15289 | &data); |
15290 | data = vcpu_data_host_to_guest(vcpu, data, len); |
15291 | @@ -125,6 +128,7 @@ static int decode_hsr(struct kvm_vcpu *vcpu, bool *is_write, int *len) |
15292 | unsigned long rt; |
15293 | int access_size; |
15294 | bool sign_extend; |
15295 | + bool sixty_four; |
15296 | |
15297 | if (kvm_vcpu_dabt_iss1tw(vcpu)) { |
15298 | /* page table accesses IO mem: tell guest to fix its TTBR */ |
15299 | @@ -138,11 +142,13 @@ static int decode_hsr(struct kvm_vcpu *vcpu, bool *is_write, int *len) |
15300 | |
15301 | *is_write = kvm_vcpu_dabt_iswrite(vcpu); |
15302 | sign_extend = kvm_vcpu_dabt_issext(vcpu); |
15303 | + sixty_four = kvm_vcpu_dabt_issf(vcpu); |
15304 | rt = kvm_vcpu_dabt_get_rd(vcpu); |
15305 | |
15306 | *len = access_size; |
15307 | vcpu->arch.mmio_decode.sign_extend = sign_extend; |
15308 | vcpu->arch.mmio_decode.rt = rt; |
15309 | + vcpu->arch.mmio_decode.sixty_four = sixty_four; |
15310 | |
15311 | return 0; |
15312 | } |
15313 | diff --git a/virt/kvm/async_pf.c b/virt/kvm/async_pf.c |
15314 | index 35305d6e68cc..d8ef708a2ef6 100644 |
15315 | --- a/virt/kvm/async_pf.c |
15316 | +++ b/virt/kvm/async_pf.c |
15317 | @@ -64,7 +64,7 @@ static void async_pf_execute(struct work_struct *work) |
15318 | struct mm_struct *mm = apf->mm; |
15319 | struct kvm_vcpu *vcpu = apf->vcpu; |
15320 | unsigned long addr = apf->addr; |
15321 | - gva_t gva = apf->gva; |
15322 | + gpa_t cr2_or_gpa = apf->cr2_or_gpa; |
15323 | int locked = 1; |
15324 | |
15325 | might_sleep(); |
15326 | @@ -92,7 +92,7 @@ static void async_pf_execute(struct work_struct *work) |
15327 | * this point |
15328 | */ |
15329 | |
15330 | - trace_kvm_async_pf_completed(addr, gva); |
15331 | + trace_kvm_async_pf_completed(addr, cr2_or_gpa); |
15332 | |
15333 | if (swq_has_sleeper(&vcpu->wq)) |
15334 | swake_up_one(&vcpu->wq); |
15335 | @@ -165,8 +165,8 @@ void kvm_check_async_pf_completion(struct kvm_vcpu *vcpu) |
15336 | } |
15337 | } |
15338 | |
15339 | -int kvm_setup_async_pf(struct kvm_vcpu *vcpu, gva_t gva, unsigned long hva, |
15340 | - struct kvm_arch_async_pf *arch) |
15341 | +int kvm_setup_async_pf(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa, |
15342 | + unsigned long hva, struct kvm_arch_async_pf *arch) |
15343 | { |
15344 | struct kvm_async_pf *work; |
15345 | |
15346 | @@ -185,7 +185,7 @@ int kvm_setup_async_pf(struct kvm_vcpu *vcpu, gva_t gva, unsigned long hva, |
15347 | |
15348 | work->wakeup_all = false; |
15349 | work->vcpu = vcpu; |
15350 | - work->gva = gva; |
15351 | + work->cr2_or_gpa = cr2_or_gpa; |
15352 | work->addr = hva; |
15353 | work->arch = *arch; |
15354 | work->mm = current->mm; |
15355 | diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c |
15356 | index 13efc291b1c7..b5ea1bafe513 100644 |
15357 | --- a/virt/kvm/kvm_main.c |
15358 | +++ b/virt/kvm/kvm_main.c |
15359 | @@ -1394,14 +1394,14 @@ bool kvm_is_visible_gfn(struct kvm *kvm, gfn_t gfn) |
15360 | } |
15361 | EXPORT_SYMBOL_GPL(kvm_is_visible_gfn); |
15362 | |
15363 | -unsigned long kvm_host_page_size(struct kvm *kvm, gfn_t gfn) |
15364 | +unsigned long kvm_host_page_size(struct kvm_vcpu *vcpu, gfn_t gfn) |
15365 | { |
15366 | struct vm_area_struct *vma; |
15367 | unsigned long addr, size; |
15368 | |
15369 | size = PAGE_SIZE; |
15370 | |
15371 | - addr = gfn_to_hva(kvm, gfn); |
15372 | + addr = kvm_vcpu_gfn_to_hva_prot(vcpu, gfn, NULL); |
15373 | if (kvm_is_error_hva(addr)) |
15374 | return PAGE_SIZE; |
15375 | |
15376 | @@ -1809,26 +1809,72 @@ struct page *gfn_to_page(struct kvm *kvm, gfn_t gfn) |
15377 | } |
15378 | EXPORT_SYMBOL_GPL(gfn_to_page); |
15379 | |
15380 | -static int __kvm_map_gfn(struct kvm_memory_slot *slot, gfn_t gfn, |
15381 | - struct kvm_host_map *map) |
15382 | +void kvm_release_pfn(kvm_pfn_t pfn, bool dirty, struct gfn_to_pfn_cache *cache) |
15383 | +{ |
15384 | + if (pfn == 0) |
15385 | + return; |
15386 | + |
15387 | + if (cache) |
15388 | + cache->pfn = cache->gfn = 0; |
15389 | + |
15390 | + if (dirty) |
15391 | + kvm_release_pfn_dirty(pfn); |
15392 | + else |
15393 | + kvm_release_pfn_clean(pfn); |
15394 | +} |
15395 | + |
15396 | +static void kvm_cache_gfn_to_pfn(struct kvm_memory_slot *slot, gfn_t gfn, |
15397 | + struct gfn_to_pfn_cache *cache, u64 gen) |
15398 | +{ |
15399 | + kvm_release_pfn(cache->pfn, cache->dirty, cache); |
15400 | + |
15401 | + cache->pfn = gfn_to_pfn_memslot(slot, gfn); |
15402 | + cache->gfn = gfn; |
15403 | + cache->dirty = false; |
15404 | + cache->generation = gen; |
15405 | +} |
15406 | + |
15407 | +static int __kvm_map_gfn(struct kvm_memslots *slots, gfn_t gfn, |
15408 | + struct kvm_host_map *map, |
15409 | + struct gfn_to_pfn_cache *cache, |
15410 | + bool atomic) |
15411 | { |
15412 | kvm_pfn_t pfn; |
15413 | void *hva = NULL; |
15414 | struct page *page = KVM_UNMAPPED_PAGE; |
15415 | + struct kvm_memory_slot *slot = __gfn_to_memslot(slots, gfn); |
15416 | + u64 gen = slots->generation; |
15417 | |
15418 | if (!map) |
15419 | return -EINVAL; |
15420 | |
15421 | - pfn = gfn_to_pfn_memslot(slot, gfn); |
15422 | + if (cache) { |
15423 | + if (!cache->pfn || cache->gfn != gfn || |
15424 | + cache->generation != gen) { |
15425 | + if (atomic) |
15426 | + return -EAGAIN; |
15427 | + kvm_cache_gfn_to_pfn(slot, gfn, cache, gen); |
15428 | + } |
15429 | + pfn = cache->pfn; |
15430 | + } else { |
15431 | + if (atomic) |
15432 | + return -EAGAIN; |
15433 | + pfn = gfn_to_pfn_memslot(slot, gfn); |
15434 | + } |
15435 | if (is_error_noslot_pfn(pfn)) |
15436 | return -EINVAL; |
15437 | |
15438 | if (pfn_valid(pfn)) { |
15439 | page = pfn_to_page(pfn); |
15440 | - hva = kmap(page); |
15441 | + if (atomic) |
15442 | + hva = kmap_atomic(page); |
15443 | + else |
15444 | + hva = kmap(page); |
15445 | #ifdef CONFIG_HAS_IOMEM |
15446 | - } else { |
15447 | + } else if (!atomic) { |
15448 | hva = memremap(pfn_to_hpa(pfn), PAGE_SIZE, MEMREMAP_WB); |
15449 | + } else { |
15450 | + return -EINVAL; |
15451 | #endif |
15452 | } |
15453 | |
15454 | @@ -1843,14 +1889,25 @@ static int __kvm_map_gfn(struct kvm_memory_slot *slot, gfn_t gfn, |
15455 | return 0; |
15456 | } |
15457 | |
15458 | +int kvm_map_gfn(struct kvm_vcpu *vcpu, gfn_t gfn, struct kvm_host_map *map, |
15459 | + struct gfn_to_pfn_cache *cache, bool atomic) |
15460 | +{ |
15461 | + return __kvm_map_gfn(kvm_memslots(vcpu->kvm), gfn, map, |
15462 | + cache, atomic); |
15463 | +} |
15464 | +EXPORT_SYMBOL_GPL(kvm_map_gfn); |
15465 | + |
15466 | int kvm_vcpu_map(struct kvm_vcpu *vcpu, gfn_t gfn, struct kvm_host_map *map) |
15467 | { |
15468 | - return __kvm_map_gfn(kvm_vcpu_gfn_to_memslot(vcpu, gfn), gfn, map); |
15469 | + return __kvm_map_gfn(kvm_vcpu_memslots(vcpu), gfn, map, |
15470 | + NULL, false); |
15471 | } |
15472 | EXPORT_SYMBOL_GPL(kvm_vcpu_map); |
15473 | |
15474 | -void kvm_vcpu_unmap(struct kvm_vcpu *vcpu, struct kvm_host_map *map, |
15475 | - bool dirty) |
15476 | +static void __kvm_unmap_gfn(struct kvm_memory_slot *memslot, |
15477 | + struct kvm_host_map *map, |
15478 | + struct gfn_to_pfn_cache *cache, |
15479 | + bool dirty, bool atomic) |
15480 | { |
15481 | if (!map) |
15482 | return; |
15483 | @@ -1858,23 +1915,45 @@ void kvm_vcpu_unmap(struct kvm_vcpu *vcpu, struct kvm_host_map *map, |
15484 | if (!map->hva) |
15485 | return; |
15486 | |
15487 | - if (map->page != KVM_UNMAPPED_PAGE) |
15488 | - kunmap(map->page); |
15489 | + if (map->page != KVM_UNMAPPED_PAGE) { |
15490 | + if (atomic) |
15491 | + kunmap_atomic(map->hva); |
15492 | + else |
15493 | + kunmap(map->page); |
15494 | + } |
15495 | #ifdef CONFIG_HAS_IOMEM |
15496 | - else |
15497 | + else if (!atomic) |
15498 | memunmap(map->hva); |
15499 | + else |
15500 | + WARN_ONCE(1, "Unexpected unmapping in atomic context"); |
15501 | #endif |
15502 | |
15503 | - if (dirty) { |
15504 | - kvm_vcpu_mark_page_dirty(vcpu, map->gfn); |
15505 | - kvm_release_pfn_dirty(map->pfn); |
15506 | - } else { |
15507 | - kvm_release_pfn_clean(map->pfn); |
15508 | - } |
15509 | + if (dirty) |
15510 | + mark_page_dirty_in_slot(memslot, map->gfn); |
15511 | + |
15512 | + if (cache) |
15513 | + cache->dirty |= dirty; |
15514 | + else |
15515 | + kvm_release_pfn(map->pfn, dirty, NULL); |
15516 | |
15517 | map->hva = NULL; |
15518 | map->page = NULL; |
15519 | } |
15520 | + |
15521 | +int kvm_unmap_gfn(struct kvm_vcpu *vcpu, struct kvm_host_map *map, |
15522 | + struct gfn_to_pfn_cache *cache, bool dirty, bool atomic) |
15523 | +{ |
15524 | + __kvm_unmap_gfn(gfn_to_memslot(vcpu->kvm, map->gfn), map, |
15525 | + cache, dirty, atomic); |
15526 | + return 0; |
15527 | +} |
15528 | +EXPORT_SYMBOL_GPL(kvm_unmap_gfn); |
15529 | + |
15530 | +void kvm_vcpu_unmap(struct kvm_vcpu *vcpu, struct kvm_host_map *map, bool dirty) |
15531 | +{ |
15532 | + __kvm_unmap_gfn(kvm_vcpu_gfn_to_memslot(vcpu, map->gfn), map, NULL, |
15533 | + dirty, false); |
15534 | +} |
15535 | EXPORT_SYMBOL_GPL(kvm_vcpu_unmap); |
15536 | |
15537 | struct page *kvm_vcpu_gfn_to_page(struct kvm_vcpu *vcpu, gfn_t gfn) |