Magellan Linux

Contents of /trunk/kernel-alx/patches-5.4/0284-5.4.185-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3635 - (show annotations) (download)
Mon Oct 24 12:34:12 2022 UTC (19 months, 1 week ago) by niro
File size: 45085 byte(s)
-sync kernel patches
1 diff --git a/Makefile b/Makefile
2 index e914e1a8a7d2c..bd3bdf86b992e 100644
3 --- a/Makefile
4 +++ b/Makefile
5 @@ -1,7 +1,7 @@
6 # SPDX-License-Identifier: GPL-2.0
7 VERSION = 5
8 PATCHLEVEL = 4
9 -SUBLEVEL = 184
10 +SUBLEVEL = 185
11 EXTRAVERSION =
12 NAME = Kleptomaniac Octopus
13
14 diff --git a/arch/arm/boot/dts/aspeed-g6-pinctrl.dtsi b/arch/arm/boot/dts/aspeed-g6-pinctrl.dtsi
15 index 996e006e06c25..f310f4d3bcc7c 100644
16 --- a/arch/arm/boot/dts/aspeed-g6-pinctrl.dtsi
17 +++ b/arch/arm/boot/dts/aspeed-g6-pinctrl.dtsi
18 @@ -118,7 +118,7 @@
19 };
20
21 pinctrl_fwqspid_default: fwqspid_default {
22 - function = "FWQSPID";
23 + function = "FWSPID";
24 groups = "FWQSPID";
25 };
26
27 diff --git a/arch/arm/include/asm/spectre.h b/arch/arm/include/asm/spectre.h
28 index d1fa5607d3aa3..85f9e538fb325 100644
29 --- a/arch/arm/include/asm/spectre.h
30 +++ b/arch/arm/include/asm/spectre.h
31 @@ -25,7 +25,13 @@ enum {
32 SPECTRE_V2_METHOD_LOOP8 = BIT(__SPECTRE_V2_METHOD_LOOP8),
33 };
34
35 +#ifdef CONFIG_GENERIC_CPU_VULNERABILITIES
36 void spectre_v2_update_state(unsigned int state, unsigned int methods);
37 +#else
38 +static inline void spectre_v2_update_state(unsigned int state,
39 + unsigned int methods)
40 +{}
41 +#endif
42
43 int spectre_bhb_update_vectors(unsigned int method);
44
45 diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
46 index 94d25425b7bce..3d65fa56a0e5d 100644
47 --- a/arch/arm/kernel/entry-armv.S
48 +++ b/arch/arm/kernel/entry-armv.S
49 @@ -1043,9 +1043,9 @@ vector_bhb_loop8_\name:
50
51 @ bhb workaround
52 mov r0, #8
53 -1: b . + 4
54 +3: b . + 4
55 subs r0, r0, #1
56 - bne 1b
57 + bne 3b
58 dsb
59 isb
60 b 2b
61 diff --git a/arch/arm64/boot/dts/marvell/armada-3720-turris-mox.dts b/arch/arm64/boot/dts/marvell/armada-3720-turris-mox.dts
62 index 16e73597bb78c..2e8239d489f82 100644
63 --- a/arch/arm64/boot/dts/marvell/armada-3720-turris-mox.dts
64 +++ b/arch/arm64/boot/dts/marvell/armada-3720-turris-mox.dts
65 @@ -18,6 +18,7 @@
66
67 aliases {
68 spi0 = &spi0;
69 + ethernet0 = &eth0;
70 ethernet1 = &eth1;
71 };
72
73 @@ -137,7 +138,9 @@
74 /*
75 * U-Boot port for Turris Mox has a bug which always expects that "ranges" DT property
76 * contains exactly 2 ranges with 3 (child) address cells, 2 (parent) address cells and
77 - * 2 size cells and also expects that the second range starts at 16 MB offset. If these
78 + * 2 size cells and also expects that the second range starts at 16 MB offset. Also it
79 + * expects that first range uses same address for PCI (child) and CPU (parent) cells (so
80 + * no remapping) and that this address is the lowest from all specified ranges. If these
81 * conditions are not met then U-Boot crashes during loading kernel DTB file. PCIe address
82 * space is 128 MB long, so the best split between MEM and IO is to use fixed 16 MB window
83 * for IO and the rest 112 MB (64+32+16) for MEM, despite that maximal IO size is just 64 kB.
84 @@ -146,6 +149,9 @@
85 * https://source.denx.de/u-boot/u-boot/-/commit/cb2ddb291ee6fcbddd6d8f4ff49089dfe580f5d7
86 * https://source.denx.de/u-boot/u-boot/-/commit/c64ac3b3185aeb3846297ad7391fc6df8ecd73bf
87 * https://source.denx.de/u-boot/u-boot/-/commit/4a82fca8e330157081fc132a591ebd99ba02ee33
88 + * Bug related to requirement of same child and parent addresses for first range is fixed
89 + * in U-Boot version 2022.04 by following commit:
90 + * https://source.denx.de/u-boot/u-boot/-/commit/1fd54253bca7d43d046bba4853fe5fafd034bc17
91 */
92 #address-cells = <3>;
93 #size-cells = <2>;
94 diff --git a/arch/arm64/boot/dts/marvell/armada-37xx.dtsi b/arch/arm64/boot/dts/marvell/armada-37xx.dtsi
95 index 3d15e4ab3f53a..9405d9c619ca6 100644
96 --- a/arch/arm64/boot/dts/marvell/armada-37xx.dtsi
97 +++ b/arch/arm64/boot/dts/marvell/armada-37xx.dtsi
98 @@ -495,7 +495,7 @@
99 * (totaling 127 MiB) for MEM.
100 */
101 ranges = <0x82000000 0 0xe8000000 0 0xe8000000 0 0x07f00000 /* Port 0 MEM */
102 - 0x81000000 0 0xefff0000 0 0xefff0000 0 0x00010000>; /* Port 0 IO */
103 + 0x81000000 0 0x00000000 0 0xefff0000 0 0x00010000>; /* Port 0 IO */
104 interrupt-map-mask = <0 0 0 7>;
105 interrupt-map = <0 0 0 1 &pcie_intc 0>,
106 <0 0 0 2 &pcie_intc 1>,
107 diff --git a/arch/riscv/kernel/module.c b/arch/riscv/kernel/module.c
108 index 6bf5b16743843..a963b761e1a39 100644
109 --- a/arch/riscv/kernel/module.c
110 +++ b/arch/riscv/kernel/module.c
111 @@ -13,6 +13,19 @@
112 #include <asm/pgtable.h>
113 #include <asm/sections.h>
114
115 +/*
116 + * The auipc+jalr instruction pair can reach any PC-relative offset
117 + * in the range [-2^31 - 2^11, 2^31 - 2^11)
118 + */
119 +static bool riscv_insn_valid_32bit_offset(ptrdiff_t val)
120 +{
121 +#ifdef CONFIG_32BIT
122 + return true;
123 +#else
124 + return (-(1L << 31) - (1L << 11)) <= val && val < ((1L << 31) - (1L << 11));
125 +#endif
126 +}
127 +
128 static int apply_r_riscv_32_rela(struct module *me, u32 *location, Elf_Addr v)
129 {
130 if (v != (u32)v) {
131 @@ -95,7 +108,7 @@ static int apply_r_riscv_pcrel_hi20_rela(struct module *me, u32 *location,
132 ptrdiff_t offset = (void *)v - (void *)location;
133 s32 hi20;
134
135 - if (offset != (s32)offset) {
136 + if (!riscv_insn_valid_32bit_offset(offset)) {
137 pr_err(
138 "%s: target %016llx can not be addressed by the 32-bit offset from PC = %p\n",
139 me->name, (long long)v, location);
140 @@ -197,10 +210,9 @@ static int apply_r_riscv_call_plt_rela(struct module *me, u32 *location,
141 Elf_Addr v)
142 {
143 ptrdiff_t offset = (void *)v - (void *)location;
144 - s32 fill_v = offset;
145 u32 hi20, lo12;
146
147 - if (offset != fill_v) {
148 + if (!riscv_insn_valid_32bit_offset(offset)) {
149 /* Only emit the plt entry if offset over 32-bit range */
150 if (IS_ENABLED(CONFIG_MODULE_SECTIONS)) {
151 offset = module_emit_plt_entry(me, v);
152 @@ -224,10 +236,9 @@ static int apply_r_riscv_call_rela(struct module *me, u32 *location,
153 Elf_Addr v)
154 {
155 ptrdiff_t offset = (void *)v - (void *)location;
156 - s32 fill_v = offset;
157 u32 hi20, lo12;
158
159 - if (offset != fill_v) {
160 + if (!riscv_insn_valid_32bit_offset(offset)) {
161 pr_err(
162 "%s: target %016llx can not be addressed by the 32-bit offset from PC = %p\n",
163 me->name, (long long)v, location);
164 diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h
165 index f48905f796e9d..56eb9a6524e96 100644
166 --- a/arch/x86/include/asm/cpufeatures.h
167 +++ b/arch/x86/include/asm/cpufeatures.h
168 @@ -96,6 +96,7 @@
169 #define X86_FEATURE_SYSCALL32 ( 3*32+14) /* "" syscall in IA32 userspace */
170 #define X86_FEATURE_SYSENTER32 ( 3*32+15) /* "" sysenter in IA32 userspace */
171 #define X86_FEATURE_REP_GOOD ( 3*32+16) /* REP microcode works well */
172 +#define X86_FEATURE_SME_COHERENT ( 3*32+17) /* "" AMD hardware-enforced cache coherency */
173 #define X86_FEATURE_LFENCE_RDTSC ( 3*32+18) /* "" LFENCE synchronizes RDTSC */
174 #define X86_FEATURE_ACC_POWER ( 3*32+19) /* AMD Accumulated Power Mechanism */
175 #define X86_FEATURE_NOPL ( 3*32+20) /* The NOPL (0F 1F) instructions */
176 @@ -107,6 +108,7 @@
177 #define X86_FEATURE_EXTD_APICID ( 3*32+26) /* Extended APICID (8 bits) */
178 #define X86_FEATURE_AMD_DCM ( 3*32+27) /* AMD multi-node processor */
179 #define X86_FEATURE_APERFMPERF ( 3*32+28) /* P-State hardware coordination feedback capability (APERF/MPERF MSRs) */
180 +/* free ( 3*32+29) */
181 #define X86_FEATURE_NONSTOP_TSC_S3 ( 3*32+30) /* TSC doesn't stop in S3 state */
182 #define X86_FEATURE_TSC_KNOWN_FREQ ( 3*32+31) /* TSC has known frequency */
183
184 diff --git a/arch/x86/kernel/cpu/scattered.c b/arch/x86/kernel/cpu/scattered.c
185 index adf9b71386eff..53004dbd55c47 100644
186 --- a/arch/x86/kernel/cpu/scattered.c
187 +++ b/arch/x86/kernel/cpu/scattered.c
188 @@ -41,6 +41,7 @@ static const struct cpuid_bit cpuid_bits[] = {
189 { X86_FEATURE_MBA, CPUID_EBX, 6, 0x80000008, 0 },
190 { X86_FEATURE_SME, CPUID_EAX, 0, 0x8000001f, 0 },
191 { X86_FEATURE_SEV, CPUID_EAX, 1, 0x8000001f, 0 },
192 + { X86_FEATURE_SME_COHERENT, CPUID_EAX, 10, 0x8000001f, 0 },
193 { 0, 0, 0, 0, 0 }
194 };
195
196 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
197 index 2f84509f28289..125970286f289 100644
198 --- a/arch/x86/kvm/svm.c
199 +++ b/arch/x86/kvm/svm.c
200 @@ -1904,7 +1904,8 @@ static void sev_clflush_pages(struct page *pages[], unsigned long npages)
201 uint8_t *page_virtual;
202 unsigned long i;
203
204 - if (npages == 0 || pages == NULL)
205 + if (this_cpu_has(X86_FEATURE_SME_COHERENT) || npages == 0 ||
206 + pages == NULL)
207 return;
208
209 for (i = 0; i < npages; i++) {
210 diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
211 index 281e584cfe39e..d61313f5c5b98 100644
212 --- a/arch/x86/mm/pageattr.c
213 +++ b/arch/x86/mm/pageattr.c
214 @@ -1967,7 +1967,7 @@ static int __set_memory_enc_dec(unsigned long addr, int numpages, bool enc)
215 /*
216 * Before changing the encryption attribute, we need to flush caches.
217 */
218 - cpa_flush(&cpa, 1);
219 + cpa_flush(&cpa, !this_cpu_has(X86_FEATURE_SME_COHERENT));
220
221 ret = __change_page_attr_set_clr(&cpa, 1);
222
223 diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
224 index 816eb2db73080..4b3645e648ee9 100644
225 --- a/drivers/block/virtio_blk.c
226 +++ b/drivers/block/virtio_blk.c
227 @@ -980,9 +980,15 @@ static int virtblk_probe(struct virtio_device *vdev)
228
229 virtio_cread(vdev, struct virtio_blk_config, max_discard_seg,
230 &v);
231 +
232 + /*
233 + * max_discard_seg == 0 is out of spec but we always
234 + * handled it.
235 + */
236 + if (!v)
237 + v = sg_elems - 2;
238 blk_queue_max_discard_segments(q,
239 - min_not_zero(v,
240 - MAX_DISCARD_SEGMENTS));
241 + min(v, MAX_DISCARD_SEGMENTS));
242
243 blk_queue_flag_set(QUEUE_FLAG_DISCARD, q);
244 }
245 diff --git a/drivers/clk/qcom/gdsc.c b/drivers/clk/qcom/gdsc.c
246 index a250f59708d85..888965bb93edf 100644
247 --- a/drivers/clk/qcom/gdsc.c
248 +++ b/drivers/clk/qcom/gdsc.c
249 @@ -1,6 +1,6 @@
250 // SPDX-License-Identifier: GPL-2.0-only
251 /*
252 - * Copyright (c) 2015, 2017-2018, The Linux Foundation. All rights reserved.
253 + * Copyright (c) 2015, 2017-2018, 2022, The Linux Foundation. All rights reserved.
254 */
255
256 #include <linux/bitops.h>
257 @@ -31,9 +31,14 @@
258 #define CFG_GDSCR_OFFSET 0x4
259
260 /* Wait 2^n CXO cycles between all states. Here, n=2 (4 cycles). */
261 -#define EN_REST_WAIT_VAL (0x2 << 20)
262 -#define EN_FEW_WAIT_VAL (0x8 << 16)
263 -#define CLK_DIS_WAIT_VAL (0x2 << 12)
264 +#define EN_REST_WAIT_VAL 0x2
265 +#define EN_FEW_WAIT_VAL 0x8
266 +#define CLK_DIS_WAIT_VAL 0x2
267 +
268 +/* Transition delay shifts */
269 +#define EN_REST_WAIT_SHIFT 20
270 +#define EN_FEW_WAIT_SHIFT 16
271 +#define CLK_DIS_WAIT_SHIFT 12
272
273 #define RETAIN_MEM BIT(14)
274 #define RETAIN_PERIPH BIT(13)
275 @@ -308,7 +313,18 @@ static int gdsc_init(struct gdsc *sc)
276 */
277 mask = HW_CONTROL_MASK | SW_OVERRIDE_MASK |
278 EN_REST_WAIT_MASK | EN_FEW_WAIT_MASK | CLK_DIS_WAIT_MASK;
279 - val = EN_REST_WAIT_VAL | EN_FEW_WAIT_VAL | CLK_DIS_WAIT_VAL;
280 +
281 + if (!sc->en_rest_wait_val)
282 + sc->en_rest_wait_val = EN_REST_WAIT_VAL;
283 + if (!sc->en_few_wait_val)
284 + sc->en_few_wait_val = EN_FEW_WAIT_VAL;
285 + if (!sc->clk_dis_wait_val)
286 + sc->clk_dis_wait_val = CLK_DIS_WAIT_VAL;
287 +
288 + val = sc->en_rest_wait_val << EN_REST_WAIT_SHIFT |
289 + sc->en_few_wait_val << EN_FEW_WAIT_SHIFT |
290 + sc->clk_dis_wait_val << CLK_DIS_WAIT_SHIFT;
291 +
292 ret = regmap_update_bits(sc->regmap, sc->gdscr, mask, val);
293 if (ret)
294 return ret;
295 diff --git a/drivers/clk/qcom/gdsc.h b/drivers/clk/qcom/gdsc.h
296 index 64cdc8cf0d4d2..907396ccb83fb 100644
297 --- a/drivers/clk/qcom/gdsc.h
298 +++ b/drivers/clk/qcom/gdsc.h
299 @@ -1,6 +1,6 @@
300 /* SPDX-License-Identifier: GPL-2.0-only */
301 /*
302 - * Copyright (c) 2015, 2017-2018, The Linux Foundation. All rights reserved.
303 + * Copyright (c) 2015, 2017-2018, 2022, The Linux Foundation. All rights reserved.
304 */
305
306 #ifndef __QCOM_GDSC_H__
307 @@ -21,6 +21,9 @@ struct reset_controller_dev;
308 * @cxcs: offsets of branch registers to toggle mem/periph bits in
309 * @cxc_count: number of @cxcs
310 * @pwrsts: Possible powerdomain power states
311 + * @en_rest_wait_val: transition delay value for receiving enr ack signal
312 + * @en_few_wait_val: transition delay value for receiving enf ack signal
313 + * @clk_dis_wait_val: transition delay value for halting clock
314 * @resets: ids of resets associated with this gdsc
315 * @reset_count: number of @resets
316 * @rcdev: reset controller
317 @@ -34,6 +37,9 @@ struct gdsc {
318 unsigned int clamp_io_ctrl;
319 unsigned int *cxcs;
320 unsigned int cxc_count;
321 + unsigned int en_rest_wait_val;
322 + unsigned int en_few_wait_val;
323 + unsigned int clk_dis_wait_val;
324 const u8 pwrsts;
325 /* Powerdomain allowable state bitfields */
326 #define PWRSTS_OFF BIT(0)
327 diff --git a/drivers/gpio/gpio-ts4900.c b/drivers/gpio/gpio-ts4900.c
328 index 1da8d05863295..410452306bf7b 100644
329 --- a/drivers/gpio/gpio-ts4900.c
330 +++ b/drivers/gpio/gpio-ts4900.c
331 @@ -1,7 +1,7 @@
332 /*
333 * Digital I/O driver for Technologic Systems I2C FPGA Core
334 *
335 - * Copyright (C) 2015 Technologic Systems
336 + * Copyright (C) 2015, 2018 Technologic Systems
337 * Copyright (C) 2016 Savoir-Faire Linux
338 *
339 * This program is free software; you can redistribute it and/or
340 @@ -52,19 +52,33 @@ static int ts4900_gpio_direction_input(struct gpio_chip *chip,
341 {
342 struct ts4900_gpio_priv *priv = gpiochip_get_data(chip);
343
344 - /*
345 - * This will clear the output enable bit, the other bits are
346 - * dontcare when this is cleared
347 + /* Only clear the OE bit here, requires a RMW. Prevents potential issue
348 + * with OE and data getting to the physical pin at different times.
349 */
350 - return regmap_write(priv->regmap, offset, 0);
351 + return regmap_update_bits(priv->regmap, offset, TS4900_GPIO_OE, 0);
352 }
353
354 static int ts4900_gpio_direction_output(struct gpio_chip *chip,
355 unsigned int offset, int value)
356 {
357 struct ts4900_gpio_priv *priv = gpiochip_get_data(chip);
358 + unsigned int reg;
359 int ret;
360
361 + /* If changing from an input to an output, we need to first set the
362 + * proper data bit to what is requested and then set OE bit. This
363 + * prevents a glitch that can occur on the IO line
364 + */
365 + regmap_read(priv->regmap, offset, &reg);
366 + if (!(reg & TS4900_GPIO_OE)) {
367 + if (value)
368 + reg = TS4900_GPIO_OUT;
369 + else
370 + reg &= ~TS4900_GPIO_OUT;
371 +
372 + regmap_write(priv->regmap, offset, reg);
373 + }
374 +
375 if (value)
376 ret = regmap_write(priv->regmap, offset, TS4900_GPIO_OE |
377 TS4900_GPIO_OUT);
378 diff --git a/drivers/gpu/drm/sun4i/sun8i_mixer.h b/drivers/gpu/drm/sun4i/sun8i_mixer.h
379 index 345b28b0a80a1..dc4300a7b019b 100644
380 --- a/drivers/gpu/drm/sun4i/sun8i_mixer.h
381 +++ b/drivers/gpu/drm/sun4i/sun8i_mixer.h
382 @@ -114,10 +114,10 @@
383 /* format 13 is semi-planar YUV411 VUVU */
384 #define SUN8I_MIXER_FBFMT_YUV411 14
385 /* format 15 doesn't exist */
386 -/* format 16 is P010 YVU */
387 -#define SUN8I_MIXER_FBFMT_P010_YUV 17
388 -/* format 18 is P210 YVU */
389 -#define SUN8I_MIXER_FBFMT_P210_YUV 19
390 +#define SUN8I_MIXER_FBFMT_P010_YUV 16
391 +/* format 17 is P010 YVU */
392 +#define SUN8I_MIXER_FBFMT_P210_YUV 18
393 +/* format 19 is P210 YVU */
394 /* format 20 is packed YVU444 10-bit */
395 /* format 21 is packed YUV444 10-bit */
396
397 diff --git a/drivers/mmc/host/meson-gx-mmc.c b/drivers/mmc/host/meson-gx-mmc.c
398 index cdd57ce55b2fa..9044faf0050a1 100644
399 --- a/drivers/mmc/host/meson-gx-mmc.c
400 +++ b/drivers/mmc/host/meson-gx-mmc.c
401 @@ -174,6 +174,8 @@ struct meson_host {
402 int irq;
403
404 bool vqmmc_enabled;
405 + bool needs_pre_post_req;
406 +
407 };
408
409 #define CMD_CFG_LENGTH_MASK GENMASK(8, 0)
410 @@ -655,6 +657,8 @@ static void meson_mmc_request_done(struct mmc_host *mmc,
411 struct meson_host *host = mmc_priv(mmc);
412
413 host->cmd = NULL;
414 + if (host->needs_pre_post_req)
415 + meson_mmc_post_req(mmc, mrq, 0);
416 mmc_request_done(host->mmc, mrq);
417 }
418
419 @@ -872,7 +876,7 @@ static int meson_mmc_validate_dram_access(struct mmc_host *mmc, struct mmc_data
420 static void meson_mmc_request(struct mmc_host *mmc, struct mmc_request *mrq)
421 {
422 struct meson_host *host = mmc_priv(mmc);
423 - bool needs_pre_post_req = mrq->data &&
424 + host->needs_pre_post_req = mrq->data &&
425 !(mrq->data->host_cookie & SD_EMMC_PRE_REQ_DONE);
426
427 /*
428 @@ -888,22 +892,19 @@ static void meson_mmc_request(struct mmc_host *mmc, struct mmc_request *mrq)
429 }
430 }
431
432 - if (needs_pre_post_req) {
433 + if (host->needs_pre_post_req) {
434 meson_mmc_get_transfer_mode(mmc, mrq);
435 if (!meson_mmc_desc_chain_mode(mrq->data))
436 - needs_pre_post_req = false;
437 + host->needs_pre_post_req = false;
438 }
439
440 - if (needs_pre_post_req)
441 + if (host->needs_pre_post_req)
442 meson_mmc_pre_req(mmc, mrq);
443
444 /* Stop execution */
445 writel(0, host->regs + SD_EMMC_START);
446
447 meson_mmc_start_cmd(mmc, mrq->sbc ?: mrq->cmd);
448 -
449 - if (needs_pre_post_req)
450 - meson_mmc_post_req(mmc, mrq, 0);
451 }
452
453 static void meson_mmc_read_resp(struct mmc_host *mmc, struct mmc_command *cmd)
454 diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c b/drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c
455 index 164988f3b4fab..a2da09da4907b 100644
456 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c
457 +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c
458 @@ -41,6 +41,13 @@
459 void bcmgenet_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
460 {
461 struct bcmgenet_priv *priv = netdev_priv(dev);
462 + struct device *kdev = &priv->pdev->dev;
463 +
464 + if (!device_can_wakeup(kdev)) {
465 + wol->supported = 0;
466 + wol->wolopts = 0;
467 + return;
468 + }
469
470 wol->supported = WAKE_MAGIC | WAKE_MAGICSECURE;
471 wol->wolopts = priv->wolopts;
472 diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
473 index 0dc52cf5367e7..480d2ca369e6b 100644
474 --- a/drivers/net/ethernet/cadence/macb_main.c
475 +++ b/drivers/net/ethernet/cadence/macb_main.c
476 @@ -1283,7 +1283,14 @@ static int macb_poll(struct napi_struct *napi, int budget)
477 if (work_done < budget) {
478 napi_complete_done(napi, work_done);
479
480 - /* Packets received while interrupts were disabled */
481 + /* RSR bits only seem to propagate to raise interrupts when
482 + * interrupts are enabled at the time, so if bits are already
483 + * set due to packets received while interrupts were disabled,
484 + * they will not cause another interrupt to be generated when
485 + * interrupts are re-enabled.
486 + * Check for this case here. This has been seen to happen
487 + * around 30% of the time under heavy network load.
488 + */
489 status = macb_readl(bp, RSR);
490 if (status) {
491 if (bp->caps & MACB_CAPS_ISR_CLEAR_ON_WRITE)
492 @@ -1291,6 +1298,22 @@ static int macb_poll(struct napi_struct *napi, int budget)
493 napi_reschedule(napi);
494 } else {
495 queue_writel(queue, IER, bp->rx_intr_mask);
496 +
497 + /* In rare cases, packets could have been received in
498 + * the window between the check above and re-enabling
499 + * interrupts. Therefore, a double-check is required
500 + * to avoid losing a wakeup. This can potentially race
501 + * with the interrupt handler doing the same actions
502 + * if an interrupt is raised just after enabling them,
503 + * but this should be harmless.
504 + */
505 + status = macb_readl(bp, RSR);
506 + if (unlikely(status)) {
507 + queue_writel(queue, IDR, bp->rx_intr_mask);
508 + if (bp->caps & MACB_CAPS_ISR_CLEAR_ON_WRITE)
509 + queue_writel(queue, ISR, MACB_BIT(RCOMP));
510 + napi_schedule(napi);
511 + }
512 }
513 }
514
515 diff --git a/drivers/net/ethernet/freescale/gianfar_ethtool.c b/drivers/net/ethernet/freescale/gianfar_ethtool.c
516 index 3c8e4e2efc070..01a7255e86c92 100644
517 --- a/drivers/net/ethernet/freescale/gianfar_ethtool.c
518 +++ b/drivers/net/ethernet/freescale/gianfar_ethtool.c
519 @@ -1489,6 +1489,7 @@ static int gfar_get_ts_info(struct net_device *dev,
520 ptp_node = of_find_compatible_node(NULL, NULL, "fsl,etsec-ptp");
521 if (ptp_node) {
522 ptp_dev = of_find_device_by_node(ptp_node);
523 + of_node_put(ptp_node);
524 if (ptp_dev)
525 ptp = platform_get_drvdata(ptp_dev);
526 }
527 diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
528 index 1a7aa078f3510..6c7b364d0bf03 100644
529 --- a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
530 +++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
531 @@ -130,11 +130,8 @@ static int cmd_alloc_index(struct mlx5_cmd *cmd)
532
533 static void cmd_free_index(struct mlx5_cmd *cmd, int idx)
534 {
535 - unsigned long flags;
536 -
537 - spin_lock_irqsave(&cmd->alloc_lock, flags);
538 + lockdep_assert_held(&cmd->alloc_lock);
539 set_bit(idx, &cmd->bitmask);
540 - spin_unlock_irqrestore(&cmd->alloc_lock, flags);
541 }
542
543 static void cmd_ent_get(struct mlx5_cmd_work_ent *ent)
544 @@ -144,17 +141,21 @@ static void cmd_ent_get(struct mlx5_cmd_work_ent *ent)
545
546 static void cmd_ent_put(struct mlx5_cmd_work_ent *ent)
547 {
548 + struct mlx5_cmd *cmd = ent->cmd;
549 + unsigned long flags;
550 +
551 + spin_lock_irqsave(&cmd->alloc_lock, flags);
552 if (!refcount_dec_and_test(&ent->refcnt))
553 - return;
554 + goto out;
555
556 if (ent->idx >= 0) {
557 - struct mlx5_cmd *cmd = ent->cmd;
558 -
559 cmd_free_index(cmd, ent->idx);
560 up(ent->page_queue ? &cmd->pages_sem : &cmd->sem);
561 }
562
563 cmd_free_ent(ent);
564 +out:
565 + spin_unlock_irqrestore(&cmd->alloc_lock, flags);
566 }
567
568 static struct mlx5_cmd_layout *get_inst(struct mlx5_cmd *cmd, int idx)
569 diff --git a/drivers/net/ethernet/nxp/lpc_eth.c b/drivers/net/ethernet/nxp/lpc_eth.c
570 index 3b177421651f1..d2e220a94a57c 100644
571 --- a/drivers/net/ethernet/nxp/lpc_eth.c
572 +++ b/drivers/net/ethernet/nxp/lpc_eth.c
573 @@ -1470,6 +1470,7 @@ static int lpc_eth_drv_resume(struct platform_device *pdev)
574 {
575 struct net_device *ndev = platform_get_drvdata(pdev);
576 struct netdata_local *pldat;
577 + int ret;
578
579 if (device_may_wakeup(&pdev->dev))
580 disable_irq_wake(ndev->irq);
581 @@ -1479,7 +1480,9 @@ static int lpc_eth_drv_resume(struct platform_device *pdev)
582 pldat = netdev_priv(ndev);
583
584 /* Enable interface clock */
585 - clk_enable(pldat->clk);
586 + ret = clk_enable(pldat->clk);
587 + if (ret)
588 + return ret;
589
590 /* Reset and initialize */
591 __lpc_eth_reset(pldat);
592 diff --git a/drivers/net/ethernet/qlogic/qed/qed_sriov.c b/drivers/net/ethernet/qlogic/qed/qed_sriov.c
593 index fb9c3ca5d36cc..5e8f8eb916e64 100644
594 --- a/drivers/net/ethernet/qlogic/qed/qed_sriov.c
595 +++ b/drivers/net/ethernet/qlogic/qed/qed_sriov.c
596 @@ -3801,11 +3801,11 @@ bool qed_iov_mark_vf_flr(struct qed_hwfn *p_hwfn, u32 *p_disabled_vfs)
597 return found;
598 }
599
600 -static void qed_iov_get_link(struct qed_hwfn *p_hwfn,
601 - u16 vfid,
602 - struct qed_mcp_link_params *p_params,
603 - struct qed_mcp_link_state *p_link,
604 - struct qed_mcp_link_capabilities *p_caps)
605 +static int qed_iov_get_link(struct qed_hwfn *p_hwfn,
606 + u16 vfid,
607 + struct qed_mcp_link_params *p_params,
608 + struct qed_mcp_link_state *p_link,
609 + struct qed_mcp_link_capabilities *p_caps)
610 {
611 struct qed_vf_info *p_vf = qed_iov_get_vf_info(p_hwfn,
612 vfid,
613 @@ -3813,7 +3813,7 @@ static void qed_iov_get_link(struct qed_hwfn *p_hwfn,
614 struct qed_bulletin_content *p_bulletin;
615
616 if (!p_vf)
617 - return;
618 + return -EINVAL;
619
620 p_bulletin = p_vf->bulletin.p_virt;
621
622 @@ -3823,6 +3823,7 @@ static void qed_iov_get_link(struct qed_hwfn *p_hwfn,
623 __qed_vf_get_link_state(p_hwfn, p_link, p_bulletin);
624 if (p_caps)
625 __qed_vf_get_link_caps(p_hwfn, p_caps, p_bulletin);
626 + return 0;
627 }
628
629 static int
630 @@ -4684,6 +4685,7 @@ static int qed_get_vf_config(struct qed_dev *cdev,
631 struct qed_public_vf_info *vf_info;
632 struct qed_mcp_link_state link;
633 u32 tx_rate;
634 + int ret;
635
636 /* Sanitize request */
637 if (IS_VF(cdev))
638 @@ -4697,7 +4699,9 @@ static int qed_get_vf_config(struct qed_dev *cdev,
639
640 vf_info = qed_iov_get_public_vf_info(hwfn, vf_id, true);
641
642 - qed_iov_get_link(hwfn, vf_id, NULL, &link, NULL);
643 + ret = qed_iov_get_link(hwfn, vf_id, NULL, &link, NULL);
644 + if (ret)
645 + return ret;
646
647 /* Fill information about VF */
648 ivi->vf = vf_id;
649 diff --git a/drivers/net/ethernet/qlogic/qed/qed_vf.c b/drivers/net/ethernet/qlogic/qed/qed_vf.c
650 index adc2c8f3d48ef..62e4511db8575 100644
651 --- a/drivers/net/ethernet/qlogic/qed/qed_vf.c
652 +++ b/drivers/net/ethernet/qlogic/qed/qed_vf.c
653 @@ -539,6 +539,9 @@ int qed_vf_hw_prepare(struct qed_hwfn *p_hwfn)
654 p_iov->bulletin.size,
655 &p_iov->bulletin.phys,
656 GFP_KERNEL);
657 + if (!p_iov->bulletin.p_virt)
658 + goto free_pf2vf_reply;
659 +
660 DP_VERBOSE(p_hwfn, QED_MSG_IOV,
661 "VF's bulletin Board [%p virt 0x%llx phys 0x%08x bytes]\n",
662 p_iov->bulletin.p_virt,
663 @@ -578,6 +581,10 @@ int qed_vf_hw_prepare(struct qed_hwfn *p_hwfn)
664
665 return rc;
666
667 +free_pf2vf_reply:
668 + dma_free_coherent(&p_hwfn->cdev->pdev->dev,
669 + sizeof(union pfvf_tlvs),
670 + p_iov->pf2vf_reply, p_iov->pf2vf_reply_phys);
671 free_vf2pf_request:
672 dma_free_coherent(&p_hwfn->cdev->pdev->dev,
673 sizeof(union vfpf_tlvs),
674 diff --git a/drivers/net/ethernet/ti/cpts.c b/drivers/net/ethernet/ti/cpts.c
675 index 26cfe3f7ed8df..453ad1247288d 100644
676 --- a/drivers/net/ethernet/ti/cpts.c
677 +++ b/drivers/net/ethernet/ti/cpts.c
678 @@ -454,7 +454,9 @@ int cpts_register(struct cpts *cpts)
679 for (i = 0; i < CPTS_MAX_EVENTS; i++)
680 list_add(&cpts->pool_data[i].list, &cpts->pool);
681
682 - clk_enable(cpts->refclk);
683 + err = clk_enable(cpts->refclk);
684 + if (err)
685 + return err;
686
687 cpts_write32(cpts, CPTS_EN, control);
688 cpts_write32(cpts, TS_PEND_EN, int_enable);
689 diff --git a/drivers/net/ethernet/xilinx/xilinx_emaclite.c b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
690 index 53dbf3e28f1ef..63a2d1bcccfbc 100644
691 --- a/drivers/net/ethernet/xilinx/xilinx_emaclite.c
692 +++ b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
693 @@ -1187,7 +1187,7 @@ static int xemaclite_of_probe(struct platform_device *ofdev)
694 if (rc) {
695 dev_err(dev,
696 "Cannot register network device, aborting\n");
697 - goto error;
698 + goto put_node;
699 }
700
701 dev_info(dev,
702 @@ -1195,6 +1195,8 @@ static int xemaclite_of_probe(struct platform_device *ofdev)
703 (unsigned int __force)ndev->mem_start, lp->base_addr, ndev->irq);
704 return 0;
705
706 +put_node:
707 + of_node_put(lp->phy_node);
708 error:
709 free_netdev(ndev);
710 return rc;
711 diff --git a/drivers/net/phy/dp83822.c b/drivers/net/phy/dp83822.c
712 index 8a4b1d167ce2f..ae17d2f9d5347 100644
713 --- a/drivers/net/phy/dp83822.c
714 +++ b/drivers/net/phy/dp83822.c
715 @@ -238,7 +238,7 @@ static int dp83822_config_intr(struct phy_device *phydev)
716 if (err < 0)
717 return err;
718
719 - err = phy_write(phydev, MII_DP83822_MISR1, 0);
720 + err = phy_write(phydev, MII_DP83822_MISR2, 0);
721 if (err < 0)
722 return err;
723
724 diff --git a/drivers/net/xen-netback/xenbus.c b/drivers/net/xen-netback/xenbus.c
725 index 416305e6d0932..44e353dd2ba19 100644
726 --- a/drivers/net/xen-netback/xenbus.c
727 +++ b/drivers/net/xen-netback/xenbus.c
728 @@ -435,6 +435,7 @@ static void backend_disconnect(struct backend_info *be)
729 unsigned int queue_index;
730
731 xen_unregister_watchers(vif);
732 + xenbus_rm(XBT_NIL, be->dev->nodename, "hotplug-status");
733 #ifdef CONFIG_DEBUG_FS
734 xenvif_debugfs_delif(vif);
735 #endif /* CONFIG_DEBUG_FS */
736 @@ -979,15 +980,11 @@ static void connect(struct backend_info *be)
737 xenvif_carrier_on(be->vif);
738
739 unregister_hotplug_status_watch(be);
740 - if (xenbus_exists(XBT_NIL, dev->nodename, "hotplug-status")) {
741 - err = xenbus_watch_pathfmt(dev, &be->hotplug_status_watch,
742 - NULL, hotplug_status_changed,
743 - "%s/%s", dev->nodename,
744 - "hotplug-status");
745 - if (err)
746 - goto err;
747 + err = xenbus_watch_pathfmt(dev, &be->hotplug_status_watch, NULL,
748 + hotplug_status_changed,
749 + "%s/%s", dev->nodename, "hotplug-status");
750 + if (!err)
751 be->have_hotplug_status_watch = 1;
752 - }
753
754 netif_tx_wake_all_queues(be->vif->dev);
755
756 diff --git a/drivers/nfc/port100.c b/drivers/nfc/port100.c
757 index 1caebefb25ff1..2ae1474faede9 100644
758 --- a/drivers/nfc/port100.c
759 +++ b/drivers/nfc/port100.c
760 @@ -1609,7 +1609,9 @@ free_nfc_dev:
761 nfc_digital_free_device(dev->nfc_digital_dev);
762
763 error:
764 + usb_kill_urb(dev->in_urb);
765 usb_free_urb(dev->in_urb);
766 + usb_kill_urb(dev->out_urb);
767 usb_free_urb(dev->out_urb);
768 usb_put_dev(dev->udev);
769
770 diff --git a/drivers/staging/gdm724x/gdm_lte.c b/drivers/staging/gdm724x/gdm_lte.c
771 index 8093d06086388..4dba62aed10b8 100644
772 --- a/drivers/staging/gdm724x/gdm_lte.c
773 +++ b/drivers/staging/gdm724x/gdm_lte.c
774 @@ -76,14 +76,15 @@ static void tx_complete(void *arg)
775
776 static int gdm_lte_rx(struct sk_buff *skb, struct nic *nic, int nic_type)
777 {
778 - int ret;
779 + int ret, len;
780
781 + len = skb->len + ETH_HLEN;
782 ret = netif_rx_ni(skb);
783 if (ret == NET_RX_DROP) {
784 nic->stats.rx_dropped++;
785 } else {
786 nic->stats.rx_packets++;
787 - nic->stats.rx_bytes += skb->len + ETH_HLEN;
788 + nic->stats.rx_bytes += len;
789 }
790
791 return 0;
792 diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c
793 index 91627e7443260..cab97cda54304 100644
794 --- a/drivers/virtio/virtio.c
795 +++ b/drivers/virtio/virtio.c
796 @@ -167,14 +167,12 @@ void virtio_add_status(struct virtio_device *dev, unsigned int status)
797 }
798 EXPORT_SYMBOL_GPL(virtio_add_status);
799
800 -int virtio_finalize_features(struct virtio_device *dev)
801 +/* Do some validation, then set FEATURES_OK */
802 +static int virtio_features_ok(struct virtio_device *dev)
803 {
804 - int ret = dev->config->finalize_features(dev);
805 unsigned status;
806
807 might_sleep();
808 - if (ret)
809 - return ret;
810
811 if (!virtio_has_feature(dev, VIRTIO_F_VERSION_1))
812 return 0;
813 @@ -188,7 +186,6 @@ int virtio_finalize_features(struct virtio_device *dev)
814 }
815 return 0;
816 }
817 -EXPORT_SYMBOL_GPL(virtio_finalize_features);
818
819 static int virtio_dev_probe(struct device *_d)
820 {
821 @@ -225,17 +222,6 @@ static int virtio_dev_probe(struct device *_d)
822 driver_features_legacy = driver_features;
823 }
824
825 - /*
826 - * Some devices detect legacy solely via F_VERSION_1. Write
827 - * F_VERSION_1 to force LE config space accesses before FEATURES_OK for
828 - * these when needed.
829 - */
830 - if (drv->validate && !virtio_legacy_is_little_endian()
831 - && device_features & BIT_ULL(VIRTIO_F_VERSION_1)) {
832 - dev->features = BIT_ULL(VIRTIO_F_VERSION_1);
833 - dev->config->finalize_features(dev);
834 - }
835 -
836 if (device_features & (1ULL << VIRTIO_F_VERSION_1))
837 dev->features = driver_features & device_features;
838 else
839 @@ -246,13 +232,26 @@ static int virtio_dev_probe(struct device *_d)
840 if (device_features & (1ULL << i))
841 __virtio_set_bit(dev, i);
842
843 + err = dev->config->finalize_features(dev);
844 + if (err)
845 + goto err;
846 +
847 if (drv->validate) {
848 + u64 features = dev->features;
849 +
850 err = drv->validate(dev);
851 if (err)
852 goto err;
853 +
854 + /* Did validation change any features? Then write them again. */
855 + if (features != dev->features) {
856 + err = dev->config->finalize_features(dev);
857 + if (err)
858 + goto err;
859 + }
860 }
861
862 - err = virtio_finalize_features(dev);
863 + err = virtio_features_ok(dev);
864 if (err)
865 goto err;
866
867 @@ -417,7 +416,11 @@ int virtio_device_restore(struct virtio_device *dev)
868 /* We have a driver! */
869 virtio_add_status(dev, VIRTIO_CONFIG_S_DRIVER);
870
871 - ret = virtio_finalize_features(dev);
872 + ret = dev->config->finalize_features(dev);
873 + if (ret)
874 + goto err;
875 +
876 + ret = virtio_features_ok(dev);
877 if (ret)
878 goto err;
879
880 diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
881 index ad1d4c8faf449..b7f20196439a2 100644
882 --- a/fs/ext4/resize.c
883 +++ b/fs/ext4/resize.c
884 @@ -74,6 +74,11 @@ int ext4_resize_begin(struct super_block *sb)
885 return -EPERM;
886 }
887
888 + if (ext4_has_feature_sparse_super2(sb)) {
889 + ext4_msg(sb, KERN_ERR, "Online resizing not supported with sparse_super2");
890 + return -EOPNOTSUPP;
891 + }
892 +
893 if (test_and_set_bit_lock(EXT4_FLAGS_RESIZING,
894 &EXT4_SB(sb)->s_ext4_flags))
895 ret = -EBUSY;
896 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
897 index 64d6c8c9f1ff2..ac6a8da340139 100644
898 --- a/fs/fuse/dev.c
899 +++ b/fs/fuse/dev.c
900 @@ -933,7 +933,17 @@ static int fuse_copy_page(struct fuse_copy_state *cs, struct page **pagep,
901
902 while (count) {
903 if (cs->write && cs->pipebufs && page) {
904 - return fuse_ref_page(cs, page, offset, count);
905 + /*
906 + * Can't control lifetime of pipe buffers, so always
907 + * copy user pages.
908 + */
909 + if (cs->req->args->user_pages) {
910 + err = fuse_copy_fill(cs);
911 + if (err)
912 + return err;
913 + } else {
914 + return fuse_ref_page(cs, page, offset, count);
915 + }
916 } else if (!cs->len) {
917 if (cs->move_pages && page &&
918 offset == 0 && count == PAGE_SIZE) {
919 diff --git a/fs/fuse/file.c b/fs/fuse/file.c
920 index 5cf13196ce69e..efb2a48712919 100644
921 --- a/fs/fuse/file.c
922 +++ b/fs/fuse/file.c
923 @@ -1433,6 +1433,7 @@ static int fuse_get_user_pages(struct fuse_args_pages *ap, struct iov_iter *ii,
924 (PAGE_SIZE - ret) & (PAGE_SIZE - 1);
925 }
926
927 + ap->args.user_pages = true;
928 if (write)
929 ap->args.in_pages = 1;
930 else
931 diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
932 index d878926485451..83c2855bc7406 100644
933 --- a/fs/fuse/fuse_i.h
934 +++ b/fs/fuse/fuse_i.h
935 @@ -248,6 +248,7 @@ struct fuse_args {
936 bool nocreds:1;
937 bool in_pages:1;
938 bool out_pages:1;
939 + bool user_pages:1;
940 bool out_argvar:1;
941 bool page_zeroing:1;
942 bool page_replace:1;
943 diff --git a/include/linux/mlx5/mlx5_ifc.h b/include/linux/mlx5/mlx5_ifc.h
944 index 641a01bc5f6f7..031022e326356 100644
945 --- a/include/linux/mlx5/mlx5_ifc.h
946 +++ b/include/linux/mlx5/mlx5_ifc.h
947 @@ -8975,8 +8975,8 @@ struct mlx5_ifc_bufferx_reg_bits {
948 u8 reserved_at_0[0x6];
949 u8 lossy[0x1];
950 u8 epsb[0x1];
951 - u8 reserved_at_8[0xc];
952 - u8 size[0xc];
953 + u8 reserved_at_8[0x8];
954 + u8 size[0x10];
955
956 u8 xoff_threshold[0x10];
957 u8 xon_threshold[0x10];
958 diff --git a/include/linux/virtio.h b/include/linux/virtio.h
959 index 7c075463c7f2b..b80376654a604 100644
960 --- a/include/linux/virtio.h
961 +++ b/include/linux/virtio.h
962 @@ -135,7 +135,6 @@ void virtio_break_device(struct virtio_device *dev);
963 void virtio_config_changed(struct virtio_device *dev);
964 void virtio_config_disable(struct virtio_device *dev);
965 void virtio_config_enable(struct virtio_device *dev);
966 -int virtio_finalize_features(struct virtio_device *dev);
967 #ifdef CONFIG_PM_SLEEP
968 int virtio_device_freeze(struct virtio_device *dev);
969 int virtio_device_restore(struct virtio_device *dev);
970 diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h
971 index bb4cc49107503..ad4d4697a1673 100644
972 --- a/include/linux/virtio_config.h
973 +++ b/include/linux/virtio_config.h
974 @@ -56,8 +56,9 @@ struct irq_affinity;
975 * Returns the first 64 feature bits (all we currently need).
976 * @finalize_features: confirm what device features we'll be using.
977 * vdev: the virtio_device
978 - * This gives the final feature bits for the device: it can change
979 + * This sends the driver feature bits to the device: it can change
980 * the dev->feature bits if it wants.
981 + * Note: despite the name this can be called any number of times.
982 * Returns 0 on success or error status
983 * @bus_name: return the bus name associated with the device (optional)
984 * vdev: the virtio_device
985 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
986 index 1a89b2bf626a5..56619766e9103 100644
987 --- a/kernel/trace/trace.c
988 +++ b/kernel/trace/trace.c
989 @@ -1305,10 +1305,12 @@ static int __init set_buf_size(char *str)
990 if (!str)
991 return 0;
992 buf_size = memparse(str, &str);
993 - /* nr_entries can not be zero */
994 - if (buf_size == 0)
995 - return 0;
996 - trace_buf_size = buf_size;
997 + /*
998 + * nr_entries can not be zero and the startup
999 + * tests require some buffer space. Therefore
1000 + * ensure we have at least 4096 bytes of buffer.
1001 + */
1002 + trace_buf_size = max(4096UL, buf_size);
1003 return 1;
1004 }
1005 __setup("trace_buf_size=", set_buf_size);
1006 diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c
1007 index 184af6da0defc..093b73c454d28 100644
1008 --- a/net/ax25/af_ax25.c
1009 +++ b/net/ax25/af_ax25.c
1010 @@ -87,6 +87,13 @@ again:
1011 ax25_for_each(s, &ax25_list) {
1012 if (s->ax25_dev == ax25_dev) {
1013 sk = s->sk;
1014 + if (!sk) {
1015 + spin_unlock_bh(&ax25_list_lock);
1016 + s->ax25_dev = NULL;
1017 + ax25_disconnect(s, ENETUNREACH);
1018 + spin_lock_bh(&ax25_list_lock);
1019 + goto again;
1020 + }
1021 sock_hold(sk);
1022 spin_unlock_bh(&ax25_list_lock);
1023 lock_sock(sk);
1024 diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
1025 index bcad7028bbf45..ad45f13a0370b 100644
1026 --- a/net/core/net-sysfs.c
1027 +++ b/net/core/net-sysfs.c
1028 @@ -212,7 +212,7 @@ static ssize_t speed_show(struct device *dev,
1029 if (!rtnl_trylock())
1030 return restart_syscall();
1031
1032 - if (netif_running(netdev)) {
1033 + if (netif_running(netdev) && netif_device_present(netdev)) {
1034 struct ethtool_link_ksettings cmd;
1035
1036 if (!__ethtool_get_link_ksettings(netdev, &cmd))
1037 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
1038 index d1f29a3eb70be..60d070b254846 100644
1039 --- a/net/ipv6/addrconf.c
1040 +++ b/net/ipv6/addrconf.c
1041 @@ -4924,6 +4924,7 @@ static int inet6_fill_ifaddr(struct sk_buff *skb, struct inet6_ifaddr *ifa,
1042 nla_put_s32(skb, IFA_TARGET_NETNSID, args->netnsid))
1043 goto error;
1044
1045 + spin_lock_bh(&ifa->lock);
1046 if (!((ifa->flags&IFA_F_PERMANENT) &&
1047 (ifa->prefered_lft == INFINITY_LIFE_TIME))) {
1048 preferred = ifa->prefered_lft;
1049 @@ -4945,6 +4946,7 @@ static int inet6_fill_ifaddr(struct sk_buff *skb, struct inet6_ifaddr *ifa,
1050 preferred = INFINITY_LIFE_TIME;
1051 valid = INFINITY_LIFE_TIME;
1052 }
1053 + spin_unlock_bh(&ifa->lock);
1054
1055 if (!ipv6_addr_any(&ifa->peer_addr)) {
1056 if (nla_put_in6_addr(skb, IFA_LOCAL, &ifa->addr) < 0 ||
1057 diff --git a/net/sctp/diag.c b/net/sctp/diag.c
1058 index 7921e77fa55a3..5a918e74bb82b 100644
1059 --- a/net/sctp/diag.c
1060 +++ b/net/sctp/diag.c
1061 @@ -61,10 +61,6 @@ static void inet_diag_msg_sctpasoc_fill(struct inet_diag_msg *r,
1062 r->idiag_timer = SCTP_EVENT_TIMEOUT_T3_RTX;
1063 r->idiag_retrans = asoc->rtx_data_chunks;
1064 r->idiag_expires = jiffies_to_msecs(t3_rtx->expires - jiffies);
1065 - } else {
1066 - r->idiag_timer = 0;
1067 - r->idiag_retrans = 0;
1068 - r->idiag_expires = 0;
1069 }
1070 }
1071
1072 @@ -144,13 +140,14 @@ static int inet_sctp_diag_fill(struct sock *sk, struct sctp_association *asoc,
1073 r = nlmsg_data(nlh);
1074 BUG_ON(!sk_fullsock(sk));
1075
1076 + r->idiag_timer = 0;
1077 + r->idiag_retrans = 0;
1078 + r->idiag_expires = 0;
1079 if (asoc) {
1080 inet_diag_msg_sctpasoc_fill(r, sk, asoc);
1081 } else {
1082 inet_diag_msg_common_fill(r, sk);
1083 r->idiag_state = sk->sk_state;
1084 - r->idiag_timer = 0;
1085 - r->idiag_retrans = 0;
1086 }
1087
1088 if (inet_diag_msg_attrs_fill(sk, skb, r, ext, user_ns, net_admin))
1089 diff --git a/tools/testing/selftests/bpf/prog_tests/timer_crash.c b/tools/testing/selftests/bpf/prog_tests/timer_crash.c
1090 new file mode 100644
1091 index 0000000000000..f74b82305da8c
1092 --- /dev/null
1093 +++ b/tools/testing/selftests/bpf/prog_tests/timer_crash.c
1094 @@ -0,0 +1,32 @@
1095 +// SPDX-License-Identifier: GPL-2.0
1096 +#include <test_progs.h>
1097 +#include "timer_crash.skel.h"
1098 +
1099 +enum {
1100 + MODE_ARRAY,
1101 + MODE_HASH,
1102 +};
1103 +
1104 +static void test_timer_crash_mode(int mode)
1105 +{
1106 + struct timer_crash *skel;
1107 +
1108 + skel = timer_crash__open_and_load();
1109 + if (!ASSERT_OK_PTR(skel, "timer_crash__open_and_load"))
1110 + return;
1111 + skel->bss->pid = getpid();
1112 + skel->bss->crash_map = mode;
1113 + if (!ASSERT_OK(timer_crash__attach(skel), "timer_crash__attach"))
1114 + goto end;
1115 + usleep(1);
1116 +end:
1117 + timer_crash__destroy(skel);
1118 +}
1119 +
1120 +void test_timer_crash(void)
1121 +{
1122 + if (test__start_subtest("array"))
1123 + test_timer_crash_mode(MODE_ARRAY);
1124 + if (test__start_subtest("hash"))
1125 + test_timer_crash_mode(MODE_HASH);
1126 +}
1127 diff --git a/tools/testing/selftests/bpf/progs/timer_crash.c b/tools/testing/selftests/bpf/progs/timer_crash.c
1128 new file mode 100644
1129 index 0000000000000..f8f7944e70dae
1130 --- /dev/null
1131 +++ b/tools/testing/selftests/bpf/progs/timer_crash.c
1132 @@ -0,0 +1,54 @@
1133 +// SPDX-License-Identifier: GPL-2.0
1134 +
1135 +#include <vmlinux.h>
1136 +#include <bpf/bpf_tracing.h>
1137 +#include <bpf/bpf_helpers.h>
1138 +
1139 +struct map_elem {
1140 + struct bpf_timer timer;
1141 + struct bpf_spin_lock lock;
1142 +};
1143 +
1144 +struct {
1145 + __uint(type, BPF_MAP_TYPE_ARRAY);
1146 + __uint(max_entries, 1);
1147 + __type(key, int);
1148 + __type(value, struct map_elem);
1149 +} amap SEC(".maps");
1150 +
1151 +struct {
1152 + __uint(type, BPF_MAP_TYPE_HASH);
1153 + __uint(max_entries, 1);
1154 + __type(key, int);
1155 + __type(value, struct map_elem);
1156 +} hmap SEC(".maps");
1157 +
1158 +int pid = 0;
1159 +int crash_map = 0; /* 0 for amap, 1 for hmap */
1160 +
1161 +SEC("fentry/do_nanosleep")
1162 +int sys_enter(void *ctx)
1163 +{
1164 + struct map_elem *e, value = {};
1165 + void *map = crash_map ? (void *)&hmap : (void *)&amap;
1166 +
1167 + if (bpf_get_current_task_btf()->tgid != pid)
1168 + return 0;
1169 +
1170 + *(void **)&value = (void *)0xdeadcaf3;
1171 +
1172 + bpf_map_update_elem(map, &(int){0}, &value, 0);
1173 + /* For array map, doing bpf_map_update_elem will do a
1174 + * check_and_free_timer_in_array, which will trigger the crash if timer
1175 + * pointer was overwritten, for hmap we need to use bpf_timer_cancel.
1176 + */
1177 + if (crash_map == 1) {
1178 + e = bpf_map_lookup_elem(map, &(int){0});
1179 + if (!e)
1180 + return 0;
1181 + bpf_timer_cancel(&e->timer);
1182 + }
1183 + return 0;
1184 +}
1185 +
1186 +char _license[] SEC("license") = "GPL";
1187 diff --git a/tools/testing/selftests/memfd/memfd_test.c b/tools/testing/selftests/memfd/memfd_test.c
1188 index c67d32eeb668e..290cec2a6a338 100644
1189 --- a/tools/testing/selftests/memfd/memfd_test.c
1190 +++ b/tools/testing/selftests/memfd/memfd_test.c
1191 @@ -421,6 +421,7 @@ static void mfd_fail_write(int fd)
1192 printf("mmap()+mprotect() didn't fail as expected\n");
1193 abort();
1194 }
1195 + munmap(p, mfd_def_size);
1196 }
1197
1198 /* verify PUNCH_HOLE fails */
1199 diff --git a/tools/testing/selftests/net/pmtu.sh b/tools/testing/selftests/net/pmtu.sh
1200 index 3429767cadcdd..88be9083b923b 100755
1201 --- a/tools/testing/selftests/net/pmtu.sh
1202 +++ b/tools/testing/selftests/net/pmtu.sh
1203 @@ -579,7 +579,6 @@ setup_routing() {
1204 setup() {
1205 [ "$(id -u)" -ne 0 ] && echo " need to run as root" && return $ksft_skip
1206
1207 - cleanup
1208 for arg do
1209 eval setup_${arg} || { echo " ${arg} not supported"; return 1; }
1210 done
1211 @@ -590,7 +589,7 @@ trace() {
1212
1213 for arg do
1214 [ "${ns_cmd}" = "" ] && ns_cmd="${arg}" && continue
1215 - ${ns_cmd} tcpdump -s 0 -i "${arg}" -w "${name}_${arg}.pcap" 2> /dev/null &
1216 + ${ns_cmd} tcpdump --immediate-mode -s 0 -i "${arg}" -w "${name}_${arg}.pcap" 2> /dev/null &
1217 tcpdump_pids="${tcpdump_pids} $!"
1218 ns_cmd=
1219 done
1220 @@ -1182,6 +1181,10 @@ run_test() {
1221
1222 unset IFS
1223
1224 + # Since cleanup() relies on variables modified by this subshell, it
1225 + # has to run in this context.
1226 + trap cleanup EXIT
1227 +
1228 if [ "$VERBOSE" = "1" ]; then
1229 printf "\n##########################################################################\n\n"
1230 fi
1231 diff --git a/tools/testing/selftests/vm/map_fixed_noreplace.c b/tools/testing/selftests/vm/map_fixed_noreplace.c
1232 index d91bde5112686..eed44322d1a63 100644
1233 --- a/tools/testing/selftests/vm/map_fixed_noreplace.c
1234 +++ b/tools/testing/selftests/vm/map_fixed_noreplace.c
1235 @@ -17,9 +17,6 @@
1236 #define MAP_FIXED_NOREPLACE 0x100000
1237 #endif
1238
1239 -#define BASE_ADDRESS (256ul * 1024 * 1024)
1240 -
1241 -
1242 static void dump_maps(void)
1243 {
1244 char cmd[32];
1245 @@ -28,18 +25,46 @@ static void dump_maps(void)
1246 system(cmd);
1247 }
1248
1249 +static unsigned long find_base_addr(unsigned long size)
1250 +{
1251 + void *addr;
1252 + unsigned long flags;
1253 +
1254 + flags = MAP_PRIVATE | MAP_ANONYMOUS;
1255 + addr = mmap(NULL, size, PROT_NONE, flags, -1, 0);
1256 + if (addr == MAP_FAILED) {
1257 + printf("Error: couldn't map the space we need for the test\n");
1258 + return 0;
1259 + }
1260 +
1261 + if (munmap(addr, size) != 0) {
1262 + printf("Error: couldn't map the space we need for the test\n");
1263 + return 0;
1264 + }
1265 + return (unsigned long)addr;
1266 +}
1267 +
1268 int main(void)
1269 {
1270 + unsigned long base_addr;
1271 unsigned long flags, addr, size, page_size;
1272 char *p;
1273
1274 page_size = sysconf(_SC_PAGE_SIZE);
1275
1276 + //let's find a base addr that is free before we start the tests
1277 + size = 5 * page_size;
1278 + base_addr = find_base_addr(size);
1279 + if (!base_addr) {
1280 + printf("Error: couldn't map the space we need for the test\n");
1281 + return 1;
1282 + }
1283 +
1284 flags = MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED_NOREPLACE;
1285
1286 // Check we can map all the areas we need below
1287 errno = 0;
1288 - addr = BASE_ADDRESS;
1289 + addr = base_addr;
1290 size = 5 * page_size;
1291 p = mmap((void *)addr, size, PROT_NONE, flags, -1, 0);
1292
1293 @@ -60,7 +85,7 @@ int main(void)
1294 printf("unmap() successful\n");
1295
1296 errno = 0;
1297 - addr = BASE_ADDRESS + page_size;
1298 + addr = base_addr + page_size;
1299 size = 3 * page_size;
1300 p = mmap((void *)addr, size, PROT_NONE, flags, -1, 0);
1301 printf("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p);
1302 @@ -80,7 +105,7 @@ int main(void)
1303 * +4 | free | new
1304 */
1305 errno = 0;
1306 - addr = BASE_ADDRESS;
1307 + addr = base_addr;
1308 size = 5 * page_size;
1309 p = mmap((void *)addr, size, PROT_NONE, flags, -1, 0);
1310 printf("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p);
1311 @@ -101,7 +126,7 @@ int main(void)
1312 * +4 | free |
1313 */
1314 errno = 0;
1315 - addr = BASE_ADDRESS + (2 * page_size);
1316 + addr = base_addr + (2 * page_size);
1317 size = page_size;
1318 p = mmap((void *)addr, size, PROT_NONE, flags, -1, 0);
1319 printf("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p);
1320 @@ -121,7 +146,7 @@ int main(void)
1321 * +4 | free | new
1322 */
1323 errno = 0;
1324 - addr = BASE_ADDRESS + (3 * page_size);
1325 + addr = base_addr + (3 * page_size);
1326 size = 2 * page_size;
1327 p = mmap((void *)addr, size, PROT_NONE, flags, -1, 0);
1328 printf("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p);
1329 @@ -141,7 +166,7 @@ int main(void)
1330 * +4 | free |
1331 */
1332 errno = 0;
1333 - addr = BASE_ADDRESS;
1334 + addr = base_addr;
1335 size = 2 * page_size;
1336 p = mmap((void *)addr, size, PROT_NONE, flags, -1, 0);
1337 printf("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p);
1338 @@ -161,7 +186,7 @@ int main(void)
1339 * +4 | free |
1340 */
1341 errno = 0;
1342 - addr = BASE_ADDRESS;
1343 + addr = base_addr;
1344 size = page_size;
1345 p = mmap((void *)addr, size, PROT_NONE, flags, -1, 0);
1346 printf("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p);
1347 @@ -181,7 +206,7 @@ int main(void)
1348 * +4 | free | new
1349 */
1350 errno = 0;
1351 - addr = BASE_ADDRESS + (4 * page_size);
1352 + addr = base_addr + (4 * page_size);
1353 size = page_size;
1354 p = mmap((void *)addr, size, PROT_NONE, flags, -1, 0);
1355 printf("mmap() @ 0x%lx-0x%lx p=%p result=%m\n", addr, addr + size, p);
1356 @@ -192,7 +217,7 @@ int main(void)
1357 return 1;
1358 }
1359
1360 - addr = BASE_ADDRESS;
1361 + addr = base_addr;
1362 size = 5 * page_size;
1363 if (munmap((void *)addr, size) != 0) {
1364 dump_maps();