Gentoo Archives: gentoo-commits

From: "Anthony G. Basile" <blueness@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/hardened-patchset:master commit in: 4.6.5/, 4.6.4/
Date: Fri, 29 Jul 2016 10:42:46
Message-Id: 1469788930.45fd70a4e4cc66277c3ad793b16e7ce60b592d37.blueness@gentoo
1 commit: 45fd70a4e4cc66277c3ad793b16e7ce60b592d37
2 Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
3 AuthorDate: Fri Jul 29 10:42:10 2016 +0000
4 Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
5 CommitDate: Fri Jul 29 10:42:10 2016 +0000
6 URL: https://gitweb.gentoo.org/proj/hardened-patchset.git/commit/?id=45fd70a4
7
8 grsecurity-3.1-4.6.5-201607272152
9
10 {4.6.4 => 4.6.5}/0000_README | 6 +-
11 4.6.5/1004_linux-4.6.5.patch | 7262 ++++++++++++++++++++
12 .../4420_grsecurity-3.1-4.6.5-201607272152.patch | 1741 +++--
13 {4.6.4 => 4.6.5}/4425_grsec_remove_EI_PAX.patch | 0
14 {4.6.4 => 4.6.5}/4427_force_XATTR_PAX_tmpfs.patch | 0
15 .../4430_grsec-remove-localversion-grsec.patch | 0
16 {4.6.4 => 4.6.5}/4435_grsec-mute-warnings.patch | 0
17 .../4440_grsec-remove-protected-paths.patch | 0
18 .../4450_grsec-kconfig-default-gids.patch | 0
19 .../4465_selinux-avc_audit-log-curr_ip.patch | 0
20 {4.6.4 => 4.6.5}/4470_disable-compat_vdso.patch | 0
21 {4.6.4 => 4.6.5}/4475_emutramp_default_on.patch | 0
22 12 files changed, 8045 insertions(+), 964 deletions(-)
23
24 diff --git a/4.6.4/0000_README b/4.6.5/0000_README
25 similarity index 92%
26 rename from 4.6.4/0000_README
27 rename to 4.6.5/0000_README
28 index 81410da..016e706 100644
29 --- a/4.6.4/0000_README
30 +++ b/4.6.5/0000_README
31 @@ -2,7 +2,11 @@ README
32 -----------------------------------------------------------------------------
33 Individual Patch Descriptions:
34 -----------------------------------------------------------------------------
35 -Patch: 4420_grsecurity-3.1-4.6.4-201607242014.patch
36 +Patch: 1004_linux-4.6.5.patch
37 +From: http://www.kernel.org
38 +Desc: Linux 4.6.5
39 +
40 +Patch: 4420_grsecurity-3.1-4.6.5-201607272152.patch
41 From: http://www.grsecurity.net
42 Desc: hardened-sources base patch from upstream grsecurity
43
44
45 diff --git a/4.6.5/1004_linux-4.6.5.patch b/4.6.5/1004_linux-4.6.5.patch
46 new file mode 100644
47 index 0000000..98b6b74
48 --- /dev/null
49 +++ b/4.6.5/1004_linux-4.6.5.patch
50 @@ -0,0 +1,7262 @@
51 +diff --git a/Documentation/ABI/testing/sysfs-bus-iio-proximity-as3935 b/Documentation/ABI/testing/sysfs-bus-iio-proximity-as3935
52 +index 6708c5e..33e96f7 100644
53 +--- a/Documentation/ABI/testing/sysfs-bus-iio-proximity-as3935
54 ++++ b/Documentation/ABI/testing/sysfs-bus-iio-proximity-as3935
55 +@@ -1,4 +1,4 @@
56 +-What /sys/bus/iio/devices/iio:deviceX/in_proximity_raw
57 ++What /sys/bus/iio/devices/iio:deviceX/in_proximity_input
58 + Date: March 2014
59 + KernelVersion: 3.15
60 + Contact: Matt Ranostay <mranostay@×××××.com>
61 +diff --git a/Documentation/scsi/scsi_eh.txt b/Documentation/scsi/scsi_eh.txt
62 +index 8638f61..37eca00 100644
63 +--- a/Documentation/scsi/scsi_eh.txt
64 ++++ b/Documentation/scsi/scsi_eh.txt
65 +@@ -263,19 +263,23 @@ scmd->allowed.
66 +
67 + 3. scmd recovered
68 + ACTION: scsi_eh_finish_cmd() is invoked to EH-finish scmd
69 +- - shost->host_failed--
70 + - clear scmd->eh_eflags
71 + - scsi_setup_cmd_retry()
72 + - move from local eh_work_q to local eh_done_q
73 + LOCKING: none
74 ++ CONCURRENCY: at most one thread per separate eh_work_q to
75 ++ keep queue manipulation lockless
76 +
77 + 4. EH completes
78 + ACTION: scsi_eh_flush_done_q() retries scmds or notifies upper
79 +- layer of failure.
80 ++ layer of failure. May be called concurrently but must have
81 ++ a no more than one thread per separate eh_work_q to
82 ++ manipulate the queue locklessly
83 + - scmd is removed from eh_done_q and scmd->eh_entry is cleared
84 + - if retry is necessary, scmd is requeued using
85 + scsi_queue_insert()
86 + - otherwise, scsi_finish_command() is invoked for scmd
87 ++ - zero shost->host_failed
88 + LOCKING: queue or finish function performs appropriate locking
89 +
90 +
91 +diff --git a/Makefile b/Makefile
92 +index cd37442..7d693a8 100644
93 +--- a/Makefile
94 ++++ b/Makefile
95 +@@ -1,6 +1,6 @@
96 + VERSION = 4
97 + PATCHLEVEL = 6
98 +-SUBLEVEL = 4
99 ++SUBLEVEL = 5
100 + EXTRAVERSION =
101 + NAME = Charred Weasel
102 +
103 +diff --git a/arch/arm/boot/dts/armada-385-linksys.dtsi b/arch/arm/boot/dts/armada-385-linksys.dtsi
104 +index 8450944..22f7a13 100644
105 +--- a/arch/arm/boot/dts/armada-385-linksys.dtsi
106 ++++ b/arch/arm/boot/dts/armada-385-linksys.dtsi
107 +@@ -58,8 +58,8 @@
108 + soc {
109 + ranges = <MBUS_ID(0xf0, 0x01) 0 0xf1000000 0x100000
110 + MBUS_ID(0x01, 0x1d) 0 0xfff00000 0x100000
111 +- MBUS_ID(0x09, 0x09) 0 0xf1100000 0x10000
112 +- MBUS_ID(0x09, 0x05) 0 0xf1110000 0x10000>;
113 ++ MBUS_ID(0x09, 0x19) 0 0xf1100000 0x10000
114 ++ MBUS_ID(0x09, 0x15) 0 0xf1110000 0x10000>;
115 +
116 + internal-regs {
117 +
118 +diff --git a/arch/arm/boot/dts/sun5i-r8-chip.dts b/arch/arm/boot/dts/sun5i-r8-chip.dts
119 +index f6898c6..c937c85 100644
120 +--- a/arch/arm/boot/dts/sun5i-r8-chip.dts
121 ++++ b/arch/arm/boot/dts/sun5i-r8-chip.dts
122 +@@ -52,7 +52,7 @@
123 +
124 + / {
125 + model = "NextThing C.H.I.P.";
126 +- compatible = "nextthing,chip", "allwinner,sun5i-r8";
127 ++ compatible = "nextthing,chip", "allwinner,sun5i-r8", "allwinner,sun5i-a13";
128 +
129 + aliases {
130 + i2c0 = &i2c0;
131 +diff --git a/arch/arm/boot/dts/sun6i-a31s-primo81.dts b/arch/arm/boot/dts/sun6i-a31s-primo81.dts
132 +index 68b479b..73c133f 100644
133 +--- a/arch/arm/boot/dts/sun6i-a31s-primo81.dts
134 ++++ b/arch/arm/boot/dts/sun6i-a31s-primo81.dts
135 +@@ -176,8 +176,6 @@
136 + };
137 +
138 + &reg_dc1sw {
139 +- regulator-min-microvolt = <3000000>;
140 +- regulator-max-microvolt = <3000000>;
141 + regulator-name = "vcc-lcd";
142 + };
143 +
144 +diff --git a/arch/arm/boot/dts/sun6i-a31s-yones-toptech-bs1078-v2.dts b/arch/arm/boot/dts/sun6i-a31s-yones-toptech-bs1078-v2.dts
145 +index 360adfb..d6ad619 100644
146 +--- a/arch/arm/boot/dts/sun6i-a31s-yones-toptech-bs1078-v2.dts
147 ++++ b/arch/arm/boot/dts/sun6i-a31s-yones-toptech-bs1078-v2.dts
148 +@@ -135,8 +135,6 @@
149 +
150 + &reg_dc1sw {
151 + regulator-name = "vcc-lcd-usb2";
152 +- regulator-min-microvolt = <3000000>;
153 +- regulator-max-microvolt = <3000000>;
154 + };
155 +
156 + &reg_dc5ldo {
157 +diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h
158 +index aeddd28..92fd2c8 100644
159 +--- a/arch/arm/include/asm/pgtable-2level.h
160 ++++ b/arch/arm/include/asm/pgtable-2level.h
161 +@@ -193,6 +193,7 @@ static inline pmd_t *pmd_offset(pud_t *pud, unsigned long addr)
162 +
163 + #define pmd_large(pmd) (pmd_val(pmd) & 2)
164 + #define pmd_bad(pmd) (pmd_val(pmd) & 2)
165 ++#define pmd_present(pmd) (pmd_val(pmd))
166 +
167 + #define copy_pmd(pmdpd,pmdps) \
168 + do { \
169 +diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
170 +index dc46398..7411466 100644
171 +--- a/arch/arm/include/asm/pgtable-3level.h
172 ++++ b/arch/arm/include/asm/pgtable-3level.h
173 +@@ -211,6 +211,7 @@ static inline pmd_t *pmd_offset(pud_t *pud, unsigned long addr)
174 + : !!(pmd_val(pmd) & (val)))
175 + #define pmd_isclear(pmd, val) (!(pmd_val(pmd) & (val)))
176 +
177 ++#define pmd_present(pmd) (pmd_isset((pmd), L_PMD_SECT_VALID))
178 + #define pmd_young(pmd) (pmd_isset((pmd), PMD_SECT_AF))
179 + #define pte_special(pte) (pte_isset((pte), L_PTE_SPECIAL))
180 + static inline pte_t pte_mkspecial(pte_t pte)
181 +@@ -249,10 +250,10 @@ PMD_BIT_FUNC(mkyoung, |= PMD_SECT_AF);
182 + #define pfn_pmd(pfn,prot) (__pmd(((phys_addr_t)(pfn) << PAGE_SHIFT) | pgprot_val(prot)))
183 + #define mk_pmd(page,prot) pfn_pmd(page_to_pfn(page),prot)
184 +
185 +-/* represent a notpresent pmd by zero, this is used by pmdp_invalidate */
186 ++/* represent a notpresent pmd by faulting entry, this is used by pmdp_invalidate */
187 + static inline pmd_t pmd_mknotpresent(pmd_t pmd)
188 + {
189 +- return __pmd(0);
190 ++ return __pmd(pmd_val(pmd) & ~L_PMD_SECT_VALID);
191 + }
192 +
193 + static inline pmd_t pmd_modify(pmd_t pmd, pgprot_t newprot)
194 +diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
195 +index 348caab..d622040 100644
196 +--- a/arch/arm/include/asm/pgtable.h
197 ++++ b/arch/arm/include/asm/pgtable.h
198 +@@ -182,7 +182,6 @@ extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
199 + #define pgd_offset_k(addr) pgd_offset(&init_mm, addr)
200 +
201 + #define pmd_none(pmd) (!pmd_val(pmd))
202 +-#define pmd_present(pmd) (pmd_val(pmd))
203 +
204 + static inline pte_t *pmd_page_vaddr(pmd_t pmd)
205 + {
206 +diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
207 +index dded1b7..72b11d9 100644
208 +--- a/arch/arm/kvm/arm.c
209 ++++ b/arch/arm/kvm/arm.c
210 +@@ -267,6 +267,7 @@ void kvm_arch_vcpu_free(struct kvm_vcpu *vcpu)
211 + kvm_timer_vcpu_terminate(vcpu);
212 + kvm_vgic_vcpu_destroy(vcpu);
213 + kvm_pmu_vcpu_destroy(vcpu);
214 ++ kvm_vcpu_uninit(vcpu);
215 + kmem_cache_free(kvm_vcpu_cache, vcpu);
216 + }
217 +
218 +diff --git a/arch/arm/mach-imx/mach-imx6ul.c b/arch/arm/mach-imx/mach-imx6ul.c
219 +index a38b16b..b56de4b 100644
220 +--- a/arch/arm/mach-imx/mach-imx6ul.c
221 ++++ b/arch/arm/mach-imx/mach-imx6ul.c
222 +@@ -46,7 +46,7 @@ static int ksz8081_phy_fixup(struct phy_device *dev)
223 + static void __init imx6ul_enet_phy_init(void)
224 + {
225 + if (IS_BUILTIN(CONFIG_PHYLIB))
226 +- phy_register_fixup_for_uid(PHY_ID_KSZ8081, 0xffffffff,
227 ++ phy_register_fixup_for_uid(PHY_ID_KSZ8081, MICREL_PHY_ID_MASK,
228 + ksz8081_phy_fixup);
229 + }
230 +
231 +diff --git a/arch/arm/mach-mvebu/coherency.c b/arch/arm/mach-mvebu/coherency.c
232 +index 7e989d6..474abff 100644
233 +--- a/arch/arm/mach-mvebu/coherency.c
234 ++++ b/arch/arm/mach-mvebu/coherency.c
235 +@@ -162,22 +162,16 @@ exit:
236 + }
237 +
238 + /*
239 +- * This ioremap hook is used on Armada 375/38x to ensure that PCIe
240 +- * memory areas are mapped as MT_UNCACHED instead of MT_DEVICE. This
241 +- * is needed as a workaround for a deadlock issue between the PCIe
242 +- * interface and the cache controller.
243 ++ * This ioremap hook is used on Armada 375/38x to ensure that all MMIO
244 ++ * areas are mapped as MT_UNCACHED instead of MT_DEVICE. This is
245 ++ * needed for the HW I/O coherency mechanism to work properly without
246 ++ * deadlock.
247 + */
248 + static void __iomem *
249 +-armada_pcie_wa_ioremap_caller(phys_addr_t phys_addr, size_t size,
250 +- unsigned int mtype, void *caller)
251 ++armada_wa_ioremap_caller(phys_addr_t phys_addr, size_t size,
252 ++ unsigned int mtype, void *caller)
253 + {
254 +- struct resource pcie_mem;
255 +-
256 +- mvebu_mbus_get_pcie_mem_aperture(&pcie_mem);
257 +-
258 +- if (pcie_mem.start <= phys_addr && (phys_addr + size) <= pcie_mem.end)
259 +- mtype = MT_UNCACHED;
260 +-
261 ++ mtype = MT_UNCACHED;
262 + return __arm_ioremap_caller(phys_addr, size, mtype, caller);
263 + }
264 +
265 +@@ -186,7 +180,7 @@ static void __init armada_375_380_coherency_init(struct device_node *np)
266 + struct device_node *cache_dn;
267 +
268 + coherency_cpu_base = of_iomap(np, 0);
269 +- arch_ioremap_caller = armada_pcie_wa_ioremap_caller;
270 ++ arch_ioremap_caller = armada_wa_ioremap_caller;
271 +
272 + /*
273 + * We should switch the PL310 to I/O coherency mode only if
274 +diff --git a/arch/arm64/include/asm/ptrace.h b/arch/arm64/include/asm/ptrace.h
275 +index a307eb6..7f94755 100644
276 +--- a/arch/arm64/include/asm/ptrace.h
277 ++++ b/arch/arm64/include/asm/ptrace.h
278 +@@ -117,6 +117,8 @@ struct pt_regs {
279 + };
280 + u64 orig_x0;
281 + u64 syscallno;
282 ++ u64 orig_addr_limit;
283 ++ u64 unused; // maintain 16 byte alignment
284 + };
285 +
286 + #define arch_has_single_step() (1)
287 +diff --git a/arch/arm64/kernel/asm-offsets.c b/arch/arm64/kernel/asm-offsets.c
288 +index 3ae6b31..1abcd88 100644
289 +--- a/arch/arm64/kernel/asm-offsets.c
290 ++++ b/arch/arm64/kernel/asm-offsets.c
291 +@@ -59,6 +59,7 @@ int main(void)
292 + DEFINE(S_PC, offsetof(struct pt_regs, pc));
293 + DEFINE(S_ORIG_X0, offsetof(struct pt_regs, orig_x0));
294 + DEFINE(S_SYSCALLNO, offsetof(struct pt_regs, syscallno));
295 ++ DEFINE(S_ORIG_ADDR_LIMIT, offsetof(struct pt_regs, orig_addr_limit));
296 + DEFINE(S_FRAME_SIZE, sizeof(struct pt_regs));
297 + BLANK();
298 + DEFINE(MM_CONTEXT_ID, offsetof(struct mm_struct, context.id.counter));
299 +diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S
300 +index 12e8d2b..6c3b734 100644
301 +--- a/arch/arm64/kernel/entry.S
302 ++++ b/arch/arm64/kernel/entry.S
303 +@@ -28,6 +28,7 @@
304 + #include <asm/errno.h>
305 + #include <asm/esr.h>
306 + #include <asm/irq.h>
307 ++#include <asm/memory.h>
308 + #include <asm/thread_info.h>
309 + #include <asm/unistd.h>
310 +
311 +@@ -97,7 +98,14 @@
312 + mov x29, xzr // fp pointed to user-space
313 + .else
314 + add x21, sp, #S_FRAME_SIZE
315 +- .endif
316 ++ get_thread_info tsk
317 ++ /* Save the task's original addr_limit and set USER_DS (TASK_SIZE_64) */
318 ++ ldr x20, [tsk, #TI_ADDR_LIMIT]
319 ++ str x20, [sp, #S_ORIG_ADDR_LIMIT]
320 ++ mov x20, #TASK_SIZE_64
321 ++ str x20, [tsk, #TI_ADDR_LIMIT]
322 ++ ALTERNATIVE(nop, SET_PSTATE_UAO(0), ARM64_HAS_UAO, CONFIG_ARM64_UAO)
323 ++ .endif /* \el == 0 */
324 + mrs x22, elr_el1
325 + mrs x23, spsr_el1
326 + stp lr, x21, [sp, #S_LR]
327 +@@ -128,6 +136,14 @@
328 + .endm
329 +
330 + .macro kernel_exit, el
331 ++ .if \el != 0
332 ++ /* Restore the task's original addr_limit. */
333 ++ ldr x20, [sp, #S_ORIG_ADDR_LIMIT]
334 ++ str x20, [tsk, #TI_ADDR_LIMIT]
335 ++
336 ++ /* No need to restore UAO, it will be restored from SPSR_EL1 */
337 ++ .endif
338 ++
339 + ldp x21, x22, [sp, #S_PC] // load ELR, SPSR
340 + .if \el == 0
341 + ct_user_enter
342 +@@ -406,7 +422,6 @@ el1_irq:
343 + bl trace_hardirqs_off
344 + #endif
345 +
346 +- get_thread_info tsk
347 + irq_handler
348 +
349 + #ifdef CONFIG_PREEMPT
350 +diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c
351 +index c539208..58651a9 100644
352 +--- a/arch/arm64/kernel/traps.c
353 ++++ b/arch/arm64/kernel/traps.c
354 +@@ -64,8 +64,7 @@ static void dump_mem(const char *lvl, const char *str, unsigned long bottom,
355 +
356 + /*
357 + * We need to switch to kernel mode so that we can use __get_user
358 +- * to safely read from kernel space. Note that we now dump the
359 +- * code first, just in case the backtrace kills us.
360 ++ * to safely read from kernel space.
361 + */
362 + fs = get_fs();
363 + set_fs(KERNEL_DS);
364 +@@ -111,21 +110,12 @@ static void dump_backtrace_entry(unsigned long where)
365 + print_ip_sym(where);
366 + }
367 +
368 +-static void dump_instr(const char *lvl, struct pt_regs *regs)
369 ++static void __dump_instr(const char *lvl, struct pt_regs *regs)
370 + {
371 + unsigned long addr = instruction_pointer(regs);
372 +- mm_segment_t fs;
373 + char str[sizeof("00000000 ") * 5 + 2 + 1], *p = str;
374 + int i;
375 +
376 +- /*
377 +- * We need to switch to kernel mode so that we can use __get_user
378 +- * to safely read from kernel space. Note that we now dump the
379 +- * code first, just in case the backtrace kills us.
380 +- */
381 +- fs = get_fs();
382 +- set_fs(KERNEL_DS);
383 +-
384 + for (i = -4; i < 1; i++) {
385 + unsigned int val, bad;
386 +
387 +@@ -139,8 +129,18 @@ static void dump_instr(const char *lvl, struct pt_regs *regs)
388 + }
389 + }
390 + printk("%sCode: %s\n", lvl, str);
391 ++}
392 +
393 +- set_fs(fs);
394 ++static void dump_instr(const char *lvl, struct pt_regs *regs)
395 ++{
396 ++ if (!user_mode(regs)) {
397 ++ mm_segment_t fs = get_fs();
398 ++ set_fs(KERNEL_DS);
399 ++ __dump_instr(lvl, regs);
400 ++ set_fs(fs);
401 ++ } else {
402 ++ __dump_instr(lvl, regs);
403 ++ }
404 + }
405 +
406 + static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
407 +diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
408 +index 10b79e9..e22849a9 100644
409 +--- a/arch/arm64/mm/fault.c
410 ++++ b/arch/arm64/mm/fault.c
411 +@@ -284,7 +284,8 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
412 + }
413 +
414 + if (permission_fault(esr) && (addr < USER_DS)) {
415 +- if (get_fs() == KERNEL_DS)
416 ++ /* regs->orig_addr_limit may be 0 if we entered from EL0 */
417 ++ if (regs->orig_addr_limit == KERNEL_DS)
418 + die("Accessing user space memory with fs=KERNEL_DS", regs, esr);
419 +
420 + if (!search_exception_tables(regs->pc))
421 +diff --git a/arch/arm64/mm/flush.c b/arch/arm64/mm/flush.c
422 +index dbd12ea..43a76b0 100644
423 +--- a/arch/arm64/mm/flush.c
424 ++++ b/arch/arm64/mm/flush.c
425 +@@ -71,10 +71,6 @@ void __sync_icache_dcache(pte_t pte, unsigned long addr)
426 + {
427 + struct page *page = pte_page(pte);
428 +
429 +- /* no flushing needed for anonymous pages */
430 +- if (!page_mapping(page))
431 +- return;
432 +-
433 + if (!test_and_set_bit(PG_dcache_clean, &page->flags))
434 + sync_icache_aliases(page_address(page),
435 + PAGE_SIZE << compound_order(page));
436 +diff --git a/arch/mips/include/asm/kvm_host.h b/arch/mips/include/asm/kvm_host.h
437 +index 942b8f6..1907ab3 100644
438 +--- a/arch/mips/include/asm/kvm_host.h
439 ++++ b/arch/mips/include/asm/kvm_host.h
440 +@@ -336,6 +336,7 @@ struct kvm_mips_tlb {
441 + #define KVM_MIPS_GUEST_TLB_SIZE 64
442 + struct kvm_vcpu_arch {
443 + void *host_ebase, *guest_ebase;
444 ++ int (*vcpu_run)(struct kvm_run *run, struct kvm_vcpu *vcpu);
445 + unsigned long host_stack;
446 + unsigned long host_gp;
447 +
448 +diff --git a/arch/mips/kvm/interrupt.h b/arch/mips/kvm/interrupt.h
449 +index 4ab4bdf..2143884 100644
450 +--- a/arch/mips/kvm/interrupt.h
451 ++++ b/arch/mips/kvm/interrupt.h
452 +@@ -28,6 +28,7 @@
453 + #define MIPS_EXC_MAX 12
454 + /* XXXSL More to follow */
455 +
456 ++extern char __kvm_mips_vcpu_run_end[];
457 + extern char mips32_exception[], mips32_exceptionEnd[];
458 + extern char mips32_GuestException[], mips32_GuestExceptionEnd[];
459 +
460 +diff --git a/arch/mips/kvm/locore.S b/arch/mips/kvm/locore.S
461 +index 81687ab..fc93a08 100644
462 +--- a/arch/mips/kvm/locore.S
463 ++++ b/arch/mips/kvm/locore.S
464 +@@ -227,6 +227,7 @@ FEXPORT(__kvm_mips_load_k0k1)
465 +
466 + /* Jump to guest */
467 + eret
468 ++EXPORT(__kvm_mips_vcpu_run_end)
469 +
470 + VECTOR(MIPSX(exception), unknown)
471 + /* Find out what mode we came from and jump to the proper handler. */
472 +diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c
473 +index 70ef1a4..e223cb3 100644
474 +--- a/arch/mips/kvm/mips.c
475 ++++ b/arch/mips/kvm/mips.c
476 +@@ -314,6 +314,15 @@ struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, unsigned int id)
477 + memcpy(gebase + offset, mips32_GuestException,
478 + mips32_GuestExceptionEnd - mips32_GuestException);
479 +
480 ++#ifdef MODULE
481 ++ offset += mips32_GuestExceptionEnd - mips32_GuestException;
482 ++ memcpy(gebase + offset, (char *)__kvm_mips_vcpu_run,
483 ++ __kvm_mips_vcpu_run_end - (char *)__kvm_mips_vcpu_run);
484 ++ vcpu->arch.vcpu_run = gebase + offset;
485 ++#else
486 ++ vcpu->arch.vcpu_run = __kvm_mips_vcpu_run;
487 ++#endif
488 ++
489 + /* Invalidate the icache for these ranges */
490 + local_flush_icache_range((unsigned long)gebase,
491 + (unsigned long)gebase + ALIGN(size, PAGE_SIZE));
492 +@@ -403,7 +412,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
493 + /* Disable hardware page table walking while in guest */
494 + htw_stop();
495 +
496 +- r = __kvm_mips_vcpu_run(run, vcpu);
497 ++ r = vcpu->arch.vcpu_run(run, vcpu);
498 +
499 + /* Re-enable HTW before enabling interrupts */
500 + htw_start();
501 +diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
502 +index b8500b4..bec85055 100644
503 +--- a/arch/powerpc/kernel/process.c
504 ++++ b/arch/powerpc/kernel/process.c
505 +@@ -1501,6 +1501,16 @@ void start_thread(struct pt_regs *regs, unsigned long start, unsigned long sp)
506 + current->thread.regs = regs - 1;
507 + }
508 +
509 ++#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
510 ++ /*
511 ++ * Clear any transactional state, we're exec()ing. The cause is
512 ++ * not important as there will never be a recheckpoint so it's not
513 ++ * user visible.
514 ++ */
515 ++ if (MSR_TM_SUSPENDED(mfmsr()))
516 ++ tm_reclaim_current(0);
517 ++#endif
518 ++
519 + memset(regs->gpr, 0, sizeof(regs->gpr));
520 + regs->ctr = 0;
521 + regs->link = 0;
522 +diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
523 +index ccd2037..6ee4b72 100644
524 +--- a/arch/powerpc/kernel/prom_init.c
525 ++++ b/arch/powerpc/kernel/prom_init.c
526 +@@ -719,7 +719,7 @@ unsigned char ibm_architecture_vec[] = {
527 + * must match by the macro below. Update the definition if
528 + * the structure layout changes.
529 + */
530 +-#define IBM_ARCH_VEC_NRCORES_OFFSET 125
531 ++#define IBM_ARCH_VEC_NRCORES_OFFSET 133
532 + W(NR_CPUS), /* number of cores supported */
533 + 0,
534 + 0,
535 +diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c
536 +index bd98ce2..3e8865b 100644
537 +--- a/arch/powerpc/platforms/pseries/iommu.c
538 ++++ b/arch/powerpc/platforms/pseries/iommu.c
539 +@@ -912,7 +912,8 @@ machine_arch_initcall(pseries, find_existing_ddw_windows);
540 + static int query_ddw(struct pci_dev *dev, const u32 *ddw_avail,
541 + struct ddw_query_response *query)
542 + {
543 +- struct eeh_dev *edev;
544 ++ struct device_node *dn;
545 ++ struct pci_dn *pdn;
546 + u32 cfg_addr;
547 + u64 buid;
548 + int ret;
549 +@@ -923,11 +924,10 @@ static int query_ddw(struct pci_dev *dev, const u32 *ddw_avail,
550 + * Retrieve them from the pci device, not the node with the
551 + * dma-window property
552 + */
553 +- edev = pci_dev_to_eeh_dev(dev);
554 +- cfg_addr = edev->config_addr;
555 +- if (edev->pe_config_addr)
556 +- cfg_addr = edev->pe_config_addr;
557 +- buid = edev->phb->buid;
558 ++ dn = pci_device_to_OF_node(dev);
559 ++ pdn = PCI_DN(dn);
560 ++ buid = pdn->phb->buid;
561 ++ cfg_addr = ((pdn->busno << 16) | (pdn->devfn << 8));
562 +
563 + ret = rtas_call(ddw_avail[0], 3, 5, (u32 *)query,
564 + cfg_addr, BUID_HI(buid), BUID_LO(buid));
565 +@@ -941,7 +941,8 @@ static int create_ddw(struct pci_dev *dev, const u32 *ddw_avail,
566 + struct ddw_create_response *create, int page_shift,
567 + int window_shift)
568 + {
569 +- struct eeh_dev *edev;
570 ++ struct device_node *dn;
571 ++ struct pci_dn *pdn;
572 + u32 cfg_addr;
573 + u64 buid;
574 + int ret;
575 +@@ -952,11 +953,10 @@ static int create_ddw(struct pci_dev *dev, const u32 *ddw_avail,
576 + * Retrieve them from the pci device, not the node with the
577 + * dma-window property
578 + */
579 +- edev = pci_dev_to_eeh_dev(dev);
580 +- cfg_addr = edev->config_addr;
581 +- if (edev->pe_config_addr)
582 +- cfg_addr = edev->pe_config_addr;
583 +- buid = edev->phb->buid;
584 ++ dn = pci_device_to_OF_node(dev);
585 ++ pdn = PCI_DN(dn);
586 ++ buid = pdn->phb->buid;
587 ++ cfg_addr = ((pdn->busno << 16) | (pdn->devfn << 8));
588 +
589 + do {
590 + /* extra outputs are LIOBN and dma-addr (hi, lo) */
591 +diff --git a/arch/s390/include/asm/fpu/api.h b/arch/s390/include/asm/fpu/api.h
592 +index 5e04f3c..8ae236b0 100644
593 +--- a/arch/s390/include/asm/fpu/api.h
594 ++++ b/arch/s390/include/asm/fpu/api.h
595 +@@ -22,7 +22,7 @@ static inline int test_fp_ctl(u32 fpc)
596 + " la %0,0\n"
597 + "1:\n"
598 + EX_TABLE(0b,1b)
599 +- : "=d" (rc), "=d" (orig_fpc)
600 ++ : "=d" (rc), "=&d" (orig_fpc)
601 + : "d" (fpc), "0" (-EINVAL));
602 + return rc;
603 + }
604 +diff --git a/arch/s390/kernel/ipl.c b/arch/s390/kernel/ipl.c
605 +index f20abdb..d14069d 100644
606 +--- a/arch/s390/kernel/ipl.c
607 ++++ b/arch/s390/kernel/ipl.c
608 +@@ -2064,12 +2064,5 @@ void s390_reset_system(void)
609 + S390_lowcore.program_new_psw.addr =
610 + (unsigned long) s390_base_pgm_handler;
611 +
612 +- /*
613 +- * Clear subchannel ID and number to signal new kernel that no CCW or
614 +- * SCSI IPL has been done (for kexec and kdump)
615 +- */
616 +- S390_lowcore.subchannel_id = 0;
617 +- S390_lowcore.subchannel_nr = 0;
618 +-
619 + do_reset_calls();
620 + }
621 +diff --git a/arch/s390/mm/pgtable.c b/arch/s390/mm/pgtable.c
622 +index 4324b87..9f0ce0e 100644
623 +--- a/arch/s390/mm/pgtable.c
624 ++++ b/arch/s390/mm/pgtable.c
625 +@@ -437,7 +437,7 @@ void ptep_zap_unused(struct mm_struct *mm, unsigned long addr,
626 + pgste = pgste_get_lock(ptep);
627 + pgstev = pgste_val(pgste);
628 + pte = *ptep;
629 +- if (pte_swap(pte) &&
630 ++ if (!reset && pte_swap(pte) &&
631 + ((pgstev & _PGSTE_GPS_USAGE_MASK) == _PGSTE_GPS_USAGE_UNUSED ||
632 + (pgstev & _PGSTE_GPS_ZERO))) {
633 + ptep_zap_swap_entry(mm, pte_to_swp_entry(pte));
634 +diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
635 +index b1ef9e4..b67f9e8 100644
636 +--- a/arch/x86/boot/Makefile
637 ++++ b/arch/x86/boot/Makefile
638 +@@ -171,6 +171,9 @@ isoimage: $(obj)/bzImage
639 + for i in lib lib64 share end ; do \
640 + if [ -f /usr/$$i/syslinux/isolinux.bin ] ; then \
641 + cp /usr/$$i/syslinux/isolinux.bin $(obj)/isoimage ; \
642 ++ if [ -f /usr/$$i/syslinux/ldlinux.c32 ]; then \
643 ++ cp /usr/$$i/syslinux/ldlinux.c32 $(obj)/isoimage ; \
644 ++ fi ; \
645 + break ; \
646 + fi ; \
647 + if [ $$i = end ] ; then exit 1 ; fi ; \
648 +diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c
649 +index 041e442..7eb806c 100644
650 +--- a/arch/x86/events/core.c
651 ++++ b/arch/x86/events/core.c
652 +@@ -2313,7 +2313,7 @@ void
653 + perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
654 + {
655 + struct stack_frame frame;
656 +- const void __user *fp;
657 ++ const unsigned long __user *fp;
658 +
659 + if (perf_guest_cbs && perf_guest_cbs->is_in_guest()) {
660 + /* TODO: We don't support guest os callchain now */
661 +@@ -2326,7 +2326,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
662 + if (regs->flags & (X86_VM_MASK | PERF_EFLAGS_VM))
663 + return;
664 +
665 +- fp = (void __user *)regs->bp;
666 ++ fp = (unsigned long __user *)regs->bp;
667 +
668 + perf_callchain_store(entry, regs->ip);
669 +
670 +@@ -2339,16 +2339,17 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
671 + pagefault_disable();
672 + while (entry->nr < PERF_MAX_STACK_DEPTH) {
673 + unsigned long bytes;
674 ++
675 + frame.next_frame = NULL;
676 + frame.return_address = 0;
677 +
678 +- if (!access_ok(VERIFY_READ, fp, 16))
679 ++ if (!access_ok(VERIFY_READ, fp, sizeof(*fp) * 2))
680 + break;
681 +
682 +- bytes = __copy_from_user_nmi(&frame.next_frame, fp, 8);
683 ++ bytes = __copy_from_user_nmi(&frame.next_frame, fp, sizeof(*fp));
684 + if (bytes != 0)
685 + break;
686 +- bytes = __copy_from_user_nmi(&frame.return_address, fp+8, 8);
687 ++ bytes = __copy_from_user_nmi(&frame.return_address, fp + 1, sizeof(*fp));
688 + if (bytes != 0)
689 + break;
690 +
691 +diff --git a/arch/x86/events/intel/rapl.c b/arch/x86/events/intel/rapl.c
692 +index 1705c9d..78ee9eb 100644
693 +--- a/arch/x86/events/intel/rapl.c
694 ++++ b/arch/x86/events/intel/rapl.c
695 +@@ -665,7 +665,7 @@ static void __init cleanup_rapl_pmus(void)
696 + int i;
697 +
698 + for (i = 0; i < rapl_pmus->maxpkg; i++)
699 +- kfree(rapl_pmus->pmus + i);
700 ++ kfree(rapl_pmus->pmus[i]);
701 + kfree(rapl_pmus);
702 + }
703 +
704 +diff --git a/arch/x86/include/asm/msr.h b/arch/x86/include/asm/msr.h
705 +index 7a79ee2..33c709c 100644
706 +--- a/arch/x86/include/asm/msr.h
707 ++++ b/arch/x86/include/asm/msr.h
708 +@@ -112,7 +112,7 @@ static inline void native_write_msr(unsigned int msr,
709 + unsigned low, unsigned high)
710 + {
711 + asm volatile("wrmsr" : : "c" (msr), "a"(low), "d" (high) : "memory");
712 +- if (msr_tracepoint_active(__tracepoint_read_msr))
713 ++ if (msr_tracepoint_active(__tracepoint_write_msr))
714 + do_trace_write_msr(msr, ((u64)high << 32 | low), 0);
715 + }
716 +
717 +@@ -131,7 +131,7 @@ notrace static inline int native_write_msr_safe(unsigned int msr,
718 + : "c" (msr), "0" (low), "d" (high),
719 + [fault] "i" (-EIO)
720 + : "memory");
721 +- if (msr_tracepoint_active(__tracepoint_read_msr))
722 ++ if (msr_tracepoint_active(__tracepoint_write_msr))
723 + do_trace_write_msr(msr, ((u64)high << 32 | low), err);
724 + return err;
725 + }
726 +diff --git a/arch/x86/kernel/amd_nb.c b/arch/x86/kernel/amd_nb.c
727 +index a147e67..e991d5c 100644
728 +--- a/arch/x86/kernel/amd_nb.c
729 ++++ b/arch/x86/kernel/amd_nb.c
730 +@@ -71,8 +71,8 @@ int amd_cache_northbridges(void)
731 + while ((misc = next_northbridge(misc, amd_nb_misc_ids)) != NULL)
732 + i++;
733 +
734 +- if (i == 0)
735 +- return 0;
736 ++ if (!i)
737 ++ return -ENODEV;
738 +
739 + nb = kzalloc(i * sizeof(struct amd_northbridge), GFP_KERNEL);
740 + if (!nb)
741 +diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
742 +index ae703ac..44bcd57 100644
743 +--- a/arch/x86/kernel/kprobes/core.c
744 ++++ b/arch/x86/kernel/kprobes/core.c
745 +@@ -960,7 +960,19 @@ int kprobe_fault_handler(struct pt_regs *regs, int trapnr)
746 + * normal page fault.
747 + */
748 + regs->ip = (unsigned long)cur->addr;
749 ++ /*
750 ++ * Trap flag (TF) has been set here because this fault
751 ++ * happened where the single stepping will be done.
752 ++ * So clear it by resetting the current kprobe:
753 ++ */
754 ++ regs->flags &= ~X86_EFLAGS_TF;
755 ++
756 ++ /*
757 ++ * If the TF flag was set before the kprobe hit,
758 ++ * don't touch it:
759 ++ */
760 + regs->flags |= kcb->kprobe_old_flags;
761 ++
762 + if (kcb->kprobe_status == KPROBE_REENTER)
763 + restore_previous_kprobe(kcb);
764 + else
765 +diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
766 +index faf52bac..c4217a2 100644
767 +--- a/arch/x86/kvm/vmx.c
768 ++++ b/arch/x86/kvm/vmx.c
769 +@@ -2072,7 +2072,8 @@ static void vmx_vcpu_pi_load(struct kvm_vcpu *vcpu, int cpu)
770 + unsigned int dest;
771 +
772 + if (!kvm_arch_has_assigned_device(vcpu->kvm) ||
773 +- !irq_remapping_cap(IRQ_POSTING_CAP))
774 ++ !irq_remapping_cap(IRQ_POSTING_CAP) ||
775 ++ !kvm_vcpu_apicv_active(vcpu))
776 + return;
777 +
778 + do {
779 +@@ -2180,7 +2181,8 @@ static void vmx_vcpu_pi_put(struct kvm_vcpu *vcpu)
780 + struct pi_desc *pi_desc = vcpu_to_pi_desc(vcpu);
781 +
782 + if (!kvm_arch_has_assigned_device(vcpu->kvm) ||
783 +- !irq_remapping_cap(IRQ_POSTING_CAP))
784 ++ !irq_remapping_cap(IRQ_POSTING_CAP) ||
785 ++ !kvm_vcpu_apicv_active(vcpu))
786 + return;
787 +
788 + /* Set SN when the vCPU is preempted */
789 +@@ -6657,7 +6659,13 @@ static int get_vmx_mem_address(struct kvm_vcpu *vcpu,
790 +
791 + /* Checks for #GP/#SS exceptions. */
792 + exn = false;
793 +- if (is_protmode(vcpu)) {
794 ++ if (is_long_mode(vcpu)) {
795 ++ /* Long mode: #GP(0)/#SS(0) if the memory address is in a
796 ++ * non-canonical form. This is the only check on the memory
797 ++ * destination for long mode!
798 ++ */
799 ++ exn = is_noncanonical_address(*ret);
800 ++ } else if (is_protmode(vcpu)) {
801 + /* Protected mode: apply checks for segment validity in the
802 + * following order:
803 + * - segment type check (#GP(0) may be thrown)
804 +@@ -6674,17 +6682,10 @@ static int get_vmx_mem_address(struct kvm_vcpu *vcpu,
805 + * execute-only code segment
806 + */
807 + exn = ((s.type & 0xa) == 8);
808 +- }
809 +- if (exn) {
810 +- kvm_queue_exception_e(vcpu, GP_VECTOR, 0);
811 +- return 1;
812 +- }
813 +- if (is_long_mode(vcpu)) {
814 +- /* Long mode: #GP(0)/#SS(0) if the memory address is in a
815 +- * non-canonical form. This is an only check for long mode.
816 +- */
817 +- exn = is_noncanonical_address(*ret);
818 +- } else if (is_protmode(vcpu)) {
819 ++ if (exn) {
820 ++ kvm_queue_exception_e(vcpu, GP_VECTOR, 0);
821 ++ return 1;
822 ++ }
823 + /* Protected mode: #GP(0)/#SS(0) if the segment is unusable.
824 + */
825 + exn = (s.unusable != 0);
826 +@@ -10702,7 +10703,8 @@ static int vmx_pre_block(struct kvm_vcpu *vcpu)
827 + struct pi_desc *pi_desc = vcpu_to_pi_desc(vcpu);
828 +
829 + if (!kvm_arch_has_assigned_device(vcpu->kvm) ||
830 +- !irq_remapping_cap(IRQ_POSTING_CAP))
831 ++ !irq_remapping_cap(IRQ_POSTING_CAP) ||
832 ++ !kvm_vcpu_apicv_active(vcpu))
833 + return 0;
834 +
835 + vcpu->pre_pcpu = vcpu->cpu;
836 +@@ -10768,7 +10770,8 @@ static void vmx_post_block(struct kvm_vcpu *vcpu)
837 + unsigned long flags;
838 +
839 + if (!kvm_arch_has_assigned_device(vcpu->kvm) ||
840 +- !irq_remapping_cap(IRQ_POSTING_CAP))
841 ++ !irq_remapping_cap(IRQ_POSTING_CAP) ||
842 ++ !kvm_vcpu_apicv_active(vcpu))
843 + return;
844 +
845 + do {
846 +@@ -10821,7 +10824,8 @@ static int vmx_update_pi_irte(struct kvm *kvm, unsigned int host_irq,
847 + int idx, ret = -EINVAL;
848 +
849 + if (!kvm_arch_has_assigned_device(kvm) ||
850 +- !irq_remapping_cap(IRQ_POSTING_CAP))
851 ++ !irq_remapping_cap(IRQ_POSTING_CAP) ||
852 ++ !kvm_vcpu_apicv_active(kvm->vcpus[0]))
853 + return 0;
854 +
855 + idx = srcu_read_lock(&kvm->irq_srcu);
856 +diff --git a/crypto/rsa-pkcs1pad.c b/crypto/rsa-pkcs1pad.c
857 +index ead8dc0..8ba4266 100644
858 +--- a/crypto/rsa-pkcs1pad.c
859 ++++ b/crypto/rsa-pkcs1pad.c
860 +@@ -102,10 +102,10 @@ struct pkcs1pad_inst_ctx {
861 + };
862 +
863 + struct pkcs1pad_request {
864 +- struct akcipher_request child_req;
865 +-
866 + struct scatterlist in_sg[3], out_sg[2];
867 + uint8_t *in_buf, *out_buf;
868 ++
869 ++ struct akcipher_request child_req;
870 + };
871 +
872 + static int pkcs1pad_set_pub_key(struct crypto_akcipher *tfm, const void *key,
873 +diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
874 +index 961acc7..91a9e6a 100644
875 +--- a/drivers/ata/libata-eh.c
876 ++++ b/drivers/ata/libata-eh.c
877 +@@ -606,7 +606,7 @@ void ata_scsi_error(struct Scsi_Host *host)
878 + ata_scsi_port_error_handler(host, ap);
879 +
880 + /* finish or retry handled scmd's and clean up */
881 +- WARN_ON(host->host_failed || !list_empty(&eh_work_q));
882 ++ WARN_ON(!list_empty(&eh_work_q));
883 +
884 + DPRINTK("EXIT\n");
885 + }
886 +diff --git a/drivers/base/module.c b/drivers/base/module.c
887 +index db930d3..2a21578 100644
888 +--- a/drivers/base/module.c
889 ++++ b/drivers/base/module.c
890 +@@ -24,10 +24,12 @@ static char *make_driver_name(struct device_driver *drv)
891 +
892 + static void module_create_drivers_dir(struct module_kobject *mk)
893 + {
894 +- if (!mk || mk->drivers_dir)
895 +- return;
896 ++ static DEFINE_MUTEX(drivers_dir_mutex);
897 +
898 +- mk->drivers_dir = kobject_create_and_add("drivers", &mk->kobj);
899 ++ mutex_lock(&drivers_dir_mutex);
900 ++ if (mk && !mk->drivers_dir)
901 ++ mk->drivers_dir = kobject_create_and_add("drivers", &mk->kobj);
902 ++ mutex_unlock(&drivers_dir_mutex);
903 + }
904 +
905 + void module_add_driver(struct module *mod, struct device_driver *drv)
906 +diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
907 +index 94fb407..44b1bd6 100644
908 +--- a/drivers/char/ipmi/ipmi_msghandler.c
909 ++++ b/drivers/char/ipmi/ipmi_msghandler.c
910 +@@ -3820,6 +3820,7 @@ static void handle_new_recv_msgs(ipmi_smi_t intf)
911 + while (!list_empty(&intf->waiting_rcv_msgs)) {
912 + smi_msg = list_entry(intf->waiting_rcv_msgs.next,
913 + struct ipmi_smi_msg, link);
914 ++ list_del(&smi_msg->link);
915 + if (!run_to_completion)
916 + spin_unlock_irqrestore(&intf->waiting_rcv_msgs_lock,
917 + flags);
918 +@@ -3829,11 +3830,14 @@ static void handle_new_recv_msgs(ipmi_smi_t intf)
919 + if (rv > 0) {
920 + /*
921 + * To preserve message order, quit if we
922 +- * can't handle a message.
923 ++ * can't handle a message. Add the message
924 ++ * back at the head, this is safe because this
925 ++ * tasklet is the only thing that pulls the
926 ++ * messages.
927 + */
928 ++ list_add(&smi_msg->link, &intf->waiting_rcv_msgs);
929 + break;
930 + } else {
931 +- list_del(&smi_msg->link);
932 + if (rv == 0)
933 + /* Message handled */
934 + ipmi_free_smi_msg(smi_msg);
935 +diff --git a/drivers/crypto/qat/qat_common/Makefile b/drivers/crypto/qat/qat_common/Makefile
936 +index 29c7c53..92561c8 100644
937 +--- a/drivers/crypto/qat/qat_common/Makefile
938 ++++ b/drivers/crypto/qat/qat_common/Makefile
939 +@@ -2,6 +2,7 @@ $(obj)/qat_rsapubkey-asn1.o: $(obj)/qat_rsapubkey-asn1.c \
940 + $(obj)/qat_rsapubkey-asn1.h
941 + $(obj)/qat_rsaprivkey-asn1.o: $(obj)/qat_rsaprivkey-asn1.c \
942 + $(obj)/qat_rsaprivkey-asn1.h
943 ++$(obj)/qat_asym_algs.o: $(obj)/qat_rsapubkey-asn1.h $(obj)/qat_rsaprivkey-asn1.h
944 +
945 + clean-files += qat_rsapubkey-asn1.c qat_rsapubkey-asn1.h
946 + clean-files += qat_rsaprivkey-asn1.c qat_rsaprivkey-asn1.h
947 +diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c
948 +index 1472f48..ff51b51 100644
949 +--- a/drivers/edac/edac_mc.c
950 ++++ b/drivers/edac/edac_mc.c
951 +@@ -565,7 +565,8 @@ void edac_mc_reset_delay_period(unsigned long value)
952 + list_for_each(item, &mc_devices) {
953 + mci = list_entry(item, struct mem_ctl_info, link);
954 +
955 +- edac_mod_work(&mci->work, value);
956 ++ if (mci->op_state == OP_RUNNING_POLL)
957 ++ edac_mod_work(&mci->work, value);
958 + }
959 + mutex_unlock(&mem_ctls_mutex);
960 + }
961 +diff --git a/drivers/edac/sb_edac.c b/drivers/edac/sb_edac.c
962 +index 8bf745d..b274fa2 100644
963 +--- a/drivers/edac/sb_edac.c
964 ++++ b/drivers/edac/sb_edac.c
965 +@@ -239,8 +239,11 @@ static const u32 rir_offset[MAX_RIR_RANGES][MAX_RIR_WAY] = {
966 + { 0x1a0, 0x1a4, 0x1a8, 0x1ac, 0x1b0, 0x1b4, 0x1b8, 0x1bc },
967 + };
968 +
969 +-#define RIR_RNK_TGT(reg) GET_BITFIELD(reg, 16, 19)
970 +-#define RIR_OFFSET(reg) GET_BITFIELD(reg, 2, 14)
971 ++#define RIR_RNK_TGT(type, reg) (((type) == BROADWELL) ? \
972 ++ GET_BITFIELD(reg, 20, 23) : GET_BITFIELD(reg, 16, 19))
973 ++
974 ++#define RIR_OFFSET(type, reg) (((type) == HASWELL || (type) == BROADWELL) ? \
975 ++ GET_BITFIELD(reg, 2, 15) : GET_BITFIELD(reg, 2, 14))
976 +
977 + /* Device 16, functions 2-7 */
978 +
979 +@@ -1916,14 +1919,14 @@ static void get_memory_layout(const struct mem_ctl_info *mci)
980 + pci_read_config_dword(pvt->pci_tad[i],
981 + rir_offset[j][k],
982 + &reg);
983 +- tmp_mb = RIR_OFFSET(reg) << 6;
984 ++ tmp_mb = RIR_OFFSET(pvt->info.type, reg) << 6;
985 +
986 + gb = div_u64_rem(tmp_mb, 1024, &mb);
987 + edac_dbg(0, "CH#%d RIR#%d INTL#%d, offset %u.%03u GB (0x%016Lx), tgt: %d, reg=0x%08x\n",
988 + i, j, k,
989 + gb, (mb*1000)/1024,
990 + ((u64)tmp_mb) << 20L,
991 +- (u32)RIR_RNK_TGT(reg),
992 ++ (u32)RIR_RNK_TGT(pvt->info.type, reg),
993 + reg);
994 + }
995 + }
996 +@@ -2256,7 +2259,7 @@ static int get_memory_error_data(struct mem_ctl_info *mci,
997 + pci_read_config_dword(pvt->pci_tad[ch_add + base_ch],
998 + rir_offset[n_rir][idx],
999 + &reg);
1000 +- *rank = RIR_RNK_TGT(reg);
1001 ++ *rank = RIR_RNK_TGT(pvt->info.type, reg);
1002 +
1003 + edac_dbg(0, "RIR#%d: channel address 0x%08Lx < 0x%08Lx, RIR interleave %d, index %d\n",
1004 + n_rir,
1005 +diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
1006 +index 8b3226d..caff46c 100644
1007 +--- a/drivers/extcon/extcon-palmas.c
1008 ++++ b/drivers/extcon/extcon-palmas.c
1009 +@@ -360,6 +360,8 @@ static int palmas_usb_probe(struct platform_device *pdev)
1010 +
1011 + palmas_enable_irq(palmas_usb);
1012 + /* perform initial detection */
1013 ++ if (palmas_usb->enable_gpio_vbus_detection)
1014 ++ palmas_vbus_irq_handler(palmas_usb->gpio_vbus_irq, palmas_usb);
1015 + palmas_gpio_id_detect(&palmas_usb->wq_detectid.work);
1016 + device_set_wakeup_capable(&pdev->dev, true);
1017 + return 0;
1018 +diff --git a/drivers/gpio/gpio-sch.c b/drivers/gpio/gpio-sch.c
1019 +index e85e753..eb43ae4 100644
1020 +--- a/drivers/gpio/gpio-sch.c
1021 ++++ b/drivers/gpio/gpio-sch.c
1022 +@@ -61,9 +61,8 @@ static unsigned sch_gpio_bit(struct sch_gpio *sch, unsigned gpio)
1023 + return gpio % 8;
1024 + }
1025 +
1026 +-static int sch_gpio_reg_get(struct gpio_chip *gc, unsigned gpio, unsigned reg)
1027 ++static int sch_gpio_reg_get(struct sch_gpio *sch, unsigned gpio, unsigned reg)
1028 + {
1029 +- struct sch_gpio *sch = gpiochip_get_data(gc);
1030 + unsigned short offset, bit;
1031 + u8 reg_val;
1032 +
1033 +@@ -75,10 +74,9 @@ static int sch_gpio_reg_get(struct gpio_chip *gc, unsigned gpio, unsigned reg)
1034 + return reg_val;
1035 + }
1036 +
1037 +-static void sch_gpio_reg_set(struct gpio_chip *gc, unsigned gpio, unsigned reg,
1038 ++static void sch_gpio_reg_set(struct sch_gpio *sch, unsigned gpio, unsigned reg,
1039 + int val)
1040 + {
1041 +- struct sch_gpio *sch = gpiochip_get_data(gc);
1042 + unsigned short offset, bit;
1043 + u8 reg_val;
1044 +
1045 +@@ -98,14 +96,15 @@ static int sch_gpio_direction_in(struct gpio_chip *gc, unsigned gpio_num)
1046 + struct sch_gpio *sch = gpiochip_get_data(gc);
1047 +
1048 + spin_lock(&sch->lock);
1049 +- sch_gpio_reg_set(gc, gpio_num, GIO, 1);
1050 ++ sch_gpio_reg_set(sch, gpio_num, GIO, 1);
1051 + spin_unlock(&sch->lock);
1052 + return 0;
1053 + }
1054 +
1055 + static int sch_gpio_get(struct gpio_chip *gc, unsigned gpio_num)
1056 + {
1057 +- return sch_gpio_reg_get(gc, gpio_num, GLV);
1058 ++ struct sch_gpio *sch = gpiochip_get_data(gc);
1059 ++ return sch_gpio_reg_get(sch, gpio_num, GLV);
1060 + }
1061 +
1062 + static void sch_gpio_set(struct gpio_chip *gc, unsigned gpio_num, int val)
1063 +@@ -113,7 +112,7 @@ static void sch_gpio_set(struct gpio_chip *gc, unsigned gpio_num, int val)
1064 + struct sch_gpio *sch = gpiochip_get_data(gc);
1065 +
1066 + spin_lock(&sch->lock);
1067 +- sch_gpio_reg_set(gc, gpio_num, GLV, val);
1068 ++ sch_gpio_reg_set(sch, gpio_num, GLV, val);
1069 + spin_unlock(&sch->lock);
1070 + }
1071 +
1072 +@@ -123,7 +122,7 @@ static int sch_gpio_direction_out(struct gpio_chip *gc, unsigned gpio_num,
1073 + struct sch_gpio *sch = gpiochip_get_data(gc);
1074 +
1075 + spin_lock(&sch->lock);
1076 +- sch_gpio_reg_set(gc, gpio_num, GIO, 0);
1077 ++ sch_gpio_reg_set(sch, gpio_num, GIO, 0);
1078 + spin_unlock(&sch->lock);
1079 +
1080 + /*
1081 +@@ -182,13 +181,13 @@ static int sch_gpio_probe(struct platform_device *pdev)
1082 + * GPIO7 is configured by the CMC as SLPIOVR
1083 + * Enable GPIO[9:8] core powered gpios explicitly
1084 + */
1085 +- sch_gpio_reg_set(&sch->chip, 8, GEN, 1);
1086 +- sch_gpio_reg_set(&sch->chip, 9, GEN, 1);
1087 ++ sch_gpio_reg_set(sch, 8, GEN, 1);
1088 ++ sch_gpio_reg_set(sch, 9, GEN, 1);
1089 + /*
1090 + * SUS_GPIO[2:0] enabled by default
1091 + * Enable SUS_GPIO3 resume powered gpio explicitly
1092 + */
1093 +- sch_gpio_reg_set(&sch->chip, 13, GEN, 1);
1094 ++ sch_gpio_reg_set(sch, 13, GEN, 1);
1095 + break;
1096 +
1097 + case PCI_DEVICE_ID_INTEL_ITC_LPC:
1098 +diff --git a/drivers/gpio/gpiolib-legacy.c b/drivers/gpio/gpiolib-legacy.c
1099 +index 3a5c701..8b83099 100644
1100 +--- a/drivers/gpio/gpiolib-legacy.c
1101 ++++ b/drivers/gpio/gpiolib-legacy.c
1102 +@@ -28,6 +28,10 @@ int gpio_request_one(unsigned gpio, unsigned long flags, const char *label)
1103 + if (!desc && gpio_is_valid(gpio))
1104 + return -EPROBE_DEFER;
1105 +
1106 ++ err = gpiod_request(desc, label);
1107 ++ if (err)
1108 ++ return err;
1109 ++
1110 + if (flags & GPIOF_OPEN_DRAIN)
1111 + set_bit(FLAG_OPEN_DRAIN, &desc->flags);
1112 +
1113 +@@ -37,10 +41,6 @@ int gpio_request_one(unsigned gpio, unsigned long flags, const char *label)
1114 + if (flags & GPIOF_ACTIVE_LOW)
1115 + set_bit(FLAG_ACTIVE_LOW, &desc->flags);
1116 +
1117 +- err = gpiod_request(desc, label);
1118 +- if (err)
1119 +- return err;
1120 +-
1121 + if (flags & GPIOF_DIR_IN)
1122 + err = gpiod_direction_input(desc);
1123 + else
1124 +diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
1125 +index cf3e712..996a733 100644
1126 +--- a/drivers/gpio/gpiolib.c
1127 ++++ b/drivers/gpio/gpiolib.c
1128 +@@ -1324,14 +1324,6 @@ static int __gpiod_request(struct gpio_desc *desc, const char *label)
1129 + spin_lock_irqsave(&gpio_lock, flags);
1130 + }
1131 + done:
1132 +- if (status < 0) {
1133 +- /* Clear flags that might have been set by the caller before
1134 +- * requesting the GPIO.
1135 +- */
1136 +- clear_bit(FLAG_ACTIVE_LOW, &desc->flags);
1137 +- clear_bit(FLAG_OPEN_DRAIN, &desc->flags);
1138 +- clear_bit(FLAG_OPEN_SOURCE, &desc->flags);
1139 +- }
1140 + spin_unlock_irqrestore(&gpio_lock, flags);
1141 + return status;
1142 + }
1143 +@@ -1345,8 +1337,12 @@ done:
1144 + #define VALIDATE_DESC(desc) do { \
1145 + if (!desc) \
1146 + return 0; \
1147 ++ if (IS_ERR(desc)) { \
1148 ++ pr_warn("%s: invalid GPIO (errorpointer)\n", __func__); \
1149 ++ return PTR_ERR(desc); \
1150 ++ } \
1151 + if (!desc->gdev) { \
1152 +- pr_warn("%s: invalid GPIO\n", __func__); \
1153 ++ pr_warn("%s: invalid GPIO (no device)\n", __func__); \
1154 + return -EINVAL; \
1155 + } \
1156 + if ( !desc->gdev->chip ) { \
1157 +@@ -1358,8 +1354,12 @@ done:
1158 + #define VALIDATE_DESC_VOID(desc) do { \
1159 + if (!desc) \
1160 + return; \
1161 ++ if (IS_ERR(desc)) { \
1162 ++ pr_warn("%s: invalid GPIO (errorpointer)\n", __func__); \
1163 ++ return; \
1164 ++ } \
1165 + if (!desc->gdev) { \
1166 +- pr_warn("%s: invalid GPIO\n", __func__); \
1167 ++ pr_warn("%s: invalid GPIO (no device)\n", __func__); \
1168 + return; \
1169 + } \
1170 + if (!desc->gdev->chip) { \
1171 +@@ -2011,7 +2011,7 @@ int gpiod_to_irq(const struct gpio_desc *desc)
1172 + * requires this function to not return zero on an invalid descriptor
1173 + * but rather a negative error number.
1174 + */
1175 +- if (!desc || !desc->gdev || !desc->gdev->chip)
1176 ++ if (!desc || IS_ERR(desc) || !desc->gdev || !desc->gdev->chip)
1177 + return -EINVAL;
1178 +
1179 + chip = desc->gdev->chip;
1180 +@@ -2507,28 +2507,13 @@ struct gpio_desc *__must_check gpiod_get_optional(struct device *dev,
1181 + }
1182 + EXPORT_SYMBOL_GPL(gpiod_get_optional);
1183 +
1184 +-/**
1185 +- * gpiod_parse_flags - helper function to parse GPIO lookup flags
1186 +- * @desc: gpio to be setup
1187 +- * @lflags: gpio_lookup_flags - returned from of_find_gpio() or
1188 +- * of_get_gpio_hog()
1189 +- *
1190 +- * Set the GPIO descriptor flags based on the given GPIO lookup flags.
1191 +- */
1192 +-static void gpiod_parse_flags(struct gpio_desc *desc, unsigned long lflags)
1193 +-{
1194 +- if (lflags & GPIO_ACTIVE_LOW)
1195 +- set_bit(FLAG_ACTIVE_LOW, &desc->flags);
1196 +- if (lflags & GPIO_OPEN_DRAIN)
1197 +- set_bit(FLAG_OPEN_DRAIN, &desc->flags);
1198 +- if (lflags & GPIO_OPEN_SOURCE)
1199 +- set_bit(FLAG_OPEN_SOURCE, &desc->flags);
1200 +-}
1201 +
1202 + /**
1203 + * gpiod_configure_flags - helper function to configure a given GPIO
1204 + * @desc: gpio whose value will be assigned
1205 + * @con_id: function within the GPIO consumer
1206 ++ * @lflags: gpio_lookup_flags - returned from of_find_gpio() or
1207 ++ * of_get_gpio_hog()
1208 + * @dflags: gpiod_flags - optional GPIO initialization flags
1209 + *
1210 + * Return 0 on success, -ENOENT if no GPIO has been assigned to the
1211 +@@ -2536,10 +2521,17 @@ static void gpiod_parse_flags(struct gpio_desc *desc, unsigned long lflags)
1212 + * occurred while trying to acquire the GPIO.
1213 + */
1214 + static int gpiod_configure_flags(struct gpio_desc *desc, const char *con_id,
1215 +- enum gpiod_flags dflags)
1216 ++ unsigned long lflags, enum gpiod_flags dflags)
1217 + {
1218 + int status;
1219 +
1220 ++ if (lflags & GPIO_ACTIVE_LOW)
1221 ++ set_bit(FLAG_ACTIVE_LOW, &desc->flags);
1222 ++ if (lflags & GPIO_OPEN_DRAIN)
1223 ++ set_bit(FLAG_OPEN_DRAIN, &desc->flags);
1224 ++ if (lflags & GPIO_OPEN_SOURCE)
1225 ++ set_bit(FLAG_OPEN_SOURCE, &desc->flags);
1226 ++
1227 + /* No particular flag request, return here... */
1228 + if (!(dflags & GPIOD_FLAGS_BIT_DIR_SET)) {
1229 + pr_debug("no flags found for %s\n", con_id);
1230 +@@ -2606,13 +2598,11 @@ struct gpio_desc *__must_check gpiod_get_index(struct device *dev,
1231 + return desc;
1232 + }
1233 +
1234 +- gpiod_parse_flags(desc, lookupflags);
1235 +-
1236 + status = gpiod_request(desc, con_id);
1237 + if (status < 0)
1238 + return ERR_PTR(status);
1239 +
1240 +- status = gpiod_configure_flags(desc, con_id, flags);
1241 ++ status = gpiod_configure_flags(desc, con_id, lookupflags, flags);
1242 + if (status < 0) {
1243 + dev_dbg(dev, "setup of GPIO %s failed\n", con_id);
1244 + gpiod_put(desc);
1245 +@@ -2668,6 +2658,10 @@ struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
1246 + if (IS_ERR(desc))
1247 + return desc;
1248 +
1249 ++ ret = gpiod_request(desc, NULL);
1250 ++ if (ret)
1251 ++ return ERR_PTR(ret);
1252 ++
1253 + if (active_low)
1254 + set_bit(FLAG_ACTIVE_LOW, &desc->flags);
1255 +
1256 +@@ -2678,10 +2672,6 @@ struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
1257 + set_bit(FLAG_OPEN_SOURCE, &desc->flags);
1258 + }
1259 +
1260 +- ret = gpiod_request(desc, NULL);
1261 +- if (ret)
1262 +- return ERR_PTR(ret);
1263 +-
1264 + return desc;
1265 + }
1266 + EXPORT_SYMBOL_GPL(fwnode_get_named_gpiod);
1267 +@@ -2734,8 +2724,6 @@ int gpiod_hog(struct gpio_desc *desc, const char *name,
1268 + chip = gpiod_to_chip(desc);
1269 + hwnum = gpio_chip_hwgpio(desc);
1270 +
1271 +- gpiod_parse_flags(desc, lflags);
1272 +-
1273 + local_desc = gpiochip_request_own_desc(chip, hwnum, name);
1274 + if (IS_ERR(local_desc)) {
1275 + pr_err("requesting hog GPIO %s (chip %s, offset %d) failed\n",
1276 +@@ -2743,7 +2731,7 @@ int gpiod_hog(struct gpio_desc *desc, const char *name,
1277 + return PTR_ERR(local_desc);
1278 + }
1279 +
1280 +- status = gpiod_configure_flags(desc, name, dflags);
1281 ++ status = gpiod_configure_flags(desc, name, lflags, dflags);
1282 + if (status < 0) {
1283 + pr_err("setup of hog GPIO %s (chip %s, offset %d) failed\n",
1284 + name, chip->label, hwnum);
1285 +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
1286 +index 6043dc7..3e21732 100644
1287 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
1288 ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
1289 +@@ -880,7 +880,7 @@ static int amdgpu_cgs_acpi_eval_object(void *cgs_device,
1290 + struct cgs_acpi_method_argument *argument = NULL;
1291 + uint32_t i, count;
1292 + acpi_status status;
1293 +- int result;
1294 ++ int result = 0;
1295 + uint32_t func_no = 0xFFFFFFFF;
1296 +
1297 + handle = ACPI_HANDLE(&adev->pdev->dev);
1298 +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
1299 +index b04337d..d78739d 100644
1300 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
1301 ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
1302 +@@ -448,7 +448,8 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file
1303 + dev_info.max_memory_clock = adev->pm.default_mclk * 10;
1304 + }
1305 + dev_info.enabled_rb_pipes_mask = adev->gfx.config.backend_enable_mask;
1306 +- dev_info.num_rb_pipes = adev->gfx.config.num_rbs;
1307 ++ dev_info.num_rb_pipes = adev->gfx.config.max_backends_per_se *
1308 ++ adev->gfx.config.max_shader_engines;
1309 + dev_info.num_hw_gfx_contexts = adev->gfx.config.max_hw_contexts;
1310 + dev_info._pad = 0;
1311 + dev_info.ids_flags = 0;
1312 +diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
1313 +index bb8709066..d2216f8 100644
1314 +--- a/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
1315 ++++ b/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
1316 +@@ -5074,7 +5074,7 @@ static int gfx_v7_0_eop_irq(struct amdgpu_device *adev,
1317 + case 2:
1318 + for (i = 0; i < adev->gfx.num_compute_rings; i++) {
1319 + ring = &adev->gfx.compute_ring[i];
1320 +- if ((ring->me == me_id) & (ring->pipe == pipe_id))
1321 ++ if ((ring->me == me_id) && (ring->pipe == pipe_id))
1322 + amdgpu_fence_process(ring);
1323 + }
1324 + break;
1325 +diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
1326 +index ac00579..7708d90 100644
1327 +--- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c
1328 ++++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
1329 +@@ -242,13 +242,19 @@ static void kfd_process_notifier_release(struct mmu_notifier *mn,
1330 + pqm_uninit(&p->pqm);
1331 +
1332 + /* Iterate over all process device data structure and check
1333 +- * if we should reset all wavefronts */
1334 +- list_for_each_entry(pdd, &p->per_device_data, per_device_list)
1335 ++ * if we should delete debug managers and reset all wavefronts
1336 ++ */
1337 ++ list_for_each_entry(pdd, &p->per_device_data, per_device_list) {
1338 ++ if ((pdd->dev->dbgmgr) &&
1339 ++ (pdd->dev->dbgmgr->pasid == p->pasid))
1340 ++ kfd_dbgmgr_destroy(pdd->dev->dbgmgr);
1341 ++
1342 + if (pdd->reset_wavefronts) {
1343 + pr_warn("amdkfd: Resetting all wave fronts\n");
1344 + dbgdev_wave_reset_wavefronts(pdd->dev, p);
1345 + pdd->reset_wavefronts = false;
1346 + }
1347 ++ }
1348 +
1349 + mutex_unlock(&p->mutex);
1350 +
1351 +@@ -404,42 +410,52 @@ void kfd_unbind_process_from_device(struct kfd_dev *dev, unsigned int pasid)
1352 +
1353 + idx = srcu_read_lock(&kfd_processes_srcu);
1354 +
1355 ++ /*
1356 ++ * Look for the process that matches the pasid. If there is no such
1357 ++ * process, we either released it in amdkfd's own notifier, or there
1358 ++ * is a bug. Unfortunately, there is no way to tell...
1359 ++ */
1360 + hash_for_each_rcu(kfd_processes_table, i, p, kfd_processes)
1361 +- if (p->pasid == pasid)
1362 +- break;
1363 ++ if (p->pasid == pasid) {
1364 +
1365 +- srcu_read_unlock(&kfd_processes_srcu, idx);
1366 ++ srcu_read_unlock(&kfd_processes_srcu, idx);
1367 +
1368 +- BUG_ON(p->pasid != pasid);
1369 ++ pr_debug("Unbinding process %d from IOMMU\n", pasid);
1370 +
1371 +- mutex_lock(&p->mutex);
1372 ++ mutex_lock(&p->mutex);
1373 +
1374 +- if ((dev->dbgmgr) && (dev->dbgmgr->pasid == p->pasid))
1375 +- kfd_dbgmgr_destroy(dev->dbgmgr);
1376 ++ if ((dev->dbgmgr) && (dev->dbgmgr->pasid == p->pasid))
1377 ++ kfd_dbgmgr_destroy(dev->dbgmgr);
1378 +
1379 +- pqm_uninit(&p->pqm);
1380 ++ pqm_uninit(&p->pqm);
1381 +
1382 +- pdd = kfd_get_process_device_data(dev, p);
1383 ++ pdd = kfd_get_process_device_data(dev, p);
1384 +
1385 +- if (!pdd) {
1386 +- mutex_unlock(&p->mutex);
1387 +- return;
1388 +- }
1389 ++ if (!pdd) {
1390 ++ mutex_unlock(&p->mutex);
1391 ++ return;
1392 ++ }
1393 +
1394 +- if (pdd->reset_wavefronts) {
1395 +- dbgdev_wave_reset_wavefronts(pdd->dev, p);
1396 +- pdd->reset_wavefronts = false;
1397 +- }
1398 ++ if (pdd->reset_wavefronts) {
1399 ++ dbgdev_wave_reset_wavefronts(pdd->dev, p);
1400 ++ pdd->reset_wavefronts = false;
1401 ++ }
1402 +
1403 +- /*
1404 +- * Just mark pdd as unbound, because we still need it to call
1405 +- * amd_iommu_unbind_pasid() in when the process exits.
1406 +- * We don't call amd_iommu_unbind_pasid() here
1407 +- * because the IOMMU called us.
1408 +- */
1409 +- pdd->bound = false;
1410 ++ /*
1411 ++ * Just mark pdd as unbound, because we still need it
1412 ++ * to call amd_iommu_unbind_pasid() in when the
1413 ++ * process exits.
1414 ++ * We don't call amd_iommu_unbind_pasid() here
1415 ++ * because the IOMMU called us.
1416 ++ */
1417 ++ pdd->bound = false;
1418 +
1419 +- mutex_unlock(&p->mutex);
1420 ++ mutex_unlock(&p->mutex);
1421 ++
1422 ++ return;
1423 ++ }
1424 ++
1425 ++ srcu_read_unlock(&kfd_processes_srcu, idx);
1426 + }
1427 +
1428 + struct kfd_process_device *kfd_get_first_process_device_data(struct kfd_process *p)
1429 +diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c b/drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c
1430 +index fa208ad..efb77ed 100644
1431 +--- a/drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c
1432 ++++ b/drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c
1433 +@@ -306,10 +306,14 @@ int phm_store_dal_configuration_data(struct pp_hwmgr *hwmgr,
1434 + {
1435 + PHM_FUNC_CHECK(hwmgr);
1436 +
1437 +- if (hwmgr->hwmgr_func->store_cc6_data == NULL)
1438 ++ if (display_config == NULL)
1439 + return -EINVAL;
1440 +
1441 + hwmgr->display_config = *display_config;
1442 ++
1443 ++ if (hwmgr->hwmgr_func->store_cc6_data == NULL)
1444 ++ return -EINVAL;
1445 ++
1446 + /* to do pass other display configuration in furture */
1447 +
1448 + if (hwmgr->hwmgr_func->store_cc6_data)
1449 +diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/pp_acpi.c b/drivers/gpu/drm/amd/powerplay/hwmgr/pp_acpi.c
1450 +index 7b2d500..7cce483 100644
1451 +--- a/drivers/gpu/drm/amd/powerplay/hwmgr/pp_acpi.c
1452 ++++ b/drivers/gpu/drm/amd/powerplay/hwmgr/pp_acpi.c
1453 +@@ -21,6 +21,20 @@ bool acpi_atcs_functions_supported(void *device, uint32_t index)
1454 + return result == 0 ? (output_buf.function_bits & (1 << (index - 1))) != 0 : false;
1455 + }
1456 +
1457 ++bool acpi_atcs_notify_pcie_device_ready(void *device)
1458 ++{
1459 ++ int32_t temp_buffer = 1;
1460 ++
1461 ++ return cgs_call_acpi_method(device, CGS_ACPI_METHOD_ATCS,
1462 ++ ATCS_FUNCTION_PCIE_DEVICE_READY_NOTIFICATION,
1463 ++ &temp_buffer,
1464 ++ NULL,
1465 ++ 0,
1466 ++ sizeof(temp_buffer),
1467 ++ 0);
1468 ++}
1469 ++
1470 ++
1471 + int acpi_pcie_perf_request(void *device, uint8_t perf_req, bool advertise)
1472 + {
1473 + struct atcs_pref_req_input atcs_input;
1474 +@@ -29,7 +43,7 @@ int acpi_pcie_perf_request(void *device, uint8_t perf_req, bool advertise)
1475 + int result;
1476 + struct cgs_system_info info = {0};
1477 +
1478 +- if (!acpi_atcs_functions_supported(device, ATCS_FUNCTION_PCIE_PERFORMANCE_REQUEST))
1479 ++ if( 0 != acpi_atcs_notify_pcie_device_ready(device))
1480 + return -EINVAL;
1481 +
1482 + info.size = sizeof(struct cgs_system_info);
1483 +@@ -54,7 +68,7 @@ int acpi_pcie_perf_request(void *device, uint8_t perf_req, bool advertise)
1484 + ATCS_FUNCTION_PCIE_PERFORMANCE_REQUEST,
1485 + &atcs_input,
1486 + &atcs_output,
1487 +- 0,
1488 ++ 1,
1489 + sizeof(atcs_input),
1490 + sizeof(atcs_output));
1491 + if (result != 0)
1492 +diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/tonga_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/tonga_hwmgr.c
1493 +index 0d5d837..aae2e8e 100644
1494 +--- a/drivers/gpu/drm/amd/powerplay/hwmgr/tonga_hwmgr.c
1495 ++++ b/drivers/gpu/drm/amd/powerplay/hwmgr/tonga_hwmgr.c
1496 +@@ -1298,7 +1298,7 @@ static int tonga_populate_smc_mvdd_table(struct pp_hwmgr *hwmgr,
1497 + table->Smio[count] |=
1498 + data->mvdd_voltage_table.entries[count].smio_low;
1499 + }
1500 +- table->SmioMask2 = data->vddci_voltage_table.mask_low;
1501 ++ table->SmioMask2 = data->mvdd_voltage_table.mask_low;
1502 +
1503 + CONVERT_FROM_HOST_TO_SMC_UL(table->MvddLevelCount);
1504 + }
1505 +diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/tonga_processpptables.c b/drivers/gpu/drm/amd/powerplay/hwmgr/tonga_processpptables.c
1506 +index b156481..17766e8 100644
1507 +--- a/drivers/gpu/drm/amd/powerplay/hwmgr/tonga_processpptables.c
1508 ++++ b/drivers/gpu/drm/amd/powerplay/hwmgr/tonga_processpptables.c
1509 +@@ -299,7 +299,7 @@ static int init_dpm_2_parameters(
1510 + (((unsigned long)powerplay_table) + le16_to_cpu(powerplay_table->usPPMTableOffset));
1511 +
1512 + if (0 != powerplay_table->usPPMTableOffset) {
1513 +- if (1 == get_platform_power_management_table(hwmgr, atom_ppm_table)) {
1514 ++ if (get_platform_power_management_table(hwmgr, atom_ppm_table) == 0) {
1515 + phm_cap_set(hwmgr->platform_descriptor.platformCaps,
1516 + PHM_PlatformCaps_EnablePlatformPowerManagement);
1517 + }
1518 +diff --git a/drivers/gpu/drm/amd/powerplay/inc/pp_acpi.h b/drivers/gpu/drm/amd/powerplay/inc/pp_acpi.h
1519 +index 3bd5e69..3df5de2 100644
1520 +--- a/drivers/gpu/drm/amd/powerplay/inc/pp_acpi.h
1521 ++++ b/drivers/gpu/drm/amd/powerplay/inc/pp_acpi.h
1522 +@@ -26,3 +26,4 @@ extern bool acpi_atcs_functions_supported(void *device,
1523 + extern int acpi_pcie_perf_request(void *device,
1524 + uint8_t perf_req,
1525 + bool advertise);
1526 ++extern bool acpi_atcs_notify_pcie_device_ready(void *device);
1527 +diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
1528 +index d65dcae..6d9c0f5 100644
1529 +--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
1530 ++++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
1531 +@@ -335,6 +335,8 @@ atmel_hlcdc_plane_update_pos_and_size(struct atmel_hlcdc_plane *plane,
1532 +
1533 + atmel_hlcdc_layer_update_cfg(&plane->layer, 13, 0xffffffff,
1534 + factor_reg);
1535 ++ } else {
1536 ++ atmel_hlcdc_layer_update_cfg(&plane->layer, 13, 0xffffffff, 0);
1537 + }
1538 + }
1539 +
1540 +diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
1541 +index d307d96..080a090 100644
1542 +--- a/drivers/gpu/drm/drm_atomic.c
1543 ++++ b/drivers/gpu/drm/drm_atomic.c
1544 +@@ -354,6 +354,8 @@ int drm_atomic_set_mode_prop_for_crtc(struct drm_crtc_state *state,
1545 + drm_property_unreference_blob(state->mode_blob);
1546 + state->mode_blob = NULL;
1547 +
1548 ++ memset(&state->mode, 0, sizeof(state->mode));
1549 ++
1550 + if (blob) {
1551 + if (blob->length != sizeof(struct drm_mode_modeinfo) ||
1552 + drm_mode_convert_umode(&state->mode,
1553 +@@ -366,7 +368,6 @@ int drm_atomic_set_mode_prop_for_crtc(struct drm_crtc_state *state,
1554 + DRM_DEBUG_ATOMIC("Set [MODE:%s] for CRTC state %p\n",
1555 + state->mode.name, state);
1556 + } else {
1557 +- memset(&state->mode, 0, sizeof(state->mode));
1558 + state->enable = false;
1559 + DRM_DEBUG_ATOMIC("Set [NOMODE] for CRTC state %p\n",
1560 + state);
1561 +@@ -1287,14 +1288,39 @@ EXPORT_SYMBOL(drm_atomic_add_affected_planes);
1562 + */
1563 + void drm_atomic_legacy_backoff(struct drm_atomic_state *state)
1564 + {
1565 ++ struct drm_device *dev = state->dev;
1566 ++ unsigned crtc_mask = 0;
1567 ++ struct drm_crtc *crtc;
1568 + int ret;
1569 ++ bool global = false;
1570 ++
1571 ++ drm_for_each_crtc(crtc, dev) {
1572 ++ if (crtc->acquire_ctx != state->acquire_ctx)
1573 ++ continue;
1574 ++
1575 ++ crtc_mask |= drm_crtc_mask(crtc);
1576 ++ crtc->acquire_ctx = NULL;
1577 ++ }
1578 ++
1579 ++ if (WARN_ON(dev->mode_config.acquire_ctx == state->acquire_ctx)) {
1580 ++ global = true;
1581 ++
1582 ++ dev->mode_config.acquire_ctx = NULL;
1583 ++ }
1584 +
1585 + retry:
1586 + drm_modeset_backoff(state->acquire_ctx);
1587 +
1588 +- ret = drm_modeset_lock_all_ctx(state->dev, state->acquire_ctx);
1589 ++ ret = drm_modeset_lock_all_ctx(dev, state->acquire_ctx);
1590 + if (ret)
1591 + goto retry;
1592 ++
1593 ++ drm_for_each_crtc(crtc, dev)
1594 ++ if (drm_crtc_mask(crtc) & crtc_mask)
1595 ++ crtc->acquire_ctx = state->acquire_ctx;
1596 ++
1597 ++ if (global)
1598 ++ dev->mode_config.acquire_ctx = state->acquire_ctx;
1599 + }
1600 + EXPORT_SYMBOL(drm_atomic_legacy_backoff);
1601 +
1602 +diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
1603 +index f30de80..691a1b9 100644
1604 +--- a/drivers/gpu/drm/drm_crtc.c
1605 ++++ b/drivers/gpu/drm/drm_crtc.c
1606 +@@ -2800,8 +2800,6 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
1607 + goto out;
1608 + }
1609 +
1610 +- drm_mode_set_crtcinfo(mode, CRTC_INTERLACE_HALVE_V);
1611 +-
1612 + /*
1613 + * Check whether the primary plane supports the fb pixel format.
1614 + * Drivers not implementing the universal planes API use a
1615 +diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
1616 +index 71ea052..ccfe7e7 100644
1617 +--- a/drivers/gpu/drm/drm_dp_mst_topology.c
1618 ++++ b/drivers/gpu/drm/drm_dp_mst_topology.c
1619 +@@ -2908,11 +2908,9 @@ static void drm_dp_destroy_connector_work(struct work_struct *work)
1620 + drm_dp_port_teardown_pdt(port, port->pdt);
1621 +
1622 + if (!port->input && port->vcpi.vcpi > 0) {
1623 +- if (mgr->mst_state) {
1624 +- drm_dp_mst_reset_vcpi_slots(mgr, port);
1625 +- drm_dp_update_payload_part1(mgr);
1626 +- drm_dp_mst_put_payload_id(mgr, port->vcpi.vcpi);
1627 +- }
1628 ++ drm_dp_mst_reset_vcpi_slots(mgr, port);
1629 ++ drm_dp_update_payload_part1(mgr);
1630 ++ drm_dp_mst_put_payload_id(mgr, port->vcpi.vcpi);
1631 + }
1632 +
1633 + kref_put(&port->kref, drm_dp_free_mst_port);
1634 +diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c b/drivers/gpu/drm/drm_fb_cma_helper.c
1635 +index bb88e3d..e619b00 100644
1636 +--- a/drivers/gpu/drm/drm_fb_cma_helper.c
1637 ++++ b/drivers/gpu/drm/drm_fb_cma_helper.c
1638 +@@ -301,7 +301,7 @@ static int drm_fbdev_cma_create(struct drm_fb_helper *helper,
1639 + err_fb_info_destroy:
1640 + drm_fb_helper_release_fbi(helper);
1641 + err_gem_free_object:
1642 +- dev->driver->gem_free_object(&obj->base);
1643 ++ drm_gem_object_unreference_unlocked(&obj->base);
1644 + return ret;
1645 + }
1646 +
1647 +diff --git a/drivers/gpu/drm/drm_gem_cma_helper.c b/drivers/gpu/drm/drm_gem_cma_helper.c
1648 +index 1f500a1..d988ca0 100644
1649 +--- a/drivers/gpu/drm/drm_gem_cma_helper.c
1650 ++++ b/drivers/gpu/drm/drm_gem_cma_helper.c
1651 +@@ -121,7 +121,7 @@ struct drm_gem_cma_object *drm_gem_cma_create(struct drm_device *drm,
1652 + return cma_obj;
1653 +
1654 + error:
1655 +- drm->driver->gem_free_object(&cma_obj->base);
1656 ++ drm_gem_object_unreference_unlocked(&cma_obj->base);
1657 + return ERR_PTR(ret);
1658 + }
1659 + EXPORT_SYMBOL_GPL(drm_gem_cma_create);
1660 +@@ -162,18 +162,12 @@ drm_gem_cma_create_with_handle(struct drm_file *file_priv,
1661 + * and handle has the id what user can see.
1662 + */
1663 + ret = drm_gem_handle_create(file_priv, gem_obj, handle);
1664 +- if (ret)
1665 +- goto err_handle_create;
1666 +-
1667 + /* drop reference from allocate - handle holds it now. */
1668 + drm_gem_object_unreference_unlocked(gem_obj);
1669 ++ if (ret)
1670 ++ return ERR_PTR(ret);
1671 +
1672 + return cma_obj;
1673 +-
1674 +-err_handle_create:
1675 +- drm->driver->gem_free_object(gem_obj);
1676 +-
1677 +- return ERR_PTR(ret);
1678 + }
1679 +
1680 + /**
1681 +diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
1682 +index f7448a5..5d0fc26 100644
1683 +--- a/drivers/gpu/drm/drm_modes.c
1684 ++++ b/drivers/gpu/drm/drm_modes.c
1685 +@@ -1518,6 +1518,8 @@ int drm_mode_convert_umode(struct drm_display_mode *out,
1686 + if (out->status != MODE_OK)
1687 + goto out;
1688 +
1689 ++ drm_mode_set_crtcinfo(out, CRTC_INTERLACE_HALVE_V);
1690 ++
1691 + ret = 0;
1692 +
1693 + out:
1694 +diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
1695 +index e8d9337..77886f1 100644
1696 +--- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
1697 ++++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
1698 +@@ -40,9 +40,10 @@ static const struct regmap_config fsl_dcu_regmap_config = {
1699 + .reg_bits = 32,
1700 + .reg_stride = 4,
1701 + .val_bits = 32,
1702 +- .cache_type = REGCACHE_RBTREE,
1703 ++ .cache_type = REGCACHE_FLAT,
1704 +
1705 + .volatile_reg = fsl_dcu_drm_is_volatile_reg,
1706 ++ .max_register = 0x11fc,
1707 + };
1708 +
1709 + static int fsl_dcu_drm_irq_init(struct drm_device *dev)
1710 +diff --git a/drivers/gpu/drm/i915/i915_gem_shrinker.c b/drivers/gpu/drm/i915/i915_gem_shrinker.c
1711 +index d3c473f..3af4061 100644
1712 +--- a/drivers/gpu/drm/i915/i915_gem_shrinker.c
1713 ++++ b/drivers/gpu/drm/i915/i915_gem_shrinker.c
1714 +@@ -39,7 +39,7 @@ static bool mutex_is_locked_by(struct mutex *mutex, struct task_struct *task)
1715 + if (!mutex_is_locked(mutex))
1716 + return false;
1717 +
1718 +-#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_MUTEXES)
1719 ++#if defined(CONFIG_DEBUG_MUTEXES) || defined(CONFIG_MUTEX_SPIN_ON_OWNER)
1720 + return mutex->owner == task;
1721 + #else
1722 + /* Since UP may be pre-empted, we cannot assume that we own the lock */
1723 +diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
1724 +index 7741efb..e5db9e1 100644
1725 +--- a/drivers/gpu/drm/i915/intel_display.c
1726 ++++ b/drivers/gpu/drm/i915/intel_display.c
1727 +@@ -8229,12 +8229,14 @@ static void ironlake_init_pch_refclk(struct drm_device *dev)
1728 + {
1729 + struct drm_i915_private *dev_priv = dev->dev_private;
1730 + struct intel_encoder *encoder;
1731 ++ int i;
1732 + u32 val, final;
1733 + bool has_lvds = false;
1734 + bool has_cpu_edp = false;
1735 + bool has_panel = false;
1736 + bool has_ck505 = false;
1737 + bool can_ssc = false;
1738 ++ bool using_ssc_source = false;
1739 +
1740 + /* We need to take the global config into account */
1741 + for_each_intel_encoder(dev, encoder) {
1742 +@@ -8261,8 +8263,22 @@ static void ironlake_init_pch_refclk(struct drm_device *dev)
1743 + can_ssc = true;
1744 + }
1745 +
1746 +- DRM_DEBUG_KMS("has_panel %d has_lvds %d has_ck505 %d\n",
1747 +- has_panel, has_lvds, has_ck505);
1748 ++ /* Check if any DPLLs are using the SSC source */
1749 ++ for (i = 0; i < dev_priv->num_shared_dpll; i++) {
1750 ++ u32 temp = I915_READ(PCH_DPLL(i));
1751 ++
1752 ++ if (!(temp & DPLL_VCO_ENABLE))
1753 ++ continue;
1754 ++
1755 ++ if ((temp & PLL_REF_INPUT_MASK) ==
1756 ++ PLLB_REF_INPUT_SPREADSPECTRUMIN) {
1757 ++ using_ssc_source = true;
1758 ++ break;
1759 ++ }
1760 ++ }
1761 ++
1762 ++ DRM_DEBUG_KMS("has_panel %d has_lvds %d has_ck505 %d using_ssc_source %d\n",
1763 ++ has_panel, has_lvds, has_ck505, using_ssc_source);
1764 +
1765 + /* Ironlake: try to setup display ref clock before DPLL
1766 + * enabling. This is only under driver's control after
1767 +@@ -8299,9 +8315,9 @@ static void ironlake_init_pch_refclk(struct drm_device *dev)
1768 + final |= DREF_CPU_SOURCE_OUTPUT_NONSPREAD;
1769 + } else
1770 + final |= DREF_CPU_SOURCE_OUTPUT_DISABLE;
1771 +- } else {
1772 +- final |= DREF_SSC_SOURCE_DISABLE;
1773 +- final |= DREF_CPU_SOURCE_OUTPUT_DISABLE;
1774 ++ } else if (using_ssc_source) {
1775 ++ final |= DREF_SSC_SOURCE_ENABLE;
1776 ++ final |= DREF_SSC1_ENABLE;
1777 + }
1778 +
1779 + if (final == val)
1780 +@@ -8347,7 +8363,7 @@ static void ironlake_init_pch_refclk(struct drm_device *dev)
1781 + POSTING_READ(PCH_DREF_CONTROL);
1782 + udelay(200);
1783 + } else {
1784 +- DRM_DEBUG_KMS("Disabling SSC entirely\n");
1785 ++ DRM_DEBUG_KMS("Disabling CPU source output\n");
1786 +
1787 + val &= ~DREF_CPU_SOURCE_OUTPUT_MASK;
1788 +
1789 +@@ -8358,16 +8374,20 @@ static void ironlake_init_pch_refclk(struct drm_device *dev)
1790 + POSTING_READ(PCH_DREF_CONTROL);
1791 + udelay(200);
1792 +
1793 +- /* Turn off the SSC source */
1794 +- val &= ~DREF_SSC_SOURCE_MASK;
1795 +- val |= DREF_SSC_SOURCE_DISABLE;
1796 ++ if (!using_ssc_source) {
1797 ++ DRM_DEBUG_KMS("Disabling SSC source\n");
1798 +
1799 +- /* Turn off SSC1 */
1800 +- val &= ~DREF_SSC1_ENABLE;
1801 ++ /* Turn off the SSC source */
1802 ++ val &= ~DREF_SSC_SOURCE_MASK;
1803 ++ val |= DREF_SSC_SOURCE_DISABLE;
1804 +
1805 +- I915_WRITE(PCH_DREF_CONTROL, val);
1806 +- POSTING_READ(PCH_DREF_CONTROL);
1807 +- udelay(200);
1808 ++ /* Turn off SSC1 */
1809 ++ val &= ~DREF_SSC1_ENABLE;
1810 ++
1811 ++ I915_WRITE(PCH_DREF_CONTROL, val);
1812 ++ POSTING_READ(PCH_DREF_CONTROL);
1813 ++ udelay(200);
1814 ++ }
1815 + }
1816 +
1817 + BUG_ON(val != final);
1818 +diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
1819 +index 412a34c..69054ef 100644
1820 +--- a/drivers/gpu/drm/i915/intel_dp.c
1821 ++++ b/drivers/gpu/drm/i915/intel_dp.c
1822 +@@ -4942,13 +4942,15 @@ static void intel_edp_panel_vdd_sanitize(struct intel_dp *intel_dp)
1823 +
1824 + void intel_dp_encoder_reset(struct drm_encoder *encoder)
1825 + {
1826 +- struct intel_dp *intel_dp;
1827 ++ struct drm_i915_private *dev_priv = to_i915(encoder->dev);
1828 ++ struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
1829 ++
1830 ++ if (!HAS_DDI(dev_priv))
1831 ++ intel_dp->DP = I915_READ(intel_dp->output_reg);
1832 +
1833 + if (to_intel_encoder(encoder)->type != INTEL_OUTPUT_EDP)
1834 + return;
1835 +
1836 +- intel_dp = enc_to_intel_dp(encoder);
1837 +-
1838 + pps_lock(intel_dp);
1839 +
1840 + /*
1841 +@@ -5020,9 +5022,6 @@ intel_dp_hpd_pulse(struct intel_digital_port *intel_dig_port, bool long_hpd)
1842 + intel_display_power_get(dev_priv, power_domain);
1843 +
1844 + if (long_hpd) {
1845 +- /* indicate that we need to restart link training */
1846 +- intel_dp->train_set_valid = false;
1847 +-
1848 + if (!intel_digital_port_connected(dev_priv, intel_dig_port))
1849 + goto mst_fail;
1850 +
1851 +diff --git a/drivers/gpu/drm/i915/intel_dp_link_training.c b/drivers/gpu/drm/i915/intel_dp_link_training.c
1852 +index 0b8eefc..926a1e6 100644
1853 +--- a/drivers/gpu/drm/i915/intel_dp_link_training.c
1854 ++++ b/drivers/gpu/drm/i915/intel_dp_link_training.c
1855 +@@ -85,8 +85,7 @@ static bool
1856 + intel_dp_reset_link_train(struct intel_dp *intel_dp,
1857 + uint8_t dp_train_pat)
1858 + {
1859 +- if (!intel_dp->train_set_valid)
1860 +- memset(intel_dp->train_set, 0, sizeof(intel_dp->train_set));
1861 ++ memset(intel_dp->train_set, 0, sizeof(intel_dp->train_set));
1862 + intel_dp_set_signal_levels(intel_dp);
1863 + return intel_dp_set_link_train(intel_dp, dp_train_pat);
1864 + }
1865 +@@ -161,22 +160,6 @@ intel_dp_link_training_clock_recovery(struct intel_dp *intel_dp)
1866 + break;
1867 + }
1868 +
1869 +- /*
1870 +- * if we used previously trained voltage and pre-emphasis values
1871 +- * and we don't get clock recovery, reset link training values
1872 +- */
1873 +- if (intel_dp->train_set_valid) {
1874 +- DRM_DEBUG_KMS("clock recovery not ok, reset");
1875 +- /* clear the flag as we are not reusing train set */
1876 +- intel_dp->train_set_valid = false;
1877 +- if (!intel_dp_reset_link_train(intel_dp,
1878 +- DP_TRAINING_PATTERN_1 |
1879 +- DP_LINK_SCRAMBLING_DISABLE)) {
1880 +- DRM_ERROR("failed to enable link training\n");
1881 +- return;
1882 +- }
1883 +- continue;
1884 +- }
1885 +
1886 + /* Check to see if we've tried the max voltage */
1887 + for (i = 0; i < intel_dp->lane_count; i++)
1888 +@@ -284,7 +267,6 @@ intel_dp_link_training_channel_equalization(struct intel_dp *intel_dp)
1889 + /* Make sure clock is still ok */
1890 + if (!drm_dp_clock_recovery_ok(link_status,
1891 + intel_dp->lane_count)) {
1892 +- intel_dp->train_set_valid = false;
1893 + intel_dp_link_training_clock_recovery(intel_dp);
1894 + intel_dp_set_link_train(intel_dp,
1895 + training_pattern |
1896 +@@ -301,7 +283,6 @@ intel_dp_link_training_channel_equalization(struct intel_dp *intel_dp)
1897 +
1898 + /* Try 5 times, then try clock recovery if that fails */
1899 + if (tries > 5) {
1900 +- intel_dp->train_set_valid = false;
1901 + intel_dp_link_training_clock_recovery(intel_dp);
1902 + intel_dp_set_link_train(intel_dp,
1903 + training_pattern |
1904 +@@ -322,10 +303,8 @@ intel_dp_link_training_channel_equalization(struct intel_dp *intel_dp)
1905 +
1906 + intel_dp_set_idle_link_train(intel_dp);
1907 +
1908 +- if (channel_eq) {
1909 +- intel_dp->train_set_valid = true;
1910 ++ if (channel_eq)
1911 + DRM_DEBUG_KMS("Channel EQ done. DP Training successful\n");
1912 +- }
1913 + }
1914 +
1915 + void intel_dp_stop_link_train(struct intel_dp *intel_dp)
1916 +diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
1917 +index 3a30b37..8dd2cc5 100644
1918 +--- a/drivers/gpu/drm/i915/intel_drv.h
1919 ++++ b/drivers/gpu/drm/i915/intel_drv.h
1920 +@@ -811,8 +811,6 @@ struct intel_dp {
1921 + /* This is called before a link training is starterd */
1922 + void (*prepare_link_retrain)(struct intel_dp *intel_dp);
1923 +
1924 +- bool train_set_valid;
1925 +-
1926 + /* Displayport compliance testing */
1927 + unsigned long compliance_test_type;
1928 + unsigned long compliance_test_data;
1929 +diff --git a/drivers/gpu/drm/i915/intel_fbc.c b/drivers/gpu/drm/i915/intel_fbc.c
1930 +index 0f0492f..28f4407 100644
1931 +--- a/drivers/gpu/drm/i915/intel_fbc.c
1932 ++++ b/drivers/gpu/drm/i915/intel_fbc.c
1933 +@@ -823,8 +823,7 @@ static bool intel_fbc_can_choose(struct intel_crtc *crtc)
1934 + {
1935 + struct drm_i915_private *dev_priv = crtc->base.dev->dev_private;
1936 + struct intel_fbc *fbc = &dev_priv->fbc;
1937 +- bool enable_by_default = IS_HASWELL(dev_priv) ||
1938 +- IS_BROADWELL(dev_priv);
1939 ++ bool enable_by_default = IS_BROADWELL(dev_priv);
1940 +
1941 + if (intel_vgpu_active(dev_priv->dev)) {
1942 + fbc->no_fbc_reason = "VGPU is active";
1943 +diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c
1944 +index 14e64e0..d347dca 100644
1945 +--- a/drivers/gpu/drm/mgag200/mgag200_mode.c
1946 ++++ b/drivers/gpu/drm/mgag200/mgag200_mode.c
1947 +@@ -182,7 +182,7 @@ static int mga_g200se_set_plls(struct mga_device *mdev, long clock)
1948 + }
1949 + }
1950 +
1951 +- fvv = pllreffreq * testn / testm;
1952 ++ fvv = pllreffreq * (n + 1) / (m + 1);
1953 + fvv = (fvv - 800000) / 50000;
1954 +
1955 + if (fvv > 15)
1956 +@@ -202,6 +202,14 @@ static int mga_g200se_set_plls(struct mga_device *mdev, long clock)
1957 + WREG_DAC(MGA1064_PIX_PLLC_M, m);
1958 + WREG_DAC(MGA1064_PIX_PLLC_N, n);
1959 + WREG_DAC(MGA1064_PIX_PLLC_P, p);
1960 ++
1961 ++ if (mdev->unique_rev_id >= 0x04) {
1962 ++ WREG_DAC(0x1a, 0x09);
1963 ++ msleep(20);
1964 ++ WREG_DAC(0x1a, 0x01);
1965 ++
1966 ++ }
1967 ++
1968 + return 0;
1969 + }
1970 +
1971 +diff --git a/drivers/gpu/drm/nouveau/include/nvkm/subdev/bios/disp.h b/drivers/gpu/drm/nouveau/include/nvkm/subdev/bios/disp.h
1972 +index db10c11..c5a6ebd 100644
1973 +--- a/drivers/gpu/drm/nouveau/include/nvkm/subdev/bios/disp.h
1974 ++++ b/drivers/gpu/drm/nouveau/include/nvkm/subdev/bios/disp.h
1975 +@@ -25,7 +25,8 @@ u16 nvbios_outp_match(struct nvkm_bios *, u16 type, u16 mask,
1976 + u8 *ver, u8 *hdr, u8 *cnt, u8 *len, struct nvbios_outp *);
1977 +
1978 + struct nvbios_ocfg {
1979 +- u16 match;
1980 ++ u8 proto;
1981 ++ u8 flags;
1982 + u16 clkcmp[2];
1983 + };
1984 +
1985 +@@ -33,7 +34,7 @@ u16 nvbios_ocfg_entry(struct nvkm_bios *, u16 outp, u8 idx,
1986 + u8 *ver, u8 *hdr, u8 *cnt, u8 *len);
1987 + u16 nvbios_ocfg_parse(struct nvkm_bios *, u16 outp, u8 idx,
1988 + u8 *ver, u8 *hdr, u8 *cnt, u8 *len, struct nvbios_ocfg *);
1989 +-u16 nvbios_ocfg_match(struct nvkm_bios *, u16 outp, u16 type,
1990 ++u16 nvbios_ocfg_match(struct nvkm_bios *, u16 outp, u8 proto, u8 flags,
1991 + u8 *ver, u8 *hdr, u8 *cnt, u8 *len, struct nvbios_ocfg *);
1992 + u16 nvbios_oclk_match(struct nvkm_bios *, u16 cmp, u32 khz);
1993 + #endif
1994 +diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.c b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
1995 +index 59f27e7..e40a1b0 100644
1996 +--- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c
1997 ++++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
1998 +@@ -557,6 +557,8 @@ nouveau_fbcon_init(struct drm_device *dev)
1999 + if (ret)
2000 + goto fini;
2001 +
2002 ++ if (fbcon->helper.fbdev)
2003 ++ fbcon->helper.fbdev->pixmap.buf_align = 4;
2004 + return 0;
2005 +
2006 + fini:
2007 +diff --git a/drivers/gpu/drm/nouveau/nv04_fbcon.c b/drivers/gpu/drm/nouveau/nv04_fbcon.c
2008 +index 789dc29..8f715fe 100644
2009 +--- a/drivers/gpu/drm/nouveau/nv04_fbcon.c
2010 ++++ b/drivers/gpu/drm/nouveau/nv04_fbcon.c
2011 +@@ -82,7 +82,6 @@ nv04_fbcon_imageblit(struct fb_info *info, const struct fb_image *image)
2012 + uint32_t fg;
2013 + uint32_t bg;
2014 + uint32_t dsize;
2015 +- uint32_t width;
2016 + uint32_t *data = (uint32_t *)image->data;
2017 + int ret;
2018 +
2019 +@@ -93,9 +92,6 @@ nv04_fbcon_imageblit(struct fb_info *info, const struct fb_image *image)
2020 + if (ret)
2021 + return ret;
2022 +
2023 +- width = ALIGN(image->width, 8);
2024 +- dsize = ALIGN(width * image->height, 32) >> 5;
2025 +-
2026 + if (info->fix.visual == FB_VISUAL_TRUECOLOR ||
2027 + info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
2028 + fg = ((uint32_t *) info->pseudo_palette)[image->fg_color];
2029 +@@ -111,10 +107,11 @@ nv04_fbcon_imageblit(struct fb_info *info, const struct fb_image *image)
2030 + ((image->dx + image->width) & 0xffff));
2031 + OUT_RING(chan, bg);
2032 + OUT_RING(chan, fg);
2033 +- OUT_RING(chan, (image->height << 16) | width);
2034 ++ OUT_RING(chan, (image->height << 16) | image->width);
2035 + OUT_RING(chan, (image->height << 16) | image->width);
2036 + OUT_RING(chan, (image->dy << 16) | (image->dx & 0xffff));
2037 +
2038 ++ dsize = ALIGN(image->width * image->height, 32) >> 5;
2039 + while (dsize) {
2040 + int iter_len = dsize > 128 ? 128 : dsize;
2041 +
2042 +diff --git a/drivers/gpu/drm/nouveau/nv50_fbcon.c b/drivers/gpu/drm/nouveau/nv50_fbcon.c
2043 +index e05499d..a4e259a 100644
2044 +--- a/drivers/gpu/drm/nouveau/nv50_fbcon.c
2045 ++++ b/drivers/gpu/drm/nouveau/nv50_fbcon.c
2046 +@@ -95,7 +95,7 @@ nv50_fbcon_imageblit(struct fb_info *info, const struct fb_image *image)
2047 + struct nouveau_fbdev *nfbdev = info->par;
2048 + struct nouveau_drm *drm = nouveau_drm(nfbdev->dev);
2049 + struct nouveau_channel *chan = drm->channel;
2050 +- uint32_t width, dwords, *data = (uint32_t *)image->data;
2051 ++ uint32_t dwords, *data = (uint32_t *)image->data;
2052 + uint32_t mask = ~(~0 >> (32 - info->var.bits_per_pixel));
2053 + uint32_t *palette = info->pseudo_palette;
2054 + int ret;
2055 +@@ -107,9 +107,6 @@ nv50_fbcon_imageblit(struct fb_info *info, const struct fb_image *image)
2056 + if (ret)
2057 + return ret;
2058 +
2059 +- width = ALIGN(image->width, 32);
2060 +- dwords = (width * image->height) >> 5;
2061 +-
2062 + BEGIN_NV04(chan, NvSub2D, 0x0814, 2);
2063 + if (info->fix.visual == FB_VISUAL_TRUECOLOR ||
2064 + info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
2065 +@@ -128,6 +125,7 @@ nv50_fbcon_imageblit(struct fb_info *info, const struct fb_image *image)
2066 + OUT_RING(chan, 0);
2067 + OUT_RING(chan, image->dy);
2068 +
2069 ++ dwords = ALIGN(image->width * image->height, 32) >> 5;
2070 + while (dwords) {
2071 + int push = dwords > 2047 ? 2047 : dwords;
2072 +
2073 +diff --git a/drivers/gpu/drm/nouveau/nvc0_fbcon.c b/drivers/gpu/drm/nouveau/nvc0_fbcon.c
2074 +index c97395b..f28315e 100644
2075 +--- a/drivers/gpu/drm/nouveau/nvc0_fbcon.c
2076 ++++ b/drivers/gpu/drm/nouveau/nvc0_fbcon.c
2077 +@@ -95,7 +95,7 @@ nvc0_fbcon_imageblit(struct fb_info *info, const struct fb_image *image)
2078 + struct nouveau_fbdev *nfbdev = info->par;
2079 + struct nouveau_drm *drm = nouveau_drm(nfbdev->dev);
2080 + struct nouveau_channel *chan = drm->channel;
2081 +- uint32_t width, dwords, *data = (uint32_t *)image->data;
2082 ++ uint32_t dwords, *data = (uint32_t *)image->data;
2083 + uint32_t mask = ~(~0 >> (32 - info->var.bits_per_pixel));
2084 + uint32_t *palette = info->pseudo_palette;
2085 + int ret;
2086 +@@ -107,9 +107,6 @@ nvc0_fbcon_imageblit(struct fb_info *info, const struct fb_image *image)
2087 + if (ret)
2088 + return ret;
2089 +
2090 +- width = ALIGN(image->width, 32);
2091 +- dwords = (width * image->height) >> 5;
2092 +-
2093 + BEGIN_NVC0(chan, NvSub2D, 0x0814, 2);
2094 + if (info->fix.visual == FB_VISUAL_TRUECOLOR ||
2095 + info->fix.visual == FB_VISUAL_DIRECTCOLOR) {
2096 +@@ -128,6 +125,7 @@ nvc0_fbcon_imageblit(struct fb_info *info, const struct fb_image *image)
2097 + OUT_RING (chan, 0);
2098 + OUT_RING (chan, image->dy);
2099 +
2100 ++ dwords = ALIGN(image->width * image->height, 32) >> 5;
2101 + while (dwords) {
2102 + int push = dwords > 2047 ? 2047 : dwords;
2103 +
2104 +diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/device/pci.c b/drivers/gpu/drm/nouveau/nvkm/engine/device/pci.c
2105 +index 18fab397..62ad030 100644
2106 +--- a/drivers/gpu/drm/nouveau/nvkm/engine/device/pci.c
2107 ++++ b/drivers/gpu/drm/nouveau/nvkm/engine/device/pci.c
2108 +@@ -1614,7 +1614,7 @@ nvkm_device_pci_func = {
2109 + .fini = nvkm_device_pci_fini,
2110 + .resource_addr = nvkm_device_pci_resource_addr,
2111 + .resource_size = nvkm_device_pci_resource_size,
2112 +- .cpu_coherent = !IS_ENABLED(CONFIG_ARM) && !IS_ENABLED(CONFIG_ARM64),
2113 ++ .cpu_coherent = !IS_ENABLED(CONFIG_ARM),
2114 + };
2115 +
2116 + int
2117 +diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/Kbuild b/drivers/gpu/drm/nouveau/nvkm/engine/disp/Kbuild
2118 +index a74c5dd..e2a64ed 100644
2119 +--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/Kbuild
2120 ++++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/Kbuild
2121 +@@ -18,6 +18,7 @@ nvkm-y += nvkm/engine/disp/piornv50.o
2122 + nvkm-y += nvkm/engine/disp/sornv50.o
2123 + nvkm-y += nvkm/engine/disp/sorg94.o
2124 + nvkm-y += nvkm/engine/disp/sorgf119.o
2125 ++nvkm-y += nvkm/engine/disp/sorgm107.o
2126 + nvkm-y += nvkm/engine/disp/sorgm200.o
2127 + nvkm-y += nvkm/engine/disp/dport.o
2128 +
2129 +diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gf119.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gf119.c
2130 +index f031466..5dd3438 100644
2131 +--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gf119.c
2132 ++++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gf119.c
2133 +@@ -76,6 +76,7 @@ exec_lookup(struct nv50_disp *disp, int head, int or, u32 ctrl,
2134 + mask |= 0x0001 << or;
2135 + mask |= 0x0100 << head;
2136 +
2137 ++
2138 + list_for_each_entry(outp, &disp->base.outp, head) {
2139 + if ((outp->info.hasht & 0xff) == type &&
2140 + (outp->info.hashm & mask) == mask) {
2141 +@@ -155,25 +156,21 @@ exec_clkcmp(struct nv50_disp *disp, int head, int id, u32 pclk, u32 *conf)
2142 + if (!outp)
2143 + return NULL;
2144 +
2145 ++ *conf = (ctrl & 0x00000f00) >> 8;
2146 + switch (outp->info.type) {
2147 + case DCB_OUTPUT_TMDS:
2148 +- *conf = (ctrl & 0x00000f00) >> 8;
2149 + if (*conf == 5)
2150 + *conf |= 0x0100;
2151 + break;
2152 + case DCB_OUTPUT_LVDS:
2153 +- *conf = disp->sor.lvdsconf;
2154 +- break;
2155 +- case DCB_OUTPUT_DP:
2156 +- *conf = (ctrl & 0x00000f00) >> 8;
2157 ++ *conf |= disp->sor.lvdsconf;
2158 + break;
2159 +- case DCB_OUTPUT_ANALOG:
2160 + default:
2161 +- *conf = 0x00ff;
2162 + break;
2163 + }
2164 +
2165 +- data = nvbios_ocfg_match(bios, data, *conf, &ver, &hdr, &cnt, &len, &info2);
2166 ++ data = nvbios_ocfg_match(bios, data, *conf & 0xff, *conf >> 8,
2167 ++ &ver, &hdr, &cnt, &len, &info2);
2168 + if (data && id < 0xff) {
2169 + data = nvbios_oclk_match(bios, info2.clkcmp[id], pclk);
2170 + if (data) {
2171 +diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gm107.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gm107.c
2172 +index b694414..f4b9cf8 100644
2173 +--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/gm107.c
2174 ++++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/gm107.c
2175 +@@ -36,7 +36,7 @@ gm107_disp = {
2176 + .outp.internal.crt = nv50_dac_output_new,
2177 + .outp.internal.tmds = nv50_sor_output_new,
2178 + .outp.internal.lvds = nv50_sor_output_new,
2179 +- .outp.internal.dp = gf119_sor_dp_new,
2180 ++ .outp.internal.dp = gm107_sor_dp_new,
2181 + .dac.nr = 3,
2182 + .dac.power = nv50_dac_power,
2183 + .dac.sense = nv50_dac_sense,
2184 +diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.c
2185 +index 4226d21..fcb1b0c 100644
2186 +--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.c
2187 ++++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.c
2188 +@@ -387,22 +387,17 @@ exec_clkcmp(struct nv50_disp *disp, int head, int id, u32 pclk, u32 *conf)
2189 + if (!outp)
2190 + return NULL;
2191 +
2192 ++ *conf = (ctrl & 0x00000f00) >> 8;
2193 + if (outp->info.location == 0) {
2194 + switch (outp->info.type) {
2195 + case DCB_OUTPUT_TMDS:
2196 +- *conf = (ctrl & 0x00000f00) >> 8;
2197 + if (*conf == 5)
2198 + *conf |= 0x0100;
2199 + break;
2200 + case DCB_OUTPUT_LVDS:
2201 +- *conf = disp->sor.lvdsconf;
2202 ++ *conf |= disp->sor.lvdsconf;
2203 + break;
2204 +- case DCB_OUTPUT_DP:
2205 +- *conf = (ctrl & 0x00000f00) >> 8;
2206 +- break;
2207 +- case DCB_OUTPUT_ANALOG:
2208 + default:
2209 +- *conf = 0x00ff;
2210 + break;
2211 + }
2212 + } else {
2213 +@@ -410,7 +405,8 @@ exec_clkcmp(struct nv50_disp *disp, int head, int id, u32 pclk, u32 *conf)
2214 + pclk = pclk / 2;
2215 + }
2216 +
2217 +- data = nvbios_ocfg_match(bios, data, *conf, &ver, &hdr, &cnt, &len, &info2);
2218 ++ data = nvbios_ocfg_match(bios, data, *conf & 0xff, *conf >> 8,
2219 ++ &ver, &hdr, &cnt, &len, &info2);
2220 + if (data && id < 0xff) {
2221 + data = nvbios_oclk_match(bios, info2.clkcmp[id], pclk);
2222 + if (data) {
2223 +diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/outpdp.h b/drivers/gpu/drm/nouveau/nvkm/engine/disp/outpdp.h
2224 +index e9067ba..4e983f6 100644
2225 +--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/outpdp.h
2226 ++++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/outpdp.h
2227 +@@ -62,7 +62,12 @@ int g94_sor_dp_lnk_pwr(struct nvkm_output_dp *, int);
2228 + int gf119_sor_dp_new(struct nvkm_disp *, int, struct dcb_output *,
2229 + struct nvkm_output **);
2230 + int gf119_sor_dp_lnk_ctl(struct nvkm_output_dp *, int, int, bool);
2231 ++int gf119_sor_dp_drv_ctl(struct nvkm_output_dp *, int, int, int, int);
2232 +
2233 +-int gm200_sor_dp_new(struct nvkm_disp *, int, struct dcb_output *,
2234 +- struct nvkm_output **);
2235 ++int gm107_sor_dp_new(struct nvkm_disp *, int, struct dcb_output *,
2236 ++ struct nvkm_output **);
2237 ++int gm107_sor_dp_pattern(struct nvkm_output_dp *, int);
2238 ++
2239 ++int gm200_sor_dp_new(struct nvkm_disp *, int, struct dcb_output *,
2240 ++ struct nvkm_output **);
2241 + #endif
2242 +diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/sorgf119.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/sorgf119.c
2243 +index b4b41b1..49bd5da 100644
2244 +--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/sorgf119.c
2245 ++++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/sorgf119.c
2246 +@@ -40,8 +40,8 @@ static int
2247 + gf119_sor_dp_pattern(struct nvkm_output_dp *outp, int pattern)
2248 + {
2249 + struct nvkm_device *device = outp->base.disp->engine.subdev.device;
2250 +- const u32 loff = gf119_sor_loff(outp);
2251 +- nvkm_mask(device, 0x61c110 + loff, 0x0f0f0f0f, 0x01010101 * pattern);
2252 ++ const u32 soff = gf119_sor_soff(outp);
2253 ++ nvkm_mask(device, 0x61c110 + soff, 0x0f0f0f0f, 0x01010101 * pattern);
2254 + return 0;
2255 + }
2256 +
2257 +@@ -64,7 +64,7 @@ gf119_sor_dp_lnk_ctl(struct nvkm_output_dp *outp, int nr, int bw, bool ef)
2258 + return 0;
2259 + }
2260 +
2261 +-static int
2262 ++int
2263 + gf119_sor_dp_drv_ctl(struct nvkm_output_dp *outp,
2264 + int ln, int vs, int pe, int pc)
2265 + {
2266 +diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/sorgm107.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/sorgm107.c
2267 +new file mode 100644
2268 +index 0000000..37790b2
2269 +--- /dev/null
2270 ++++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/sorgm107.c
2271 +@@ -0,0 +1,53 @@
2272 ++/*
2273 ++ * Copyright 2016 Red Hat Inc.
2274 ++ *
2275 ++ * Permission is hereby granted, free of charge, to any person obtaining a
2276 ++ * copy of this software and associated documentation files (the "Software"),
2277 ++ * to deal in the Software without restriction, including without limitation
2278 ++ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
2279 ++ * and/or sell copies of the Software, and to permit persons to whom the
2280 ++ * Software is furnished to do so, subject to the following conditions:
2281 ++ *
2282 ++ * The above copyright notice and this permission notice shall be included in
2283 ++ * all copies or substantial portions of the Software.
2284 ++ *
2285 ++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2286 ++ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2287 ++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
2288 ++ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
2289 ++ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
2290 ++ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
2291 ++ * OTHER DEALINGS IN THE SOFTWARE.
2292 ++ *
2293 ++ * Authors: Ben Skeggs <bskeggs@××××××.com>
2294 ++ */
2295 ++#include "nv50.h"
2296 ++#include "outpdp.h"
2297 ++
2298 ++int
2299 ++gm107_sor_dp_pattern(struct nvkm_output_dp *outp, int pattern)
2300 ++{
2301 ++ struct nvkm_device *device = outp->base.disp->engine.subdev.device;
2302 ++ const u32 soff = outp->base.or * 0x800;
2303 ++ const u32 data = 0x01010101 * pattern;
2304 ++ if (outp->base.info.sorconf.link & 1)
2305 ++ nvkm_mask(device, 0x61c110 + soff, 0x0f0f0f0f, data);
2306 ++ else
2307 ++ nvkm_mask(device, 0x61c12c + soff, 0x0f0f0f0f, data);
2308 ++ return 0;
2309 ++}
2310 ++
2311 ++static const struct nvkm_output_dp_func
2312 ++gm107_sor_dp_func = {
2313 ++ .pattern = gm107_sor_dp_pattern,
2314 ++ .lnk_pwr = g94_sor_dp_lnk_pwr,
2315 ++ .lnk_ctl = gf119_sor_dp_lnk_ctl,
2316 ++ .drv_ctl = gf119_sor_dp_drv_ctl,
2317 ++};
2318 ++
2319 ++int
2320 ++gm107_sor_dp_new(struct nvkm_disp *disp, int index,
2321 ++ struct dcb_output *dcbE, struct nvkm_output **poutp)
2322 ++{
2323 ++ return nvkm_output_dp_new_(&gm107_sor_dp_func, disp, index, dcbE, poutp);
2324 ++}
2325 +diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/disp/sorgm200.c b/drivers/gpu/drm/nouveau/nvkm/engine/disp/sorgm200.c
2326 +index 2cfbef9..c44fa7e 100644
2327 +--- a/drivers/gpu/drm/nouveau/nvkm/engine/disp/sorgm200.c
2328 ++++ b/drivers/gpu/drm/nouveau/nvkm/engine/disp/sorgm200.c
2329 +@@ -57,19 +57,6 @@ gm200_sor_dp_lane_map(struct nvkm_device *device, u8 lane)
2330 + }
2331 +
2332 + static int
2333 +-gm200_sor_dp_pattern(struct nvkm_output_dp *outp, int pattern)
2334 +-{
2335 +- struct nvkm_device *device = outp->base.disp->engine.subdev.device;
2336 +- const u32 soff = gm200_sor_soff(outp);
2337 +- const u32 data = 0x01010101 * pattern;
2338 +- if (outp->base.info.sorconf.link & 1)
2339 +- nvkm_mask(device, 0x61c110 + soff, 0x0f0f0f0f, data);
2340 +- else
2341 +- nvkm_mask(device, 0x61c12c + soff, 0x0f0f0f0f, data);
2342 +- return 0;
2343 +-}
2344 +-
2345 +-static int
2346 + gm200_sor_dp_lnk_pwr(struct nvkm_output_dp *outp, int nr)
2347 + {
2348 + struct nvkm_device *device = outp->base.disp->engine.subdev.device;
2349 +@@ -129,7 +116,7 @@ gm200_sor_dp_drv_ctl(struct nvkm_output_dp *outp,
2350 +
2351 + static const struct nvkm_output_dp_func
2352 + gm200_sor_dp_func = {
2353 +- .pattern = gm200_sor_dp_pattern,
2354 ++ .pattern = gm107_sor_dp_pattern,
2355 + .lnk_pwr = gm200_sor_dp_lnk_pwr,
2356 + .lnk_ctl = gf119_sor_dp_lnk_ctl,
2357 + .drv_ctl = gm200_sor_dp_drv_ctl,
2358 +diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.c b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.c
2359 +index b2de290..b0c7216 100644
2360 +--- a/drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.c
2361 ++++ b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.c
2362 +@@ -942,22 +942,41 @@ gf100_gr_trap_gpc_rop(struct gf100_gr *gr, int gpc)
2363 + }
2364 +
2365 + static const struct nvkm_enum gf100_mp_warp_error[] = {
2366 +- { 0x00, "NO_ERROR" },
2367 +- { 0x01, "STACK_MISMATCH" },
2368 ++ { 0x01, "STACK_ERROR" },
2369 ++ { 0x02, "API_STACK_ERROR" },
2370 ++ { 0x03, "RET_EMPTY_STACK_ERROR" },
2371 ++ { 0x04, "PC_WRAP" },
2372 + { 0x05, "MISALIGNED_PC" },
2373 +- { 0x08, "MISALIGNED_GPR" },
2374 +- { 0x09, "INVALID_OPCODE" },
2375 +- { 0x0d, "GPR_OUT_OF_BOUNDS" },
2376 +- { 0x0e, "MEM_OUT_OF_BOUNDS" },
2377 +- { 0x0f, "UNALIGNED_MEM_ACCESS" },
2378 ++ { 0x06, "PC_OVERFLOW" },
2379 ++ { 0x07, "MISALIGNED_IMMC_ADDR" },
2380 ++ { 0x08, "MISALIGNED_REG" },
2381 ++ { 0x09, "ILLEGAL_INSTR_ENCODING" },
2382 ++ { 0x0a, "ILLEGAL_SPH_INSTR_COMBO" },
2383 ++ { 0x0b, "ILLEGAL_INSTR_PARAM" },
2384 ++ { 0x0c, "INVALID_CONST_ADDR" },
2385 ++ { 0x0d, "OOR_REG" },
2386 ++ { 0x0e, "OOR_ADDR" },
2387 ++ { 0x0f, "MISALIGNED_ADDR" },
2388 + { 0x10, "INVALID_ADDR_SPACE" },
2389 +- { 0x11, "INVALID_PARAM" },
2390 ++ { 0x11, "ILLEGAL_INSTR_PARAM2" },
2391 ++ { 0x12, "INVALID_CONST_ADDR_LDC" },
2392 ++ { 0x13, "GEOMETRY_SM_ERROR" },
2393 ++ { 0x14, "DIVERGENT" },
2394 ++ { 0x15, "WARP_EXIT" },
2395 + {}
2396 + };
2397 +
2398 + static const struct nvkm_bitfield gf100_mp_global_error[] = {
2399 ++ { 0x00000001, "SM_TO_SM_FAULT" },
2400 ++ { 0x00000002, "L1_ERROR" },
2401 + { 0x00000004, "MULTIPLE_WARP_ERRORS" },
2402 +- { 0x00000008, "OUT_OF_STACK_SPACE" },
2403 ++ { 0x00000008, "PHYSICAL_STACK_OVERFLOW" },
2404 ++ { 0x00000010, "BPT_INT" },
2405 ++ { 0x00000020, "BPT_PAUSE" },
2406 ++ { 0x00000040, "SINGLE_STEP_COMPLETE" },
2407 ++ { 0x20000000, "ECC_SEC_ERROR" },
2408 ++ { 0x40000000, "ECC_DED_ERROR" },
2409 ++ { 0x80000000, "TIMEOUT" },
2410 + {}
2411 + };
2412 +
2413 +diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/disp.c b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/disp.c
2414 +index a5e9213..9efb1b4 100644
2415 +--- a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/disp.c
2416 ++++ b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/disp.c
2417 +@@ -141,7 +141,8 @@ nvbios_ocfg_parse(struct nvkm_bios *bios, u16 outp, u8 idx,
2418 + {
2419 + u16 data = nvbios_ocfg_entry(bios, outp, idx, ver, hdr, cnt, len);
2420 + if (data) {
2421 +- info->match = nvbios_rd16(bios, data + 0x00);
2422 ++ info->proto = nvbios_rd08(bios, data + 0x00);
2423 ++ info->flags = nvbios_rd16(bios, data + 0x01);
2424 + info->clkcmp[0] = nvbios_rd16(bios, data + 0x02);
2425 + info->clkcmp[1] = nvbios_rd16(bios, data + 0x04);
2426 + }
2427 +@@ -149,12 +150,13 @@ nvbios_ocfg_parse(struct nvkm_bios *bios, u16 outp, u8 idx,
2428 + }
2429 +
2430 + u16
2431 +-nvbios_ocfg_match(struct nvkm_bios *bios, u16 outp, u16 type,
2432 ++nvbios_ocfg_match(struct nvkm_bios *bios, u16 outp, u8 proto, u8 flags,
2433 + u8 *ver, u8 *hdr, u8 *cnt, u8 *len, struct nvbios_ocfg *info)
2434 + {
2435 + u16 data, idx = 0;
2436 + while ((data = nvbios_ocfg_parse(bios, outp, idx++, ver, hdr, cnt, len, info))) {
2437 +- if (info->match == type)
2438 ++ if ((info->proto == proto || info->proto == 0xff) &&
2439 ++ (info->flags == flags))
2440 + break;
2441 + }
2442 + return data;
2443 +diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/ltc/gm107.c b/drivers/gpu/drm/nouveau/nvkm/subdev/ltc/gm107.c
2444 +index e292f56..389fb13 100644
2445 +--- a/drivers/gpu/drm/nouveau/nvkm/subdev/ltc/gm107.c
2446 ++++ b/drivers/gpu/drm/nouveau/nvkm/subdev/ltc/gm107.c
2447 +@@ -69,11 +69,11 @@ gm107_ltc_zbc_clear_depth(struct nvkm_ltc *ltc, int i, const u32 depth)
2448 + }
2449 +
2450 + static void
2451 +-gm107_ltc_lts_isr(struct nvkm_ltc *ltc, int c, int s)
2452 ++gm107_ltc_intr_lts(struct nvkm_ltc *ltc, int c, int s)
2453 + {
2454 + struct nvkm_subdev *subdev = &ltc->subdev;
2455 + struct nvkm_device *device = subdev->device;
2456 +- u32 base = 0x140000 + (c * 0x2000) + (s * 0x200);
2457 ++ u32 base = 0x140400 + (c * 0x2000) + (s * 0x200);
2458 + u32 stat = nvkm_rd32(device, base + 0x00c);
2459 +
2460 + if (stat) {
2461 +@@ -92,7 +92,7 @@ gm107_ltc_intr(struct nvkm_ltc *ltc)
2462 + while (mask) {
2463 + u32 s, c = __ffs(mask);
2464 + for (s = 0; s < ltc->lts_nr; s++)
2465 +- gm107_ltc_lts_isr(ltc, c, s);
2466 ++ gm107_ltc_intr_lts(ltc, c, s);
2467 + mask &= ~(1 << c);
2468 + }
2469 + }
2470 +diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/ltc/gm200.c b/drivers/gpu/drm/nouveau/nvkm/subdev/ltc/gm200.c
2471 +index 2a29bfd..e18e0dc 100644
2472 +--- a/drivers/gpu/drm/nouveau/nvkm/subdev/ltc/gm200.c
2473 ++++ b/drivers/gpu/drm/nouveau/nvkm/subdev/ltc/gm200.c
2474 +@@ -46,7 +46,7 @@ static const struct nvkm_ltc_func
2475 + gm200_ltc = {
2476 + .oneinit = gm200_ltc_oneinit,
2477 + .init = gm200_ltc_init,
2478 +- .intr = gm107_ltc_intr, /*XXX: not validated */
2479 ++ .intr = gm107_ltc_intr,
2480 + .cbc_clear = gm107_ltc_cbc_clear,
2481 + .cbc_wait = gm107_ltc_cbc_wait,
2482 + .zbc = 16,
2483 +diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
2484 +index d0826fb..cb29868 100644
2485 +--- a/drivers/gpu/drm/radeon/radeon_device.c
2486 ++++ b/drivers/gpu/drm/radeon/radeon_device.c
2487 +@@ -630,6 +630,23 @@ void radeon_gtt_location(struct radeon_device *rdev, struct radeon_mc *mc)
2488 + /*
2489 + * GPU helpers function.
2490 + */
2491 ++
2492 ++/**
2493 ++ * radeon_device_is_virtual - check if we are running is a virtual environment
2494 ++ *
2495 ++ * Check if the asic has been passed through to a VM (all asics).
2496 ++ * Used at driver startup.
2497 ++ * Returns true if virtual or false if not.
2498 ++ */
2499 ++static bool radeon_device_is_virtual(void)
2500 ++{
2501 ++#ifdef CONFIG_X86
2502 ++ return boot_cpu_has(X86_FEATURE_HYPERVISOR);
2503 ++#else
2504 ++ return false;
2505 ++#endif
2506 ++}
2507 ++
2508 + /**
2509 + * radeon_card_posted - check if the hw has already been initialized
2510 + *
2511 +@@ -643,6 +660,10 @@ bool radeon_card_posted(struct radeon_device *rdev)
2512 + {
2513 + uint32_t reg;
2514 +
2515 ++ /* for pass through, always force asic_init */
2516 ++ if (radeon_device_is_virtual())
2517 ++ return false;
2518 ++
2519 + /* required for EFI mode on macbook2,1 which uses an r5xx asic */
2520 + if (efi_enabled(EFI_BOOT) &&
2521 + (rdev->pdev->subsystem_vendor == PCI_VENDOR_ID_APPLE) &&
2522 +diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
2523 +index e3daafa..3e7c9ac 100644
2524 +--- a/drivers/gpu/drm/ttm/ttm_bo.c
2525 ++++ b/drivers/gpu/drm/ttm/ttm_bo.c
2526 +@@ -1016,9 +1016,9 @@ out_unlock:
2527 + return ret;
2528 + }
2529 +
2530 +-static bool ttm_bo_mem_compat(struct ttm_placement *placement,
2531 +- struct ttm_mem_reg *mem,
2532 +- uint32_t *new_flags)
2533 ++bool ttm_bo_mem_compat(struct ttm_placement *placement,
2534 ++ struct ttm_mem_reg *mem,
2535 ++ uint32_t *new_flags)
2536 + {
2537 + int i;
2538 +
2539 +@@ -1050,6 +1050,7 @@ static bool ttm_bo_mem_compat(struct ttm_placement *placement,
2540 +
2541 + return false;
2542 + }
2543 ++EXPORT_SYMBOL(ttm_bo_mem_compat);
2544 +
2545 + int ttm_bo_validate(struct ttm_buffer_object *bo,
2546 + struct ttm_placement *placement,
2547 +diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c
2548 +index 299925a..eadc981 100644
2549 +--- a/drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c
2550 ++++ b/drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c
2551 +@@ -49,6 +49,7 @@ int vmw_dmabuf_pin_in_placement(struct vmw_private *dev_priv,
2552 + {
2553 + struct ttm_buffer_object *bo = &buf->base;
2554 + int ret;
2555 ++ uint32_t new_flags;
2556 +
2557 + ret = ttm_write_lock(&dev_priv->reservation_sem, interruptible);
2558 + if (unlikely(ret != 0))
2559 +@@ -60,7 +61,12 @@ int vmw_dmabuf_pin_in_placement(struct vmw_private *dev_priv,
2560 + if (unlikely(ret != 0))
2561 + goto err;
2562 +
2563 +- ret = ttm_bo_validate(bo, placement, interruptible, false);
2564 ++ if (buf->pin_count > 0)
2565 ++ ret = ttm_bo_mem_compat(placement, &bo->mem,
2566 ++ &new_flags) == true ? 0 : -EINVAL;
2567 ++ else
2568 ++ ret = ttm_bo_validate(bo, placement, interruptible, false);
2569 ++
2570 + if (!ret)
2571 + vmw_bo_pin_reserved(buf, true);
2572 +
2573 +@@ -91,6 +97,7 @@ int vmw_dmabuf_pin_in_vram_or_gmr(struct vmw_private *dev_priv,
2574 + {
2575 + struct ttm_buffer_object *bo = &buf->base;
2576 + int ret;
2577 ++ uint32_t new_flags;
2578 +
2579 + ret = ttm_write_lock(&dev_priv->reservation_sem, interruptible);
2580 + if (unlikely(ret != 0))
2581 +@@ -102,6 +109,12 @@ int vmw_dmabuf_pin_in_vram_or_gmr(struct vmw_private *dev_priv,
2582 + if (unlikely(ret != 0))
2583 + goto err;
2584 +
2585 ++ if (buf->pin_count > 0) {
2586 ++ ret = ttm_bo_mem_compat(&vmw_vram_gmr_placement, &bo->mem,
2587 ++ &new_flags) == true ? 0 : -EINVAL;
2588 ++ goto out_unreserve;
2589 ++ }
2590 ++
2591 + ret = ttm_bo_validate(bo, &vmw_vram_gmr_placement, interruptible,
2592 + false);
2593 + if (likely(ret == 0) || ret == -ERESTARTSYS)
2594 +@@ -161,6 +174,7 @@ int vmw_dmabuf_pin_in_start_of_vram(struct vmw_private *dev_priv,
2595 + struct ttm_placement placement;
2596 + struct ttm_place place;
2597 + int ret = 0;
2598 ++ uint32_t new_flags;
2599 +
2600 + place = vmw_vram_placement.placement[0];
2601 + place.lpfn = bo->num_pages;
2602 +@@ -185,10 +199,15 @@ int vmw_dmabuf_pin_in_start_of_vram(struct vmw_private *dev_priv,
2603 + */
2604 + if (bo->mem.mem_type == TTM_PL_VRAM &&
2605 + bo->mem.start < bo->num_pages &&
2606 +- bo->mem.start > 0)
2607 ++ bo->mem.start > 0 &&
2608 ++ buf->pin_count == 0)
2609 + (void) ttm_bo_validate(bo, &vmw_sys_placement, false, false);
2610 +
2611 +- ret = ttm_bo_validate(bo, &placement, interruptible, false);
2612 ++ if (buf->pin_count > 0)
2613 ++ ret = ttm_bo_mem_compat(&placement, &bo->mem,
2614 ++ &new_flags) == true ? 0 : -EINVAL;
2615 ++ else
2616 ++ ret = ttm_bo_validate(bo, &placement, interruptible, false);
2617 +
2618 + /* For some reason we didn't end up at the start of vram */
2619 + WARN_ON(ret == 0 && bo->offset != 0);
2620 +diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
2621 +index f2cf923..2a50546 100644
2622 +--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
2623 ++++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
2624 +@@ -227,6 +227,7 @@ static int vmw_force_iommu;
2625 + static int vmw_restrict_iommu;
2626 + static int vmw_force_coherent;
2627 + static int vmw_restrict_dma_mask;
2628 ++static int vmw_assume_16bpp;
2629 +
2630 + static int vmw_probe(struct pci_dev *, const struct pci_device_id *);
2631 + static void vmw_master_init(struct vmw_master *);
2632 +@@ -243,6 +244,8 @@ MODULE_PARM_DESC(force_coherent, "Force coherent TTM pages");
2633 + module_param_named(force_coherent, vmw_force_coherent, int, 0600);
2634 + MODULE_PARM_DESC(restrict_dma_mask, "Restrict DMA mask to 44 bits with IOMMU");
2635 + module_param_named(restrict_dma_mask, vmw_restrict_dma_mask, int, 0600);
2636 ++MODULE_PARM_DESC(assume_16bpp, "Assume 16-bpp when filtering modes");
2637 ++module_param_named(assume_16bpp, vmw_assume_16bpp, int, 0600);
2638 +
2639 +
2640 + static void vmw_print_capabilities(uint32_t capabilities)
2641 +@@ -653,6 +656,8 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
2642 + dev_priv->vram_start = pci_resource_start(dev->pdev, 1);
2643 + dev_priv->mmio_start = pci_resource_start(dev->pdev, 2);
2644 +
2645 ++ dev_priv->assume_16bpp = !!vmw_assume_16bpp;
2646 ++
2647 + dev_priv->enable_fb = enable_fbdev;
2648 +
2649 + vmw_write(dev_priv, SVGA_REG_ID, SVGA_ID_2);
2650 +@@ -699,6 +704,13 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
2651 + vmw_read(dev_priv,
2652 + SVGA_REG_SUGGESTED_GBOBJECT_MEM_SIZE_KB);
2653 +
2654 ++ /*
2655 ++ * Workaround for low memory 2D VMs to compensate for the
2656 ++ * allocation taken by fbdev
2657 ++ */
2658 ++ if (!(dev_priv->capabilities & SVGA_CAP_3D))
2659 ++ mem_size *= 2;
2660 ++
2661 + dev_priv->max_mob_pages = mem_size * 1024 / PAGE_SIZE;
2662 + dev_priv->prim_bb_mem =
2663 + vmw_read(dev_priv,
2664 +diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
2665 +index 6db358a..cab0c54 100644
2666 +--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
2667 ++++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
2668 +@@ -386,6 +386,7 @@ struct vmw_private {
2669 + spinlock_t hw_lock;
2670 + spinlock_t cap_lock;
2671 + bool has_dx;
2672 ++ bool assume_16bpp;
2673 +
2674 + /*
2675 + * VGA registers.
2676 +diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
2677 +index 679a4cb..d2d9395 100644
2678 +--- a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
2679 ++++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
2680 +@@ -517,28 +517,6 @@ static int vmw_fb_kms_framebuffer(struct fb_info *info)
2681 +
2682 + par->set_fb = &vfb->base;
2683 +
2684 +- if (!par->bo_ptr) {
2685 +- /*
2686 +- * Pin before mapping. Since we don't know in what placement
2687 +- * to pin, call into KMS to do it for us.
2688 +- */
2689 +- ret = vfb->pin(vfb);
2690 +- if (ret) {
2691 +- DRM_ERROR("Could not pin the fbdev framebuffer.\n");
2692 +- return ret;
2693 +- }
2694 +-
2695 +- ret = ttm_bo_kmap(&par->vmw_bo->base, 0,
2696 +- par->vmw_bo->base.num_pages, &par->map);
2697 +- if (ret) {
2698 +- vfb->unpin(vfb);
2699 +- DRM_ERROR("Could not map the fbdev framebuffer.\n");
2700 +- return ret;
2701 +- }
2702 +-
2703 +- par->bo_ptr = ttm_kmap_obj_virtual(&par->map, &par->bo_iowrite);
2704 +- }
2705 +-
2706 + return 0;
2707 + }
2708 +
2709 +@@ -601,6 +579,31 @@ static int vmw_fb_set_par(struct fb_info *info)
2710 + if (ret)
2711 + goto out_unlock;
2712 +
2713 ++ if (!par->bo_ptr) {
2714 ++ struct vmw_framebuffer *vfb = vmw_framebuffer_to_vfb(set.fb);
2715 ++
2716 ++ /*
2717 ++ * Pin before mapping. Since we don't know in what placement
2718 ++ * to pin, call into KMS to do it for us.
2719 ++ */
2720 ++ ret = vfb->pin(vfb);
2721 ++ if (ret) {
2722 ++ DRM_ERROR("Could not pin the fbdev framebuffer.\n");
2723 ++ goto out_unlock;
2724 ++ }
2725 ++
2726 ++ ret = ttm_bo_kmap(&par->vmw_bo->base, 0,
2727 ++ par->vmw_bo->base.num_pages, &par->map);
2728 ++ if (ret) {
2729 ++ vfb->unpin(vfb);
2730 ++ DRM_ERROR("Could not map the fbdev framebuffer.\n");
2731 ++ goto out_unlock;
2732 ++ }
2733 ++
2734 ++ par->bo_ptr = ttm_kmap_obj_virtual(&par->map, &par->bo_iowrite);
2735 ++ }
2736 ++
2737 ++
2738 + vmw_fb_dirty_mark(par, par->fb_x, par->fb_y,
2739 + par->set_fb->width, par->set_fb->height);
2740 +
2741 +diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
2742 +index b07543b..6ccd61d 100644
2743 +--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
2744 ++++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
2745 +@@ -1553,14 +1553,10 @@ int vmw_du_connector_fill_modes(struct drm_connector *connector,
2746 + DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC)
2747 + };
2748 + int i;
2749 +- u32 assumed_bpp = 2;
2750 ++ u32 assumed_bpp = 4;
2751 +
2752 +- /*
2753 +- * If using screen objects, then assume 32-bpp because that's what the
2754 +- * SVGA device is assuming
2755 +- */
2756 +- if (dev_priv->active_display_unit == vmw_du_screen_object)
2757 +- assumed_bpp = 4;
2758 ++ if (dev_priv->assume_16bpp)
2759 ++ assumed_bpp = 2;
2760 +
2761 + if (dev_priv->active_display_unit == vmw_du_screen_target) {
2762 + max_width = min(max_width, dev_priv->stdu_max_width);
2763 +diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
2764 +index 9ca818f..41932a7 100644
2765 +--- a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
2766 ++++ b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
2767 +@@ -399,8 +399,10 @@ static int vmw_stdu_bind_fb(struct vmw_private *dev_priv,
2768 +
2769 + WARN_ON_ONCE(!stdu->defined);
2770 +
2771 +- if (!vfb->dmabuf && new_fb->width == mode->hdisplay &&
2772 +- new_fb->height == mode->vdisplay)
2773 ++ new_vfbs = (vfb->dmabuf) ? NULL : vmw_framebuffer_to_vfbs(new_fb);
2774 ++
2775 ++ if (new_vfbs && new_vfbs->surface->base_size.width == mode->hdisplay &&
2776 ++ new_vfbs->surface->base_size.height == mode->vdisplay)
2777 + new_content_type = SAME_AS_DISPLAY;
2778 + else if (vfb->dmabuf)
2779 + new_content_type = SEPARATE_DMA;
2780 +@@ -444,7 +446,6 @@ static int vmw_stdu_bind_fb(struct vmw_private *dev_priv,
2781 + content_srf.mip_levels[0] = 1;
2782 + content_srf.multisample_count = 0;
2783 + } else {
2784 +- new_vfbs = vmw_framebuffer_to_vfbs(new_fb);
2785 + content_srf = *new_vfbs->surface;
2786 + }
2787 +
2788 +@@ -464,7 +465,6 @@ static int vmw_stdu_bind_fb(struct vmw_private *dev_priv,
2789 + return ret;
2790 + }
2791 + } else if (new_content_type == SAME_AS_DISPLAY) {
2792 +- new_vfbs = vmw_framebuffer_to_vfbs(new_fb);
2793 + new_display_srf = vmw_surface_reference(new_vfbs->surface);
2794 + }
2795 +
2796 +diff --git a/drivers/hid/hid-elo.c b/drivers/hid/hid-elo.c
2797 +index aad8c16..0cd4f72 100644
2798 +--- a/drivers/hid/hid-elo.c
2799 ++++ b/drivers/hid/hid-elo.c
2800 +@@ -261,7 +261,7 @@ static void elo_remove(struct hid_device *hdev)
2801 + struct elo_priv *priv = hid_get_drvdata(hdev);
2802 +
2803 + hid_hw_stop(hdev);
2804 +- flush_workqueue(wq);
2805 ++ cancel_delayed_work_sync(&priv->work);
2806 + kfree(priv);
2807 + }
2808 +
2809 +diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
2810 +index c741f5e..0088979 100644
2811 +--- a/drivers/hid/hid-multitouch.c
2812 ++++ b/drivers/hid/hid-multitouch.c
2813 +@@ -61,6 +61,7 @@ MODULE_LICENSE("GPL");
2814 + #define MT_QUIRK_ALWAYS_VALID (1 << 4)
2815 + #define MT_QUIRK_VALID_IS_INRANGE (1 << 5)
2816 + #define MT_QUIRK_VALID_IS_CONFIDENCE (1 << 6)
2817 ++#define MT_QUIRK_CONFIDENCE (1 << 7)
2818 + #define MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE (1 << 8)
2819 + #define MT_QUIRK_NO_AREA (1 << 9)
2820 + #define MT_QUIRK_IGNORE_DUPLICATES (1 << 10)
2821 +@@ -78,6 +79,7 @@ struct mt_slot {
2822 + __s32 contactid; /* the device ContactID assigned to this slot */
2823 + bool touch_state; /* is the touch valid? */
2824 + bool inrange_state; /* is the finger in proximity of the sensor? */
2825 ++ bool confidence_state; /* is the touch made by a finger? */
2826 + };
2827 +
2828 + struct mt_class {
2829 +@@ -503,10 +505,8 @@ static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi,
2830 + return 1;
2831 + case HID_DG_CONFIDENCE:
2832 + if (cls->name == MT_CLS_WIN_8 &&
2833 +- field->application == HID_DG_TOUCHPAD) {
2834 +- cls->quirks &= ~MT_QUIRK_ALWAYS_VALID;
2835 +- cls->quirks |= MT_QUIRK_VALID_IS_CONFIDENCE;
2836 +- }
2837 ++ field->application == HID_DG_TOUCHPAD)
2838 ++ cls->quirks |= MT_QUIRK_CONFIDENCE;
2839 + mt_store_field(usage, td, hi);
2840 + return 1;
2841 + case HID_DG_TIPSWITCH:
2842 +@@ -619,6 +619,7 @@ static void mt_complete_slot(struct mt_device *td, struct input_dev *input)
2843 + return;
2844 +
2845 + if (td->curvalid || (td->mtclass.quirks & MT_QUIRK_ALWAYS_VALID)) {
2846 ++ int active;
2847 + int slotnum = mt_compute_slot(td, input);
2848 + struct mt_slot *s = &td->curdata;
2849 + struct input_mt *mt = input->mt;
2850 +@@ -633,10 +634,14 @@ static void mt_complete_slot(struct mt_device *td, struct input_dev *input)
2851 + return;
2852 + }
2853 +
2854 ++ if (!(td->mtclass.quirks & MT_QUIRK_CONFIDENCE))
2855 ++ s->confidence_state = 1;
2856 ++ active = (s->touch_state || s->inrange_state) &&
2857 ++ s->confidence_state;
2858 ++
2859 + input_mt_slot(input, slotnum);
2860 +- input_mt_report_slot_state(input, MT_TOOL_FINGER,
2861 +- s->touch_state || s->inrange_state);
2862 +- if (s->touch_state || s->inrange_state) {
2863 ++ input_mt_report_slot_state(input, MT_TOOL_FINGER, active);
2864 ++ if (active) {
2865 + /* this finger is in proximity of the sensor */
2866 + int wide = (s->w > s->h);
2867 + /* divided by two to match visual scale of touch */
2868 +@@ -701,6 +706,8 @@ static void mt_process_mt_event(struct hid_device *hid, struct hid_field *field,
2869 + td->curdata.touch_state = value;
2870 + break;
2871 + case HID_DG_CONFIDENCE:
2872 ++ if (quirks & MT_QUIRK_CONFIDENCE)
2873 ++ td->curdata.confidence_state = value;
2874 + if (quirks & MT_QUIRK_VALID_IS_CONFIDENCE)
2875 + td->curvalid = value;
2876 + break;
2877 +diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
2878 +index 2f1ddca..700145b 100644
2879 +--- a/drivers/hid/usbhid/hiddev.c
2880 ++++ b/drivers/hid/usbhid/hiddev.c
2881 +@@ -516,13 +516,13 @@ static noinline int hiddev_ioctl_usage(struct hiddev *hiddev, unsigned int cmd,
2882 + goto inval;
2883 + } else if (uref->usage_index >= field->report_count)
2884 + goto inval;
2885 +-
2886 +- else if ((cmd == HIDIOCGUSAGES || cmd == HIDIOCSUSAGES) &&
2887 +- (uref_multi->num_values > HID_MAX_MULTI_USAGES ||
2888 +- uref->usage_index + uref_multi->num_values > field->report_count))
2889 +- goto inval;
2890 + }
2891 +
2892 ++ if ((cmd == HIDIOCGUSAGES || cmd == HIDIOCSUSAGES) &&
2893 ++ (uref_multi->num_values > HID_MAX_MULTI_USAGES ||
2894 ++ uref->usage_index + uref_multi->num_values > field->report_count))
2895 ++ goto inval;
2896 ++
2897 + switch (cmd) {
2898 + case HIDIOCGUSAGE:
2899 + uref->value = field->value[uref->usage_index];
2900 +diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c
2901 +index c43318d..a9356a3 100644
2902 +--- a/drivers/hwmon/dell-smm-hwmon.c
2903 ++++ b/drivers/hwmon/dell-smm-hwmon.c
2904 +@@ -66,11 +66,13 @@
2905 +
2906 + static DEFINE_MUTEX(i8k_mutex);
2907 + static char bios_version[4];
2908 ++static char bios_machineid[16];
2909 + static struct device *i8k_hwmon_dev;
2910 + static u32 i8k_hwmon_flags;
2911 + static uint i8k_fan_mult = I8K_FAN_MULT;
2912 + static uint i8k_pwm_mult;
2913 + static uint i8k_fan_max = I8K_FAN_HIGH;
2914 ++static bool disallow_fan_type_call;
2915 +
2916 + #define I8K_HWMON_HAVE_TEMP1 (1 << 0)
2917 + #define I8K_HWMON_HAVE_TEMP2 (1 << 1)
2918 +@@ -94,13 +96,13 @@ module_param(ignore_dmi, bool, 0);
2919 + MODULE_PARM_DESC(ignore_dmi, "Continue probing hardware even if DMI data does not match");
2920 +
2921 + #if IS_ENABLED(CONFIG_I8K)
2922 +-static bool restricted;
2923 ++static bool restricted = true;
2924 + module_param(restricted, bool, 0);
2925 +-MODULE_PARM_DESC(restricted, "Allow fan control if SYS_ADMIN capability set");
2926 ++MODULE_PARM_DESC(restricted, "Restrict fan control and serial number to CAP_SYS_ADMIN (default: 1)");
2927 +
2928 + static bool power_status;
2929 + module_param(power_status, bool, 0600);
2930 +-MODULE_PARM_DESC(power_status, "Report power status in /proc/i8k");
2931 ++MODULE_PARM_DESC(power_status, "Report power status in /proc/i8k (default: 0)");
2932 + #endif
2933 +
2934 + static uint fan_mult;
2935 +@@ -235,14 +237,28 @@ static int i8k_get_fan_speed(int fan)
2936 + /*
2937 + * Read the fan type.
2938 + */
2939 +-static int i8k_get_fan_type(int fan)
2940 ++static int _i8k_get_fan_type(int fan)
2941 + {
2942 + struct smm_regs regs = { .eax = I8K_SMM_GET_FAN_TYPE, };
2943 +
2944 ++ if (disallow_fan_type_call)
2945 ++ return -EINVAL;
2946 ++
2947 + regs.ebx = fan & 0xff;
2948 + return i8k_smm(&regs) ? : regs.eax & 0xff;
2949 + }
2950 +
2951 ++static int i8k_get_fan_type(int fan)
2952 ++{
2953 ++ /* I8K_SMM_GET_FAN_TYPE SMM call is expensive, so cache values */
2954 ++ static int types[2] = { INT_MIN, INT_MIN };
2955 ++
2956 ++ if (types[fan] == INT_MIN)
2957 ++ types[fan] = _i8k_get_fan_type(fan);
2958 ++
2959 ++ return types[fan];
2960 ++}
2961 ++
2962 + /*
2963 + * Read the fan nominal rpm for specific fan speed.
2964 + */
2965 +@@ -392,9 +408,11 @@ i8k_ioctl_unlocked(struct file *fp, unsigned int cmd, unsigned long arg)
2966 + break;
2967 +
2968 + case I8K_MACHINE_ID:
2969 +- memset(buff, 0, 16);
2970 +- strlcpy(buff, i8k_get_dmi_data(DMI_PRODUCT_SERIAL),
2971 +- sizeof(buff));
2972 ++ if (restricted && !capable(CAP_SYS_ADMIN))
2973 ++ return -EPERM;
2974 ++
2975 ++ memset(buff, 0, sizeof(buff));
2976 ++ strlcpy(buff, bios_machineid, sizeof(buff));
2977 + break;
2978 +
2979 + case I8K_FN_STATUS:
2980 +@@ -511,7 +529,7 @@ static int i8k_proc_show(struct seq_file *seq, void *offset)
2981 + seq_printf(seq, "%s %s %s %d %d %d %d %d %d %d\n",
2982 + I8K_PROC_FMT,
2983 + bios_version,
2984 +- i8k_get_dmi_data(DMI_PRODUCT_SERIAL),
2985 ++ (restricted && !capable(CAP_SYS_ADMIN)) ? "-1" : bios_machineid,
2986 + cpu_temp,
2987 + left_fan, right_fan, left_speed, right_speed,
2988 + ac_power, fn_key);
2989 +@@ -718,6 +736,9 @@ static struct attribute *i8k_attrs[] = {
2990 + static umode_t i8k_is_visible(struct kobject *kobj, struct attribute *attr,
2991 + int index)
2992 + {
2993 ++ if (disallow_fan_type_call &&
2994 ++ (index == 9 || index == 12))
2995 ++ return 0;
2996 + if (index >= 0 && index <= 1 &&
2997 + !(i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP1))
2998 + return 0;
2999 +@@ -767,13 +788,17 @@ static int __init i8k_init_hwmon(void)
3000 + if (err >= 0)
3001 + i8k_hwmon_flags |= I8K_HWMON_HAVE_TEMP4;
3002 +
3003 +- /* First fan attributes, if fan type is OK */
3004 +- err = i8k_get_fan_type(0);
3005 ++ /* First fan attributes, if fan status or type is OK */
3006 ++ err = i8k_get_fan_status(0);
3007 ++ if (err < 0)
3008 ++ err = i8k_get_fan_type(0);
3009 + if (err >= 0)
3010 + i8k_hwmon_flags |= I8K_HWMON_HAVE_FAN1;
3011 +
3012 +- /* Second fan attributes, if fan type is OK */
3013 +- err = i8k_get_fan_type(1);
3014 ++ /* Second fan attributes, if fan status or type is OK */
3015 ++ err = i8k_get_fan_status(1);
3016 ++ if (err < 0)
3017 ++ err = i8k_get_fan_type(1);
3018 + if (err >= 0)
3019 + i8k_hwmon_flags |= I8K_HWMON_HAVE_FAN2;
3020 +
3021 +@@ -929,12 +954,14 @@ static struct dmi_system_id i8k_dmi_table[] __initdata = {
3022 +
3023 + MODULE_DEVICE_TABLE(dmi, i8k_dmi_table);
3024 +
3025 +-static struct dmi_system_id i8k_blacklist_dmi_table[] __initdata = {
3026 ++/*
3027 ++ * On some machines once I8K_SMM_GET_FAN_TYPE is issued then CPU fan speed
3028 ++ * randomly going up and down due to bug in Dell SMM or BIOS. Here is blacklist
3029 ++ * of affected Dell machines for which we disallow I8K_SMM_GET_FAN_TYPE call.
3030 ++ * See bug: https://bugzilla.kernel.org/show_bug.cgi?id=100121
3031 ++ */
3032 ++static struct dmi_system_id i8k_blacklist_fan_type_dmi_table[] __initdata = {
3033 + {
3034 +- /*
3035 +- * CPU fan speed going up and down on Dell Studio XPS 8000
3036 +- * for unknown reasons.
3037 +- */
3038 + .ident = "Dell Studio XPS 8000",
3039 + .matches = {
3040 + DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
3041 +@@ -942,16 +969,19 @@ static struct dmi_system_id i8k_blacklist_dmi_table[] __initdata = {
3042 + },
3043 + },
3044 + {
3045 +- /*
3046 +- * CPU fan speed going up and down on Dell Studio XPS 8100
3047 +- * for unknown reasons.
3048 +- */
3049 + .ident = "Dell Studio XPS 8100",
3050 + .matches = {
3051 + DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
3052 + DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Studio XPS 8100"),
3053 + },
3054 + },
3055 ++ {
3056 ++ .ident = "Dell Inspiron 580",
3057 ++ .matches = {
3058 ++ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
3059 ++ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Inspiron 580 "),
3060 ++ },
3061 ++ },
3062 + { }
3063 + };
3064 +
3065 +@@ -966,8 +996,7 @@ static int __init i8k_probe(void)
3066 + /*
3067 + * Get DMI information
3068 + */
3069 +- if (!dmi_check_system(i8k_dmi_table) ||
3070 +- dmi_check_system(i8k_blacklist_dmi_table)) {
3071 ++ if (!dmi_check_system(i8k_dmi_table)) {
3072 + if (!ignore_dmi && !force)
3073 + return -ENODEV;
3074 +
3075 +@@ -978,8 +1007,13 @@ static int __init i8k_probe(void)
3076 + i8k_get_dmi_data(DMI_BIOS_VERSION));
3077 + }
3078 +
3079 ++ if (dmi_check_system(i8k_blacklist_fan_type_dmi_table))
3080 ++ disallow_fan_type_call = true;
3081 ++
3082 + strlcpy(bios_version, i8k_get_dmi_data(DMI_BIOS_VERSION),
3083 + sizeof(bios_version));
3084 ++ strlcpy(bios_machineid, i8k_get_dmi_data(DMI_PRODUCT_SERIAL),
3085 ++ sizeof(bios_machineid));
3086 +
3087 + /*
3088 + * Get SMM Dell signature
3089 +diff --git a/drivers/iio/accel/kxsd9.c b/drivers/iio/accel/kxsd9.c
3090 +index 923f565..3a9f106 100644
3091 +--- a/drivers/iio/accel/kxsd9.c
3092 ++++ b/drivers/iio/accel/kxsd9.c
3093 +@@ -81,7 +81,7 @@ static int kxsd9_write_scale(struct iio_dev *indio_dev, int micro)
3094 +
3095 + mutex_lock(&st->buf_lock);
3096 + ret = spi_w8r8(st->us, KXSD9_READ(KXSD9_REG_CTRL_C));
3097 +- if (ret)
3098 ++ if (ret < 0)
3099 + goto error_ret;
3100 + st->tx[0] = KXSD9_WRITE(KXSD9_REG_CTRL_C);
3101 + st->tx[1] = (ret & ~KXSD9_FS_MASK) | i;
3102 +@@ -163,7 +163,7 @@ static int kxsd9_read_raw(struct iio_dev *indio_dev,
3103 + break;
3104 + case IIO_CHAN_INFO_SCALE:
3105 + ret = spi_w8r8(st->us, KXSD9_READ(KXSD9_REG_CTRL_C));
3106 +- if (ret)
3107 ++ if (ret < 0)
3108 + goto error_ret;
3109 + *val2 = kxsd9_micro_scales[ret & KXSD9_FS_MASK];
3110 + ret = IIO_VAL_INT_PLUS_MICRO;
3111 +diff --git a/drivers/iio/adc/ad7266.c b/drivers/iio/adc/ad7266.c
3112 +index 21e19b6..2123f0a 100644
3113 +--- a/drivers/iio/adc/ad7266.c
3114 ++++ b/drivers/iio/adc/ad7266.c
3115 +@@ -396,8 +396,8 @@ static int ad7266_probe(struct spi_device *spi)
3116 +
3117 + st = iio_priv(indio_dev);
3118 +
3119 +- st->reg = devm_regulator_get(&spi->dev, "vref");
3120 +- if (!IS_ERR_OR_NULL(st->reg)) {
3121 ++ st->reg = devm_regulator_get_optional(&spi->dev, "vref");
3122 ++ if (!IS_ERR(st->reg)) {
3123 + ret = regulator_enable(st->reg);
3124 + if (ret)
3125 + return ret;
3126 +@@ -408,6 +408,9 @@ static int ad7266_probe(struct spi_device *spi)
3127 +
3128 + st->vref_mv = ret / 1000;
3129 + } else {
3130 ++ /* Any other error indicates that the regulator does exist */
3131 ++ if (PTR_ERR(st->reg) != -ENODEV)
3132 ++ return PTR_ERR(st->reg);
3133 + /* Use internal reference */
3134 + st->vref_mv = 2500;
3135 + }
3136 +diff --git a/drivers/iio/humidity/hdc100x.c b/drivers/iio/humidity/hdc100x.c
3137 +index fa47676..a03832a 100644
3138 +--- a/drivers/iio/humidity/hdc100x.c
3139 ++++ b/drivers/iio/humidity/hdc100x.c
3140 +@@ -55,7 +55,7 @@ static const struct {
3141 + },
3142 + { /* IIO_HUMIDITYRELATIVE channel */
3143 + .shift = 8,
3144 +- .mask = 2,
3145 ++ .mask = 3,
3146 + },
3147 + };
3148 +
3149 +@@ -164,14 +164,14 @@ static int hdc100x_get_measurement(struct hdc100x_data *data,
3150 + dev_err(&client->dev, "cannot read high byte measurement");
3151 + return ret;
3152 + }
3153 +- val = ret << 6;
3154 ++ val = ret << 8;
3155 +
3156 + ret = i2c_smbus_read_byte(client);
3157 + if (ret < 0) {
3158 + dev_err(&client->dev, "cannot read low byte measurement");
3159 + return ret;
3160 + }
3161 +- val |= ret >> 2;
3162 ++ val |= ret;
3163 +
3164 + return val;
3165 + }
3166 +@@ -211,18 +211,18 @@ static int hdc100x_read_raw(struct iio_dev *indio_dev,
3167 + return IIO_VAL_INT_PLUS_MICRO;
3168 + case IIO_CHAN_INFO_SCALE:
3169 + if (chan->type == IIO_TEMP) {
3170 +- *val = 165;
3171 +- *val2 = 65536 >> 2;
3172 ++ *val = 165000;
3173 ++ *val2 = 65536;
3174 + return IIO_VAL_FRACTIONAL;
3175 + } else {
3176 +- *val = 0;
3177 +- *val2 = 10000;
3178 +- return IIO_VAL_INT_PLUS_MICRO;
3179 ++ *val = 100;
3180 ++ *val2 = 65536;
3181 ++ return IIO_VAL_FRACTIONAL;
3182 + }
3183 + break;
3184 + case IIO_CHAN_INFO_OFFSET:
3185 +- *val = -3971;
3186 +- *val2 = 879096;
3187 ++ *val = -15887;
3188 ++ *val2 = 515151;
3189 + return IIO_VAL_INT_PLUS_MICRO;
3190 + default:
3191 + return -EINVAL;
3192 +diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c
3193 +index ae2806a..0c52dfe 100644
3194 +--- a/drivers/iio/industrialio-trigger.c
3195 ++++ b/drivers/iio/industrialio-trigger.c
3196 +@@ -210,22 +210,35 @@ static int iio_trigger_attach_poll_func(struct iio_trigger *trig,
3197 +
3198 + /* Prevent the module from being removed whilst attached to a trigger */
3199 + __module_get(pf->indio_dev->info->driver_module);
3200 ++
3201 ++ /* Get irq number */
3202 + pf->irq = iio_trigger_get_irq(trig);
3203 ++ if (pf->irq < 0)
3204 ++ goto out_put_module;
3205 ++
3206 ++ /* Request irq */
3207 + ret = request_threaded_irq(pf->irq, pf->h, pf->thread,
3208 + pf->type, pf->name,
3209 + pf);
3210 +- if (ret < 0) {
3211 +- module_put(pf->indio_dev->info->driver_module);
3212 +- return ret;
3213 +- }
3214 ++ if (ret < 0)
3215 ++ goto out_put_irq;
3216 +
3217 ++ /* Enable trigger in driver */
3218 + if (trig->ops && trig->ops->set_trigger_state && notinuse) {
3219 + ret = trig->ops->set_trigger_state(trig, true);
3220 + if (ret < 0)
3221 +- module_put(pf->indio_dev->info->driver_module);
3222 ++ goto out_free_irq;
3223 + }
3224 +
3225 + return ret;
3226 ++
3227 ++out_free_irq:
3228 ++ free_irq(pf->irq, pf);
3229 ++out_put_irq:
3230 ++ iio_trigger_put_irq(trig, pf->irq);
3231 ++out_put_module:
3232 ++ module_put(pf->indio_dev->info->driver_module);
3233 ++ return ret;
3234 + }
3235 +
3236 + static int iio_trigger_detach_poll_func(struct iio_trigger *trig,
3237 +diff --git a/drivers/iio/light/apds9960.c b/drivers/iio/light/apds9960.c
3238 +index a6af56a..6443aad 100644
3239 +--- a/drivers/iio/light/apds9960.c
3240 ++++ b/drivers/iio/light/apds9960.c
3241 +@@ -1006,6 +1006,7 @@ static int apds9960_probe(struct i2c_client *client,
3242 +
3243 + iio_device_attach_buffer(indio_dev, buffer);
3244 +
3245 ++ indio_dev->dev.parent = &client->dev;
3246 + indio_dev->info = &apds9960_info;
3247 + indio_dev->name = APDS9960_DRV_NAME;
3248 + indio_dev->channels = apds9960_channels;
3249 +diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c
3250 +index 172393a..d3ca320 100644
3251 +--- a/drivers/iio/pressure/st_pressure_core.c
3252 ++++ b/drivers/iio/pressure/st_pressure_core.c
3253 +@@ -28,15 +28,21 @@
3254 + #include <linux/iio/common/st_sensors.h>
3255 + #include "st_pressure.h"
3256 +
3257 ++#define MCELSIUS_PER_CELSIUS 1000
3258 ++
3259 ++/* Default pressure sensitivity */
3260 + #define ST_PRESS_LSB_PER_MBAR 4096UL
3261 + #define ST_PRESS_KPASCAL_NANO_SCALE (100000000UL / \
3262 + ST_PRESS_LSB_PER_MBAR)
3263 ++
3264 ++/* Default temperature sensitivity */
3265 + #define ST_PRESS_LSB_PER_CELSIUS 480UL
3266 +-#define ST_PRESS_CELSIUS_NANO_SCALE (1000000000UL / \
3267 +- ST_PRESS_LSB_PER_CELSIUS)
3268 ++#define ST_PRESS_MILLI_CELSIUS_OFFSET 42500UL
3269 ++
3270 + #define ST_PRESS_NUMBER_DATA_CHANNELS 1
3271 +
3272 + /* FULLSCALE */
3273 ++#define ST_PRESS_FS_AVL_1100MB 1100
3274 + #define ST_PRESS_FS_AVL_1260MB 1260
3275 +
3276 + #define ST_PRESS_1_OUT_XL_ADDR 0x28
3277 +@@ -54,9 +60,6 @@
3278 + #define ST_PRESS_LPS331AP_PW_MASK 0x80
3279 + #define ST_PRESS_LPS331AP_FS_ADDR 0x23
3280 + #define ST_PRESS_LPS331AP_FS_MASK 0x30
3281 +-#define ST_PRESS_LPS331AP_FS_AVL_1260_VAL 0x00
3282 +-#define ST_PRESS_LPS331AP_FS_AVL_1260_GAIN ST_PRESS_KPASCAL_NANO_SCALE
3283 +-#define ST_PRESS_LPS331AP_FS_AVL_TEMP_GAIN ST_PRESS_CELSIUS_NANO_SCALE
3284 + #define ST_PRESS_LPS331AP_BDU_ADDR 0x20
3285 + #define ST_PRESS_LPS331AP_BDU_MASK 0x04
3286 + #define ST_PRESS_LPS331AP_DRDY_IRQ_ADDR 0x22
3287 +@@ -65,9 +68,14 @@
3288 + #define ST_PRESS_LPS331AP_IHL_IRQ_ADDR 0x22
3289 + #define ST_PRESS_LPS331AP_IHL_IRQ_MASK 0x80
3290 + #define ST_PRESS_LPS331AP_MULTIREAD_BIT true
3291 +-#define ST_PRESS_LPS331AP_TEMP_OFFSET 42500
3292 +
3293 + /* CUSTOM VALUES FOR LPS001WP SENSOR */
3294 ++
3295 ++/* LPS001WP pressure resolution */
3296 ++#define ST_PRESS_LPS001WP_LSB_PER_MBAR 16UL
3297 ++/* LPS001WP temperature resolution */
3298 ++#define ST_PRESS_LPS001WP_LSB_PER_CELSIUS 64UL
3299 ++
3300 + #define ST_PRESS_LPS001WP_WAI_EXP 0xba
3301 + #define ST_PRESS_LPS001WP_ODR_ADDR 0x20
3302 + #define ST_PRESS_LPS001WP_ODR_MASK 0x30
3303 +@@ -76,6 +84,8 @@
3304 + #define ST_PRESS_LPS001WP_ODR_AVL_13HZ_VAL 0x03
3305 + #define ST_PRESS_LPS001WP_PW_ADDR 0x20
3306 + #define ST_PRESS_LPS001WP_PW_MASK 0x40
3307 ++#define ST_PRESS_LPS001WP_FS_AVL_PRESS_GAIN \
3308 ++ (100000000UL / ST_PRESS_LPS001WP_LSB_PER_MBAR)
3309 + #define ST_PRESS_LPS001WP_BDU_ADDR 0x20
3310 + #define ST_PRESS_LPS001WP_BDU_MASK 0x04
3311 + #define ST_PRESS_LPS001WP_MULTIREAD_BIT true
3312 +@@ -92,11 +102,6 @@
3313 + #define ST_PRESS_LPS25H_ODR_AVL_25HZ_VAL 0x04
3314 + #define ST_PRESS_LPS25H_PW_ADDR 0x20
3315 + #define ST_PRESS_LPS25H_PW_MASK 0x80
3316 +-#define ST_PRESS_LPS25H_FS_ADDR 0x00
3317 +-#define ST_PRESS_LPS25H_FS_MASK 0x00
3318 +-#define ST_PRESS_LPS25H_FS_AVL_1260_VAL 0x00
3319 +-#define ST_PRESS_LPS25H_FS_AVL_1260_GAIN ST_PRESS_KPASCAL_NANO_SCALE
3320 +-#define ST_PRESS_LPS25H_FS_AVL_TEMP_GAIN ST_PRESS_CELSIUS_NANO_SCALE
3321 + #define ST_PRESS_LPS25H_BDU_ADDR 0x20
3322 + #define ST_PRESS_LPS25H_BDU_MASK 0x04
3323 + #define ST_PRESS_LPS25H_DRDY_IRQ_ADDR 0x23
3324 +@@ -105,7 +110,6 @@
3325 + #define ST_PRESS_LPS25H_IHL_IRQ_ADDR 0x22
3326 + #define ST_PRESS_LPS25H_IHL_IRQ_MASK 0x80
3327 + #define ST_PRESS_LPS25H_MULTIREAD_BIT true
3328 +-#define ST_PRESS_LPS25H_TEMP_OFFSET 42500
3329 + #define ST_PRESS_LPS25H_OUT_XL_ADDR 0x28
3330 + #define ST_TEMP_LPS25H_OUT_L_ADDR 0x2b
3331 +
3332 +@@ -157,7 +161,9 @@ static const struct iio_chan_spec st_press_lps001wp_channels[] = {
3333 + .storagebits = 16,
3334 + .endianness = IIO_LE,
3335 + },
3336 +- .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
3337 ++ .info_mask_separate =
3338 ++ BIT(IIO_CHAN_INFO_RAW) |
3339 ++ BIT(IIO_CHAN_INFO_SCALE),
3340 + .modified = 0,
3341 + },
3342 + {
3343 +@@ -173,7 +179,7 @@ static const struct iio_chan_spec st_press_lps001wp_channels[] = {
3344 + },
3345 + .info_mask_separate =
3346 + BIT(IIO_CHAN_INFO_RAW) |
3347 +- BIT(IIO_CHAN_INFO_OFFSET),
3348 ++ BIT(IIO_CHAN_INFO_SCALE),
3349 + .modified = 0,
3350 + },
3351 + IIO_CHAN_SOFT_TIMESTAMP(1)
3352 +@@ -208,11 +214,14 @@ static const struct st_sensor_settings st_press_sensors_settings[] = {
3353 + .addr = ST_PRESS_LPS331AP_FS_ADDR,
3354 + .mask = ST_PRESS_LPS331AP_FS_MASK,
3355 + .fs_avl = {
3356 ++ /*
3357 ++ * Pressure and temperature sensitivity values
3358 ++ * as defined in table 3 of LPS331AP datasheet.
3359 ++ */
3360 + [0] = {
3361 + .num = ST_PRESS_FS_AVL_1260MB,
3362 +- .value = ST_PRESS_LPS331AP_FS_AVL_1260_VAL,
3363 +- .gain = ST_PRESS_LPS331AP_FS_AVL_1260_GAIN,
3364 +- .gain2 = ST_PRESS_LPS331AP_FS_AVL_TEMP_GAIN,
3365 ++ .gain = ST_PRESS_KPASCAL_NANO_SCALE,
3366 ++ .gain2 = ST_PRESS_LSB_PER_CELSIUS,
3367 + },
3368 + },
3369 + },
3370 +@@ -254,7 +263,17 @@ static const struct st_sensor_settings st_press_sensors_settings[] = {
3371 + .value_off = ST_SENSORS_DEFAULT_POWER_OFF_VALUE,
3372 + },
3373 + .fs = {
3374 +- .addr = 0,
3375 ++ .fs_avl = {
3376 ++ /*
3377 ++ * Pressure and temperature resolution values
3378 ++ * as defined in table 3 of LPS001WP datasheet.
3379 ++ */
3380 ++ [0] = {
3381 ++ .num = ST_PRESS_FS_AVL_1100MB,
3382 ++ .gain = ST_PRESS_LPS001WP_FS_AVL_PRESS_GAIN,
3383 ++ .gain2 = ST_PRESS_LPS001WP_LSB_PER_CELSIUS,
3384 ++ },
3385 ++ },
3386 + },
3387 + .bdu = {
3388 + .addr = ST_PRESS_LPS001WP_BDU_ADDR,
3389 +@@ -291,14 +310,15 @@ static const struct st_sensor_settings st_press_sensors_settings[] = {
3390 + .value_off = ST_SENSORS_DEFAULT_POWER_OFF_VALUE,
3391 + },
3392 + .fs = {
3393 +- .addr = ST_PRESS_LPS25H_FS_ADDR,
3394 +- .mask = ST_PRESS_LPS25H_FS_MASK,
3395 + .fs_avl = {
3396 ++ /*
3397 ++ * Pressure and temperature sensitivity values
3398 ++ * as defined in table 3 of LPS25H datasheet.
3399 ++ */
3400 + [0] = {
3401 + .num = ST_PRESS_FS_AVL_1260MB,
3402 +- .value = ST_PRESS_LPS25H_FS_AVL_1260_VAL,
3403 +- .gain = ST_PRESS_LPS25H_FS_AVL_1260_GAIN,
3404 +- .gain2 = ST_PRESS_LPS25H_FS_AVL_TEMP_GAIN,
3405 ++ .gain = ST_PRESS_KPASCAL_NANO_SCALE,
3406 ++ .gain2 = ST_PRESS_LSB_PER_CELSIUS,
3407 + },
3408 + },
3409 + },
3410 +@@ -354,26 +374,26 @@ static int st_press_read_raw(struct iio_dev *indio_dev,
3411 +
3412 + return IIO_VAL_INT;
3413 + case IIO_CHAN_INFO_SCALE:
3414 +- *val = 0;
3415 +-
3416 + switch (ch->type) {
3417 + case IIO_PRESSURE:
3418 ++ *val = 0;
3419 + *val2 = press_data->current_fullscale->gain;
3420 +- break;
3421 ++ return IIO_VAL_INT_PLUS_NANO;
3422 + case IIO_TEMP:
3423 ++ *val = MCELSIUS_PER_CELSIUS;
3424 + *val2 = press_data->current_fullscale->gain2;
3425 +- break;
3426 ++ return IIO_VAL_FRACTIONAL;
3427 + default:
3428 + err = -EINVAL;
3429 + goto read_error;
3430 + }
3431 +
3432 +- return IIO_VAL_INT_PLUS_NANO;
3433 + case IIO_CHAN_INFO_OFFSET:
3434 + switch (ch->type) {
3435 + case IIO_TEMP:
3436 +- *val = 425;
3437 +- *val2 = 10;
3438 ++ *val = ST_PRESS_MILLI_CELSIUS_OFFSET *
3439 ++ press_data->current_fullscale->gain2;
3440 ++ *val2 = MCELSIUS_PER_CELSIUS;
3441 + break;
3442 + default:
3443 + err = -EINVAL;
3444 +diff --git a/drivers/iio/proximity/as3935.c b/drivers/iio/proximity/as3935.c
3445 +index f4d29d5..e2f926c 100644
3446 +--- a/drivers/iio/proximity/as3935.c
3447 ++++ b/drivers/iio/proximity/as3935.c
3448 +@@ -64,6 +64,7 @@ struct as3935_state {
3449 + struct delayed_work work;
3450 +
3451 + u32 tune_cap;
3452 ++ u8 buffer[16]; /* 8-bit data + 56-bit padding + 64-bit timestamp */
3453 + u8 buf[2] ____cacheline_aligned;
3454 + };
3455 +
3456 +@@ -72,7 +73,8 @@ static const struct iio_chan_spec as3935_channels[] = {
3457 + .type = IIO_PROXIMITY,
3458 + .info_mask_separate =
3459 + BIT(IIO_CHAN_INFO_RAW) |
3460 +- BIT(IIO_CHAN_INFO_PROCESSED),
3461 ++ BIT(IIO_CHAN_INFO_PROCESSED) |
3462 ++ BIT(IIO_CHAN_INFO_SCALE),
3463 + .scan_index = 0,
3464 + .scan_type = {
3465 + .sign = 'u',
3466 +@@ -181,7 +183,12 @@ static int as3935_read_raw(struct iio_dev *indio_dev,
3467 + /* storm out of range */
3468 + if (*val == AS3935_DATA_MASK)
3469 + return -EINVAL;
3470 +- *val *= 1000;
3471 ++
3472 ++ if (m == IIO_CHAN_INFO_PROCESSED)
3473 ++ *val *= 1000;
3474 ++ break;
3475 ++ case IIO_CHAN_INFO_SCALE:
3476 ++ *val = 1000;
3477 + break;
3478 + default:
3479 + return -EINVAL;
3480 +@@ -206,10 +213,10 @@ static irqreturn_t as3935_trigger_handler(int irq, void *private)
3481 + ret = as3935_read(st, AS3935_DATA, &val);
3482 + if (ret)
3483 + goto err_read;
3484 +- val &= AS3935_DATA_MASK;
3485 +- val *= 1000;
3486 +
3487 +- iio_push_to_buffers_with_timestamp(indio_dev, &val, pf->timestamp);
3488 ++ st->buffer[0] = val & AS3935_DATA_MASK;
3489 ++ iio_push_to_buffers_with_timestamp(indio_dev, &st->buffer,
3490 ++ pf->timestamp);
3491 + err_read:
3492 + iio_trigger_notify_done(indio_dev->trig);
3493 +
3494 +diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
3495 +index 1d92e09..c995255 100644
3496 +--- a/drivers/infiniband/core/cm.c
3497 ++++ b/drivers/infiniband/core/cm.c
3498 +@@ -3452,14 +3452,14 @@ static int cm_establish(struct ib_cm_id *cm_id)
3499 + work->cm_event.event = IB_CM_USER_ESTABLISHED;
3500 +
3501 + /* Check if the device started its remove_one */
3502 +- spin_lock_irq(&cm.lock);
3503 ++ spin_lock_irqsave(&cm.lock, flags);
3504 + if (!cm_dev->going_down) {
3505 + queue_delayed_work(cm.wq, &work->work, 0);
3506 + } else {
3507 + kfree(work);
3508 + ret = -ENODEV;
3509 + }
3510 +- spin_unlock_irq(&cm.lock);
3511 ++ spin_unlock_irqrestore(&cm.lock, flags);
3512 +
3513 + out:
3514 + return ret;
3515 +diff --git a/drivers/infiniband/hw/mlx4/ah.c b/drivers/infiniband/hw/mlx4/ah.c
3516 +index 105246f..5fc6233 100644
3517 +--- a/drivers/infiniband/hw/mlx4/ah.c
3518 ++++ b/drivers/infiniband/hw/mlx4/ah.c
3519 +@@ -47,6 +47,7 @@ static struct ib_ah *create_ib_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr,
3520 +
3521 + ah->av.ib.port_pd = cpu_to_be32(to_mpd(pd)->pdn | (ah_attr->port_num << 24));
3522 + ah->av.ib.g_slid = ah_attr->src_path_bits;
3523 ++ ah->av.ib.sl_tclass_flowlabel = cpu_to_be32(ah_attr->sl << 28);
3524 + if (ah_attr->ah_flags & IB_AH_GRH) {
3525 + ah->av.ib.g_slid |= 0x80;
3526 + ah->av.ib.gid_index = ah_attr->grh.sgid_index;
3527 +@@ -64,7 +65,6 @@ static struct ib_ah *create_ib_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr,
3528 + !(1 << ah->av.ib.stat_rate & dev->caps.stat_rate_support))
3529 + --ah->av.ib.stat_rate;
3530 + }
3531 +- ah->av.ib.sl_tclass_flowlabel = cpu_to_be32(ah_attr->sl << 28);
3532 +
3533 + return &ah->ibah;
3534 + }
3535 +diff --git a/drivers/infiniband/sw/rdmavt/qp.c b/drivers/infiniband/sw/rdmavt/qp.c
3536 +index a9e3bcc..a0ecf08 100644
3537 +--- a/drivers/infiniband/sw/rdmavt/qp.c
3538 ++++ b/drivers/infiniband/sw/rdmavt/qp.c
3539 +@@ -683,8 +683,10 @@ struct ib_qp *rvt_create_qp(struct ib_pd *ibpd,
3540 + * initialization that is needed.
3541 + */
3542 + priv = rdi->driver_f.qp_priv_alloc(rdi, qp, gfp);
3543 +- if (!priv)
3544 ++ if (IS_ERR(priv)) {
3545 ++ ret = priv;
3546 + goto bail_qp;
3547 ++ }
3548 + qp->priv = priv;
3549 + qp->timeout_jiffies =
3550 + usecs_to_jiffies((4096UL * (1UL << qp->timeout)) /
3551 +diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
3552 +index bf4959f..94f1bf7 100644
3553 +--- a/drivers/iommu/amd_iommu_init.c
3554 ++++ b/drivers/iommu/amd_iommu_init.c
3555 +@@ -1363,13 +1363,23 @@ static int __init amd_iommu_init_pci(void)
3556 + break;
3557 + }
3558 +
3559 ++ /*
3560 ++ * Order is important here to make sure any unity map requirements are
3561 ++ * fulfilled. The unity mappings are created and written to the device
3562 ++ * table during the amd_iommu_init_api() call.
3563 ++ *
3564 ++ * After that we call init_device_table_dma() to make sure any
3565 ++ * uninitialized DTE will block DMA, and in the end we flush the caches
3566 ++ * of all IOMMUs to make sure the changes to the device table are
3567 ++ * active.
3568 ++ */
3569 ++ ret = amd_iommu_init_api();
3570 ++
3571 + init_device_table_dma();
3572 +
3573 + for_each_iommu(iommu)
3574 + iommu_flush_all_caches(iommu);
3575 +
3576 +- ret = amd_iommu_init_api();
3577 +-
3578 + if (!ret)
3579 + print_iommu_info();
3580 +
3581 +diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c
3582 +index 4ff73ff..3e20208 100644
3583 +--- a/drivers/iommu/arm-smmu-v3.c
3584 ++++ b/drivers/iommu/arm-smmu-v3.c
3585 +@@ -1942,6 +1942,7 @@ static struct iommu_ops arm_smmu_ops = {
3586 + .attach_dev = arm_smmu_attach_dev,
3587 + .map = arm_smmu_map,
3588 + .unmap = arm_smmu_unmap,
3589 ++ .map_sg = default_iommu_map_sg,
3590 + .iova_to_phys = arm_smmu_iova_to_phys,
3591 + .add_device = arm_smmu_add_device,
3592 + .remove_device = arm_smmu_remove_device,
3593 +diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
3594 +index e1852e8..ae364e0 100644
3595 +--- a/drivers/iommu/intel-iommu.c
3596 ++++ b/drivers/iommu/intel-iommu.c
3597 +@@ -3169,11 +3169,6 @@ static int __init init_dmars(void)
3598 + }
3599 + }
3600 +
3601 +- iommu_flush_write_buffer(iommu);
3602 +- iommu_set_root_entry(iommu);
3603 +- iommu->flush.flush_context(iommu, 0, 0, 0, DMA_CCMD_GLOBAL_INVL);
3604 +- iommu->flush.flush_iotlb(iommu, 0, 0, 0, DMA_TLB_GLOBAL_FLUSH);
3605 +-
3606 + if (!ecap_pass_through(iommu->ecap))
3607 + hw_pass_through = 0;
3608 + #ifdef CONFIG_INTEL_IOMMU_SVM
3609 +@@ -3182,6 +3177,18 @@ static int __init init_dmars(void)
3610 + #endif
3611 + }
3612 +
3613 ++ /*
3614 ++ * Now that qi is enabled on all iommus, set the root entry and flush
3615 ++ * caches. This is required on some Intel X58 chipsets, otherwise the
3616 ++ * flush_context function will loop forever and the boot hangs.
3617 ++ */
3618 ++ for_each_active_iommu(iommu, drhd) {
3619 ++ iommu_flush_write_buffer(iommu);
3620 ++ iommu_set_root_entry(iommu);
3621 ++ iommu->flush.flush_context(iommu, 0, 0, 0, DMA_CCMD_GLOBAL_INVL);
3622 ++ iommu->flush.flush_iotlb(iommu, 0, 0, 0, DMA_TLB_GLOBAL_FLUSH);
3623 ++ }
3624 ++
3625 + if (iommu_pass_through)
3626 + iommu_identity_mapping |= IDENTMAP_ALL;
3627 +
3628 +diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c
3629 +index 5710a06..0ea8d9a 100644
3630 +--- a/drivers/iommu/rockchip-iommu.c
3631 ++++ b/drivers/iommu/rockchip-iommu.c
3632 +@@ -815,7 +815,7 @@ static int rk_iommu_attach_device(struct iommu_domain *domain,
3633 + dte_addr = virt_to_phys(rk_domain->dt);
3634 + for (i = 0; i < iommu->num_mmu; i++) {
3635 + rk_iommu_write(iommu->bases[i], RK_MMU_DTE_ADDR, dte_addr);
3636 +- rk_iommu_command(iommu->bases[i], RK_MMU_CMD_ZAP_CACHE);
3637 ++ rk_iommu_base_command(iommu->bases[i], RK_MMU_CMD_ZAP_CACHE);
3638 + rk_iommu_write(iommu->bases[i], RK_MMU_INT_MASK, RK_MMU_IRQ_MASK);
3639 + }
3640 +
3641 +diff --git a/drivers/irqchip/irq-mips-gic.c b/drivers/irqchip/irq-mips-gic.c
3642 +index 4dffccf..40fb120 100644
3643 +--- a/drivers/irqchip/irq-mips-gic.c
3644 ++++ b/drivers/irqchip/irq-mips-gic.c
3645 +@@ -734,6 +734,12 @@ static int gic_irq_domain_alloc(struct irq_domain *d, unsigned int virq,
3646 + /* verify that it doesn't conflict with an IPI irq */
3647 + if (test_bit(spec->hwirq, ipi_resrv))
3648 + return -EBUSY;
3649 ++
3650 ++ hwirq = GIC_SHARED_TO_HWIRQ(spec->hwirq);
3651 ++
3652 ++ return irq_domain_set_hwirq_and_chip(d, virq, hwirq,
3653 ++ &gic_level_irq_controller,
3654 ++ NULL);
3655 + } else {
3656 + base_hwirq = find_first_bit(ipi_resrv, gic_shared_intrs);
3657 + if (base_hwirq == gic_shared_intrs) {
3658 +@@ -855,10 +861,14 @@ static int gic_dev_domain_alloc(struct irq_domain *d, unsigned int virq,
3659 + &gic_level_irq_controller,
3660 + NULL);
3661 + if (ret)
3662 +- return ret;
3663 ++ goto error;
3664 + }
3665 +
3666 + return 0;
3667 ++
3668 ++error:
3669 ++ irq_domain_free_irqs_parent(d, virq, nr_irqs);
3670 ++ return ret;
3671 + }
3672 +
3673 + void gic_dev_domain_free(struct irq_domain *d, unsigned int virq,
3674 +diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
3675 +index d7723ce..12690c1 100644
3676 +--- a/drivers/media/usb/uvc/uvc_v4l2.c
3677 ++++ b/drivers/media/usb/uvc/uvc_v4l2.c
3678 +@@ -1408,47 +1408,44 @@ static int uvc_v4l2_put_xu_query(const struct uvc_xu_control_query *kp,
3679 + static long uvc_v4l2_compat_ioctl32(struct file *file,
3680 + unsigned int cmd, unsigned long arg)
3681 + {
3682 ++ struct uvc_fh *handle = file->private_data;
3683 + union {
3684 + struct uvc_xu_control_mapping xmap;
3685 + struct uvc_xu_control_query xqry;
3686 + } karg;
3687 + void __user *up = compat_ptr(arg);
3688 +- mm_segment_t old_fs;
3689 + long ret;
3690 +
3691 + switch (cmd) {
3692 + case UVCIOC_CTRL_MAP32:
3693 +- cmd = UVCIOC_CTRL_MAP;
3694 + ret = uvc_v4l2_get_xu_mapping(&karg.xmap, up);
3695 ++ if (ret)
3696 ++ return ret;
3697 ++ ret = uvc_ioctl_ctrl_map(handle->chain, &karg.xmap);
3698 ++ if (ret)
3699 ++ return ret;
3700 ++ ret = uvc_v4l2_put_xu_mapping(&karg.xmap, up);
3701 ++ if (ret)
3702 ++ return ret;
3703 ++
3704 + break;
3705 +
3706 + case UVCIOC_CTRL_QUERY32:
3707 +- cmd = UVCIOC_CTRL_QUERY;
3708 + ret = uvc_v4l2_get_xu_query(&karg.xqry, up);
3709 ++ if (ret)
3710 ++ return ret;
3711 ++ ret = uvc_xu_ctrl_query(handle->chain, &karg.xqry);
3712 ++ if (ret)
3713 ++ return ret;
3714 ++ ret = uvc_v4l2_put_xu_query(&karg.xqry, up);
3715 ++ if (ret)
3716 ++ return ret;
3717 + break;
3718 +
3719 + default:
3720 + return -ENOIOCTLCMD;
3721 + }
3722 +
3723 +- old_fs = get_fs();
3724 +- set_fs(KERNEL_DS);
3725 +- ret = video_ioctl2(file, cmd, (unsigned long)&karg);
3726 +- set_fs(old_fs);
3727 +-
3728 +- if (ret < 0)
3729 +- return ret;
3730 +-
3731 +- switch (cmd) {
3732 +- case UVCIOC_CTRL_MAP:
3733 +- ret = uvc_v4l2_put_xu_mapping(&karg.xmap, up);
3734 +- break;
3735 +-
3736 +- case UVCIOC_CTRL_QUERY:
3737 +- ret = uvc_v4l2_put_xu_query(&karg.xqry, up);
3738 +- break;
3739 +- }
3740 +-
3741 + return ret;
3742 + }
3743 + #endif
3744 +diff --git a/drivers/memory/omap-gpmc.c b/drivers/memory/omap-gpmc.c
3745 +index 21825dd..859b4a1 100644
3746 +--- a/drivers/memory/omap-gpmc.c
3747 ++++ b/drivers/memory/omap-gpmc.c
3748 +@@ -394,7 +394,7 @@ static void gpmc_cs_bool_timings(int cs, const struct gpmc_bool_timings *p)
3749 + gpmc_cs_modify_reg(cs, GPMC_CS_CONFIG4,
3750 + GPMC_CONFIG4_OEEXTRADELAY, p->oe_extra_delay);
3751 + gpmc_cs_modify_reg(cs, GPMC_CS_CONFIG4,
3752 +- GPMC_CONFIG4_OEEXTRADELAY, p->we_extra_delay);
3753 ++ GPMC_CONFIG4_WEEXTRADELAY, p->we_extra_delay);
3754 + gpmc_cs_modify_reg(cs, GPMC_CS_CONFIG6,
3755 + GPMC_CONFIG6_CYCLE2CYCLESAMECSEN,
3756 + p->cycle2cyclesamecsen);
3757 +diff --git a/drivers/mtd/ubi/eba.c b/drivers/mtd/ubi/eba.c
3758 +index 96fddb0..4dd0391 100644
3759 +--- a/drivers/mtd/ubi/eba.c
3760 ++++ b/drivers/mtd/ubi/eba.c
3761 +@@ -575,6 +575,7 @@ static int recover_peb(struct ubi_device *ubi, int pnum, int vol_id, int lnum,
3762 + int err, idx = vol_id2idx(ubi, vol_id), new_pnum, data_size, tries = 0;
3763 + struct ubi_volume *vol = ubi->volumes[idx];
3764 + struct ubi_vid_hdr *vid_hdr;
3765 ++ uint32_t crc;
3766 +
3767 + vid_hdr = ubi_zalloc_vid_hdr(ubi, GFP_NOFS);
3768 + if (!vid_hdr)
3769 +@@ -599,14 +600,8 @@ retry:
3770 + goto out_put;
3771 + }
3772 +
3773 +- vid_hdr->sqnum = cpu_to_be64(ubi_next_sqnum(ubi));
3774 +- err = ubi_io_write_vid_hdr(ubi, new_pnum, vid_hdr);
3775 +- if (err) {
3776 +- up_read(&ubi->fm_eba_sem);
3777 +- goto write_error;
3778 +- }
3779 ++ ubi_assert(vid_hdr->vol_type == UBI_VID_DYNAMIC);
3780 +
3781 +- data_size = offset + len;
3782 + mutex_lock(&ubi->buf_mutex);
3783 + memset(ubi->peb_buf + offset, 0xFF, len);
3784 +
3785 +@@ -621,6 +616,19 @@ retry:
3786 +
3787 + memcpy(ubi->peb_buf + offset, buf, len);
3788 +
3789 ++ data_size = offset + len;
3790 ++ crc = crc32(UBI_CRC32_INIT, ubi->peb_buf, data_size);
3791 ++ vid_hdr->sqnum = cpu_to_be64(ubi_next_sqnum(ubi));
3792 ++ vid_hdr->copy_flag = 1;
3793 ++ vid_hdr->data_size = cpu_to_be32(data_size);
3794 ++ vid_hdr->data_crc = cpu_to_be32(crc);
3795 ++ err = ubi_io_write_vid_hdr(ubi, new_pnum, vid_hdr);
3796 ++ if (err) {
3797 ++ mutex_unlock(&ubi->buf_mutex);
3798 ++ up_read(&ubi->fm_eba_sem);
3799 ++ goto write_error;
3800 ++ }
3801 ++
3802 + err = ubi_io_write_data(ubi, ubi->peb_buf, new_pnum, 0, data_size);
3803 + if (err) {
3804 + mutex_unlock(&ubi->buf_mutex);
3805 +diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c
3806 +index 9fcb489..c70e515 100644
3807 +--- a/drivers/net/geneve.c
3808 ++++ b/drivers/net/geneve.c
3809 +@@ -1092,12 +1092,17 @@ static netdev_tx_t geneve_xmit(struct sk_buff *skb, struct net_device *dev)
3810 +
3811 + static int __geneve_change_mtu(struct net_device *dev, int new_mtu, bool strict)
3812 + {
3813 ++ struct geneve_dev *geneve = netdev_priv(dev);
3814 + /* The max_mtu calculation does not take account of GENEVE
3815 + * options, to avoid excluding potentially valid
3816 + * configurations.
3817 + */
3818 +- int max_mtu = IP_MAX_MTU - GENEVE_BASE_HLEN - sizeof(struct iphdr)
3819 +- - dev->hard_header_len;
3820 ++ int max_mtu = IP_MAX_MTU - GENEVE_BASE_HLEN - dev->hard_header_len;
3821 ++
3822 ++ if (geneve->remote.sa.sa_family == AF_INET6)
3823 ++ max_mtu -= sizeof(struct ipv6hdr);
3824 ++ else
3825 ++ max_mtu -= sizeof(struct iphdr);
3826 +
3827 + if (new_mtu < 68)
3828 + return -EINVAL;
3829 +diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
3830 +index 9e803bb..8f3c55d 100644
3831 +--- a/drivers/net/macsec.c
3832 ++++ b/drivers/net/macsec.c
3833 +@@ -2564,6 +2564,7 @@ static netdev_tx_t macsec_start_xmit(struct sk_buff *skb,
3834 + u64_stats_update_begin(&secy_stats->syncp);
3835 + secy_stats->stats.OutPktsUntagged++;
3836 + u64_stats_update_end(&secy_stats->syncp);
3837 ++ skb->dev = macsec->real_dev;
3838 + len = skb->len;
3839 + ret = dev_queue_xmit(skb);
3840 + count_tx(dev, ret, len);
3841 +diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
3842 +index 2fb31ed..d4425c56 100644
3843 +--- a/drivers/net/usb/cdc_ncm.c
3844 ++++ b/drivers/net/usb/cdc_ncm.c
3845 +@@ -852,6 +852,13 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_
3846 + if (cdc_ncm_init(dev))
3847 + goto error2;
3848 +
3849 ++ /* Some firmwares need a pause here or they will silently fail
3850 ++ * to set up the interface properly. This value was decided
3851 ++ * empirically on a Sierra Wireless MC7455 running 02.08.02.00
3852 ++ * firmware.
3853 ++ */
3854 ++ usleep_range(10000, 20000);
3855 ++
3856 + /* configure data interface */
3857 + temp = usb_set_interface(dev->udev, iface_no, data_altsetting);
3858 + if (temp) {
3859 +diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
3860 +index e85e073..06664ba 100644
3861 +--- a/drivers/net/wireless/mac80211_hwsim.c
3862 ++++ b/drivers/net/wireless/mac80211_hwsim.c
3863 +@@ -2771,6 +2771,7 @@ static int hwsim_tx_info_frame_received_nl(struct sk_buff *skb_2,
3864 + if (!info->attrs[HWSIM_ATTR_ADDR_TRANSMITTER] ||
3865 + !info->attrs[HWSIM_ATTR_FLAGS] ||
3866 + !info->attrs[HWSIM_ATTR_COOKIE] ||
3867 ++ !info->attrs[HWSIM_ATTR_SIGNAL] ||
3868 + !info->attrs[HWSIM_ATTR_TX_INFO])
3869 + goto out;
3870 +
3871 +diff --git a/drivers/net/wireless/realtek/rtlwifi/core.c b/drivers/net/wireless/realtek/rtlwifi/core.c
3872 +index 0f48048..3a0faa8 100644
3873 +--- a/drivers/net/wireless/realtek/rtlwifi/core.c
3874 ++++ b/drivers/net/wireless/realtek/rtlwifi/core.c
3875 +@@ -54,7 +54,7 @@ EXPORT_SYMBOL(channel5g_80m);
3876 + void rtl_addr_delay(u32 addr)
3877 + {
3878 + if (addr == 0xfe)
3879 +- msleep(50);
3880 ++ mdelay(50);
3881 + else if (addr == 0xfd)
3882 + msleep(5);
3883 + else if (addr == 0xfc)
3884 +@@ -75,7 +75,7 @@ void rtl_rfreg_delay(struct ieee80211_hw *hw, enum radio_path rfpath, u32 addr,
3885 + rtl_addr_delay(addr);
3886 + } else {
3887 + rtl_set_rfreg(hw, rfpath, addr, mask, data);
3888 +- usleep_range(1, 2);
3889 ++ udelay(1);
3890 + }
3891 + }
3892 + EXPORT_SYMBOL(rtl_rfreg_delay);
3893 +@@ -86,7 +86,7 @@ void rtl_bb_delay(struct ieee80211_hw *hw, u32 addr, u32 data)
3894 + rtl_addr_delay(addr);
3895 + } else {
3896 + rtl_set_bbreg(hw, addr, MASKDWORD, data);
3897 +- usleep_range(1, 2);
3898 ++ udelay(1);
3899 + }
3900 + }
3901 + EXPORT_SYMBOL(rtl_bb_delay);
3902 +diff --git a/drivers/of/irq.c b/drivers/of/irq.c
3903 +index e7bfc17..6ec743f 100644
3904 +--- a/drivers/of/irq.c
3905 ++++ b/drivers/of/irq.c
3906 +@@ -386,13 +386,13 @@ int of_irq_to_resource(struct device_node *dev, int index, struct resource *r)
3907 + EXPORT_SYMBOL_GPL(of_irq_to_resource);
3908 +
3909 + /**
3910 +- * of_irq_get - Decode a node's IRQ and return it as a Linux irq number
3911 ++ * of_irq_get - Decode a node's IRQ and return it as a Linux IRQ number
3912 + * @dev: pointer to device tree node
3913 +- * @index: zero-based index of the irq
3914 +- *
3915 +- * Returns Linux irq number on success, or -EPROBE_DEFER if the irq domain
3916 +- * is not yet created.
3917 ++ * @index: zero-based index of the IRQ
3918 + *
3919 ++ * Returns Linux IRQ number on success, or 0 on the IRQ mapping failure, or
3920 ++ * -EPROBE_DEFER if the IRQ domain is not yet created, or error code in case
3921 ++ * of any other failure.
3922 + */
3923 + int of_irq_get(struct device_node *dev, int index)
3924 + {
3925 +@@ -413,12 +413,13 @@ int of_irq_get(struct device_node *dev, int index)
3926 + EXPORT_SYMBOL_GPL(of_irq_get);
3927 +
3928 + /**
3929 +- * of_irq_get_byname - Decode a node's IRQ and return it as a Linux irq number
3930 ++ * of_irq_get_byname - Decode a node's IRQ and return it as a Linux IRQ number
3931 + * @dev: pointer to device tree node
3932 +- * @name: irq name
3933 ++ * @name: IRQ name
3934 + *
3935 +- * Returns Linux irq number on success, or -EPROBE_DEFER if the irq domain
3936 +- * is not yet created, or error code in case of any other failure.
3937 ++ * Returns Linux IRQ number on success, or 0 on the IRQ mapping failure, or
3938 ++ * -EPROBE_DEFER if the IRQ domain is not yet created, or error code in case
3939 ++ * of any other failure.
3940 + */
3941 + int of_irq_get_byname(struct device_node *dev, const char *name)
3942 + {
3943 +diff --git a/drivers/pci/vc.c b/drivers/pci/vc.c
3944 +index dfbab61..1fa3a32 100644
3945 +--- a/drivers/pci/vc.c
3946 ++++ b/drivers/pci/vc.c
3947 +@@ -221,9 +221,9 @@ static int pci_vc_do_save_buffer(struct pci_dev *dev, int pos,
3948 + else
3949 + pci_write_config_word(dev, pos + PCI_VC_PORT_CTRL,
3950 + *(u16 *)buf);
3951 +- buf += 2;
3952 ++ buf += 4;
3953 + }
3954 +- len += 2;
3955 ++ len += 4;
3956 +
3957 + /*
3958 + * If we have any Low Priority VCs and a VC Arbitration Table Offset
3959 +diff --git a/drivers/regulator/qcom_smd-regulator.c b/drivers/regulator/qcom_smd-regulator.c
3960 +index 56a17ec..6c7fe477 100644
3961 +--- a/drivers/regulator/qcom_smd-regulator.c
3962 ++++ b/drivers/regulator/qcom_smd-regulator.c
3963 +@@ -140,6 +140,18 @@ static const struct regulator_ops rpm_smps_ldo_ops = {
3964 + .enable = rpm_reg_enable,
3965 + .disable = rpm_reg_disable,
3966 + .is_enabled = rpm_reg_is_enabled,
3967 ++ .list_voltage = regulator_list_voltage_linear_range,
3968 ++
3969 ++ .get_voltage = rpm_reg_get_voltage,
3970 ++ .set_voltage = rpm_reg_set_voltage,
3971 ++
3972 ++ .set_load = rpm_reg_set_load,
3973 ++};
3974 ++
3975 ++static const struct regulator_ops rpm_smps_ldo_ops_fixed = {
3976 ++ .enable = rpm_reg_enable,
3977 ++ .disable = rpm_reg_disable,
3978 ++ .is_enabled = rpm_reg_is_enabled,
3979 +
3980 + .get_voltage = rpm_reg_get_voltage,
3981 + .set_voltage = rpm_reg_set_voltage,
3982 +@@ -247,7 +259,7 @@ static const struct regulator_desc pm8941_nldo = {
3983 + static const struct regulator_desc pm8941_lnldo = {
3984 + .fixed_uV = 1740000,
3985 + .n_voltages = 1,
3986 +- .ops = &rpm_smps_ldo_ops,
3987 ++ .ops = &rpm_smps_ldo_ops_fixed,
3988 + };
3989 +
3990 + static const struct regulator_desc pm8941_switch = {
3991 +diff --git a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c
3992 +index d4c2856..3ddc85e 100644
3993 +--- a/drivers/scsi/53c700.c
3994 ++++ b/drivers/scsi/53c700.c
3995 +@@ -1122,7 +1122,7 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp,
3996 + } else {
3997 + struct scsi_cmnd *SCp;
3998 +
3999 +- SCp = scsi_host_find_tag(SDp->host, SCSI_NO_TAG);
4000 ++ SCp = SDp->current_cmnd;
4001 + if(unlikely(SCp == NULL)) {
4002 + sdev_printk(KERN_ERR, SDp,
4003 + "no saved request for untagged cmd\n");
4004 +@@ -1826,7 +1826,7 @@ NCR_700_queuecommand_lck(struct scsi_cmnd *SCp, void (*done)(struct scsi_cmnd *)
4005 + slot->tag, slot);
4006 + } else {
4007 + slot->tag = SCSI_NO_TAG;
4008 +- /* must populate current_cmnd for scsi_host_find_tag to work */
4009 ++ /* save current command for reselection */
4010 + SCp->device->current_cmnd = SCp;
4011 + }
4012 + /* sanity check: some of the commands generated by the mid-layer
4013 +diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
4014 +index 984ddcb..1b9c049 100644
4015 +--- a/drivers/scsi/scsi_error.c
4016 ++++ b/drivers/scsi/scsi_error.c
4017 +@@ -1127,7 +1127,6 @@ static int scsi_eh_action(struct scsi_cmnd *scmd, int rtn)
4018 + */
4019 + void scsi_eh_finish_cmd(struct scsi_cmnd *scmd, struct list_head *done_q)
4020 + {
4021 +- scmd->device->host->host_failed--;
4022 + scmd->eh_eflags = 0;
4023 + list_move_tail(&scmd->eh_entry, done_q);
4024 + }
4025 +@@ -2226,6 +2225,9 @@ int scsi_error_handler(void *data)
4026 + else
4027 + scsi_unjam_host(shost);
4028 +
4029 ++ /* All scmds have been handled */
4030 ++ shost->host_failed = 0;
4031 ++
4032 + /*
4033 + * Note - if the above fails completely, the action is to take
4034 + * individual devices offline and flush the queue of any
4035 +diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
4036 +index f52b74c..41c3a2c 100644
4037 +--- a/drivers/scsi/sd.c
4038 ++++ b/drivers/scsi/sd.c
4039 +@@ -2862,10 +2862,10 @@ static int sd_revalidate_disk(struct gendisk *disk)
4040 + if (sdkp->opt_xfer_blocks &&
4041 + sdkp->opt_xfer_blocks <= dev_max &&
4042 + sdkp->opt_xfer_blocks <= SD_DEF_XFER_BLOCKS &&
4043 +- sdkp->opt_xfer_blocks * sdp->sector_size >= PAGE_SIZE)
4044 +- rw_max = q->limits.io_opt =
4045 +- sdkp->opt_xfer_blocks * sdp->sector_size;
4046 +- else
4047 ++ logical_to_bytes(sdp, sdkp->opt_xfer_blocks) >= PAGE_SIZE) {
4048 ++ q->limits.io_opt = logical_to_bytes(sdp, sdkp->opt_xfer_blocks);
4049 ++ rw_max = logical_to_sectors(sdp, sdkp->opt_xfer_blocks);
4050 ++ } else
4051 + rw_max = BLK_DEF_MAX_SECTORS;
4052 +
4053 + /* Combine with controller limits */
4054 +diff --git a/drivers/scsi/sd.h b/drivers/scsi/sd.h
4055 +index 654630b..765a6f1 100644
4056 +--- a/drivers/scsi/sd.h
4057 ++++ b/drivers/scsi/sd.h
4058 +@@ -151,6 +151,11 @@ static inline sector_t logical_to_sectors(struct scsi_device *sdev, sector_t blo
4059 + return blocks << (ilog2(sdev->sector_size) - 9);
4060 + }
4061 +
4062 ++static inline unsigned int logical_to_bytes(struct scsi_device *sdev, sector_t blocks)
4063 ++{
4064 ++ return blocks * sdev->sector_size;
4065 ++}
4066 ++
4067 + /*
4068 + * A DIF-capable target device can be formatted with different
4069 + * protection schemes. Currently 0 through 3 are defined:
4070 +diff --git a/drivers/staging/iio/accel/sca3000_core.c b/drivers/staging/iio/accel/sca3000_core.c
4071 +index a8f533a..ec12181 100644
4072 +--- a/drivers/staging/iio/accel/sca3000_core.c
4073 ++++ b/drivers/staging/iio/accel/sca3000_core.c
4074 +@@ -594,7 +594,7 @@ static ssize_t sca3000_read_frequency(struct device *dev,
4075 + goto error_ret_mut;
4076 + ret = sca3000_read_ctrl_reg(st, SCA3000_REG_CTRL_SEL_OUT_CTRL);
4077 + mutex_unlock(&st->lock);
4078 +- if (ret)
4079 ++ if (ret < 0)
4080 + goto error_ret;
4081 + val = ret;
4082 + if (base_freq > 0)
4083 +diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
4084 +index 6ceac4f..5b4b47e 100644
4085 +--- a/drivers/thermal/cpu_cooling.c
4086 ++++ b/drivers/thermal/cpu_cooling.c
4087 +@@ -857,14 +857,6 @@ __cpufreq_cooling_register(struct device_node *np,
4088 + goto free_power_table;
4089 + }
4090 +
4091 +- snprintf(dev_name, sizeof(dev_name), "thermal-cpufreq-%d",
4092 +- cpufreq_dev->id);
4093 +-
4094 +- cool_dev = thermal_of_cooling_device_register(np, dev_name, cpufreq_dev,
4095 +- &cpufreq_cooling_ops);
4096 +- if (IS_ERR(cool_dev))
4097 +- goto remove_idr;
4098 +-
4099 + /* Fill freq-table in descending order of frequencies */
4100 + for (i = 0, freq = -1; i <= cpufreq_dev->max_level; i++) {
4101 + freq = find_next_max(table, freq);
4102 +@@ -877,6 +869,14 @@ __cpufreq_cooling_register(struct device_node *np,
4103 + pr_debug("%s: freq:%u KHz\n", __func__, freq);
4104 + }
4105 +
4106 ++ snprintf(dev_name, sizeof(dev_name), "thermal-cpufreq-%d",
4107 ++ cpufreq_dev->id);
4108 ++
4109 ++ cool_dev = thermal_of_cooling_device_register(np, dev_name, cpufreq_dev,
4110 ++ &cpufreq_cooling_ops);
4111 ++ if (IS_ERR(cool_dev))
4112 ++ goto remove_idr;
4113 ++
4114 + cpufreq_dev->clipped_freq = cpufreq_dev->freq_table[0];
4115 + cpufreq_dev->cool_dev = cool_dev;
4116 +
4117 +diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
4118 +index f973bfc..1e93a37 100644
4119 +--- a/drivers/tty/vt/keyboard.c
4120 ++++ b/drivers/tty/vt/keyboard.c
4121 +@@ -366,34 +366,22 @@ static void to_utf8(struct vc_data *vc, uint c)
4122 +
4123 + static void do_compute_shiftstate(void)
4124 + {
4125 +- unsigned int i, j, k, sym, val;
4126 ++ unsigned int k, sym, val;
4127 +
4128 + shift_state = 0;
4129 + memset(shift_down, 0, sizeof(shift_down));
4130 +
4131 +- for (i = 0; i < ARRAY_SIZE(key_down); i++) {
4132 +-
4133 +- if (!key_down[i])
4134 ++ for_each_set_bit(k, key_down, min(NR_KEYS, KEY_CNT)) {
4135 ++ sym = U(key_maps[0][k]);
4136 ++ if (KTYP(sym) != KT_SHIFT && KTYP(sym) != KT_SLOCK)
4137 + continue;
4138 +
4139 +- k = i * BITS_PER_LONG;
4140 +-
4141 +- for (j = 0; j < BITS_PER_LONG; j++, k++) {
4142 +-
4143 +- if (!test_bit(k, key_down))
4144 +- continue;
4145 ++ val = KVAL(sym);
4146 ++ if (val == KVAL(K_CAPSSHIFT))
4147 ++ val = KVAL(K_SHIFT);
4148 +
4149 +- sym = U(key_maps[0][k]);
4150 +- if (KTYP(sym) != KT_SHIFT && KTYP(sym) != KT_SLOCK)
4151 +- continue;
4152 +-
4153 +- val = KVAL(sym);
4154 +- if (val == KVAL(K_CAPSSHIFT))
4155 +- val = KVAL(K_SHIFT);
4156 +-
4157 +- shift_down[val]++;
4158 +- shift_state |= (1 << val);
4159 +- }
4160 ++ shift_down[val]++;
4161 ++ shift_state |= BIT(val);
4162 + }
4163 + }
4164 +
4165 +diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
4166 +index bd523ad..e9e29de 100644
4167 +--- a/drivers/tty/vt/vt.c
4168 ++++ b/drivers/tty/vt/vt.c
4169 +@@ -750,6 +750,7 @@ static void visual_init(struct vc_data *vc, int num, int init)
4170 + vc->vc_complement_mask = 0;
4171 + vc->vc_can_do_color = 0;
4172 + vc->vc_panic_force_write = false;
4173 ++ vc->vc_cur_blink_ms = DEFAULT_CURSOR_BLINK_MS;
4174 + vc->vc_sw->con_init(vc, init);
4175 + if (!vc->vc_complement_mask)
4176 + vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800;
4177 +diff --git a/drivers/usb/common/usb-otg-fsm.c b/drivers/usb/common/usb-otg-fsm.c
4178 +index 504708f..6c6040c 100644
4179 +--- a/drivers/usb/common/usb-otg-fsm.c
4180 ++++ b/drivers/usb/common/usb-otg-fsm.c
4181 +@@ -21,6 +21,7 @@
4182 + * 675 Mass Ave, Cambridge, MA 02139, USA.
4183 + */
4184 +
4185 ++#include <linux/module.h>
4186 + #include <linux/kernel.h>
4187 + #include <linux/types.h>
4188 + #include <linux/mutex.h>
4189 +@@ -452,3 +453,4 @@ int otg_statemachine(struct otg_fsm *fsm)
4190 + return state_changed;
4191 + }
4192 + EXPORT_SYMBOL_GPL(otg_statemachine);
4193 ++MODULE_LICENSE("GPL");
4194 +diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
4195 +index 980fc57..2d107d0 100644
4196 +--- a/drivers/usb/core/hcd.c
4197 ++++ b/drivers/usb/core/hcd.c
4198 +@@ -2597,26 +2597,23 @@ EXPORT_SYMBOL_GPL(usb_create_hcd);
4199 + * Don't deallocate the bandwidth_mutex until the last shared usb_hcd is
4200 + * deallocated.
4201 + *
4202 +- * Make sure to only deallocate the bandwidth_mutex when the primary HCD is
4203 +- * freed. When hcd_release() is called for either hcd in a peer set
4204 +- * invalidate the peer's ->shared_hcd and ->primary_hcd pointers to
4205 +- * block new peering attempts
4206 ++ * Make sure to deallocate the bandwidth_mutex only when the last HCD is
4207 ++ * freed. When hcd_release() is called for either hcd in a peer set,
4208 ++ * invalidate the peer's ->shared_hcd and ->primary_hcd pointers.
4209 + */
4210 + static void hcd_release(struct kref *kref)
4211 + {
4212 + struct usb_hcd *hcd = container_of (kref, struct usb_hcd, kref);
4213 +
4214 + mutex_lock(&usb_port_peer_mutex);
4215 +- if (usb_hcd_is_primary_hcd(hcd)) {
4216 +- kfree(hcd->address0_mutex);
4217 +- kfree(hcd->bandwidth_mutex);
4218 +- }
4219 + if (hcd->shared_hcd) {
4220 + struct usb_hcd *peer = hcd->shared_hcd;
4221 +
4222 + peer->shared_hcd = NULL;
4223 +- if (peer->primary_hcd == hcd)
4224 +- peer->primary_hcd = NULL;
4225 ++ peer->primary_hcd = NULL;
4226 ++ } else {
4227 ++ kfree(hcd->address0_mutex);
4228 ++ kfree(hcd->bandwidth_mutex);
4229 + }
4230 + mutex_unlock(&usb_port_peer_mutex);
4231 + kfree(hcd);
4232 +diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
4233 +index 3c58d63..dec0b21 100644
4234 +--- a/drivers/usb/dwc2/core.h
4235 ++++ b/drivers/usb/dwc2/core.h
4236 +@@ -64,6 +64,17 @@
4237 + DWC2_TRACE_SCHEDULER_VB(pr_fmt("%s: SCH: " fmt), \
4238 + dev_name(hsotg->dev), ##__VA_ARGS__)
4239 +
4240 ++#ifdef CONFIG_MIPS
4241 ++/*
4242 ++ * There are some MIPS machines that can run in either big-endian
4243 ++ * or little-endian mode and that use the dwc2 register without
4244 ++ * a byteswap in both ways.
4245 ++ * Unlike other architectures, MIPS apparently does not require a
4246 ++ * barrier before the __raw_writel() to synchronize with DMA but does
4247 ++ * require the barrier after the __raw_writel() to serialize a set of
4248 ++ * writes. This set of operations was added specifically for MIPS and
4249 ++ * should only be used there.
4250 ++ */
4251 + static inline u32 dwc2_readl(const void __iomem *addr)
4252 + {
4253 + u32 value = __raw_readl(addr);
4254 +@@ -90,6 +101,22 @@ static inline void dwc2_writel(u32 value, void __iomem *addr)
4255 + pr_info("INFO:: wrote %08x to %p\n", value, addr);
4256 + #endif
4257 + }
4258 ++#else
4259 ++/* Normal architectures just use readl/write */
4260 ++static inline u32 dwc2_readl(const void __iomem *addr)
4261 ++{
4262 ++ return readl(addr);
4263 ++}
4264 ++
4265 ++static inline void dwc2_writel(u32 value, void __iomem *addr)
4266 ++{
4267 ++ writel(value, addr);
4268 ++
4269 ++#ifdef DWC2_LOG_WRITES
4270 ++ pr_info("info:: wrote %08x to %p\n", value, addr);
4271 ++#endif
4272 ++}
4273 ++#endif
4274 +
4275 + /* Maximum number of Endpoints/HostChannels */
4276 + #define MAX_EPS_CHANNELS 16
4277 +diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
4278 +index 7b6d74f..476c0e3 100644
4279 +--- a/drivers/virtio/virtio_balloon.c
4280 ++++ b/drivers/virtio/virtio_balloon.c
4281 +@@ -75,7 +75,7 @@ struct virtio_balloon {
4282 +
4283 + /* The array of pfns we tell the Host about. */
4284 + unsigned int num_pfns;
4285 +- u32 pfns[VIRTIO_BALLOON_ARRAY_PFNS_MAX];
4286 ++ __virtio32 pfns[VIRTIO_BALLOON_ARRAY_PFNS_MAX];
4287 +
4288 + /* Memory statistics */
4289 + struct virtio_balloon_stat stats[VIRTIO_BALLOON_S_NR];
4290 +@@ -127,14 +127,16 @@ static void tell_host(struct virtio_balloon *vb, struct virtqueue *vq)
4291 +
4292 + }
4293 +
4294 +-static void set_page_pfns(u32 pfns[], struct page *page)
4295 ++static void set_page_pfns(struct virtio_balloon *vb,
4296 ++ __virtio32 pfns[], struct page *page)
4297 + {
4298 + unsigned int i;
4299 +
4300 + /* Set balloon pfns pointing at this page.
4301 + * Note that the first pfn points at start of the page. */
4302 + for (i = 0; i < VIRTIO_BALLOON_PAGES_PER_PAGE; i++)
4303 +- pfns[i] = page_to_balloon_pfn(page) + i;
4304 ++ pfns[i] = cpu_to_virtio32(vb->vdev,
4305 ++ page_to_balloon_pfn(page) + i);
4306 + }
4307 +
4308 + static unsigned fill_balloon(struct virtio_balloon *vb, size_t num)
4309 +@@ -158,7 +160,7 @@ static unsigned fill_balloon(struct virtio_balloon *vb, size_t num)
4310 + msleep(200);
4311 + break;
4312 + }
4313 +- set_page_pfns(vb->pfns + vb->num_pfns, page);
4314 ++ set_page_pfns(vb, vb->pfns + vb->num_pfns, page);
4315 + vb->num_pages += VIRTIO_BALLOON_PAGES_PER_PAGE;
4316 + if (!virtio_has_feature(vb->vdev,
4317 + VIRTIO_BALLOON_F_DEFLATE_ON_OOM))
4318 +@@ -177,10 +179,12 @@ static unsigned fill_balloon(struct virtio_balloon *vb, size_t num)
4319 + static void release_pages_balloon(struct virtio_balloon *vb)
4320 + {
4321 + unsigned int i;
4322 ++ struct page *page;
4323 +
4324 + /* Find pfns pointing at start of each page, get pages and free them. */
4325 + for (i = 0; i < vb->num_pfns; i += VIRTIO_BALLOON_PAGES_PER_PAGE) {
4326 +- struct page *page = balloon_pfn_to_page(vb->pfns[i]);
4327 ++ page = balloon_pfn_to_page(virtio32_to_cpu(vb->vdev,
4328 ++ vb->pfns[i]));
4329 + if (!virtio_has_feature(vb->vdev,
4330 + VIRTIO_BALLOON_F_DEFLATE_ON_OOM))
4331 + adjust_managed_page_count(page, 1);
4332 +@@ -203,7 +207,7 @@ static unsigned leak_balloon(struct virtio_balloon *vb, size_t num)
4333 + page = balloon_page_dequeue(vb_dev_info);
4334 + if (!page)
4335 + break;
4336 +- set_page_pfns(vb->pfns + vb->num_pfns, page);
4337 ++ set_page_pfns(vb, vb->pfns + vb->num_pfns, page);
4338 + vb->num_pages -= VIRTIO_BALLOON_PAGES_PER_PAGE;
4339 + }
4340 +
4341 +@@ -471,13 +475,13 @@ static int virtballoon_migratepage(struct balloon_dev_info *vb_dev_info,
4342 + __count_vm_event(BALLOON_MIGRATE);
4343 + spin_unlock_irqrestore(&vb_dev_info->pages_lock, flags);
4344 + vb->num_pfns = VIRTIO_BALLOON_PAGES_PER_PAGE;
4345 +- set_page_pfns(vb->pfns, newpage);
4346 ++ set_page_pfns(vb, vb->pfns, newpage);
4347 + tell_host(vb, vb->inflate_vq);
4348 +
4349 + /* balloon's page migration 2nd step -- deflate "page" */
4350 + balloon_page_delete(page);
4351 + vb->num_pfns = VIRTIO_BALLOON_PAGES_PER_PAGE;
4352 +- set_page_pfns(vb->pfns, page);
4353 ++ set_page_pfns(vb, vb->pfns, page);
4354 + tell_host(vb, vb->deflate_vq);
4355 +
4356 + mutex_unlock(&vb->balloon_lock);
4357 +diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c
4358 +index d46839f..e4db19e 100644
4359 +--- a/drivers/xen/balloon.c
4360 ++++ b/drivers/xen/balloon.c
4361 +@@ -151,8 +151,6 @@ static DECLARE_WAIT_QUEUE_HEAD(balloon_wq);
4362 + static void balloon_process(struct work_struct *work);
4363 + static DECLARE_DELAYED_WORK(balloon_worker, balloon_process);
4364 +
4365 +-static void release_memory_resource(struct resource *resource);
4366 +-
4367 + /* When ballooning out (allocating memory to return to Xen) we don't really
4368 + want the kernel to try too hard since that can trigger the oom killer. */
4369 + #define GFP_BALLOON \
4370 +@@ -248,6 +246,19 @@ static enum bp_state update_schedule(enum bp_state state)
4371 + }
4372 +
4373 + #ifdef CONFIG_XEN_BALLOON_MEMORY_HOTPLUG
4374 ++static void release_memory_resource(struct resource *resource)
4375 ++{
4376 ++ if (!resource)
4377 ++ return;
4378 ++
4379 ++ /*
4380 ++ * No need to reset region to identity mapped since we now
4381 ++ * know that no I/O can be in this region
4382 ++ */
4383 ++ release_resource(resource);
4384 ++ kfree(resource);
4385 ++}
4386 ++
4387 + static struct resource *additional_memory_resource(phys_addr_t size)
4388 + {
4389 + struct resource *res;
4390 +@@ -286,19 +297,6 @@ static struct resource *additional_memory_resource(phys_addr_t size)
4391 + return res;
4392 + }
4393 +
4394 +-static void release_memory_resource(struct resource *resource)
4395 +-{
4396 +- if (!resource)
4397 +- return;
4398 +-
4399 +- /*
4400 +- * No need to reset region to identity mapped since we now
4401 +- * know that no I/O can be in this region
4402 +- */
4403 +- release_resource(resource);
4404 +- kfree(resource);
4405 +-}
4406 +-
4407 + static enum bp_state reserve_additional_memory(void)
4408 + {
4409 + long credit;
4410 +diff --git a/drivers/xen/xen-acpi-processor.c b/drivers/xen/xen-acpi-processor.c
4411 +index 076970a..4ce10bc 100644
4412 +--- a/drivers/xen/xen-acpi-processor.c
4413 ++++ b/drivers/xen/xen-acpi-processor.c
4414 +@@ -423,36 +423,7 @@ upload:
4415 +
4416 + return 0;
4417 + }
4418 +-static int __init check_prereq(void)
4419 +-{
4420 +- struct cpuinfo_x86 *c = &cpu_data(0);
4421 +-
4422 +- if (!xen_initial_domain())
4423 +- return -ENODEV;
4424 +-
4425 +- if (!acpi_gbl_FADT.smi_command)
4426 +- return -ENODEV;
4427 +-
4428 +- if (c->x86_vendor == X86_VENDOR_INTEL) {
4429 +- if (!cpu_has(c, X86_FEATURE_EST))
4430 +- return -ENODEV;
4431 +
4432 +- return 0;
4433 +- }
4434 +- if (c->x86_vendor == X86_VENDOR_AMD) {
4435 +- /* Copied from powernow-k8.h, can't include ../cpufreq/powernow
4436 +- * as we get compile warnings for the static functions.
4437 +- */
4438 +-#define CPUID_FREQ_VOLT_CAPABILITIES 0x80000007
4439 +-#define USE_HW_PSTATE 0x00000080
4440 +- u32 eax, ebx, ecx, edx;
4441 +- cpuid(CPUID_FREQ_VOLT_CAPABILITIES, &eax, &ebx, &ecx, &edx);
4442 +- if ((edx & USE_HW_PSTATE) != USE_HW_PSTATE)
4443 +- return -ENODEV;
4444 +- return 0;
4445 +- }
4446 +- return -ENODEV;
4447 +-}
4448 + /* acpi_perf_data is a pointer to percpu data. */
4449 + static struct acpi_processor_performance __percpu *acpi_perf_data;
4450 +
4451 +@@ -509,10 +480,10 @@ struct notifier_block xen_acpi_processor_resume_nb = {
4452 + static int __init xen_acpi_processor_init(void)
4453 + {
4454 + unsigned int i;
4455 +- int rc = check_prereq();
4456 ++ int rc;
4457 +
4458 +- if (rc)
4459 +- return rc;
4460 ++ if (!xen_initial_domain())
4461 ++ return -ENODEV;
4462 +
4463 + nr_acpi_bits = get_max_acpi_id() + 1;
4464 + acpi_ids_done = kcalloc(BITS_TO_LONGS(nr_acpi_bits), sizeof(unsigned long), GFP_KERNEL);
4465 +diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
4466 +index ec7928a..234707c 100644
4467 +--- a/fs/btrfs/ctree.c
4468 ++++ b/fs/btrfs/ctree.c
4469 +@@ -1552,6 +1552,7 @@ noinline int btrfs_cow_block(struct btrfs_trans_handle *trans,
4470 + trans->transid, root->fs_info->generation);
4471 +
4472 + if (!should_cow_block(trans, root, buf)) {
4473 ++ trans->dirty = true;
4474 + *cow_ret = buf;
4475 + return 0;
4476 + }
4477 +@@ -2773,8 +2774,10 @@ again:
4478 + * then we don't want to set the path blocking,
4479 + * so we test it here
4480 + */
4481 +- if (!should_cow_block(trans, root, b))
4482 ++ if (!should_cow_block(trans, root, b)) {
4483 ++ trans->dirty = true;
4484 + goto cow_done;
4485 ++ }
4486 +
4487 + /*
4488 + * must have write locks on this node and the
4489 +diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
4490 +index 84e060e..78f1b57 100644
4491 +--- a/fs/btrfs/extent-tree.c
4492 ++++ b/fs/btrfs/extent-tree.c
4493 +@@ -7929,7 +7929,7 @@ btrfs_init_new_buffer(struct btrfs_trans_handle *trans, struct btrfs_root *root,
4494 + set_extent_dirty(&trans->transaction->dirty_pages, buf->start,
4495 + buf->start + buf->len - 1, GFP_NOFS);
4496 + }
4497 +- trans->blocks_used++;
4498 ++ trans->dirty = true;
4499 + /* this returns a buffer locked for blocking */
4500 + return buf;
4501 + }
4502 +diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
4503 +index 00b8f37..d7c138f 100644
4504 +--- a/fs/btrfs/super.c
4505 ++++ b/fs/btrfs/super.c
4506 +@@ -239,7 +239,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
4507 + trans->aborted = errno;
4508 + /* Nothing used. The other threads that have joined this
4509 + * transaction may be able to continue. */
4510 +- if (!trans->blocks_used && list_empty(&trans->new_bgs)) {
4511 ++ if (!trans->dirty && list_empty(&trans->new_bgs)) {
4512 + const char *errstr;
4513 +
4514 + errstr = btrfs_decode_error(errno);
4515 +diff --git a/fs/btrfs/transaction.h b/fs/btrfs/transaction.h
4516 +index 72be51f..c0b501a 100644
4517 +--- a/fs/btrfs/transaction.h
4518 ++++ b/fs/btrfs/transaction.h
4519 +@@ -110,7 +110,6 @@ struct btrfs_trans_handle {
4520 + u64 chunk_bytes_reserved;
4521 + unsigned long use_count;
4522 + unsigned long blocks_reserved;
4523 +- unsigned long blocks_used;
4524 + unsigned long delayed_ref_updates;
4525 + struct btrfs_transaction *transaction;
4526 + struct btrfs_block_rsv *block_rsv;
4527 +@@ -121,6 +120,7 @@ struct btrfs_trans_handle {
4528 + bool can_flush_pending_bgs;
4529 + bool reloc_reserved;
4530 + bool sync;
4531 ++ bool dirty;
4532 + unsigned int type;
4533 + /*
4534 + * this root is only needed to validate that the root passed to
4535 +diff --git a/fs/cifs/cifs_unicode.c b/fs/cifs/cifs_unicode.c
4536 +index 5a53ac6..02b071bf 100644
4537 +--- a/fs/cifs/cifs_unicode.c
4538 ++++ b/fs/cifs/cifs_unicode.c
4539 +@@ -101,6 +101,12 @@ convert_sfm_char(const __u16 src_char, char *target)
4540 + case SFM_SLASH:
4541 + *target = '\\';
4542 + break;
4543 ++ case SFM_SPACE:
4544 ++ *target = ' ';
4545 ++ break;
4546 ++ case SFM_PERIOD:
4547 ++ *target = '.';
4548 ++ break;
4549 + default:
4550 + return false;
4551 + }
4552 +@@ -404,7 +410,7 @@ static __le16 convert_to_sfu_char(char src_char)
4553 + return dest_char;
4554 + }
4555 +
4556 +-static __le16 convert_to_sfm_char(char src_char)
4557 ++static __le16 convert_to_sfm_char(char src_char, bool end_of_string)
4558 + {
4559 + __le16 dest_char;
4560 +
4561 +@@ -427,6 +433,18 @@ static __le16 convert_to_sfm_char(char src_char)
4562 + case '|':
4563 + dest_char = cpu_to_le16(SFM_PIPE);
4564 + break;
4565 ++ case '.':
4566 ++ if (end_of_string)
4567 ++ dest_char = cpu_to_le16(SFM_PERIOD);
4568 ++ else
4569 ++ dest_char = 0;
4570 ++ break;
4571 ++ case ' ':
4572 ++ if (end_of_string)
4573 ++ dest_char = cpu_to_le16(SFM_SPACE);
4574 ++ else
4575 ++ dest_char = 0;
4576 ++ break;
4577 + default:
4578 + dest_char = 0;
4579 + }
4580 +@@ -469,9 +487,16 @@ cifsConvertToUTF16(__le16 *target, const char *source, int srclen,
4581 + /* see if we must remap this char */
4582 + if (map_chars == SFU_MAP_UNI_RSVD)
4583 + dst_char = convert_to_sfu_char(src_char);
4584 +- else if (map_chars == SFM_MAP_UNI_RSVD)
4585 +- dst_char = convert_to_sfm_char(src_char);
4586 +- else
4587 ++ else if (map_chars == SFM_MAP_UNI_RSVD) {
4588 ++ bool end_of_string;
4589 ++
4590 ++ if (i == srclen - 1)
4591 ++ end_of_string = true;
4592 ++ else
4593 ++ end_of_string = false;
4594 ++
4595 ++ dst_char = convert_to_sfm_char(src_char, end_of_string);
4596 ++ } else
4597 + dst_char = 0;
4598 + /*
4599 + * FIXME: We can not handle remapping backslash (UNI_SLASH)
4600 +diff --git a/fs/cifs/cifs_unicode.h b/fs/cifs/cifs_unicode.h
4601 +index bdc52cb..479bc0a 100644
4602 +--- a/fs/cifs/cifs_unicode.h
4603 ++++ b/fs/cifs/cifs_unicode.h
4604 +@@ -64,6 +64,8 @@
4605 + #define SFM_LESSTHAN ((__u16) 0xF023)
4606 + #define SFM_PIPE ((__u16) 0xF027)
4607 + #define SFM_SLASH ((__u16) 0xF026)
4608 ++#define SFM_PERIOD ((__u16) 0xF028)
4609 ++#define SFM_SPACE ((__u16) 0xF029)
4610 +
4611 + /*
4612 + * Mapping mechanism to use when one of the seven reserved characters is
4613 +diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
4614 +index 6f62ac8..34cbc58 100644
4615 +--- a/fs/cifs/connect.c
4616 ++++ b/fs/cifs/connect.c
4617 +@@ -428,7 +428,9 @@ cifs_echo_request(struct work_struct *work)
4618 + * server->ops->need_neg() == true. Also, no need to ping if
4619 + * we got a response recently.
4620 + */
4621 +- if (!server->ops->need_neg || server->ops->need_neg(server) ||
4622 ++
4623 ++ if (server->tcpStatus == CifsNeedReconnect ||
4624 ++ server->tcpStatus == CifsExiting || server->tcpStatus == CifsNew ||
4625 + (server->ops->can_echo && !server->ops->can_echo(server)) ||
4626 + time_before(jiffies, server->lstrp + echo_interval - HZ))
4627 + goto requeue_echo;
4628 +diff --git a/fs/cifs/ntlmssp.h b/fs/cifs/ntlmssp.h
4629 +index 848249f..3079b38 100644
4630 +--- a/fs/cifs/ntlmssp.h
4631 ++++ b/fs/cifs/ntlmssp.h
4632 +@@ -133,6 +133,6 @@ typedef struct _AUTHENTICATE_MESSAGE {
4633 +
4634 + int decode_ntlmssp_challenge(char *bcc_ptr, int blob_len, struct cifs_ses *ses);
4635 + void build_ntlmssp_negotiate_blob(unsigned char *pbuffer, struct cifs_ses *ses);
4636 +-int build_ntlmssp_auth_blob(unsigned char *pbuffer, u16 *buflen,
4637 ++int build_ntlmssp_auth_blob(unsigned char **pbuffer, u16 *buflen,
4638 + struct cifs_ses *ses,
4639 + const struct nls_table *nls_cp);
4640 +diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c
4641 +index af0ec2d..e88ffe1 100644
4642 +--- a/fs/cifs/sess.c
4643 ++++ b/fs/cifs/sess.c
4644 +@@ -364,19 +364,43 @@ void build_ntlmssp_negotiate_blob(unsigned char *pbuffer,
4645 + sec_blob->DomainName.MaximumLength = 0;
4646 + }
4647 +
4648 +-/* We do not malloc the blob, it is passed in pbuffer, because its
4649 +- maximum possible size is fixed and small, making this approach cleaner.
4650 +- This function returns the length of the data in the blob */
4651 +-int build_ntlmssp_auth_blob(unsigned char *pbuffer,
4652 ++static int size_of_ntlmssp_blob(struct cifs_ses *ses)
4653 ++{
4654 ++ int sz = sizeof(AUTHENTICATE_MESSAGE) + ses->auth_key.len
4655 ++ - CIFS_SESS_KEY_SIZE + CIFS_CPHTXT_SIZE + 2;
4656 ++
4657 ++ if (ses->domainName)
4658 ++ sz += 2 * strnlen(ses->domainName, CIFS_MAX_DOMAINNAME_LEN);
4659 ++ else
4660 ++ sz += 2;
4661 ++
4662 ++ if (ses->user_name)
4663 ++ sz += 2 * strnlen(ses->user_name, CIFS_MAX_USERNAME_LEN);
4664 ++ else
4665 ++ sz += 2;
4666 ++
4667 ++ return sz;
4668 ++}
4669 ++
4670 ++int build_ntlmssp_auth_blob(unsigned char **pbuffer,
4671 + u16 *buflen,
4672 + struct cifs_ses *ses,
4673 + const struct nls_table *nls_cp)
4674 + {
4675 + int rc;
4676 +- AUTHENTICATE_MESSAGE *sec_blob = (AUTHENTICATE_MESSAGE *)pbuffer;
4677 ++ AUTHENTICATE_MESSAGE *sec_blob;
4678 + __u32 flags;
4679 + unsigned char *tmp;
4680 +
4681 ++ rc = setup_ntlmv2_rsp(ses, nls_cp);
4682 ++ if (rc) {
4683 ++ cifs_dbg(VFS, "Error %d during NTLMSSP authentication\n", rc);
4684 ++ *buflen = 0;
4685 ++ goto setup_ntlmv2_ret;
4686 ++ }
4687 ++ *pbuffer = kmalloc(size_of_ntlmssp_blob(ses), GFP_KERNEL);
4688 ++ sec_blob = (AUTHENTICATE_MESSAGE *)*pbuffer;
4689 ++
4690 + memcpy(sec_blob->Signature, NTLMSSP_SIGNATURE, 8);
4691 + sec_blob->MessageType = NtLmAuthenticate;
4692 +
4693 +@@ -391,7 +415,7 @@ int build_ntlmssp_auth_blob(unsigned char *pbuffer,
4694 + flags |= NTLMSSP_NEGOTIATE_KEY_XCH;
4695 + }
4696 +
4697 +- tmp = pbuffer + sizeof(AUTHENTICATE_MESSAGE);
4698 ++ tmp = *pbuffer + sizeof(AUTHENTICATE_MESSAGE);
4699 + sec_blob->NegotiateFlags = cpu_to_le32(flags);
4700 +
4701 + sec_blob->LmChallengeResponse.BufferOffset =
4702 +@@ -399,13 +423,9 @@ int build_ntlmssp_auth_blob(unsigned char *pbuffer,
4703 + sec_blob->LmChallengeResponse.Length = 0;
4704 + sec_blob->LmChallengeResponse.MaximumLength = 0;
4705 +
4706 +- sec_blob->NtChallengeResponse.BufferOffset = cpu_to_le32(tmp - pbuffer);
4707 ++ sec_blob->NtChallengeResponse.BufferOffset =
4708 ++ cpu_to_le32(tmp - *pbuffer);
4709 + if (ses->user_name != NULL) {
4710 +- rc = setup_ntlmv2_rsp(ses, nls_cp);
4711 +- if (rc) {
4712 +- cifs_dbg(VFS, "Error %d during NTLMSSP authentication\n", rc);
4713 +- goto setup_ntlmv2_ret;
4714 +- }
4715 + memcpy(tmp, ses->auth_key.response + CIFS_SESS_KEY_SIZE,
4716 + ses->auth_key.len - CIFS_SESS_KEY_SIZE);
4717 + tmp += ses->auth_key.len - CIFS_SESS_KEY_SIZE;
4718 +@@ -423,7 +443,7 @@ int build_ntlmssp_auth_blob(unsigned char *pbuffer,
4719 + }
4720 +
4721 + if (ses->domainName == NULL) {
4722 +- sec_blob->DomainName.BufferOffset = cpu_to_le32(tmp - pbuffer);
4723 ++ sec_blob->DomainName.BufferOffset = cpu_to_le32(tmp - *pbuffer);
4724 + sec_blob->DomainName.Length = 0;
4725 + sec_blob->DomainName.MaximumLength = 0;
4726 + tmp += 2;
4727 +@@ -432,14 +452,14 @@ int build_ntlmssp_auth_blob(unsigned char *pbuffer,
4728 + len = cifs_strtoUTF16((__le16 *)tmp, ses->domainName,
4729 + CIFS_MAX_USERNAME_LEN, nls_cp);
4730 + len *= 2; /* unicode is 2 bytes each */
4731 +- sec_blob->DomainName.BufferOffset = cpu_to_le32(tmp - pbuffer);
4732 ++ sec_blob->DomainName.BufferOffset = cpu_to_le32(tmp - *pbuffer);
4733 + sec_blob->DomainName.Length = cpu_to_le16(len);
4734 + sec_blob->DomainName.MaximumLength = cpu_to_le16(len);
4735 + tmp += len;
4736 + }
4737 +
4738 + if (ses->user_name == NULL) {
4739 +- sec_blob->UserName.BufferOffset = cpu_to_le32(tmp - pbuffer);
4740 ++ sec_blob->UserName.BufferOffset = cpu_to_le32(tmp - *pbuffer);
4741 + sec_blob->UserName.Length = 0;
4742 + sec_blob->UserName.MaximumLength = 0;
4743 + tmp += 2;
4744 +@@ -448,13 +468,13 @@ int build_ntlmssp_auth_blob(unsigned char *pbuffer,
4745 + len = cifs_strtoUTF16((__le16 *)tmp, ses->user_name,
4746 + CIFS_MAX_USERNAME_LEN, nls_cp);
4747 + len *= 2; /* unicode is 2 bytes each */
4748 +- sec_blob->UserName.BufferOffset = cpu_to_le32(tmp - pbuffer);
4749 ++ sec_blob->UserName.BufferOffset = cpu_to_le32(tmp - *pbuffer);
4750 + sec_blob->UserName.Length = cpu_to_le16(len);
4751 + sec_blob->UserName.MaximumLength = cpu_to_le16(len);
4752 + tmp += len;
4753 + }
4754 +
4755 +- sec_blob->WorkstationName.BufferOffset = cpu_to_le32(tmp - pbuffer);
4756 ++ sec_blob->WorkstationName.BufferOffset = cpu_to_le32(tmp - *pbuffer);
4757 + sec_blob->WorkstationName.Length = 0;
4758 + sec_blob->WorkstationName.MaximumLength = 0;
4759 + tmp += 2;
4760 +@@ -463,19 +483,19 @@ int build_ntlmssp_auth_blob(unsigned char *pbuffer,
4761 + (ses->ntlmssp->server_flags & NTLMSSP_NEGOTIATE_EXTENDED_SEC))
4762 + && !calc_seckey(ses)) {
4763 + memcpy(tmp, ses->ntlmssp->ciphertext, CIFS_CPHTXT_SIZE);
4764 +- sec_blob->SessionKey.BufferOffset = cpu_to_le32(tmp - pbuffer);
4765 ++ sec_blob->SessionKey.BufferOffset = cpu_to_le32(tmp - *pbuffer);
4766 + sec_blob->SessionKey.Length = cpu_to_le16(CIFS_CPHTXT_SIZE);
4767 + sec_blob->SessionKey.MaximumLength =
4768 + cpu_to_le16(CIFS_CPHTXT_SIZE);
4769 + tmp += CIFS_CPHTXT_SIZE;
4770 + } else {
4771 +- sec_blob->SessionKey.BufferOffset = cpu_to_le32(tmp - pbuffer);
4772 ++ sec_blob->SessionKey.BufferOffset = cpu_to_le32(tmp - *pbuffer);
4773 + sec_blob->SessionKey.Length = 0;
4774 + sec_blob->SessionKey.MaximumLength = 0;
4775 + }
4776 +
4777 ++ *buflen = tmp - *pbuffer;
4778 + setup_ntlmv2_ret:
4779 +- *buflen = tmp - pbuffer;
4780 + return rc;
4781 + }
4782 +
4783 +@@ -1266,7 +1286,7 @@ sess_auth_rawntlmssp_authenticate(struct sess_data *sess_data)
4784 + struct cifs_ses *ses = sess_data->ses;
4785 + __u16 bytes_remaining;
4786 + char *bcc_ptr;
4787 +- char *ntlmsspblob = NULL;
4788 ++ unsigned char *ntlmsspblob = NULL;
4789 + u16 blob_len;
4790 +
4791 + cifs_dbg(FYI, "rawntlmssp session setup authenticate phase\n");
4792 +@@ -1279,19 +1299,7 @@ sess_auth_rawntlmssp_authenticate(struct sess_data *sess_data)
4793 + /* Build security blob before we assemble the request */
4794 + pSMB = (SESSION_SETUP_ANDX *)sess_data->iov[0].iov_base;
4795 + smb_buf = (struct smb_hdr *)pSMB;
4796 +- /*
4797 +- * 5 is an empirical value, large enough to hold
4798 +- * authenticate message plus max 10 of av paris,
4799 +- * domain, user, workstation names, flags, etc.
4800 +- */
4801 +- ntlmsspblob = kzalloc(5*sizeof(struct _AUTHENTICATE_MESSAGE),
4802 +- GFP_KERNEL);
4803 +- if (!ntlmsspblob) {
4804 +- rc = -ENOMEM;
4805 +- goto out;
4806 +- }
4807 +-
4808 +- rc = build_ntlmssp_auth_blob(ntlmsspblob,
4809 ++ rc = build_ntlmssp_auth_blob(&ntlmsspblob,
4810 + &blob_len, ses, sess_data->nls_cp);
4811 + if (rc)
4812 + goto out_free_ntlmsspblob;
4813 +diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
4814 +index 8f38e33..29e06db 100644
4815 +--- a/fs/cifs/smb2pdu.c
4816 ++++ b/fs/cifs/smb2pdu.c
4817 +@@ -588,7 +588,7 @@ SMB2_sess_setup(const unsigned int xid, struct cifs_ses *ses,
4818 + u16 blob_length = 0;
4819 + struct key *spnego_key = NULL;
4820 + char *security_blob = NULL;
4821 +- char *ntlmssp_blob = NULL;
4822 ++ unsigned char *ntlmssp_blob = NULL;
4823 + bool use_spnego = false; /* else use raw ntlmssp */
4824 +
4825 + cifs_dbg(FYI, "Session Setup\n");
4826 +@@ -713,13 +713,7 @@ ssetup_ntlmssp_authenticate:
4827 + iov[1].iov_len = blob_length;
4828 + } else if (phase == NtLmAuthenticate) {
4829 + req->hdr.SessionId = ses->Suid;
4830 +- ntlmssp_blob = kzalloc(sizeof(struct _NEGOTIATE_MESSAGE) + 500,
4831 +- GFP_KERNEL);
4832 +- if (ntlmssp_blob == NULL) {
4833 +- rc = -ENOMEM;
4834 +- goto ssetup_exit;
4835 +- }
4836 +- rc = build_ntlmssp_auth_blob(ntlmssp_blob, &blob_length, ses,
4837 ++ rc = build_ntlmssp_auth_blob(&ntlmssp_blob, &blob_length, ses,
4838 + nls_cp);
4839 + if (rc) {
4840 + cifs_dbg(FYI, "build_ntlmssp_auth_blob failed %d\n",
4841 +@@ -1818,6 +1812,33 @@ SMB2_echo(struct TCP_Server_Info *server)
4842 +
4843 + cifs_dbg(FYI, "In echo request\n");
4844 +
4845 ++ if (server->tcpStatus == CifsNeedNegotiate) {
4846 ++ struct list_head *tmp, *tmp2;
4847 ++ struct cifs_ses *ses;
4848 ++ struct cifs_tcon *tcon;
4849 ++
4850 ++ cifs_dbg(FYI, "Need negotiate, reconnecting tcons\n");
4851 ++ spin_lock(&cifs_tcp_ses_lock);
4852 ++ list_for_each(tmp, &server->smb_ses_list) {
4853 ++ ses = list_entry(tmp, struct cifs_ses, smb_ses_list);
4854 ++ list_for_each(tmp2, &ses->tcon_list) {
4855 ++ tcon = list_entry(tmp2, struct cifs_tcon,
4856 ++ tcon_list);
4857 ++ /* add check for persistent handle reconnect */
4858 ++ if (tcon && tcon->need_reconnect) {
4859 ++ spin_unlock(&cifs_tcp_ses_lock);
4860 ++ rc = smb2_reconnect(SMB2_ECHO, tcon);
4861 ++ spin_lock(&cifs_tcp_ses_lock);
4862 ++ }
4863 ++ }
4864 ++ }
4865 ++ spin_unlock(&cifs_tcp_ses_lock);
4866 ++ }
4867 ++
4868 ++ /* if no session, renegotiate failed above */
4869 ++ if (server->tcpStatus == CifsNeedNegotiate)
4870 ++ return -EIO;
4871 ++
4872 + rc = small_smb2_init(SMB2_ECHO, NULL, (void **)&req);
4873 + if (rc)
4874 + return rc;
4875 +diff --git a/fs/namei.c b/fs/namei.c
4876 +index 30145f8..aaa3b69 100644
4877 +--- a/fs/namei.c
4878 ++++ b/fs/namei.c
4879 +@@ -3173,6 +3173,10 @@ retry_lookup:
4880 + got_write = false;
4881 + }
4882 +
4883 ++ error = follow_managed(&path, nd);
4884 ++ if (unlikely(error < 0))
4885 ++ return error;
4886 ++
4887 + if (unlikely(d_is_negative(path.dentry))) {
4888 + path_to_nameidata(&path, nd);
4889 + return -ENOENT;
4890 +@@ -3188,10 +3192,6 @@ retry_lookup:
4891 + return -EEXIST;
4892 + }
4893 +
4894 +- error = follow_managed(&path, nd);
4895 +- if (unlikely(error < 0))
4896 +- return error;
4897 +-
4898 + seq = 0; /* out of RCU mode, so the value doesn't matter */
4899 + inode = d_backing_inode(path.dentry);
4900 + finish_lookup:
4901 +diff --git a/fs/namespace.c b/fs/namespace.c
4902 +index 4fb1691..783004a 100644
4903 +--- a/fs/namespace.c
4904 ++++ b/fs/namespace.c
4905 +@@ -2409,8 +2409,10 @@ static int do_new_mount(struct path *path, const char *fstype, int flags,
4906 + mnt_flags |= MNT_NODEV | MNT_LOCK_NODEV;
4907 + }
4908 + if (type->fs_flags & FS_USERNS_VISIBLE) {
4909 +- if (!fs_fully_visible(type, &mnt_flags))
4910 ++ if (!fs_fully_visible(type, &mnt_flags)) {
4911 ++ put_filesystem(type);
4912 + return -EPERM;
4913 ++ }
4914 + }
4915 + }
4916 +
4917 +@@ -3245,6 +3247,10 @@ static bool fs_fully_visible(struct file_system_type *type, int *new_mnt_flags)
4918 + if (mnt->mnt.mnt_sb->s_iflags & SB_I_NOEXEC)
4919 + mnt_flags &= ~(MNT_LOCK_NOSUID | MNT_LOCK_NOEXEC);
4920 +
4921 ++ /* Don't miss readonly hidden in the superblock flags */
4922 ++ if (mnt->mnt.mnt_sb->s_flags & MS_RDONLY)
4923 ++ mnt_flags |= MNT_LOCK_READONLY;
4924 ++
4925 + /* Verify the mount flags are equal to or more permissive
4926 + * than the proposed new mount.
4927 + */
4928 +@@ -3271,7 +3277,7 @@ static bool fs_fully_visible(struct file_system_type *type, int *new_mnt_flags)
4929 + list_for_each_entry(child, &mnt->mnt_mounts, mnt_child) {
4930 + struct inode *inode = child->mnt_mountpoint->d_inode;
4931 + /* Only worry about locked mounts */
4932 +- if (!(mnt_flags & MNT_LOCKED))
4933 ++ if (!(child->mnt.mnt_flags & MNT_LOCKED))
4934 + continue;
4935 + /* Is the directory permanetly empty? */
4936 + if (!is_empty_dir_inode(inode))
4937 +diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
4938 +index 33eb817..a7dd1fe 100644
4939 +--- a/fs/nfs/dir.c
4940 ++++ b/fs/nfs/dir.c
4941 +@@ -1527,9 +1527,9 @@ int nfs_atomic_open(struct inode *dir, struct dentry *dentry,
4942 + err = PTR_ERR(inode);
4943 + trace_nfs_atomic_open_exit(dir, ctx, open_flags, err);
4944 + put_nfs_open_context(ctx);
4945 ++ d_drop(dentry);
4946 + switch (err) {
4947 + case -ENOENT:
4948 +- d_drop(dentry);
4949 + d_add(dentry, NULL);
4950 + nfs_set_verifier(dentry, nfs_save_change_attribute(dir));
4951 + break;
4952 +diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
4953 +index 327b8c3..de2523f 100644
4954 +--- a/fs/nfs/nfs4proc.c
4955 ++++ b/fs/nfs/nfs4proc.c
4956 +@@ -2860,12 +2860,11 @@ static void nfs4_close_prepare(struct rpc_task *task, void *data)
4957 + call_close |= is_wronly;
4958 + else if (is_wronly)
4959 + calldata->arg.fmode |= FMODE_WRITE;
4960 ++ if (calldata->arg.fmode != (FMODE_READ|FMODE_WRITE))
4961 ++ call_close |= is_rdwr;
4962 + } else if (is_rdwr)
4963 + calldata->arg.fmode |= FMODE_READ|FMODE_WRITE;
4964 +
4965 +- if (calldata->arg.fmode == 0)
4966 +- call_close |= is_rdwr;
4967 +-
4968 + if (!nfs4_valid_open_stateid(state))
4969 + call_close = 0;
4970 + spin_unlock(&state->owner->so_lock);
4971 +diff --git a/fs/nfs/pnfs_nfs.c b/fs/nfs/pnfs_nfs.c
4972 +index 776dccb..dcb7000 100644
4973 +--- a/fs/nfs/pnfs_nfs.c
4974 ++++ b/fs/nfs/pnfs_nfs.c
4975 +@@ -247,7 +247,11 @@ void pnfs_fetch_commit_bucket_list(struct list_head *pages,
4976 + }
4977 +
4978 + /* Helper function for pnfs_generic_commit_pagelist to catch an empty
4979 +- * page list. This can happen when two commits race. */
4980 ++ * page list. This can happen when two commits race.
4981 ++ *
4982 ++ * This must be called instead of nfs_init_commit - call one or the other, but
4983 ++ * not both!
4984 ++ */
4985 + static bool
4986 + pnfs_generic_commit_cancel_empty_pagelist(struct list_head *pages,
4987 + struct nfs_commit_data *data,
4988 +@@ -256,7 +260,11 @@ pnfs_generic_commit_cancel_empty_pagelist(struct list_head *pages,
4989 + if (list_empty(pages)) {
4990 + if (atomic_dec_and_test(&cinfo->mds->rpcs_out))
4991 + wake_up_atomic_t(&cinfo->mds->rpcs_out);
4992 +- nfs_commitdata_release(data);
4993 ++ /* don't call nfs_commitdata_release - it tries to put
4994 ++ * the open_context which is not acquired until nfs_init_commit
4995 ++ * which has not been called on @data */
4996 ++ WARN_ON_ONCE(data->context);
4997 ++ nfs_commit_free(data);
4998 + return true;
4999 + }
5000 +
5001 +diff --git a/fs/nfs/read.c b/fs/nfs/read.c
5002 +index 6776d7a..572e5b3 100644
5003 +--- a/fs/nfs/read.c
5004 ++++ b/fs/nfs/read.c
5005 +@@ -367,13 +367,13 @@ readpage_async_filler(void *data, struct page *page)
5006 + nfs_list_remove_request(new);
5007 + nfs_readpage_release(new);
5008 + error = desc->pgio->pg_error;
5009 +- goto out_unlock;
5010 ++ goto out;
5011 + }
5012 + return 0;
5013 + out_error:
5014 + error = PTR_ERR(new);
5015 +-out_unlock:
5016 + unlock_page(page);
5017 ++out:
5018 + return error;
5019 + }
5020 +
5021 +diff --git a/fs/nfsd/nfs2acl.c b/fs/nfsd/nfs2acl.c
5022 +index 1580ea6..d08cd88 100644
5023 +--- a/fs/nfsd/nfs2acl.c
5024 ++++ b/fs/nfsd/nfs2acl.c
5025 +@@ -104,22 +104,21 @@ static __be32 nfsacld_proc_setacl(struct svc_rqst * rqstp,
5026 + goto out;
5027 +
5028 + inode = d_inode(fh->fh_dentry);
5029 +- if (!IS_POSIXACL(inode) || !inode->i_op->set_acl) {
5030 +- error = -EOPNOTSUPP;
5031 +- goto out_errno;
5032 +- }
5033 +
5034 + error = fh_want_write(fh);
5035 + if (error)
5036 + goto out_errno;
5037 +
5038 +- error = inode->i_op->set_acl(inode, argp->acl_access, ACL_TYPE_ACCESS);
5039 ++ fh_lock(fh);
5040 ++
5041 ++ error = set_posix_acl(inode, ACL_TYPE_ACCESS, argp->acl_access);
5042 + if (error)
5043 +- goto out_drop_write;
5044 +- error = inode->i_op->set_acl(inode, argp->acl_default,
5045 +- ACL_TYPE_DEFAULT);
5046 ++ goto out_drop_lock;
5047 ++ error = set_posix_acl(inode, ACL_TYPE_DEFAULT, argp->acl_default);
5048 + if (error)
5049 +- goto out_drop_write;
5050 ++ goto out_drop_lock;
5051 ++
5052 ++ fh_unlock(fh);
5053 +
5054 + fh_drop_write(fh);
5055 +
5056 +@@ -131,7 +130,8 @@ out:
5057 + posix_acl_release(argp->acl_access);
5058 + posix_acl_release(argp->acl_default);
5059 + return nfserr;
5060 +-out_drop_write:
5061 ++out_drop_lock:
5062 ++ fh_unlock(fh);
5063 + fh_drop_write(fh);
5064 + out_errno:
5065 + nfserr = nfserrno(error);
5066 +diff --git a/fs/nfsd/nfs3acl.c b/fs/nfsd/nfs3acl.c
5067 +index 01df4cd..0c89034 100644
5068 +--- a/fs/nfsd/nfs3acl.c
5069 ++++ b/fs/nfsd/nfs3acl.c
5070 +@@ -95,22 +95,20 @@ static __be32 nfsd3_proc_setacl(struct svc_rqst * rqstp,
5071 + goto out;
5072 +
5073 + inode = d_inode(fh->fh_dentry);
5074 +- if (!IS_POSIXACL(inode) || !inode->i_op->set_acl) {
5075 +- error = -EOPNOTSUPP;
5076 +- goto out_errno;
5077 +- }
5078 +
5079 + error = fh_want_write(fh);
5080 + if (error)
5081 + goto out_errno;
5082 +
5083 +- error = inode->i_op->set_acl(inode, argp->acl_access, ACL_TYPE_ACCESS);
5084 ++ fh_lock(fh);
5085 ++
5086 ++ error = set_posix_acl(inode, ACL_TYPE_ACCESS, argp->acl_access);
5087 + if (error)
5088 +- goto out_drop_write;
5089 +- error = inode->i_op->set_acl(inode, argp->acl_default,
5090 +- ACL_TYPE_DEFAULT);
5091 ++ goto out_drop_lock;
5092 ++ error = set_posix_acl(inode, ACL_TYPE_DEFAULT, argp->acl_default);
5093 +
5094 +-out_drop_write:
5095 ++out_drop_lock:
5096 ++ fh_unlock(fh);
5097 + fh_drop_write(fh);
5098 + out_errno:
5099 + nfserr = nfserrno(error);
5100 +diff --git a/fs/nfsd/nfs4acl.c b/fs/nfsd/nfs4acl.c
5101 +index 6adabd6..71292a0 100644
5102 +--- a/fs/nfsd/nfs4acl.c
5103 ++++ b/fs/nfsd/nfs4acl.c
5104 +@@ -770,9 +770,6 @@ nfsd4_set_nfs4_acl(struct svc_rqst *rqstp, struct svc_fh *fhp,
5105 + dentry = fhp->fh_dentry;
5106 + inode = d_inode(dentry);
5107 +
5108 +- if (!inode->i_op->set_acl || !IS_POSIXACL(inode))
5109 +- return nfserr_attrnotsupp;
5110 +-
5111 + if (S_ISDIR(inode->i_mode))
5112 + flags = NFS4_ACL_DIR;
5113 +
5114 +@@ -782,16 +779,19 @@ nfsd4_set_nfs4_acl(struct svc_rqst *rqstp, struct svc_fh *fhp,
5115 + if (host_error < 0)
5116 + goto out_nfserr;
5117 +
5118 +- host_error = inode->i_op->set_acl(inode, pacl, ACL_TYPE_ACCESS);
5119 ++ fh_lock(fhp);
5120 ++
5121 ++ host_error = set_posix_acl(inode, ACL_TYPE_ACCESS, pacl);
5122 + if (host_error < 0)
5123 +- goto out_release;
5124 ++ goto out_drop_lock;
5125 +
5126 + if (S_ISDIR(inode->i_mode)) {
5127 +- host_error = inode->i_op->set_acl(inode, dpacl,
5128 +- ACL_TYPE_DEFAULT);
5129 ++ host_error = set_posix_acl(inode, ACL_TYPE_DEFAULT, dpacl);
5130 + }
5131 +
5132 +-out_release:
5133 ++out_drop_lock:
5134 ++ fh_unlock(fhp);
5135 ++
5136 + posix_acl_release(pacl);
5137 + posix_acl_release(dpacl);
5138 + out_nfserr:
5139 +diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c
5140 +index 7389cb1..04c68d9 100644
5141 +--- a/fs/nfsd/nfs4callback.c
5142 ++++ b/fs/nfsd/nfs4callback.c
5143 +@@ -710,22 +710,6 @@ static struct rpc_cred *get_backchannel_cred(struct nfs4_client *clp, struct rpc
5144 + }
5145 + }
5146 +
5147 +-static struct rpc_clnt *create_backchannel_client(struct rpc_create_args *args)
5148 +-{
5149 +- struct rpc_xprt *xprt;
5150 +-
5151 +- if (args->protocol != XPRT_TRANSPORT_BC_TCP)
5152 +- return rpc_create(args);
5153 +-
5154 +- xprt = args->bc_xprt->xpt_bc_xprt;
5155 +- if (xprt) {
5156 +- xprt_get(xprt);
5157 +- return rpc_create_xprt(args, xprt);
5158 +- }
5159 +-
5160 +- return rpc_create(args);
5161 +-}
5162 +-
5163 + static int setup_callback_client(struct nfs4_client *clp, struct nfs4_cb_conn *conn, struct nfsd4_session *ses)
5164 + {
5165 + int maxtime = max_cb_time(clp->net);
5166 +@@ -768,7 +752,7 @@ static int setup_callback_client(struct nfs4_client *clp, struct nfs4_cb_conn *c
5167 + args.authflavor = ses->se_cb_sec.flavor;
5168 + }
5169 + /* Create RPC client */
5170 +- client = create_backchannel_client(&args);
5171 ++ client = rpc_create(&args);
5172 + if (IS_ERR(client)) {
5173 + dprintk("NFSD: couldn't create callback client: %ld\n",
5174 + PTR_ERR(client));
5175 +diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
5176 +index 0462eed..9e04e49 100644
5177 +--- a/fs/nfsd/nfs4state.c
5178 ++++ b/fs/nfsd/nfs4state.c
5179 +@@ -3487,6 +3487,10 @@ init_open_stateid(struct nfs4_ol_stateid *stp, struct nfs4_file *fp,
5180 + struct nfs4_openowner *oo = open->op_openowner;
5181 + struct nfs4_ol_stateid *retstp = NULL;
5182 +
5183 ++ /* We are moving these outside of the spinlocks to avoid the warnings */
5184 ++ mutex_init(&stp->st_mutex);
5185 ++ mutex_lock(&stp->st_mutex);
5186 ++
5187 + spin_lock(&oo->oo_owner.so_client->cl_lock);
5188 + spin_lock(&fp->fi_lock);
5189 +
5190 +@@ -3502,13 +3506,17 @@ init_open_stateid(struct nfs4_ol_stateid *stp, struct nfs4_file *fp,
5191 + stp->st_access_bmap = 0;
5192 + stp->st_deny_bmap = 0;
5193 + stp->st_openstp = NULL;
5194 +- init_rwsem(&stp->st_rwsem);
5195 + list_add(&stp->st_perstateowner, &oo->oo_owner.so_stateids);
5196 + list_add(&stp->st_perfile, &fp->fi_stateids);
5197 +
5198 + out_unlock:
5199 + spin_unlock(&fp->fi_lock);
5200 + spin_unlock(&oo->oo_owner.so_client->cl_lock);
5201 ++ if (retstp) {
5202 ++ mutex_lock(&retstp->st_mutex);
5203 ++ /* Not that we need to, just for neatness */
5204 ++ mutex_unlock(&stp->st_mutex);
5205 ++ }
5206 + return retstp;
5207 + }
5208 +
5209 +@@ -4335,32 +4343,34 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf
5210 + */
5211 + if (stp) {
5212 + /* Stateid was found, this is an OPEN upgrade */
5213 +- down_read(&stp->st_rwsem);
5214 ++ mutex_lock(&stp->st_mutex);
5215 + status = nfs4_upgrade_open(rqstp, fp, current_fh, stp, open);
5216 + if (status) {
5217 +- up_read(&stp->st_rwsem);
5218 ++ mutex_unlock(&stp->st_mutex);
5219 + goto out;
5220 + }
5221 + } else {
5222 + stp = open->op_stp;
5223 + open->op_stp = NULL;
5224 ++ /*
5225 ++ * init_open_stateid() either returns a locked stateid
5226 ++ * it found, or initializes and locks the new one we passed in
5227 ++ */
5228 + swapstp = init_open_stateid(stp, fp, open);
5229 + if (swapstp) {
5230 + nfs4_put_stid(&stp->st_stid);
5231 + stp = swapstp;
5232 +- down_read(&stp->st_rwsem);
5233 + status = nfs4_upgrade_open(rqstp, fp, current_fh,
5234 + stp, open);
5235 + if (status) {
5236 +- up_read(&stp->st_rwsem);
5237 ++ mutex_unlock(&stp->st_mutex);
5238 + goto out;
5239 + }
5240 + goto upgrade_out;
5241 + }
5242 +- down_read(&stp->st_rwsem);
5243 + status = nfs4_get_vfs_file(rqstp, fp, current_fh, stp, open);
5244 + if (status) {
5245 +- up_read(&stp->st_rwsem);
5246 ++ mutex_unlock(&stp->st_mutex);
5247 + release_open_stateid(stp);
5248 + goto out;
5249 + }
5250 +@@ -4372,7 +4382,7 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf
5251 + }
5252 + upgrade_out:
5253 + nfs4_inc_and_copy_stateid(&open->op_stateid, &stp->st_stid);
5254 +- up_read(&stp->st_rwsem);
5255 ++ mutex_unlock(&stp->st_mutex);
5256 +
5257 + if (nfsd4_has_session(&resp->cstate)) {
5258 + if (open->op_deleg_want & NFS4_SHARE_WANT_NO_DELEG) {
5259 +@@ -4983,12 +4993,12 @@ static __be32 nfs4_seqid_op_checks(struct nfsd4_compound_state *cstate, stateid_
5260 + * revoked delegations are kept only for free_stateid.
5261 + */
5262 + return nfserr_bad_stateid;
5263 +- down_write(&stp->st_rwsem);
5264 ++ mutex_lock(&stp->st_mutex);
5265 + status = check_stateid_generation(stateid, &stp->st_stid.sc_stateid, nfsd4_has_session(cstate));
5266 + if (status == nfs_ok)
5267 + status = nfs4_check_fh(current_fh, &stp->st_stid);
5268 + if (status != nfs_ok)
5269 +- up_write(&stp->st_rwsem);
5270 ++ mutex_unlock(&stp->st_mutex);
5271 + return status;
5272 + }
5273 +
5274 +@@ -5036,7 +5046,7 @@ static __be32 nfs4_preprocess_confirmed_seqid_op(struct nfsd4_compound_state *cs
5275 + return status;
5276 + oo = openowner(stp->st_stateowner);
5277 + if (!(oo->oo_flags & NFS4_OO_CONFIRMED)) {
5278 +- up_write(&stp->st_rwsem);
5279 ++ mutex_unlock(&stp->st_mutex);
5280 + nfs4_put_stid(&stp->st_stid);
5281 + return nfserr_bad_stateid;
5282 + }
5283 +@@ -5068,12 +5078,12 @@ nfsd4_open_confirm(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
5284 + oo = openowner(stp->st_stateowner);
5285 + status = nfserr_bad_stateid;
5286 + if (oo->oo_flags & NFS4_OO_CONFIRMED) {
5287 +- up_write(&stp->st_rwsem);
5288 ++ mutex_unlock(&stp->st_mutex);
5289 + goto put_stateid;
5290 + }
5291 + oo->oo_flags |= NFS4_OO_CONFIRMED;
5292 + nfs4_inc_and_copy_stateid(&oc->oc_resp_stateid, &stp->st_stid);
5293 +- up_write(&stp->st_rwsem);
5294 ++ mutex_unlock(&stp->st_mutex);
5295 + dprintk("NFSD: %s: success, seqid=%d stateid=" STATEID_FMT "\n",
5296 + __func__, oc->oc_seqid, STATEID_VAL(&stp->st_stid.sc_stateid));
5297 +
5298 +@@ -5149,7 +5159,7 @@ nfsd4_open_downgrade(struct svc_rqst *rqstp,
5299 + nfs4_inc_and_copy_stateid(&od->od_stateid, &stp->st_stid);
5300 + status = nfs_ok;
5301 + put_stateid:
5302 +- up_write(&stp->st_rwsem);
5303 ++ mutex_unlock(&stp->st_mutex);
5304 + nfs4_put_stid(&stp->st_stid);
5305 + out:
5306 + nfsd4_bump_seqid(cstate, status);
5307 +@@ -5202,7 +5212,7 @@ nfsd4_close(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
5308 + if (status)
5309 + goto out;
5310 + nfs4_inc_and_copy_stateid(&close->cl_stateid, &stp->st_stid);
5311 +- up_write(&stp->st_rwsem);
5312 ++ mutex_unlock(&stp->st_mutex);
5313 +
5314 + nfsd4_close_open_stateid(stp);
5315 +
5316 +@@ -5428,7 +5438,7 @@ init_lock_stateid(struct nfs4_ol_stateid *stp, struct nfs4_lockowner *lo,
5317 + stp->st_access_bmap = 0;
5318 + stp->st_deny_bmap = open_stp->st_deny_bmap;
5319 + stp->st_openstp = open_stp;
5320 +- init_rwsem(&stp->st_rwsem);
5321 ++ mutex_init(&stp->st_mutex);
5322 + list_add(&stp->st_locks, &open_stp->st_locks);
5323 + list_add(&stp->st_perstateowner, &lo->lo_owner.so_stateids);
5324 + spin_lock(&fp->fi_lock);
5325 +@@ -5597,7 +5607,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
5326 + &open_stp, nn);
5327 + if (status)
5328 + goto out;
5329 +- up_write(&open_stp->st_rwsem);
5330 ++ mutex_unlock(&open_stp->st_mutex);
5331 + open_sop = openowner(open_stp->st_stateowner);
5332 + status = nfserr_bad_stateid;
5333 + if (!same_clid(&open_sop->oo_owner.so_client->cl_clientid,
5334 +@@ -5606,7 +5616,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
5335 + status = lookup_or_create_lock_state(cstate, open_stp, lock,
5336 + &lock_stp, &new);
5337 + if (status == nfs_ok)
5338 +- down_write(&lock_stp->st_rwsem);
5339 ++ mutex_lock(&lock_stp->st_mutex);
5340 + } else {
5341 + status = nfs4_preprocess_seqid_op(cstate,
5342 + lock->lk_old_lock_seqid,
5343 +@@ -5710,7 +5720,7 @@ out:
5344 + seqid_mutating_err(ntohl(status)))
5345 + lock_sop->lo_owner.so_seqid++;
5346 +
5347 +- up_write(&lock_stp->st_rwsem);
5348 ++ mutex_unlock(&lock_stp->st_mutex);
5349 +
5350 + /*
5351 + * If this is a new, never-before-used stateid, and we are
5352 +@@ -5880,7 +5890,7 @@ nfsd4_locku(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
5353 + fput:
5354 + fput(filp);
5355 + put_stateid:
5356 +- up_write(&stp->st_rwsem);
5357 ++ mutex_unlock(&stp->st_mutex);
5358 + nfs4_put_stid(&stp->st_stid);
5359 + out:
5360 + nfsd4_bump_seqid(cstate, status);
5361 +diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h
5362 +index c050c53..c89d7b5 100644
5363 +--- a/fs/nfsd/state.h
5364 ++++ b/fs/nfsd/state.h
5365 +@@ -535,7 +535,7 @@ struct nfs4_ol_stateid {
5366 + unsigned char st_access_bmap;
5367 + unsigned char st_deny_bmap;
5368 + struct nfs4_ol_stateid *st_openstp;
5369 +- struct rw_semaphore st_rwsem;
5370 ++ struct mutex st_mutex;
5371 + };
5372 +
5373 + static inline struct nfs4_ol_stateid *openlockstateid(struct nfs4_stid *s)
5374 +diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
5375 +index b3fc0a3..fb35aa2 100644
5376 +--- a/fs/overlayfs/dir.c
5377 ++++ b/fs/overlayfs/dir.c
5378 +@@ -511,6 +511,7 @@ static int ovl_remove_and_whiteout(struct dentry *dentry, bool is_dir)
5379 + struct dentry *upper;
5380 + struct dentry *opaquedir = NULL;
5381 + int err;
5382 ++ int flags = 0;
5383 +
5384 + if (WARN_ON(!workdir))
5385 + return -EROFS;
5386 +@@ -540,46 +541,39 @@ static int ovl_remove_and_whiteout(struct dentry *dentry, bool is_dir)
5387 + if (err)
5388 + goto out_dput;
5389 +
5390 +- whiteout = ovl_whiteout(workdir, dentry);
5391 +- err = PTR_ERR(whiteout);
5392 +- if (IS_ERR(whiteout))
5393 ++ upper = lookup_one_len(dentry->d_name.name, upperdir,
5394 ++ dentry->d_name.len);
5395 ++ err = PTR_ERR(upper);
5396 ++ if (IS_ERR(upper))
5397 + goto out_unlock;
5398 +
5399 +- upper = ovl_dentry_upper(dentry);
5400 +- if (!upper) {
5401 +- upper = lookup_one_len(dentry->d_name.name, upperdir,
5402 +- dentry->d_name.len);
5403 +- err = PTR_ERR(upper);
5404 +- if (IS_ERR(upper))
5405 +- goto kill_whiteout;
5406 +-
5407 +- err = ovl_do_rename(wdir, whiteout, udir, upper, 0);
5408 +- dput(upper);
5409 +- if (err)
5410 +- goto kill_whiteout;
5411 +- } else {
5412 +- int flags = 0;
5413 ++ err = -ESTALE;
5414 ++ if ((opaquedir && upper != opaquedir) ||
5415 ++ (!opaquedir && ovl_dentry_upper(dentry) &&
5416 ++ upper != ovl_dentry_upper(dentry))) {
5417 ++ goto out_dput_upper;
5418 ++ }
5419 +
5420 +- if (opaquedir)
5421 +- upper = opaquedir;
5422 +- err = -ESTALE;
5423 +- if (upper->d_parent != upperdir)
5424 +- goto kill_whiteout;
5425 ++ whiteout = ovl_whiteout(workdir, dentry);
5426 ++ err = PTR_ERR(whiteout);
5427 ++ if (IS_ERR(whiteout))
5428 ++ goto out_dput_upper;
5429 +
5430 +- if (is_dir)
5431 +- flags |= RENAME_EXCHANGE;
5432 ++ if (d_is_dir(upper))
5433 ++ flags = RENAME_EXCHANGE;
5434 +
5435 +- err = ovl_do_rename(wdir, whiteout, udir, upper, flags);
5436 +- if (err)
5437 +- goto kill_whiteout;
5438 ++ err = ovl_do_rename(wdir, whiteout, udir, upper, flags);
5439 ++ if (err)
5440 ++ goto kill_whiteout;
5441 ++ if (flags)
5442 ++ ovl_cleanup(wdir, upper);
5443 +
5444 +- if (is_dir)
5445 +- ovl_cleanup(wdir, upper);
5446 +- }
5447 + ovl_dentry_version_inc(dentry->d_parent);
5448 + out_d_drop:
5449 + d_drop(dentry);
5450 + dput(whiteout);
5451 ++out_dput_upper:
5452 ++ dput(upper);
5453 + out_unlock:
5454 + unlock_rename(workdir, upperdir);
5455 + out_dput:
5456 +diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
5457 +index a4ff5d0..d46fa60 100644
5458 +--- a/fs/overlayfs/inode.c
5459 ++++ b/fs/overlayfs/inode.c
5460 +@@ -59,16 +59,40 @@ int ovl_setattr(struct dentry *dentry, struct iattr *attr)
5461 + if (err)
5462 + goto out;
5463 +
5464 ++ if (attr->ia_valid & ATTR_SIZE) {
5465 ++ struct inode *realinode = d_inode(ovl_dentry_real(dentry));
5466 ++
5467 ++ err = -ETXTBSY;
5468 ++ if (atomic_read(&realinode->i_writecount) < 0)
5469 ++ goto out_drop_write;
5470 ++ }
5471 ++
5472 + err = ovl_copy_up(dentry);
5473 + if (!err) {
5474 ++ struct inode *winode = NULL;
5475 ++
5476 + upperdentry = ovl_dentry_upper(dentry);
5477 +
5478 ++ if (attr->ia_valid & ATTR_SIZE) {
5479 ++ winode = d_inode(upperdentry);
5480 ++ err = get_write_access(winode);
5481 ++ if (err)
5482 ++ goto out_drop_write;
5483 ++ }
5484 ++
5485 ++ if (attr->ia_valid & (ATTR_KILL_SUID|ATTR_KILL_SGID))
5486 ++ attr->ia_valid &= ~ATTR_MODE;
5487 ++
5488 + inode_lock(upperdentry->d_inode);
5489 + err = notify_change(upperdentry, attr, NULL);
5490 + if (!err)
5491 + ovl_copyattr(upperdentry->d_inode, dentry->d_inode);
5492 + inode_unlock(upperdentry->d_inode);
5493 ++
5494 ++ if (winode)
5495 ++ put_write_access(winode);
5496 + }
5497 ++out_drop_write:
5498 + ovl_drop_write(dentry);
5499 + out:
5500 + return err;
5501 +@@ -121,16 +145,18 @@ int ovl_permission(struct inode *inode, int mask)
5502 +
5503 + err = vfs_getattr(&realpath, &stat);
5504 + if (err)
5505 +- return err;
5506 ++ goto out_dput;
5507 +
5508 ++ err = -ESTALE;
5509 + if ((stat.mode ^ inode->i_mode) & S_IFMT)
5510 +- return -ESTALE;
5511 ++ goto out_dput;
5512 +
5513 + inode->i_mode = stat.mode;
5514 + inode->i_uid = stat.uid;
5515 + inode->i_gid = stat.gid;
5516 +
5517 +- return generic_permission(inode, mask);
5518 ++ err = generic_permission(inode, mask);
5519 ++ goto out_dput;
5520 + }
5521 +
5522 + /* Careful in RCU walk mode */
5523 +@@ -400,12 +426,11 @@ struct inode *ovl_new_inode(struct super_block *sb, umode_t mode,
5524 + if (!inode)
5525 + return NULL;
5526 +
5527 +- mode &= S_IFMT;
5528 +-
5529 + inode->i_ino = get_next_ino();
5530 + inode->i_mode = mode;
5531 + inode->i_flags |= S_NOATIME | S_NOCMTIME;
5532 +
5533 ++ mode &= S_IFMT;
5534 + switch (mode) {
5535 + case S_IFDIR:
5536 + inode->i_private = oe;
5537 +diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h
5538 +index 6a7090f..294ccc0 100644
5539 +--- a/fs/overlayfs/overlayfs.h
5540 ++++ b/fs/overlayfs/overlayfs.h
5541 +@@ -185,6 +185,7 @@ static inline void ovl_copyattr(struct inode *from, struct inode *to)
5542 + {
5543 + to->i_uid = from->i_uid;
5544 + to->i_gid = from->i_gid;
5545 ++ to->i_mode = from->i_mode;
5546 + }
5547 +
5548 + /* dir.c */
5549 +diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
5550 +index 791235e..7952a50f 100644
5551 +--- a/fs/overlayfs/super.c
5552 ++++ b/fs/overlayfs/super.c
5553 +@@ -1064,16 +1064,21 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
5554 + /*
5555 + * Upper should support d_type, else whiteouts are visible.
5556 + * Given workdir and upper are on same fs, we can do
5557 +- * iterate_dir() on workdir.
5558 ++ * iterate_dir() on workdir. This check requires successful
5559 ++ * creation of workdir in previous step.
5560 + */
5561 +- err = ovl_check_d_type_supported(&workpath);
5562 +- if (err < 0)
5563 +- goto out_put_workdir;
5564 ++ if (ufs->workdir) {
5565 ++ err = ovl_check_d_type_supported(&workpath);
5566 ++ if (err < 0)
5567 ++ goto out_put_workdir;
5568 +
5569 +- if (!err) {
5570 +- pr_err("overlayfs: upper fs needs to support d_type.\n");
5571 +- err = -EINVAL;
5572 +- goto out_put_workdir;
5573 ++ /*
5574 ++ * We allowed this configuration and don't want to
5575 ++ * break users over kernel upgrade. So warn instead
5576 ++ * of erroring out.
5577 ++ */
5578 ++ if (!err)
5579 ++ pr_warn("overlayfs: upper fs needs to support d_type.\n");
5580 + }
5581 + }
5582 +
5583 +diff --git a/fs/posix_acl.c b/fs/posix_acl.c
5584 +index 711dd51..e11ea5f 100644
5585 +--- a/fs/posix_acl.c
5586 ++++ b/fs/posix_acl.c
5587 +@@ -786,39 +786,43 @@ posix_acl_xattr_get(const struct xattr_handler *handler,
5588 + return error;
5589 + }
5590 +
5591 +-static int
5592 +-posix_acl_xattr_set(const struct xattr_handler *handler,
5593 +- struct dentry *dentry, const char *name,
5594 +- const void *value, size_t size, int flags)
5595 ++int
5596 ++set_posix_acl(struct inode *inode, int type, struct posix_acl *acl)
5597 + {
5598 +- struct inode *inode = d_backing_inode(dentry);
5599 +- struct posix_acl *acl = NULL;
5600 +- int ret;
5601 +-
5602 + if (!IS_POSIXACL(inode))
5603 + return -EOPNOTSUPP;
5604 + if (!inode->i_op->set_acl)
5605 + return -EOPNOTSUPP;
5606 +
5607 +- if (handler->flags == ACL_TYPE_DEFAULT && !S_ISDIR(inode->i_mode))
5608 +- return value ? -EACCES : 0;
5609 ++ if (type == ACL_TYPE_DEFAULT && !S_ISDIR(inode->i_mode))
5610 ++ return acl ? -EACCES : 0;
5611 + if (!inode_owner_or_capable(inode))
5612 + return -EPERM;
5613 +
5614 ++ if (acl) {
5615 ++ int ret = posix_acl_valid(acl);
5616 ++ if (ret)
5617 ++ return ret;
5618 ++ }
5619 ++ return inode->i_op->set_acl(inode, acl, type);
5620 ++}
5621 ++EXPORT_SYMBOL(set_posix_acl);
5622 ++
5623 ++static int
5624 ++posix_acl_xattr_set(const struct xattr_handler *handler,
5625 ++ struct dentry *dentry, const char *name,
5626 ++ const void *value, size_t size, int flags)
5627 ++{
5628 ++ struct inode *inode = d_backing_inode(dentry);
5629 ++ struct posix_acl *acl = NULL;
5630 ++ int ret;
5631 ++
5632 + if (value) {
5633 + acl = posix_acl_from_xattr(&init_user_ns, value, size);
5634 + if (IS_ERR(acl))
5635 + return PTR_ERR(acl);
5636 +-
5637 +- if (acl) {
5638 +- ret = posix_acl_valid(acl);
5639 +- if (ret)
5640 +- goto out;
5641 +- }
5642 + }
5643 +-
5644 +- ret = inode->i_op->set_acl(inode, acl, handler->flags);
5645 +-out:
5646 ++ ret = set_posix_acl(inode, handler->flags, acl);
5647 + posix_acl_release(acl);
5648 + return ret;
5649 + }
5650 +diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
5651 +index 446753d..5b5ec8d 100644
5652 +--- a/fs/ubifs/file.c
5653 ++++ b/fs/ubifs/file.c
5654 +@@ -52,6 +52,7 @@
5655 + #include "ubifs.h"
5656 + #include <linux/mount.h>
5657 + #include <linux/slab.h>
5658 ++#include <linux/migrate.h>
5659 +
5660 + static int read_block(struct inode *inode, void *addr, unsigned int block,
5661 + struct ubifs_data_node *dn)
5662 +@@ -1452,6 +1453,26 @@ static int ubifs_set_page_dirty(struct page *page)
5663 + return ret;
5664 + }
5665 +
5666 ++#ifdef CONFIG_MIGRATION
5667 ++static int ubifs_migrate_page(struct address_space *mapping,
5668 ++ struct page *newpage, struct page *page, enum migrate_mode mode)
5669 ++{
5670 ++ int rc;
5671 ++
5672 ++ rc = migrate_page_move_mapping(mapping, newpage, page, NULL, mode, 0);
5673 ++ if (rc != MIGRATEPAGE_SUCCESS)
5674 ++ return rc;
5675 ++
5676 ++ if (PagePrivate(page)) {
5677 ++ ClearPagePrivate(page);
5678 ++ SetPagePrivate(newpage);
5679 ++ }
5680 ++
5681 ++ migrate_page_copy(newpage, page);
5682 ++ return MIGRATEPAGE_SUCCESS;
5683 ++}
5684 ++#endif
5685 ++
5686 + static int ubifs_releasepage(struct page *page, gfp_t unused_gfp_flags)
5687 + {
5688 + /*
5689 +@@ -1591,6 +1612,9 @@ const struct address_space_operations ubifs_file_address_operations = {
5690 + .write_end = ubifs_write_end,
5691 + .invalidatepage = ubifs_invalidatepage,
5692 + .set_page_dirty = ubifs_set_page_dirty,
5693 ++#ifdef CONFIG_MIGRATION
5694 ++ .migratepage = ubifs_migrate_page,
5695 ++#endif
5696 + .releasepage = ubifs_releasepage,
5697 + };
5698 +
5699 +diff --git a/include/asm-generic/qspinlock.h b/include/asm-generic/qspinlock.h
5700 +index 6bd0570..05f05f1 100644
5701 +--- a/include/asm-generic/qspinlock.h
5702 ++++ b/include/asm-generic/qspinlock.h
5703 +@@ -22,37 +22,33 @@
5704 + #include <asm-generic/qspinlock_types.h>
5705 +
5706 + /**
5707 ++ * queued_spin_unlock_wait - wait until the _current_ lock holder releases the lock
5708 ++ * @lock : Pointer to queued spinlock structure
5709 ++ *
5710 ++ * There is a very slight possibility of live-lock if the lockers keep coming
5711 ++ * and the waiter is just unfortunate enough to not see any unlock state.
5712 ++ */
5713 ++#ifndef queued_spin_unlock_wait
5714 ++extern void queued_spin_unlock_wait(struct qspinlock *lock);
5715 ++#endif
5716 ++
5717 ++/**
5718 + * queued_spin_is_locked - is the spinlock locked?
5719 + * @lock: Pointer to queued spinlock structure
5720 + * Return: 1 if it is locked, 0 otherwise
5721 + */
5722 ++#ifndef queued_spin_is_locked
5723 + static __always_inline int queued_spin_is_locked(struct qspinlock *lock)
5724 + {
5725 + /*
5726 +- * queued_spin_lock_slowpath() can ACQUIRE the lock before
5727 +- * issuing the unordered store that sets _Q_LOCKED_VAL.
5728 +- *
5729 +- * See both smp_cond_acquire() sites for more detail.
5730 +- *
5731 +- * This however means that in code like:
5732 +- *
5733 +- * spin_lock(A) spin_lock(B)
5734 +- * spin_unlock_wait(B) spin_is_locked(A)
5735 +- * do_something() do_something()
5736 +- *
5737 +- * Both CPUs can end up running do_something() because the store
5738 +- * setting _Q_LOCKED_VAL will pass through the loads in
5739 +- * spin_unlock_wait() and/or spin_is_locked().
5740 ++ * See queued_spin_unlock_wait().
5741 + *
5742 +- * Avoid this by issuing a full memory barrier between the spin_lock()
5743 +- * and the loads in spin_unlock_wait() and spin_is_locked().
5744 +- *
5745 +- * Note that regular mutual exclusion doesn't care about this
5746 +- * delayed store.
5747 ++ * Any !0 state indicates it is locked, even if _Q_LOCKED_VAL
5748 ++ * isn't immediately observable.
5749 + */
5750 +- smp_mb();
5751 +- return atomic_read(&lock->val) & _Q_LOCKED_MASK;
5752 ++ return atomic_read(&lock->val);
5753 + }
5754 ++#endif
5755 +
5756 + /**
5757 + * queued_spin_value_unlocked - is the spinlock structure unlocked?
5758 +@@ -122,21 +118,6 @@ static __always_inline void queued_spin_unlock(struct qspinlock *lock)
5759 + }
5760 + #endif
5761 +
5762 +-/**
5763 +- * queued_spin_unlock_wait - wait until current lock holder releases the lock
5764 +- * @lock : Pointer to queued spinlock structure
5765 +- *
5766 +- * There is a very slight possibility of live-lock if the lockers keep coming
5767 +- * and the waiter is just unfortunate enough to not see any unlock state.
5768 +- */
5769 +-static inline void queued_spin_unlock_wait(struct qspinlock *lock)
5770 +-{
5771 +- /* See queued_spin_is_locked() */
5772 +- smp_mb();
5773 +- while (atomic_read(&lock->val) & _Q_LOCKED_MASK)
5774 +- cpu_relax();
5775 +-}
5776 +-
5777 + #ifndef virt_spin_lock
5778 + static __always_inline bool virt_spin_lock(struct qspinlock *lock)
5779 + {
5780 +diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
5781 +index 055a08d..a74c49d 100644
5782 +--- a/include/drm/ttm/ttm_bo_api.h
5783 ++++ b/include/drm/ttm/ttm_bo_api.h
5784 +@@ -316,6 +316,20 @@ ttm_bo_reference(struct ttm_buffer_object *bo)
5785 + */
5786 + extern int ttm_bo_wait(struct ttm_buffer_object *bo, bool lazy,
5787 + bool interruptible, bool no_wait);
5788 ++
5789 ++/**
5790 ++ * ttm_bo_mem_compat - Check if proposed placement is compatible with a bo
5791 ++ *
5792 ++ * @placement: Return immediately if buffer is busy.
5793 ++ * @mem: The struct ttm_mem_reg indicating the region where the bo resides
5794 ++ * @new_flags: Describes compatible placement found
5795 ++ *
5796 ++ * Returns true if the placement is compatible
5797 ++ */
5798 ++extern bool ttm_bo_mem_compat(struct ttm_placement *placement,
5799 ++ struct ttm_mem_reg *mem,
5800 ++ uint32_t *new_flags);
5801 ++
5802 + /**
5803 + * ttm_bo_validate
5804 + *
5805 +diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
5806 +index 786ad32..07b83d3 100644
5807 +--- a/include/linux/cpuidle.h
5808 ++++ b/include/linux/cpuidle.h
5809 +@@ -152,6 +152,8 @@ extern void cpuidle_disable_device(struct cpuidle_device *dev);
5810 + extern int cpuidle_play_dead(void);
5811 +
5812 + extern struct cpuidle_driver *cpuidle_get_cpu_driver(struct cpuidle_device *dev);
5813 ++static inline struct cpuidle_device *cpuidle_get_device(void)
5814 ++{return __this_cpu_read(cpuidle_devices); }
5815 + #else
5816 + static inline void disable_cpuidle(void) { }
5817 + static inline bool cpuidle_not_available(struct cpuidle_driver *drv,
5818 +@@ -187,6 +189,7 @@ static inline void cpuidle_disable_device(struct cpuidle_device *dev) { }
5819 + static inline int cpuidle_play_dead(void) {return -ENODEV; }
5820 + static inline struct cpuidle_driver *cpuidle_get_cpu_driver(
5821 + struct cpuidle_device *dev) {return NULL; }
5822 ++static inline struct cpuidle_device *cpuidle_get_device(void) {return NULL; }
5823 + #endif
5824 +
5825 + #if defined(CONFIG_CPU_IDLE) && defined(CONFIG_SUSPEND)
5826 +diff --git a/include/linux/dcache.h b/include/linux/dcache.h
5827 +index 7e9422c..ad5d582 100644
5828 +--- a/include/linux/dcache.h
5829 ++++ b/include/linux/dcache.h
5830 +@@ -576,5 +576,17 @@ static inline struct inode *vfs_select_inode(struct dentry *dentry,
5831 + return inode;
5832 + }
5833 +
5834 ++/**
5835 ++ * d_real_inode - Return the real inode
5836 ++ * @dentry: The dentry to query
5837 ++ *
5838 ++ * If dentry is on an union/overlay, then return the underlying, real inode.
5839 ++ * Otherwise return d_inode().
5840 ++ */
5841 ++static inline struct inode *d_real_inode(struct dentry *dentry)
5842 ++{
5843 ++ return d_backing_inode(d_real(dentry));
5844 ++}
5845 ++
5846 +
5847 + #endif /* __LINUX_DCACHE_H */
5848 +diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h
5849 +index 0536524..6890446 100644
5850 +--- a/include/linux/jump_label.h
5851 ++++ b/include/linux/jump_label.h
5852 +@@ -117,13 +117,18 @@ struct module;
5853 +
5854 + #include <linux/atomic.h>
5855 +
5856 ++#ifdef HAVE_JUMP_LABEL
5857 ++
5858 + static inline int static_key_count(struct static_key *key)
5859 + {
5860 +- return atomic_read(&key->enabled);
5861 ++ /*
5862 ++ * -1 means the first static_key_slow_inc() is in progress.
5863 ++ * static_key_enabled() must return true, so return 1 here.
5864 ++ */
5865 ++ int n = atomic_read(&key->enabled);
5866 ++ return n >= 0 ? n : 1;
5867 + }
5868 +
5869 +-#ifdef HAVE_JUMP_LABEL
5870 +-
5871 + #define JUMP_TYPE_FALSE 0UL
5872 + #define JUMP_TYPE_TRUE 1UL
5873 + #define JUMP_TYPE_MASK 1UL
5874 +@@ -162,6 +167,11 @@ extern void jump_label_apply_nops(struct module *mod);
5875 +
5876 + #else /* !HAVE_JUMP_LABEL */
5877 +
5878 ++static inline int static_key_count(struct static_key *key)
5879 ++{
5880 ++ return atomic_read(&key->enabled);
5881 ++}
5882 ++
5883 + static __always_inline void jump_label_init(void)
5884 + {
5885 + static_key_initialized = true;
5886 +diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
5887 +index 15d0df9..794b924 100644
5888 +--- a/include/linux/skbuff.h
5889 ++++ b/include/linux/skbuff.h
5890 +@@ -1062,6 +1062,7 @@ __skb_set_sw_hash(struct sk_buff *skb, __u32 hash, bool is_l4)
5891 + }
5892 +
5893 + void __skb_get_hash(struct sk_buff *skb);
5894 ++u32 __skb_get_hash_symmetric(struct sk_buff *skb);
5895 + u32 skb_get_poff(const struct sk_buff *skb);
5896 + u32 __skb_get_poff(const struct sk_buff *skb, void *data,
5897 + const struct flow_keys *keys, int hlen);
5898 +@@ -2860,6 +2861,25 @@ static inline void skb_postpush_rcsum(struct sk_buff *skb,
5899 + }
5900 +
5901 + /**
5902 ++ * skb_push_rcsum - push skb and update receive checksum
5903 ++ * @skb: buffer to update
5904 ++ * @len: length of data pulled
5905 ++ *
5906 ++ * This function performs an skb_push on the packet and updates
5907 ++ * the CHECKSUM_COMPLETE checksum. It should be used on
5908 ++ * receive path processing instead of skb_push unless you know
5909 ++ * that the checksum difference is zero (e.g., a valid IP header)
5910 ++ * or you are setting ip_summed to CHECKSUM_NONE.
5911 ++ */
5912 ++static inline unsigned char *skb_push_rcsum(struct sk_buff *skb,
5913 ++ unsigned int len)
5914 ++{
5915 ++ skb_push(skb, len);
5916 ++ skb_postpush_rcsum(skb, skb->data, len);
5917 ++ return skb->data;
5918 ++}
5919 ++
5920 ++/**
5921 + * pskb_trim_rcsum - trim received skb and update checksum
5922 + * @skb: buffer to trim
5923 + * @len: new length
5924 +diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
5925 +index 9a7ddba..14d70f5 100644
5926 +--- a/include/linux/sunrpc/clnt.h
5927 ++++ b/include/linux/sunrpc/clnt.h
5928 +@@ -137,8 +137,6 @@ struct rpc_create_args {
5929 + #define RPC_CLNT_CREATE_NO_RETRANS_TIMEOUT (1UL << 9)
5930 +
5931 + struct rpc_clnt *rpc_create(struct rpc_create_args *args);
5932 +-struct rpc_clnt *rpc_create_xprt(struct rpc_create_args *args,
5933 +- struct rpc_xprt *xprt);
5934 + struct rpc_clnt *rpc_bind_new_program(struct rpc_clnt *,
5935 + const struct rpc_program *, u32);
5936 + struct rpc_clnt *rpc_clone_client(struct rpc_clnt *);
5937 +diff --git a/include/linux/sunrpc/svc_xprt.h b/include/linux/sunrpc/svc_xprt.h
5938 +index b7dabc4..79ba508 100644
5939 +--- a/include/linux/sunrpc/svc_xprt.h
5940 ++++ b/include/linux/sunrpc/svc_xprt.h
5941 +@@ -84,6 +84,7 @@ struct svc_xprt {
5942 +
5943 + struct net *xpt_net;
5944 + struct rpc_xprt *xpt_bc_xprt; /* NFSv4.1 backchannel */
5945 ++ struct rpc_xprt_switch *xpt_bc_xps; /* NFSv4.1 backchannel */
5946 + };
5947 +
5948 + static inline void unregister_xpt_user(struct svc_xprt *xpt, struct svc_xpt_user *u)
5949 +diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h
5950 +index fb0d212..9f51e1d 100644
5951 +--- a/include/linux/sunrpc/xprt.h
5952 ++++ b/include/linux/sunrpc/xprt.h
5953 +@@ -296,6 +296,7 @@ struct xprt_create {
5954 + size_t addrlen;
5955 + const char *servername;
5956 + struct svc_xprt *bc_xprt; /* NFSv4.1 backchannel */
5957 ++ struct rpc_xprt_switch *bc_xps;
5958 + unsigned int flags;
5959 + };
5960 +
5961 +diff --git a/include/linux/usb/ehci_def.h b/include/linux/usb/ehci_def.h
5962 +index 966889a..e479033 100644
5963 +--- a/include/linux/usb/ehci_def.h
5964 ++++ b/include/linux/usb/ehci_def.h
5965 +@@ -180,11 +180,11 @@ struct ehci_regs {
5966 + * PORTSCx
5967 + */
5968 + /* HOSTPC: offset 0x84 */
5969 +- u32 hostpc[1]; /* HOSTPC extension */
5970 ++ u32 hostpc[0]; /* HOSTPC extension */
5971 + #define HOSTPC_PHCD (1<<22) /* Phy clock disable */
5972 + #define HOSTPC_PSPD (3<<25) /* Port speed detection */
5973 +
5974 +- u32 reserved5[16];
5975 ++ u32 reserved5[17];
5976 +
5977 + /* USBMODE_EX: offset 0xc8 */
5978 + u32 usbmode_ex; /* USB Device mode extension */
5979 +diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
5980 +index fb2cef4..b8334a6 100644
5981 +--- a/include/rdma/ib_verbs.h
5982 ++++ b/include/rdma/ib_verbs.h
5983 +@@ -217,7 +217,7 @@ enum ib_device_cap_flags {
5984 + IB_DEVICE_CROSS_CHANNEL = (1 << 27),
5985 + IB_DEVICE_MANAGED_FLOW_STEERING = (1 << 29),
5986 + IB_DEVICE_SIGNATURE_HANDOVER = (1 << 30),
5987 +- IB_DEVICE_ON_DEMAND_PAGING = (1 << 31),
5988 ++ IB_DEVICE_ON_DEMAND_PAGING = (1ULL << 31),
5989 + IB_DEVICE_SG_GAPS_REG = (1ULL << 32),
5990 + IB_DEVICE_VIRTUAL_FUNCTION = ((u64)1 << 33),
5991 + };
5992 +diff --git a/include/rdma/rdma_vt.h b/include/rdma/rdma_vt.h
5993 +index a869655..6ee9d97 100644
5994 +--- a/include/rdma/rdma_vt.h
5995 ++++ b/include/rdma/rdma_vt.h
5996 +@@ -203,7 +203,9 @@ struct rvt_driver_provided {
5997 +
5998 + /*
5999 + * Allocate a private queue pair data structure for driver specific
6000 +- * information which is opaque to rdmavt.
6001 ++ * information which is opaque to rdmavt. Errors are returned via
6002 ++ * ERR_PTR(err). The driver is free to return NULL or a valid
6003 ++ * pointer.
6004 + */
6005 + void * (*qp_priv_alloc)(struct rvt_dev_info *rdi, struct rvt_qp *qp,
6006 + gfp_t gfp);
6007 +diff --git a/kernel/futex.c b/kernel/futex.c
6008 +index c20f06f..6555d54 100644
6009 +--- a/kernel/futex.c
6010 ++++ b/kernel/futex.c
6011 +@@ -469,7 +469,7 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
6012 + {
6013 + unsigned long address = (unsigned long)uaddr;
6014 + struct mm_struct *mm = current->mm;
6015 +- struct page *page;
6016 ++ struct page *page, *tail;
6017 + struct address_space *mapping;
6018 + int err, ro = 0;
6019 +
6020 +@@ -530,7 +530,15 @@ again:
6021 + * considered here and page lock forces unnecessarily serialization
6022 + * From this point on, mapping will be re-verified if necessary and
6023 + * page lock will be acquired only if it is unavoidable
6024 +- */
6025 ++ *
6026 ++ * Mapping checks require the head page for any compound page so the
6027 ++ * head page and mapping is looked up now. For anonymous pages, it
6028 ++ * does not matter if the page splits in the future as the key is
6029 ++ * based on the address. For filesystem-backed pages, the tail is
6030 ++ * required as the index of the page determines the key. For
6031 ++ * base pages, there is no tail page and tail == page.
6032 ++ */
6033 ++ tail = page;
6034 + page = compound_head(page);
6035 + mapping = READ_ONCE(page->mapping);
6036 +
6037 +@@ -654,7 +662,7 @@ again:
6038 +
6039 + key->both.offset |= FUT_OFF_INODE; /* inode-based key */
6040 + key->shared.inode = inode;
6041 +- key->shared.pgoff = basepage_index(page);
6042 ++ key->shared.pgoff = basepage_index(tail);
6043 + rcu_read_unlock();
6044 + }
6045 +
6046 +diff --git a/kernel/jump_label.c b/kernel/jump_label.c
6047 +index 05254ee..4b353e0 100644
6048 +--- a/kernel/jump_label.c
6049 ++++ b/kernel/jump_label.c
6050 +@@ -58,13 +58,36 @@ static void jump_label_update(struct static_key *key);
6051 +
6052 + void static_key_slow_inc(struct static_key *key)
6053 + {
6054 ++ int v, v1;
6055 ++
6056 + STATIC_KEY_CHECK_USE();
6057 +- if (atomic_inc_not_zero(&key->enabled))
6058 +- return;
6059 ++
6060 ++ /*
6061 ++ * Careful if we get concurrent static_key_slow_inc() calls;
6062 ++ * later calls must wait for the first one to _finish_ the
6063 ++ * jump_label_update() process. At the same time, however,
6064 ++ * the jump_label_update() call below wants to see
6065 ++ * static_key_enabled(&key) for jumps to be updated properly.
6066 ++ *
6067 ++ * So give a special meaning to negative key->enabled: it sends
6068 ++ * static_key_slow_inc() down the slow path, and it is non-zero
6069 ++ * so it counts as "enabled" in jump_label_update(). Note that
6070 ++ * atomic_inc_unless_negative() checks >= 0, so roll our own.
6071 ++ */
6072 ++ for (v = atomic_read(&key->enabled); v > 0; v = v1) {
6073 ++ v1 = atomic_cmpxchg(&key->enabled, v, v + 1);
6074 ++ if (likely(v1 == v))
6075 ++ return;
6076 ++ }
6077 +
6078 + jump_label_lock();
6079 +- if (atomic_inc_return(&key->enabled) == 1)
6080 ++ if (atomic_read(&key->enabled) == 0) {
6081 ++ atomic_set(&key->enabled, -1);
6082 + jump_label_update(key);
6083 ++ atomic_set(&key->enabled, 1);
6084 ++ } else {
6085 ++ atomic_inc(&key->enabled);
6086 ++ }
6087 + jump_label_unlock();
6088 + }
6089 + EXPORT_SYMBOL_GPL(static_key_slow_inc);
6090 +@@ -72,6 +95,13 @@ EXPORT_SYMBOL_GPL(static_key_slow_inc);
6091 + static void __static_key_slow_dec(struct static_key *key,
6092 + unsigned long rate_limit, struct delayed_work *work)
6093 + {
6094 ++ /*
6095 ++ * The negative count check is valid even when a negative
6096 ++ * key->enabled is in use by static_key_slow_inc(); a
6097 ++ * __static_key_slow_dec() before the first static_key_slow_inc()
6098 ++ * returns is unbalanced, because all other static_key_slow_inc()
6099 ++ * instances block while the update is in progress.
6100 ++ */
6101 + if (!atomic_dec_and_mutex_lock(&key->enabled, &jump_label_mutex)) {
6102 + WARN(atomic_read(&key->enabled) < 0,
6103 + "jump label: negative count!\n");
6104 +diff --git a/kernel/locking/mutex.c b/kernel/locking/mutex.c
6105 +index e364b42..79d2d76 100644
6106 +--- a/kernel/locking/mutex.c
6107 ++++ b/kernel/locking/mutex.c
6108 +@@ -486,9 +486,6 @@ __ww_mutex_lock_check_stamp(struct mutex *lock, struct ww_acquire_ctx *ctx)
6109 + if (!hold_ctx)
6110 + return 0;
6111 +
6112 +- if (unlikely(ctx == hold_ctx))
6113 +- return -EALREADY;
6114 +-
6115 + if (ctx->stamp - hold_ctx->stamp <= LONG_MAX &&
6116 + (ctx->stamp != hold_ctx->stamp || ctx > hold_ctx)) {
6117 + #ifdef CONFIG_DEBUG_MUTEXES
6118 +@@ -514,6 +511,12 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
6119 + unsigned long flags;
6120 + int ret;
6121 +
6122 ++ if (use_ww_ctx) {
6123 ++ struct ww_mutex *ww = container_of(lock, struct ww_mutex, base);
6124 ++ if (unlikely(ww_ctx == READ_ONCE(ww->ctx)))
6125 ++ return -EALREADY;
6126 ++ }
6127 ++
6128 + preempt_disable();
6129 + mutex_acquire_nest(&lock->dep_map, subclass, 0, nest_lock, ip);
6130 +
6131 +diff --git a/kernel/locking/qspinlock.c b/kernel/locking/qspinlock.c
6132 +index ce2f75e..5fc8c31 100644
6133 +--- a/kernel/locking/qspinlock.c
6134 ++++ b/kernel/locking/qspinlock.c
6135 +@@ -267,6 +267,66 @@ static __always_inline u32 __pv_wait_head_or_lock(struct qspinlock *lock,
6136 + #define queued_spin_lock_slowpath native_queued_spin_lock_slowpath
6137 + #endif
6138 +
6139 ++/*
6140 ++ * queued_spin_lock_slowpath() can (load-)ACQUIRE the lock before
6141 ++ * issuing an _unordered_ store to set _Q_LOCKED_VAL.
6142 ++ *
6143 ++ * This means that the store can be delayed, but no later than the
6144 ++ * store-release from the unlock. This means that simply observing
6145 ++ * _Q_LOCKED_VAL is not sufficient to determine if the lock is acquired.
6146 ++ *
6147 ++ * There are two paths that can issue the unordered store:
6148 ++ *
6149 ++ * (1) clear_pending_set_locked(): *,1,0 -> *,0,1
6150 ++ *
6151 ++ * (2) set_locked(): t,0,0 -> t,0,1 ; t != 0
6152 ++ * atomic_cmpxchg_relaxed(): t,0,0 -> 0,0,1
6153 ++ *
6154 ++ * However, in both cases we have other !0 state we've set before to queue
6155 ++ * ourseves:
6156 ++ *
6157 ++ * For (1) we have the atomic_cmpxchg_acquire() that set _Q_PENDING_VAL, our
6158 ++ * load is constrained by that ACQUIRE to not pass before that, and thus must
6159 ++ * observe the store.
6160 ++ *
6161 ++ * For (2) we have a more intersting scenario. We enqueue ourselves using
6162 ++ * xchg_tail(), which ends up being a RELEASE. This in itself is not
6163 ++ * sufficient, however that is followed by an smp_cond_acquire() on the same
6164 ++ * word, giving a RELEASE->ACQUIRE ordering. This again constrains our load and
6165 ++ * guarantees we must observe that store.
6166 ++ *
6167 ++ * Therefore both cases have other !0 state that is observable before the
6168 ++ * unordered locked byte store comes through. This means we can use that to
6169 ++ * wait for the lock store, and then wait for an unlock.
6170 ++ */
6171 ++#ifndef queued_spin_unlock_wait
6172 ++void queued_spin_unlock_wait(struct qspinlock *lock)
6173 ++{
6174 ++ u32 val;
6175 ++
6176 ++ for (;;) {
6177 ++ val = atomic_read(&lock->val);
6178 ++
6179 ++ if (!val) /* not locked, we're done */
6180 ++ goto done;
6181 ++
6182 ++ if (val & _Q_LOCKED_MASK) /* locked, go wait for unlock */
6183 ++ break;
6184 ++
6185 ++ /* not locked, but pending, wait until we observe the lock */
6186 ++ cpu_relax();
6187 ++ }
6188 ++
6189 ++ /* any unlock is good */
6190 ++ while (atomic_read(&lock->val) & _Q_LOCKED_MASK)
6191 ++ cpu_relax();
6192 ++
6193 ++done:
6194 ++ smp_rmb(); /* CTRL + RMB -> ACQUIRE */
6195 ++}
6196 ++EXPORT_SYMBOL(queued_spin_unlock_wait);
6197 ++#endif
6198 ++
6199 + #endif /* _GEN_PV_LOCK_SLOWPATH */
6200 +
6201 + /**
6202 +diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
6203 +index e7dd0ec..eeaf920 100644
6204 +--- a/kernel/sched/fair.c
6205 ++++ b/kernel/sched/fair.c
6206 +@@ -2821,6 +2821,23 @@ static inline void update_tg_load_avg(struct cfs_rq *cfs_rq, int force) {}
6207 +
6208 + static inline u64 cfs_rq_clock_task(struct cfs_rq *cfs_rq);
6209 +
6210 ++/*
6211 ++ * Unsigned subtract and clamp on underflow.
6212 ++ *
6213 ++ * Explicitly do a load-store to ensure the intermediate value never hits
6214 ++ * memory. This allows lockless observations without ever seeing the negative
6215 ++ * values.
6216 ++ */
6217 ++#define sub_positive(_ptr, _val) do { \
6218 ++ typeof(_ptr) ptr = (_ptr); \
6219 ++ typeof(*ptr) val = (_val); \
6220 ++ typeof(*ptr) res, var = READ_ONCE(*ptr); \
6221 ++ res = var - val; \
6222 ++ if (res > var) \
6223 ++ res = 0; \
6224 ++ WRITE_ONCE(*ptr, res); \
6225 ++} while (0)
6226 ++
6227 + /* Group cfs_rq's load_avg is used for task_h_load and update_cfs_share */
6228 + static inline int update_cfs_rq_load_avg(u64 now, struct cfs_rq *cfs_rq)
6229 + {
6230 +@@ -2829,15 +2846,15 @@ static inline int update_cfs_rq_load_avg(u64 now, struct cfs_rq *cfs_rq)
6231 +
6232 + if (atomic_long_read(&cfs_rq->removed_load_avg)) {
6233 + s64 r = atomic_long_xchg(&cfs_rq->removed_load_avg, 0);
6234 +- sa->load_avg = max_t(long, sa->load_avg - r, 0);
6235 +- sa->load_sum = max_t(s64, sa->load_sum - r * LOAD_AVG_MAX, 0);
6236 ++ sub_positive(&sa->load_avg, r);
6237 ++ sub_positive(&sa->load_sum, r * LOAD_AVG_MAX);
6238 + removed = 1;
6239 + }
6240 +
6241 + if (atomic_long_read(&cfs_rq->removed_util_avg)) {
6242 + long r = atomic_long_xchg(&cfs_rq->removed_util_avg, 0);
6243 +- sa->util_avg = max_t(long, sa->util_avg - r, 0);
6244 +- sa->util_sum = max_t(s32, sa->util_sum - r * LOAD_AVG_MAX, 0);
6245 ++ sub_positive(&sa->util_avg, r);
6246 ++ sub_positive(&sa->util_sum, r * LOAD_AVG_MAX);
6247 + }
6248 +
6249 + decayed = __update_load_avg(now, cpu_of(rq_of(cfs_rq)), sa,
6250 +@@ -2927,10 +2944,10 @@ static void detach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *s
6251 + &se->avg, se->on_rq * scale_load_down(se->load.weight),
6252 + cfs_rq->curr == se, NULL);
6253 +
6254 +- cfs_rq->avg.load_avg = max_t(long, cfs_rq->avg.load_avg - se->avg.load_avg, 0);
6255 +- cfs_rq->avg.load_sum = max_t(s64, cfs_rq->avg.load_sum - se->avg.load_sum, 0);
6256 +- cfs_rq->avg.util_avg = max_t(long, cfs_rq->avg.util_avg - se->avg.util_avg, 0);
6257 +- cfs_rq->avg.util_sum = max_t(s32, cfs_rq->avg.util_sum - se->avg.util_sum, 0);
6258 ++ sub_positive(&cfs_rq->avg.load_avg, se->avg.load_avg);
6259 ++ sub_positive(&cfs_rq->avg.load_sum, se->avg.load_sum);
6260 ++ sub_positive(&cfs_rq->avg.util_avg, se->avg.util_avg);
6261 ++ sub_positive(&cfs_rq->avg.util_sum, se->avg.util_sum);
6262 + }
6263 +
6264 + /* Add the load generated by se into cfs_rq's load average */
6265 +diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c
6266 +index bd12c6c..c5aeedf 100644
6267 +--- a/kernel/sched/idle.c
6268 ++++ b/kernel/sched/idle.c
6269 +@@ -127,7 +127,7 @@ static int call_cpuidle(struct cpuidle_driver *drv, struct cpuidle_device *dev,
6270 + */
6271 + static void cpuidle_idle_call(void)
6272 + {
6273 +- struct cpuidle_device *dev = __this_cpu_read(cpuidle_devices);
6274 ++ struct cpuidle_device *dev = cpuidle_get_device();
6275 + struct cpuidle_driver *drv = cpuidle_get_cpu_driver(dev);
6276 + int next_state, entered_state;
6277 +
6278 +diff --git a/kernel/trace/trace_printk.c b/kernel/trace/trace_printk.c
6279 +index f96f038..ad1d616 100644
6280 +--- a/kernel/trace/trace_printk.c
6281 ++++ b/kernel/trace/trace_printk.c
6282 +@@ -36,6 +36,10 @@ struct trace_bprintk_fmt {
6283 + static inline struct trace_bprintk_fmt *lookup_format(const char *fmt)
6284 + {
6285 + struct trace_bprintk_fmt *pos;
6286 ++
6287 ++ if (!fmt)
6288 ++ return ERR_PTR(-EINVAL);
6289 ++
6290 + list_for_each_entry(pos, &trace_bprintk_fmt_list, list) {
6291 + if (!strcmp(pos->fmt, fmt))
6292 + return pos;
6293 +@@ -57,7 +61,8 @@ void hold_module_trace_bprintk_format(const char **start, const char **end)
6294 + for (iter = start; iter < end; iter++) {
6295 + struct trace_bprintk_fmt *tb_fmt = lookup_format(*iter);
6296 + if (tb_fmt) {
6297 +- *iter = tb_fmt->fmt;
6298 ++ if (!IS_ERR(tb_fmt))
6299 ++ *iter = tb_fmt->fmt;
6300 + continue;
6301 + }
6302 +
6303 +diff --git a/mm/migrate.c b/mm/migrate.c
6304 +index f9dfb18..bdf3410 100644
6305 +--- a/mm/migrate.c
6306 ++++ b/mm/migrate.c
6307 +@@ -431,6 +431,7 @@ int migrate_page_move_mapping(struct address_space *mapping,
6308 +
6309 + return MIGRATEPAGE_SUCCESS;
6310 + }
6311 ++EXPORT_SYMBOL(migrate_page_move_mapping);
6312 +
6313 + /*
6314 + * The expected number of remaining references is the same as that
6315 +@@ -586,6 +587,7 @@ void migrate_page_copy(struct page *newpage, struct page *page)
6316 +
6317 + mem_cgroup_migrate(page, newpage);
6318 + }
6319 ++EXPORT_SYMBOL(migrate_page_copy);
6320 +
6321 + /************************************************************
6322 + * Migration functions
6323 +diff --git a/mm/page-writeback.c b/mm/page-writeback.c
6324 +index bc5149d..e389f0a 100644
6325 +--- a/mm/page-writeback.c
6326 ++++ b/mm/page-writeback.c
6327 +@@ -369,8 +369,9 @@ static void domain_dirty_limits(struct dirty_throttle_control *dtc)
6328 + struct dirty_throttle_control *gdtc = mdtc_gdtc(dtc);
6329 + unsigned long bytes = vm_dirty_bytes;
6330 + unsigned long bg_bytes = dirty_background_bytes;
6331 +- unsigned long ratio = vm_dirty_ratio;
6332 +- unsigned long bg_ratio = dirty_background_ratio;
6333 ++ /* convert ratios to per-PAGE_SIZE for higher precision */
6334 ++ unsigned long ratio = (vm_dirty_ratio * PAGE_SIZE) / 100;
6335 ++ unsigned long bg_ratio = (dirty_background_ratio * PAGE_SIZE) / 100;
6336 + unsigned long thresh;
6337 + unsigned long bg_thresh;
6338 + struct task_struct *tsk;
6339 +@@ -382,26 +383,28 @@ static void domain_dirty_limits(struct dirty_throttle_control *dtc)
6340 + /*
6341 + * The byte settings can't be applied directly to memcg
6342 + * domains. Convert them to ratios by scaling against
6343 +- * globally available memory.
6344 ++ * globally available memory. As the ratios are in
6345 ++ * per-PAGE_SIZE, they can be obtained by dividing bytes by
6346 ++ * number of pages.
6347 + */
6348 + if (bytes)
6349 +- ratio = min(DIV_ROUND_UP(bytes, PAGE_SIZE) * 100 /
6350 +- global_avail, 100UL);
6351 ++ ratio = min(DIV_ROUND_UP(bytes, global_avail),
6352 ++ PAGE_SIZE);
6353 + if (bg_bytes)
6354 +- bg_ratio = min(DIV_ROUND_UP(bg_bytes, PAGE_SIZE) * 100 /
6355 +- global_avail, 100UL);
6356 ++ bg_ratio = min(DIV_ROUND_UP(bg_bytes, global_avail),
6357 ++ PAGE_SIZE);
6358 + bytes = bg_bytes = 0;
6359 + }
6360 +
6361 + if (bytes)
6362 + thresh = DIV_ROUND_UP(bytes, PAGE_SIZE);
6363 + else
6364 +- thresh = (ratio * available_memory) / 100;
6365 ++ thresh = (ratio * available_memory) / PAGE_SIZE;
6366 +
6367 + if (bg_bytes)
6368 + bg_thresh = DIV_ROUND_UP(bg_bytes, PAGE_SIZE);
6369 + else
6370 +- bg_thresh = (bg_ratio * available_memory) / 100;
6371 ++ bg_thresh = (bg_ratio * available_memory) / PAGE_SIZE;
6372 +
6373 + if (bg_thresh >= thresh)
6374 + bg_thresh = thresh / 2;
6375 +diff --git a/mm/percpu.c b/mm/percpu.c
6376 +index 0c59684..9903830 100644
6377 +--- a/mm/percpu.c
6378 ++++ b/mm/percpu.c
6379 +@@ -112,7 +112,7 @@ struct pcpu_chunk {
6380 + int map_used; /* # of map entries used before the sentry */
6381 + int map_alloc; /* # of map entries allocated */
6382 + int *map; /* allocation map */
6383 +- struct work_struct map_extend_work;/* async ->map[] extension */
6384 ++ struct list_head map_extend_list;/* on pcpu_map_extend_chunks */
6385 +
6386 + void *data; /* chunk data */
6387 + int first_free; /* no free below this */
6388 +@@ -162,10 +162,13 @@ static struct pcpu_chunk *pcpu_reserved_chunk;
6389 + static int pcpu_reserved_chunk_limit;
6390 +
6391 + static DEFINE_SPINLOCK(pcpu_lock); /* all internal data structures */
6392 +-static DEFINE_MUTEX(pcpu_alloc_mutex); /* chunk create/destroy, [de]pop */
6393 ++static DEFINE_MUTEX(pcpu_alloc_mutex); /* chunk create/destroy, [de]pop, map ext */
6394 +
6395 + static struct list_head *pcpu_slot __read_mostly; /* chunk list slots */
6396 +
6397 ++/* chunks which need their map areas extended, protected by pcpu_lock */
6398 ++static LIST_HEAD(pcpu_map_extend_chunks);
6399 ++
6400 + /*
6401 + * The number of empty populated pages, protected by pcpu_lock. The
6402 + * reserved chunk doesn't contribute to the count.
6403 +@@ -395,13 +398,19 @@ static int pcpu_need_to_extend(struct pcpu_chunk *chunk, bool is_atomic)
6404 + {
6405 + int margin, new_alloc;
6406 +
6407 ++ lockdep_assert_held(&pcpu_lock);
6408 ++
6409 + if (is_atomic) {
6410 + margin = 3;
6411 +
6412 + if (chunk->map_alloc <
6413 +- chunk->map_used + PCPU_ATOMIC_MAP_MARGIN_LOW &&
6414 +- pcpu_async_enabled)
6415 +- schedule_work(&chunk->map_extend_work);
6416 ++ chunk->map_used + PCPU_ATOMIC_MAP_MARGIN_LOW) {
6417 ++ if (list_empty(&chunk->map_extend_list)) {
6418 ++ list_add_tail(&chunk->map_extend_list,
6419 ++ &pcpu_map_extend_chunks);
6420 ++ pcpu_schedule_balance_work();
6421 ++ }
6422 ++ }
6423 + } else {
6424 + margin = PCPU_ATOMIC_MAP_MARGIN_HIGH;
6425 + }
6426 +@@ -435,6 +444,8 @@ static int pcpu_extend_area_map(struct pcpu_chunk *chunk, int new_alloc)
6427 + size_t old_size = 0, new_size = new_alloc * sizeof(new[0]);
6428 + unsigned long flags;
6429 +
6430 ++ lockdep_assert_held(&pcpu_alloc_mutex);
6431 ++
6432 + new = pcpu_mem_zalloc(new_size);
6433 + if (!new)
6434 + return -ENOMEM;
6435 +@@ -467,20 +478,6 @@ out_unlock:
6436 + return 0;
6437 + }
6438 +
6439 +-static void pcpu_map_extend_workfn(struct work_struct *work)
6440 +-{
6441 +- struct pcpu_chunk *chunk = container_of(work, struct pcpu_chunk,
6442 +- map_extend_work);
6443 +- int new_alloc;
6444 +-
6445 +- spin_lock_irq(&pcpu_lock);
6446 +- new_alloc = pcpu_need_to_extend(chunk, false);
6447 +- spin_unlock_irq(&pcpu_lock);
6448 +-
6449 +- if (new_alloc)
6450 +- pcpu_extend_area_map(chunk, new_alloc);
6451 +-}
6452 +-
6453 + /**
6454 + * pcpu_fit_in_area - try to fit the requested allocation in a candidate area
6455 + * @chunk: chunk the candidate area belongs to
6456 +@@ -740,7 +737,7 @@ static struct pcpu_chunk *pcpu_alloc_chunk(void)
6457 + chunk->map_used = 1;
6458 +
6459 + INIT_LIST_HEAD(&chunk->list);
6460 +- INIT_WORK(&chunk->map_extend_work, pcpu_map_extend_workfn);
6461 ++ INIT_LIST_HEAD(&chunk->map_extend_list);
6462 + chunk->free_size = pcpu_unit_size;
6463 + chunk->contig_hint = pcpu_unit_size;
6464 +
6465 +@@ -895,6 +892,9 @@ static void __percpu *pcpu_alloc(size_t size, size_t align, bool reserved,
6466 + return NULL;
6467 + }
6468 +
6469 ++ if (!is_atomic)
6470 ++ mutex_lock(&pcpu_alloc_mutex);
6471 ++
6472 + spin_lock_irqsave(&pcpu_lock, flags);
6473 +
6474 + /* serve reserved allocations from the reserved chunk if available */
6475 +@@ -967,12 +967,9 @@ restart:
6476 + if (is_atomic)
6477 + goto fail;
6478 +
6479 +- mutex_lock(&pcpu_alloc_mutex);
6480 +-
6481 + if (list_empty(&pcpu_slot[pcpu_nr_slots - 1])) {
6482 + chunk = pcpu_create_chunk();
6483 + if (!chunk) {
6484 +- mutex_unlock(&pcpu_alloc_mutex);
6485 + err = "failed to allocate new chunk";
6486 + goto fail;
6487 + }
6488 +@@ -983,7 +980,6 @@ restart:
6489 + spin_lock_irqsave(&pcpu_lock, flags);
6490 + }
6491 +
6492 +- mutex_unlock(&pcpu_alloc_mutex);
6493 + goto restart;
6494 +
6495 + area_found:
6496 +@@ -993,8 +989,6 @@ area_found:
6497 + if (!is_atomic) {
6498 + int page_start, page_end, rs, re;
6499 +
6500 +- mutex_lock(&pcpu_alloc_mutex);
6501 +-
6502 + page_start = PFN_DOWN(off);
6503 + page_end = PFN_UP(off + size);
6504 +
6505 +@@ -1005,7 +999,6 @@ area_found:
6506 +
6507 + spin_lock_irqsave(&pcpu_lock, flags);
6508 + if (ret) {
6509 +- mutex_unlock(&pcpu_alloc_mutex);
6510 + pcpu_free_area(chunk, off, &occ_pages);
6511 + err = "failed to populate";
6512 + goto fail_unlock;
6513 +@@ -1045,6 +1038,8 @@ fail:
6514 + /* see the flag handling in pcpu_blance_workfn() */
6515 + pcpu_atomic_alloc_failed = true;
6516 + pcpu_schedule_balance_work();
6517 ++ } else {
6518 ++ mutex_unlock(&pcpu_alloc_mutex);
6519 + }
6520 + return NULL;
6521 + }
6522 +@@ -1129,6 +1124,7 @@ static void pcpu_balance_workfn(struct work_struct *work)
6523 + if (chunk == list_first_entry(free_head, struct pcpu_chunk, list))
6524 + continue;
6525 +
6526 ++ list_del_init(&chunk->map_extend_list);
6527 + list_move(&chunk->list, &to_free);
6528 + }
6529 +
6530 +@@ -1146,6 +1142,25 @@ static void pcpu_balance_workfn(struct work_struct *work)
6531 + pcpu_destroy_chunk(chunk);
6532 + }
6533 +
6534 ++ /* service chunks which requested async area map extension */
6535 ++ do {
6536 ++ int new_alloc = 0;
6537 ++
6538 ++ spin_lock_irq(&pcpu_lock);
6539 ++
6540 ++ chunk = list_first_entry_or_null(&pcpu_map_extend_chunks,
6541 ++ struct pcpu_chunk, map_extend_list);
6542 ++ if (chunk) {
6543 ++ list_del_init(&chunk->map_extend_list);
6544 ++ new_alloc = pcpu_need_to_extend(chunk, false);
6545 ++ }
6546 ++
6547 ++ spin_unlock_irq(&pcpu_lock);
6548 ++
6549 ++ if (new_alloc)
6550 ++ pcpu_extend_area_map(chunk, new_alloc);
6551 ++ } while (chunk);
6552 ++
6553 + /*
6554 + * Ensure there are certain number of free populated pages for
6555 + * atomic allocs. Fill up from the most packed so that atomic
6556 +@@ -1644,7 +1659,7 @@ int __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai,
6557 + */
6558 + schunk = memblock_virt_alloc(pcpu_chunk_struct_size, 0);
6559 + INIT_LIST_HEAD(&schunk->list);
6560 +- INIT_WORK(&schunk->map_extend_work, pcpu_map_extend_workfn);
6561 ++ INIT_LIST_HEAD(&schunk->map_extend_list);
6562 + schunk->base_addr = base_addr;
6563 + schunk->map = smap;
6564 + schunk->map_alloc = ARRAY_SIZE(smap);
6565 +@@ -1673,7 +1688,7 @@ int __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai,
6566 + if (dyn_size) {
6567 + dchunk = memblock_virt_alloc(pcpu_chunk_struct_size, 0);
6568 + INIT_LIST_HEAD(&dchunk->list);
6569 +- INIT_WORK(&dchunk->map_extend_work, pcpu_map_extend_workfn);
6570 ++ INIT_LIST_HEAD(&dchunk->map_extend_list);
6571 + dchunk->base_addr = base_addr;
6572 + dchunk->map = dmap;
6573 + dchunk->map_alloc = ARRAY_SIZE(dmap);
6574 +diff --git a/mm/shmem.c b/mm/shmem.c
6575 +index 719bd6b..9ca09f5 100644
6576 +--- a/mm/shmem.c
6577 ++++ b/mm/shmem.c
6578 +@@ -2236,9 +2236,11 @@ static long shmem_fallocate(struct file *file, int mode, loff_t offset,
6579 + NULL);
6580 + if (error) {
6581 + /* Remove the !PageUptodate pages we added */
6582 +- shmem_undo_range(inode,
6583 +- (loff_t)start << PAGE_SHIFT,
6584 +- (loff_t)index << PAGE_SHIFT, true);
6585 ++ if (index > start) {
6586 ++ shmem_undo_range(inode,
6587 ++ (loff_t)start << PAGE_SHIFT,
6588 ++ ((loff_t)index << PAGE_SHIFT) - 1, true);
6589 ++ }
6590 + goto undone;
6591 + }
6592 +
6593 +diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
6594 +index a669dea..61ad43f 100644
6595 +--- a/net/core/flow_dissector.c
6596 ++++ b/net/core/flow_dissector.c
6597 +@@ -651,6 +651,23 @@ void make_flow_keys_digest(struct flow_keys_digest *digest,
6598 + }
6599 + EXPORT_SYMBOL(make_flow_keys_digest);
6600 +
6601 ++static struct flow_dissector flow_keys_dissector_symmetric __read_mostly;
6602 ++
6603 ++u32 __skb_get_hash_symmetric(struct sk_buff *skb)
6604 ++{
6605 ++ struct flow_keys keys;
6606 ++
6607 ++ __flow_hash_secret_init();
6608 ++
6609 ++ memset(&keys, 0, sizeof(keys));
6610 ++ __skb_flow_dissect(skb, &flow_keys_dissector_symmetric, &keys,
6611 ++ NULL, 0, 0, 0,
6612 ++ FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL);
6613 ++
6614 ++ return __flow_hash_from_keys(&keys, hashrnd);
6615 ++}
6616 ++EXPORT_SYMBOL_GPL(__skb_get_hash_symmetric);
6617 ++
6618 + /**
6619 + * __skb_get_hash: calculate a flow hash
6620 + * @skb: sk_buff to calculate flow hash from
6621 +@@ -868,6 +885,29 @@ static const struct flow_dissector_key flow_keys_dissector_keys[] = {
6622 + },
6623 + };
6624 +
6625 ++static const struct flow_dissector_key flow_keys_dissector_symmetric_keys[] = {
6626 ++ {
6627 ++ .key_id = FLOW_DISSECTOR_KEY_CONTROL,
6628 ++ .offset = offsetof(struct flow_keys, control),
6629 ++ },
6630 ++ {
6631 ++ .key_id = FLOW_DISSECTOR_KEY_BASIC,
6632 ++ .offset = offsetof(struct flow_keys, basic),
6633 ++ },
6634 ++ {
6635 ++ .key_id = FLOW_DISSECTOR_KEY_IPV4_ADDRS,
6636 ++ .offset = offsetof(struct flow_keys, addrs.v4addrs),
6637 ++ },
6638 ++ {
6639 ++ .key_id = FLOW_DISSECTOR_KEY_IPV6_ADDRS,
6640 ++ .offset = offsetof(struct flow_keys, addrs.v6addrs),
6641 ++ },
6642 ++ {
6643 ++ .key_id = FLOW_DISSECTOR_KEY_PORTS,
6644 ++ .offset = offsetof(struct flow_keys, ports),
6645 ++ },
6646 ++};
6647 ++
6648 + static const struct flow_dissector_key flow_keys_buf_dissector_keys[] = {
6649 + {
6650 + .key_id = FLOW_DISSECTOR_KEY_CONTROL,
6651 +@@ -889,6 +929,9 @@ static int __init init_default_flow_dissectors(void)
6652 + skb_flow_dissector_init(&flow_keys_dissector,
6653 + flow_keys_dissector_keys,
6654 + ARRAY_SIZE(flow_keys_dissector_keys));
6655 ++ skb_flow_dissector_init(&flow_keys_dissector_symmetric,
6656 ++ flow_keys_dissector_symmetric_keys,
6657 ++ ARRAY_SIZE(flow_keys_dissector_symmetric_keys));
6658 + skb_flow_dissector_init(&flow_keys_buf_dissector,
6659 + flow_keys_buf_dissector_keys,
6660 + ARRAY_SIZE(flow_keys_buf_dissector_keys));
6661 +diff --git a/net/core/skbuff.c b/net/core/skbuff.c
6662 +index e561f9f..59bf4d7 100644
6663 +--- a/net/core/skbuff.c
6664 ++++ b/net/core/skbuff.c
6665 +@@ -3016,24 +3016,6 @@ int skb_append_pagefrags(struct sk_buff *skb, struct page *page,
6666 + EXPORT_SYMBOL_GPL(skb_append_pagefrags);
6667 +
6668 + /**
6669 +- * skb_push_rcsum - push skb and update receive checksum
6670 +- * @skb: buffer to update
6671 +- * @len: length of data pulled
6672 +- *
6673 +- * This function performs an skb_push on the packet and updates
6674 +- * the CHECKSUM_COMPLETE checksum. It should be used on
6675 +- * receive path processing instead of skb_push unless you know
6676 +- * that the checksum difference is zero (e.g., a valid IP header)
6677 +- * or you are setting ip_summed to CHECKSUM_NONE.
6678 +- */
6679 +-static unsigned char *skb_push_rcsum(struct sk_buff *skb, unsigned len)
6680 +-{
6681 +- skb_push(skb, len);
6682 +- skb_postpush_rcsum(skb, skb->data, len);
6683 +- return skb->data;
6684 +-}
6685 +-
6686 +-/**
6687 + * skb_pull_rcsum - pull skb and update receive checksum
6688 + * @skb: buffer to update
6689 + * @len: length of data pulled
6690 +diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
6691 +index ea071fa..c26fac2 100644
6692 +--- a/net/ipv6/ip6_fib.c
6693 ++++ b/net/ipv6/ip6_fib.c
6694 +@@ -177,6 +177,7 @@ static void rt6_free_pcpu(struct rt6_info *non_pcpu_rt)
6695 + }
6696 + }
6697 +
6698 ++ free_percpu(non_pcpu_rt->rt6i_pcpu);
6699 + non_pcpu_rt->rt6i_pcpu = NULL;
6700 + }
6701 +
6702 +diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
6703 +index d32cefc..34a5712 100644
6704 +--- a/net/mac80211/mesh.c
6705 ++++ b/net/mac80211/mesh.c
6706 +@@ -150,19 +150,26 @@ u32 mesh_accept_plinks_update(struct ieee80211_sub_if_data *sdata)
6707 + void mesh_sta_cleanup(struct sta_info *sta)
6708 + {
6709 + struct ieee80211_sub_if_data *sdata = sta->sdata;
6710 +- u32 changed;
6711 ++ u32 changed = 0;
6712 +
6713 + /*
6714 + * maybe userspace handles peer allocation and peering, but in either
6715 + * case the beacon is still generated by the kernel and we might need
6716 + * an update.
6717 + */
6718 +- changed = mesh_accept_plinks_update(sdata);
6719 ++ if (sdata->u.mesh.user_mpm &&
6720 ++ sta->mesh->plink_state == NL80211_PLINK_ESTAB)
6721 ++ changed |= mesh_plink_dec_estab_count(sdata);
6722 ++ changed |= mesh_accept_plinks_update(sdata);
6723 + if (!sdata->u.mesh.user_mpm) {
6724 + changed |= mesh_plink_deactivate(sta);
6725 + del_timer_sync(&sta->mesh->plink_timer);
6726 + }
6727 +
6728 ++ /* make sure no readers can access nexthop sta from here on */
6729 ++ mesh_path_flush_by_nexthop(sta);
6730 ++ synchronize_net();
6731 ++
6732 + if (changed)
6733 + ieee80211_mbss_info_change_notify(sdata, changed);
6734 + }
6735 +diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h
6736 +index 62193f4..ba7ce53 100644
6737 +--- a/net/mac80211/sta_info.h
6738 ++++ b/net/mac80211/sta_info.h
6739 +@@ -275,7 +275,7 @@ struct ieee80211_fast_tx {
6740 + u8 sa_offs, da_offs, pn_offs;
6741 + u8 band;
6742 + u8 hdr[30 + 2 + IEEE80211_FAST_XMIT_MAX_IV +
6743 +- sizeof(rfc1042_header)];
6744 ++ sizeof(rfc1042_header)] __aligned(2);
6745 +
6746 + struct rcu_head rcu_head;
6747 + };
6748 +diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
6749 +index 18d0bec..8012f67 100644
6750 +--- a/net/packet/af_packet.c
6751 ++++ b/net/packet/af_packet.c
6752 +@@ -1340,7 +1340,7 @@ static unsigned int fanout_demux_hash(struct packet_fanout *f,
6753 + struct sk_buff *skb,
6754 + unsigned int num)
6755 + {
6756 +- return reciprocal_scale(skb_get_hash(skb), num);
6757 ++ return reciprocal_scale(__skb_get_hash_symmetric(skb), num);
6758 + }
6759 +
6760 + static unsigned int fanout_demux_lb(struct packet_fanout *f,
6761 +diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c
6762 +index 8f3948d..934336e 100644
6763 +--- a/net/sched/act_mirred.c
6764 ++++ b/net/sched/act_mirred.c
6765 +@@ -180,7 +180,7 @@ static int tcf_mirred(struct sk_buff *skb, const struct tc_action *a,
6766 +
6767 + if (!(at & AT_EGRESS)) {
6768 + if (m->tcfm_ok_push)
6769 +- skb_push(skb2, skb->mac_len);
6770 ++ skb_push_rcsum(skb2, skb->mac_len);
6771 + }
6772 +
6773 + /* mirror is always swallowed */
6774 +diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
6775 +index 7e0c9bf..837dd91 100644
6776 +--- a/net/sunrpc/clnt.c
6777 ++++ b/net/sunrpc/clnt.c
6778 +@@ -446,16 +446,27 @@ out_no_rpciod:
6779 + return ERR_PTR(err);
6780 + }
6781 +
6782 +-struct rpc_clnt *rpc_create_xprt(struct rpc_create_args *args,
6783 ++static struct rpc_clnt *rpc_create_xprt(struct rpc_create_args *args,
6784 + struct rpc_xprt *xprt)
6785 + {
6786 + struct rpc_clnt *clnt = NULL;
6787 + struct rpc_xprt_switch *xps;
6788 +
6789 +- xps = xprt_switch_alloc(xprt, GFP_KERNEL);
6790 +- if (xps == NULL)
6791 +- return ERR_PTR(-ENOMEM);
6792 +-
6793 ++ if (args->bc_xprt && args->bc_xprt->xpt_bc_xps) {
6794 ++ WARN_ON(args->protocol != XPRT_TRANSPORT_BC_TCP);
6795 ++ xps = args->bc_xprt->xpt_bc_xps;
6796 ++ xprt_switch_get(xps);
6797 ++ } else {
6798 ++ xps = xprt_switch_alloc(xprt, GFP_KERNEL);
6799 ++ if (xps == NULL) {
6800 ++ xprt_put(xprt);
6801 ++ return ERR_PTR(-ENOMEM);
6802 ++ }
6803 ++ if (xprt->bc_xprt) {
6804 ++ xprt_switch_get(xps);
6805 ++ xprt->bc_xprt->xpt_bc_xps = xps;
6806 ++ }
6807 ++ }
6808 + clnt = rpc_new_client(args, xps, xprt, NULL);
6809 + if (IS_ERR(clnt))
6810 + return clnt;
6811 +@@ -483,7 +494,6 @@ struct rpc_clnt *rpc_create_xprt(struct rpc_create_args *args,
6812 +
6813 + return clnt;
6814 + }
6815 +-EXPORT_SYMBOL_GPL(rpc_create_xprt);
6816 +
6817 + /**
6818 + * rpc_create - create an RPC client and transport with one call
6819 +@@ -509,6 +519,15 @@ struct rpc_clnt *rpc_create(struct rpc_create_args *args)
6820 + };
6821 + char servername[48];
6822 +
6823 ++ if (args->bc_xprt) {
6824 ++ WARN_ON(args->protocol != XPRT_TRANSPORT_BC_TCP);
6825 ++ xprt = args->bc_xprt->xpt_bc_xprt;
6826 ++ if (xprt) {
6827 ++ xprt_get(xprt);
6828 ++ return rpc_create_xprt(args, xprt);
6829 ++ }
6830 ++ }
6831 ++
6832 + if (args->flags & RPC_CLNT_CREATE_INFINITE_SLOTS)
6833 + xprtargs.flags |= XPRT_CREATE_INFINITE_SLOTS;
6834 + if (args->flags & RPC_CLNT_CREATE_NO_IDLE_TIMEOUT)
6835 +diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c
6836 +index 7422f28..7231cb4 100644
6837 +--- a/net/sunrpc/svc_xprt.c
6838 ++++ b/net/sunrpc/svc_xprt.c
6839 +@@ -136,6 +136,8 @@ static void svc_xprt_free(struct kref *kref)
6840 + /* See comment on corresponding get in xs_setup_bc_tcp(): */
6841 + if (xprt->xpt_bc_xprt)
6842 + xprt_put(xprt->xpt_bc_xprt);
6843 ++ if (xprt->xpt_bc_xps)
6844 ++ xprt_switch_put(xprt->xpt_bc_xps);
6845 + xprt->xpt_ops->xpo_free(xprt);
6846 + module_put(owner);
6847 + }
6848 +diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
6849 +index 65e7595..e9e5dd0 100644
6850 +--- a/net/sunrpc/xprtsock.c
6851 ++++ b/net/sunrpc/xprtsock.c
6852 +@@ -3050,6 +3050,7 @@ static struct rpc_xprt *xs_setup_bc_tcp(struct xprt_create *args)
6853 + return xprt;
6854 +
6855 + args->bc_xprt->xpt_bc_xprt = NULL;
6856 ++ args->bc_xprt->xpt_bc_xps = NULL;
6857 + xprt_put(xprt);
6858 + ret = ERR_PTR(-EINVAL);
6859 + out_err:
6860 +diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
6861 +index 8269da7..7748199 100644
6862 +--- a/net/unix/af_unix.c
6863 ++++ b/net/unix/af_unix.c
6864 +@@ -315,7 +315,7 @@ static struct sock *unix_find_socket_byinode(struct inode *i)
6865 + &unix_socket_table[i->i_ino & (UNIX_HASH_SIZE - 1)]) {
6866 + struct dentry *dentry = unix_sk(s)->path.dentry;
6867 +
6868 +- if (dentry && d_backing_inode(dentry) == i) {
6869 ++ if (dentry && d_real_inode(dentry) == i) {
6870 + sock_hold(s);
6871 + goto found;
6872 + }
6873 +@@ -911,7 +911,7 @@ static struct sock *unix_find_other(struct net *net,
6874 + err = kern_path(sunname->sun_path, LOOKUP_FOLLOW, &path);
6875 + if (err)
6876 + goto fail;
6877 +- inode = d_backing_inode(path.dentry);
6878 ++ inode = d_real_inode(path.dentry);
6879 + err = inode_permission(inode, MAY_WRITE);
6880 + if (err)
6881 + goto put_fail;
6882 +@@ -1048,7 +1048,7 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
6883 + goto out_up;
6884 + }
6885 + addr->hash = UNIX_HASH_SIZE;
6886 +- hash = d_backing_inode(dentry)->i_ino & (UNIX_HASH_SIZE - 1);
6887 ++ hash = d_real_inode(dentry)->i_ino & (UNIX_HASH_SIZE - 1);
6888 + spin_lock(&unix_table_lock);
6889 + u->path = u_path;
6890 + list = &unix_socket_table[hash];
6891 +diff --git a/net/wireless/core.c b/net/wireless/core.c
6892 +index 9f1c4aa..c878045 100644
6893 +--- a/net/wireless/core.c
6894 ++++ b/net/wireless/core.c
6895 +@@ -360,8 +360,6 @@ struct wiphy *wiphy_new_nm(const struct cfg80211_ops *ops, int sizeof_priv,
6896 + WARN_ON(ops->remain_on_channel && !ops->cancel_remain_on_channel);
6897 + WARN_ON(ops->tdls_channel_switch && !ops->tdls_cancel_channel_switch);
6898 + WARN_ON(ops->add_tx_ts && !ops->del_tx_ts);
6899 +- WARN_ON(ops->set_tx_power && !ops->get_tx_power);
6900 +- WARN_ON(ops->set_antenna && !ops->get_antenna);
6901 +
6902 + alloc_size = sizeof(*rdev) + sizeof_priv;
6903 +
6904 +diff --git a/net/wireless/util.c b/net/wireless/util.c
6905 +index 9f440a9..47b9178 100644
6906 +--- a/net/wireless/util.c
6907 ++++ b/net/wireless/util.c
6908 +@@ -509,7 +509,7 @@ static int __ieee80211_data_to_8023(struct sk_buff *skb, struct ethhdr *ehdr,
6909 + * replace EtherType */
6910 + hdrlen += ETH_ALEN + 2;
6911 + else
6912 +- tmp.h_proto = htons(skb->len);
6913 ++ tmp.h_proto = htons(skb->len - hdrlen);
6914 +
6915 + pskb_pull(skb, hdrlen);
6916 +
6917 +diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
6918 +index a915507..fec7578 100644
6919 +--- a/scripts/mod/file2alias.c
6920 ++++ b/scripts/mod/file2alias.c
6921 +@@ -384,7 +384,7 @@ static void do_of_entry_multi(void *symval, struct module *mod)
6922 + len = sprintf(alias, "of:N%sT%s", (*name)[0] ? *name : "*",
6923 + (*type)[0] ? *type : "*");
6924 +
6925 +- if (compatible[0])
6926 ++ if ((*compatible)[0])
6927 + sprintf(&alias[len], "%sC%s", (*type)[0] ? "*" : "",
6928 + *compatible);
6929 +
6930 +diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
6931 +index dec607c..5ee8201 100644
6932 +--- a/security/apparmor/lsm.c
6933 ++++ b/security/apparmor/lsm.c
6934 +@@ -523,34 +523,34 @@ static int apparmor_setprocattr(struct task_struct *task, char *name,
6935 + {
6936 + struct common_audit_data sa;
6937 + struct apparmor_audit_data aad = {0,};
6938 +- char *command, *args = value;
6939 ++ char *command, *largs = NULL, *args = value;
6940 + size_t arg_size;
6941 + int error;
6942 +
6943 + if (size == 0)
6944 + return -EINVAL;
6945 +- /* args points to a PAGE_SIZE buffer, AppArmor requires that
6946 +- * the buffer must be null terminated or have size <= PAGE_SIZE -1
6947 +- * so that AppArmor can null terminate them
6948 +- */
6949 +- if (args[size - 1] != '\0') {
6950 +- if (size == PAGE_SIZE)
6951 +- return -EINVAL;
6952 +- args[size] = '\0';
6953 +- }
6954 +-
6955 + /* task can only write its own attributes */
6956 + if (current != task)
6957 + return -EACCES;
6958 +
6959 +- args = value;
6960 ++ /* AppArmor requires that the buffer must be null terminated atm */
6961 ++ if (args[size - 1] != '\0') {
6962 ++ /* null terminate */
6963 ++ largs = args = kmalloc(size + 1, GFP_KERNEL);
6964 ++ if (!args)
6965 ++ return -ENOMEM;
6966 ++ memcpy(args, value, size);
6967 ++ args[size] = '\0';
6968 ++ }
6969 ++
6970 ++ error = -EINVAL;
6971 + args = strim(args);
6972 + command = strsep(&args, " ");
6973 + if (!args)
6974 +- return -EINVAL;
6975 ++ goto out;
6976 + args = skip_spaces(args);
6977 + if (!*args)
6978 +- return -EINVAL;
6979 ++ goto out;
6980 +
6981 + arg_size = size - (args - (char *) value);
6982 + if (strcmp(name, "current") == 0) {
6983 +@@ -576,10 +576,12 @@ static int apparmor_setprocattr(struct task_struct *task, char *name,
6984 + goto fail;
6985 + } else
6986 + /* only support the "current" and "exec" process attributes */
6987 +- return -EINVAL;
6988 ++ goto fail;
6989 +
6990 + if (!error)
6991 + error = size;
6992 ++out:
6993 ++ kfree(largs);
6994 + return error;
6995 +
6996 + fail:
6997 +@@ -588,9 +590,9 @@ fail:
6998 + aad.profile = aa_current_profile();
6999 + aad.op = OP_SETPROCATTR;
7000 + aad.info = name;
7001 +- aad.error = -EINVAL;
7002 ++ aad.error = error = -EINVAL;
7003 + aa_audit_msg(AUDIT_APPARMOR_DENIED, &sa, NULL);
7004 +- return -EINVAL;
7005 ++ goto out;
7006 + }
7007 +
7008 + static int apparmor_task_setrlimit(struct task_struct *task,
7009 +diff --git a/security/keys/key.c b/security/keys/key.c
7010 +index b287551..af7f682 100644
7011 +--- a/security/keys/key.c
7012 ++++ b/security/keys/key.c
7013 +@@ -584,7 +584,7 @@ int key_reject_and_link(struct key *key,
7014 +
7015 + mutex_unlock(&key_construction_mutex);
7016 +
7017 +- if (keyring)
7018 ++ if (keyring && link_ret == 0)
7019 + __key_link_end(keyring, &key->index_key, edit);
7020 +
7021 + /* wake up anyone waiting for a key to be constructed */
7022 +diff --git a/sound/core/control.c b/sound/core/control.c
7023 +index a85d455..b4fe9b0 100644
7024 +--- a/sound/core/control.c
7025 ++++ b/sound/core/control.c
7026 +@@ -160,6 +160,8 @@ void snd_ctl_notify(struct snd_card *card, unsigned int mask,
7027 +
7028 + if (snd_BUG_ON(!card || !id))
7029 + return;
7030 ++ if (card->shutdown)
7031 ++ return;
7032 + read_lock(&card->ctl_files_rwlock);
7033 + #if IS_ENABLED(CONFIG_SND_MIXER_OSS)
7034 + card->mixer_oss_change_count++;
7035 +diff --git a/sound/core/pcm.c b/sound/core/pcm.c
7036 +index 308c9ec..8e980aa 100644
7037 +--- a/sound/core/pcm.c
7038 ++++ b/sound/core/pcm.c
7039 +@@ -849,6 +849,14 @@ int snd_pcm_new_internal(struct snd_card *card, const char *id, int device,
7040 + }
7041 + EXPORT_SYMBOL(snd_pcm_new_internal);
7042 +
7043 ++static void free_chmap(struct snd_pcm_str *pstr)
7044 ++{
7045 ++ if (pstr->chmap_kctl) {
7046 ++ snd_ctl_remove(pstr->pcm->card, pstr->chmap_kctl);
7047 ++ pstr->chmap_kctl = NULL;
7048 ++ }
7049 ++}
7050 ++
7051 + static void snd_pcm_free_stream(struct snd_pcm_str * pstr)
7052 + {
7053 + struct snd_pcm_substream *substream, *substream_next;
7054 +@@ -871,6 +879,7 @@ static void snd_pcm_free_stream(struct snd_pcm_str * pstr)
7055 + kfree(setup);
7056 + }
7057 + #endif
7058 ++ free_chmap(pstr);
7059 + if (pstr->substream_count)
7060 + put_device(&pstr->dev);
7061 + }
7062 +@@ -1135,10 +1144,7 @@ static int snd_pcm_dev_disconnect(struct snd_device *device)
7063 + for (cidx = 0; cidx < 2; cidx++) {
7064 + if (!pcm->internal)
7065 + snd_unregister_device(&pcm->streams[cidx].dev);
7066 +- if (pcm->streams[cidx].chmap_kctl) {
7067 +- snd_ctl_remove(pcm->card, pcm->streams[cidx].chmap_kctl);
7068 +- pcm->streams[cidx].chmap_kctl = NULL;
7069 +- }
7070 ++ free_chmap(&pcm->streams[cidx]);
7071 + }
7072 + mutex_unlock(&pcm->open_mutex);
7073 + mutex_unlock(&register_mutex);
7074 +diff --git a/sound/core/timer.c b/sound/core/timer.c
7075 +index 6469bed..23b73f6 100644
7076 +--- a/sound/core/timer.c
7077 ++++ b/sound/core/timer.c
7078 +@@ -1954,6 +1954,7 @@ static ssize_t snd_timer_user_read(struct file *file, char __user *buffer,
7079 +
7080 + qhead = tu->qhead++;
7081 + tu->qhead %= tu->queue_size;
7082 ++ tu->qused--;
7083 + spin_unlock_irq(&tu->qlock);
7084 +
7085 + if (tu->tread) {
7086 +@@ -1967,7 +1968,6 @@ static ssize_t snd_timer_user_read(struct file *file, char __user *buffer,
7087 + }
7088 +
7089 + spin_lock_irq(&tu->qlock);
7090 +- tu->qused--;
7091 + if (err < 0)
7092 + goto _error;
7093 + result += unit;
7094 +diff --git a/sound/drivers/dummy.c b/sound/drivers/dummy.c
7095 +index c0f8f61..172dacd 100644
7096 +--- a/sound/drivers/dummy.c
7097 ++++ b/sound/drivers/dummy.c
7098 +@@ -420,6 +420,7 @@ static int dummy_hrtimer_stop(struct snd_pcm_substream *substream)
7099 +
7100 + static inline void dummy_hrtimer_sync(struct dummy_hrtimer_pcm *dpcm)
7101 + {
7102 ++ hrtimer_cancel(&dpcm->timer);
7103 + tasklet_kill(&dpcm->tasklet);
7104 + }
7105 +
7106 +diff --git a/sound/hda/hdac_regmap.c b/sound/hda/hdac_regmap.c
7107 +index 87041dd..47a358f 100644
7108 +--- a/sound/hda/hdac_regmap.c
7109 ++++ b/sound/hda/hdac_regmap.c
7110 +@@ -444,7 +444,7 @@ int snd_hdac_regmap_write_raw(struct hdac_device *codec, unsigned int reg,
7111 + err = reg_raw_write(codec, reg, val);
7112 + if (err == -EAGAIN) {
7113 + err = snd_hdac_power_up_pm(codec);
7114 +- if (!err)
7115 ++ if (err >= 0)
7116 + err = reg_raw_write(codec, reg, val);
7117 + snd_hdac_power_down_pm(codec);
7118 + }
7119 +@@ -470,7 +470,7 @@ static int __snd_hdac_regmap_read_raw(struct hdac_device *codec,
7120 + err = reg_raw_read(codec, reg, val, uncached);
7121 + if (err == -EAGAIN) {
7122 + err = snd_hdac_power_up_pm(codec);
7123 +- if (!err)
7124 ++ if (err >= 0)
7125 + err = reg_raw_read(codec, reg, val, uncached);
7126 + snd_hdac_power_down_pm(codec);
7127 + }
7128 +diff --git a/sound/pci/au88x0/au88x0_core.c b/sound/pci/au88x0/au88x0_core.c
7129 +index 4667c32..7417718 100644
7130 +--- a/sound/pci/au88x0/au88x0_core.c
7131 ++++ b/sound/pci/au88x0/au88x0_core.c
7132 +@@ -1444,9 +1444,8 @@ static int vortex_wtdma_bufshift(vortex_t * vortex, int wtdma)
7133 + int page, p, pp, delta, i;
7134 +
7135 + page =
7136 +- (hwread(vortex->mmio, VORTEX_WTDMA_STAT + (wtdma << 2)) &
7137 +- WT_SUBBUF_MASK)
7138 +- >> WT_SUBBUF_SHIFT;
7139 ++ (hwread(vortex->mmio, VORTEX_WTDMA_STAT + (wtdma << 2))
7140 ++ >> WT_SUBBUF_SHIFT) & WT_SUBBUF_MASK;
7141 + if (dma->nr_periods >= 4)
7142 + delta = (page - dma->period_real) & 3;
7143 + else {
7144 +diff --git a/sound/pci/echoaudio/echoaudio.c b/sound/pci/echoaudio/echoaudio.c
7145 +index 1cb85ae..286f5e3 100644
7146 +--- a/sound/pci/echoaudio/echoaudio.c
7147 ++++ b/sound/pci/echoaudio/echoaudio.c
7148 +@@ -2200,11 +2200,11 @@ static int snd_echo_resume(struct device *dev)
7149 + u32 pipe_alloc_mask;
7150 + int err;
7151 +
7152 +- commpage_bak = kmalloc(sizeof(struct echoaudio), GFP_KERNEL);
7153 ++ commpage_bak = kmalloc(sizeof(*commpage), GFP_KERNEL);
7154 + if (commpage_bak == NULL)
7155 + return -ENOMEM;
7156 + commpage = chip->comm_page;
7157 +- memcpy(commpage_bak, commpage, sizeof(struct comm_page));
7158 ++ memcpy(commpage_bak, commpage, sizeof(*commpage));
7159 +
7160 + err = init_hw(chip, chip->pci->device, chip->pci->subsystem_device);
7161 + if (err < 0) {
7162 +diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
7163 +index dfaf1a9..d77cc76 100644
7164 +--- a/sound/pci/hda/hda_generic.c
7165 ++++ b/sound/pci/hda/hda_generic.c
7166 +@@ -3977,6 +3977,8 @@ static hda_nid_t set_path_power(struct hda_codec *codec, hda_nid_t nid,
7167 +
7168 + for (n = 0; n < spec->paths.used; n++) {
7169 + path = snd_array_elem(&spec->paths, n);
7170 ++ if (!path->depth)
7171 ++ continue;
7172 + if (path->path[0] == nid ||
7173 + path->path[path->depth - 1] == nid) {
7174 + bool pin_old = path->pin_enabled;
7175 +diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
7176 +index 94089fc..6f8ea13 100644
7177 +--- a/sound/pci/hda/hda_intel.c
7178 ++++ b/sound/pci/hda/hda_intel.c
7179 +@@ -367,9 +367,10 @@ enum {
7180 + #define IS_SKL_LP(pci) ((pci)->vendor == 0x8086 && (pci)->device == 0x9d70)
7181 + #define IS_KBL(pci) ((pci)->vendor == 0x8086 && (pci)->device == 0xa171)
7182 + #define IS_KBL_LP(pci) ((pci)->vendor == 0x8086 && (pci)->device == 0x9d71)
7183 ++#define IS_KBL_H(pci) ((pci)->vendor == 0x8086 && (pci)->device == 0xa2f0)
7184 + #define IS_BXT(pci) ((pci)->vendor == 0x8086 && (pci)->device == 0x5a98)
7185 + #define IS_SKL_PLUS(pci) (IS_SKL(pci) || IS_SKL_LP(pci) || IS_BXT(pci)) || \
7186 +- IS_KBL(pci) || IS_KBL_LP(pci)
7187 ++ IS_KBL(pci) || IS_KBL_LP(pci) || IS_KBL_H(pci)
7188 +
7189 + static char *driver_short_names[] = {
7190 + [AZX_DRIVER_ICH] = "HDA Intel",
7191 +@@ -1217,8 +1218,10 @@ static int azx_free(struct azx *chip)
7192 + if (use_vga_switcheroo(hda)) {
7193 + if (chip->disabled && hda->probe_continued)
7194 + snd_hda_unlock_devices(&chip->bus);
7195 +- if (hda->vga_switcheroo_registered)
7196 ++ if (hda->vga_switcheroo_registered) {
7197 + vga_switcheroo_unregister_client(chip->pci);
7198 ++ vga_switcheroo_fini_domain_pm_ops(chip->card->dev);
7199 ++ }
7200 + }
7201 +
7202 + if (bus->chip_init) {
7203 +@@ -2190,6 +2193,9 @@ static const struct pci_device_id azx_ids[] = {
7204 + /* Kabylake-LP */
7205 + { PCI_DEVICE(0x8086, 0x9d71),
7206 + .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_INTEL_SKYLAKE },
7207 ++ /* Kabylake-H */
7208 ++ { PCI_DEVICE(0x8086, 0xa2f0),
7209 ++ .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_INTEL_SKYLAKE },
7210 + /* Broxton-P(Apollolake) */
7211 + { PCI_DEVICE(0x8086, 0x5a98),
7212 + .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_INTEL_BROXTON },
7213 +@@ -2263,6 +2269,8 @@ static const struct pci_device_id azx_ids[] = {
7214 + .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS },
7215 + { PCI_DEVICE(0x1002, 0x157a),
7216 + .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS },
7217 ++ { PCI_DEVICE(0x1002, 0x15b3),
7218 ++ .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS },
7219 + { PCI_DEVICE(0x1002, 0x793b),
7220 + .driver_data = AZX_DRIVER_ATIHDMI | AZX_DCAPS_PRESET_ATI_HDMI },
7221 + { PCI_DEVICE(0x1002, 0x7919),
7222 +diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
7223 +index 0fe18ed..abcb5a6 100644
7224 +--- a/sound/pci/hda/patch_realtek.c
7225 ++++ b/sound/pci/hda/patch_realtek.c
7226 +@@ -5650,6 +5650,9 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
7227 + SND_PCI_QUIRK(0x17aa, 0x503c, "Thinkpad L450", ALC292_FIXUP_TPT440_DOCK),
7228 + SND_PCI_QUIRK(0x17aa, 0x504a, "ThinkPad X260", ALC292_FIXUP_TPT440_DOCK),
7229 + SND_PCI_QUIRK(0x17aa, 0x504b, "Thinkpad", ALC293_FIXUP_LENOVO_SPK_NOISE),
7230 ++ SND_PCI_QUIRK(0x17aa, 0x5050, "Thinkpad T560p", ALC292_FIXUP_TPT460),
7231 ++ SND_PCI_QUIRK(0x17aa, 0x5051, "Thinkpad L460", ALC292_FIXUP_TPT460),
7232 ++ SND_PCI_QUIRK(0x17aa, 0x5053, "Thinkpad T460", ALC292_FIXUP_TPT460),
7233 + SND_PCI_QUIRK(0x17aa, 0x5109, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
7234 + SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_PCM_44K),
7235 + SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD),
7236 +@@ -5735,7 +5738,6 @@ static const struct hda_model_fixup alc269_fixup_models[] = {
7237 + {}
7238 + };
7239 + #define ALC225_STANDARD_PINS \
7240 +- {0x12, 0xb7a60130}, \
7241 + {0x21, 0x04211020}
7242 +
7243 + #define ALC256_STANDARD_PINS \
7244 +@@ -5760,10 +5762,24 @@ static const struct hda_model_fixup alc269_fixup_models[] = {
7245 + static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = {
7246 + SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
7247 + ALC225_STANDARD_PINS,
7248 ++ {0x12, 0xb7a60130},
7249 + {0x14, 0x901701a0}),
7250 + SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
7251 + ALC225_STANDARD_PINS,
7252 ++ {0x12, 0xb7a60130},
7253 + {0x14, 0x901701b0}),
7254 ++ SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
7255 ++ ALC225_STANDARD_PINS,
7256 ++ {0x12, 0xb7a60150},
7257 ++ {0x14, 0x901701a0}),
7258 ++ SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
7259 ++ ALC225_STANDARD_PINS,
7260 ++ {0x12, 0xb7a60150},
7261 ++ {0x14, 0x901701b0}),
7262 ++ SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
7263 ++ ALC225_STANDARD_PINS,
7264 ++ {0x12, 0xb7a60130},
7265 ++ {0x1b, 0x90170110}),
7266 + SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL2_MIC_NO_PRESENCE,
7267 + {0x14, 0x90170110},
7268 + {0x21, 0x02211020}),
7269 +@@ -5832,6 +5848,10 @@ static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = {
7270 + {0x14, 0x90170120},
7271 + {0x21, 0x02211030}),
7272 + SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7273 ++ {0x12, 0x90a60170},
7274 ++ {0x14, 0x90170120},
7275 ++ {0x21, 0x02211030}),
7276 ++ SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
7277 + ALC256_STANDARD_PINS),
7278 + SND_HDA_PIN_QUIRK(0x10ec0280, 0x103c, "HP", ALC280_FIXUP_HP_GPIO4,
7279 + {0x12, 0x90a60130},
7280 +diff --git a/sound/usb/card.c b/sound/usb/card.c
7281 +index 3fc6358..2d49350 100644
7282 +--- a/sound/usb/card.c
7283 ++++ b/sound/usb/card.c
7284 +@@ -552,7 +552,6 @@ static int usb_audio_probe(struct usb_interface *intf,
7285 + goto __error;
7286 + }
7287 + chip = usb_chip[i];
7288 +- dev_set_drvdata(&dev->dev, chip);
7289 + atomic_inc(&chip->active); /* avoid autopm */
7290 + break;
7291 + }
7292 +@@ -578,6 +577,7 @@ static int usb_audio_probe(struct usb_interface *intf,
7293 + goto __error;
7294 + }
7295 + }
7296 ++ dev_set_drvdata(&dev->dev, chip);
7297 +
7298 + /*
7299 + * For devices with more than one control interface, we assume the
7300 +diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
7301 +index 4fd482f..7cb1224 100644
7302 +--- a/virt/kvm/kvm_main.c
7303 ++++ b/virt/kvm/kvm_main.c
7304 +@@ -2868,7 +2868,7 @@ static long kvm_vm_ioctl(struct file *filp,
7305 + if (copy_from_user(&routing, argp, sizeof(routing)))
7306 + goto out;
7307 + r = -EINVAL;
7308 +- if (routing.nr >= KVM_MAX_IRQ_ROUTES)
7309 ++ if (routing.nr > KVM_MAX_IRQ_ROUTES)
7310 + goto out;
7311 + if (routing.flags)
7312 + goto out;
7313
7314 diff --git a/4.6.4/4420_grsecurity-3.1-4.6.4-201607242014.patch b/4.6.5/4420_grsecurity-3.1-4.6.5-201607272152.patch
7315 similarity index 99%
7316 rename from 4.6.4/4420_grsecurity-3.1-4.6.4-201607242014.patch
7317 rename to 4.6.5/4420_grsecurity-3.1-4.6.5-201607272152.patch
7318 index f7868ce..927b9ba 100644
7319 --- a/4.6.4/4420_grsecurity-3.1-4.6.4-201607242014.patch
7320 +++ b/4.6.5/4420_grsecurity-3.1-4.6.5-201607272152.patch
7321 @@ -420,7 +420,7 @@ index fcddfd5..71afd6b 100644
7322
7323 A toggle value indicating if modules are allowed to be loaded
7324 diff --git a/Makefile b/Makefile
7325 -index cd37442..4c8e887 100644
7326 +index 7d693a8..28a594e 100644
7327 --- a/Makefile
7328 +++ b/Makefile
7329 @@ -298,7 +298,9 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
7330 @@ -1913,7 +1913,7 @@ index d0131ee..23a0939 100644
7331 #define PTE_EXT_AP0 (_AT(pteval_t, 1) << 4)
7332 #define PTE_EXT_AP1 (_AT(pteval_t, 2) << 4)
7333 diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h
7334 -index aeddd28..207745c 100644
7335 +index 92fd2c8..061dae1 100644
7336 --- a/arch/arm/include/asm/pgtable-2level.h
7337 +++ b/arch/arm/include/asm/pgtable-2level.h
7338 @@ -127,6 +127,9 @@
7339 @@ -1927,7 +1927,7 @@ index aeddd28..207745c 100644
7340 * These are the memory types, defined to be compatible with
7341 * pre-ARMv6 CPUs cacheable and bufferable bits: n/a,n/a,C,B
7342 diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
7343 -index dc46398..70dab92 100644
7344 +index 7411466..c57e55a 100644
7345 --- a/arch/arm/include/asm/pgtable-3level.h
7346 +++ b/arch/arm/include/asm/pgtable-3level.h
7347 @@ -80,6 +80,7 @@
7348 @@ -1952,7 +1952,7 @@ index dc46398..70dab92 100644
7349 #define L_PTE_DIRTY_HIGH (1 << (55 - 32))
7350
7351 diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
7352 -index 348caab..306b62d 100644
7353 +index d622040..fcebd79 100644
7354 --- a/arch/arm/include/asm/pgtable.h
7355 +++ b/arch/arm/include/asm/pgtable.h
7356 @@ -33,6 +33,9 @@
7357 @@ -2035,7 +2035,7 @@ index 348caab..306b62d 100644
7358 */
7359 #define _L_PTE_DEFAULT L_PTE_PRESENT | L_PTE_YOUNG
7360
7361 -@@ -307,7 +355,7 @@ static inline pte_t pte_mknexec(pte_t pte)
7362 +@@ -306,7 +354,7 @@ static inline pte_t pte_mknexec(pte_t pte)
7363 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
7364 {
7365 const pteval_t mask = L_PTE_XN | L_PTE_RDONLY | L_PTE_USER |
7366 @@ -3226,7 +3226,7 @@ index e2c6da0..6155a88 100644
7367 . = ALIGN(1<<SECTION_SHIFT);
7368 #else
7369 diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
7370 -index dded1b7..6fa4373 100644
7371 +index 72b11d9..505a0f5 100644
7372 --- a/arch/arm/kvm/arm.c
7373 +++ b/arch/arm/kvm/arm.c
7374 @@ -59,7 +59,7 @@ static unsigned long hyp_default_vectors;
7375 @@ -3238,7 +3238,7 @@ index dded1b7..6fa4373 100644
7376 static u32 kvm_next_vmid;
7377 static unsigned int kvm_vmid_bits __read_mostly;
7378 static DEFINE_SPINLOCK(kvm_vmid_lock);
7379 -@@ -392,7 +392,7 @@ void force_vm_exit(const cpumask_t *mask)
7380 +@@ -393,7 +393,7 @@ void force_vm_exit(const cpumask_t *mask)
7381 */
7382 static bool need_new_vmid_gen(struct kvm *kvm)
7383 {
7384 @@ -3247,7 +3247,7 @@ index dded1b7..6fa4373 100644
7385 }
7386
7387 /**
7388 -@@ -425,7 +425,7 @@ static void update_vttbr(struct kvm *kvm)
7389 +@@ -426,7 +426,7 @@ static void update_vttbr(struct kvm *kvm)
7390
7391 /* First user of a new VMID generation? */
7392 if (unlikely(kvm_next_vmid == 0)) {
7393 @@ -3256,7 +3256,7 @@ index dded1b7..6fa4373 100644
7394 kvm_next_vmid = 1;
7395
7396 /*
7397 -@@ -442,7 +442,7 @@ static void update_vttbr(struct kvm *kvm)
7398 +@@ -443,7 +443,7 @@ static void update_vttbr(struct kvm *kvm)
7399 kvm_call_hyp(__kvm_flush_vm_context);
7400 }
7401
7402 @@ -3375,27 +3375,27 @@ index 1ccbba9..7a95c29 100644
7403 }
7404
7405 diff --git a/arch/arm/mach-mvebu/coherency.c b/arch/arm/mach-mvebu/coherency.c
7406 -index 7e989d6..614bf8b 100644
7407 +index 474abff..0d6a05a 100644
7408 --- a/arch/arm/mach-mvebu/coherency.c
7409 +++ b/arch/arm/mach-mvebu/coherency.c
7410 @@ -163,7 +163,7 @@ exit:
7411
7412 /*
7413 - * This ioremap hook is used on Armada 375/38x to ensure that PCIe
7414 -- * memory areas are mapped as MT_UNCACHED instead of MT_DEVICE. This
7415 -+ * memory areas are mapped as MT_UNCACHED_RW instead of MT_DEVICE. This
7416 - * is needed as a workaround for a deadlock issue between the PCIe
7417 - * interface and the cache controller.
7418 - */
7419 -@@ -176,7 +176,7 @@ armada_pcie_wa_ioremap_caller(phys_addr_t phys_addr, size_t size,
7420 - mvebu_mbus_get_pcie_mem_aperture(&pcie_mem);
7421 -
7422 - if (pcie_mem.start <= phys_addr && (phys_addr + size) <= pcie_mem.end)
7423 -- mtype = MT_UNCACHED;
7424 -+ mtype = MT_UNCACHED_RW;
7425 -
7426 + * This ioremap hook is used on Armada 375/38x to ensure that all MMIO
7427 +- * areas are mapped as MT_UNCACHED instead of MT_DEVICE. This is
7428 ++ * areas are mapped as MT_UNCACHED_RW instead of MT_DEVICE. This is
7429 + * needed for the HW I/O coherency mechanism to work properly without
7430 + * deadlock.
7431 + */
7432 +@@ -171,7 +171,7 @@ static void __iomem *
7433 + armada_wa_ioremap_caller(phys_addr_t phys_addr, size_t size,
7434 + unsigned int mtype, void *caller)
7435 + {
7436 +- mtype = MT_UNCACHED;
7437 ++ mtype = MT_UNCACHED_RW;
7438 return __arm_ioremap_caller(phys_addr, size, mtype, caller);
7439 }
7440 +
7441 diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
7442 index b6443a4..20a0b74 100644
7443 --- a/arch/arm/mach-omap2/board-n8x0.c
7444 @@ -8974,7 +8974,7 @@ index 5a7a78f..c0e4207 100644
7445 sechdrs, module);
7446 if (!module->arch.tramp)
7447 diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
7448 -index b8500b4..2873781 100644
7449 +index bec85055..8a6b0c2b 100644
7450 --- a/arch/powerpc/kernel/process.c
7451 +++ b/arch/powerpc/kernel/process.c
7452 @@ -1318,8 +1318,8 @@ void show_regs(struct pt_regs * regs)
7453 @@ -8988,7 +8988,7 @@ index b8500b4..2873781 100644
7454 #endif
7455 show_stack(current, (unsigned long *) regs->gpr[1]);
7456 if (!user_mode(regs))
7457 -@@ -1829,10 +1829,10 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
7458 +@@ -1839,10 +1839,10 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
7459 newsp = stack[0];
7460 ip = stack[STACK_FRAME_LR_SAVE];
7461 if (!firstframe || ip != lr) {
7462 @@ -9001,7 +9001,7 @@ index b8500b4..2873781 100644
7463 (void *)current->ret_stack[curr_frame].ret);
7464 curr_frame--;
7465 }
7466 -@@ -1852,7 +1852,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
7467 +@@ -1862,7 +1862,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
7468 struct pt_regs *regs = (struct pt_regs *)
7469 (sp + STACK_FRAME_OVERHEAD);
7470 lr = regs->link;
7471 @@ -9010,7 +9010,7 @@ index b8500b4..2873781 100644
7472 regs->trap, (void *)regs->nip, (void *)lr);
7473 firstframe = 1;
7474 }
7475 -@@ -1889,13 +1889,6 @@ void notrace __ppc64_runlatch_off(void)
7476 +@@ -1899,13 +1899,6 @@ void notrace __ppc64_runlatch_off(void)
7477 }
7478 #endif /* CONFIG_PPC64 */
7479
7480 @@ -16778,7 +16778,7 @@ index 10868aa..e645e1d 100644
7481 +ENDPROC(async_page_fault)
7482 #endif
7483 diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
7484 -index 858b555..d5a0c9b 100644
7485 +index 858b555..9e9c957 100644
7486 --- a/arch/x86/entry/entry_64.S
7487 +++ b/arch/x86/entry/entry_64.S
7488 @@ -36,6 +36,8 @@
7489 @@ -16790,7 +16790,7 @@ index 858b555..d5a0c9b 100644
7490
7491 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
7492 #include <linux/elf-em.h>
7493 -@@ -53,6 +55,402 @@ ENTRY(native_usergs_sysret64)
7494 +@@ -53,6 +55,395 @@ ENTRY(native_usergs_sysret64)
7495 ENDPROC(native_usergs_sysret64)
7496 #endif /* CONFIG_PARAVIRT */
7497
7498 @@ -16974,8 +16974,6 @@ index 858b555..d5a0c9b 100644
7499 + sub phys_base(%rip),%rbx
7500 +
7501 +#ifdef CONFIG_PARAVIRT
7502 -+ cmpl $0, pv_info+PARAVIRT_enabled
7503 -+ jz 1f
7504 + pushq %rdi
7505 + i = 0
7506 + .rept USER_PGD_PTRS
7507 @@ -16986,17 +16984,15 @@ index 858b555..d5a0c9b 100644
7508 + i = i + 1
7509 + .endr
7510 + popq %rdi
7511 -+ jmp 2f
7512 -+1:
7513 -+#endif
7514 -+
7515 ++#else
7516 + i = 0
7517 + .rept USER_PGD_PTRS
7518 + movb $0,i*8(%rbx)
7519 + i = i + 1
7520 + .endr
7521 ++#endif
7522 +
7523 -+2: SET_RDI_INTO_CR3
7524 ++ SET_RDI_INTO_CR3
7525 +
7526 +#ifdef CONFIG_PAX_KERNEXEC
7527 + GET_CR0_INTO_RDI
7528 @@ -17048,8 +17044,6 @@ index 858b555..d5a0c9b 100644
7529 + sub phys_base(%rip),%rbx
7530 +
7531 +#ifdef CONFIG_PARAVIRT
7532 -+ cmpl $0, pv_info+PARAVIRT_enabled
7533 -+ jz 1f
7534 + i = 0
7535 + .rept USER_PGD_PTRS
7536 + mov i*8(%rbx),%rsi
7537 @@ -17058,15 +17052,14 @@ index 858b555..d5a0c9b 100644
7538 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
7539 + i = i + 1
7540 + .endr
7541 -+ jmp 2f
7542 -+1:
7543 -+#endif
7544 -+
7545 ++#else
7546 + i = 0
7547 + .rept USER_PGD_PTRS
7548 + movb $0x67,i*8(%rbx)
7549 + i = i + 1
7550 + .endr
7551 ++#endif
7552 ++
7553 +2:
7554 +
7555 +#ifdef CONFIG_PARAVIRT
7556 @@ -17193,7 +17186,7 @@ index 858b555..d5a0c9b 100644
7557 .macro TRACE_IRQS_IRETQ
7558 #ifdef CONFIG_TRACE_IRQFLAGS
7559 bt $9, EFLAGS(%rsp) /* interrupts off? */
7560 -@@ -88,7 +486,7 @@ ENDPROC(native_usergs_sysret64)
7561 +@@ -88,7 +479,7 @@ ENDPROC(native_usergs_sysret64)
7562 .endm
7563
7564 .macro TRACE_IRQS_IRETQ_DEBUG
7565 @@ -17202,7 +17195,7 @@ index 858b555..d5a0c9b 100644
7566 jnc 1f
7567 TRACE_IRQS_ON_DEBUG
7568 1:
7569 -@@ -175,11 +573,22 @@ GLOBAL(entry_SYSCALL_64_after_swapgs)
7570 +@@ -175,11 +566,22 @@ GLOBAL(entry_SYSCALL_64_after_swapgs)
7571 pushq %r11 /* pt_regs->r11 */
7572 sub $(6*8), %rsp /* pt_regs->bp, bx, r12-15 not saved */
7573
7574 @@ -17226,7 +17219,7 @@ index 858b555..d5a0c9b 100644
7575 jnz entry_SYSCALL64_slow_path
7576
7577 entry_SYSCALL_64_fastpath:
7578 -@@ -217,9 +626,13 @@ entry_SYSCALL_64_fastpath:
7579 +@@ -217,9 +619,13 @@ entry_SYSCALL_64_fastpath:
7580 */
7581 DISABLE_INTERRUPTS(CLBR_NONE)
7582 TRACE_IRQS_OFF
7583 @@ -17241,7 +17234,7 @@ index 858b555..d5a0c9b 100644
7584 LOCKDEP_SYS_EXIT
7585 TRACE_IRQS_ON /* user mode is traced as IRQs on */
7586 movq RIP(%rsp), %rcx
7587 -@@ -248,6 +661,9 @@ entry_SYSCALL64_slow_path:
7588 +@@ -248,6 +654,9 @@ entry_SYSCALL64_slow_path:
7589 call do_syscall_64 /* returns with IRQs disabled */
7590
7591 return_from_SYSCALL_64:
7592 @@ -17251,7 +17244,7 @@ index 858b555..d5a0c9b 100644
7593 RESTORE_EXTRA_REGS
7594 TRACE_IRQS_IRETQ /* we're about to change IF */
7595
7596 -@@ -322,7 +738,7 @@ syscall_return_via_sysret:
7597 +@@ -322,7 +731,7 @@ syscall_return_via_sysret:
7598 opportunistic_sysret_failed:
7599 SWAPGS
7600 jmp restore_c_regs_and_iret
7601 @@ -17260,7 +17253,7 @@ index 858b555..d5a0c9b 100644
7602
7603 ENTRY(stub_ptregs_64)
7604 /*
7605 -@@ -349,13 +765,13 @@ ENTRY(stub_ptregs_64)
7606 +@@ -349,13 +758,13 @@ ENTRY(stub_ptregs_64)
7607 1:
7608 /* Called from C */
7609 jmp *%rax /* called from C */
7610 @@ -17276,7 +17269,7 @@ index 858b555..d5a0c9b 100644
7611 .endm
7612
7613 /* Instantiate ptregs_stub for each ptregs-using syscall */
7614 -@@ -400,10 +816,12 @@ ENTRY(ret_from_fork)
7615 +@@ -400,10 +809,12 @@ ENTRY(ret_from_fork)
7616 1:
7617 movq %rsp, %rdi
7618 call syscall_return_slowpath /* returns with IRQs disabled */
7619 @@ -17290,7 +17283,7 @@ index 858b555..d5a0c9b 100644
7620
7621 /*
7622 * Build the entry stubs with some assembler magic.
7623 -@@ -418,7 +836,7 @@ ENTRY(irq_entries_start)
7624 +@@ -418,7 +829,7 @@ ENTRY(irq_entries_start)
7625 jmp common_interrupt
7626 .align 8
7627 .endr
7628 @@ -17299,7 +17292,7 @@ index 858b555..d5a0c9b 100644
7629
7630 /*
7631 * Interrupt entry/exit.
7632 -@@ -444,6 +862,12 @@ END(irq_entries_start)
7633 +@@ -444,6 +855,12 @@ END(irq_entries_start)
7634 */
7635 SWAPGS
7636
7637 @@ -17312,7 +17305,7 @@ index 858b555..d5a0c9b 100644
7638 /*
7639 * We need to tell lockdep that IRQs are off. We can't do this until
7640 * we fix gsbase, and we should do it before enter_from_user_mode
7641 -@@ -456,7 +880,9 @@ END(irq_entries_start)
7642 +@@ -456,7 +873,9 @@ END(irq_entries_start)
7643
7644 CALL_enter_from_user_mode
7645
7646 @@ -17323,7 +17316,7 @@ index 858b555..d5a0c9b 100644
7647 /*
7648 * Save previous stack pointer, optionally switch to interrupt stack.
7649 * irq_count is used to check if a CPU is already on an interrupt stack
7650 -@@ -468,6 +894,7 @@ END(irq_entries_start)
7651 +@@ -468,6 +887,7 @@ END(irq_entries_start)
7652 incl PER_CPU_VAR(irq_count)
7653 cmovzq PER_CPU_VAR(irq_stack_ptr), %rsp
7654 pushq %rdi
7655 @@ -17331,7 +17324,7 @@ index 858b555..d5a0c9b 100644
7656 /* We entered an interrupt context - irqs are off: */
7657 TRACE_IRQS_OFF
7658
7659 -@@ -499,6 +926,8 @@ ret_from_intr:
7660 +@@ -499,6 +919,8 @@ ret_from_intr:
7661 GLOBAL(retint_user)
7662 mov %rsp,%rdi
7663 call prepare_exit_to_usermode
7664 @@ -17340,7 +17333,7 @@ index 858b555..d5a0c9b 100644
7665 TRACE_IRQS_IRETQ
7666 SWAPGS
7667 jmp restore_regs_and_iret
7668 -@@ -516,6 +945,21 @@ retint_kernel:
7669 +@@ -516,6 +938,21 @@ retint_kernel:
7670 jmp 0b
7671 1:
7672 #endif
7673 @@ -17362,7 +17355,7 @@ index 858b555..d5a0c9b 100644
7674 /*
7675 * The iretq could re-enable interrupts:
7676 */
7677 -@@ -559,15 +1003,15 @@ native_irq_return_ldt:
7678 +@@ -559,15 +996,15 @@ native_irq_return_ldt:
7679 SWAPGS
7680 movq PER_CPU_VAR(espfix_waddr), %rdi
7681 movq %rax, (0*8)(%rdi) /* RAX */
7682 @@ -17383,7 +17376,7 @@ index 858b555..d5a0c9b 100644
7683 movq %rax, (4*8)(%rdi)
7684 andl $0xffff0000, %eax
7685 popq %rdi
7686 -@@ -577,7 +1021,7 @@ native_irq_return_ldt:
7687 +@@ -577,7 +1014,7 @@ native_irq_return_ldt:
7688 popq %rax
7689 jmp native_irq_return_iret
7690 #endif
7691 @@ -17392,7 +17385,7 @@ index 858b555..d5a0c9b 100644
7692
7693 /*
7694 * APIC interrupts.
7695 -@@ -589,7 +1033,7 @@ ENTRY(\sym)
7696 +@@ -589,7 +1026,7 @@ ENTRY(\sym)
7697 .Lcommon_\sym:
7698 interrupt \do_sym
7699 jmp ret_from_intr
7700 @@ -17401,7 +17394,7 @@ index 858b555..d5a0c9b 100644
7701 .endm
7702
7703 #ifdef CONFIG_TRACING
7704 -@@ -654,7 +1098,7 @@ apicinterrupt IRQ_WORK_VECTOR irq_work_interrupt smp_irq_work_interrupt
7705 +@@ -654,7 +1091,7 @@ apicinterrupt IRQ_WORK_VECTOR irq_work_interrupt smp_irq_work_interrupt
7706 /*
7707 * Exception entry points.
7708 */
7709 @@ -17410,7 +17403,7 @@ index 858b555..d5a0c9b 100644
7710
7711 .macro idtentry sym do_sym has_error_code:req paranoid=0 shift_ist=-1
7712 ENTRY(\sym)
7713 -@@ -701,6 +1145,12 @@ ENTRY(\sym)
7714 +@@ -701,6 +1138,12 @@ ENTRY(\sym)
7715 .endif
7716
7717 .if \shift_ist != -1
7718 @@ -17423,7 +17416,7 @@ index 858b555..d5a0c9b 100644
7719 subq $EXCEPTION_STKSZ, CPU_TSS_IST(\shift_ist)
7720 .endif
7721
7722 -@@ -744,7 +1194,7 @@ ENTRY(\sym)
7723 +@@ -744,7 +1187,7 @@ ENTRY(\sym)
7724
7725 jmp error_exit /* %ebx: no swapgs flag */
7726 .endif
7727 @@ -17432,7 +17425,7 @@ index 858b555..d5a0c9b 100644
7728 .endm
7729
7730 #ifdef CONFIG_TRACING
7731 -@@ -786,8 +1236,9 @@ gs_change:
7732 +@@ -786,8 +1229,9 @@ gs_change:
7733 2: mfence /* workaround */
7734 SWAPGS
7735 popfq
7736 @@ -17443,7 +17436,7 @@ index 858b555..d5a0c9b 100644
7737
7738 _ASM_EXTABLE(gs_change, bad_gs)
7739 .section .fixup, "ax"
7740 -@@ -809,8 +1260,9 @@ ENTRY(do_softirq_own_stack)
7741 +@@ -809,8 +1253,9 @@ ENTRY(do_softirq_own_stack)
7742 call __do_softirq
7743 leaveq
7744 decl PER_CPU_VAR(irq_count)
7745 @@ -17454,7 +17447,7 @@ index 858b555..d5a0c9b 100644
7746
7747 #ifdef CONFIG_XEN
7748 idtentry xen_hypervisor_callback xen_do_hypervisor_callback has_error_code=0
7749 -@@ -846,7 +1298,7 @@ ENTRY(xen_do_hypervisor_callback) /* do_hypervisor_callback(struct *pt_regs) */
7750 +@@ -846,7 +1291,7 @@ ENTRY(xen_do_hypervisor_callback) /* do_hypervisor_callback(struct *pt_regs) */
7751 call xen_maybe_preempt_hcall
7752 #endif
7753 jmp error_exit
7754 @@ -17463,7 +17456,7 @@ index 858b555..d5a0c9b 100644
7755
7756 /*
7757 * Hypervisor uses this for application faults while it executes.
7758 -@@ -891,7 +1343,7 @@ ENTRY(xen_failsafe_callback)
7759 +@@ -891,7 +1336,7 @@ ENTRY(xen_failsafe_callback)
7760 SAVE_C_REGS
7761 SAVE_EXTRA_REGS
7762 jmp error_exit
7763 @@ -17472,7 +17465,7 @@ index 858b555..d5a0c9b 100644
7764
7765 apicinterrupt3 HYPERVISOR_CALLBACK_VECTOR \
7766 xen_hvm_callback_vector xen_evtchn_do_upcall
7767 -@@ -903,7 +1355,7 @@ apicinterrupt3 HYPERVISOR_CALLBACK_VECTOR \
7768 +@@ -903,7 +1348,7 @@ apicinterrupt3 HYPERVISOR_CALLBACK_VECTOR \
7769 hyperv_callback_vector hyperv_vector_handler
7770 #endif /* CONFIG_HYPERV */
7771
7772 @@ -17481,7 +17474,7 @@ index 858b555..d5a0c9b 100644
7773 idtentry int3 do_int3 has_error_code=0 paranoid=1 shift_ist=DEBUG_STACK
7774 idtentry stack_segment do_stack_segment has_error_code=1
7775
7776 -@@ -940,8 +1392,34 @@ ENTRY(paranoid_entry)
7777 +@@ -940,8 +1385,34 @@ ENTRY(paranoid_entry)
7778 js 1f /* negative -> in kernel */
7779 SWAPGS
7780 xorl %ebx, %ebx
7781 @@ -17518,7 +17511,7 @@ index 858b555..d5a0c9b 100644
7782
7783 /*
7784 * "Paranoid" exit path from exception stack. This is invoked
7785 -@@ -958,19 +1436,26 @@ END(paranoid_entry)
7786 +@@ -958,19 +1429,26 @@ END(paranoid_entry)
7787 ENTRY(paranoid_exit)
7788 DISABLE_INTERRUPTS(CLBR_NONE)
7789 TRACE_IRQS_OFF_DEBUG
7790 @@ -17547,7 +17540,7 @@ index 858b555..d5a0c9b 100644
7791
7792 /*
7793 * Save all registers in pt_regs, and switch gs if needed.
7794 -@@ -984,13 +1469,18 @@ ENTRY(error_entry)
7795 +@@ -984,13 +1462,18 @@ ENTRY(error_entry)
7796 testb $3, CS+8(%rsp)
7797 jz .Lerror_kernelspace
7798
7799 @@ -17567,7 +17560,7 @@ index 858b555..d5a0c9b 100644
7800 .Lerror_entry_from_usermode_after_swapgs:
7801 /*
7802 * We need to tell lockdep that IRQs are off. We can't do this until
7803 -@@ -999,10 +1489,12 @@ ENTRY(error_entry)
7804 +@@ -999,10 +1482,12 @@ ENTRY(error_entry)
7805 */
7806 TRACE_IRQS_OFF
7807 CALL_enter_from_user_mode
7808 @@ -17580,7 +17573,7 @@ index 858b555..d5a0c9b 100644
7809 ret
7810
7811 /*
7812 -@@ -1020,14 +1512,16 @@ ENTRY(error_entry)
7813 +@@ -1020,14 +1505,16 @@ ENTRY(error_entry)
7814 cmpq %rax, RIP+8(%rsp)
7815 je .Lbstep_iret
7816 cmpq $gs_change, RIP+8(%rsp)
7817 @@ -17599,7 +17592,7 @@ index 858b555..d5a0c9b 100644
7818
7819 .Lbstep_iret:
7820 /* Fix truncated RIP */
7821 -@@ -1041,6 +1535,12 @@ ENTRY(error_entry)
7822 +@@ -1041,6 +1528,12 @@ ENTRY(error_entry)
7823 */
7824 SWAPGS
7825
7826 @@ -17612,7 +17605,7 @@ index 858b555..d5a0c9b 100644
7827 /*
7828 * Pretend that the exception came from user mode: set up pt_regs
7829 * as if we faulted immediately after IRET and clear EBX so that
7830 -@@ -1051,11 +1551,11 @@ ENTRY(error_entry)
7831 +@@ -1051,11 +1544,11 @@ ENTRY(error_entry)
7832 mov %rax, %rsp
7833 decl %ebx
7834 jmp .Lerror_entry_from_usermode_after_swapgs
7835 @@ -17626,7 +17619,7 @@ index 858b555..d5a0c9b 100644
7836 * 1: already in kernel mode, don't need SWAPGS
7837 * 0: user gsbase is loaded, we need SWAPGS and standard preparation for return to usermode
7838 */
7839 -@@ -1063,10 +1563,10 @@ ENTRY(error_exit)
7840 +@@ -1063,10 +1556,10 @@ ENTRY(error_exit)
7841 movl %ebx, %eax
7842 DISABLE_INTERRUPTS(CLBR_NONE)
7843 TRACE_IRQS_OFF
7844 @@ -17639,7 +17632,7 @@ index 858b555..d5a0c9b 100644
7845
7846 /* Runs on exception stack */
7847 ENTRY(nmi)
7848 -@@ -1120,6 +1620,8 @@ ENTRY(nmi)
7849 +@@ -1120,6 +1613,8 @@ ENTRY(nmi)
7850 * other IST entries.
7851 */
7852
7853 @@ -17648,7 +17641,7 @@ index 858b555..d5a0c9b 100644
7854 /* Use %rdx as our temp variable throughout */
7855 pushq %rdx
7856
7857 -@@ -1163,6 +1665,12 @@ ENTRY(nmi)
7858 +@@ -1163,6 +1658,12 @@ ENTRY(nmi)
7859 pushq %r14 /* pt_regs->r14 */
7860 pushq %r15 /* pt_regs->r15 */
7861
7862 @@ -17661,7 +17654,7 @@ index 858b555..d5a0c9b 100644
7863 /*
7864 * At this point we no longer need to worry about stack damage
7865 * due to nesting -- we're on the normal thread stack and we're
7866 -@@ -1173,12 +1681,19 @@ ENTRY(nmi)
7867 +@@ -1173,12 +1674,19 @@ ENTRY(nmi)
7868 movq $-1, %rsi
7869 call do_nmi
7870
7871 @@ -17681,7 +17674,7 @@ index 858b555..d5a0c9b 100644
7872 jmp restore_c_regs_and_iret
7873
7874 .Lnmi_from_kernel:
7875 -@@ -1300,6 +1815,7 @@ nested_nmi_out:
7876 +@@ -1300,6 +1808,7 @@ nested_nmi_out:
7877 popq %rdx
7878
7879 /* We are returning to kernel mode, so this cannot result in a fault. */
7880 @@ -17689,7 +17682,7 @@ index 858b555..d5a0c9b 100644
7881 INTERRUPT_RETURN
7882
7883 first_nmi:
7884 -@@ -1328,7 +1844,7 @@ first_nmi:
7885 +@@ -1328,7 +1837,7 @@ first_nmi:
7886 pushq %rsp /* RSP (minus 8 because of the previous push) */
7887 addq $8, (%rsp) /* Fix up RSP */
7888 pushfq /* RFLAGS */
7889 @@ -17698,7 +17691,7 @@ index 858b555..d5a0c9b 100644
7890 pushq $1f /* RIP */
7891 INTERRUPT_RETURN /* continues at repeat_nmi below */
7892 1:
7893 -@@ -1373,20 +1889,22 @@ end_repeat_nmi:
7894 +@@ -1373,20 +1882,22 @@ end_repeat_nmi:
7895 ALLOC_PT_GPREGS_ON_STACK
7896
7897 /*
7898 @@ -17724,7 +17717,7 @@ index 858b555..d5a0c9b 100644
7899 jnz nmi_restore
7900 nmi_swapgs:
7901 SWAPGS_UNSAFE_STACK
7902 -@@ -1397,6 +1915,8 @@ nmi_restore:
7903 +@@ -1397,6 +1908,8 @@ nmi_restore:
7904 /* Point RSP at the "iret" frame. */
7905 REMOVE_PT_GPREGS_FROM_STACK 6*8
7906
7907 @@ -17733,7 +17726,7 @@ index 858b555..d5a0c9b 100644
7908 /*
7909 * Clear "NMI executing". Set DF first so that we can easily
7910 * distinguish the remaining code between here and IRET from
7911 -@@ -1414,9 +1934,9 @@ nmi_restore:
7912 +@@ -1414,9 +1927,9 @@ nmi_restore:
7913 * mode, so this cannot result in a fault.
7914 */
7915 INTERRUPT_RETURN
7916 @@ -18249,7 +18242,7 @@ index 6011a57..311bea0 100644
7917
7918 while (amd_iommu_v2_event_descs[i].attr.attr.name)
7919 diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c
7920 -index 041e442..3ed82386 100644
7921 +index 7eb806c..13eb73d 100644
7922 --- a/arch/x86/events/core.c
7923 +++ b/arch/x86/events/core.c
7924 @@ -1535,7 +1535,7 @@ static void __init pmu_check_apic(void)
7925 @@ -18279,7 +18272,7 @@ index 041e442..3ed82386 100644
7926 }
7927
7928 return get_desc_base(desc);
7929 -@@ -2356,7 +2356,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
7930 +@@ -2357,7 +2357,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
7931 break;
7932
7933 perf_callchain_store(entry, frame.return_address);
7934 @@ -18645,7 +18638,7 @@ index 7377814..a128ad7 100644
7935 pt_config_stop(event);
7936
7937 diff --git a/arch/x86/events/intel/rapl.c b/arch/x86/events/intel/rapl.c
7938 -index 1705c9d..4204f6f 100644
7939 +index 78ee9eb..1aae264 100644
7940 --- a/arch/x86/events/intel/rapl.c
7941 +++ b/arch/x86/events/intel/rapl.c
7942 @@ -100,14 +100,14 @@ static const char *const rapl_domain_names[NR_RAPL_DOMAINS] __initconst = {
7943 @@ -19416,7 +19409,7 @@ index 3e86742..1b19554 100644
7944 * @v: pointer to type int
7945 *
7946 diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
7947 -index a984111..d1b3a88 100644
7948 +index a984111..7a258c7 100644
7949 --- a/arch/x86/include/asm/atomic64_32.h
7950 +++ b/arch/x86/include/asm/atomic64_32.h
7951 @@ -11,6 +11,14 @@ typedef struct {
7952 @@ -19616,6 +19609,25 @@ index a984111..d1b3a88 100644
7953 * atomic64_sub - subtract the atomic64 variable
7954 * @i: integer value to subtract
7955 * @v: pointer to type atomic64_t
7956 +@@ -222,6 +341,18 @@ static inline void atomic64_inc(atomic64_t *v)
7957 + }
7958 +
7959 + /**
7960 ++ * atomic64_inc_unchecked - increment atomic64 variable
7961 ++ * @v: pointer to type atomic64_unchecked_t
7962 ++ *
7963 ++ * Atomically increments @v by 1.
7964 ++ */
7965 ++static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
7966 ++{
7967 ++ __alternative_atomic64(inc_unchecked, inc_return_unchecked, /* no output */,
7968 ++ "S" (v) : "memory", "eax", "ecx", "edx");
7969 ++}
7970 ++
7971 ++/**
7972 + * atomic64_dec - decrement atomic64 variable
7973 + * @v: pointer to type atomic64_t
7974 + *
7975 diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
7976 index 0373510..3619c56 100644
7977 --- a/arch/x86/include/asm/atomic64_64.h
7978 @@ -25521,7 +25533,7 @@ index 9307f18..a43f175 100644
7979 proc_create("apm", 0, NULL, &apm_file_ops);
7980
7981 diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
7982 -index 5c04246..7492f2f 100644
7983 +index 5c04246..e280385 100644
7984 --- a/arch/x86/kernel/asm-offsets.c
7985 +++ b/arch/x86/kernel/asm-offsets.c
7986 @@ -32,6 +32,8 @@ void common(void) {
7987 @@ -25533,15 +25545,7 @@ index 5c04246..7492f2f 100644
7988
7989 BLANK();
7990 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
7991 -@@ -59,6 +61,7 @@ void common(void) {
7992 -
7993 - #ifdef CONFIG_PARAVIRT
7994 - BLANK();
7995 -+ OFFSET(PARAVIRT_enabled, pv_info, paravirt_enabled);
7996 - OFFSET(PARAVIRT_PATCH_pv_cpu_ops, paravirt_patch_template, pv_cpu_ops);
7997 - OFFSET(PARAVIRT_PATCH_pv_irq_ops, paravirt_patch_template, pv_irq_ops);
7998 - OFFSET(PV_IRQ_irq_disable, pv_irq_ops, irq_disable);
7999 -@@ -66,8 +69,26 @@ void common(void) {
8000 +@@ -66,8 +68,26 @@ void common(void) {
8001 OFFSET(PV_CPU_iret, pv_cpu_ops, iret);
8002 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
8003 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
8004 @@ -25568,7 +25572,7 @@ index 5c04246..7492f2f 100644
8005 #ifdef CONFIG_XEN
8006 BLANK();
8007 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
8008 -@@ -85,4 +106,5 @@ void common(void) {
8009 +@@ -85,4 +105,5 @@ void common(void) {
8010
8011 BLANK();
8012 DEFINE(PTREGS_SIZE, sizeof(struct pt_regs));
8013 @@ -28547,7 +28551,7 @@ index 2da6ee9..fc0ca78 100644
8014 }
8015
8016 diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
8017 -index ae703ac..d510d8a 100644
8018 +index 44bcd57..044428a 100644
8019 --- a/arch/x86/kernel/kprobes/core.c
8020 +++ b/arch/x86/kernel/kprobes/core.c
8021 @@ -121,9 +121,12 @@ __synthesize_relative_insn(void *from, void *to, u8 op)
8022 @@ -32012,7 +32016,7 @@ index 31346a3..038711e 100644
8023 .disabled_by_bios = is_disabled,
8024 .hardware_setup = svm_hardware_setup,
8025 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
8026 -index faf52bac..fdc4818 100644
8027 +index c4217a2..964fb8e 100644
8028 --- a/arch/x86/kvm/vmx.c
8029 +++ b/arch/x86/kvm/vmx.c
8030 @@ -1589,14 +1589,14 @@ static __always_inline void vmcs_writel(unsigned long field, unsigned long value
8031 @@ -32044,7 +32048,7 @@ index faf52bac..fdc4818 100644
8032 load_TR_desc();
8033 }
8034
8035 -@@ -2158,6 +2162,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
8036 +@@ -2159,6 +2163,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
8037 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
8038 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
8039
8040 @@ -32055,7 +32059,7 @@ index faf52bac..fdc4818 100644
8041 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
8042 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
8043
8044 -@@ -2481,7 +2489,7 @@ static void setup_msrs(struct vcpu_vmx *vmx)
8045 +@@ -2483,7 +2491,7 @@ static void setup_msrs(struct vcpu_vmx *vmx)
8046 * guest_tsc = (host_tsc * tsc multiplier) >> 48 + tsc_offset
8047 * -- Intel TSC Scaling for Virtualization White Paper, sec 1.3
8048 */
8049 @@ -32064,7 +32068,7 @@ index faf52bac..fdc4818 100644
8050 {
8051 u64 host_tsc, tsc_offset;
8052
8053 -@@ -4722,7 +4730,10 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
8054 +@@ -4724,7 +4732,10 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
8055 unsigned long cr4;
8056
8057 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
8058 @@ -32075,7 +32079,7 @@ index faf52bac..fdc4818 100644
8059
8060 /* Save the most likely value for this task's CR4 in the VMCS. */
8061 cr4 = cr4_read_shadow();
8062 -@@ -4749,7 +4760,7 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
8063 +@@ -4751,7 +4762,7 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
8064 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
8065 vmx->host_idt_base = dt.address;
8066
8067 @@ -32084,7 +32088,7 @@ index faf52bac..fdc4818 100644
8068
8069 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
8070 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
8071 -@@ -6297,11 +6308,17 @@ static __init int hardware_setup(void)
8072 +@@ -6299,11 +6310,17 @@ static __init int hardware_setup(void)
8073 * page upon invalidation. No need to do anything if not
8074 * using the APIC_ACCESS_ADDR VMCS field.
8075 */
8076 @@ -32104,7 +32108,7 @@ index faf52bac..fdc4818 100644
8077
8078 if (enable_ept && !cpu_has_vmx_ept_2m_page())
8079 kvm_disable_largepages();
8080 -@@ -6371,10 +6388,12 @@ static __init int hardware_setup(void)
8081 +@@ -6373,10 +6390,12 @@ static __init int hardware_setup(void)
8082 enable_pml = 0;
8083
8084 if (!enable_pml) {
8085 @@ -32117,7 +32121,7 @@ index faf52bac..fdc4818 100644
8086 }
8087
8088 kvm_set_posted_intr_wakeup_handler(wakeup_handler);
8089 -@@ -8705,6 +8724,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
8090 +@@ -8706,6 +8725,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
8091 "jmp 2f \n\t"
8092 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
8093 "2: "
8094 @@ -32130,7 +32134,7 @@ index faf52bac..fdc4818 100644
8095 /* Save guest registers, load host registers, keep flags */
8096 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
8097 "pop %0 \n\t"
8098 -@@ -8757,6 +8782,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
8099 +@@ -8758,6 +8783,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
8100 #endif
8101 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
8102 [wordsize]"i"(sizeof(ulong))
8103 @@ -32142,7 +32146,7 @@ index faf52bac..fdc4818 100644
8104 : "cc", "memory"
8105 #ifdef CONFIG_X86_64
8106 , "rax", "rbx", "rdi", "rsi"
8107 -@@ -8770,7 +8800,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
8108 +@@ -8771,7 +8801,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
8109 if (debugctlmsr)
8110 update_debugctlmsr(debugctlmsr);
8111
8112 @@ -32151,7 +32155,7 @@ index faf52bac..fdc4818 100644
8113 /*
8114 * The sysexit path does not restore ds/es, so we must set them to
8115 * a reasonable value ourselves.
8116 -@@ -8779,8 +8809,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
8117 +@@ -8780,8 +8810,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
8118 * may be executed in interrupt context, which saves and restore segments
8119 * around it, nullifying its effect.
8120 */
8121 @@ -32172,7 +32176,7 @@ index faf52bac..fdc4818 100644
8122 #endif
8123
8124 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
8125 -@@ -10889,7 +10929,7 @@ out:
8126 +@@ -10893,7 +10933,7 @@ out:
8127 return ret;
8128 }
8129
8130 @@ -36183,7 +36187,7 @@ index 9d56f27..0d15fff 100644
8131 (unsigned long)(&__init_begin),
8132 (unsigned long)(&__init_end));
8133 diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
8134 -index bd7a9b9..94d80a5 100644
8135 +index bd7a9b9..f1dad0b 100644
8136 --- a/arch/x86/mm/init_32.c
8137 +++ b/arch/x86/mm/init_32.c
8138 @@ -62,33 +62,6 @@ static noinline int do_test_wp_bit(void);
8139 @@ -36458,7 +36462,7 @@ index bd7a9b9..94d80a5 100644
8140 + struct desc_struct d;
8141 + int cpu;
8142
8143 -+ limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
8144 ++ limit = get_kernel_rpl() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
8145 + limit = (limit - 1UL) >> PAGE_SHIFT;
8146 +
8147 + memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
8148 @@ -36476,7 +36480,7 @@ index bd7a9b9..94d80a5 100644
8149 + start = ktla_ktva(start);
8150 +#ifdef CONFIG_PAX_KERNEXEC
8151 + /* PaX: make KERNEL_CS read-only */
8152 -+ if (!paravirt_enabled()) {
8153 ++ if (!get_kernel_rpl()) {
8154 +#endif
8155 kernel_set_to_readonly = 1;
8156
8157 @@ -42843,7 +42847,7 @@ index be54e53..50272fe 100644
8158 {
8159 struct hpet_timer __iomem *timer;
8160 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
8161 -index 94fb407..603dd43 100644
8162 +index 44b1bd6..6877066 100644
8163 --- a/drivers/char/ipmi/ipmi_msghandler.c
8164 +++ b/drivers/char/ipmi/ipmi_msghandler.c
8165 @@ -436,7 +436,7 @@ struct ipmi_smi {
8166 @@ -45022,7 +45026,7 @@ index ac8deb0..f3caa10 100644
8167 return -EINVAL;
8168 }
8169 diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
8170 -index cf3e712..2d532c3 100644
8171 +index 996a733..742b84f 100644
8172 --- a/drivers/gpio/gpiolib.c
8173 +++ b/drivers/gpio/gpiolib.c
8174 @@ -1031,8 +1031,10 @@ static void gpiochip_irqchip_remove(struct gpio_chip *gpiochip)
8175 @@ -45087,7 +45091,7 @@ index 35a1248..fd2510a 100644
8176 if (amdgpu_atpx_priv.dhandle == ACPI_HANDLE(&pdev->dev))
8177 return VGA_SWITCHEROO_IGD;
8178 diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
8179 -index 6043dc7..517c964 100644
8180 +index 3e21732..21fc524 100644
8181 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
8182 +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
8183 @@ -1076,49 +1076,49 @@ int amdgpu_cgs_call_acpi_method(void *cgs_device,
8184 @@ -45285,10 +45289,10 @@ index f1e17d6..e7d750a 100644
8185 amdgpu_sync_fini();
8186 }
8187 diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
8188 -index b04337d..7db2712 100644
8189 +index d78739d..64027ae 100644
8190 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
8191 +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
8192 -@@ -755,4 +755,4 @@ const struct drm_ioctl_desc amdgpu_ioctls_kms[] = {
8193 +@@ -756,4 +756,4 @@ const struct drm_ioctl_desc amdgpu_ioctls_kms[] = {
8194 DRM_IOCTL_DEF_DRV(AMDGPU_GEM_OP, amdgpu_gem_op_ioctl, DRM_AUTH|DRM_RENDER_ALLOW),
8195 DRM_IOCTL_DEF_DRV(AMDGPU_GEM_USERPTR, amdgpu_gem_userptr_ioctl, DRM_AUTH|DRM_RENDER_ALLOW),
8196 };
8197 @@ -46110,10 +46114,10 @@ index 96926f0..69097ba 100644
8198 {
8199 struct bochs_device *bochs =
8200 diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
8201 -index f30de80..7893e10 100644
8202 +index 691a1b9..8d05d29 100644
8203 --- a/drivers/gpu/drm/drm_crtc.c
8204 +++ b/drivers/gpu/drm/drm_crtc.c
8205 -@@ -4258,7 +4258,7 @@ int drm_mode_getproperty_ioctl(struct drm_device *dev,
8206 +@@ -4256,7 +4256,7 @@ int drm_mode_getproperty_ioctl(struct drm_device *dev,
8207 goto done;
8208 }
8209
8210 @@ -47008,10 +47012,10 @@ index d1a46ef..4999f42 100644
8211
8212 /**
8213 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
8214 -index 7741efb..483be63 100644
8215 +index e5db9e1..e07f0de 100644
8216 --- a/drivers/gpu/drm/i915/intel_display.c
8217 +++ b/drivers/gpu/drm/i915/intel_display.c
8218 -@@ -15120,13 +15120,13 @@ struct intel_quirk {
8219 +@@ -15140,13 +15140,13 @@ struct intel_quirk {
8220 int subsystem_vendor;
8221 int subsystem_device;
8222 void (*hook)(struct drm_device *dev);
8223 @@ -47028,7 +47032,7 @@ index 7741efb..483be63 100644
8224
8225 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
8226 {
8227 -@@ -15134,18 +15134,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
8228 +@@ -15154,18 +15154,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
8229 return 1;
8230 }
8231
8232 @@ -47059,7 +47063,7 @@ index 7741efb..483be63 100644
8233 .hook = quirk_invert_brightness,
8234 },
8235 };
8236 -@@ -15228,7 +15230,7 @@ static void intel_init_quirks(struct drm_device *dev)
8237 +@@ -15248,7 +15250,7 @@ static void intel_init_quirks(struct drm_device *dev)
8238 q->hook(dev);
8239 }
8240 for (i = 0; i < ARRAY_SIZE(intel_dmi_quirks); i++) {
8241 @@ -47206,10 +47210,10 @@ index 792f924..aeb1334 100644
8242 -int mga_max_ioctl = ARRAY_SIZE(mga_ioctls);
8243 +const int mga_max_ioctl = ARRAY_SIZE(mga_ioctls);
8244 diff --git a/drivers/gpu/drm/mgag200/mgag200_mode.c b/drivers/gpu/drm/mgag200/mgag200_mode.c
8245 -index 14e64e0..620b163 100644
8246 +index d347dca..887b809 100644
8247 --- a/drivers/gpu/drm/mgag200/mgag200_mode.c
8248 +++ b/drivers/gpu/drm/mgag200/mgag200_mode.c
8249 -@@ -1565,7 +1565,7 @@ static uint32_t mga_vga_calculate_mode_bandwidth(struct drm_display_mode *mode,
8250 +@@ -1573,7 +1573,7 @@ static uint32_t mga_vga_calculate_mode_bandwidth(struct drm_display_mode *mode,
8251
8252 #define MODE_BANDWIDTH MODE_BAD
8253
8254 @@ -48006,10 +48010,10 @@ index 81a63d7..5c7f8e7 100644
8255 {
8256 struct drm_device *dev = connector->dev;
8257 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
8258 -index d0826fb..b47e793 100644
8259 +index cb29868..33523a2 100644
8260 --- a/drivers/gpu/drm/radeon/radeon_device.c
8261 +++ b/drivers/gpu/drm/radeon/radeon_device.c
8262 -@@ -1253,7 +1253,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
8263 +@@ -1274,7 +1274,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
8264 * locking inversion with the driver load path. And the access here is
8265 * completely racy anyway. So don't bother with locking for now.
8266 */
8267 @@ -48989,10 +48993,10 @@ index 9fd924c..c64b065 100644
8268
8269 static int virtio_gpu_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,
8270 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
8271 -index 6db358a..6401339 100644
8272 +index cab0c54..c03f271 100644
8273 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
8274 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
8275 -@@ -437,7 +437,7 @@ struct vmw_private {
8276 +@@ -438,7 +438,7 @@ struct vmw_private {
8277 * Fencing and IRQs.
8278 */
8279
8280 @@ -49178,29 +49182,6 @@ index c13fb5b..55a3802 100644
8281 return -EFAULT;
8282
8283 *off += size;
8284 -diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
8285 -index 2f1ddca..700145b 100644
8286 ---- a/drivers/hid/usbhid/hiddev.c
8287 -+++ b/drivers/hid/usbhid/hiddev.c
8288 -@@ -516,13 +516,13 @@ static noinline int hiddev_ioctl_usage(struct hiddev *hiddev, unsigned int cmd,
8289 - goto inval;
8290 - } else if (uref->usage_index >= field->report_count)
8291 - goto inval;
8292 --
8293 -- else if ((cmd == HIDIOCGUSAGES || cmd == HIDIOCSUSAGES) &&
8294 -- (uref_multi->num_values > HID_MAX_MULTI_USAGES ||
8295 -- uref->usage_index + uref_multi->num_values > field->report_count))
8296 -- goto inval;
8297 - }
8298 -
8299 -+ if ((cmd == HIDIOCGUSAGES || cmd == HIDIOCSUSAGES) &&
8300 -+ (uref_multi->num_values > HID_MAX_MULTI_USAGES ||
8301 -+ uref->usage_index + uref_multi->num_values > field->report_count))
8302 -+ goto inval;
8303 -+
8304 - switch (cmd) {
8305 - case HIDIOCGUSAGE:
8306 - uref->value = field->value[uref->usage_index];
8307 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
8308 index 56dd261..493d7e0 100644
8309 --- a/drivers/hv/channel.c
8310 @@ -49488,10 +49469,10 @@ index 6a27eb2..349ed23 100644
8311 };
8312
8313 diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c
8314 -index c43318d..24bfd03 100644
8315 +index a9356a3..0785f99 100644
8316 --- a/drivers/hwmon/dell-smm-hwmon.c
8317 +++ b/drivers/hwmon/dell-smm-hwmon.c
8318 -@@ -819,7 +819,7 @@ static const struct i8k_config_data i8k_config_data[] = {
8319 +@@ -844,7 +844,7 @@ static const struct i8k_config_data i8k_config_data[] = {
8320 },
8321 };
8322
8323 @@ -49500,15 +49481,20 @@ index c43318d..24bfd03 100644
8324 {
8325 .ident = "Dell Inspiron",
8326 .matches = {
8327 -@@ -929,7 +929,7 @@ static struct dmi_system_id i8k_dmi_table[] __initdata = {
8328 -
8329 - MODULE_DEVICE_TABLE(dmi, i8k_dmi_table);
8330 -
8331 --static struct dmi_system_id i8k_blacklist_dmi_table[] __initdata = {
8332 -+static const struct dmi_system_id i8k_blacklist_dmi_table[] __initconst = {
8333 +@@ -960,8 +960,12 @@ MODULE_DEVICE_TABLE(dmi, i8k_dmi_table);
8334 + * of affected Dell machines for which we disallow I8K_SMM_GET_FAN_TYPE call.
8335 + * See bug: https://bugzilla.kernel.org/show_bug.cgi?id=100121
8336 + */
8337 +-static struct dmi_system_id i8k_blacklist_fan_type_dmi_table[] __initdata = {
8338 ++static const struct dmi_system_id i8k_blacklist_fan_type_dmi_table[] __initconst = {
8339 {
8340 - /*
8341 - * CPU fan speed going up and down on Dell Studio XPS 8000
8342 ++ /*
8343 ++ * CPU fan speed going up and down on Dell Studio XPS 8000
8344 ++ * for unknown reasons.
8345 ++ */
8346 + .ident = "Dell Studio XPS 8000",
8347 + .matches = {
8348 + DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
8349 diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
8350 index 1f64378..2b6e615 100644
8351 --- a/drivers/hwmon/ibmaem.c
8352 @@ -49830,7 +49816,7 @@ index 0e931a9..f7cba63 100644
8353
8354 if (chipset >= AK_MAX_TYPE) {
8355 diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
8356 -index 1d92e09..215593e 100644
8357 +index c995255..7de0b49 100644
8358 --- a/drivers/infiniband/core/cm.c
8359 +++ b/drivers/infiniband/core/cm.c
8360 @@ -115,7 +115,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
8361 @@ -51368,7 +51354,7 @@ index 5efadad..d1b358e 100644
8362 CMD_SET_TYPE(cmd, CMD_COMPL_WAIT);
8363 }
8364 diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c
8365 -index 4ff73ff..6f1ffa8 100644
8366 +index 3e20208..e0a3c34 100644
8367 --- a/drivers/iommu/arm-smmu-v3.c
8368 +++ b/drivers/iommu/arm-smmu-v3.c
8369 @@ -1562,7 +1562,7 @@ static int arm_smmu_domain_finalise(struct iommu_domain *domain)
8370 @@ -57959,7 +57945,7 @@ index 170dd68..19b339d 100644
8371 err = -EFAULT;
8372 goto out_array_args;
8373 diff --git a/drivers/memory/omap-gpmc.c b/drivers/memory/omap-gpmc.c
8374 -index 21825dd..6e29aa3 100644
8375 +index 859b4a1..a6f983f 100644
8376 --- a/drivers/memory/omap-gpmc.c
8377 +++ b/drivers/memory/omap-gpmc.c
8378 @@ -232,7 +232,6 @@ struct omap3_gpmc_regs {
8379 @@ -62979,10 +62965,10 @@ index 4684644..6687c7f 100644
8380 u32 ii;
8381 u32 num_frag;
8382 diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c
8383 -index 9fcb489..8f58614 100644
8384 +index c70e515..4abd90a 100644
8385 --- a/drivers/net/geneve.c
8386 +++ b/drivers/net/geneve.c
8387 -@@ -1508,7 +1508,7 @@ nla_put_failure:
8388 +@@ -1513,7 +1513,7 @@ nla_put_failure:
8389 return -EMSGSIZE;
8390 }
8391
8392 @@ -63234,10 +63220,10 @@ index a400288..0c59bcd 100644
8393 .init = loopback_net_init,
8394 };
8395 diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
8396 -index 9e803bb..fb251d2 100644
8397 +index 8f3c55d..223d73b 100644
8398 --- a/drivers/net/macsec.c
8399 +++ b/drivers/net/macsec.c
8400 -@@ -3217,7 +3217,7 @@ nla_put_failure:
8401 +@@ -3218,7 +3218,7 @@ nla_put_failure:
8402 return -EMSGSIZE;
8403 }
8404
8405 @@ -67468,10 +67454,10 @@ index 48e8a97..3499ec8 100644
8406
8407 const struct iw_handler_def prism54_handler_def = {
8408 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
8409 -index e85e073..5242113 100644
8410 +index 06664ba..974b505 100644
8411 --- a/drivers/net/wireless/mac80211_hwsim.c
8412 +++ b/drivers/net/wireless/mac80211_hwsim.c
8413 -@@ -3218,20 +3218,20 @@ static int __init init_mac80211_hwsim(void)
8414 +@@ -3219,20 +3219,20 @@ static int __init init_mac80211_hwsim(void)
8415 if (channels < 1)
8416 return -EINVAL;
8417
8418 @@ -73037,6 +73023,125 @@ index 1deb6ad..3057db5 100644
8419 drv = scsi_cmd_to_driver(cmd);
8420 if (drv->done)
8421 good_bytes = drv->done(cmd);
8422 +diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
8423 +index f3d69a98..40f8223 100644
8424 +--- a/drivers/scsi/scsi_debug.c
8425 ++++ b/drivers/scsi/scsi_debug.c
8426 +@@ -559,9 +559,9 @@ static bool scsi_debug_host_lock = DEF_HOST_LOCK;
8427 + static bool scsi_debug_strict = DEF_STRICT;
8428 + static bool sdebug_any_injecting_opt;
8429 +
8430 +-static atomic_t sdebug_cmnd_count;
8431 +-static atomic_t sdebug_completions;
8432 +-static atomic_t sdebug_a_tsf; /* counter of 'almost' TSFs */
8433 ++static atomic_unchecked_t sdebug_cmnd_count;
8434 ++static atomic_unchecked_t sdebug_completions;
8435 ++static atomic_unchecked_t sdebug_a_tsf; /* counter of 'almost' TSFs */
8436 +
8437 + #define DEV_READONLY(TGT) (0)
8438 +
8439 +@@ -3447,7 +3447,7 @@ static void sdebug_q_cmd_complete(unsigned long indx)
8440 + struct scsi_cmnd *scp;
8441 + struct sdebug_dev_info *devip;
8442 +
8443 +- atomic_inc(&sdebug_completions);
8444 ++ atomic_inc_unchecked(&sdebug_completions);
8445 + qa_indx = indx;
8446 + if ((qa_indx < 0) || (qa_indx >= SCSI_DEBUG_CANQUEUE)) {
8447 + pr_err("wild qa_indx=%d\n", qa_indx);
8448 +@@ -3507,7 +3507,7 @@ sdebug_q_cmd_hrt_complete(struct hrtimer *timer)
8449 + struct scsi_cmnd *scp;
8450 + struct sdebug_dev_info *devip;
8451 +
8452 +- atomic_inc(&sdebug_completions);
8453 ++ atomic_inc_unchecked(&sdebug_completions);
8454 + qa_indx = sd_hrtp->qa_indx;
8455 + if ((qa_indx < 0) || (qa_indx >= SCSI_DEBUG_CANQUEUE)) {
8456 + pr_err("wild qa_indx=%d\n", qa_indx);
8457 +@@ -3976,9 +3976,9 @@ schedule_resp(struct scsi_cmnd *cmnd, struct sdebug_dev_info *devip,
8458 + (SCSI_DEBUG_OPT_RARE_TSF & scsi_debug_opts) &&
8459 + (scsi_result == 0)) {
8460 + if ((num_in_q == (qdepth - 1)) &&
8461 +- (atomic_inc_return(&sdebug_a_tsf) >=
8462 ++ (atomic_inc_return_unchecked(&sdebug_a_tsf) >=
8463 + abs(scsi_debug_every_nth))) {
8464 +- atomic_set(&sdebug_a_tsf, 0);
8465 ++ atomic_set_unchecked(&sdebug_a_tsf, 0);
8466 + inject = 1;
8467 + scsi_result = device_qfull_result;
8468 + }
8469 +@@ -4182,7 +4182,7 @@ static int scsi_debug_write_info(struct Scsi_Host *host, char *buffer, int lengt
8470 + return -EINVAL;
8471 + scsi_debug_opts = opts;
8472 + if (scsi_debug_every_nth != 0)
8473 +- atomic_set(&sdebug_cmnd_count, 0);
8474 ++ atomic_set_unchecked(&sdebug_cmnd_count, 0);
8475 + return length;
8476 + }
8477 +
8478 +@@ -4197,8 +4197,8 @@ static int scsi_debug_show_info(struct seq_file *m, struct Scsi_Host *host)
8479 + if (scsi_debug_every_nth > 0)
8480 + snprintf(b, sizeof(b), " (curr:%d)",
8481 + ((SCSI_DEBUG_OPT_RARE_TSF & scsi_debug_opts) ?
8482 +- atomic_read(&sdebug_a_tsf) :
8483 +- atomic_read(&sdebug_cmnd_count)));
8484 ++ atomic_read_unchecked(&sdebug_a_tsf) :
8485 ++ atomic_read_unchecked(&sdebug_cmnd_count)));
8486 + else
8487 + b[0] = '\0';
8488 +
8489 +@@ -4213,7 +4213,7 @@ static int scsi_debug_show_info(struct seq_file *m, struct Scsi_Host *host)
8490 + SCSI_DEBUG_VERSION, scsi_debug_version_date,
8491 + scsi_debug_num_tgts, scsi_debug_dev_size_mb, scsi_debug_opts,
8492 + scsi_debug_every_nth, b, scsi_debug_delay, scsi_debug_ndelay,
8493 +- scsi_debug_max_luns, atomic_read(&sdebug_completions),
8494 ++ scsi_debug_max_luns, atomic_read_unchecked(&sdebug_completions),
8495 + scsi_debug_sector_size, sdebug_cylinders_per, sdebug_heads,
8496 + sdebug_sectors_per, num_aborts, num_dev_resets,
8497 + num_target_resets, num_bus_resets, num_host_resets,
8498 +@@ -4328,8 +4328,8 @@ opts_done:
8499 + sdebug_any_injecting_opt = true;
8500 + else if (SCSI_DEBUG_OPT_SHORT_TRANSFER & opts)
8501 + sdebug_any_injecting_opt = true;
8502 +- atomic_set(&sdebug_cmnd_count, 0);
8503 +- atomic_set(&sdebug_a_tsf, 0);
8504 ++ atomic_set_unchecked(&sdebug_cmnd_count, 0);
8505 ++ atomic_set_unchecked(&sdebug_a_tsf, 0);
8506 + return count;
8507 + }
8508 + static DRIVER_ATTR_RW(opts);
8509 +@@ -4459,7 +4459,7 @@ static ssize_t every_nth_store(struct device_driver *ddp, const char *buf,
8510 +
8511 + if ((count > 0) && (1 == sscanf(buf, "%d", &nth))) {
8512 + scsi_debug_every_nth = nth;
8513 +- atomic_set(&sdebug_cmnd_count, 0);
8514 ++ atomic_set_unchecked(&sdebug_cmnd_count, 0);
8515 + return count;
8516 + }
8517 + return -EINVAL;
8518 +@@ -4783,8 +4783,8 @@ static int __init scsi_debug_init(void)
8519 + int k;
8520 + int ret;
8521 +
8522 +- atomic_set(&sdebug_cmnd_count, 0);
8523 +- atomic_set(&sdebug_completions, 0);
8524 ++ atomic_set_unchecked(&sdebug_cmnd_count, 0);
8525 ++ atomic_set_unchecked(&sdebug_completions, 0);
8526 + atomic_set(&retired_max_queue, 0);
8527 +
8528 + if (scsi_debug_ndelay >= 1000000000) {
8529 +@@ -5106,9 +5106,9 @@ check_inject(struct scsi_cmnd *scp)
8530 +
8531 + memset(ep, 0, sizeof(struct sdebug_scmd_extra_t));
8532 +
8533 +- if (atomic_inc_return(&sdebug_cmnd_count) >=
8534 ++ if (atomic_inc_return_unchecked(&sdebug_cmnd_count) >=
8535 + abs(scsi_debug_every_nth)) {
8536 +- atomic_set(&sdebug_cmnd_count, 0);
8537 ++ atomic_set_unchecked(&sdebug_cmnd_count, 0);
8538 + if (scsi_debug_every_nth < -1)
8539 + scsi_debug_every_nth = -1;
8540 + if (SCSI_DEBUG_OPT_TIMEOUT & scsi_debug_opts)
8541 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
8542 index f704d02..18cad07 100644
8543 --- a/drivers/scsi/scsi_lib.c
8544 @@ -73209,7 +73314,7 @@ index e3cd3ec..97ab643 100644
8545
8546 transport_setup_device(&rport->dev);
8547 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
8548 -index f52b74c..527a5d7 100644
8549 +index 41c3a2c..9aa3d32 100644
8550 --- a/drivers/scsi/sd.c
8551 +++ b/drivers/scsi/sd.c
8552 @@ -112,7 +112,7 @@ static int sd_resume(struct device *);
8553 @@ -75004,10 +75109,10 @@ index 13965f2..0ea64d0 100644
8554 void rtw_os_xmit_schedule(struct adapter *padapter);
8555
8556 diff --git a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c
8557 -index 0fea338..e6f2263 100644
8558 +index 0fea338..acc951f 100644
8559 --- a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c
8560 +++ b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c
8561 -@@ -814,7 +814,7 @@ void usb_write_port_cancel(struct adapter *padapter)
8562 +@@ -814,10 +814,10 @@ void usb_write_port_cancel(struct adapter *padapter)
8563 }
8564 }
8565
8566 @@ -75015,8 +75120,12 @@ index 0fea338..e6f2263 100644
8567 +void rtl8188eu_recv_tasklet(unsigned long priv)
8568 {
8569 struct sk_buff *pskb;
8570 - struct adapter *adapt = priv;
8571 -@@ -833,7 +833,7 @@ void rtl8188eu_recv_tasklet(void *priv)
8572 +- struct adapter *adapt = priv;
8573 ++ struct adapter *adapt = (struct adapter *)priv;
8574 + struct recv_priv *precvpriv = &adapt->recvpriv;
8575 +
8576 + while (NULL != (pskb = skb_dequeue(&precvpriv->rx_skb_queue))) {
8577 +@@ -833,10 +833,10 @@ void rtl8188eu_recv_tasklet(void *priv)
8578 }
8579 }
8580
8581 @@ -75024,7 +75133,11 @@ index 0fea338..e6f2263 100644
8582 +void rtl8188eu_xmit_tasklet(unsigned long priv)
8583 {
8584 int ret = false;
8585 - struct adapter *adapt = priv;
8586 +- struct adapter *adapt = priv;
8587 ++ struct adapter *adapt = (struct adapter *)priv;
8588 + struct xmit_priv *pxmitpriv = &adapt->xmitpriv;
8589 +
8590 + if (check_fwstate(&adapt->mlmepriv, _FW_UNDER_SURVEY))
8591 diff --git a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c
8592 index 1593e28..a4345f9 100644
8593 --- a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c
8594 @@ -76272,7 +76385,7 @@ index c57e788..24d15dd 100644
8595 login->tgt_agt = sbp_target_agent_register(login);
8596 if (IS_ERR(login->tgt_agt)) {
8597 diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
8598 -index 6ceac4f..f8059ccd 100644
8599 +index 5b4b47e..94fac45 100644
8600 --- a/drivers/thermal/cpu_cooling.c
8601 +++ b/drivers/thermal/cpu_cooling.c
8602 @@ -838,10 +838,11 @@ __cpufreq_cooling_register(struct device_node *np,
8603 @@ -77898,10 +78011,10 @@ index dbcca30..7549b6f 100644
8604 tty_port_tty_set(port, tty);
8605
8606 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
8607 -index f973bfc..cc47958 100644
8608 +index 1e93a37..81c499f 100644
8609 --- a/drivers/tty/vt/keyboard.c
8610 +++ b/drivers/tty/vt/keyboard.c
8611 -@@ -642,6 +642,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
8612 +@@ -630,6 +630,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
8613 kbd->kbdmode == VC_OFF) &&
8614 value != KVAL(K_SAK))
8615 return; /* SAK is allowed even in raw mode */
8616 @@ -77918,7 +78031,7 @@ index f973bfc..cc47958 100644
8617 fn_handler[value](vc);
8618 }
8619
8620 -@@ -1876,9 +1886,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
8621 +@@ -1864,9 +1874,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
8622 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
8623 return -EFAULT;
8624
8625 @@ -77928,7 +78041,7 @@ index f973bfc..cc47958 100644
8626 switch (cmd) {
8627 case KDGKBENT:
8628 /* Ensure another thread doesn't free it under us */
8629 -@@ -1893,6 +1900,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
8630 +@@ -1881,6 +1888,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
8631 spin_unlock_irqrestore(&kbd_event_lock, flags);
8632 return put_user(val, &user_kbe->kb_value);
8633 case KDSKBENT:
8634 @@ -77938,7 +78051,7 @@ index f973bfc..cc47958 100644
8635 if (!perm)
8636 return -EPERM;
8637 if (!i && v == K_NOSUCHMAP) {
8638 -@@ -1983,9 +1993,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
8639 +@@ -1971,9 +1981,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
8640 int i, j, k;
8641 int ret;
8642
8643 @@ -77948,7 +78061,7 @@ index f973bfc..cc47958 100644
8644 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
8645 if (!kbs) {
8646 ret = -ENOMEM;
8647 -@@ -2019,6 +2026,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
8648 +@@ -2007,6 +2014,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
8649 kfree(kbs);
8650 return ((p && *p) ? -EOVERFLOW : 0);
8651 case KDSKBSENT:
8652 @@ -78245,7 +78358,7 @@ index 52c4461..adf74f5 100644
8653 (uurb->endpoint & USB_DIR_IN);
8654
8655 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
8656 -index 980fc57..e36e99a 100644
8657 +index 2d107d0..9489679 100644
8658 --- a/drivers/usb/core/hcd.c
8659 +++ b/drivers/usb/core/hcd.c
8660 @@ -1629,7 +1629,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
8661 @@ -96575,7 +96688,7 @@ index 20a2c02..5daa230 100644
8662 else if (whole->bd_holder != NULL)
8663 return false; /* is a partition of a held device */
8664 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
8665 -index ec7928a..89f482a 100644
8666 +index 234707c..fa73ff27 100644
8667 --- a/fs/btrfs/ctree.c
8668 +++ b/fs/btrfs/ctree.c
8669 @@ -358,7 +358,7 @@ static inline void tree_mod_log_write_unlock(struct btrfs_fs_info *fs_info)
8670 @@ -96604,9 +96717,20 @@ index ec7928a..89f482a 100644
8671
8672 WARN_ON(trans->transid != btrfs_header_generation(parent));
8673 diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
8674 -index 208d199..0a5afe1 100644
8675 +index 208d199..c8a54d0 100644
8676 --- a/fs/btrfs/ctree.h
8677 +++ b/fs/btrfs/ctree.h
8678 +@@ -979,8 +979,8 @@ struct btrfs_dev_replace {
8679 + u64 replace_state; /* see #define above */
8680 + u64 time_started; /* seconds since 1-Jan-1970 */
8681 + u64 time_stopped; /* seconds since 1-Jan-1970 */
8682 +- atomic64_t num_write_errors;
8683 +- atomic64_t num_uncorrectable_read_errors;
8684 ++ atomic64_unchecked_t num_write_errors;
8685 ++ atomic64_unchecked_t num_uncorrectable_read_errors;
8686 +
8687 + u64 cursor_left;
8688 + u64 committed_cursor_left;
8689 @@ -1615,7 +1615,7 @@ struct btrfs_fs_info {
8690
8691 /* this protects tree_mod_seq_list */
8692 @@ -96700,6 +96824,83 @@ index 430b368..85f12e1 100644
8693
8694 /* first set the basic ref node struct up */
8695 atomic_set(&ref->refs, 1);
8696 +diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
8697 +index 26bcb48..0d4f068 100644
8698 +--- a/fs/btrfs/dev-replace.c
8699 ++++ b/fs/btrfs/dev-replace.c
8700 +@@ -85,8 +85,8 @@ no_valid_dev_replace_entry_found:
8701 + dev_replace->replace_state = 0;
8702 + dev_replace->time_started = 0;
8703 + dev_replace->time_stopped = 0;
8704 +- atomic64_set(&dev_replace->num_write_errors, 0);
8705 +- atomic64_set(&dev_replace->num_uncorrectable_read_errors, 0);
8706 ++ atomic64_set_unchecked(&dev_replace->num_write_errors, 0);
8707 ++ atomic64_set_unchecked(&dev_replace->num_uncorrectable_read_errors, 0);
8708 + dev_replace->cursor_left = 0;
8709 + dev_replace->committed_cursor_left = 0;
8710 + dev_replace->cursor_left_last_write_of_item = 0;
8711 +@@ -115,9 +115,9 @@ no_valid_dev_replace_entry_found:
8712 + dev_replace->time_started = btrfs_dev_replace_time_started(eb, ptr);
8713 + dev_replace->time_stopped =
8714 + btrfs_dev_replace_time_stopped(eb, ptr);
8715 +- atomic64_set(&dev_replace->num_write_errors,
8716 ++ atomic64_set_unchecked(&dev_replace->num_write_errors,
8717 + btrfs_dev_replace_num_write_errors(eb, ptr));
8718 +- atomic64_set(&dev_replace->num_uncorrectable_read_errors,
8719 ++ atomic64_set_unchecked(&dev_replace->num_uncorrectable_read_errors,
8720 + btrfs_dev_replace_num_uncorrectable_read_errors(eb, ptr));
8721 + dev_replace->cursor_left = btrfs_dev_replace_cursor_left(eb, ptr);
8722 + dev_replace->committed_cursor_left = dev_replace->cursor_left;
8723 +@@ -277,9 +277,9 @@ int btrfs_run_dev_replace(struct btrfs_trans_handle *trans,
8724 + btrfs_set_dev_replace_time_started(eb, ptr, dev_replace->time_started);
8725 + btrfs_set_dev_replace_time_stopped(eb, ptr, dev_replace->time_stopped);
8726 + btrfs_set_dev_replace_num_write_errors(eb, ptr,
8727 +- atomic64_read(&dev_replace->num_write_errors));
8728 ++ atomic64_read_unchecked(&dev_replace->num_write_errors));
8729 + btrfs_set_dev_replace_num_uncorrectable_read_errors(eb, ptr,
8730 +- atomic64_read(&dev_replace->num_uncorrectable_read_errors));
8731 ++ atomic64_read_unchecked(&dev_replace->num_uncorrectable_read_errors));
8732 + dev_replace->cursor_left_last_write_of_item =
8733 + dev_replace->cursor_left;
8734 + btrfs_set_dev_replace_cursor_left(eb, ptr,
8735 +@@ -394,8 +394,8 @@ int btrfs_dev_replace_start(struct btrfs_root *root,
8736 + dev_replace->cursor_right = 0;
8737 + dev_replace->is_valid = 1;
8738 + dev_replace->item_needs_writeback = 1;
8739 +- atomic64_set(&dev_replace->num_write_errors, 0);
8740 +- atomic64_set(&dev_replace->num_uncorrectable_read_errors, 0);
8741 ++ atomic64_set_unchecked(&dev_replace->num_write_errors, 0);
8742 ++ atomic64_set_unchecked(&dev_replace->num_uncorrectable_read_errors, 0);
8743 + args->result = BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_ERROR;
8744 + btrfs_dev_replace_unlock(dev_replace, 1);
8745 +
8746 +@@ -659,9 +659,9 @@ void btrfs_dev_replace_status(struct btrfs_fs_info *fs_info,
8747 + args->status.time_started = dev_replace->time_started;
8748 + args->status.time_stopped = dev_replace->time_stopped;
8749 + args->status.num_write_errors =
8750 +- atomic64_read(&dev_replace->num_write_errors);
8751 ++ atomic64_read_unchecked(&dev_replace->num_write_errors);
8752 + args->status.num_uncorrectable_read_errors =
8753 +- atomic64_read(&dev_replace->num_uncorrectable_read_errors);
8754 ++ atomic64_read_unchecked(&dev_replace->num_uncorrectable_read_errors);
8755 + switch (dev_replace->replace_state) {
8756 + case BTRFS_IOCTL_DEV_REPLACE_STATE_NEVER_STARTED:
8757 + case BTRFS_IOCTL_DEV_REPLACE_STATE_CANCELED:
8758 +diff --git a/fs/btrfs/dev-replace.h b/fs/btrfs/dev-replace.h
8759 +index 29e3ef5..37e8d79 100644
8760 +--- a/fs/btrfs/dev-replace.h
8761 ++++ b/fs/btrfs/dev-replace.h
8762 +@@ -40,8 +40,8 @@ void btrfs_dev_replace_set_lock_blocking(struct btrfs_dev_replace *dev_replace);
8763 + void btrfs_dev_replace_clear_lock_blocking(
8764 + struct btrfs_dev_replace *dev_replace);
8765 +
8766 +-static inline void btrfs_dev_replace_stats_inc(atomic64_t *stat_value)
8767 ++static inline void btrfs_dev_replace_stats_inc(atomic64_unchecked_t *stat_value)
8768 + {
8769 +- atomic64_inc(stat_value);
8770 ++ atomic64_inc_unchecked(stat_value);
8771 + }
8772 + #endif
8773 diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
8774 index 4e47849..d0d47dc 100644
8775 --- a/fs/btrfs/disk-io.c
8776 @@ -96917,8 +97118,21 @@ index 0b7792e..be2ccab17 100644
8777 /*
8778 * build a list of bios to read all the missing parts of this
8779 * stripe
8780 +diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
8781 +index 4678f03..0cadde2 100644
8782 +--- a/fs/btrfs/scrub.c
8783 ++++ b/fs/btrfs/scrub.c
8784 +@@ -3667,7 +3667,7 @@ int scrub_enumerate_chunks(struct scrub_ctx *sctx,
8785 + if (ret)
8786 + break;
8787 + if (is_dev_replace &&
8788 +- atomic64_read(&dev_replace->num_write_errors) > 0) {
8789 ++ atomic64_read_unchecked(&dev_replace->num_write_errors) > 0) {
8790 + ret = -EIO;
8791 + break;
8792 + }
8793 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
8794 -index 00b8f37..c5e191f 100644
8795 +index d7c138f..02ad00f 100644
8796 --- a/fs/btrfs/super.c
8797 +++ b/fs/btrfs/super.c
8798 @@ -248,7 +248,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
8799 @@ -97860,10 +98074,10 @@ index 3525ed7..ac8afb7 100644
8800 }
8801
8802 diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
8803 -index 8f38e33..90f716a 100644
8804 +index 29e06db..e14922b 100644
8805 --- a/fs/cifs/smb2pdu.c
8806 +++ b/fs/cifs/smb2pdu.c
8807 -@@ -2388,8 +2388,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
8808 +@@ -2409,8 +2409,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
8809 default:
8810 cifs_dbg(VFS, "info level %u isn't supported\n",
8811 srch_inf->info_level);
8812 @@ -103538,7 +103752,7 @@ index 14db05d..687f6d8 100644
8813 #define MNT_NS_INTERNAL ERR_PTR(-EINVAL) /* distinct from any mnt_namespace */
8814
8815 diff --git a/fs/namei.c b/fs/namei.c
8816 -index 30145f8..ddb7af4 100644
8817 +index aaa3b69..c610f44 100644
8818 --- a/fs/namei.c
8819 +++ b/fs/namei.c
8820 @@ -336,17 +336,32 @@ int generic_permission(struct inode *inode, int mask)
8821 @@ -103838,7 +104052,7 @@ index 30145f8..ddb7af4 100644
8822 /*
8823 * If atomic_open() acquired write access it is dropped now due to
8824 * possible mount and symlink following (this might be optimized away if
8825 -@@ -3178,6 +3314,13 @@ retry_lookup:
8826 +@@ -3182,6 +3318,13 @@ retry_lookup:
8827 return -ENOENT;
8828 }
8829
8830 @@ -104134,7 +104348,7 @@ index 30145f8..ddb7af4 100644
8831 out:
8832 return len;
8833 diff --git a/fs/namespace.c b/fs/namespace.c
8834 -index 4fb1691..3077a5c 100644
8835 +index 783004a..419cf4a 100644
8836 --- a/fs/namespace.c
8837 +++ b/fs/namespace.c
8838 @@ -1516,6 +1516,9 @@ static int do_umount(struct mount *mnt, int flags)
8839 @@ -104175,7 +104389,7 @@ index 4fb1691..3077a5c 100644
8840 {
8841 return sys_umount(name, 0);
8842 }
8843 -@@ -2721,6 +2727,16 @@ long do_mount(const char *dev_name, const char __user *dir_name,
8844 +@@ -2723,6 +2729,16 @@ long do_mount(const char *dev_name, const char __user *dir_name,
8845 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
8846 MS_STRICTATIME);
8847
8848 @@ -104192,7 +104406,7 @@ index 4fb1691..3077a5c 100644
8849 if (flags & MS_REMOUNT)
8850 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
8851 data_page);
8852 -@@ -2734,7 +2750,10 @@ long do_mount(const char *dev_name, const char __user *dir_name,
8853 +@@ -2736,7 +2752,10 @@ long do_mount(const char *dev_name, const char __user *dir_name,
8854 retval = do_new_mount(&path, type_page, flags, mnt_flags,
8855 dev_name, data_page);
8856 dput_out:
8857 @@ -104203,7 +104417,7 @@ index 4fb1691..3077a5c 100644
8858 return retval;
8859 }
8860
8861 -@@ -2752,7 +2771,7 @@ static void free_mnt_ns(struct mnt_namespace *ns)
8862 +@@ -2754,7 +2773,7 @@ static void free_mnt_ns(struct mnt_namespace *ns)
8863 * number incrementing at 10Ghz will take 12,427 years to wrap which
8864 * is effectively never, so we can ignore the possibility.
8865 */
8866 @@ -104212,7 +104426,7 @@ index 4fb1691..3077a5c 100644
8867
8868 static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
8869 {
8870 -@@ -2768,7 +2787,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
8871 +@@ -2770,7 +2789,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
8872 return ERR_PTR(ret);
8873 }
8874 new_ns->ns.ops = &mntns_operations;
8875 @@ -104221,7 +104435,7 @@ index 4fb1691..3077a5c 100644
8876 atomic_set(&new_ns->count, 1);
8877 new_ns->root = NULL;
8878 INIT_LIST_HEAD(&new_ns->list);
8879 -@@ -2778,6 +2797,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
8880 +@@ -2780,6 +2799,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
8881 return new_ns;
8882 }
8883
8884 @@ -104229,7 +104443,7 @@ index 4fb1691..3077a5c 100644
8885 struct mnt_namespace *copy_mnt_ns(unsigned long flags, struct mnt_namespace *ns,
8886 struct user_namespace *user_ns, struct fs_struct *new_fs)
8887 {
8888 -@@ -2899,8 +2919,8 @@ struct dentry *mount_subtree(struct vfsmount *mnt, const char *name)
8889 +@@ -2901,8 +2921,8 @@ struct dentry *mount_subtree(struct vfsmount *mnt, const char *name)
8890 }
8891 EXPORT_SYMBOL(mount_subtree);
8892
8893 @@ -104240,7 +104454,7 @@ index 4fb1691..3077a5c 100644
8894 {
8895 int ret;
8896 char *kernel_type;
8897 -@@ -3006,6 +3026,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
8898 +@@ -3008,6 +3028,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
8899 if (error)
8900 goto out2;
8901
8902 @@ -104252,7 +104466,7 @@ index 4fb1691..3077a5c 100644
8903 get_fs_root(current->fs, &root);
8904 old_mp = lock_mount(&old);
8905 error = PTR_ERR(old_mp);
8906 -@@ -3324,7 +3349,7 @@ static int mntns_install(struct nsproxy *nsproxy, struct ns_common *ns)
8907 +@@ -3330,7 +3355,7 @@ static int mntns_install(struct nsproxy *nsproxy, struct ns_common *ns)
8908 !ns_capable(current_user_ns(), CAP_SYS_ADMIN))
8909 return -EPERM;
8910
8911 @@ -104618,7 +104832,7 @@ index 976c906..16b86ac 100644
8912 .pc_ressize = 256,
8913 .pc_xdrressize = NFS4_CALLBACK_BUFSIZE,
8914 diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
8915 -index 33eb817..e72c6b7 100644
8916 +index a7dd1fe..9d5f829 100644
8917 --- a/fs/nfs/dir.c
8918 +++ b/fs/nfs/dir.c
8919 @@ -681,8 +681,9 @@ out:
8920 @@ -107117,7 +107331,7 @@ index 88474a4..55ee771 100644
8921 .p_replen = NFS4_##restype##_sz, \
8922 .p_statidx = NFSPROC4_CLNT_##proc, \
8923 diff --git a/fs/nfs/read.c b/fs/nfs/read.c
8924 -index 6776d7a..f018f72 100644
8925 +index 572e5b3..5245a0a 100644
8926 --- a/fs/nfs/read.c
8927 +++ b/fs/nfs/read.c
8928 @@ -346,7 +346,7 @@ struct nfs_readdesc {
8929 @@ -107194,7 +107408,7 @@ index 4123551..813b403 100644
8930
8931 #endif /* _NFSD4_CURRENT_STATE_H */
8932 diff --git a/fs/nfsd/nfs2acl.c b/fs/nfsd/nfs2acl.c
8933 -index 1580ea6..5d74e50 100644
8934 +index d08cd88..5d74e50 100644
8935 --- a/fs/nfsd/nfs2acl.c
8936 +++ b/fs/nfsd/nfs2acl.c
8937 @@ -27,9 +27,10 @@ nfsacld_proc_null(struct svc_rqst *rqstp, void *argp, void *resp)
8938 @@ -107224,47 +107438,6 @@ index 1580ea6..5d74e50 100644
8939 struct inode *inode;
8940 svc_fh *fh;
8941 __be32 nfserr = 0;
8942 -@@ -104,22 +105,21 @@ static __be32 nfsacld_proc_setacl(struct svc_rqst * rqstp,
8943 - goto out;
8944 -
8945 - inode = d_inode(fh->fh_dentry);
8946 -- if (!IS_POSIXACL(inode) || !inode->i_op->set_acl) {
8947 -- error = -EOPNOTSUPP;
8948 -- goto out_errno;
8949 -- }
8950 -
8951 - error = fh_want_write(fh);
8952 - if (error)
8953 - goto out_errno;
8954 -
8955 -- error = inode->i_op->set_acl(inode, argp->acl_access, ACL_TYPE_ACCESS);
8956 -+ fh_lock(fh);
8957 -+
8958 -+ error = set_posix_acl(inode, ACL_TYPE_ACCESS, argp->acl_access);
8959 - if (error)
8960 -- goto out_drop_write;
8961 -- error = inode->i_op->set_acl(inode, argp->acl_default,
8962 -- ACL_TYPE_DEFAULT);
8963 -+ goto out_drop_lock;
8964 -+ error = set_posix_acl(inode, ACL_TYPE_DEFAULT, argp->acl_default);
8965 - if (error)
8966 -- goto out_drop_write;
8967 -+ goto out_drop_lock;
8968 -+
8969 -+ fh_unlock(fh);
8970 -
8971 - fh_drop_write(fh);
8972 -
8973 -@@ -131,7 +131,8 @@ out:
8974 - posix_acl_release(argp->acl_access);
8975 - posix_acl_release(argp->acl_default);
8976 - return nfserr;
8977 --out_drop_write:
8978 -+out_drop_lock:
8979 -+ fh_unlock(fh);
8980 - fh_drop_write(fh);
8981 - out_errno:
8982 - nfserr = nfserrno(error);
8983 @@ -141,9 +142,10 @@ out_errno:
8984 /*
8985 * Check file attributes
8986 @@ -107441,7 +107614,7 @@ index 1580ea6..5d74e50 100644
8987 sizeof(struct nfsd3_##rest##res), \
8988 0, \
8989 diff --git a/fs/nfsd/nfs3acl.c b/fs/nfsd/nfs3acl.c
8990 -index 01df4cd..36a8d76 100644
8991 +index 0c89034..36a8d76 100644
8992 --- a/fs/nfsd/nfs3acl.c
8993 +++ b/fs/nfsd/nfs3acl.c
8994 @@ -26,9 +26,10 @@ nfsd3_proc_null(struct svc_rqst *rqstp, void *argp, void *resp)
8995 @@ -107471,37 +107644,7 @@ index 01df4cd..36a8d76 100644
8996 struct inode *inode;
8997 svc_fh *fh;
8998 __be32 nfserr = 0;
8999 -@@ -95,22 +96,20 @@ static __be32 nfsd3_proc_setacl(struct svc_rqst * rqstp,
9000 - goto out;
9001 -
9002 - inode = d_inode(fh->fh_dentry);
9003 -- if (!IS_POSIXACL(inode) || !inode->i_op->set_acl) {
9004 -- error = -EOPNOTSUPP;
9005 -- goto out_errno;
9006 -- }
9007 -
9008 - error = fh_want_write(fh);
9009 - if (error)
9010 - goto out_errno;
9011 -
9012 -- error = inode->i_op->set_acl(inode, argp->acl_access, ACL_TYPE_ACCESS);
9013 -+ fh_lock(fh);
9014 -+
9015 -+ error = set_posix_acl(inode, ACL_TYPE_ACCESS, argp->acl_access);
9016 - if (error)
9017 -- goto out_drop_write;
9018 -- error = inode->i_op->set_acl(inode, argp->acl_default,
9019 -- ACL_TYPE_DEFAULT);
9020 -+ goto out_drop_lock;
9021 -+ error = set_posix_acl(inode, ACL_TYPE_DEFAULT, argp->acl_default);
9022 -
9023 --out_drop_write:
9024 -+out_drop_lock:
9025 -+ fh_unlock(fh);
9026 - fh_drop_write(fh);
9027 - out_errno:
9028 - nfserr = nfserrno(error);
9029 -@@ -125,9 +124,10 @@ out:
9030 +@@ -123,9 +124,10 @@ out:
9031 /*
9032 * XDR decode functions
9033 */
9034 @@ -107514,7 +107657,7 @@ index 01df4cd..36a8d76 100644
9035 p = nfs3svc_decode_fh(p, &args->fh);
9036 if (!p)
9037 return 0;
9038 -@@ -137,9 +137,10 @@ static int nfs3svc_decode_getaclargs(struct svc_rqst *rqstp, __be32 *p,
9039 +@@ -135,9 +137,10 @@ static int nfs3svc_decode_getaclargs(struct svc_rqst *rqstp, __be32 *p,
9040 }
9041
9042
9043 @@ -107527,7 +107670,7 @@ index 01df4cd..36a8d76 100644
9044 struct kvec *head = rqstp->rq_arg.head;
9045 unsigned int base;
9046 int n;
9047 -@@ -168,9 +169,10 @@ static int nfs3svc_decode_setaclargs(struct svc_rqst *rqstp, __be32 *p,
9048 +@@ -166,9 +169,10 @@ static int nfs3svc_decode_setaclargs(struct svc_rqst *rqstp, __be32 *p,
9049 */
9050
9051 /* GETACL */
9052 @@ -107540,7 +107683,7 @@ index 01df4cd..36a8d76 100644
9053 struct dentry *dentry = resp->fh.fh_dentry;
9054
9055 p = nfs3svc_encode_post_op_attr(rqstp, p, &resp->fh);
9056 -@@ -213,9 +215,10 @@ static int nfs3svc_encode_getaclres(struct svc_rqst *rqstp, __be32 *p,
9057 +@@ -211,9 +215,10 @@ static int nfs3svc_encode_getaclres(struct svc_rqst *rqstp, __be32 *p,
9058 }
9059
9060 /* SETACL */
9061 @@ -107553,7 +107696,7 @@ index 01df4cd..36a8d76 100644
9062 p = nfs3svc_encode_post_op_attr(rqstp, p, &resp->fh);
9063
9064 return xdr_ressize_check(rqstp, p);
9065 -@@ -224,9 +227,10 @@ static int nfs3svc_encode_setaclres(struct svc_rqst *rqstp, __be32 *p,
9066 +@@ -222,9 +227,10 @@ static int nfs3svc_encode_setaclres(struct svc_rqst *rqstp, __be32 *p,
9067 /*
9068 * XDR release functions
9069 */
9070 @@ -107566,7 +107709,7 @@ index 01df4cd..36a8d76 100644
9071 fh_put(&resp->fh);
9072 posix_acl_release(resp->acl_access);
9073 posix_acl_release(resp->acl_default);
9074 -@@ -240,10 +244,10 @@ static int nfs3svc_release_getacl(struct svc_rqst *rqstp, __be32 *p,
9075 +@@ -238,10 +244,10 @@ static int nfs3svc_release_getacl(struct svc_rqst *rqstp, __be32 *p,
9076 struct nfsd3_voidargs { int dummy; };
9077
9078 #define PROC(name, argt, rest, relt, cache, respsize) \
9079 @@ -108597,47 +108740,8 @@ index 2246454..b866de8 100644
9080 fh_put(&resp->fh1);
9081 fh_put(&resp->fh2);
9082 return 1;
9083 -diff --git a/fs/nfsd/nfs4acl.c b/fs/nfsd/nfs4acl.c
9084 -index 6adabd6..71292a0 100644
9085 ---- a/fs/nfsd/nfs4acl.c
9086 -+++ b/fs/nfsd/nfs4acl.c
9087 -@@ -770,9 +770,6 @@ nfsd4_set_nfs4_acl(struct svc_rqst *rqstp, struct svc_fh *fhp,
9088 - dentry = fhp->fh_dentry;
9089 - inode = d_inode(dentry);
9090 -
9091 -- if (!inode->i_op->set_acl || !IS_POSIXACL(inode))
9092 -- return nfserr_attrnotsupp;
9093 --
9094 - if (S_ISDIR(inode->i_mode))
9095 - flags = NFS4_ACL_DIR;
9096 -
9097 -@@ -782,16 +779,19 @@ nfsd4_set_nfs4_acl(struct svc_rqst *rqstp, struct svc_fh *fhp,
9098 - if (host_error < 0)
9099 - goto out_nfserr;
9100 -
9101 -- host_error = inode->i_op->set_acl(inode, pacl, ACL_TYPE_ACCESS);
9102 -+ fh_lock(fhp);
9103 -+
9104 -+ host_error = set_posix_acl(inode, ACL_TYPE_ACCESS, pacl);
9105 - if (host_error < 0)
9106 -- goto out_release;
9107 -+ goto out_drop_lock;
9108 -
9109 - if (S_ISDIR(inode->i_mode)) {
9110 -- host_error = inode->i_op->set_acl(inode, dpacl,
9111 -- ACL_TYPE_DEFAULT);
9112 -+ host_error = set_posix_acl(inode, ACL_TYPE_DEFAULT, dpacl);
9113 - }
9114 -
9115 --out_release:
9116 -+out_drop_lock:
9117 -+ fh_unlock(fhp);
9118 -+
9119 - posix_acl_release(pacl);
9120 - posix_acl_release(dpacl);
9121 - out_nfserr:
9122 diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c
9123 -index 7389cb1..e031e30d 100644
9124 +index 04c68d9..cc49866 100644
9125 --- a/fs/nfsd/nfs4callback.c
9126 +++ b/fs/nfsd/nfs4callback.c
9127 @@ -470,8 +470,7 @@ static int decode_cb_sequence4res(struct xdr_stream *xdr,
9128 @@ -109544,7 +109648,7 @@ index de1ff1d..bd4c347 100644
9129 .pc_ressize = sizeof(struct nfsd4_compoundres),
9130 .pc_release = nfsd4_release_compoundargs,
9131 diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
9132 -index 0462eed..7709d1d 100644
9133 +index 9e04e49..1e7e2d3 100644
9134 --- a/fs/nfsd/nfs4state.c
9135 +++ b/fs/nfsd/nfs4state.c
9136 @@ -2362,8 +2362,9 @@ static bool client_has_state(struct nfs4_client *clp)
9137 @@ -109657,7 +109761,7 @@ index 0462eed..7709d1d 100644
9138 struct nfs4_client *conf, *unconf;
9139 struct nfs4_client *old = NULL;
9140 nfs4_verifier confirm = setclientid_confirm->sc_confirm;
9141 -@@ -4436,8 +4446,9 @@ void nfsd4_cleanup_open_state(struct nfsd4_compound_state *cstate,
9142 +@@ -4446,8 +4456,9 @@ void nfsd4_cleanup_open_state(struct nfsd4_compound_state *cstate,
9143
9144 __be32
9145 nfsd4_renew(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
9146 @@ -109668,7 +109772,7 @@ index 0462eed..7709d1d 100644
9147 struct nfs4_client *clp;
9148 __be32 status;
9149 struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id);
9150 -@@ -4893,8 +4904,9 @@ out:
9151 +@@ -4903,8 +4914,9 @@ out:
9152 */
9153 __be32
9154 nfsd4_test_stateid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
9155 @@ -109679,7 +109783,7 @@ index 0462eed..7709d1d 100644
9156 struct nfsd4_test_stateid_id *stateid;
9157 struct nfs4_client *cl = cstate->session->se_client;
9158
9159 -@@ -4907,8 +4919,9 @@ nfsd4_test_stateid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
9160 +@@ -4917,8 +4929,9 @@ nfsd4_test_stateid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
9161
9162 __be32
9163 nfsd4_free_stateid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
9164 @@ -109690,7 +109794,7 @@ index 0462eed..7709d1d 100644
9165 stateid_t *stateid = &free_stateid->fr_stateid;
9166 struct nfs4_stid *s;
9167 struct nfs4_delegation *dp;
9168 -@@ -5046,8 +5059,9 @@ static __be32 nfs4_preprocess_confirmed_seqid_op(struct nfsd4_compound_state *cs
9169 +@@ -5056,8 +5069,9 @@ static __be32 nfs4_preprocess_confirmed_seqid_op(struct nfsd4_compound_state *cs
9170
9171 __be32
9172 nfsd4_open_confirm(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
9173 @@ -109701,7 +109805,7 @@ index 0462eed..7709d1d 100644
9174 __be32 status;
9175 struct nfs4_openowner *oo;
9176 struct nfs4_ol_stateid *stp;
9177 -@@ -5115,8 +5129,9 @@ static inline void nfs4_stateid_downgrade(struct nfs4_ol_stateid *stp, u32 to_ac
9178 +@@ -5125,8 +5139,9 @@ static inline void nfs4_stateid_downgrade(struct nfs4_ol_stateid *stp, u32 to_ac
9179 __be32
9180 nfsd4_open_downgrade(struct svc_rqst *rqstp,
9181 struct nfsd4_compound_state *cstate,
9182 @@ -109712,7 +109816,7 @@ index 0462eed..7709d1d 100644
9183 __be32 status;
9184 struct nfs4_ol_stateid *stp;
9185 struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id);
9186 -@@ -5184,8 +5199,9 @@ static void nfsd4_close_open_stateid(struct nfs4_ol_stateid *s)
9187 +@@ -5194,8 +5209,9 @@ static void nfsd4_close_open_stateid(struct nfs4_ol_stateid *s)
9188 */
9189 __be32
9190 nfsd4_close(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
9191 @@ -109723,7 +109827,7 @@ index 0462eed..7709d1d 100644
9192 __be32 status;
9193 struct nfs4_ol_stateid *stp;
9194 struct net *net = SVC_NET(rqstp);
9195 -@@ -5214,8 +5230,9 @@ out:
9196 +@@ -5224,8 +5240,9 @@ out:
9197
9198 __be32
9199 nfsd4_delegreturn(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
9200 @@ -109734,7 +109838,7 @@ index 0462eed..7709d1d 100644
9201 struct nfs4_delegation *dp;
9202 stateid_t *stateid = &dr->dr_stateid;
9203 struct nfs4_stid *s;
9204 -@@ -5549,8 +5566,9 @@ out:
9205 +@@ -5559,8 +5576,9 @@ out:
9206 */
9207 __be32
9208 nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
9209 @@ -109745,7 +109849,7 @@ index 0462eed..7709d1d 100644
9210 struct nfs4_openowner *open_sop = NULL;
9211 struct nfs4_lockowner *lock_sop = NULL;
9212 struct nfs4_ol_stateid *lock_stp = NULL;
9213 -@@ -5753,8 +5771,9 @@ static __be32 nfsd_test_lock(struct svc_rqst *rqstp, struct svc_fh *fhp, struct
9214 +@@ -5763,8 +5781,9 @@ static __be32 nfsd_test_lock(struct svc_rqst *rqstp, struct svc_fh *fhp, struct
9215 */
9216 __be32
9217 nfsd4_lockt(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
9218 @@ -109756,7 +109860,7 @@ index 0462eed..7709d1d 100644
9219 struct file_lock *file_lock = NULL;
9220 struct nfs4_lockowner *lo = NULL;
9221 __be32 status;
9222 -@@ -5826,8 +5845,9 @@ out:
9223 +@@ -5836,8 +5855,9 @@ out:
9224
9225 __be32
9226 nfsd4_locku(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
9227 @@ -109767,7 +109871,7 @@ index 0462eed..7709d1d 100644
9228 struct nfs4_ol_stateid *stp;
9229 struct file *filp = NULL;
9230 struct file_lock *file_lock = NULL;
9231 -@@ -5933,8 +5953,9 @@ check_for_locks(struct nfs4_file *fp, struct nfs4_lockowner *lowner)
9232 +@@ -5943,8 +5963,9 @@ check_for_locks(struct nfs4_file *fp, struct nfs4_lockowner *lowner)
9233 __be32
9234 nfsd4_release_lockowner(struct svc_rqst *rqstp,
9235 struct nfsd4_compound_state *cstate,
9236 @@ -109778,7 +109882,7 @@ index 0462eed..7709d1d 100644
9237 clientid_t *clid = &rlockowner->rl_clientid;
9238 struct nfs4_stateowner *sop;
9239 struct nfs4_lockowner *lo = NULL;
9240 -@@ -6878,26 +6899,34 @@ clear_current_stateid(struct nfsd4_compound_state *cstate)
9241 +@@ -6888,26 +6909,34 @@ clear_current_stateid(struct nfsd4_compound_state *cstate)
9242 * functions to set current state id
9243 */
9244 void
9245 @@ -109817,7 +109921,7 @@ index 0462eed..7709d1d 100644
9246 put_stateid(cstate, &lock->lk_resp_stateid);
9247 }
9248
9249 -@@ -6906,49 +6935,65 @@ nfsd4_set_lockstateid(struct nfsd4_compound_state *cstate, struct nfsd4_lock *lo
9250 +@@ -6916,49 +6945,65 @@ nfsd4_set_lockstateid(struct nfsd4_compound_state *cstate, struct nfsd4_lock *lo
9251 */
9252
9253 void
9254 @@ -112947,48 +113051,10 @@ index cc514da..2895466 100644
9255 if (res < 0) {
9256 free_page((unsigned long) buf);
9257 diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
9258 -index a4ff5d0..43d5748 100644
9259 +index d46fa60..e9a726d 100644
9260 --- a/fs/overlayfs/inode.c
9261 +++ b/fs/overlayfs/inode.c
9262 -@@ -59,16 +59,37 @@ int ovl_setattr(struct dentry *dentry, struct iattr *attr)
9263 - if (err)
9264 - goto out;
9265 -
9266 -+ if (attr->ia_valid & ATTR_SIZE) {
9267 -+ struct inode *realinode = d_inode(ovl_dentry_real(dentry));
9268 -+
9269 -+ err = -ETXTBSY;
9270 -+ if (atomic_read(&realinode->i_writecount) < 0)
9271 -+ goto out_drop_write;
9272 -+ }
9273 -+
9274 - err = ovl_copy_up(dentry);
9275 - if (!err) {
9276 -+ struct inode *winode = NULL;
9277 -+
9278 - upperdentry = ovl_dentry_upper(dentry);
9279 -
9280 -+ if (attr->ia_valid & ATTR_SIZE) {
9281 -+ winode = d_inode(upperdentry);
9282 -+ err = get_write_access(winode);
9283 -+ if (err)
9284 -+ goto out_drop_write;
9285 -+ }
9286 -+
9287 - inode_lock(upperdentry->d_inode);
9288 - err = notify_change(upperdentry, attr, NULL);
9289 - if (!err)
9290 - ovl_copyattr(upperdentry->d_inode, dentry->d_inode);
9291 - inode_unlock(upperdentry->d_inode);
9292 -+
9293 -+ if (winode)
9294 -+ put_write_access(winode);
9295 - }
9296 -+out_drop_write:
9297 - ovl_drop_write(dentry);
9298 - out:
9299 - return err;
9300 -@@ -347,6 +368,9 @@ struct inode *ovl_d_select_inode(struct dentry *dentry, unsigned file_flags)
9301 +@@ -373,6 +373,9 @@ struct inode *ovl_d_select_inode(struct dentry *dentry, unsigned file_flags)
9302 if (d_is_dir(dentry))
9303 return d_backing_inode(dentry);
9304
9305 @@ -112999,7 +113065,7 @@ index a4ff5d0..43d5748 100644
9306 if (ovl_open_need_copy_up(file_flags, type, realpath.dentry)) {
9307 err = ovl_want_write(dentry);
9308 diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
9309 -index 791235e..f6aecf4 100644
9310 +index 7952a50f..631ff67 100644
9311 --- a/fs/overlayfs/super.c
9312 +++ b/fs/overlayfs/super.c
9313 @@ -194,7 +194,7 @@ void ovl_path_lower(struct dentry *dentry, struct path *path)
9314 @@ -113022,25 +113088,6 @@ index 791235e..f6aecf4 100644
9315 struct dentry *root_dentry;
9316 struct ovl_entry *oe;
9317 struct ovl_fs *ufs;
9318 -@@ -1070,11 +1070,13 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
9319 - if (err < 0)
9320 - goto out_put_workdir;
9321 -
9322 -- if (!err) {
9323 -- pr_err("overlayfs: upper fs needs to support d_type.\n");
9324 -- err = -EINVAL;
9325 -- goto out_put_workdir;
9326 -- }
9327 -+ /*
9328 -+ * We allowed this configuration and don't want to
9329 -+ * break users over kernel upgrade. So warn instead
9330 -+ * of erroring out.
9331 -+ */
9332 -+ if (!err)
9333 -+ pr_warn("overlayfs: upper fs needs to support d_type.\n");
9334 - }
9335 -
9336 - err = -ENOMEM;
9337 diff --git a/fs/pipe.c b/fs/pipe.c
9338 index 0d3f516..91735ad 100644
9339 --- a/fs/pipe.c
9340 @@ -113290,7 +113337,7 @@ index 0d3f516..91735ad 100644
9341
9342 if (!capable(CAP_SYS_RESOURCE) && size > pipe_max_size) {
9343 diff --git a/fs/posix_acl.c b/fs/posix_acl.c
9344 -index 711dd51..afa7a82 100644
9345 +index e11ea5f..20e2d4d 100644
9346 --- a/fs/posix_acl.c
9347 +++ b/fs/posix_acl.c
9348 @@ -20,6 +20,7 @@
9349 @@ -113370,74 +113417,6 @@ index 711dd51..afa7a82 100644
9350 acl_e->e_gid =
9351 make_kgid(user_ns,
9352 le32_to_cpu(entry->e_id));
9353 -@@ -786,39 +797,47 @@ posix_acl_xattr_get(const struct xattr_handler *handler,
9354 - return error;
9355 - }
9356 -
9357 -+int
9358 -+set_posix_acl(struct inode *inode, int type, struct posix_acl *acl)
9359 -+{
9360 -+ if (!IS_POSIXACL(inode))
9361 -+ return -EOPNOTSUPP;
9362 -+ if (!inode->i_op->set_acl)
9363 -+ return -EOPNOTSUPP;
9364 -+
9365 -+ if (type == ACL_TYPE_DEFAULT && !S_ISDIR(inode->i_mode))
9366 -+ return acl ? -EACCES : 0;
9367 -+ if (!inode_owner_or_capable(inode))
9368 -+ return -EPERM;
9369 -+
9370 -+ if (acl) {
9371 -+ int ret = posix_acl_valid(acl);
9372 -+ if (ret)
9373 -+ return ret;
9374 -+ }
9375 -+ return inode->i_op->set_acl(inode, acl, type);
9376 -+}
9377 -+EXPORT_SYMBOL(set_posix_acl);
9378 -+
9379 - static int
9380 - posix_acl_xattr_set(const struct xattr_handler *handler,
9381 -- struct dentry *dentry, const char *name,
9382 -- const void *value, size_t size, int flags)
9383 -+ struct dentry *dentry,
9384 -+ const char *name, const void *value,
9385 -+ size_t size, int flags)
9386 - {
9387 - struct inode *inode = d_backing_inode(dentry);
9388 - struct posix_acl *acl = NULL;
9389 - int ret;
9390 -
9391 -- if (!IS_POSIXACL(inode))
9392 -- return -EOPNOTSUPP;
9393 -- if (!inode->i_op->set_acl)
9394 -- return -EOPNOTSUPP;
9395 --
9396 -- if (handler->flags == ACL_TYPE_DEFAULT && !S_ISDIR(inode->i_mode))
9397 -- return value ? -EACCES : 0;
9398 -- if (!inode_owner_or_capable(inode))
9399 -- return -EPERM;
9400 -+ if (strcmp(name, "") != 0)
9401 -+ return -EINVAL;
9402 -
9403 - if (value) {
9404 - acl = posix_acl_from_xattr(&init_user_ns, value, size);
9405 - if (IS_ERR(acl))
9406 - return PTR_ERR(acl);
9407 --
9408 -- if (acl) {
9409 -- ret = posix_acl_valid(acl);
9410 -- if (ret)
9411 -- goto out;
9412 -- }
9413 - }
9414 --
9415 -- ret = inode->i_op->set_acl(inode, acl, handler->flags);
9416 --out:
9417 -+ ret = set_posix_acl(inode, handler->flags, acl);
9418 - posix_acl_release(acl);
9419 - return ret;
9420 - }
9421 diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
9422 index 1ade120..a86f1a2 100644
9423 --- a/fs/proc/Kconfig
9424 @@ -129806,7 +129785,7 @@ index 718e872..e16712a 100644
9425 /* flags */
9426 #define CPUFREQ_STICKY (1 << 0) /* driver isn't removed even if
9427 diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
9428 -index 786ad32..09d1fb1 100644
9429 +index 07b83d3..3373ad6 100644
9430 --- a/include/linux/cpuidle.h
9431 +++ b/include/linux/cpuidle.h
9432 @@ -59,7 +59,8 @@ struct cpuidle_state {
9433 @@ -129819,7 +129798,7 @@ index 786ad32..09d1fb1 100644
9434
9435 /* Idle State Flags */
9436 #define CPUIDLE_FLAG_COUPLED (0x02) /* state applies to multiple cpus */
9437 -@@ -234,7 +235,7 @@ struct cpuidle_governor {
9438 +@@ -237,7 +238,7 @@ struct cpuidle_governor {
9439 void (*reflect) (struct cpuidle_device *dev, int index);
9440
9441 struct module *owner;
9442 @@ -129965,7 +129944,7 @@ index 653589e..4ef254a 100644
9443 return c | 0x20;
9444 }
9445 diff --git a/include/linux/dcache.h b/include/linux/dcache.h
9446 -index 7e9422c..a1181c6 100644
9447 +index ad5d582..a794cac 100644
9448 --- a/include/linux/dcache.h
9449 +++ b/include/linux/dcache.h
9450 @@ -123,6 +123,9 @@ struct dentry {
9451 @@ -133448,6 +133427,63 @@ index 9230f9a..065b8f8 100644
9452
9453 /* Function to register/unregister hook points. */
9454 int nf_register_net_hook(struct net *net, const struct nf_hook_ops *ops);
9455 +diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
9456 +index f48b8a6..8971034 100644
9457 +--- a/include/linux/netfilter/ipset/ip_set.h
9458 ++++ b/include/linux/netfilter/ipset/ip_set.h
9459 +@@ -104,8 +104,8 @@ struct ip_set_ext {
9460 + };
9461 +
9462 + struct ip_set_counter {
9463 +- atomic64_t bytes;
9464 +- atomic64_t packets;
9465 ++ atomic64_unchecked_t bytes;
9466 ++ atomic64_unchecked_t packets;
9467 + };
9468 +
9469 + struct ip_set_comment_rcu {
9470 +@@ -297,25 +297,25 @@ ip_set_put_flags(struct sk_buff *skb, struct ip_set *set)
9471 + static inline void
9472 + ip_set_add_bytes(u64 bytes, struct ip_set_counter *counter)
9473 + {
9474 +- atomic64_add((long long)bytes, &(counter)->bytes);
9475 ++ atomic64_add_unchecked((long long)bytes, &(counter)->bytes);
9476 + }
9477 +
9478 + static inline void
9479 + ip_set_add_packets(u64 packets, struct ip_set_counter *counter)
9480 + {
9481 +- atomic64_add((long long)packets, &(counter)->packets);
9482 ++ atomic64_add_unchecked((long long)packets, &(counter)->packets);
9483 + }
9484 +
9485 + static inline u64
9486 + ip_set_get_bytes(const struct ip_set_counter *counter)
9487 + {
9488 +- return (u64)atomic64_read(&(counter)->bytes);
9489 ++ return (u64)atomic64_read_unchecked(&(counter)->bytes);
9490 + }
9491 +
9492 + static inline u64
9493 + ip_set_get_packets(const struct ip_set_counter *counter)
9494 + {
9495 +- return (u64)atomic64_read(&(counter)->packets);
9496 ++ return (u64)atomic64_read_unchecked(&(counter)->packets);
9497 + }
9498 +
9499 + static inline void
9500 +@@ -384,9 +384,9 @@ ip_set_init_counter(struct ip_set_counter *counter,
9501 + const struct ip_set_ext *ext)
9502 + {
9503 + if (ext->bytes != ULLONG_MAX)
9504 +- atomic64_set(&(counter)->bytes, (long long)(ext->bytes));
9505 ++ atomic64_set_unchecked(&(counter)->bytes, (long long)(ext->bytes));
9506 + if (ext->packets != ULLONG_MAX)
9507 +- atomic64_set(&(counter)->packets, (long long)(ext->packets));
9508 ++ atomic64_set_unchecked(&(counter)->packets, (long long)(ext->packets));
9509 + }
9510 +
9511 + /* Netlink CB args */
9512 diff --git a/include/linux/netfilter/ipset/ip_set_comment.h b/include/linux/netfilter/ipset/ip_set_comment.h
9513 index 8d02485..a1e1aa5 100644
9514 --- a/include/linux/netfilter/ipset/ip_set_comment.h
9515 @@ -134379,7 +134415,7 @@ index 556ec1e..38c19c9 100644
9516
9517 /*
9518 diff --git a/include/linux/sched.h b/include/linux/sched.h
9519 -index 52c4847..3a5c90b 100644
9520 +index 52c4847..e87db2a 100644
9521 --- a/include/linux/sched.h
9522 +++ b/include/linux/sched.h
9523 @@ -7,7 +7,7 @@
9524 @@ -134399,7 +134435,7 @@ index 52c4847..3a5c90b 100644
9525
9526 #define VMACACHE_BITS 2
9527 #define VMACACHE_SIZE (1U << VMACACHE_BITS)
9528 -@@ -441,6 +442,19 @@ struct nsproxy;
9529 +@@ -441,6 +442,18 @@ struct nsproxy;
9530 struct user_namespace;
9531
9532 #ifdef CONFIG_MMU
9533 @@ -134414,12 +134450,11 @@ index 52c4847..3a5c90b 100644
9534 +#endif
9535 +
9536 +extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
9537 -+extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
9538 +
9539 extern void arch_pick_mmap_layout(struct mm_struct *mm);
9540 extern unsigned long
9541 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
9542 -@@ -777,6 +791,17 @@ struct signal_struct {
9543 +@@ -777,6 +790,17 @@ struct signal_struct {
9544 #ifdef CONFIG_TASKSTATS
9545 struct taskstats *stats;
9546 #endif
9547 @@ -134437,7 +134472,7 @@ index 52c4847..3a5c90b 100644
9548 #ifdef CONFIG_AUDIT
9549 unsigned audit_tty;
9550 struct tty_audit_buf *tty_audit_buf;
9551 -@@ -790,7 +815,7 @@ struct signal_struct {
9552 +@@ -790,7 +814,7 @@ struct signal_struct {
9553 struct mutex cred_guard_mutex; /* guard against foreign influences on
9554 * credential calculations
9555 * (notably. ptrace) */
9556 @@ -134446,7 +134481,7 @@ index 52c4847..3a5c90b 100644
9557
9558 /*
9559 * Bits in flags field of signal_struct.
9560 -@@ -845,6 +870,14 @@ struct user_struct {
9561 +@@ -845,6 +869,14 @@ struct user_struct {
9562 struct key *session_keyring; /* UID's default session keyring */
9563 #endif
9564
9565 @@ -134461,7 +134496,7 @@ index 52c4847..3a5c90b 100644
9566 /* Hash table maintenance information */
9567 struct hlist_node uidhash_node;
9568 kuid_t uid;
9569 -@@ -852,7 +885,7 @@ struct user_struct {
9570 +@@ -852,7 +884,7 @@ struct user_struct {
9571 #if defined(CONFIG_PERF_EVENTS) || defined(CONFIG_BPF_SYSCALL)
9572 atomic_long_t locked_vm;
9573 #endif
9574 @@ -134470,7 +134505,7 @@ index 52c4847..3a5c90b 100644
9575
9576 extern int uids_sysfs_init(void);
9577
9578 -@@ -1394,6 +1427,9 @@ struct tlbflush_unmap_batch {
9579 +@@ -1394,6 +1426,9 @@ struct tlbflush_unmap_batch {
9580 struct task_struct {
9581 volatile long state; /* -1 unrunnable, 0 runnable, >0 stopped */
9582 void *stack;
9583 @@ -134480,7 +134515,7 @@ index 52c4847..3a5c90b 100644
9584 atomic_t usage;
9585 unsigned int flags; /* per process flags, defined below */
9586 unsigned int ptrace;
9587 -@@ -1529,8 +1565,8 @@ struct task_struct {
9588 +@@ -1529,8 +1564,8 @@ struct task_struct {
9589 struct list_head thread_node;
9590
9591 struct completion *vfork_done; /* for vfork() */
9592 @@ -134491,7 +134526,7 @@ index 52c4847..3a5c90b 100644
9593
9594 cputime_t utime, stime, utimescaled, stimescaled;
9595 cputime_t gtime;
9596 -@@ -1560,11 +1596,6 @@ struct task_struct {
9597 +@@ -1560,11 +1595,6 @@ struct task_struct {
9598 struct task_cputime cputime_expires;
9599 struct list_head cpu_timers[3];
9600
9601 @@ -134503,7 +134538,7 @@ index 52c4847..3a5c90b 100644
9602 char comm[TASK_COMM_LEN]; /* executable name excluding path
9603 - access with [gs]et_task_comm (which lock
9604 it with task_lock())
9605 -@@ -1580,6 +1611,8 @@ struct task_struct {
9606 +@@ -1580,6 +1610,8 @@ struct task_struct {
9607 /* hung task detection */
9608 unsigned long last_switch_count;
9609 #endif
9610 @@ -134512,7 +134547,7 @@ index 52c4847..3a5c90b 100644
9611 /* filesystem information */
9612 struct fs_struct *fs;
9613 /* open file information */
9614 -@@ -1657,6 +1690,10 @@ struct task_struct {
9615 +@@ -1657,6 +1689,10 @@ struct task_struct {
9616 unsigned int in_ubsan;
9617 #endif
9618
9619 @@ -134523,7 +134558,7 @@ index 52c4847..3a5c90b 100644
9620 /* journalling filesystem info */
9621 void *journal_info;
9622
9623 -@@ -1695,6 +1732,10 @@ struct task_struct {
9624 +@@ -1695,6 +1731,10 @@ struct task_struct {
9625 /* cg_list protected by css_set_lock and tsk->alloc_lock */
9626 struct list_head cg_list;
9627 #endif
9628 @@ -134534,7 +134569,7 @@ index 52c4847..3a5c90b 100644
9629 #ifdef CONFIG_FUTEX
9630 struct robust_list_head __user *robust_list;
9631 #ifdef CONFIG_COMPAT
9632 -@@ -1810,7 +1851,7 @@ struct task_struct {
9633 +@@ -1810,7 +1850,7 @@ struct task_struct {
9634 * Number of functions that haven't been traced
9635 * because of depth overrun.
9636 */
9637 @@ -134543,7 +134578,7 @@ index 52c4847..3a5c90b 100644
9638 /* Pause for the tracing */
9639 atomic_t tracing_graph_pause;
9640 #endif
9641 -@@ -1852,22 +1893,89 @@ struct task_struct {
9642 +@@ -1852,22 +1892,89 @@ struct task_struct {
9643 #ifdef CONFIG_MMU
9644 struct task_struct *oom_reaper_list;
9645 #endif
9646 @@ -134643,7 +134678,7 @@ index 52c4847..3a5c90b 100644
9647 /* Future-safe accessor for struct task_struct's cpus_allowed. */
9648 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
9649
9650 -@@ -1949,7 +2057,7 @@ struct pid_namespace;
9651 +@@ -1949,7 +2056,7 @@ struct pid_namespace;
9652 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
9653 struct pid_namespace *ns);
9654
9655 @@ -134652,7 +134687,7 @@ index 52c4847..3a5c90b 100644
9656 {
9657 return tsk->pid;
9658 }
9659 -@@ -2311,6 +2419,48 @@ extern u64 sched_clock_cpu(int cpu);
9660 +@@ -2311,6 +2418,48 @@ extern u64 sched_clock_cpu(int cpu);
9661
9662 extern void sched_clock_init(void);
9663
9664 @@ -134701,7 +134736,7 @@ index 52c4847..3a5c90b 100644
9665 #ifndef CONFIG_HAVE_UNSTABLE_SCHED_CLOCK
9666 static inline void sched_clock_tick(void)
9667 {
9668 -@@ -2436,7 +2586,9 @@ extern void set_curr_task(int cpu, struct task_struct *p);
9669 +@@ -2436,7 +2585,9 @@ extern void set_curr_task(int cpu, struct task_struct *p);
9670 void yield(void);
9671
9672 union thread_union {
9673 @@ -134711,7 +134746,7 @@ index 52c4847..3a5c90b 100644
9674 unsigned long stack[THREAD_SIZE/sizeof(long)];
9675 };
9676
9677 -@@ -2469,6 +2621,7 @@ extern struct pid_namespace init_pid_ns;
9678 +@@ -2469,6 +2620,7 @@ extern struct pid_namespace init_pid_ns;
9679 */
9680
9681 extern struct task_struct *find_task_by_vpid(pid_t nr);
9682 @@ -134719,7 +134754,7 @@ index 52c4847..3a5c90b 100644
9683 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
9684 struct pid_namespace *ns);
9685
9686 -@@ -2500,7 +2653,7 @@ extern void proc_caches_init(void);
9687 +@@ -2500,7 +2652,7 @@ extern void proc_caches_init(void);
9688 extern void flush_signals(struct task_struct *);
9689 extern void ignore_signals(struct task_struct *);
9690 extern void flush_signal_handlers(struct task_struct *, int force_default);
9691 @@ -134728,7 +134763,7 @@ index 52c4847..3a5c90b 100644
9692
9693 static inline int kernel_dequeue_signal(siginfo_t *info)
9694 {
9695 -@@ -2654,7 +2807,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
9696 +@@ -2654,7 +2806,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
9697 extern void exit_itimers(struct signal_struct *);
9698 extern void flush_itimer_signals(void);
9699
9700 @@ -134737,7 +134772,7 @@ index 52c4847..3a5c90b 100644
9701
9702 extern int do_execve(struct filename *,
9703 const char __user * const __user *,
9704 -@@ -2769,11 +2922,13 @@ static inline int thread_group_empty(struct task_struct *p)
9705 +@@ -2769,11 +2921,13 @@ static inline int thread_group_empty(struct task_struct *p)
9706 * It must not be nested with write_lock_irq(&tasklist_lock),
9707 * neither inside nor outside.
9708 */
9709 @@ -134751,7 +134786,7 @@ index 52c4847..3a5c90b 100644
9710 static inline void task_unlock(struct task_struct *p)
9711 {
9712 spin_unlock(&p->alloc_lock);
9713 -@@ -2859,9 +3014,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
9714 +@@ -2859,9 +3013,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
9715 #define task_stack_end_corrupted(task) \
9716 (*(end_of_stack(task)) != STACK_END_MAGIC)
9717
9718 @@ -134981,7 +135016,7 @@ index d80259a..41a639a 100644
9719
9720 static inline void disallow_signal(int sig)
9721 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
9722 -index 15d0df9..31bf6d0 100644
9723 +index 794b924..3b11d45 100644
9724 --- a/include/linux/skbuff.h
9725 +++ b/include/linux/skbuff.h
9726 @@ -889,7 +889,7 @@ struct sk_buff *__alloc_skb(unsigned int size, gfp_t priority, int flags,
9727 @@ -134993,7 +135028,7 @@ index 15d0df9..31bf6d0 100644
9728 gfp_t priority)
9729 {
9730 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
9731 -@@ -2187,7 +2187,7 @@ static inline unsigned char *skb_checksum_start(const struct sk_buff *skb)
9732 +@@ -2188,7 +2188,7 @@ static inline unsigned char *skb_checksum_start(const struct sk_buff *skb)
9733 return skb->head + skb->csum_start;
9734 }
9735
9736 @@ -135002,7 +135037,7 @@ index 15d0df9..31bf6d0 100644
9737 {
9738 return skb_transport_header(skb) - skb->data;
9739 }
9740 -@@ -2202,7 +2202,7 @@ static inline u32 skb_inner_network_header_len(const struct sk_buff *skb)
9741 +@@ -2203,7 +2203,7 @@ static inline u32 skb_inner_network_header_len(const struct sk_buff *skb)
9742 return skb->inner_transport_header - skb->inner_network_header;
9743 }
9744
9745 @@ -135011,7 +135046,7 @@ index 15d0df9..31bf6d0 100644
9746 {
9747 return skb_network_header(skb) - skb->data;
9748 }
9749 -@@ -2262,7 +2262,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
9750 +@@ -2263,7 +2263,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
9751 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
9752 */
9753 #ifndef NET_SKB_PAD
9754 @@ -135020,7 +135055,7 @@ index 15d0df9..31bf6d0 100644
9755 #endif
9756
9757 int ___pskb_trim(struct sk_buff *skb, unsigned int len);
9758 -@@ -2936,9 +2936,9 @@ struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags, int noblock,
9759 +@@ -2956,9 +2956,9 @@ struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags, int noblock,
9760 int *err);
9761 unsigned int datagram_poll(struct file *file, struct socket *sock,
9762 struct poll_table_struct *wait);
9763 @@ -135032,7 +135067,7 @@ index 15d0df9..31bf6d0 100644
9764 struct msghdr *msg, int size)
9765 {
9766 return skb_copy_datagram_iter(from, offset, &msg->msg_iter, size);
9767 -@@ -3467,6 +3467,9 @@ static inline void nf_reset(struct sk_buff *skb)
9768 +@@ -3487,6 +3487,9 @@ static inline void nf_reset(struct sk_buff *skb)
9769 nf_bridge_put(skb->nf_bridge);
9770 skb->nf_bridge = NULL;
9771 #endif
9772 @@ -135533,7 +135568,7 @@ index 5c9c6cd..f16c5c9 100644
9773
9774 #endif /* _LINUX_SUNRPC_ADDR_H */
9775 diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
9776 -index 9a7ddba..10918de1 100644
9777 +index 14d70f5..88ae065 100644
9778 --- a/include/linux/sunrpc/clnt.h
9779 +++ b/include/linux/sunrpc/clnt.h
9780 @@ -103,7 +103,7 @@ struct rpc_procinfo {
9781 @@ -140600,7 +140635,7 @@ index d277e83..824b594 100644
9782 int threads = max_threads;
9783 int min = MIN_THREADS;
9784 diff --git a/kernel/futex.c b/kernel/futex.c
9785 -index c20f06f..a00ab76 100644
9786 +index 6555d54..4c66189 100644
9787 --- a/kernel/futex.c
9788 +++ b/kernel/futex.c
9789 @@ -202,7 +202,7 @@ struct futex_pi_state {
9790 @@ -140633,7 +140668,7 @@ index c20f06f..a00ab76 100644
9791 /*
9792 * The futex address must be "naturally" aligned.
9793 */
9794 -@@ -726,7 +731,7 @@ static int cmpxchg_futex_value_locked(u32 *curval, u32 __user *uaddr,
9795 +@@ -734,7 +739,7 @@ static int cmpxchg_futex_value_locked(u32 *curval, u32 __user *uaddr,
9796
9797 static int get_futex_value_locked(u32 *dest, u32 __user *from)
9798 {
9799 @@ -140642,7 +140677,7 @@ index c20f06f..a00ab76 100644
9800
9801 pagefault_disable();
9802 ret = __copy_from_user_inatomic(dest, from, sizeof(u32));
9803 -@@ -3241,6 +3246,7 @@ static void __init futex_detect_cmpxchg(void)
9804 +@@ -3249,6 +3254,7 @@ static void __init futex_detect_cmpxchg(void)
9805 {
9806 #ifndef CONFIG_HAVE_FUTEX_CMPXCHG
9807 u32 curval;
9808 @@ -140650,7 +140685,7 @@ index c20f06f..a00ab76 100644
9809
9810 /*
9811 * This will fail and we want it. Some arch implementations do
9812 -@@ -3252,8 +3258,11 @@ static void __init futex_detect_cmpxchg(void)
9813 +@@ -3260,8 +3266,11 @@ static void __init futex_detect_cmpxchg(void)
9814 * implementation, the non-functional ones will return
9815 * -ENOSYS.
9816 */
9817 @@ -140744,7 +140779,7 @@ index 5707f97..d526a3d 100644
9818 if (handled != desc->threads_handled_last) {
9819 action_ret = IRQ_HANDLED;
9820 diff --git a/kernel/jump_label.c b/kernel/jump_label.c
9821 -index 05254ee..a2e0725 100644
9822 +index 4b353e0..94322e3 100644
9823 --- a/kernel/jump_label.c
9824 +++ b/kernel/jump_label.c
9825 @@ -14,6 +14,7 @@
9826 @@ -140765,7 +140800,7 @@ index 05254ee..a2e0725 100644
9827 }
9828
9829 static void jump_label_update(struct static_key *key);
9830 -@@ -386,10 +389,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
9831 +@@ -416,10 +419,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
9832 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
9833 struct jump_entry *iter;
9834
9835 @@ -141345,10 +141380,10 @@ index 0799fd3..d06ae3b 100644
9836 extern void debug_mutex_init(struct mutex *lock, const char *name,
9837 struct lock_class_key *key);
9838 diff --git a/kernel/locking/mutex.c b/kernel/locking/mutex.c
9839 -index e364b42..642bee3 100644
9840 +index 79d2d76..a70b90d 100644
9841 --- a/kernel/locking/mutex.c
9842 +++ b/kernel/locking/mutex.c
9843 -@@ -534,7 +534,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
9844 +@@ -537,7 +537,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
9845 goto skip_wait;
9846
9847 debug_mutex_lock_common(lock, &waiter);
9848 @@ -141357,7 +141392,7 @@ index e364b42..642bee3 100644
9849
9850 /* add waiting tasks to the end of the waitqueue (FIFO): */
9851 list_add_tail(&waiter.list, &lock->wait_list);
9852 -@@ -581,7 +581,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
9853 +@@ -584,7 +584,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
9854 }
9855 __set_task_state(task, TASK_RUNNING);
9856
9857 @@ -141366,7 +141401,7 @@ index e364b42..642bee3 100644
9858 /* set it to 0 if there are no waiters left: */
9859 if (likely(list_empty(&lock->wait_list)))
9860 atomic_set(&lock->count, 0);
9861 -@@ -602,7 +602,7 @@ skip_wait:
9862 +@@ -605,7 +605,7 @@ skip_wait:
9863 return 0;
9864
9865 err:
9866 @@ -143548,7 +143583,7 @@ index 686ec8a..8fc3873 100644
9867 static void push_dl_tasks(struct rq *);
9868 static void pull_dl_task(struct rq *);
9869 diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
9870 -index 4fbc3bd..591825d 100644
9871 +index 4fbc3bd..6d8ac0d 100644
9872 --- a/kernel/sched/debug.c
9873 +++ b/kernel/sched/debug.c
9874 @@ -193,7 +193,7 @@ late_initcall(sched_init_debug);
9875 @@ -143614,8 +143649,12 @@ index 4fbc3bd..591825d 100644
9876 const char *procname, void *data, int maxlen,
9877 umode_t mode, proc_handler *proc_handler,
9878 bool load_idx)
9879 -@@ -263,7 +266,7 @@ set_table_entry(struct ctl_table *entry,
9880 - static struct ctl_table *
9881 +@@ -260,10 +263,10 @@ set_table_entry(struct ctl_table *entry,
9882 + }
9883 + }
9884 +
9885 +-static struct ctl_table *
9886 ++static ctl_table_no_const *
9887 sd_alloc_ctl_domain_table(struct sched_domain *sd)
9888 {
9889 - struct ctl_table *table = sd_alloc_ctl_entry(14);
9890 @@ -143678,10 +143717,10 @@ index 4fbc3bd..591825d 100644
9891 return -ENOMEM;
9892 return 0;
9893 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
9894 -index e7dd0ec..bbbbe5e 100644
9895 +index eeaf920..9f33e68 100644
9896 --- a/kernel/sched/fair.c
9897 +++ b/kernel/sched/fair.c
9898 -@@ -8061,7 +8061,7 @@ static void nohz_idle_balance(struct rq *this_rq, enum cpu_idle_type idle) { }
9899 +@@ -8078,7 +8078,7 @@ static void nohz_idle_balance(struct rq *this_rq, enum cpu_idle_type idle) { }
9900 * run_rebalance_domains is triggered when needed from the scheduler tick.
9901 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
9902 */
9903 @@ -148529,10 +148568,10 @@ index 36cc01b..d862cd8 100644
9904 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
9905
9906 diff --git a/mm/migrate.c b/mm/migrate.c
9907 -index f9dfb18..c97ca70 100644
9908 +index bdf3410..d7158a8 100644
9909 --- a/mm/migrate.c
9910 +++ b/mm/migrate.c
9911 -@@ -1524,8 +1524,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
9912 +@@ -1526,8 +1526,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
9913 */
9914 tcred = __task_cred(task);
9915 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
9916 @@ -148640,7 +148679,7 @@ index 5b72266..dc04ce5 100644
9917 .priority = IPC_CALLBACK_PRI, /* use lowest priority */
9918 };
9919 diff --git a/mm/mmap.c b/mm/mmap.c
9920 -index bd2e1a53..9299d7f 100644
9921 +index bd2e1a53..cbb2d1b 100644
9922 --- a/mm/mmap.c
9923 +++ b/mm/mmap.c
9924 @@ -43,6 +43,7 @@
9925 @@ -149028,7 +149067,7 @@ index bd2e1a53..9299d7f 100644
9926 kmem_cache_free(vm_area_cachep, vma);
9927 unacct_error:
9928 if (charged)
9929 -@@ -1585,7 +1761,63 @@ unacct_error:
9930 +@@ -1585,7 +1761,54 @@ unacct_error:
9931 return error;
9932 }
9933
9934 @@ -149072,28 +149111,19 @@ index bd2e1a53..9299d7f 100644
9935 + return true;
9936 +}
9937 +
9938 -+unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
9939 ++unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long flag, unsigned long gap_start, unsigned long gap_end)
9940 +{
9941 -+ if (vma->vm_start < len)
9942 -+ return -ENOMEM;
9943 -+
9944 -+ if (!(vma->vm_flags & VM_GROWSDOWN)) {
9945 -+ if (offset <= vma->vm_start - len)
9946 -+ return vma->vm_start - len - offset;
9947 -+ else
9948 -+ return -ENOMEM;
9949 -+ }
9950 ++ if (!vma || !(vma->vm_flags & flag))
9951 ++ return 0;
9952 +
9953 -+ if (sysctl_heap_stack_gap <= vma->vm_start - len)
9954 -+ return vma->vm_start - len - sysctl_heap_stack_gap;
9955 -+ return -ENOMEM;
9956 ++ return min(sysctl_heap_stack_gap, gap_end - gap_start);
9957 +}
9958 +
9959 +unsigned long unmapped_area(const struct vm_unmapped_area_info *info)
9960 {
9961 /*
9962 * We implement the search by looking for an rbtree node that
9963 -@@ -1633,11 +1865,29 @@ unsigned long unmapped_area(struct vm_unmapped_area_info *info)
9964 +@@ -1633,11 +1856,20 @@ unsigned long unmapped_area(struct vm_unmapped_area_info *info)
9965 }
9966 }
9967
9968 @@ -149109,22 +149139,13 @@ index bd2e1a53..9299d7f 100644
9969 + else
9970 + gap_start = gap_end;
9971 +
9972 -+ if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
9973 -+ if (gap_end - gap_start > sysctl_heap_stack_gap)
9974 -+ gap_start += sysctl_heap_stack_gap;
9975 -+ else
9976 -+ gap_start = gap_end;
9977 -+ }
9978 -+ if (vma->vm_flags & VM_GROWSDOWN) {
9979 -+ if (gap_end - gap_start > sysctl_heap_stack_gap)
9980 -+ gap_end -= sysctl_heap_stack_gap;
9981 -+ else
9982 -+ gap_end = gap_start;
9983 -+ }
9984 ++ gap_start += skip_heap_stack_gap(vma->vm_prev, VM_GROWSUP, gap_start, gap_end);
9985 ++ gap_end -= skip_heap_stack_gap(vma, VM_GROWSDOWN, gap_start, gap_end);
9986 ++
9987 if (gap_end >= low_limit && gap_end - gap_start >= length)
9988 goto found;
9989
9990 -@@ -1687,7 +1937,7 @@ found:
9991 +@@ -1687,7 +1919,7 @@ found:
9992 return gap_start;
9993 }
9994
9995 @@ -149133,7 +149154,7 @@ index bd2e1a53..9299d7f 100644
9996 {
9997 struct mm_struct *mm = current->mm;
9998 struct vm_area_struct *vma;
9999 -@@ -1741,6 +1991,24 @@ check_current:
10000 +@@ -1741,6 +1973,15 @@ check_current:
10001 gap_end = vma->vm_start;
10002 if (gap_end < low_limit)
10003 return -ENOMEM;
10004 @@ -149143,22 +149164,13 @@ index bd2e1a53..9299d7f 100644
10005 + else
10006 + gap_end = gap_start;
10007 +
10008 -+ if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
10009 -+ if (gap_end - gap_start > sysctl_heap_stack_gap)
10010 -+ gap_start += sysctl_heap_stack_gap;
10011 -+ else
10012 -+ gap_start = gap_end;
10013 -+ }
10014 -+ if (vma->vm_flags & VM_GROWSDOWN) {
10015 -+ if (gap_end - gap_start > sysctl_heap_stack_gap)
10016 -+ gap_end -= sysctl_heap_stack_gap;
10017 -+ else
10018 -+ gap_end = gap_start;
10019 -+ }
10020 ++ gap_start += skip_heap_stack_gap(vma->vm_prev, VM_GROWSUP, gap_start, gap_end);
10021 ++ gap_end -= skip_heap_stack_gap(vma, VM_GROWSDOWN, gap_start, gap_end);
10022 ++
10023 if (gap_start <= high_limit && gap_end - gap_start >= length)
10024 goto found;
10025
10026 -@@ -1804,6 +2072,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
10027 +@@ -1804,6 +2045,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
10028 struct mm_struct *mm = current->mm;
10029 struct vm_area_struct *vma;
10030 struct vm_unmapped_area_info info;
10031 @@ -149166,7 +149178,7 @@ index bd2e1a53..9299d7f 100644
10032
10033 if (len > TASK_SIZE - mmap_min_addr)
10034 return -ENOMEM;
10035 -@@ -1811,11 +2080,15 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
10036 +@@ -1811,11 +2053,15 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
10037 if (flags & MAP_FIXED)
10038 return addr;
10039
10040 @@ -149183,7 +149195,7 @@ index bd2e1a53..9299d7f 100644
10041 return addr;
10042 }
10043
10044 -@@ -1824,6 +2097,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
10045 +@@ -1824,6 +2070,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
10046 info.low_limit = mm->mmap_base;
10047 info.high_limit = TASK_SIZE;
10048 info.align_mask = 0;
10049 @@ -149191,7 +149203,7 @@ index bd2e1a53..9299d7f 100644
10050 return vm_unmapped_area(&info);
10051 }
10052 #endif
10053 -@@ -1842,6 +2116,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10054 +@@ -1842,6 +2089,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10055 struct mm_struct *mm = current->mm;
10056 unsigned long addr = addr0;
10057 struct vm_unmapped_area_info info;
10058 @@ -149199,7 +149211,7 @@ index bd2e1a53..9299d7f 100644
10059
10060 /* requested length too big for entire address space */
10061 if (len > TASK_SIZE - mmap_min_addr)
10062 -@@ -1850,12 +2125,16 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10063 +@@ -1850,12 +2098,16 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10064 if (flags & MAP_FIXED)
10065 return addr;
10066
10067 @@ -149217,7 +149229,7 @@ index bd2e1a53..9299d7f 100644
10068 return addr;
10069 }
10070
10071 -@@ -1864,6 +2143,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10072 +@@ -1864,6 +2116,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10073 info.low_limit = max(PAGE_SIZE, mmap_min_addr);
10074 info.high_limit = mm->mmap_base;
10075 info.align_mask = 0;
10076 @@ -149225,7 +149237,7 @@ index bd2e1a53..9299d7f 100644
10077 addr = vm_unmapped_area(&info);
10078
10079 /*
10080 -@@ -1876,6 +2156,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10081 +@@ -1876,6 +2129,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10082 VM_BUG_ON(addr != -ENOMEM);
10083 info.flags = 0;
10084 info.low_limit = TASK_UNMAPPED_BASE;
10085 @@ -149238,7 +149250,7 @@ index bd2e1a53..9299d7f 100644
10086 info.high_limit = TASK_SIZE;
10087 addr = vm_unmapped_area(&info);
10088 }
10089 -@@ -1975,6 +2261,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
10090 +@@ -1975,6 +2234,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
10091 return vma;
10092 }
10093
10094 @@ -149267,7 +149279,7 @@ index bd2e1a53..9299d7f 100644
10095 /*
10096 * Verify that the stack growth is acceptable and
10097 * update accounting. This is shared with both the
10098 -@@ -1992,8 +2300,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
10099 +@@ -1992,8 +2273,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
10100
10101 /* Stack limit test */
10102 actual_size = size;
10103 @@ -149277,7 +149289,7 @@ index bd2e1a53..9299d7f 100644
10104 if (actual_size > READ_ONCE(rlim[RLIMIT_STACK].rlim_cur))
10105 return -ENOMEM;
10106
10107 -@@ -2004,6 +2311,10 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
10108 +@@ -2004,6 +2284,10 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
10109 locked = mm->locked_vm + grow;
10110 limit = READ_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
10111 limit >>= PAGE_SHIFT;
10112 @@ -149288,7 +149300,7 @@ index bd2e1a53..9299d7f 100644
10113 if (locked > limit && !capable(CAP_IPC_LOCK))
10114 return -ENOMEM;
10115 }
10116 -@@ -2029,17 +2340,21 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
10117 +@@ -2029,17 +2313,21 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
10118 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
10119 * vma is the last one with address > vma->vm_end. Have to extend vma.
10120 */
10121 @@ -149312,7 +149324,7 @@ index bd2e1a53..9299d7f 100644
10122 else
10123 return -ENOMEM;
10124
10125 -@@ -2047,15 +2362,24 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
10126 +@@ -2047,15 +2335,24 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
10127 if (unlikely(anon_vma_prepare(vma)))
10128 return -ENOMEM;
10129
10130 @@ -149339,7 +149351,7 @@ index bd2e1a53..9299d7f 100644
10131 unsigned long size, grow;
10132
10133 size = address - vma->vm_start;
10134 -@@ -2093,6 +2417,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
10135 +@@ -2093,6 +2390,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
10136 }
10137 }
10138 }
10139 @@ -149348,7 +149360,7 @@ index bd2e1a53..9299d7f 100644
10140 anon_vma_unlock_write(vma->anon_vma);
10141 khugepaged_enter_vma_merge(vma, vma->vm_flags);
10142 validate_mm(mm);
10143 -@@ -2108,6 +2434,8 @@ int expand_downwards(struct vm_area_struct *vma,
10144 +@@ -2108,6 +2407,8 @@ int expand_downwards(struct vm_area_struct *vma,
10145 {
10146 struct mm_struct *mm = vma->vm_mm;
10147 int error;
10148 @@ -149357,7 +149369,7 @@ index bd2e1a53..9299d7f 100644
10149
10150 address &= PAGE_MASK;
10151 error = security_mmap_addr(address);
10152 -@@ -2118,6 +2446,15 @@ int expand_downwards(struct vm_area_struct *vma,
10153 +@@ -2118,6 +2419,15 @@ int expand_downwards(struct vm_area_struct *vma,
10154 if (unlikely(anon_vma_prepare(vma)))
10155 return -ENOMEM;
10156
10157 @@ -149373,7 +149385,7 @@ index bd2e1a53..9299d7f 100644
10158 /*
10159 * vma->vm_start/vm_end cannot change under us because the caller
10160 * is required to hold the mmap_sem in read mode. We need the
10161 -@@ -2126,9 +2463,17 @@ int expand_downwards(struct vm_area_struct *vma,
10162 +@@ -2126,9 +2436,17 @@ int expand_downwards(struct vm_area_struct *vma,
10163 anon_vma_lock_write(vma->anon_vma);
10164
10165 /* Somebody else might have raced and expanded it already */
10166 @@ -149392,7 +149404,7 @@ index bd2e1a53..9299d7f 100644
10167 size = vma->vm_end - address;
10168 grow = (vma->vm_start - address) >> PAGE_SHIFT;
10169
10170 -@@ -2156,13 +2501,27 @@ int expand_downwards(struct vm_area_struct *vma,
10171 +@@ -2156,13 +2474,27 @@ int expand_downwards(struct vm_area_struct *vma,
10172 vma->vm_pgoff -= grow;
10173 anon_vma_interval_tree_post_update_vma(vma);
10174 vma_gap_update(vma);
10175 @@ -149420,7 +149432,7 @@ index bd2e1a53..9299d7f 100644
10176 khugepaged_enter_vma_merge(vma, vma->vm_flags);
10177 validate_mm(mm);
10178 return error;
10179 -@@ -2262,6 +2621,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
10180 +@@ -2262,6 +2594,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
10181 do {
10182 long nrpages = vma_pages(vma);
10183
10184 @@ -149434,7 +149446,7 @@ index bd2e1a53..9299d7f 100644
10185 if (vma->vm_flags & VM_ACCOUNT)
10186 nr_accounted += nrpages;
10187 vm_stat_account(mm, vma->vm_flags, -nrpages);
10188 -@@ -2306,6 +2672,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
10189 +@@ -2306,6 +2645,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
10190 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
10191 vma->vm_prev = NULL;
10192 do {
10193 @@ -149451,7 +149463,7 @@ index bd2e1a53..9299d7f 100644
10194 vma_rb_erase(vma, &mm->mm_rb);
10195 mm->map_count--;
10196 tail_vma = vma;
10197 -@@ -2333,14 +2709,33 @@ static int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
10198 +@@ -2333,14 +2682,33 @@ static int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
10199 struct vm_area_struct *new;
10200 int err;
10201
10202 @@ -149485,7 +149497,7 @@ index bd2e1a53..9299d7f 100644
10203 /* most fields are the same, copy all, and then fixup */
10204 *new = *vma;
10205
10206 -@@ -2353,6 +2748,22 @@ static int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
10207 +@@ -2353,6 +2721,22 @@ static int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
10208 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
10209 }
10210
10211 @@ -149508,7 +149520,7 @@ index bd2e1a53..9299d7f 100644
10212 err = vma_dup_policy(vma, new);
10213 if (err)
10214 goto out_free_vma;
10215 -@@ -2373,6 +2784,38 @@ static int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
10216 +@@ -2373,6 +2757,38 @@ static int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
10217 else
10218 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
10219
10220 @@ -149547,7 +149559,7 @@ index bd2e1a53..9299d7f 100644
10221 /* Success. */
10222 if (!err)
10223 return 0;
10224 -@@ -2382,10 +2825,18 @@ static int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
10225 +@@ -2382,10 +2798,18 @@ static int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
10226 new->vm_ops->close(new);
10227 if (new->vm_file)
10228 fput(new->vm_file);
10229 @@ -149567,7 +149579,7 @@ index bd2e1a53..9299d7f 100644
10230 kmem_cache_free(vm_area_cachep, new);
10231 return err;
10232 }
10233 -@@ -2397,6 +2848,15 @@ static int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
10234 +@@ -2397,6 +2821,15 @@ static int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
10235 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
10236 unsigned long addr, int new_below)
10237 {
10238 @@ -149583,7 +149595,7 @@ index bd2e1a53..9299d7f 100644
10239 if (mm->map_count >= sysctl_max_map_count)
10240 return -ENOMEM;
10241
10242 -@@ -2408,11 +2868,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
10243 +@@ -2408,11 +2841,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
10244 * work. This now handles partial unmappings.
10245 * Jeremy Fitzhardinge <jeremy@××××.org>
10246 */
10247 @@ -149614,7 +149626,7 @@ index bd2e1a53..9299d7f 100644
10248 if ((offset_in_page(start)) || start > TASK_SIZE || len > TASK_SIZE-start)
10249 return -EINVAL;
10250
10251 -@@ -2490,6 +2969,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
10252 +@@ -2490,6 +2942,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
10253 /* Fix up all other VM information */
10254 remove_vma_list(mm, vma);
10255
10256 @@ -149623,11 +149635,10 @@ index bd2e1a53..9299d7f 100644
10257 return 0;
10258 }
10259
10260 -@@ -2498,6 +2979,13 @@ int vm_munmap(unsigned long start, size_t len)
10261 +@@ -2498,6 +2952,12 @@ int vm_munmap(unsigned long start, size_t len)
10262 int ret;
10263 struct mm_struct *mm = current->mm;
10264
10265 -+
10266 +#ifdef CONFIG_PAX_SEGMEXEC
10267 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
10268 + (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
10269 @@ -149637,7 +149648,7 @@ index bd2e1a53..9299d7f 100644
10270 down_write(&mm->mmap_sem);
10271 ret = do_munmap(mm, start, len);
10272 up_write(&mm->mmap_sem);
10273 -@@ -2543,6 +3031,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
10274 +@@ -2543,6 +3003,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
10275 down_write(&mm->mmap_sem);
10276 vma = find_vma(mm, start);
10277
10278 @@ -149649,7 +149660,7 @@ index bd2e1a53..9299d7f 100644
10279 if (!vma || !(vma->vm_flags & VM_SHARED))
10280 goto out;
10281
10282 -@@ -2603,16 +3096,6 @@ out:
10283 +@@ -2603,16 +3068,6 @@ out:
10284 return ret;
10285 }
10286
10287 @@ -149666,7 +149677,7 @@ index bd2e1a53..9299d7f 100644
10288 /*
10289 * this is really a simplified "do_mmap". it only handles
10290 * anonymous maps. eventually we may be able to do some
10291 -@@ -2626,6 +3109,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
10292 +@@ -2626,6 +3081,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
10293 struct rb_node **rb_link, *rb_parent;
10294 pgoff_t pgoff = addr >> PAGE_SHIFT;
10295 int error;
10296 @@ -149674,7 +149685,7 @@ index bd2e1a53..9299d7f 100644
10297
10298 len = PAGE_ALIGN(len);
10299 if (!len)
10300 -@@ -2633,10 +3117,24 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
10301 +@@ -2633,10 +3089,24 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
10302
10303 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
10304
10305 @@ -149699,7 +149710,7 @@ index bd2e1a53..9299d7f 100644
10306 error = mlock_future_check(mm, mm->def_flags, len);
10307 if (error)
10308 return error;
10309 -@@ -2654,16 +3152,17 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
10310 +@@ -2654,16 +3124,17 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
10311 &rb_parent)) {
10312 if (do_munmap(mm, addr, len))
10313 return -ENOMEM;
10314 @@ -149719,7 +149730,7 @@ index bd2e1a53..9299d7f 100644
10315 return -ENOMEM;
10316
10317 /* Can we just expand an old private anonymous mapping? */
10318 -@@ -2677,7 +3176,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
10319 +@@ -2677,7 +3148,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
10320 */
10321 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
10322 if (!vma) {
10323 @@ -149728,7 +149739,7 @@ index bd2e1a53..9299d7f 100644
10324 return -ENOMEM;
10325 }
10326
10327 -@@ -2691,11 +3190,12 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
10328 +@@ -2691,11 +3162,12 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
10329 vma_link(mm, vma, prev, rb_link, rb_parent);
10330 out:
10331 perf_event_mmap(vma);
10332 @@ -149744,7 +149755,7 @@ index bd2e1a53..9299d7f 100644
10333 return addr;
10334 }
10335
10336 -@@ -2757,6 +3257,7 @@ void exit_mmap(struct mm_struct *mm)
10337 +@@ -2757,6 +3229,7 @@ void exit_mmap(struct mm_struct *mm)
10338 while (vma) {
10339 if (vma->vm_flags & VM_ACCOUNT)
10340 nr_accounted += vma_pages(vma);
10341 @@ -149752,7 +149763,7 @@ index bd2e1a53..9299d7f 100644
10342 vma = remove_vma(vma);
10343 }
10344 vm_unacct_memory(nr_accounted);
10345 -@@ -2771,6 +3272,10 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
10346 +@@ -2771,6 +3244,10 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
10347 struct vm_area_struct *prev;
10348 struct rb_node **rb_link, *rb_parent;
10349
10350 @@ -149763,7 +149774,7 @@ index bd2e1a53..9299d7f 100644
10351 if (find_vma_links(mm, vma->vm_start, vma->vm_end,
10352 &prev, &rb_link, &rb_parent))
10353 return -ENOMEM;
10354 -@@ -2778,6 +3283,9 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
10355 +@@ -2778,6 +3255,9 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
10356 security_vm_enough_memory_mm(mm, vma_pages(vma)))
10357 return -ENOMEM;
10358
10359 @@ -149773,7 +149784,7 @@ index bd2e1a53..9299d7f 100644
10360 /*
10361 * The vm_pgoff of a purely anonymous vma should be irrelevant
10362 * until its first write fault, when page's anon_vma and index
10363 -@@ -2795,7 +3303,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
10364 +@@ -2795,7 +3275,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
10365 vma->vm_pgoff = vma->vm_start >> PAGE_SHIFT;
10366 }
10367
10368 @@ -149795,7 +149806,7 @@ index bd2e1a53..9299d7f 100644
10369 return 0;
10370 }
10371
10372 -@@ -2814,6 +3336,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
10373 +@@ -2814,6 +3308,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
10374 struct rb_node **rb_link, *rb_parent;
10375 bool faulted_in_anon_vma = true;
10376
10377 @@ -149804,7 +149815,7 @@ index bd2e1a53..9299d7f 100644
10378 /*
10379 * If anonymous vma has not yet been faulted, update new pgoff
10380 * to match new location, to increase its chance of merging.
10381 -@@ -2880,24 +3404,67 @@ out:
10382 +@@ -2880,24 +3376,67 @@ out:
10383 return NULL;
10384 }
10385
10386 @@ -149880,7 +149891,7 @@ index bd2e1a53..9299d7f 100644
10387 }
10388
10389 return true;
10390 -@@ -2905,6 +3472,11 @@ bool may_expand_vm(struct mm_struct *mm, vm_flags_t flags, unsigned long npages)
10391 +@@ -2905,6 +3444,11 @@ bool may_expand_vm(struct mm_struct *mm, vm_flags_t flags, unsigned long npages)
10392
10393 void vm_stat_account(struct mm_struct *mm, vm_flags_t flags, long npages)
10394 {
10395 @@ -149892,7 +149903,7 @@ index bd2e1a53..9299d7f 100644
10396 mm->total_vm += npages;
10397
10398 if (is_exec_mapping(flags))
10399 -@@ -2989,6 +3561,22 @@ static struct vm_area_struct *__install_special_mapping(
10400 +@@ -2989,6 +3533,22 @@ static struct vm_area_struct *__install_special_mapping(
10401 vma->vm_start = addr;
10402 vma->vm_end = addr + len;
10403
10404 @@ -150309,10 +150320,10 @@ index c8bd59a..82b24ab 100644
10405 struct mm_struct *mm;
10406
10407 diff --git a/mm/page-writeback.c b/mm/page-writeback.c
10408 -index bc5149d..3f523f3 100644
10409 +index e389f0a..2dfc34c 100644
10410 --- a/mm/page-writeback.c
10411 +++ b/mm/page-writeback.c
10412 -@@ -870,7 +870,7 @@ static long long pos_ratio_polynom(unsigned long setpoint,
10413 +@@ -873,7 +873,7 @@ static long long pos_ratio_polynom(unsigned long setpoint,
10414 * card's wb_dirty may rush to many times higher than wb_setpoint.
10415 * - the wb dirty thresh drops quickly due to change of JBOD workload
10416 */
10417 @@ -150490,18 +150501,9 @@ index 898fe3f..78ad9e4 100644
10418 spin_unlock_irqrestore(&zone->lock, flags);
10419 }
10420 diff --git a/mm/percpu.c b/mm/percpu.c
10421 -index 0c59684..5176325 100644
10422 +index 9903830..5176325 100644
10423 --- a/mm/percpu.c
10424 +++ b/mm/percpu.c
10425 -@@ -112,7 +112,7 @@ struct pcpu_chunk {
10426 - int map_used; /* # of map entries used before the sentry */
10427 - int map_alloc; /* # of map entries allocated */
10428 - int *map; /* allocation map */
10429 -- struct work_struct map_extend_work;/* async ->map[] extension */
10430 -+ struct list_head map_extend_list;/* on pcpu_map_extend_chunks */
10431 -
10432 - void *data; /* chunk data */
10433 - int first_free; /* no free below this */
10434 @@ -133,7 +133,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
10435 static unsigned int pcpu_high_unit_cpu __read_mostly;
10436
10437 @@ -150511,192 +150513,6 @@ index 0c59684..5176325 100644
10438 EXPORT_SYMBOL_GPL(pcpu_base_addr);
10439
10440 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
10441 -@@ -162,10 +162,13 @@ static struct pcpu_chunk *pcpu_reserved_chunk;
10442 - static int pcpu_reserved_chunk_limit;
10443 -
10444 - static DEFINE_SPINLOCK(pcpu_lock); /* all internal data structures */
10445 --static DEFINE_MUTEX(pcpu_alloc_mutex); /* chunk create/destroy, [de]pop */
10446 -+static DEFINE_MUTEX(pcpu_alloc_mutex); /* chunk create/destroy, [de]pop, map ext */
10447 -
10448 - static struct list_head *pcpu_slot __read_mostly; /* chunk list slots */
10449 -
10450 -+/* chunks which need their map areas extended, protected by pcpu_lock */
10451 -+static LIST_HEAD(pcpu_map_extend_chunks);
10452 -+
10453 - /*
10454 - * The number of empty populated pages, protected by pcpu_lock. The
10455 - * reserved chunk doesn't contribute to the count.
10456 -@@ -395,13 +398,19 @@ static int pcpu_need_to_extend(struct pcpu_chunk *chunk, bool is_atomic)
10457 - {
10458 - int margin, new_alloc;
10459 -
10460 -+ lockdep_assert_held(&pcpu_lock);
10461 -+
10462 - if (is_atomic) {
10463 - margin = 3;
10464 -
10465 - if (chunk->map_alloc <
10466 -- chunk->map_used + PCPU_ATOMIC_MAP_MARGIN_LOW &&
10467 -- pcpu_async_enabled)
10468 -- schedule_work(&chunk->map_extend_work);
10469 -+ chunk->map_used + PCPU_ATOMIC_MAP_MARGIN_LOW) {
10470 -+ if (list_empty(&chunk->map_extend_list)) {
10471 -+ list_add_tail(&chunk->map_extend_list,
10472 -+ &pcpu_map_extend_chunks);
10473 -+ pcpu_schedule_balance_work();
10474 -+ }
10475 -+ }
10476 - } else {
10477 - margin = PCPU_ATOMIC_MAP_MARGIN_HIGH;
10478 - }
10479 -@@ -435,6 +444,8 @@ static int pcpu_extend_area_map(struct pcpu_chunk *chunk, int new_alloc)
10480 - size_t old_size = 0, new_size = new_alloc * sizeof(new[0]);
10481 - unsigned long flags;
10482 -
10483 -+ lockdep_assert_held(&pcpu_alloc_mutex);
10484 -+
10485 - new = pcpu_mem_zalloc(new_size);
10486 - if (!new)
10487 - return -ENOMEM;
10488 -@@ -467,20 +478,6 @@ out_unlock:
10489 - return 0;
10490 - }
10491 -
10492 --static void pcpu_map_extend_workfn(struct work_struct *work)
10493 --{
10494 -- struct pcpu_chunk *chunk = container_of(work, struct pcpu_chunk,
10495 -- map_extend_work);
10496 -- int new_alloc;
10497 --
10498 -- spin_lock_irq(&pcpu_lock);
10499 -- new_alloc = pcpu_need_to_extend(chunk, false);
10500 -- spin_unlock_irq(&pcpu_lock);
10501 --
10502 -- if (new_alloc)
10503 -- pcpu_extend_area_map(chunk, new_alloc);
10504 --}
10505 --
10506 - /**
10507 - * pcpu_fit_in_area - try to fit the requested allocation in a candidate area
10508 - * @chunk: chunk the candidate area belongs to
10509 -@@ -740,7 +737,7 @@ static struct pcpu_chunk *pcpu_alloc_chunk(void)
10510 - chunk->map_used = 1;
10511 -
10512 - INIT_LIST_HEAD(&chunk->list);
10513 -- INIT_WORK(&chunk->map_extend_work, pcpu_map_extend_workfn);
10514 -+ INIT_LIST_HEAD(&chunk->map_extend_list);
10515 - chunk->free_size = pcpu_unit_size;
10516 - chunk->contig_hint = pcpu_unit_size;
10517 -
10518 -@@ -895,6 +892,9 @@ static void __percpu *pcpu_alloc(size_t size, size_t align, bool reserved,
10519 - return NULL;
10520 - }
10521 -
10522 -+ if (!is_atomic)
10523 -+ mutex_lock(&pcpu_alloc_mutex);
10524 -+
10525 - spin_lock_irqsave(&pcpu_lock, flags);
10526 -
10527 - /* serve reserved allocations from the reserved chunk if available */
10528 -@@ -967,12 +967,9 @@ restart:
10529 - if (is_atomic)
10530 - goto fail;
10531 -
10532 -- mutex_lock(&pcpu_alloc_mutex);
10533 --
10534 - if (list_empty(&pcpu_slot[pcpu_nr_slots - 1])) {
10535 - chunk = pcpu_create_chunk();
10536 - if (!chunk) {
10537 -- mutex_unlock(&pcpu_alloc_mutex);
10538 - err = "failed to allocate new chunk";
10539 - goto fail;
10540 - }
10541 -@@ -983,7 +980,6 @@ restart:
10542 - spin_lock_irqsave(&pcpu_lock, flags);
10543 - }
10544 -
10545 -- mutex_unlock(&pcpu_alloc_mutex);
10546 - goto restart;
10547 -
10548 - area_found:
10549 -@@ -993,8 +989,6 @@ area_found:
10550 - if (!is_atomic) {
10551 - int page_start, page_end, rs, re;
10552 -
10553 -- mutex_lock(&pcpu_alloc_mutex);
10554 --
10555 - page_start = PFN_DOWN(off);
10556 - page_end = PFN_UP(off + size);
10557 -
10558 -@@ -1005,7 +999,6 @@ area_found:
10559 -
10560 - spin_lock_irqsave(&pcpu_lock, flags);
10561 - if (ret) {
10562 -- mutex_unlock(&pcpu_alloc_mutex);
10563 - pcpu_free_area(chunk, off, &occ_pages);
10564 - err = "failed to populate";
10565 - goto fail_unlock;
10566 -@@ -1045,6 +1038,8 @@ fail:
10567 - /* see the flag handling in pcpu_blance_workfn() */
10568 - pcpu_atomic_alloc_failed = true;
10569 - pcpu_schedule_balance_work();
10570 -+ } else {
10571 -+ mutex_unlock(&pcpu_alloc_mutex);
10572 - }
10573 - return NULL;
10574 - }
10575 -@@ -1129,6 +1124,7 @@ static void pcpu_balance_workfn(struct work_struct *work)
10576 - if (chunk == list_first_entry(free_head, struct pcpu_chunk, list))
10577 - continue;
10578 -
10579 -+ list_del_init(&chunk->map_extend_list);
10580 - list_move(&chunk->list, &to_free);
10581 - }
10582 -
10583 -@@ -1146,6 +1142,25 @@ static void pcpu_balance_workfn(struct work_struct *work)
10584 - pcpu_destroy_chunk(chunk);
10585 - }
10586 -
10587 -+ /* service chunks which requested async area map extension */
10588 -+ do {
10589 -+ int new_alloc = 0;
10590 -+
10591 -+ spin_lock_irq(&pcpu_lock);
10592 -+
10593 -+ chunk = list_first_entry_or_null(&pcpu_map_extend_chunks,
10594 -+ struct pcpu_chunk, map_extend_list);
10595 -+ if (chunk) {
10596 -+ list_del_init(&chunk->map_extend_list);
10597 -+ new_alloc = pcpu_need_to_extend(chunk, false);
10598 -+ }
10599 -+
10600 -+ spin_unlock_irq(&pcpu_lock);
10601 -+
10602 -+ if (new_alloc)
10603 -+ pcpu_extend_area_map(chunk, new_alloc);
10604 -+ } while (chunk);
10605 -+
10606 - /*
10607 - * Ensure there are certain number of free populated pages for
10608 - * atomic allocs. Fill up from the most packed so that atomic
10609 -@@ -1644,7 +1659,7 @@ int __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai,
10610 - */
10611 - schunk = memblock_virt_alloc(pcpu_chunk_struct_size, 0);
10612 - INIT_LIST_HEAD(&schunk->list);
10613 -- INIT_WORK(&schunk->map_extend_work, pcpu_map_extend_workfn);
10614 -+ INIT_LIST_HEAD(&schunk->map_extend_list);
10615 - schunk->base_addr = base_addr;
10616 - schunk->map = smap;
10617 - schunk->map_alloc = ARRAY_SIZE(smap);
10618 -@@ -1673,7 +1688,7 @@ int __init pcpu_setup_first_chunk(const struct pcpu_alloc_info *ai,
10619 - if (dyn_size) {
10620 - dchunk = memblock_virt_alloc(pcpu_chunk_struct_size, 0);
10621 - INIT_LIST_HEAD(&dchunk->list);
10622 -- INIT_WORK(&dchunk->map_extend_work, pcpu_map_extend_workfn);
10623 -+ INIT_LIST_HEAD(&dchunk->map_extend_list);
10624 - dchunk->base_addr = base_addr;
10625 - dchunk->map = dmap;
10626 - dchunk->map_alloc = ARRAY_SIZE(dmap);
10627 diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
10628 index 07514d4..9989090 100644
10629 --- a/mm/process_vm_access.c
10630 @@ -150866,7 +150682,7 @@ index 3ebf9c4..ec385cd 100644
10631
10632 /*
10633 diff --git a/mm/shmem.c b/mm/shmem.c
10634 -index 719bd6b..6b464fb 100644
10635 +index 9ca09f5..448e8b3 100644
10636 --- a/mm/shmem.c
10637 +++ b/mm/shmem.c
10638 @@ -33,7 +33,7 @@
10639 @@ -150887,7 +150703,7 @@ index 719bd6b..6b464fb 100644
10640
10641 /*
10642 * shmem_fallocate communicates with shmem_fault or shmem_writepage via
10643 -@@ -2665,6 +2665,23 @@ static int shmem_xattr_handler_set(const struct xattr_handler *handler,
10644 +@@ -2667,6 +2667,23 @@ static int shmem_xattr_handler_set(const struct xattr_handler *handler,
10645 return simple_xattr_set(&info->xattrs, name, value, size, flags);
10646 }
10647
10648 @@ -150911,7 +150727,7 @@ index 719bd6b..6b464fb 100644
10649 static const struct xattr_handler shmem_security_xattr_handler = {
10650 .prefix = XATTR_SECURITY_PREFIX,
10651 .get = shmem_xattr_handler_get,
10652 -@@ -2677,6 +2694,14 @@ static const struct xattr_handler shmem_trusted_xattr_handler = {
10653 +@@ -2679,6 +2696,14 @@ static const struct xattr_handler shmem_trusted_xattr_handler = {
10654 .set = shmem_xattr_handler_set,
10655 };
10656
10657 @@ -150926,7 +150742,7 @@ index 719bd6b..6b464fb 100644
10658 static const struct xattr_handler *shmem_xattr_handlers[] = {
10659 #ifdef CONFIG_TMPFS_POSIX_ACL
10660 &posix_acl_access_xattr_handler,
10661 -@@ -2684,6 +2709,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
10662 +@@ -2686,6 +2711,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
10663 #endif
10664 &shmem_security_xattr_handler,
10665 &shmem_trusted_xattr_handler,
10666 @@ -150938,7 +150754,7 @@ index 719bd6b..6b464fb 100644
10667 NULL
10668 };
10669
10670 -@@ -3044,8 +3074,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
10671 +@@ -3046,8 +3076,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
10672 int err = -ENOMEM;
10673
10674 /* Round up to L1_CACHE_BYTES to resist false sharing */
10675 @@ -154634,7 +154450,7 @@ index 2696aef..dbd5807 100644
10676 if (!err)
10677 err = put_user(SCM_RIGHTS, &cm->cmsg_type);
10678 diff --git a/net/core/skbuff.c b/net/core/skbuff.c
10679 -index e561f9f..25281cc 100644
10680 +index 59bf4d7..71bbed8 100644
10681 --- a/net/core/skbuff.c
10682 +++ b/net/core/skbuff.c
10683 @@ -1046,7 +1046,8 @@ static void skb_headers_offset_update(struct sk_buff *skb, int off)
10684 @@ -154656,7 +154472,7 @@ index e561f9f..25281cc 100644
10685 .update = csum_partial_ext,
10686 .combine = csum_block_add_ext,
10687 };
10688 -@@ -3414,12 +3415,14 @@ void __init skb_init(void)
10689 +@@ -3396,12 +3397,14 @@ void __init skb_init(void)
10690 skbuff_head_cache = kmem_cache_create("skbuff_head_cache",
10691 sizeof(struct sk_buff),
10692 0,
10693 @@ -156846,7 +156662,7 @@ index 70f2628..721dd1e 100644
10694 {
10695 struct inet_hashinfo *hinfo = death_row->hashinfo;
10696 diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
10697 -index ea071fa..8bdb3e0 100644
10698 +index c26fac2..f944bc7 100644
10699 --- a/net/ipv6/ip6_fib.c
10700 +++ b/net/ipv6/ip6_fib.c
10701 @@ -98,9 +98,9 @@ static int fib6_new_sernum(struct net *net)
10702 @@ -159444,9 +159260,64 @@ index 2011977..ba46f29 100644
10703 };
10704 return netlink_dump_start(nlsk, skb, nlh, &c);
10705 diff --git a/net/netfilter/nfnetlink_acct.c b/net/netfilter/nfnetlink_acct.c
10706 -index dbd0803..1071d39 100644
10707 +index dbd0803..9d18caa 100644
10708 --- a/net/netfilter/nfnetlink_acct.c
10709 +++ b/net/netfilter/nfnetlink_acct.c
10710 +@@ -28,8 +28,8 @@ MODULE_AUTHOR("Pablo Neira Ayuso <pablo@×××××××××.org>");
10711 + MODULE_DESCRIPTION("nfacct: Extended Netfilter accounting infrastructure");
10712 +
10713 + struct nf_acct {
10714 +- atomic64_t pkts;
10715 +- atomic64_t bytes;
10716 ++ atomic64_unchecked_t pkts;
10717 ++ atomic64_unchecked_t bytes;
10718 + unsigned long flags;
10719 + struct list_head head;
10720 + atomic_t refcnt;
10721 +@@ -76,8 +76,8 @@ static int nfnl_acct_new(struct net *net, struct sock *nfnl,
10722 + if (matching) {
10723 + if (nlh->nlmsg_flags & NLM_F_REPLACE) {
10724 + /* reset counters if you request a replacement. */
10725 +- atomic64_set(&matching->pkts, 0);
10726 +- atomic64_set(&matching->bytes, 0);
10727 ++ atomic64_set_unchecked(&matching->pkts, 0);
10728 ++ atomic64_set_unchecked(&matching->bytes, 0);
10729 + smp_mb__before_atomic();
10730 + /* reset overquota flag if quota is enabled. */
10731 + if ((matching->flags & NFACCT_F_QUOTA))
10732 +@@ -116,11 +116,11 @@ static int nfnl_acct_new(struct net *net, struct sock *nfnl,
10733 + strncpy(nfacct->name, nla_data(tb[NFACCT_NAME]), NFACCT_NAME_MAX);
10734 +
10735 + if (tb[NFACCT_BYTES]) {
10736 +- atomic64_set(&nfacct->bytes,
10737 ++ atomic64_set_unchecked(&nfacct->bytes,
10738 + be64_to_cpu(nla_get_be64(tb[NFACCT_BYTES])));
10739 + }
10740 + if (tb[NFACCT_PKTS]) {
10741 +- atomic64_set(&nfacct->pkts,
10742 ++ atomic64_set_unchecked(&nfacct->pkts,
10743 + be64_to_cpu(nla_get_be64(tb[NFACCT_PKTS])));
10744 + }
10745 + atomic_set(&nfacct->refcnt, 1);
10746 +@@ -153,14 +153,14 @@ nfnl_acct_fill_info(struct sk_buff *skb, u32 portid, u32 seq, u32 type,
10747 +
10748 + old_flags = acct->flags;
10749 + if (type == NFNL_MSG_ACCT_GET_CTRZERO) {
10750 +- pkts = atomic64_xchg(&acct->pkts, 0);
10751 +- bytes = atomic64_xchg(&acct->bytes, 0);
10752 ++ pkts = atomic64_xchg_unchecked(&acct->pkts, 0);
10753 ++ bytes = atomic64_xchg_unchecked(&acct->bytes, 0);
10754 + smp_mb__before_atomic();
10755 + if (acct->flags & NFACCT_F_QUOTA)
10756 + clear_bit(NFACCT_OVERQUOTA_BIT, &acct->flags);
10757 + } else {
10758 +- pkts = atomic64_read(&acct->pkts);
10759 +- bytes = atomic64_read(&acct->bytes);
10760 ++ pkts = atomic64_read_unchecked(&acct->pkts);
10761 ++ bytes = atomic64_read_unchecked(&acct->bytes);
10762 + }
10763 + if (nla_put_be64(skb, NFACCT_PKTS, cpu_to_be64(pkts)) ||
10764 + nla_put_be64(skb, NFACCT_BYTES, cpu_to_be64(bytes)) ||
10765 @@ -266,10 +266,11 @@ static int nfnl_acct_get(struct net *net, struct sock *nfnl,
10766 char *acct_name;
10767
10768 @@ -159472,6 +159343,26 @@ index dbd0803..1071d39 100644
10769 }
10770
10771 if (!tb[NFACCT_NAME])
10772 +@@ -435,8 +436,8 @@ EXPORT_SYMBOL_GPL(nfnl_acct_put);
10773 +
10774 + void nfnl_acct_update(const struct sk_buff *skb, struct nf_acct *nfacct)
10775 + {
10776 +- atomic64_inc(&nfacct->pkts);
10777 +- atomic64_add(skb->len, &nfacct->bytes);
10778 ++ atomic64_inc_unchecked(&nfacct->pkts);
10779 ++ atomic64_add_unchecked(skb->len, &nfacct->bytes);
10780 + }
10781 + EXPORT_SYMBOL_GPL(nfnl_acct_update);
10782 +
10783 +@@ -471,7 +472,7 @@ int nfnl_acct_overquota(const struct sk_buff *skb, struct nf_acct *nfacct)
10784 +
10785 + quota = (u64 *)nfacct->data;
10786 + now = (nfacct->flags & NFACCT_F_QUOTA_PKTS) ?
10787 +- atomic64_read(&nfacct->pkts) : atomic64_read(&nfacct->bytes);
10788 ++ atomic64_read_unchecked(&nfacct->pkts) : atomic64_read_unchecked(&nfacct->bytes);
10789 +
10790 + ret = now > *quota;
10791 +
10792 diff --git a/net/netfilter/nfnetlink_cthelper.c b/net/netfilter/nfnetlink_cthelper.c
10793 index e924e95..1e2e233 100644
10794 --- a/net/netfilter/nfnetlink_cthelper.c
10795 @@ -159931,7 +159822,7 @@ index 5eb7694..58d8f08 100644
10796
10797 static int __init ovs_vxlan_tnl_init(void)
10798 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
10799 -index 18d0bec..8fdeb86 100644
10800 +index 8012f67..1a3168e 100644
10801 --- a/net/packet/af_packet.c
10802 +++ b/net/packet/af_packet.c
10803 @@ -278,7 +278,7 @@ static int packet_direct_xmit(struct sk_buff *skb)
10804 @@ -161172,10 +161063,10 @@ index 553bf95..c4c6132 100644
10805 goto out_nomem;
10806 cd->u.procfs.channel_ent = NULL;
10807 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
10808 -index 7e0c9bf..bdec2b8 100644
10809 +index 837dd91..7a070a7 100644
10810 --- a/net/sunrpc/clnt.c
10811 +++ b/net/sunrpc/clnt.c
10812 -@@ -1508,7 +1508,9 @@ call_start(struct rpc_task *task)
10813 +@@ -1527,7 +1527,9 @@ call_start(struct rpc_task *task)
10814 (RPC_IS_ASYNC(task) ? "async" : "sync"));
10815
10816 /* Increment call count */
10817 @@ -161701,7 +161592,7 @@ index e6cb386..9eaa00c 100644
10818 sub->evt.event = htohl(event, sub->swap);
10819 sub->evt.found_lower = htohl(found_lower, sub->swap);
10820 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
10821 -index 8269da7..8525db6 100644
10822 +index 7748199..1cc52d17 100644
10823 --- a/net/unix/af_unix.c
10824 +++ b/net/unix/af_unix.c
10825 @@ -919,6 +919,12 @@ static struct sock *unix_find_other(struct net *net,
10826 @@ -163228,22 +163119,25 @@ index 0000000..de92ed9
10827 +randomize_layout_seed.h
10828 diff --git a/scripts/gcc-plugins/Makefile b/scripts/gcc-plugins/Makefile
10829 new file mode 100644
10830 -index 0000000..ec5bc00
10831 +index 0000000..8d234d3
10832 --- /dev/null
10833 +++ b/scripts/gcc-plugins/Makefile
10834 -@@ -0,0 +1,35 @@
10835 +@@ -0,0 +1,38 @@
10836 +GCC_PLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
10837 +
10838 +ifeq ($(PLUGINCC),$(HOSTCC))
10839 + HOSTLIBS := hostlibs
10840 -+ HOST_EXTRACFLAGS += -I$(GCC_PLUGINS_DIR)/include -I$(src) -std=gnu99 -ggdb -Wall -W
10841 ++ HOST_EXTRACFLAGS += -I$(GCC_PLUGINS_DIR)/include -I$(src)
10842 ++ HOST_EXTRACFLAGS += -std=gnu99 -ggdb -fvisibility=hidden
10843 ++ HOST_EXTRACFLAGS += -Wall -W
10844 + export HOST_EXTRACFLAGS
10845 +else
10846 + HOSTLIBS := hostcxxlibs
10847 -+ HOST_EXTRACXXFLAGS += -I$(GCC_PLUGINS_DIR)/include -I$(src) -std=gnu++98 -fno-rtti
10848 -+ HOST_EXTRACXXFLAGS += -fno-exceptions -fasynchronous-unwind-tables -ggdb
10849 -+ HOST_EXTRACXXFLAGS += -Wno-narrowing -Wno-unused-variable
10850 -+ HOST_EXTRACXXFLAGS += -Wall -W -Wno-unused-parameter
10851 ++ HOST_EXTRACXXFLAGS += -I$(GCC_PLUGINS_DIR)/include -I$(src)
10852 ++ HOST_EXTRACXXFLAGS += -std=gnu++98 -ggdb -fvisibility=hidden
10853 ++ HOST_EXTRACXXFLAGS += -fno-rtti -fno-exceptions -fasynchronous-unwind-tables
10854 ++ HOST_EXTRACXXFLAGS += -Wall -W
10855 ++ HOST_EXTRACXXFLAGS += -Wno-unused-parameter -Wno-narrowing -Wno-unused-variable
10856 + export HOST_EXTRACXXFLAGS
10857 +endif
10858 +
10859 @@ -163269,7 +163163,7 @@ index 0000000..ec5bc00
10860 +clean-files += *.so
10861 diff --git a/scripts/gcc-plugins/checker_plugin.c b/scripts/gcc-plugins/checker_plugin.c
10862 new file mode 100644
10863 -index 0000000..efaf576
10864 +index 0000000..2b3c178
10865 --- /dev/null
10866 +++ b/scripts/gcc-plugins/checker_plugin.c
10867 @@ -0,0 +1,496 @@
10868 @@ -163300,7 +163194,7 @@ index 0000000..efaf576
10869 +extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
10870 +extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
10871 +
10872 -+int plugin_is_GPL_compatible;
10873 ++__visible int plugin_is_GPL_compatible;
10874 +
10875 +static struct plugin_info checker_plugin_info = {
10876 + .version = "201602181345",
10877 @@ -163704,7 +163598,7 @@ index 0000000..efaf576
10878 +#define TODO_FLAGS_FINISH TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_verify_flow | TODO_update_ssa
10879 +#include "gcc-generate-gimple-pass.h"
10880 +
10881 -+int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
10882 ++__visible int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
10883 +{
10884 + const char * const plugin_name = plugin_info->base_name;
10885 + const int argc = plugin_info->argc;
10886 @@ -163771,7 +163665,7 @@ index 0000000..efaf576
10887 +}
10888 diff --git a/scripts/gcc-plugins/colorize_plugin.c b/scripts/gcc-plugins/colorize_plugin.c
10889 new file mode 100644
10890 -index 0000000..ffe60f6
10891 +index 0000000..31fd196
10892 --- /dev/null
10893 +++ b/scripts/gcc-plugins/colorize_plugin.c
10894 @@ -0,0 +1,162 @@
10895 @@ -163790,7 +163684,7 @@ index 0000000..ffe60f6
10896 +
10897 +#include "gcc-common.h"
10898 +
10899 -+int plugin_is_GPL_compatible;
10900 ++__visible int plugin_is_GPL_compatible;
10901 +
10902 +static struct plugin_info colorize_plugin_info = {
10903 + .version = "201602181345",
10904 @@ -163888,7 +163782,7 @@ index 0000000..ffe60f6
10905 +#endif
10906 +}
10907 +
10908 -+int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
10909 ++__visible int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
10910 +{
10911 + const char * const plugin_name = plugin_info->base_name;
10912 + const int argc = plugin_info->argc;
10913 @@ -163939,7 +163833,7 @@ index 0000000..ffe60f6
10914 +}
10915 diff --git a/scripts/gcc-plugins/constify_plugin.c b/scripts/gcc-plugins/constify_plugin.c
10916 new file mode 100644
10917 -index 0000000..b769ccf
10918 +index 0000000..5287631c
10919 --- /dev/null
10920 +++ b/scripts/gcc-plugins/constify_plugin.c
10921 @@ -0,0 +1,582 @@
10922 @@ -163963,7 +163857,7 @@ index 0000000..b769ccf
10923 +// unused C type flag in all versions 4.5-6
10924 +#define TYPE_CONSTIFY_VISITED(TYPE) TYPE_LANG_FLAG_4(TYPE)
10925 +
10926 -+int plugin_is_GPL_compatible;
10927 ++__visible int plugin_is_GPL_compatible;
10928 +
10929 +static bool enabled = true;
10930 +
10931 @@ -164482,7 +164376,7 @@ index 0000000..b769ccf
10932 + targetm.section_type_flags = constify_section_type_flags;
10933 +}
10934 +
10935 -+int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
10936 ++__visible int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
10937 +{
10938 + const char * const plugin_name = plugin_info->base_name;
10939 + const int argc = plugin_info->argc;
10940 @@ -164527,10 +164421,10 @@ index 0000000..b769ccf
10941 +}
10942 diff --git a/scripts/gcc-plugins/gcc-common.h b/scripts/gcc-plugins/gcc-common.h
10943 new file mode 100644
10944 -index 0000000..7b14844
10945 +index 0000000..a4e216d
10946 --- /dev/null
10947 +++ b/scripts/gcc-plugins/gcc-common.h
10948 -@@ -0,0 +1,893 @@
10949 +@@ -0,0 +1,894 @@
10950 +#ifndef GCC_COMMON_H_INCLUDED
10951 +#define GCC_COMMON_H_INCLUDED
10952 +
10953 @@ -164688,6 +164582,7 @@ index 0000000..7b14844
10954 +#endif
10955 +
10956 +#define __unused __attribute__((__unused__))
10957 ++#define __visible __attribute__((visibility("default")))
10958 +
10959 +#define DECL_NAME_POINTER(node) IDENTIFIER_POINTER(DECL_NAME(node))
10960 +#define DECL_NAME_LENGTH(node) IDENTIFIER_LENGTH(DECL_NAME(node))
10961 @@ -166278,7 +166173,7 @@ index 0000000..7514850
10962 +fi
10963 diff --git a/scripts/gcc-plugins/initify_plugin.c b/scripts/gcc-plugins/initify_plugin.c
10964 new file mode 100644
10965 -index 0000000..bf3eb6c
10966 +index 0000000..4b554fa
10967 --- /dev/null
10968 +++ b/scripts/gcc-plugins/initify_plugin.c
10969 @@ -0,0 +1,536 @@
10970 @@ -166299,7 +166194,7 @@ index 0000000..bf3eb6c
10971 +
10972 +#include "gcc-common.h"
10973 +
10974 -+int plugin_is_GPL_compatible;
10975 ++__visible int plugin_is_GPL_compatible;
10976 +
10977 +static struct plugin_info initify_plugin_info = {
10978 + .version = "20160306",
10979 @@ -166796,7 +166691,7 @@ index 0000000..bf3eb6c
10980 + targetm.section_type_flags = initify_section_type_flags;
10981 +}
10982 +
10983 -+int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
10984 ++__visible int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
10985 +{
10986 + const char * const plugin_name = plugin_info->base_name;
10987 + struct register_pass_info initify_pass_info;
10988 @@ -166820,7 +166715,7 @@ index 0000000..bf3eb6c
10989 +}
10990 diff --git a/scripts/gcc-plugins/kallocstat_plugin.c b/scripts/gcc-plugins/kallocstat_plugin.c
10991 new file mode 100644
10992 -index 0000000..30ecc9a
10993 +index 0000000..3bd3089
10994 --- /dev/null
10995 +++ b/scripts/gcc-plugins/kallocstat_plugin.c
10996 @@ -0,0 +1,135 @@
10997 @@ -166843,7 +166738,7 @@ index 0000000..30ecc9a
10998 +
10999 +#include "gcc-common.h"
11000 +
11001 -+int plugin_is_GPL_compatible;
11002 ++__visible int plugin_is_GPL_compatible;
11003 +
11004 +static struct plugin_info kallocstat_plugin_info = {
11005 + .version = "201602181345",
11006 @@ -166939,7 +166834,7 @@ index 0000000..30ecc9a
11007 +#define NO_GATE
11008 +#include "gcc-generate-gimple-pass.h"
11009 +
11010 -+int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
11011 ++__visible int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
11012 +{
11013 + const char * const plugin_name = plugin_info->base_name;
11014 + struct register_pass_info kallocstat_pass_info;
11015 @@ -166961,7 +166856,7 @@ index 0000000..30ecc9a
11016 +}
11017 diff --git a/scripts/gcc-plugins/kernexec_plugin.c b/scripts/gcc-plugins/kernexec_plugin.c
11018 new file mode 100644
11019 -index 0000000..e31e92f
11020 +index 0000000..a213367
11021 --- /dev/null
11022 +++ b/scripts/gcc-plugins/kernexec_plugin.c
11023 @@ -0,0 +1,407 @@
11024 @@ -166984,10 +166879,10 @@ index 0000000..e31e92f
11025 +
11026 +#include "gcc-common.h"
11027 +
11028 -+int plugin_is_GPL_compatible;
11029 ++__visible int plugin_is_GPL_compatible;
11030 +
11031 +static struct plugin_info kernexec_plugin_info = {
11032 -+ .version = "201602181345",
11033 ++ .version = "201607271510",
11034 + .help = "method=[bts|or]\tinstrumentation method\n"
11035 +};
11036 +
11037 @@ -167308,7 +167203,7 @@ index 0000000..e31e92f
11038 +#define TODO_FLAGS_FINISH TODO_dump_func | TODO_ggc_collect
11039 +#include "gcc-generate-rtl-pass.h"
11040 +
11041 -+int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
11042 ++__visible int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
11043 +{
11044 + const char * const plugin_name = plugin_info->base_name;
11045 + const int argc = plugin_info->argc;
11046 @@ -167319,14 +167214,14 @@ index 0000000..e31e92f
11047 + struct register_pass_info kernexec_retaddr_pass_info;
11048 +
11049 + kernexec_reload_pass_info.pass = make_kernexec_reload_pass();
11050 -+ kernexec_reload_pass_info.reference_pass_name = "ssa";
11051 ++ kernexec_reload_pass_info.reference_pass_name = "early_optimizations";
11052 + kernexec_reload_pass_info.ref_pass_instance_number = 1;
11053 -+ kernexec_reload_pass_info.pos_op = PASS_POS_INSERT_AFTER;
11054 ++ kernexec_reload_pass_info.pos_op = PASS_POS_INSERT_BEFORE;
11055 +
11056 + kernexec_fptr_pass_info.pass = make_kernexec_fptr_pass();
11057 -+ kernexec_fptr_pass_info.reference_pass_name = "ssa";
11058 ++ kernexec_fptr_pass_info.reference_pass_name = "early_optimizations";
11059 + kernexec_fptr_pass_info.ref_pass_instance_number = 1;
11060 -+ kernexec_fptr_pass_info.pos_op = PASS_POS_INSERT_AFTER;
11061 ++ kernexec_fptr_pass_info.pos_op = PASS_POS_INSERT_BEFORE;
11062 +
11063 + kernexec_retaddr_pass_info.pass = make_kernexec_retaddr_pass();
11064 + kernexec_retaddr_pass_info.reference_pass_name = "pro_and_epilogue";
11065 @@ -167374,7 +167269,7 @@ index 0000000..e31e92f
11066 +}
11067 diff --git a/scripts/gcc-plugins/latent_entropy_plugin.c b/scripts/gcc-plugins/latent_entropy_plugin.c
11068 new file mode 100644
11069 -index 0000000..be3978c
11070 +index 0000000..a7161bf
11071 --- /dev/null
11072 +++ b/scripts/gcc-plugins/latent_entropy_plugin.c
11073 @@ -0,0 +1,613 @@
11074 @@ -167456,7 +167351,7 @@ index 0000000..be3978c
11075 +
11076 +#include "gcc-common.h"
11077 +
11078 -+int plugin_is_GPL_compatible;
11079 ++__visible int plugin_is_GPL_compatible;
11080 +
11081 +static GTY(()) tree latent_entropy_decl;
11082 +
11083 @@ -167943,7 +167838,7 @@ index 0000000..be3978c
11084 +#define TODO_FLAGS_FINISH TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
11085 +#include "gcc-generate-gimple-pass.h"
11086 +
11087 -+int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
11088 ++__visible int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
11089 +{
11090 + bool enabled = true;
11091 + const char * const plugin_name = plugin_info->base_name;
11092 @@ -167993,7 +167888,7 @@ index 0000000..be3978c
11093 +}
11094 diff --git a/scripts/gcc-plugins/randomize_layout_plugin.c b/scripts/gcc-plugins/randomize_layout_plugin.c
11095 new file mode 100644
11096 -index 0000000..a716d7a
11097 +index 0000000..3ac813e
11098 --- /dev/null
11099 +++ b/scripts/gcc-plugins/randomize_layout_plugin.c
11100 @@ -0,0 +1,940 @@
11101 @@ -168026,12 +167921,12 @@ index 0000000..a716d7a
11102 +#define ORIG_TYPE_NAME(node) \
11103 + (TYPE_NAME(TYPE_MAIN_VARIANT(node)) != NULL_TREE ? ((const unsigned char *)IDENTIFIER_POINTER(TYPE_NAME(TYPE_MAIN_VARIANT(node)))) : (const unsigned char *)"anonymous")
11104 +
11105 -+int plugin_is_GPL_compatible;
11106 ++__visible int plugin_is_GPL_compatible;
11107 +
11108 +static int performance_mode;
11109 +
11110 +static struct plugin_info randomize_layout_plugin_info = {
11111 -+ .version = "201402201816",
11112 ++ .version = "201607271952",
11113 + .help = "disable\t\t\tdo not activate plugin\n"
11114 + "performance-mode\tenable cacheline-aware layout randomization\n"
11115 +};
11116 @@ -168878,7 +168773,7 @@ index 0000000..a716d7a
11117 +#define TODO_FLAGS_FINISH TODO_dump_func
11118 +#include "gcc-generate-gimple-pass.h"
11119 +
11120 -+int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
11121 ++__visible int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
11122 +{
11123 + int i;
11124 + const char * const plugin_name = plugin_info->base_name;
11125 @@ -169607,10 +169502,10 @@ index 0000000..7c59f38
11126 +}
11127 diff --git a/scripts/gcc-plugins/rap_plugin/rap_plugin.c b/scripts/gcc-plugins/rap_plugin/rap_plugin.c
11128 new file mode 100644
11129 -index 0000000..bca74dc
11130 +index 0000000..80f2e14
11131 --- /dev/null
11132 +++ b/scripts/gcc-plugins/rap_plugin/rap_plugin.c
11133 -@@ -0,0 +1,511 @@
11134 +@@ -0,0 +1,513 @@
11135 +/*
11136 + * Copyright 2012-2016 by PaX Team <pageexec@××××××××.hu>
11137 + * Licensed under the GPL v2
11138 @@ -169627,7 +169522,7 @@ index 0000000..bca74dc
11139 +
11140 +#include "rap.h"
11141 +
11142 -+int plugin_is_GPL_compatible;
11143 ++__visible int plugin_is_GPL_compatible;
11144 +
11145 +static struct plugin_info rap_plugin_info = {
11146 + .version = "201604272100",
11147 @@ -169889,6 +169784,7 @@ index 0000000..bca74dc
11148 + fprintf(asm_out_file, "\t.previous\n");
11149 +}
11150 +
11151 ++#if BUILDING_GCC_VERSION >= 4007
11152 +// emit the rap hash as an absolute symbol for all functions seen in the frontend
11153 +// this is necessary as later unreferenced nodes will be removed yet we'd like to emit as many hashes as possible
11154 +static void rap_finish_decl(void *event_data, void *data __unused)
11155 @@ -169937,6 +169833,7 @@ index 0000000..bca74dc
11156 +
11157 + fprintf(asm_out_file, "\t.previous\n");
11158 +}
11159 ++#endif
11160 +
11161 +static bool rap_unignore_gate(void)
11162 +{
11163 @@ -169987,7 +169884,7 @@ index 0000000..bca74dc
11164 + LAST_GGC_ROOT_TAB
11165 +};
11166 +
11167 -+int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
11168 ++__visible int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
11169 +{
11170 + int i;
11171 + const char * const plugin_name = plugin_info->base_name;
11172 @@ -185058,10 +184955,10 @@ index 0000000..00c7430
11173 +}
11174 diff --git a/scripts/gcc-plugins/size_overflow_plugin/size_overflow_hash.data b/scripts/gcc-plugins/size_overflow_plugin/size_overflow_hash.data
11175 new file mode 100644
11176 -index 0000000..e6b58b6
11177 +index 0000000..56d8f55
11178 --- /dev/null
11179 +++ b/scripts/gcc-plugins/size_overflow_plugin/size_overflow_hash.data
11180 -@@ -0,0 +1,21990 @@
11181 +@@ -0,0 +1,21992 @@
11182 +enable_so_recv_ctrl_pipe_us_data_0 recv_ctrl_pipe us_data 0 0 NULL
11183 +enable_so___earlyonly_bootmem_alloc_fndecl_3 __earlyonly_bootmem_alloc fndecl 2-3-4 3 NULL
11184 +enable_so_v9fs_xattr_get_acl_fndecl_4 v9fs_xattr_get_acl fndecl 5 4 NULL
11185 @@ -185556,6 +185453,7 @@ index 0000000..e6b58b6
11186 +enable_so_idma64_alloc_desc_fndecl_1433 idma64_alloc_desc fndecl 1 1433 NULL
11187 +enable_so_relocation_count_drm_i915_gem_exec_object2_1435 relocation_count drm_i915_gem_exec_object2 0 1435 NULL
11188 +enable_so_rdev_num_s2mps11_info_1439 rdev_num s2mps11_info 0 1439 NULL
11189 ++enable_so_nr_cpusets_fndecl_1442 nr_cpusets fndecl 0 1442 NULL
11190 +enable_so_alloc_libipw_fndecl_1447 alloc_libipw fndecl 1 1447 NULL nohasharray
11191 +enable_so_loc_addr_rio_transfer_io_1447 loc_addr rio_transfer_io 0 1447 &enable_so_alloc_libipw_fndecl_1447
11192 +enable_so_size_ip_vs_sync_mesg_1448 size ip_vs_sync_mesg 0 1448 NULL
11193 @@ -192875,7 +192773,8 @@ index 0000000..e6b58b6
11194 +enable_so_ib_uverbs_reg_mr_fndecl_23214 ib_uverbs_reg_mr fndecl 4 23214 NULL
11195 +enable_so_btt_major_vardecl_btt_c_23220 btt_major vardecl_btt.c 0 23220 NULL
11196 +enable_so_read_swap_header_fndecl_23222 read_swap_header fndecl 0 23222 NULL
11197 -+enable_so_num_channels_sh_mtu2_device_23224 num_channels sh_mtu2_device 0 23224 NULL
11198 ++enable_so_num_channels_sh_mtu2_device_23224 num_channels sh_mtu2_device 0 23224 NULL nohasharray
11199 ++enable_so_size_of_ntlmssp_blob_fndecl_23224 size_of_ntlmssp_blob fndecl 0 23224 &enable_so_num_channels_sh_mtu2_device_23224
11200 +enable_so_clk_core_get_rate_fndecl_23225 clk_core_get_rate fndecl 0 23225 NULL nohasharray
11201 +enable_so_vid_hdr_offset_ubi_device_23225 vid_hdr_offset ubi_device 0 23225 &enable_so_clk_core_get_rate_fndecl_23225
11202 +enable_so_nvkm_client_map_fndecl_23228 nvkm_client_map fndecl 3-2 23228 NULL
11203 @@ -208837,7 +208736,7 @@ index 0000000..b5291e1
11204 +
11205 diff --git a/scripts/gcc-plugins/size_overflow_plugin/size_overflow_plugin.c b/scripts/gcc-plugins/size_overflow_plugin/size_overflow_plugin.c
11206 new file mode 100644
11207 -index 0000000..be40980
11208 +index 0000000..c471f8c
11209 --- /dev/null
11210 +++ b/scripts/gcc-plugins/size_overflow_plugin/size_overflow_plugin.c
11211 @@ -0,0 +1,290 @@
11212 @@ -208862,7 +208761,7 @@ index 0000000..be40980
11213 +
11214 +#include "size_overflow.h"
11215 +
11216 -+int plugin_is_GPL_compatible;
11217 ++__visible int plugin_is_GPL_compatible;
11218 +
11219 +tree report_size_overflow_decl;
11220 +
11221 @@ -209058,7 +208957,7 @@ index 0000000..be40980
11222 +
11223 +#include "gcc-generate-gimple-pass.h"
11224 +
11225 -+int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
11226 ++__visible int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
11227 +{
11228 + int i;
11229 + const char * const plugin_name = plugin_info->base_name;
11230 @@ -211271,7 +211170,7 @@ index 0000000..69e3a85
11231 +}
11232 diff --git a/scripts/gcc-plugins/stackleak_plugin.c b/scripts/gcc-plugins/stackleak_plugin.c
11233 new file mode 100644
11234 -index 0000000..8b69bd4
11235 +index 0000000..d8d3a9e
11236 --- /dev/null
11237 +++ b/scripts/gcc-plugins/stackleak_plugin.c
11238 @@ -0,0 +1,350 @@
11239 @@ -211297,7 +211196,7 @@ index 0000000..8b69bd4
11240 +
11241 +#include "gcc-common.h"
11242 +
11243 -+int plugin_is_GPL_compatible;
11244 ++__visible int plugin_is_GPL_compatible;
11245 +
11246 +static int track_frame_size = -1;
11247 +static const char track_function[] = "pax_track_stack";
11248 @@ -211552,7 +211451,7 @@ index 0000000..8b69bd4
11249 +#define TODO_FLAGS_FINISH TODO_dump_func
11250 +#include "gcc-generate-rtl-pass.h"
11251 +
11252 -+int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
11253 ++__visible int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
11254 +{
11255 + const char * const plugin_name = plugin_info->base_name;
11256 + const int argc = plugin_info->argc;
11257 @@ -211627,7 +211526,7 @@ index 0000000..8b69bd4
11258 +}
11259 diff --git a/scripts/gcc-plugins/structleak_plugin.c b/scripts/gcc-plugins/structleak_plugin.c
11260 new file mode 100644
11261 -index 0000000..d7596e6
11262 +index 0000000..583faac
11263 --- /dev/null
11264 +++ b/scripts/gcc-plugins/structleak_plugin.c
11265 @@ -0,0 +1,239 @@
11266 @@ -211662,10 +211561,10 @@ index 0000000..d7596e6
11267 +// unused C type flag in all versions 4.5-6
11268 +#define TYPE_USERSPACE(TYPE) TYPE_LANG_FLAG_5(TYPE)
11269 +
11270 -+int plugin_is_GPL_compatible;
11271 ++__visible int plugin_is_GPL_compatible;
11272 +
11273 +static struct plugin_info structleak_plugin_info = {
11274 -+ .version = "201602181345",
11275 ++ .version = "201607271510",
11276 + .help = "disable\tdo not activate plugin\n",
11277 +};
11278 +
11279 @@ -211829,7 +211728,7 @@ index 0000000..d7596e6
11280 +#define TODO_FLAGS_FINISH TODO_verify_il | TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa | TODO_ggc_collect | TODO_verify_flow
11281 +#include "gcc-generate-gimple-pass.h"
11282 +
11283 -+int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
11284 ++__visible int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
11285 +{
11286 + int i;
11287 + const char * const plugin_name = plugin_info->base_name;
11288 @@ -211839,9 +211738,9 @@ index 0000000..d7596e6
11289 + struct register_pass_info structleak_pass_info;
11290 +
11291 + structleak_pass_info.pass = make_structleak_pass();
11292 -+ structleak_pass_info.reference_pass_name = "ssa";
11293 ++ structleak_pass_info.reference_pass_name = "early_optimizations";
11294 + structleak_pass_info.ref_pass_instance_number = 1;
11295 -+ structleak_pass_info.pos_op = PASS_POS_INSERT_AFTER;
11296 ++ structleak_pass_info.pos_op = PASS_POS_INSERT_BEFORE;
11297 +
11298 + if (!plugin_default_version_check(version, &gcc_version)) {
11299 + error(G_("incompatible gcc/plugin versions"));
11300 @@ -211978,7 +211877,7 @@ index 49d61ad..69ee2cf 100755
11301 kallsymso=""
11302 kallsyms_vmlinux=""
11303 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
11304 -index a915507..27c1b41 100644
11305 +index fec7578..a9dc8fe 100644
11306 --- a/scripts/mod/file2alias.c
11307 +++ b/scripts/mod/file2alias.c
11308 @@ -156,7 +156,7 @@ static void device_id_check(const char *modname, const char *device_id,
11309 @@ -213434,7 +213333,7 @@ index c28b0f2..3b9fee0 100644
11310
11311 struct dentry *dents[AAFS_NS_SIZEOF];
11312 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
11313 -index dec607c..53d479f 100644
11314 +index 5ee8201..53d479f 100644
11315 --- a/security/apparmor/lsm.c
11316 +++ b/security/apparmor/lsm.c
11317 @@ -176,7 +176,7 @@ static int common_perm_dir_dentry(int op, struct path *dir,
11318 @@ -213466,82 +213365,7 @@ index dec607c..53d479f 100644
11319 struct path_cond cond = { d_backing_inode(old_dentry)->i_uid,
11320 d_backing_inode(old_dentry)->i_mode
11321 };
11322 -@@ -523,34 +523,34 @@ static int apparmor_setprocattr(struct task_struct *task, char *name,
11323 - {
11324 - struct common_audit_data sa;
11325 - struct apparmor_audit_data aad = {0,};
11326 -- char *command, *args = value;
11327 -+ char *command, *largs = NULL, *args = value;
11328 - size_t arg_size;
11329 - int error;
11330 -
11331 - if (size == 0)
11332 - return -EINVAL;
11333 -- /* args points to a PAGE_SIZE buffer, AppArmor requires that
11334 -- * the buffer must be null terminated or have size <= PAGE_SIZE -1
11335 -- * so that AppArmor can null terminate them
11336 -- */
11337 -- if (args[size - 1] != '\0') {
11338 -- if (size == PAGE_SIZE)
11339 -- return -EINVAL;
11340 -- args[size] = '\0';
11341 -- }
11342 --
11343 - /* task can only write its own attributes */
11344 - if (current != task)
11345 - return -EACCES;
11346 -
11347 -- args = value;
11348 -+ /* AppArmor requires that the buffer must be null terminated atm */
11349 -+ if (args[size - 1] != '\0') {
11350 -+ /* null terminate */
11351 -+ largs = args = kmalloc(size + 1, GFP_KERNEL);
11352 -+ if (!args)
11353 -+ return -ENOMEM;
11354 -+ memcpy(args, value, size);
11355 -+ args[size] = '\0';
11356 -+ }
11357 -+
11358 -+ error = -EINVAL;
11359 - args = strim(args);
11360 - command = strsep(&args, " ");
11361 - if (!args)
11362 -- return -EINVAL;
11363 -+ goto out;
11364 - args = skip_spaces(args);
11365 - if (!*args)
11366 -- return -EINVAL;
11367 -+ goto out;
11368 -
11369 - arg_size = size - (args - (char *) value);
11370 - if (strcmp(name, "current") == 0) {
11371 -@@ -576,10 +576,12 @@ static int apparmor_setprocattr(struct task_struct *task, char *name,
11372 - goto fail;
11373 - } else
11374 - /* only support the "current" and "exec" process attributes */
11375 -- return -EINVAL;
11376 -+ goto fail;
11377 -
11378 - if (!error)
11379 - error = size;
11380 -+out:
11381 -+ kfree(largs);
11382 - return error;
11383 -
11384 - fail:
11385 -@@ -588,9 +590,9 @@ fail:
11386 - aad.profile = aa_current_profile();
11387 - aad.op = OP_SETPROCATTR;
11388 - aad.info = name;
11389 -- aad.error = -EINVAL;
11390 -+ aad.error = error = -EINVAL;
11391 - aa_audit_msg(AUDIT_APPARMOR_DENIED, &sa, NULL);
11392 -- return -EINVAL;
11393 -+ goto out;
11394 - }
11395 -
11396 - static int apparmor_task_setrlimit(struct task_struct *task,
11397 -@@ -677,11 +679,11 @@ static const struct kernel_param_ops param_ops_aalockpolicy = {
11398 +@@ -679,11 +679,11 @@ static const struct kernel_param_ops param_ops_aalockpolicy = {
11399 .get = param_get_aalockpolicy
11400 };
11401
11402 @@ -213557,7 +213381,7 @@ index dec607c..53d479f 100644
11403
11404 /* Flag values, also controllable via /sys/module/apparmor/parameters
11405 * We define special types as we want to do additional mediation.
11406 -@@ -791,7 +793,7 @@ static int param_get_aauint(char *buffer, const struct kernel_param *kp)
11407 +@@ -793,7 +793,7 @@ static int param_get_aauint(char *buffer, const struct kernel_param *kp)
11408 return param_get_uint(buffer, kp);
11409 }
11410
11411 @@ -213566,7 +213390,7 @@ index dec607c..53d479f 100644
11412 {
11413 if (!capable(CAP_MAC_ADMIN))
11414 return -EPERM;
11415 -@@ -802,7 +804,7 @@ static int param_get_audit(char *buffer, struct kernel_param *kp)
11416 +@@ -804,7 +804,7 @@ static int param_get_audit(char *buffer, struct kernel_param *kp)
11417 return sprintf(buffer, "%s", audit_mode_names[aa_g_audit]);
11418 }
11419
11420 @@ -213575,7 +213399,7 @@ index dec607c..53d479f 100644
11421 {
11422 int i;
11423 if (!capable(CAP_MAC_ADMIN))
11424 -@@ -824,7 +826,7 @@ static int param_set_audit(const char *val, struct kernel_param *kp)
11425 +@@ -826,7 +826,7 @@ static int param_set_audit(const char *val, struct kernel_param *kp)
11426 return -EINVAL;
11427 }
11428
11429 @@ -213584,7 +213408,7 @@ index dec607c..53d479f 100644
11430 {
11431 if (!capable(CAP_MAC_ADMIN))
11432 return -EPERM;
11433 -@@ -835,7 +837,7 @@ static int param_get_mode(char *buffer, struct kernel_param *kp)
11434 +@@ -837,7 +837,7 @@ static int param_get_mode(char *buffer, struct kernel_param *kp)
11435 return sprintf(buffer, "%s", aa_profile_mode_names[aa_g_profile_mode]);
11436 }
11437
11438 @@ -213755,7 +213579,7 @@ index 5105c2c..a5010e6 100644
11439 extern struct key_type key_type_request_key_auth;
11440 extern struct key *request_key_auth_new(struct key *target,
11441 diff --git a/security/keys/key.c b/security/keys/key.c
11442 -index b287551..9c7e4ae6 100644
11443 +index af7f682..9c7e4ae6 100644
11444 --- a/security/keys/key.c
11445 +++ b/security/keys/key.c
11446 @@ -283,7 +283,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
11447 @@ -213767,15 +213591,6 @@ index b287551..9c7e4ae6 100644
11448 key->index_key.type = type;
11449 key->user = user;
11450 key->quotalen = quotalen;
11451 -@@ -584,7 +584,7 @@ int key_reject_and_link(struct key *key,
11452 -
11453 - mutex_unlock(&key_construction_mutex);
11454 -
11455 -- if (keyring)
11456 -+ if (keyring && link_ret == 0)
11457 - __key_link_end(keyring, &key->index_key, edit);
11458 -
11459 - /* wake up anyone waiting for a key to be constructed */
11460 @@ -1079,7 +1079,9 @@ int register_key_type(struct key_type *ktype)
11461 struct key_type *p;
11462 int ret;
11463 @@ -215474,7 +215289,7 @@ index 0a578fe..b81f62d 100644
11464 })
11465
11466 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
11467 -index 4fd482f..9e5f572 100644
11468 +index 7cb1224..a08f426 100644
11469 --- a/virt/kvm/kvm_main.c
11470 +++ b/virt/kvm/kvm_main.c
11471 @@ -90,12 +90,17 @@ LIST_HEAD(vm_list);
11472
11473 diff --git a/4.6.4/4425_grsec_remove_EI_PAX.patch b/4.6.5/4425_grsec_remove_EI_PAX.patch
11474 similarity index 100%
11475 rename from 4.6.4/4425_grsec_remove_EI_PAX.patch
11476 rename to 4.6.5/4425_grsec_remove_EI_PAX.patch
11477
11478 diff --git a/4.6.4/4427_force_XATTR_PAX_tmpfs.patch b/4.6.5/4427_force_XATTR_PAX_tmpfs.patch
11479 similarity index 100%
11480 rename from 4.6.4/4427_force_XATTR_PAX_tmpfs.patch
11481 rename to 4.6.5/4427_force_XATTR_PAX_tmpfs.patch
11482
11483 diff --git a/4.6.4/4430_grsec-remove-localversion-grsec.patch b/4.6.5/4430_grsec-remove-localversion-grsec.patch
11484 similarity index 100%
11485 rename from 4.6.4/4430_grsec-remove-localversion-grsec.patch
11486 rename to 4.6.5/4430_grsec-remove-localversion-grsec.patch
11487
11488 diff --git a/4.6.4/4435_grsec-mute-warnings.patch b/4.6.5/4435_grsec-mute-warnings.patch
11489 similarity index 100%
11490 rename from 4.6.4/4435_grsec-mute-warnings.patch
11491 rename to 4.6.5/4435_grsec-mute-warnings.patch
11492
11493 diff --git a/4.6.4/4440_grsec-remove-protected-paths.patch b/4.6.5/4440_grsec-remove-protected-paths.patch
11494 similarity index 100%
11495 rename from 4.6.4/4440_grsec-remove-protected-paths.patch
11496 rename to 4.6.5/4440_grsec-remove-protected-paths.patch
11497
11498 diff --git a/4.6.4/4450_grsec-kconfig-default-gids.patch b/4.6.5/4450_grsec-kconfig-default-gids.patch
11499 similarity index 100%
11500 rename from 4.6.4/4450_grsec-kconfig-default-gids.patch
11501 rename to 4.6.5/4450_grsec-kconfig-default-gids.patch
11502
11503 diff --git a/4.6.4/4465_selinux-avc_audit-log-curr_ip.patch b/4.6.5/4465_selinux-avc_audit-log-curr_ip.patch
11504 similarity index 100%
11505 rename from 4.6.4/4465_selinux-avc_audit-log-curr_ip.patch
11506 rename to 4.6.5/4465_selinux-avc_audit-log-curr_ip.patch
11507
11508 diff --git a/4.6.4/4470_disable-compat_vdso.patch b/4.6.5/4470_disable-compat_vdso.patch
11509 similarity index 100%
11510 rename from 4.6.4/4470_disable-compat_vdso.patch
11511 rename to 4.6.5/4470_disable-compat_vdso.patch
11512
11513 diff --git a/4.6.4/4475_emutramp_default_on.patch b/4.6.5/4475_emutramp_default_on.patch
11514 similarity index 100%
11515 rename from 4.6.4/4475_emutramp_default_on.patch
11516 rename to 4.6.5/4475_emutramp_default_on.patch