Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:4.18 commit in: /
Date: Sat, 13 Oct 2018 16:32:56
Message-Id: 1539448347.0321d35911e5d0856e9295cc57f42916d1b21282.mpagano@gentoo
1 commit: 0321d35911e5d0856e9295cc57f42916d1b21282
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Sat Oct 13 16:32:27 2018 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Sat Oct 13 16:32:27 2018 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=0321d359
7
8 Linux patch 4.18.14
9
10 Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org>
11
12 0000_README | 4 +
13 1013_linux-4.18.14.patch | 1692 ++++++++++++++++++++++++++++++++++++++++++++++
14 2 files changed, 1696 insertions(+)
15
16 diff --git a/0000_README b/0000_README
17 index f5bb594..6d1cb28 100644
18 --- a/0000_README
19 +++ b/0000_README
20 @@ -95,6 +95,10 @@ Patch: 1012_linux-4.18.13.patch
21 From: http://www.kernel.org
22 Desc: Linux 4.18.13
23
24 +Patch: 1013_linux-4.18.14.patch
25 +From: http://www.kernel.org
26 +Desc: Linux 4.18.14
27 +
28 Patch: 1500_XATTR_USER_PREFIX.patch
29 From: https://bugs.gentoo.org/show_bug.cgi?id=470644
30 Desc: Support for namespace user.pax.* on tmpfs.
31
32 diff --git a/1013_linux-4.18.14.patch b/1013_linux-4.18.14.patch
33 new file mode 100644
34 index 0000000..742cbc9
35 --- /dev/null
36 +++ b/1013_linux-4.18.14.patch
37 @@ -0,0 +1,1692 @@
38 +diff --git a/Makefile b/Makefile
39 +index 4442e9ea4b6d..5274f8ae6b44 100644
40 +--- a/Makefile
41 ++++ b/Makefile
42 +@@ -1,7 +1,7 @@
43 + # SPDX-License-Identifier: GPL-2.0
44 + VERSION = 4
45 + PATCHLEVEL = 18
46 +-SUBLEVEL = 13
47 ++SUBLEVEL = 14
48 + EXTRAVERSION =
49 + NAME = Merciless Moray
50 +
51 +diff --git a/arch/arc/kernel/process.c b/arch/arc/kernel/process.c
52 +index 4674541eba3f..8ce6e7235915 100644
53 +--- a/arch/arc/kernel/process.c
54 ++++ b/arch/arc/kernel/process.c
55 +@@ -241,6 +241,26 @@ int copy_thread(unsigned long clone_flags,
56 + task_thread_info(current)->thr_ptr;
57 + }
58 +
59 ++
60 ++ /*
61 ++ * setup usermode thread pointer #1:
62 ++ * when child is picked by scheduler, __switch_to() uses @c_callee to
63 ++ * populate usermode callee regs: this works (despite being in a kernel
64 ++ * function) since special return path for child @ret_from_fork()
65 ++ * ensures those regs are not clobbered all the way to RTIE to usermode
66 ++ */
67 ++ c_callee->r25 = task_thread_info(p)->thr_ptr;
68 ++
69 ++#ifdef CONFIG_ARC_CURR_IN_REG
70 ++ /*
71 ++ * setup usermode thread pointer #2:
72 ++ * however for this special use of r25 in kernel, __switch_to() sets
73 ++ * r25 for kernel needs and only in the final return path is usermode
74 ++ * r25 setup, from pt_regs->user_r25. So set that up as well
75 ++ */
76 ++ c_regs->user_r25 = c_callee->r25;
77 ++#endif
78 ++
79 + return 0;
80 + }
81 +
82 +diff --git a/arch/powerpc/include/asm/setup.h b/arch/powerpc/include/asm/setup.h
83 +index 8721fd004291..e1a1518a1ec7 100644
84 +--- a/arch/powerpc/include/asm/setup.h
85 ++++ b/arch/powerpc/include/asm/setup.h
86 +@@ -9,6 +9,7 @@ extern void ppc_printk_progress(char *s, unsigned short hex);
87 +
88 + extern unsigned int rtas_data;
89 + extern unsigned long long memory_limit;
90 ++extern bool init_mem_is_free;
91 + extern unsigned long klimit;
92 + extern void *zalloc_maybe_bootmem(size_t size, gfp_t mask);
93 +
94 +diff --git a/arch/powerpc/lib/code-patching.c b/arch/powerpc/lib/code-patching.c
95 +index e0d881ab304e..30cbcadb54d5 100644
96 +--- a/arch/powerpc/lib/code-patching.c
97 ++++ b/arch/powerpc/lib/code-patching.c
98 +@@ -142,7 +142,7 @@ static inline int unmap_patch_area(unsigned long addr)
99 + return 0;
100 + }
101 +
102 +-int patch_instruction(unsigned int *addr, unsigned int instr)
103 ++static int do_patch_instruction(unsigned int *addr, unsigned int instr)
104 + {
105 + int err;
106 + unsigned int *patch_addr = NULL;
107 +@@ -182,12 +182,22 @@ out:
108 + }
109 + #else /* !CONFIG_STRICT_KERNEL_RWX */
110 +
111 +-int patch_instruction(unsigned int *addr, unsigned int instr)
112 ++static int do_patch_instruction(unsigned int *addr, unsigned int instr)
113 + {
114 + return raw_patch_instruction(addr, instr);
115 + }
116 +
117 + #endif /* CONFIG_STRICT_KERNEL_RWX */
118 ++
119 ++int patch_instruction(unsigned int *addr, unsigned int instr)
120 ++{
121 ++ /* Make sure we aren't patching a freed init section */
122 ++ if (init_mem_is_free && init_section_contains(addr, 4)) {
123 ++ pr_debug("Skipping init section patching addr: 0x%px\n", addr);
124 ++ return 0;
125 ++ }
126 ++ return do_patch_instruction(addr, instr);
127 ++}
128 + NOKPROBE_SYMBOL(patch_instruction);
129 +
130 + int patch_branch(unsigned int *addr, unsigned long target, int flags)
131 +diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
132 +index 5c8530d0c611..04ccb274a620 100644
133 +--- a/arch/powerpc/mm/mem.c
134 ++++ b/arch/powerpc/mm/mem.c
135 +@@ -63,6 +63,7 @@
136 + #endif
137 +
138 + unsigned long long memory_limit;
139 ++bool init_mem_is_free;
140 +
141 + #ifdef CONFIG_HIGHMEM
142 + pte_t *kmap_pte;
143 +@@ -396,6 +397,7 @@ void free_initmem(void)
144 + {
145 + ppc_md.progress = ppc_printk_progress;
146 + mark_initmem_nx();
147 ++ init_mem_is_free = true;
148 + free_initmem_default(POISON_FREE_INITMEM);
149 + }
150 +
151 +diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile
152 +index 9589878faf46..eb1ed9a7109d 100644
153 +--- a/arch/x86/entry/vdso/Makefile
154 ++++ b/arch/x86/entry/vdso/Makefile
155 +@@ -72,7 +72,13 @@ $(obj)/vdso-image-%.c: $(obj)/vdso%.so.dbg $(obj)/vdso%.so $(obj)/vdso2c FORCE
156 + CFL := $(PROFILING) -mcmodel=small -fPIC -O2 -fasynchronous-unwind-tables -m64 \
157 + $(filter -g%,$(KBUILD_CFLAGS)) $(call cc-option, -fno-stack-protector) \
158 + -fno-omit-frame-pointer -foptimize-sibling-calls \
159 +- -DDISABLE_BRANCH_PROFILING -DBUILD_VDSO $(RETPOLINE_VDSO_CFLAGS)
160 ++ -DDISABLE_BRANCH_PROFILING -DBUILD_VDSO
161 ++
162 ++ifdef CONFIG_RETPOLINE
163 ++ifneq ($(RETPOLINE_VDSO_CFLAGS),)
164 ++ CFL += $(RETPOLINE_VDSO_CFLAGS)
165 ++endif
166 ++endif
167 +
168 + $(vobjs): KBUILD_CFLAGS := $(filter-out $(GCC_PLUGINS_CFLAGS) $(RETPOLINE_CFLAGS),$(KBUILD_CFLAGS)) $(CFL)
169 +
170 +@@ -144,7 +150,13 @@ KBUILD_CFLAGS_32 += $(call cc-option, -fno-stack-protector)
171 + KBUILD_CFLAGS_32 += $(call cc-option, -foptimize-sibling-calls)
172 + KBUILD_CFLAGS_32 += -fno-omit-frame-pointer
173 + KBUILD_CFLAGS_32 += -DDISABLE_BRANCH_PROFILING
174 +-KBUILD_CFLAGS_32 += $(RETPOLINE_VDSO_CFLAGS)
175 ++
176 ++ifdef CONFIG_RETPOLINE
177 ++ifneq ($(RETPOLINE_VDSO_CFLAGS),)
178 ++ KBUILD_CFLAGS_32 += $(RETPOLINE_VDSO_CFLAGS)
179 ++endif
180 ++endif
181 ++
182 + $(obj)/vdso32.so.dbg: KBUILD_CFLAGS = $(KBUILD_CFLAGS_32)
183 +
184 + $(obj)/vdso32.so.dbg: FORCE \
185 +diff --git a/arch/x86/entry/vdso/vclock_gettime.c b/arch/x86/entry/vdso/vclock_gettime.c
186 +index f19856d95c60..e48ca3afa091 100644
187 +--- a/arch/x86/entry/vdso/vclock_gettime.c
188 ++++ b/arch/x86/entry/vdso/vclock_gettime.c
189 +@@ -43,8 +43,9 @@ extern u8 hvclock_page
190 + notrace static long vdso_fallback_gettime(long clock, struct timespec *ts)
191 + {
192 + long ret;
193 +- asm("syscall" : "=a" (ret) :
194 +- "0" (__NR_clock_gettime), "D" (clock), "S" (ts) : "memory");
195 ++ asm ("syscall" : "=a" (ret), "=m" (*ts) :
196 ++ "0" (__NR_clock_gettime), "D" (clock), "S" (ts) :
197 ++ "memory", "rcx", "r11");
198 + return ret;
199 + }
200 +
201 +@@ -52,8 +53,9 @@ notrace static long vdso_fallback_gtod(struct timeval *tv, struct timezone *tz)
202 + {
203 + long ret;
204 +
205 +- asm("syscall" : "=a" (ret) :
206 +- "0" (__NR_gettimeofday), "D" (tv), "S" (tz) : "memory");
207 ++ asm ("syscall" : "=a" (ret), "=m" (*tv), "=m" (*tz) :
208 ++ "0" (__NR_gettimeofday), "D" (tv), "S" (tz) :
209 ++ "memory", "rcx", "r11");
210 + return ret;
211 + }
212 +
213 +@@ -64,13 +66,13 @@ notrace static long vdso_fallback_gettime(long clock, struct timespec *ts)
214 + {
215 + long ret;
216 +
217 +- asm(
218 ++ asm (
219 + "mov %%ebx, %%edx \n"
220 +- "mov %2, %%ebx \n"
221 ++ "mov %[clock], %%ebx \n"
222 + "call __kernel_vsyscall \n"
223 + "mov %%edx, %%ebx \n"
224 +- : "=a" (ret)
225 +- : "0" (__NR_clock_gettime), "g" (clock), "c" (ts)
226 ++ : "=a" (ret), "=m" (*ts)
227 ++ : "0" (__NR_clock_gettime), [clock] "g" (clock), "c" (ts)
228 + : "memory", "edx");
229 + return ret;
230 + }
231 +@@ -79,13 +81,13 @@ notrace static long vdso_fallback_gtod(struct timeval *tv, struct timezone *tz)
232 + {
233 + long ret;
234 +
235 +- asm(
236 ++ asm (
237 + "mov %%ebx, %%edx \n"
238 +- "mov %2, %%ebx \n"
239 ++ "mov %[tv], %%ebx \n"
240 + "call __kernel_vsyscall \n"
241 + "mov %%edx, %%ebx \n"
242 +- : "=a" (ret)
243 +- : "0" (__NR_gettimeofday), "g" (tv), "c" (tz)
244 ++ : "=a" (ret), "=m" (*tv), "=m" (*tz)
245 ++ : "0" (__NR_gettimeofday), [tv] "g" (tv), "c" (tz)
246 + : "memory", "edx");
247 + return ret;
248 + }
249 +diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
250 +index 97d41754769e..d02f0390c1c1 100644
251 +--- a/arch/x86/kvm/mmu.c
252 ++++ b/arch/x86/kvm/mmu.c
253 +@@ -232,6 +232,17 @@ static u64 __read_mostly shadow_nonpresent_or_rsvd_mask;
254 + */
255 + static const u64 shadow_nonpresent_or_rsvd_mask_len = 5;
256 +
257 ++/*
258 ++ * In some cases, we need to preserve the GFN of a non-present or reserved
259 ++ * SPTE when we usurp the upper five bits of the physical address space to
260 ++ * defend against L1TF, e.g. for MMIO SPTEs. To preserve the GFN, we'll
261 ++ * shift bits of the GFN that overlap with shadow_nonpresent_or_rsvd_mask
262 ++ * left into the reserved bits, i.e. the GFN in the SPTE will be split into
263 ++ * high and low parts. This mask covers the lower bits of the GFN.
264 ++ */
265 ++static u64 __read_mostly shadow_nonpresent_or_rsvd_lower_gfn_mask;
266 ++
267 ++
268 + static void mmu_spte_set(u64 *sptep, u64 spte);
269 +
270 + void kvm_mmu_set_mmio_spte_mask(u64 mmio_mask, u64 mmio_value)
271 +@@ -338,9 +349,7 @@ static bool is_mmio_spte(u64 spte)
272 +
273 + static gfn_t get_mmio_spte_gfn(u64 spte)
274 + {
275 +- u64 mask = generation_mmio_spte_mask(MMIO_GEN_MASK) | shadow_mmio_mask |
276 +- shadow_nonpresent_or_rsvd_mask;
277 +- u64 gpa = spte & ~mask;
278 ++ u64 gpa = spte & shadow_nonpresent_or_rsvd_lower_gfn_mask;
279 +
280 + gpa |= (spte >> shadow_nonpresent_or_rsvd_mask_len)
281 + & shadow_nonpresent_or_rsvd_mask;
282 +@@ -404,6 +413,8 @@ EXPORT_SYMBOL_GPL(kvm_mmu_set_mask_ptes);
283 +
284 + static void kvm_mmu_reset_all_pte_masks(void)
285 + {
286 ++ u8 low_phys_bits;
287 ++
288 + shadow_user_mask = 0;
289 + shadow_accessed_mask = 0;
290 + shadow_dirty_mask = 0;
291 +@@ -418,12 +429,17 @@ static void kvm_mmu_reset_all_pte_masks(void)
292 + * appropriate mask to guard against L1TF attacks. Otherwise, it is
293 + * assumed that the CPU is not vulnerable to L1TF.
294 + */
295 ++ low_phys_bits = boot_cpu_data.x86_phys_bits;
296 + if (boot_cpu_data.x86_phys_bits <
297 +- 52 - shadow_nonpresent_or_rsvd_mask_len)
298 ++ 52 - shadow_nonpresent_or_rsvd_mask_len) {
299 + shadow_nonpresent_or_rsvd_mask =
300 + rsvd_bits(boot_cpu_data.x86_phys_bits -
301 + shadow_nonpresent_or_rsvd_mask_len,
302 + boot_cpu_data.x86_phys_bits - 1);
303 ++ low_phys_bits -= shadow_nonpresent_or_rsvd_mask_len;
304 ++ }
305 ++ shadow_nonpresent_or_rsvd_lower_gfn_mask =
306 ++ GENMASK_ULL(low_phys_bits - 1, PAGE_SHIFT);
307 + }
308 +
309 + static int is_cpuid_PSE36(void)
310 +diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
311 +index d0c3be353bb6..32721ef9652d 100644
312 +--- a/arch/x86/kvm/vmx.c
313 ++++ b/arch/x86/kvm/vmx.c
314 +@@ -9826,15 +9826,16 @@ static void vmx_set_virtual_apic_mode(struct kvm_vcpu *vcpu)
315 + if (!lapic_in_kernel(vcpu))
316 + return;
317 +
318 ++ if (!flexpriority_enabled &&
319 ++ !cpu_has_vmx_virtualize_x2apic_mode())
320 ++ return;
321 ++
322 + /* Postpone execution until vmcs01 is the current VMCS. */
323 + if (is_guest_mode(vcpu)) {
324 + to_vmx(vcpu)->nested.change_vmcs01_virtual_apic_mode = true;
325 + return;
326 + }
327 +
328 +- if (!cpu_need_tpr_shadow(vcpu))
329 +- return;
330 +-
331 + sec_exec_control = vmcs_read32(SECONDARY_VM_EXEC_CONTROL);
332 + sec_exec_control &= ~(SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES |
333 + SECONDARY_EXEC_VIRTUALIZE_X2APIC_MODE);
334 +diff --git a/block/blk-mq.c b/block/blk-mq.c
335 +index 2f9e14361673..90e8058ae557 100644
336 +--- a/block/blk-mq.c
337 ++++ b/block/blk-mq.c
338 +@@ -1596,7 +1596,7 @@ void blk_mq_flush_plug_list(struct blk_plug *plug, bool from_schedule)
339 + BUG_ON(!rq->q);
340 + if (rq->mq_ctx != this_ctx) {
341 + if (this_ctx) {
342 +- trace_block_unplug(this_q, depth, from_schedule);
343 ++ trace_block_unplug(this_q, depth, !from_schedule);
344 + blk_mq_sched_insert_requests(this_q, this_ctx,
345 + &ctx_list,
346 + from_schedule);
347 +@@ -1616,7 +1616,7 @@ void blk_mq_flush_plug_list(struct blk_plug *plug, bool from_schedule)
348 + * on 'ctx_list'. Do those.
349 + */
350 + if (this_ctx) {
351 +- trace_block_unplug(this_q, depth, from_schedule);
352 ++ trace_block_unplug(this_q, depth, !from_schedule);
353 + blk_mq_sched_insert_requests(this_q, this_ctx, &ctx_list,
354 + from_schedule);
355 + }
356 +diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
357 +index 3f68e2919dc5..a690fd400260 100644
358 +--- a/drivers/base/power/main.c
359 ++++ b/drivers/base/power/main.c
360 +@@ -1713,8 +1713,10 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async)
361 +
362 + dpm_wait_for_subordinate(dev, async);
363 +
364 +- if (async_error)
365 ++ if (async_error) {
366 ++ dev->power.direct_complete = false;
367 + goto Complete;
368 ++ }
369 +
370 + /*
371 + * If a device configured to wake up the system from sleep states
372 +@@ -1726,6 +1728,7 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async)
373 + pm_wakeup_event(dev, 0);
374 +
375 + if (pm_wakeup_pending()) {
376 ++ dev->power.direct_complete = false;
377 + async_error = -EBUSY;
378 + goto Complete;
379 + }
380 +diff --git a/drivers/clocksource/timer-atmel-pit.c b/drivers/clocksource/timer-atmel-pit.c
381 +index ec8a4376f74f..2fab18fae4fc 100644
382 +--- a/drivers/clocksource/timer-atmel-pit.c
383 ++++ b/drivers/clocksource/timer-atmel-pit.c
384 +@@ -180,26 +180,29 @@ static int __init at91sam926x_pit_dt_init(struct device_node *node)
385 + data->base = of_iomap(node, 0);
386 + if (!data->base) {
387 + pr_err("Could not map PIT address\n");
388 +- return -ENXIO;
389 ++ ret = -ENXIO;
390 ++ goto exit;
391 + }
392 +
393 + data->mck = of_clk_get(node, 0);
394 + if (IS_ERR(data->mck)) {
395 + pr_err("Unable to get mck clk\n");
396 +- return PTR_ERR(data->mck);
397 ++ ret = PTR_ERR(data->mck);
398 ++ goto exit;
399 + }
400 +
401 + ret = clk_prepare_enable(data->mck);
402 + if (ret) {
403 + pr_err("Unable to enable mck\n");
404 +- return ret;
405 ++ goto exit;
406 + }
407 +
408 + /* Get the interrupts property */
409 + data->irq = irq_of_parse_and_map(node, 0);
410 + if (!data->irq) {
411 + pr_err("Unable to get IRQ from DT\n");
412 +- return -EINVAL;
413 ++ ret = -EINVAL;
414 ++ goto exit;
415 + }
416 +
417 + /*
418 +@@ -227,7 +230,7 @@ static int __init at91sam926x_pit_dt_init(struct device_node *node)
419 + ret = clocksource_register_hz(&data->clksrc, pit_rate);
420 + if (ret) {
421 + pr_err("Failed to register clocksource\n");
422 +- return ret;
423 ++ goto exit;
424 + }
425 +
426 + /* Set up irq handler */
427 +@@ -236,7 +239,8 @@ static int __init at91sam926x_pit_dt_init(struct device_node *node)
428 + "at91_tick", data);
429 + if (ret) {
430 + pr_err("Unable to setup IRQ\n");
431 +- return ret;
432 ++ clocksource_unregister(&data->clksrc);
433 ++ goto exit;
434 + }
435 +
436 + /* Set up and register clockevents */
437 +@@ -254,6 +258,10 @@ static int __init at91sam926x_pit_dt_init(struct device_node *node)
438 + clockevents_register_device(&data->clkevt);
439 +
440 + return 0;
441 ++
442 ++exit:
443 ++ kfree(data);
444 ++ return ret;
445 + }
446 + TIMER_OF_DECLARE(at91sam926x_pit, "atmel,at91sam9260-pit",
447 + at91sam926x_pit_dt_init);
448 +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
449 +index 23d960ec1cf2..acad2999560c 100644
450 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
451 ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
452 +@@ -246,6 +246,8 @@ int amdgpu_vce_suspend(struct amdgpu_device *adev)
453 + {
454 + int i;
455 +
456 ++ cancel_delayed_work_sync(&adev->vce.idle_work);
457 ++
458 + if (adev->vce.vcpu_bo == NULL)
459 + return 0;
460 +
461 +@@ -256,7 +258,6 @@ int amdgpu_vce_suspend(struct amdgpu_device *adev)
462 + if (i == AMDGPU_MAX_VCE_HANDLES)
463 + return 0;
464 +
465 +- cancel_delayed_work_sync(&adev->vce.idle_work);
466 + /* TODO: suspending running encoding sessions isn't supported */
467 + return -EINVAL;
468 + }
469 +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
470 +index bee49991c1ff..2dc3d1e28f3c 100644
471 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
472 ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
473 +@@ -151,11 +151,11 @@ int amdgpu_vcn_suspend(struct amdgpu_device *adev)
474 + unsigned size;
475 + void *ptr;
476 +
477 ++ cancel_delayed_work_sync(&adev->vcn.idle_work);
478 ++
479 + if (adev->vcn.vcpu_bo == NULL)
480 + return 0;
481 +
482 +- cancel_delayed_work_sync(&adev->vcn.idle_work);
483 +-
484 + size = amdgpu_bo_size(adev->vcn.vcpu_bo);
485 + ptr = adev->vcn.cpu_addr;
486 +
487 +diff --git a/drivers/gpu/drm/drm_lease.c b/drivers/gpu/drm/drm_lease.c
488 +index d638c0fb3418..23a5643a4b98 100644
489 +--- a/drivers/gpu/drm/drm_lease.c
490 ++++ b/drivers/gpu/drm/drm_lease.c
491 +@@ -566,14 +566,14 @@ int drm_mode_create_lease_ioctl(struct drm_device *dev,
492 + lessee_priv->is_master = 1;
493 + lessee_priv->authenticated = 1;
494 +
495 +- /* Hook up the fd */
496 +- fd_install(fd, lessee_file);
497 +-
498 + /* Pass fd back to userspace */
499 + DRM_DEBUG_LEASE("Returning fd %d id %d\n", fd, lessee->lessee_id);
500 + cl->fd = fd;
501 + cl->lessee_id = lessee->lessee_id;
502 +
503 ++ /* Hook up the fd */
504 ++ fd_install(fd, lessee_file);
505 ++
506 + DRM_DEBUG_LEASE("drm_mode_create_lease_ioctl succeeded\n");
507 + return 0;
508 +
509 +diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c
510 +index d4f4ce484529..8e71da403324 100644
511 +--- a/drivers/gpu/drm/drm_syncobj.c
512 ++++ b/drivers/gpu/drm/drm_syncobj.c
513 +@@ -97,6 +97,8 @@ static int drm_syncobj_fence_get_or_add_callback(struct drm_syncobj *syncobj,
514 + {
515 + int ret;
516 +
517 ++ WARN_ON(*fence);
518 ++
519 + *fence = drm_syncobj_fence_get(syncobj);
520 + if (*fence)
521 + return 1;
522 +@@ -744,6 +746,9 @@ static signed long drm_syncobj_array_wait_timeout(struct drm_syncobj **syncobjs,
523 +
524 + if (flags & DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT) {
525 + for (i = 0; i < count; ++i) {
526 ++ if (entries[i].fence)
527 ++ continue;
528 ++
529 + drm_syncobj_fence_get_or_add_callback(syncobjs[i],
530 + &entries[i].fence,
531 + &entries[i].syncobj_cb,
532 +diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c
533 +index 5f437d1570fb..21863ddde63e 100644
534 +--- a/drivers/infiniband/core/ucma.c
535 ++++ b/drivers/infiniband/core/ucma.c
536 +@@ -1759,6 +1759,8 @@ static int ucma_close(struct inode *inode, struct file *filp)
537 + mutex_lock(&mut);
538 + if (!ctx->closing) {
539 + mutex_unlock(&mut);
540 ++ ucma_put_ctx(ctx);
541 ++ wait_for_completion(&ctx->comp);
542 + /* rdma_destroy_id ensures that no event handlers are
543 + * inflight for that id before releasing it.
544 + */
545 +diff --git a/drivers/md/dm-cache-metadata.c b/drivers/md/dm-cache-metadata.c
546 +index 69dddeab124c..5936de71883f 100644
547 +--- a/drivers/md/dm-cache-metadata.c
548 ++++ b/drivers/md/dm-cache-metadata.c
549 +@@ -1455,8 +1455,8 @@ static int __load_mappings(struct dm_cache_metadata *cmd,
550 + if (hints_valid) {
551 + r = dm_array_cursor_next(&cmd->hint_cursor);
552 + if (r) {
553 +- DMERR("dm_array_cursor_next for hint failed");
554 +- goto out;
555 ++ dm_array_cursor_end(&cmd->hint_cursor);
556 ++ hints_valid = false;
557 + }
558 + }
559 +
560 +diff --git a/drivers/md/dm-cache-target.c b/drivers/md/dm-cache-target.c
561 +index 44df244807e5..a39ae8f45e32 100644
562 +--- a/drivers/md/dm-cache-target.c
563 ++++ b/drivers/md/dm-cache-target.c
564 +@@ -3017,8 +3017,13 @@ static dm_cblock_t get_cache_dev_size(struct cache *cache)
565 +
566 + static bool can_resize(struct cache *cache, dm_cblock_t new_size)
567 + {
568 +- if (from_cblock(new_size) > from_cblock(cache->cache_size))
569 +- return true;
570 ++ if (from_cblock(new_size) > from_cblock(cache->cache_size)) {
571 ++ if (cache->sized) {
572 ++ DMERR("%s: unable to extend cache due to missing cache table reload",
573 ++ cache_device_name(cache));
574 ++ return false;
575 ++ }
576 ++ }
577 +
578 + /*
579 + * We can't drop a dirty block when shrinking the cache.
580 +diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
581 +index d94ba6f72ff5..419362c2d8ac 100644
582 +--- a/drivers/md/dm-mpath.c
583 ++++ b/drivers/md/dm-mpath.c
584 +@@ -806,19 +806,19 @@ static int parse_path_selector(struct dm_arg_set *as, struct priority_group *pg,
585 + }
586 +
587 + static int setup_scsi_dh(struct block_device *bdev, struct multipath *m,
588 +- const char *attached_handler_name, char **error)
589 ++ const char **attached_handler_name, char **error)
590 + {
591 + struct request_queue *q = bdev_get_queue(bdev);
592 + int r;
593 +
594 + if (test_bit(MPATHF_RETAIN_ATTACHED_HW_HANDLER, &m->flags)) {
595 + retain:
596 +- if (attached_handler_name) {
597 ++ if (*attached_handler_name) {
598 + /*
599 + * Clear any hw_handler_params associated with a
600 + * handler that isn't already attached.
601 + */
602 +- if (m->hw_handler_name && strcmp(attached_handler_name, m->hw_handler_name)) {
603 ++ if (m->hw_handler_name && strcmp(*attached_handler_name, m->hw_handler_name)) {
604 + kfree(m->hw_handler_params);
605 + m->hw_handler_params = NULL;
606 + }
607 +@@ -830,7 +830,8 @@ retain:
608 + * handler instead of the original table passed in.
609 + */
610 + kfree(m->hw_handler_name);
611 +- m->hw_handler_name = attached_handler_name;
612 ++ m->hw_handler_name = *attached_handler_name;
613 ++ *attached_handler_name = NULL;
614 + }
615 + }
616 +
617 +@@ -867,7 +868,7 @@ static struct pgpath *parse_path(struct dm_arg_set *as, struct path_selector *ps
618 + struct pgpath *p;
619 + struct multipath *m = ti->private;
620 + struct request_queue *q;
621 +- const char *attached_handler_name;
622 ++ const char *attached_handler_name = NULL;
623 +
624 + /* we need at least a path arg */
625 + if (as->argc < 1) {
626 +@@ -890,7 +891,7 @@ static struct pgpath *parse_path(struct dm_arg_set *as, struct path_selector *ps
627 + attached_handler_name = scsi_dh_attached_handler_name(q, GFP_KERNEL);
628 + if (attached_handler_name || m->hw_handler_name) {
629 + INIT_DELAYED_WORK(&p->activate_path, activate_path_work);
630 +- r = setup_scsi_dh(p->path.dev->bdev, m, attached_handler_name, &ti->error);
631 ++ r = setup_scsi_dh(p->path.dev->bdev, m, &attached_handler_name, &ti->error);
632 + if (r) {
633 + dm_put_device(ti, p->path.dev);
634 + goto bad;
635 +@@ -905,6 +906,7 @@ static struct pgpath *parse_path(struct dm_arg_set *as, struct path_selector *ps
636 +
637 + return p;
638 + bad:
639 ++ kfree(attached_handler_name);
640 + free_pgpath(p);
641 + return ERR_PTR(r);
642 + }
643 +diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
644 +index abf9e884386c..f57f5de54206 100644
645 +--- a/drivers/mmc/core/host.c
646 ++++ b/drivers/mmc/core/host.c
647 +@@ -235,7 +235,7 @@ int mmc_of_parse(struct mmc_host *host)
648 + host->caps |= MMC_CAP_NEEDS_POLL;
649 +
650 + ret = mmc_gpiod_request_cd(host, "cd", 0, true,
651 +- cd_debounce_delay_ms,
652 ++ cd_debounce_delay_ms * 1000,
653 + &cd_gpio_invert);
654 + if (!ret)
655 + dev_info(host->parent, "Got CD GPIO\n");
656 +diff --git a/drivers/mmc/core/slot-gpio.c b/drivers/mmc/core/slot-gpio.c
657 +index 2a833686784b..86803a3a04dc 100644
658 +--- a/drivers/mmc/core/slot-gpio.c
659 ++++ b/drivers/mmc/core/slot-gpio.c
660 +@@ -271,7 +271,7 @@ int mmc_gpiod_request_cd(struct mmc_host *host, const char *con_id,
661 + if (debounce) {
662 + ret = gpiod_set_debounce(desc, debounce);
663 + if (ret < 0)
664 +- ctx->cd_debounce_delay_ms = debounce;
665 ++ ctx->cd_debounce_delay_ms = debounce / 1000;
666 + }
667 +
668 + if (gpio_invert)
669 +diff --git a/drivers/net/wireless/ath/ath10k/wmi-tlv.c b/drivers/net/wireless/ath/ath10k/wmi-tlv.c
670 +index 21eb3a598a86..bdaad6e93be5 100644
671 +--- a/drivers/net/wireless/ath/ath10k/wmi-tlv.c
672 ++++ b/drivers/net/wireless/ath/ath10k/wmi-tlv.c
673 +@@ -1619,10 +1619,10 @@ ath10k_wmi_tlv_op_gen_start_scan(struct ath10k *ar,
674 + bssid_len = arg->n_bssids * sizeof(struct wmi_mac_addr);
675 + ie_len = roundup(arg->ie_len, 4);
676 + len = (sizeof(*tlv) + sizeof(*cmd)) +
677 +- (arg->n_channels ? sizeof(*tlv) + chan_len : 0) +
678 +- (arg->n_ssids ? sizeof(*tlv) + ssid_len : 0) +
679 +- (arg->n_bssids ? sizeof(*tlv) + bssid_len : 0) +
680 +- (arg->ie_len ? sizeof(*tlv) + ie_len : 0);
681 ++ sizeof(*tlv) + chan_len +
682 ++ sizeof(*tlv) + ssid_len +
683 ++ sizeof(*tlv) + bssid_len +
684 ++ sizeof(*tlv) + ie_len;
685 +
686 + skb = ath10k_wmi_alloc_skb(ar, len);
687 + if (!skb)
688 +diff --git a/drivers/net/xen-netback/hash.c b/drivers/net/xen-netback/hash.c
689 +index 3c4c58b9fe76..3b6fb5b3bdb2 100644
690 +--- a/drivers/net/xen-netback/hash.c
691 ++++ b/drivers/net/xen-netback/hash.c
692 +@@ -332,20 +332,22 @@ u32 xenvif_set_hash_mapping_size(struct xenvif *vif, u32 size)
693 + u32 xenvif_set_hash_mapping(struct xenvif *vif, u32 gref, u32 len,
694 + u32 off)
695 + {
696 +- u32 *mapping = &vif->hash.mapping[off];
697 ++ u32 *mapping = vif->hash.mapping;
698 + struct gnttab_copy copy_op = {
699 + .source.u.ref = gref,
700 + .source.domid = vif->domid,
701 +- .dest.u.gmfn = virt_to_gfn(mapping),
702 + .dest.domid = DOMID_SELF,
703 +- .dest.offset = xen_offset_in_page(mapping),
704 +- .len = len * sizeof(u32),
705 ++ .len = len * sizeof(*mapping),
706 + .flags = GNTCOPY_source_gref
707 + };
708 +
709 +- if ((off + len > vif->hash.size) || copy_op.len > XEN_PAGE_SIZE)
710 ++ if ((off + len < off) || (off + len > vif->hash.size) ||
711 ++ len > XEN_PAGE_SIZE / sizeof(*mapping))
712 + return XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER;
713 +
714 ++ copy_op.dest.u.gmfn = virt_to_gfn(mapping + off);
715 ++ copy_op.dest.offset = xen_offset_in_page(mapping + off);
716 ++
717 + while (len-- != 0)
718 + if (mapping[off++] >= vif->num_queues)
719 + return XEN_NETIF_CTRL_STATUS_INVALID_PARAMETER;
720 +diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
721 +index 722537e14848..41b49716ac75 100644
722 +--- a/drivers/of/unittest.c
723 ++++ b/drivers/of/unittest.c
724 +@@ -771,6 +771,9 @@ static void __init of_unittest_parse_interrupts(void)
725 + struct of_phandle_args args;
726 + int i, rc;
727 +
728 ++ if (of_irq_workarounds & OF_IMAP_OLDWORLD_MAC)
729 ++ return;
730 ++
731 + np = of_find_node_by_path("/testcase-data/interrupts/interrupts0");
732 + if (!np) {
733 + pr_err("missing testcase data\n");
734 +@@ -845,6 +848,9 @@ static void __init of_unittest_parse_interrupts_extended(void)
735 + struct of_phandle_args args;
736 + int i, rc;
737 +
738 ++ if (of_irq_workarounds & OF_IMAP_OLDWORLD_MAC)
739 ++ return;
740 ++
741 + np = of_find_node_by_path("/testcase-data/interrupts/interrupts-extended0");
742 + if (!np) {
743 + pr_err("missing testcase data\n");
744 +@@ -1001,15 +1007,19 @@ static void __init of_unittest_platform_populate(void)
745 + pdev = of_find_device_by_node(np);
746 + unittest(pdev, "device 1 creation failed\n");
747 +
748 +- irq = platform_get_irq(pdev, 0);
749 +- unittest(irq == -EPROBE_DEFER, "device deferred probe failed - %d\n", irq);
750 ++ if (!(of_irq_workarounds & OF_IMAP_OLDWORLD_MAC)) {
751 ++ irq = platform_get_irq(pdev, 0);
752 ++ unittest(irq == -EPROBE_DEFER,
753 ++ "device deferred probe failed - %d\n", irq);
754 +
755 +- /* Test that a parsing failure does not return -EPROBE_DEFER */
756 +- np = of_find_node_by_path("/testcase-data/testcase-device2");
757 +- pdev = of_find_device_by_node(np);
758 +- unittest(pdev, "device 2 creation failed\n");
759 +- irq = platform_get_irq(pdev, 0);
760 +- unittest(irq < 0 && irq != -EPROBE_DEFER, "device parsing error failed - %d\n", irq);
761 ++ /* Test that a parsing failure does not return -EPROBE_DEFER */
762 ++ np = of_find_node_by_path("/testcase-data/testcase-device2");
763 ++ pdev = of_find_device_by_node(np);
764 ++ unittest(pdev, "device 2 creation failed\n");
765 ++ irq = platform_get_irq(pdev, 0);
766 ++ unittest(irq < 0 && irq != -EPROBE_DEFER,
767 ++ "device parsing error failed - %d\n", irq);
768 ++ }
769 +
770 + np = of_find_node_by_path("/testcase-data/platform-tests");
771 + unittest(np, "No testcase data in device tree\n");
772 +diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
773 +index 0abe2865a3a5..c97ad905e7c9 100644
774 +--- a/drivers/pci/pci.c
775 ++++ b/drivers/pci/pci.c
776 +@@ -1125,12 +1125,12 @@ int pci_save_state(struct pci_dev *dev)
777 + EXPORT_SYMBOL(pci_save_state);
778 +
779 + static void pci_restore_config_dword(struct pci_dev *pdev, int offset,
780 +- u32 saved_val, int retry)
781 ++ u32 saved_val, int retry, bool force)
782 + {
783 + u32 val;
784 +
785 + pci_read_config_dword(pdev, offset, &val);
786 +- if (val == saved_val)
787 ++ if (!force && val == saved_val)
788 + return;
789 +
790 + for (;;) {
791 +@@ -1149,25 +1149,36 @@ static void pci_restore_config_dword(struct pci_dev *pdev, int offset,
792 + }
793 +
794 + static void pci_restore_config_space_range(struct pci_dev *pdev,
795 +- int start, int end, int retry)
796 ++ int start, int end, int retry,
797 ++ bool force)
798 + {
799 + int index;
800 +
801 + for (index = end; index >= start; index--)
802 + pci_restore_config_dword(pdev, 4 * index,
803 + pdev->saved_config_space[index],
804 +- retry);
805 ++ retry, force);
806 + }
807 +
808 + static void pci_restore_config_space(struct pci_dev *pdev)
809 + {
810 + if (pdev->hdr_type == PCI_HEADER_TYPE_NORMAL) {
811 +- pci_restore_config_space_range(pdev, 10, 15, 0);
812 ++ pci_restore_config_space_range(pdev, 10, 15, 0, false);
813 + /* Restore BARs before the command register. */
814 +- pci_restore_config_space_range(pdev, 4, 9, 10);
815 +- pci_restore_config_space_range(pdev, 0, 3, 0);
816 ++ pci_restore_config_space_range(pdev, 4, 9, 10, false);
817 ++ pci_restore_config_space_range(pdev, 0, 3, 0, false);
818 ++ } else if (pdev->hdr_type == PCI_HEADER_TYPE_BRIDGE) {
819 ++ pci_restore_config_space_range(pdev, 12, 15, 0, false);
820 ++
821 ++ /*
822 ++ * Force rewriting of prefetch registers to avoid S3 resume
823 ++ * issues on Intel PCI bridges that occur when these
824 ++ * registers are not explicitly written.
825 ++ */
826 ++ pci_restore_config_space_range(pdev, 9, 11, 0, true);
827 ++ pci_restore_config_space_range(pdev, 0, 8, 0, false);
828 + } else {
829 +- pci_restore_config_space_range(pdev, 0, 15, 0);
830 ++ pci_restore_config_space_range(pdev, 0, 15, 0, false);
831 + }
832 + }
833 +
834 +diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
835 +index aba59521ad48..31d06f59c4e4 100644
836 +--- a/drivers/tty/tty_io.c
837 ++++ b/drivers/tty/tty_io.c
838 +@@ -1264,6 +1264,7 @@ static void tty_driver_remove_tty(struct tty_driver *driver, struct tty_struct *
839 + static int tty_reopen(struct tty_struct *tty)
840 + {
841 + struct tty_driver *driver = tty->driver;
842 ++ int retval;
843 +
844 + if (driver->type == TTY_DRIVER_TYPE_PTY &&
845 + driver->subtype == PTY_TYPE_MASTER)
846 +@@ -1277,10 +1278,14 @@ static int tty_reopen(struct tty_struct *tty)
847 +
848 + tty->count++;
849 +
850 +- if (!tty->ldisc)
851 +- return tty_ldisc_reinit(tty, tty->termios.c_line);
852 ++ if (tty->ldisc)
853 ++ return 0;
854 +
855 +- return 0;
856 ++ retval = tty_ldisc_reinit(tty, tty->termios.c_line);
857 ++ if (retval)
858 ++ tty->count--;
859 ++
860 ++ return retval;
861 + }
862 +
863 + /**
864 +diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
865 +index f8ee32d9843a..84f52774810a 100644
866 +--- a/drivers/usb/class/cdc-acm.c
867 ++++ b/drivers/usb/class/cdc-acm.c
868 +@@ -1514,6 +1514,7 @@ static void acm_disconnect(struct usb_interface *intf)
869 + {
870 + struct acm *acm = usb_get_intfdata(intf);
871 + struct tty_struct *tty;
872 ++ int i;
873 +
874 + /* sibling interface is already cleaning up */
875 + if (!acm)
876 +@@ -1544,6 +1545,11 @@ static void acm_disconnect(struct usb_interface *intf)
877 +
878 + tty_unregister_device(acm_tty_driver, acm->minor);
879 +
880 ++ usb_free_urb(acm->ctrlurb);
881 ++ for (i = 0; i < ACM_NW; i++)
882 ++ usb_free_urb(acm->wb[i].urb);
883 ++ for (i = 0; i < acm->rx_buflimit; i++)
884 ++ usb_free_urb(acm->read_urbs[i]);
885 + acm_write_buffers_free(acm);
886 + usb_free_coherent(acm->dev, acm->ctrlsize, acm->ctrl_buffer, acm->ctrl_dma);
887 + acm_read_buffers_free(acm);
888 +diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
889 +index 7334da9e9779..71d0d33c3286 100644
890 +--- a/drivers/usb/host/xhci-mtk.c
891 ++++ b/drivers/usb/host/xhci-mtk.c
892 +@@ -642,10 +642,10 @@ static int __maybe_unused xhci_mtk_resume(struct device *dev)
893 + xhci_mtk_host_enable(mtk);
894 +
895 + xhci_dbg(xhci, "%s: restart port polling\n", __func__);
896 +- set_bit(HCD_FLAG_POLL_RH, &hcd->flags);
897 +- usb_hcd_poll_rh_status(hcd);
898 + set_bit(HCD_FLAG_POLL_RH, &xhci->shared_hcd->flags);
899 + usb_hcd_poll_rh_status(xhci->shared_hcd);
900 ++ set_bit(HCD_FLAG_POLL_RH, &hcd->flags);
901 ++ usb_hcd_poll_rh_status(hcd);
902 + return 0;
903 + }
904 +
905 +diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
906 +index 6372edf339d9..722860eb5a91 100644
907 +--- a/drivers/usb/host/xhci-pci.c
908 ++++ b/drivers/usb/host/xhci-pci.c
909 +@@ -185,6 +185,8 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
910 + }
911 + if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
912 + (pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI ||
913 ++ pdev->device == PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_XHCI ||
914 ++ pdev->device == PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_XHCI ||
915 + pdev->device == PCI_DEVICE_ID_INTEL_APL_XHCI ||
916 + pdev->device == PCI_DEVICE_ID_INTEL_DNV_XHCI))
917 + xhci->quirks |= XHCI_MISSING_CAS;
918 +diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
919 +index 0215b70c4efc..e72ad9f81c73 100644
920 +--- a/drivers/usb/serial/option.c
921 ++++ b/drivers/usb/serial/option.c
922 +@@ -561,6 +561,9 @@ static void option_instat_callback(struct urb *urb);
923 + /* Interface is reserved */
924 + #define RSVD(ifnum) ((BIT(ifnum) & 0xff) << 0)
925 +
926 ++/* Interface must have two endpoints */
927 ++#define NUMEP2 BIT(16)
928 ++
929 +
930 + static const struct usb_device_id option_ids[] = {
931 + { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) },
932 +@@ -1081,8 +1084,9 @@ static const struct usb_device_id option_ids[] = {
933 + .driver_info = RSVD(4) },
934 + { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_BG96),
935 + .driver_info = RSVD(4) },
936 +- { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EP06),
937 +- .driver_info = RSVD(4) | RSVD(5) },
938 ++ { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EP06, 0xff, 0xff, 0xff),
939 ++ .driver_info = RSVD(1) | RSVD(2) | RSVD(3) | RSVD(4) | NUMEP2 },
940 ++ { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EP06, 0xff, 0, 0) },
941 + { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6001) },
942 + { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CMU_300) },
943 + { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6003),
944 +@@ -1999,6 +2003,13 @@ static int option_probe(struct usb_serial *serial,
945 + if (device_flags & RSVD(iface_desc->bInterfaceNumber))
946 + return -ENODEV;
947 +
948 ++ /*
949 ++ * Allow matching on bNumEndpoints for devices whose interface numbers
950 ++ * can change (e.g. Quectel EP06).
951 ++ */
952 ++ if (device_flags & NUMEP2 && iface_desc->bNumEndpoints != 2)
953 ++ return -ENODEV;
954 ++
955 + /* Store the device flags so we can use them during attach. */
956 + usb_set_serial_data(serial, (void *)device_flags);
957 +
958 +diff --git a/drivers/usb/serial/usb-serial-simple.c b/drivers/usb/serial/usb-serial-simple.c
959 +index 40864c2bd9dc..4d0273508043 100644
960 +--- a/drivers/usb/serial/usb-serial-simple.c
961 ++++ b/drivers/usb/serial/usb-serial-simple.c
962 +@@ -84,7 +84,8 @@ DEVICE(moto_modem, MOTO_IDS);
963 +
964 + /* Motorola Tetra driver */
965 + #define MOTOROLA_TETRA_IDS() \
966 +- { USB_DEVICE(0x0cad, 0x9011) } /* Motorola Solutions TETRA PEI */
967 ++ { USB_DEVICE(0x0cad, 0x9011) }, /* Motorola Solutions TETRA PEI */ \
968 ++ { USB_DEVICE(0x0cad, 0x9012) } /* MTP6550 */
969 + DEVICE(motorola_tetra, MOTOROLA_TETRA_IDS);
970 +
971 + /* Novatel Wireless GPS driver */
972 +diff --git a/drivers/video/fbdev/omap2/omapfb/omapfb-ioctl.c b/drivers/video/fbdev/omap2/omapfb/omapfb-ioctl.c
973 +index ef69273074ba..a3edb20ea4c3 100644
974 +--- a/drivers/video/fbdev/omap2/omapfb/omapfb-ioctl.c
975 ++++ b/drivers/video/fbdev/omap2/omapfb/omapfb-ioctl.c
976 +@@ -496,6 +496,9 @@ static int omapfb_memory_read(struct fb_info *fbi,
977 + if (!access_ok(VERIFY_WRITE, mr->buffer, mr->buffer_size))
978 + return -EFAULT;
979 +
980 ++ if (mr->w > 4096 || mr->h > 4096)
981 ++ return -EINVAL;
982 ++
983 + if (mr->w * mr->h * 3 > mr->buffer_size)
984 + return -EINVAL;
985 +
986 +@@ -509,7 +512,7 @@ static int omapfb_memory_read(struct fb_info *fbi,
987 + mr->x, mr->y, mr->w, mr->h);
988 +
989 + if (r > 0) {
990 +- if (copy_to_user(mr->buffer, buf, mr->buffer_size))
991 ++ if (copy_to_user(mr->buffer, buf, r))
992 + r = -EFAULT;
993 + }
994 +
995 +diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
996 +index 9f1c96caebda..782e7243c5c0 100644
997 +--- a/fs/f2fs/checkpoint.c
998 ++++ b/fs/f2fs/checkpoint.c
999 +@@ -746,6 +746,7 @@ static int get_checkpoint_version(struct f2fs_sb_info *sbi, block_t cp_addr,
1000 +
1001 + crc_offset = le32_to_cpu((*cp_block)->checksum_offset);
1002 + if (crc_offset > (blk_size - sizeof(__le32))) {
1003 ++ f2fs_put_page(*cp_page, 1);
1004 + f2fs_msg(sbi->sb, KERN_WARNING,
1005 + "invalid crc_offset: %zu", crc_offset);
1006 + return -EINVAL;
1007 +@@ -753,6 +754,7 @@ static int get_checkpoint_version(struct f2fs_sb_info *sbi, block_t cp_addr,
1008 +
1009 + crc = cur_cp_crc(*cp_block);
1010 + if (!f2fs_crc_valid(sbi, crc, *cp_block, crc_offset)) {
1011 ++ f2fs_put_page(*cp_page, 1);
1012 + f2fs_msg(sbi->sb, KERN_WARNING, "invalid crc value");
1013 + return -EINVAL;
1014 + }
1015 +@@ -772,14 +774,14 @@ static struct page *validate_checkpoint(struct f2fs_sb_info *sbi,
1016 + err = get_checkpoint_version(sbi, cp_addr, &cp_block,
1017 + &cp_page_1, version);
1018 + if (err)
1019 +- goto invalid_cp1;
1020 ++ return NULL;
1021 + pre_version = *version;
1022 +
1023 + cp_addr += le32_to_cpu(cp_block->cp_pack_total_block_count) - 1;
1024 + err = get_checkpoint_version(sbi, cp_addr, &cp_block,
1025 + &cp_page_2, version);
1026 + if (err)
1027 +- goto invalid_cp2;
1028 ++ goto invalid_cp;
1029 + cur_version = *version;
1030 +
1031 + if (cur_version == pre_version) {
1032 +@@ -787,9 +789,8 @@ static struct page *validate_checkpoint(struct f2fs_sb_info *sbi,
1033 + f2fs_put_page(cp_page_2, 1);
1034 + return cp_page_1;
1035 + }
1036 +-invalid_cp2:
1037 + f2fs_put_page(cp_page_2, 1);
1038 +-invalid_cp1:
1039 ++invalid_cp:
1040 + f2fs_put_page(cp_page_1, 1);
1041 + return NULL;
1042 + }
1043 +diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
1044 +index bbd1e357c23d..f4fd2e72add4 100644
1045 +--- a/fs/pstore/ram.c
1046 ++++ b/fs/pstore/ram.c
1047 +@@ -898,8 +898,22 @@ static struct platform_driver ramoops_driver = {
1048 + },
1049 + };
1050 +
1051 +-static void ramoops_register_dummy(void)
1052 ++static inline void ramoops_unregister_dummy(void)
1053 + {
1054 ++ platform_device_unregister(dummy);
1055 ++ dummy = NULL;
1056 ++
1057 ++ kfree(dummy_data);
1058 ++ dummy_data = NULL;
1059 ++}
1060 ++
1061 ++static void __init ramoops_register_dummy(void)
1062 ++{
1063 ++ /*
1064 ++ * Prepare a dummy platform data structure to carry the module
1065 ++ * parameters. If mem_size isn't set, then there are no module
1066 ++ * parameters, and we can skip this.
1067 ++ */
1068 + if (!mem_size)
1069 + return;
1070 +
1071 +@@ -932,21 +946,28 @@ static void ramoops_register_dummy(void)
1072 + if (IS_ERR(dummy)) {
1073 + pr_info("could not create platform device: %ld\n",
1074 + PTR_ERR(dummy));
1075 ++ dummy = NULL;
1076 ++ ramoops_unregister_dummy();
1077 + }
1078 + }
1079 +
1080 + static int __init ramoops_init(void)
1081 + {
1082 ++ int ret;
1083 ++
1084 + ramoops_register_dummy();
1085 +- return platform_driver_register(&ramoops_driver);
1086 ++ ret = platform_driver_register(&ramoops_driver);
1087 ++ if (ret != 0)
1088 ++ ramoops_unregister_dummy();
1089 ++
1090 ++ return ret;
1091 + }
1092 + late_initcall(ramoops_init);
1093 +
1094 + static void __exit ramoops_exit(void)
1095 + {
1096 + platform_driver_unregister(&ramoops_driver);
1097 +- platform_device_unregister(dummy);
1098 +- kfree(dummy_data);
1099 ++ ramoops_unregister_dummy();
1100 + }
1101 + module_exit(ramoops_exit);
1102 +
1103 +diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
1104 +index c5466c70d620..2a82aeeacba5 100644
1105 +--- a/fs/ubifs/super.c
1106 ++++ b/fs/ubifs/super.c
1107 +@@ -1929,6 +1929,9 @@ static struct ubi_volume_desc *open_ubi(const char *name, int mode)
1108 + int dev, vol;
1109 + char *endptr;
1110 +
1111 ++ if (!name || !*name)
1112 ++ return ERR_PTR(-EINVAL);
1113 ++
1114 + /* First, try to open using the device node path method */
1115 + ubi = ubi_open_volume_path(name, mode);
1116 + if (!IS_ERR(ubi))
1117 +diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
1118 +index 36fa6a2a82e3..4ee95d8c8413 100644
1119 +--- a/include/linux/hugetlb.h
1120 ++++ b/include/linux/hugetlb.h
1121 +@@ -140,6 +140,8 @@ pte_t *huge_pte_alloc(struct mm_struct *mm,
1122 + pte_t *huge_pte_offset(struct mm_struct *mm,
1123 + unsigned long addr, unsigned long sz);
1124 + int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr, pte_t *ptep);
1125 ++void adjust_range_if_pmd_sharing_possible(struct vm_area_struct *vma,
1126 ++ unsigned long *start, unsigned long *end);
1127 + struct page *follow_huge_addr(struct mm_struct *mm, unsigned long address,
1128 + int write);
1129 + struct page *follow_huge_pd(struct vm_area_struct *vma,
1130 +@@ -170,6 +172,18 @@ static inline unsigned long hugetlb_total_pages(void)
1131 + return 0;
1132 + }
1133 +
1134 ++static inline int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr,
1135 ++ pte_t *ptep)
1136 ++{
1137 ++ return 0;
1138 ++}
1139 ++
1140 ++static inline void adjust_range_if_pmd_sharing_possible(
1141 ++ struct vm_area_struct *vma,
1142 ++ unsigned long *start, unsigned long *end)
1143 ++{
1144 ++}
1145 ++
1146 + #define follow_hugetlb_page(m,v,p,vs,a,b,i,w,n) ({ BUG(); 0; })
1147 + #define follow_huge_addr(mm, addr, write) ERR_PTR(-EINVAL)
1148 + #define copy_hugetlb_page_range(src, dst, vma) ({ BUG(); 0; })
1149 +diff --git a/include/linux/mm.h b/include/linux/mm.h
1150 +index 68a5121694ef..40ad93bc9548 100644
1151 +--- a/include/linux/mm.h
1152 ++++ b/include/linux/mm.h
1153 +@@ -2463,6 +2463,12 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
1154 + return vma;
1155 + }
1156 +
1157 ++static inline bool range_in_vma(struct vm_area_struct *vma,
1158 ++ unsigned long start, unsigned long end)
1159 ++{
1160 ++ return (vma && vma->vm_start <= start && end <= vma->vm_end);
1161 ++}
1162 ++
1163 + #ifdef CONFIG_MMU
1164 + pgprot_t vm_get_page_prot(unsigned long vm_flags);
1165 + void vma_set_page_prot(struct vm_area_struct *vma);
1166 +diff --git a/kernel/events/core.c b/kernel/events/core.c
1167 +index c7b3e34811ec..ae22d93701db 100644
1168 +--- a/kernel/events/core.c
1169 ++++ b/kernel/events/core.c
1170 +@@ -3940,6 +3940,12 @@ int perf_event_read_local(struct perf_event *event, u64 *value,
1171 + goto out;
1172 + }
1173 +
1174 ++ /* If this is a pinned event it must be running on this CPU */
1175 ++ if (event->attr.pinned && event->oncpu != smp_processor_id()) {
1176 ++ ret = -EBUSY;
1177 ++ goto out;
1178 ++ }
1179 ++
1180 + /*
1181 + * If the event is currently on this CPU, its either a per-task event,
1182 + * or local to this CPU. Furthermore it means its ACTIVE (otherwise
1183 +diff --git a/mm/huge_memory.c b/mm/huge_memory.c
1184 +index 25346bd99364..571875b37453 100644
1185 +--- a/mm/huge_memory.c
1186 ++++ b/mm/huge_memory.c
1187 +@@ -2929,7 +2929,7 @@ void remove_migration_pmd(struct page_vma_mapped_walk *pvmw, struct page *new)
1188 + else
1189 + page_add_file_rmap(new, true);
1190 + set_pmd_at(mm, mmun_start, pvmw->pmd, pmde);
1191 +- if (vma->vm_flags & VM_LOCKED)
1192 ++ if ((vma->vm_flags & VM_LOCKED) && !PageDoubleMap(new))
1193 + mlock_vma_page(new);
1194 + update_mmu_cache_pmd(vma, address, pvmw->pmd);
1195 + }
1196 +diff --git a/mm/hugetlb.c b/mm/hugetlb.c
1197 +index 3103099f64fd..f469315a6a0f 100644
1198 +--- a/mm/hugetlb.c
1199 ++++ b/mm/hugetlb.c
1200 +@@ -4556,12 +4556,40 @@ static bool vma_shareable(struct vm_area_struct *vma, unsigned long addr)
1201 + /*
1202 + * check on proper vm_flags and page table alignment
1203 + */
1204 +- if (vma->vm_flags & VM_MAYSHARE &&
1205 +- vma->vm_start <= base && end <= vma->vm_end)
1206 ++ if (vma->vm_flags & VM_MAYSHARE && range_in_vma(vma, base, end))
1207 + return true;
1208 + return false;
1209 + }
1210 +
1211 ++/*
1212 ++ * Determine if start,end range within vma could be mapped by shared pmd.
1213 ++ * If yes, adjust start and end to cover range associated with possible
1214 ++ * shared pmd mappings.
1215 ++ */
1216 ++void adjust_range_if_pmd_sharing_possible(struct vm_area_struct *vma,
1217 ++ unsigned long *start, unsigned long *end)
1218 ++{
1219 ++ unsigned long check_addr = *start;
1220 ++
1221 ++ if (!(vma->vm_flags & VM_MAYSHARE))
1222 ++ return;
1223 ++
1224 ++ for (check_addr = *start; check_addr < *end; check_addr += PUD_SIZE) {
1225 ++ unsigned long a_start = check_addr & PUD_MASK;
1226 ++ unsigned long a_end = a_start + PUD_SIZE;
1227 ++
1228 ++ /*
1229 ++ * If sharing is possible, adjust start/end if necessary.
1230 ++ */
1231 ++ if (range_in_vma(vma, a_start, a_end)) {
1232 ++ if (a_start < *start)
1233 ++ *start = a_start;
1234 ++ if (a_end > *end)
1235 ++ *end = a_end;
1236 ++ }
1237 ++ }
1238 ++}
1239 ++
1240 + /*
1241 + * Search for a shareable pmd page for hugetlb. In any case calls pmd_alloc()
1242 + * and returns the corresponding pte. While this is not necessary for the
1243 +@@ -4659,6 +4687,11 @@ int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr, pte_t *ptep)
1244 + {
1245 + return 0;
1246 + }
1247 ++
1248 ++void adjust_range_if_pmd_sharing_possible(struct vm_area_struct *vma,
1249 ++ unsigned long *start, unsigned long *end)
1250 ++{
1251 ++}
1252 + #define want_pmd_share() (0)
1253 + #endif /* CONFIG_ARCH_WANT_HUGE_PMD_SHARE */
1254 +
1255 +diff --git a/mm/migrate.c b/mm/migrate.c
1256 +index 8c0af0f7cab1..2a55289ee9f1 100644
1257 +--- a/mm/migrate.c
1258 ++++ b/mm/migrate.c
1259 +@@ -275,6 +275,9 @@ static bool remove_migration_pte(struct page *page, struct vm_area_struct *vma,
1260 + if (vma->vm_flags & VM_LOCKED && !PageTransCompound(new))
1261 + mlock_vma_page(new);
1262 +
1263 ++ if (PageTransHuge(page) && PageMlocked(page))
1264 ++ clear_page_mlock(page);
1265 ++
1266 + /* No need to invalidate - it was non-present before */
1267 + update_mmu_cache(vma, pvmw.address, pvmw.pte);
1268 + }
1269 +diff --git a/mm/rmap.c b/mm/rmap.c
1270 +index eb477809a5c0..1e79fac3186b 100644
1271 +--- a/mm/rmap.c
1272 ++++ b/mm/rmap.c
1273 +@@ -1362,11 +1362,21 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
1274 + }
1275 +
1276 + /*
1277 +- * We have to assume the worse case ie pmd for invalidation. Note that
1278 +- * the page can not be free in this function as call of try_to_unmap()
1279 +- * must hold a reference on the page.
1280 ++ * For THP, we have to assume the worse case ie pmd for invalidation.
1281 ++ * For hugetlb, it could be much worse if we need to do pud
1282 ++ * invalidation in the case of pmd sharing.
1283 ++ *
1284 ++ * Note that the page can not be free in this function as call of
1285 ++ * try_to_unmap() must hold a reference on the page.
1286 + */
1287 + end = min(vma->vm_end, start + (PAGE_SIZE << compound_order(page)));
1288 ++ if (PageHuge(page)) {
1289 ++ /*
1290 ++ * If sharing is possible, start and end will be adjusted
1291 ++ * accordingly.
1292 ++ */
1293 ++ adjust_range_if_pmd_sharing_possible(vma, &start, &end);
1294 ++ }
1295 + mmu_notifier_invalidate_range_start(vma->vm_mm, start, end);
1296 +
1297 + while (page_vma_mapped_walk(&pvmw)) {
1298 +@@ -1409,6 +1419,32 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
1299 + subpage = page - page_to_pfn(page) + pte_pfn(*pvmw.pte);
1300 + address = pvmw.address;
1301 +
1302 ++ if (PageHuge(page)) {
1303 ++ if (huge_pmd_unshare(mm, &address, pvmw.pte)) {
1304 ++ /*
1305 ++ * huge_pmd_unshare unmapped an entire PMD
1306 ++ * page. There is no way of knowing exactly
1307 ++ * which PMDs may be cached for this mm, so
1308 ++ * we must flush them all. start/end were
1309 ++ * already adjusted above to cover this range.
1310 ++ */
1311 ++ flush_cache_range(vma, start, end);
1312 ++ flush_tlb_range(vma, start, end);
1313 ++ mmu_notifier_invalidate_range(mm, start, end);
1314 ++
1315 ++ /*
1316 ++ * The ref count of the PMD page was dropped
1317 ++ * which is part of the way map counting
1318 ++ * is done for shared PMDs. Return 'true'
1319 ++ * here. When there is no other sharing,
1320 ++ * huge_pmd_unshare returns false and we will
1321 ++ * unmap the actual page and drop map count
1322 ++ * to zero.
1323 ++ */
1324 ++ page_vma_mapped_walk_done(&pvmw);
1325 ++ break;
1326 ++ }
1327 ++ }
1328 +
1329 + if (IS_ENABLED(CONFIG_MIGRATION) &&
1330 + (flags & TTU_MIGRATION) &&
1331 +diff --git a/mm/vmstat.c b/mm/vmstat.c
1332 +index 8ba0870ecddd..55a5bb1d773d 100644
1333 +--- a/mm/vmstat.c
1334 ++++ b/mm/vmstat.c
1335 +@@ -1275,6 +1275,9 @@ const char * const vmstat_text[] = {
1336 + #ifdef CONFIG_SMP
1337 + "nr_tlb_remote_flush",
1338 + "nr_tlb_remote_flush_received",
1339 ++#else
1340 ++ "", /* nr_tlb_remote_flush */
1341 ++ "", /* nr_tlb_remote_flush_received */
1342 + #endif /* CONFIG_SMP */
1343 + "nr_tlb_local_flush_all",
1344 + "nr_tlb_local_flush_one",
1345 +diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
1346 +index aa082b71d2e4..c6bbe5b56378 100644
1347 +--- a/net/mac80211/cfg.c
1348 ++++ b/net/mac80211/cfg.c
1349 +@@ -427,7 +427,7 @@ static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev,
1350 + case NL80211_IFTYPE_AP:
1351 + case NL80211_IFTYPE_AP_VLAN:
1352 + /* Keys without a station are used for TX only */
1353 +- if (key->sta && test_sta_flag(key->sta, WLAN_STA_MFP))
1354 ++ if (sta && test_sta_flag(sta, WLAN_STA_MFP))
1355 + key->conf.flags |= IEEE80211_KEY_FLAG_RX_MGMT;
1356 + break;
1357 + case NL80211_IFTYPE_ADHOC:
1358 +diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
1359 +index 555e389b7dfa..5d22c058ae23 100644
1360 +--- a/net/mac80211/iface.c
1361 ++++ b/net/mac80211/iface.c
1362 +@@ -1756,7 +1756,8 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name,
1363 +
1364 + if (local->ops->wake_tx_queue &&
1365 + type != NL80211_IFTYPE_AP_VLAN &&
1366 +- type != NL80211_IFTYPE_MONITOR)
1367 ++ (type != NL80211_IFTYPE_MONITOR ||
1368 ++ (params->flags & MONITOR_FLAG_ACTIVE)))
1369 + txq_size += sizeof(struct txq_info) +
1370 + local->hw.txq_data_size;
1371 +
1372 +diff --git a/net/rds/ib.h b/net/rds/ib.h
1373 +index a6f4d7d68e95..83ff7c18d691 100644
1374 +--- a/net/rds/ib.h
1375 ++++ b/net/rds/ib.h
1376 +@@ -371,7 +371,7 @@ void rds_ib_mr_cqe_handler(struct rds_ib_connection *ic, struct ib_wc *wc);
1377 + int rds_ib_recv_init(void);
1378 + void rds_ib_recv_exit(void);
1379 + int rds_ib_recv_path(struct rds_conn_path *conn);
1380 +-int rds_ib_recv_alloc_caches(struct rds_ib_connection *ic);
1381 ++int rds_ib_recv_alloc_caches(struct rds_ib_connection *ic, gfp_t gfp);
1382 + void rds_ib_recv_free_caches(struct rds_ib_connection *ic);
1383 + void rds_ib_recv_refill(struct rds_connection *conn, int prefill, gfp_t gfp);
1384 + void rds_ib_inc_free(struct rds_incoming *inc);
1385 +diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
1386 +index f1684ae6abfd..6a909ea9e8fb 100644
1387 +--- a/net/rds/ib_cm.c
1388 ++++ b/net/rds/ib_cm.c
1389 +@@ -949,7 +949,7 @@ int rds_ib_conn_alloc(struct rds_connection *conn, gfp_t gfp)
1390 + if (!ic)
1391 + return -ENOMEM;
1392 +
1393 +- ret = rds_ib_recv_alloc_caches(ic);
1394 ++ ret = rds_ib_recv_alloc_caches(ic, gfp);
1395 + if (ret) {
1396 + kfree(ic);
1397 + return ret;
1398 +diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
1399 +index b4e421aa9727..918d2e676b9b 100644
1400 +--- a/net/rds/ib_recv.c
1401 ++++ b/net/rds/ib_recv.c
1402 +@@ -98,12 +98,12 @@ static void rds_ib_cache_xfer_to_ready(struct rds_ib_refill_cache *cache)
1403 + }
1404 + }
1405 +
1406 +-static int rds_ib_recv_alloc_cache(struct rds_ib_refill_cache *cache)
1407 ++static int rds_ib_recv_alloc_cache(struct rds_ib_refill_cache *cache, gfp_t gfp)
1408 + {
1409 + struct rds_ib_cache_head *head;
1410 + int cpu;
1411 +
1412 +- cache->percpu = alloc_percpu(struct rds_ib_cache_head);
1413 ++ cache->percpu = alloc_percpu_gfp(struct rds_ib_cache_head, gfp);
1414 + if (!cache->percpu)
1415 + return -ENOMEM;
1416 +
1417 +@@ -118,13 +118,13 @@ static int rds_ib_recv_alloc_cache(struct rds_ib_refill_cache *cache)
1418 + return 0;
1419 + }
1420 +
1421 +-int rds_ib_recv_alloc_caches(struct rds_ib_connection *ic)
1422 ++int rds_ib_recv_alloc_caches(struct rds_ib_connection *ic, gfp_t gfp)
1423 + {
1424 + int ret;
1425 +
1426 +- ret = rds_ib_recv_alloc_cache(&ic->i_cache_incs);
1427 ++ ret = rds_ib_recv_alloc_cache(&ic->i_cache_incs, gfp);
1428 + if (!ret) {
1429 +- ret = rds_ib_recv_alloc_cache(&ic->i_cache_frags);
1430 ++ ret = rds_ib_recv_alloc_cache(&ic->i_cache_frags, gfp);
1431 + if (ret)
1432 + free_percpu(ic->i_cache_incs.percpu);
1433 + }
1434 +diff --git a/net/tipc/netlink_compat.c b/net/tipc/netlink_compat.c
1435 +index a2f76743c73a..82f665728382 100644
1436 +--- a/net/tipc/netlink_compat.c
1437 ++++ b/net/tipc/netlink_compat.c
1438 +@@ -185,6 +185,7 @@ static int __tipc_nl_compat_dumpit(struct tipc_nl_compat_cmd_dump *cmd,
1439 + return -ENOMEM;
1440 +
1441 + buf->sk = msg->dst_sk;
1442 ++ __tipc_dump_start(&cb, msg->net);
1443 +
1444 + do {
1445 + int rem;
1446 +@@ -216,6 +217,7 @@ static int __tipc_nl_compat_dumpit(struct tipc_nl_compat_cmd_dump *cmd,
1447 + err = 0;
1448 +
1449 + err_out:
1450 ++ tipc_dump_done(&cb);
1451 + kfree_skb(buf);
1452 +
1453 + if (err == -EMSGSIZE) {
1454 +diff --git a/net/tipc/socket.c b/net/tipc/socket.c
1455 +index bdb4a9a5a83a..093e16d1b770 100644
1456 +--- a/net/tipc/socket.c
1457 ++++ b/net/tipc/socket.c
1458 +@@ -3233,7 +3233,7 @@ int tipc_nl_sk_walk(struct sk_buff *skb, struct netlink_callback *cb,
1459 + struct netlink_callback *cb,
1460 + struct tipc_sock *tsk))
1461 + {
1462 +- struct rhashtable_iter *iter = (void *)cb->args[0];
1463 ++ struct rhashtable_iter *iter = (void *)cb->args[4];
1464 + struct tipc_sock *tsk;
1465 + int err;
1466 +
1467 +@@ -3269,8 +3269,14 @@ EXPORT_SYMBOL(tipc_nl_sk_walk);
1468 +
1469 + int tipc_dump_start(struct netlink_callback *cb)
1470 + {
1471 +- struct rhashtable_iter *iter = (void *)cb->args[0];
1472 +- struct net *net = sock_net(cb->skb->sk);
1473 ++ return __tipc_dump_start(cb, sock_net(cb->skb->sk));
1474 ++}
1475 ++EXPORT_SYMBOL(tipc_dump_start);
1476 ++
1477 ++int __tipc_dump_start(struct netlink_callback *cb, struct net *net)
1478 ++{
1479 ++ /* tipc_nl_name_table_dump() uses cb->args[0...3]. */
1480 ++ struct rhashtable_iter *iter = (void *)cb->args[4];
1481 + struct tipc_net *tn = tipc_net(net);
1482 +
1483 + if (!iter) {
1484 +@@ -3278,17 +3284,16 @@ int tipc_dump_start(struct netlink_callback *cb)
1485 + if (!iter)
1486 + return -ENOMEM;
1487 +
1488 +- cb->args[0] = (long)iter;
1489 ++ cb->args[4] = (long)iter;
1490 + }
1491 +
1492 + rhashtable_walk_enter(&tn->sk_rht, iter);
1493 + return 0;
1494 + }
1495 +-EXPORT_SYMBOL(tipc_dump_start);
1496 +
1497 + int tipc_dump_done(struct netlink_callback *cb)
1498 + {
1499 +- struct rhashtable_iter *hti = (void *)cb->args[0];
1500 ++ struct rhashtable_iter *hti = (void *)cb->args[4];
1501 +
1502 + rhashtable_walk_exit(hti);
1503 + kfree(hti);
1504 +diff --git a/net/tipc/socket.h b/net/tipc/socket.h
1505 +index d43032e26532..5e575f205afe 100644
1506 +--- a/net/tipc/socket.h
1507 ++++ b/net/tipc/socket.h
1508 +@@ -69,5 +69,6 @@ int tipc_nl_sk_walk(struct sk_buff *skb, struct netlink_callback *cb,
1509 + struct netlink_callback *cb,
1510 + struct tipc_sock *tsk));
1511 + int tipc_dump_start(struct netlink_callback *cb);
1512 ++int __tipc_dump_start(struct netlink_callback *cb, struct net *net);
1513 + int tipc_dump_done(struct netlink_callback *cb);
1514 + #endif
1515 +diff --git a/tools/testing/selftests/x86/test_vdso.c b/tools/testing/selftests/x86/test_vdso.c
1516 +index 235259011704..35edd61d1663 100644
1517 +--- a/tools/testing/selftests/x86/test_vdso.c
1518 ++++ b/tools/testing/selftests/x86/test_vdso.c
1519 +@@ -17,6 +17,7 @@
1520 + #include <errno.h>
1521 + #include <sched.h>
1522 + #include <stdbool.h>
1523 ++#include <limits.h>
1524 +
1525 + #ifndef SYS_getcpu
1526 + # ifdef __x86_64__
1527 +@@ -31,6 +32,14 @@
1528 +
1529 + int nerrs = 0;
1530 +
1531 ++typedef int (*vgettime_t)(clockid_t, struct timespec *);
1532 ++
1533 ++vgettime_t vdso_clock_gettime;
1534 ++
1535 ++typedef long (*vgtod_t)(struct timeval *tv, struct timezone *tz);
1536 ++
1537 ++vgtod_t vdso_gettimeofday;
1538 ++
1539 + typedef long (*getcpu_t)(unsigned *, unsigned *, void *);
1540 +
1541 + getcpu_t vgetcpu;
1542 +@@ -95,6 +104,15 @@ static void fill_function_pointers()
1543 + printf("Warning: failed to find getcpu in vDSO\n");
1544 +
1545 + vgetcpu = (getcpu_t) vsyscall_getcpu();
1546 ++
1547 ++ vdso_clock_gettime = (vgettime_t)dlsym(vdso, "__vdso_clock_gettime");
1548 ++ if (!vdso_clock_gettime)
1549 ++ printf("Warning: failed to find clock_gettime in vDSO\n");
1550 ++
1551 ++ vdso_gettimeofday = (vgtod_t)dlsym(vdso, "__vdso_gettimeofday");
1552 ++ if (!vdso_gettimeofday)
1553 ++ printf("Warning: failed to find gettimeofday in vDSO\n");
1554 ++
1555 + }
1556 +
1557 + static long sys_getcpu(unsigned * cpu, unsigned * node,
1558 +@@ -103,6 +121,16 @@ static long sys_getcpu(unsigned * cpu, unsigned * node,
1559 + return syscall(__NR_getcpu, cpu, node, cache);
1560 + }
1561 +
1562 ++static inline int sys_clock_gettime(clockid_t id, struct timespec *ts)
1563 ++{
1564 ++ return syscall(__NR_clock_gettime, id, ts);
1565 ++}
1566 ++
1567 ++static inline int sys_gettimeofday(struct timeval *tv, struct timezone *tz)
1568 ++{
1569 ++ return syscall(__NR_gettimeofday, tv, tz);
1570 ++}
1571 ++
1572 + static void test_getcpu(void)
1573 + {
1574 + printf("[RUN]\tTesting getcpu...\n");
1575 +@@ -155,10 +183,154 @@ static void test_getcpu(void)
1576 + }
1577 + }
1578 +
1579 ++static bool ts_leq(const struct timespec *a, const struct timespec *b)
1580 ++{
1581 ++ if (a->tv_sec != b->tv_sec)
1582 ++ return a->tv_sec < b->tv_sec;
1583 ++ else
1584 ++ return a->tv_nsec <= b->tv_nsec;
1585 ++}
1586 ++
1587 ++static bool tv_leq(const struct timeval *a, const struct timeval *b)
1588 ++{
1589 ++ if (a->tv_sec != b->tv_sec)
1590 ++ return a->tv_sec < b->tv_sec;
1591 ++ else
1592 ++ return a->tv_usec <= b->tv_usec;
1593 ++}
1594 ++
1595 ++static char const * const clocknames[] = {
1596 ++ [0] = "CLOCK_REALTIME",
1597 ++ [1] = "CLOCK_MONOTONIC",
1598 ++ [2] = "CLOCK_PROCESS_CPUTIME_ID",
1599 ++ [3] = "CLOCK_THREAD_CPUTIME_ID",
1600 ++ [4] = "CLOCK_MONOTONIC_RAW",
1601 ++ [5] = "CLOCK_REALTIME_COARSE",
1602 ++ [6] = "CLOCK_MONOTONIC_COARSE",
1603 ++ [7] = "CLOCK_BOOTTIME",
1604 ++ [8] = "CLOCK_REALTIME_ALARM",
1605 ++ [9] = "CLOCK_BOOTTIME_ALARM",
1606 ++ [10] = "CLOCK_SGI_CYCLE",
1607 ++ [11] = "CLOCK_TAI",
1608 ++};
1609 ++
1610 ++static void test_one_clock_gettime(int clock, const char *name)
1611 ++{
1612 ++ struct timespec start, vdso, end;
1613 ++ int vdso_ret, end_ret;
1614 ++
1615 ++ printf("[RUN]\tTesting clock_gettime for clock %s (%d)...\n", name, clock);
1616 ++
1617 ++ if (sys_clock_gettime(clock, &start) < 0) {
1618 ++ if (errno == EINVAL) {
1619 ++ vdso_ret = vdso_clock_gettime(clock, &vdso);
1620 ++ if (vdso_ret == -EINVAL) {
1621 ++ printf("[OK]\tNo such clock.\n");
1622 ++ } else {
1623 ++ printf("[FAIL]\tNo such clock, but __vdso_clock_gettime returned %d\n", vdso_ret);
1624 ++ nerrs++;
1625 ++ }
1626 ++ } else {
1627 ++ printf("[WARN]\t clock_gettime(%d) syscall returned error %d\n", clock, errno);
1628 ++ }
1629 ++ return;
1630 ++ }
1631 ++
1632 ++ vdso_ret = vdso_clock_gettime(clock, &vdso);
1633 ++ end_ret = sys_clock_gettime(clock, &end);
1634 ++
1635 ++ if (vdso_ret != 0 || end_ret != 0) {
1636 ++ printf("[FAIL]\tvDSO returned %d, syscall errno=%d\n",
1637 ++ vdso_ret, errno);
1638 ++ nerrs++;
1639 ++ return;
1640 ++ }
1641 ++
1642 ++ printf("\t%llu.%09ld %llu.%09ld %llu.%09ld\n",
1643 ++ (unsigned long long)start.tv_sec, start.tv_nsec,
1644 ++ (unsigned long long)vdso.tv_sec, vdso.tv_nsec,
1645 ++ (unsigned long long)end.tv_sec, end.tv_nsec);
1646 ++
1647 ++ if (!ts_leq(&start, &vdso) || !ts_leq(&vdso, &end)) {
1648 ++ printf("[FAIL]\tTimes are out of sequence\n");
1649 ++ nerrs++;
1650 ++ }
1651 ++}
1652 ++
1653 ++static void test_clock_gettime(void)
1654 ++{
1655 ++ for (int clock = 0; clock < sizeof(clocknames) / sizeof(clocknames[0]);
1656 ++ clock++) {
1657 ++ test_one_clock_gettime(clock, clocknames[clock]);
1658 ++ }
1659 ++
1660 ++ /* Also test some invalid clock ids */
1661 ++ test_one_clock_gettime(-1, "invalid");
1662 ++ test_one_clock_gettime(INT_MIN, "invalid");
1663 ++ test_one_clock_gettime(INT_MAX, "invalid");
1664 ++}
1665 ++
1666 ++static void test_gettimeofday(void)
1667 ++{
1668 ++ struct timeval start, vdso, end;
1669 ++ struct timezone sys_tz, vdso_tz;
1670 ++ int vdso_ret, end_ret;
1671 ++
1672 ++ if (!vdso_gettimeofday)
1673 ++ return;
1674 ++
1675 ++ printf("[RUN]\tTesting gettimeofday...\n");
1676 ++
1677 ++ if (sys_gettimeofday(&start, &sys_tz) < 0) {
1678 ++ printf("[FAIL]\tsys_gettimeofday failed (%d)\n", errno);
1679 ++ nerrs++;
1680 ++ return;
1681 ++ }
1682 ++
1683 ++ vdso_ret = vdso_gettimeofday(&vdso, &vdso_tz);
1684 ++ end_ret = sys_gettimeofday(&end, NULL);
1685 ++
1686 ++ if (vdso_ret != 0 || end_ret != 0) {
1687 ++ printf("[FAIL]\tvDSO returned %d, syscall errno=%d\n",
1688 ++ vdso_ret, errno);
1689 ++ nerrs++;
1690 ++ return;
1691 ++ }
1692 ++
1693 ++ printf("\t%llu.%06ld %llu.%06ld %llu.%06ld\n",
1694 ++ (unsigned long long)start.tv_sec, start.tv_usec,
1695 ++ (unsigned long long)vdso.tv_sec, vdso.tv_usec,
1696 ++ (unsigned long long)end.tv_sec, end.tv_usec);
1697 ++
1698 ++ if (!tv_leq(&start, &vdso) || !tv_leq(&vdso, &end)) {
1699 ++ printf("[FAIL]\tTimes are out of sequence\n");
1700 ++ nerrs++;
1701 ++ }
1702 ++
1703 ++ if (sys_tz.tz_minuteswest == vdso_tz.tz_minuteswest &&
1704 ++ sys_tz.tz_dsttime == vdso_tz.tz_dsttime) {
1705 ++ printf("[OK]\ttimezones match: minuteswest=%d, dsttime=%d\n",
1706 ++ sys_tz.tz_minuteswest, sys_tz.tz_dsttime);
1707 ++ } else {
1708 ++ printf("[FAIL]\ttimezones do not match\n");
1709 ++ nerrs++;
1710 ++ }
1711 ++
1712 ++ /* And make sure that passing NULL for tz doesn't crash. */
1713 ++ vdso_gettimeofday(&vdso, NULL);
1714 ++}
1715 ++
1716 + int main(int argc, char **argv)
1717 + {
1718 + fill_function_pointers();
1719 +
1720 ++ test_clock_gettime();
1721 ++ test_gettimeofday();
1722 ++
1723 ++ /*
1724 ++ * Test getcpu() last so that, if something goes wrong setting affinity,
1725 ++ * we still run the other tests.
1726 ++ */
1727 + test_getcpu();
1728 +
1729 + return nerrs ? 1 : 0;