Magellan Linux

Contents of /trunk/kernel-alx/patches-4.14/0155-4.14.56-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3238 - (show annotations) (download)
Fri Nov 9 12:14:58 2018 UTC (5 years, 5 months ago) by niro
File size: 145989 byte(s)
-added up to patches-4.14.79
1 diff --git a/Documentation/kbuild/kbuild.txt b/Documentation/kbuild/kbuild.txt
2 index ac2363ea05c5..82afdb7f0816 100644
3 --- a/Documentation/kbuild/kbuild.txt
4 +++ b/Documentation/kbuild/kbuild.txt
5 @@ -152,15 +152,6 @@ stripped after they are installed. If INSTALL_MOD_STRIP is '1', then
6 the default option --strip-debug will be used. Otherwise,
7 INSTALL_MOD_STRIP value will be used as the options to the strip command.
8
9 -INSTALL_FW_PATH
10 ---------------------------------------------------
11 -INSTALL_FW_PATH specifies where to install the firmware blobs.
12 -The default value is:
13 -
14 - $(INSTALL_MOD_PATH)/lib/firmware
15 -
16 -The value can be overridden in which case the default value is ignored.
17 -
18 INSTALL_HDR_PATH
19 --------------------------------------------------
20 INSTALL_HDR_PATH specifies where to install user space headers when
21 diff --git a/Makefile b/Makefile
22 index 0700feaaa6cf..acbb0e3d29c9 100644
23 --- a/Makefile
24 +++ b/Makefile
25 @@ -1,7 +1,7 @@
26 # SPDX-License-Identifier: GPL-2.0
27 VERSION = 4
28 PATCHLEVEL = 14
29 -SUBLEVEL = 55
30 +SUBLEVEL = 56
31 EXTRAVERSION =
32 NAME = Petit Gorille
33
34 diff --git a/arch/arm64/include/asm/simd.h b/arch/arm64/include/asm/simd.h
35 index fa8b3fe932e6..6495cc51246f 100644
36 --- a/arch/arm64/include/asm/simd.h
37 +++ b/arch/arm64/include/asm/simd.h
38 @@ -29,20 +29,15 @@ DECLARE_PER_CPU(bool, kernel_neon_busy);
39 static __must_check inline bool may_use_simd(void)
40 {
41 /*
42 - * The raw_cpu_read() is racy if called with preemption enabled.
43 - * This is not a bug: kernel_neon_busy is only set when
44 - * preemption is disabled, so we cannot migrate to another CPU
45 - * while it is set, nor can we migrate to a CPU where it is set.
46 - * So, if we find it clear on some CPU then we're guaranteed to
47 - * find it clear on any CPU we could migrate to.
48 - *
49 - * If we are in between kernel_neon_begin()...kernel_neon_end(),
50 - * the flag will be set, but preemption is also disabled, so we
51 - * can't migrate to another CPU and spuriously see it become
52 - * false.
53 + * kernel_neon_busy is only set while preemption is disabled,
54 + * and is clear whenever preemption is enabled. Since
55 + * this_cpu_read() is atomic w.r.t. preemption, kernel_neon_busy
56 + * cannot change under our feet -- if it's set we cannot be
57 + * migrated, and if it's clear we cannot be migrated to a CPU
58 + * where it is set.
59 */
60 return !in_irq() && !irqs_disabled() && !in_nmi() &&
61 - !raw_cpu_read(kernel_neon_busy);
62 + !this_cpu_read(kernel_neon_busy);
63 }
64
65 #else /* ! CONFIG_KERNEL_MODE_NEON */
66 diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
67 index e1ddb94a6522..e8d772a2597d 100644
68 --- a/arch/mips/kernel/process.c
69 +++ b/arch/mips/kernel/process.c
70 @@ -29,6 +29,7 @@
71 #include <linux/kallsyms.h>
72 #include <linux/random.h>
73 #include <linux/prctl.h>
74 +#include <linux/nmi.h>
75
76 #include <asm/asm.h>
77 #include <asm/bootinfo.h>
78 @@ -655,28 +656,42 @@ unsigned long arch_align_stack(unsigned long sp)
79 return sp & ALMASK;
80 }
81
82 -static void arch_dump_stack(void *info)
83 +static DEFINE_PER_CPU(call_single_data_t, backtrace_csd);
84 +static struct cpumask backtrace_csd_busy;
85 +
86 +static void handle_backtrace(void *info)
87 {
88 - struct pt_regs *regs;
89 + nmi_cpu_backtrace(get_irq_regs());
90 + cpumask_clear_cpu(smp_processor_id(), &backtrace_csd_busy);
91 +}
92
93 - regs = get_irq_regs();
94 +static void raise_backtrace(cpumask_t *mask)
95 +{
96 + call_single_data_t *csd;
97 + int cpu;
98
99 - if (regs)
100 - show_regs(regs);
101 + for_each_cpu(cpu, mask) {
102 + /*
103 + * If we previously sent an IPI to the target CPU & it hasn't
104 + * cleared its bit in the busy cpumask then it didn't handle
105 + * our previous IPI & it's not safe for us to reuse the
106 + * call_single_data_t.
107 + */
108 + if (cpumask_test_and_set_cpu(cpu, &backtrace_csd_busy)) {
109 + pr_warn("Unable to send backtrace IPI to CPU%u - perhaps it hung?\n",
110 + cpu);
111 + continue;
112 + }
113
114 - dump_stack();
115 + csd = &per_cpu(backtrace_csd, cpu);
116 + csd->func = handle_backtrace;
117 + smp_call_function_single_async(cpu, csd);
118 + }
119 }
120
121 void arch_trigger_cpumask_backtrace(const cpumask_t *mask, bool exclude_self)
122 {
123 - long this_cpu = get_cpu();
124 -
125 - if (cpumask_test_cpu(this_cpu, mask) && !exclude_self)
126 - dump_stack();
127 -
128 - smp_call_function_many(mask, arch_dump_stack, NULL, 1);
129 -
130 - put_cpu();
131 + nmi_trigger_cpumask_backtrace(mask, exclude_self, raise_backtrace);
132 }
133
134 int mips_get_process_fp_mode(struct task_struct *task)
135 diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
136 index 5669d3b8bd38..583aed906933 100644
137 --- a/arch/mips/kernel/traps.c
138 +++ b/arch/mips/kernel/traps.c
139 @@ -351,6 +351,7 @@ static void __show_regs(const struct pt_regs *regs)
140 void show_regs(struct pt_regs *regs)
141 {
142 __show_regs((struct pt_regs *)regs);
143 + dump_stack();
144 }
145
146 void show_registers(struct pt_regs *regs)
147 diff --git a/arch/mips/mm/ioremap.c b/arch/mips/mm/ioremap.c
148 index 1986e09fb457..1601d90b087b 100644
149 --- a/arch/mips/mm/ioremap.c
150 +++ b/arch/mips/mm/ioremap.c
151 @@ -9,6 +9,7 @@
152 #include <linux/export.h>
153 #include <asm/addrspace.h>
154 #include <asm/byteorder.h>
155 +#include <linux/ioport.h>
156 #include <linux/sched.h>
157 #include <linux/slab.h>
158 #include <linux/vmalloc.h>
159 @@ -98,6 +99,20 @@ static int remap_area_pages(unsigned long address, phys_addr_t phys_addr,
160 return error;
161 }
162
163 +static int __ioremap_check_ram(unsigned long start_pfn, unsigned long nr_pages,
164 + void *arg)
165 +{
166 + unsigned long i;
167 +
168 + for (i = 0; i < nr_pages; i++) {
169 + if (pfn_valid(start_pfn + i) &&
170 + !PageReserved(pfn_to_page(start_pfn + i)))
171 + return 1;
172 + }
173 +
174 + return 0;
175 +}
176 +
177 /*
178 * Generic mapping function (not visible outside):
179 */
180 @@ -116,8 +131,8 @@ static int remap_area_pages(unsigned long address, phys_addr_t phys_addr,
181
182 void __iomem * __ioremap(phys_addr_t phys_addr, phys_addr_t size, unsigned long flags)
183 {
184 + unsigned long offset, pfn, last_pfn;
185 struct vm_struct * area;
186 - unsigned long offset;
187 phys_addr_t last_addr;
188 void * addr;
189
190 @@ -137,18 +152,16 @@ void __iomem * __ioremap(phys_addr_t phys_addr, phys_addr_t size, unsigned long
191 return (void __iomem *) CKSEG1ADDR(phys_addr);
192
193 /*
194 - * Don't allow anybody to remap normal RAM that we're using..
195 + * Don't allow anybody to remap RAM that may be allocated by the page
196 + * allocator, since that could lead to races & data clobbering.
197 */
198 - if (phys_addr < virt_to_phys(high_memory)) {
199 - char *t_addr, *t_end;
200 - struct page *page;
201 -
202 - t_addr = __va(phys_addr);
203 - t_end = t_addr + (size - 1);
204 -
205 - for(page = virt_to_page(t_addr); page <= virt_to_page(t_end); page++)
206 - if(!PageReserved(page))
207 - return NULL;
208 + pfn = PFN_DOWN(phys_addr);
209 + last_pfn = PFN_DOWN(last_addr);
210 + if (walk_system_ram_range(pfn, last_pfn - pfn + 1, NULL,
211 + __ioremap_check_ram) == 1) {
212 + WARN_ONCE(1, "ioremap on RAM at %pa - %pa\n",
213 + &phys_addr, &last_addr);
214 + return NULL;
215 }
216
217 /*
218 diff --git a/arch/x86/crypto/Makefile b/arch/x86/crypto/Makefile
219 index 5f07333bb224..9c903a420cda 100644
220 --- a/arch/x86/crypto/Makefile
221 +++ b/arch/x86/crypto/Makefile
222 @@ -15,7 +15,6 @@ obj-$(CONFIG_CRYPTO_GLUE_HELPER_X86) += glue_helper.o
223
224 obj-$(CONFIG_CRYPTO_AES_586) += aes-i586.o
225 obj-$(CONFIG_CRYPTO_TWOFISH_586) += twofish-i586.o
226 -obj-$(CONFIG_CRYPTO_SALSA20_586) += salsa20-i586.o
227 obj-$(CONFIG_CRYPTO_SERPENT_SSE2_586) += serpent-sse2-i586.o
228
229 obj-$(CONFIG_CRYPTO_AES_X86_64) += aes-x86_64.o
230 @@ -24,7 +23,6 @@ obj-$(CONFIG_CRYPTO_CAMELLIA_X86_64) += camellia-x86_64.o
231 obj-$(CONFIG_CRYPTO_BLOWFISH_X86_64) += blowfish-x86_64.o
232 obj-$(CONFIG_CRYPTO_TWOFISH_X86_64) += twofish-x86_64.o
233 obj-$(CONFIG_CRYPTO_TWOFISH_X86_64_3WAY) += twofish-x86_64-3way.o
234 -obj-$(CONFIG_CRYPTO_SALSA20_X86_64) += salsa20-x86_64.o
235 obj-$(CONFIG_CRYPTO_CHACHA20_X86_64) += chacha20-x86_64.o
236 obj-$(CONFIG_CRYPTO_SERPENT_SSE2_X86_64) += serpent-sse2-x86_64.o
237 obj-$(CONFIG_CRYPTO_AES_NI_INTEL) += aesni-intel.o
238 @@ -59,7 +57,6 @@ endif
239
240 aes-i586-y := aes-i586-asm_32.o aes_glue.o
241 twofish-i586-y := twofish-i586-asm_32.o twofish_glue.o
242 -salsa20-i586-y := salsa20-i586-asm_32.o salsa20_glue.o
243 serpent-sse2-i586-y := serpent-sse2-i586-asm_32.o serpent_sse2_glue.o
244
245 aes-x86_64-y := aes-x86_64-asm_64.o aes_glue.o
246 @@ -68,7 +65,6 @@ camellia-x86_64-y := camellia-x86_64-asm_64.o camellia_glue.o
247 blowfish-x86_64-y := blowfish-x86_64-asm_64.o blowfish_glue.o
248 twofish-x86_64-y := twofish-x86_64-asm_64.o twofish_glue.o
249 twofish-x86_64-3way-y := twofish-x86_64-asm_64-3way.o twofish_glue_3way.o
250 -salsa20-x86_64-y := salsa20-x86_64-asm_64.o salsa20_glue.o
251 chacha20-x86_64-y := chacha20-ssse3-x86_64.o chacha20_glue.o
252 serpent-sse2-x86_64-y := serpent-sse2-x86_64-asm_64.o serpent_sse2_glue.o
253
254 diff --git a/arch/x86/crypto/salsa20-i586-asm_32.S b/arch/x86/crypto/salsa20-i586-asm_32.S
255 deleted file mode 100644
256 index 329452b8f794..000000000000
257 --- a/arch/x86/crypto/salsa20-i586-asm_32.S
258 +++ /dev/null
259 @@ -1,1114 +0,0 @@
260 -# salsa20_pm.s version 20051229
261 -# D. J. Bernstein
262 -# Public domain.
263 -
264 -#include <linux/linkage.h>
265 -
266 -.text
267 -
268 -# enter salsa20_encrypt_bytes
269 -ENTRY(salsa20_encrypt_bytes)
270 - mov %esp,%eax
271 - and $31,%eax
272 - add $256,%eax
273 - sub %eax,%esp
274 - # eax_stack = eax
275 - movl %eax,80(%esp)
276 - # ebx_stack = ebx
277 - movl %ebx,84(%esp)
278 - # esi_stack = esi
279 - movl %esi,88(%esp)
280 - # edi_stack = edi
281 - movl %edi,92(%esp)
282 - # ebp_stack = ebp
283 - movl %ebp,96(%esp)
284 - # x = arg1
285 - movl 4(%esp,%eax),%edx
286 - # m = arg2
287 - movl 8(%esp,%eax),%esi
288 - # out = arg3
289 - movl 12(%esp,%eax),%edi
290 - # bytes = arg4
291 - movl 16(%esp,%eax),%ebx
292 - # bytes -= 0
293 - sub $0,%ebx
294 - # goto done if unsigned<=
295 - jbe ._done
296 -._start:
297 - # in0 = *(uint32 *) (x + 0)
298 - movl 0(%edx),%eax
299 - # in1 = *(uint32 *) (x + 4)
300 - movl 4(%edx),%ecx
301 - # in2 = *(uint32 *) (x + 8)
302 - movl 8(%edx),%ebp
303 - # j0 = in0
304 - movl %eax,164(%esp)
305 - # in3 = *(uint32 *) (x + 12)
306 - movl 12(%edx),%eax
307 - # j1 = in1
308 - movl %ecx,168(%esp)
309 - # in4 = *(uint32 *) (x + 16)
310 - movl 16(%edx),%ecx
311 - # j2 = in2
312 - movl %ebp,172(%esp)
313 - # in5 = *(uint32 *) (x + 20)
314 - movl 20(%edx),%ebp
315 - # j3 = in3
316 - movl %eax,176(%esp)
317 - # in6 = *(uint32 *) (x + 24)
318 - movl 24(%edx),%eax
319 - # j4 = in4
320 - movl %ecx,180(%esp)
321 - # in7 = *(uint32 *) (x + 28)
322 - movl 28(%edx),%ecx
323 - # j5 = in5
324 - movl %ebp,184(%esp)
325 - # in8 = *(uint32 *) (x + 32)
326 - movl 32(%edx),%ebp
327 - # j6 = in6
328 - movl %eax,188(%esp)
329 - # in9 = *(uint32 *) (x + 36)
330 - movl 36(%edx),%eax
331 - # j7 = in7
332 - movl %ecx,192(%esp)
333 - # in10 = *(uint32 *) (x + 40)
334 - movl 40(%edx),%ecx
335 - # j8 = in8
336 - movl %ebp,196(%esp)
337 - # in11 = *(uint32 *) (x + 44)
338 - movl 44(%edx),%ebp
339 - # j9 = in9
340 - movl %eax,200(%esp)
341 - # in12 = *(uint32 *) (x + 48)
342 - movl 48(%edx),%eax
343 - # j10 = in10
344 - movl %ecx,204(%esp)
345 - # in13 = *(uint32 *) (x + 52)
346 - movl 52(%edx),%ecx
347 - # j11 = in11
348 - movl %ebp,208(%esp)
349 - # in14 = *(uint32 *) (x + 56)
350 - movl 56(%edx),%ebp
351 - # j12 = in12
352 - movl %eax,212(%esp)
353 - # in15 = *(uint32 *) (x + 60)
354 - movl 60(%edx),%eax
355 - # j13 = in13
356 - movl %ecx,216(%esp)
357 - # j14 = in14
358 - movl %ebp,220(%esp)
359 - # j15 = in15
360 - movl %eax,224(%esp)
361 - # x_backup = x
362 - movl %edx,64(%esp)
363 -._bytesatleast1:
364 - # bytes - 64
365 - cmp $64,%ebx
366 - # goto nocopy if unsigned>=
367 - jae ._nocopy
368 - # ctarget = out
369 - movl %edi,228(%esp)
370 - # out = &tmp
371 - leal 0(%esp),%edi
372 - # i = bytes
373 - mov %ebx,%ecx
374 - # while (i) { *out++ = *m++; --i }
375 - rep movsb
376 - # out = &tmp
377 - leal 0(%esp),%edi
378 - # m = &tmp
379 - leal 0(%esp),%esi
380 -._nocopy:
381 - # out_backup = out
382 - movl %edi,72(%esp)
383 - # m_backup = m
384 - movl %esi,68(%esp)
385 - # bytes_backup = bytes
386 - movl %ebx,76(%esp)
387 - # in0 = j0
388 - movl 164(%esp),%eax
389 - # in1 = j1
390 - movl 168(%esp),%ecx
391 - # in2 = j2
392 - movl 172(%esp),%edx
393 - # in3 = j3
394 - movl 176(%esp),%ebx
395 - # x0 = in0
396 - movl %eax,100(%esp)
397 - # x1 = in1
398 - movl %ecx,104(%esp)
399 - # x2 = in2
400 - movl %edx,108(%esp)
401 - # x3 = in3
402 - movl %ebx,112(%esp)
403 - # in4 = j4
404 - movl 180(%esp),%eax
405 - # in5 = j5
406 - movl 184(%esp),%ecx
407 - # in6 = j6
408 - movl 188(%esp),%edx
409 - # in7 = j7
410 - movl 192(%esp),%ebx
411 - # x4 = in4
412 - movl %eax,116(%esp)
413 - # x5 = in5
414 - movl %ecx,120(%esp)
415 - # x6 = in6
416 - movl %edx,124(%esp)
417 - # x7 = in7
418 - movl %ebx,128(%esp)
419 - # in8 = j8
420 - movl 196(%esp),%eax
421 - # in9 = j9
422 - movl 200(%esp),%ecx
423 - # in10 = j10
424 - movl 204(%esp),%edx
425 - # in11 = j11
426 - movl 208(%esp),%ebx
427 - # x8 = in8
428 - movl %eax,132(%esp)
429 - # x9 = in9
430 - movl %ecx,136(%esp)
431 - # x10 = in10
432 - movl %edx,140(%esp)
433 - # x11 = in11
434 - movl %ebx,144(%esp)
435 - # in12 = j12
436 - movl 212(%esp),%eax
437 - # in13 = j13
438 - movl 216(%esp),%ecx
439 - # in14 = j14
440 - movl 220(%esp),%edx
441 - # in15 = j15
442 - movl 224(%esp),%ebx
443 - # x12 = in12
444 - movl %eax,148(%esp)
445 - # x13 = in13
446 - movl %ecx,152(%esp)
447 - # x14 = in14
448 - movl %edx,156(%esp)
449 - # x15 = in15
450 - movl %ebx,160(%esp)
451 - # i = 20
452 - mov $20,%ebp
453 - # p = x0
454 - movl 100(%esp),%eax
455 - # s = x5
456 - movl 120(%esp),%ecx
457 - # t = x10
458 - movl 140(%esp),%edx
459 - # w = x15
460 - movl 160(%esp),%ebx
461 -._mainloop:
462 - # x0 = p
463 - movl %eax,100(%esp)
464 - # x10 = t
465 - movl %edx,140(%esp)
466 - # p += x12
467 - addl 148(%esp),%eax
468 - # x5 = s
469 - movl %ecx,120(%esp)
470 - # t += x6
471 - addl 124(%esp),%edx
472 - # x15 = w
473 - movl %ebx,160(%esp)
474 - # r = x1
475 - movl 104(%esp),%esi
476 - # r += s
477 - add %ecx,%esi
478 - # v = x11
479 - movl 144(%esp),%edi
480 - # v += w
481 - add %ebx,%edi
482 - # p <<<= 7
483 - rol $7,%eax
484 - # p ^= x4
485 - xorl 116(%esp),%eax
486 - # t <<<= 7
487 - rol $7,%edx
488 - # t ^= x14
489 - xorl 156(%esp),%edx
490 - # r <<<= 7
491 - rol $7,%esi
492 - # r ^= x9
493 - xorl 136(%esp),%esi
494 - # v <<<= 7
495 - rol $7,%edi
496 - # v ^= x3
497 - xorl 112(%esp),%edi
498 - # x4 = p
499 - movl %eax,116(%esp)
500 - # x14 = t
501 - movl %edx,156(%esp)
502 - # p += x0
503 - addl 100(%esp),%eax
504 - # x9 = r
505 - movl %esi,136(%esp)
506 - # t += x10
507 - addl 140(%esp),%edx
508 - # x3 = v
509 - movl %edi,112(%esp)
510 - # p <<<= 9
511 - rol $9,%eax
512 - # p ^= x8
513 - xorl 132(%esp),%eax
514 - # t <<<= 9
515 - rol $9,%edx
516 - # t ^= x2
517 - xorl 108(%esp),%edx
518 - # s += r
519 - add %esi,%ecx
520 - # s <<<= 9
521 - rol $9,%ecx
522 - # s ^= x13
523 - xorl 152(%esp),%ecx
524 - # w += v
525 - add %edi,%ebx
526 - # w <<<= 9
527 - rol $9,%ebx
528 - # w ^= x7
529 - xorl 128(%esp),%ebx
530 - # x8 = p
531 - movl %eax,132(%esp)
532 - # x2 = t
533 - movl %edx,108(%esp)
534 - # p += x4
535 - addl 116(%esp),%eax
536 - # x13 = s
537 - movl %ecx,152(%esp)
538 - # t += x14
539 - addl 156(%esp),%edx
540 - # x7 = w
541 - movl %ebx,128(%esp)
542 - # p <<<= 13
543 - rol $13,%eax
544 - # p ^= x12
545 - xorl 148(%esp),%eax
546 - # t <<<= 13
547 - rol $13,%edx
548 - # t ^= x6
549 - xorl 124(%esp),%edx
550 - # r += s
551 - add %ecx,%esi
552 - # r <<<= 13
553 - rol $13,%esi
554 - # r ^= x1
555 - xorl 104(%esp),%esi
556 - # v += w
557 - add %ebx,%edi
558 - # v <<<= 13
559 - rol $13,%edi
560 - # v ^= x11
561 - xorl 144(%esp),%edi
562 - # x12 = p
563 - movl %eax,148(%esp)
564 - # x6 = t
565 - movl %edx,124(%esp)
566 - # p += x8
567 - addl 132(%esp),%eax
568 - # x1 = r
569 - movl %esi,104(%esp)
570 - # t += x2
571 - addl 108(%esp),%edx
572 - # x11 = v
573 - movl %edi,144(%esp)
574 - # p <<<= 18
575 - rol $18,%eax
576 - # p ^= x0
577 - xorl 100(%esp),%eax
578 - # t <<<= 18
579 - rol $18,%edx
580 - # t ^= x10
581 - xorl 140(%esp),%edx
582 - # s += r
583 - add %esi,%ecx
584 - # s <<<= 18
585 - rol $18,%ecx
586 - # s ^= x5
587 - xorl 120(%esp),%ecx
588 - # w += v
589 - add %edi,%ebx
590 - # w <<<= 18
591 - rol $18,%ebx
592 - # w ^= x15
593 - xorl 160(%esp),%ebx
594 - # x0 = p
595 - movl %eax,100(%esp)
596 - # x10 = t
597 - movl %edx,140(%esp)
598 - # p += x3
599 - addl 112(%esp),%eax
600 - # p <<<= 7
601 - rol $7,%eax
602 - # x5 = s
603 - movl %ecx,120(%esp)
604 - # t += x9
605 - addl 136(%esp),%edx
606 - # x15 = w
607 - movl %ebx,160(%esp)
608 - # r = x4
609 - movl 116(%esp),%esi
610 - # r += s
611 - add %ecx,%esi
612 - # v = x14
613 - movl 156(%esp),%edi
614 - # v += w
615 - add %ebx,%edi
616 - # p ^= x1
617 - xorl 104(%esp),%eax
618 - # t <<<= 7
619 - rol $7,%edx
620 - # t ^= x11
621 - xorl 144(%esp),%edx
622 - # r <<<= 7
623 - rol $7,%esi
624 - # r ^= x6
625 - xorl 124(%esp),%esi
626 - # v <<<= 7
627 - rol $7,%edi
628 - # v ^= x12
629 - xorl 148(%esp),%edi
630 - # x1 = p
631 - movl %eax,104(%esp)
632 - # x11 = t
633 - movl %edx,144(%esp)
634 - # p += x0
635 - addl 100(%esp),%eax
636 - # x6 = r
637 - movl %esi,124(%esp)
638 - # t += x10
639 - addl 140(%esp),%edx
640 - # x12 = v
641 - movl %edi,148(%esp)
642 - # p <<<= 9
643 - rol $9,%eax
644 - # p ^= x2
645 - xorl 108(%esp),%eax
646 - # t <<<= 9
647 - rol $9,%edx
648 - # t ^= x8
649 - xorl 132(%esp),%edx
650 - # s += r
651 - add %esi,%ecx
652 - # s <<<= 9
653 - rol $9,%ecx
654 - # s ^= x7
655 - xorl 128(%esp),%ecx
656 - # w += v
657 - add %edi,%ebx
658 - # w <<<= 9
659 - rol $9,%ebx
660 - # w ^= x13
661 - xorl 152(%esp),%ebx
662 - # x2 = p
663 - movl %eax,108(%esp)
664 - # x8 = t
665 - movl %edx,132(%esp)
666 - # p += x1
667 - addl 104(%esp),%eax
668 - # x7 = s
669 - movl %ecx,128(%esp)
670 - # t += x11
671 - addl 144(%esp),%edx
672 - # x13 = w
673 - movl %ebx,152(%esp)
674 - # p <<<= 13
675 - rol $13,%eax
676 - # p ^= x3
677 - xorl 112(%esp),%eax
678 - # t <<<= 13
679 - rol $13,%edx
680 - # t ^= x9
681 - xorl 136(%esp),%edx
682 - # r += s
683 - add %ecx,%esi
684 - # r <<<= 13
685 - rol $13,%esi
686 - # r ^= x4
687 - xorl 116(%esp),%esi
688 - # v += w
689 - add %ebx,%edi
690 - # v <<<= 13
691 - rol $13,%edi
692 - # v ^= x14
693 - xorl 156(%esp),%edi
694 - # x3 = p
695 - movl %eax,112(%esp)
696 - # x9 = t
697 - movl %edx,136(%esp)
698 - # p += x2
699 - addl 108(%esp),%eax
700 - # x4 = r
701 - movl %esi,116(%esp)
702 - # t += x8
703 - addl 132(%esp),%edx
704 - # x14 = v
705 - movl %edi,156(%esp)
706 - # p <<<= 18
707 - rol $18,%eax
708 - # p ^= x0
709 - xorl 100(%esp),%eax
710 - # t <<<= 18
711 - rol $18,%edx
712 - # t ^= x10
713 - xorl 140(%esp),%edx
714 - # s += r
715 - add %esi,%ecx
716 - # s <<<= 18
717 - rol $18,%ecx
718 - # s ^= x5
719 - xorl 120(%esp),%ecx
720 - # w += v
721 - add %edi,%ebx
722 - # w <<<= 18
723 - rol $18,%ebx
724 - # w ^= x15
725 - xorl 160(%esp),%ebx
726 - # x0 = p
727 - movl %eax,100(%esp)
728 - # x10 = t
729 - movl %edx,140(%esp)
730 - # p += x12
731 - addl 148(%esp),%eax
732 - # x5 = s
733 - movl %ecx,120(%esp)
734 - # t += x6
735 - addl 124(%esp),%edx
736 - # x15 = w
737 - movl %ebx,160(%esp)
738 - # r = x1
739 - movl 104(%esp),%esi
740 - # r += s
741 - add %ecx,%esi
742 - # v = x11
743 - movl 144(%esp),%edi
744 - # v += w
745 - add %ebx,%edi
746 - # p <<<= 7
747 - rol $7,%eax
748 - # p ^= x4
749 - xorl 116(%esp),%eax
750 - # t <<<= 7
751 - rol $7,%edx
752 - # t ^= x14
753 - xorl 156(%esp),%edx
754 - # r <<<= 7
755 - rol $7,%esi
756 - # r ^= x9
757 - xorl 136(%esp),%esi
758 - # v <<<= 7
759 - rol $7,%edi
760 - # v ^= x3
761 - xorl 112(%esp),%edi
762 - # x4 = p
763 - movl %eax,116(%esp)
764 - # x14 = t
765 - movl %edx,156(%esp)
766 - # p += x0
767 - addl 100(%esp),%eax
768 - # x9 = r
769 - movl %esi,136(%esp)
770 - # t += x10
771 - addl 140(%esp),%edx
772 - # x3 = v
773 - movl %edi,112(%esp)
774 - # p <<<= 9
775 - rol $9,%eax
776 - # p ^= x8
777 - xorl 132(%esp),%eax
778 - # t <<<= 9
779 - rol $9,%edx
780 - # t ^= x2
781 - xorl 108(%esp),%edx
782 - # s += r
783 - add %esi,%ecx
784 - # s <<<= 9
785 - rol $9,%ecx
786 - # s ^= x13
787 - xorl 152(%esp),%ecx
788 - # w += v
789 - add %edi,%ebx
790 - # w <<<= 9
791 - rol $9,%ebx
792 - # w ^= x7
793 - xorl 128(%esp),%ebx
794 - # x8 = p
795 - movl %eax,132(%esp)
796 - # x2 = t
797 - movl %edx,108(%esp)
798 - # p += x4
799 - addl 116(%esp),%eax
800 - # x13 = s
801 - movl %ecx,152(%esp)
802 - # t += x14
803 - addl 156(%esp),%edx
804 - # x7 = w
805 - movl %ebx,128(%esp)
806 - # p <<<= 13
807 - rol $13,%eax
808 - # p ^= x12
809 - xorl 148(%esp),%eax
810 - # t <<<= 13
811 - rol $13,%edx
812 - # t ^= x6
813 - xorl 124(%esp),%edx
814 - # r += s
815 - add %ecx,%esi
816 - # r <<<= 13
817 - rol $13,%esi
818 - # r ^= x1
819 - xorl 104(%esp),%esi
820 - # v += w
821 - add %ebx,%edi
822 - # v <<<= 13
823 - rol $13,%edi
824 - # v ^= x11
825 - xorl 144(%esp),%edi
826 - # x12 = p
827 - movl %eax,148(%esp)
828 - # x6 = t
829 - movl %edx,124(%esp)
830 - # p += x8
831 - addl 132(%esp),%eax
832 - # x1 = r
833 - movl %esi,104(%esp)
834 - # t += x2
835 - addl 108(%esp),%edx
836 - # x11 = v
837 - movl %edi,144(%esp)
838 - # p <<<= 18
839 - rol $18,%eax
840 - # p ^= x0
841 - xorl 100(%esp),%eax
842 - # t <<<= 18
843 - rol $18,%edx
844 - # t ^= x10
845 - xorl 140(%esp),%edx
846 - # s += r
847 - add %esi,%ecx
848 - # s <<<= 18
849 - rol $18,%ecx
850 - # s ^= x5
851 - xorl 120(%esp),%ecx
852 - # w += v
853 - add %edi,%ebx
854 - # w <<<= 18
855 - rol $18,%ebx
856 - # w ^= x15
857 - xorl 160(%esp),%ebx
858 - # x0 = p
859 - movl %eax,100(%esp)
860 - # x10 = t
861 - movl %edx,140(%esp)
862 - # p += x3
863 - addl 112(%esp),%eax
864 - # p <<<= 7
865 - rol $7,%eax
866 - # x5 = s
867 - movl %ecx,120(%esp)
868 - # t += x9
869 - addl 136(%esp),%edx
870 - # x15 = w
871 - movl %ebx,160(%esp)
872 - # r = x4
873 - movl 116(%esp),%esi
874 - # r += s
875 - add %ecx,%esi
876 - # v = x14
877 - movl 156(%esp),%edi
878 - # v += w
879 - add %ebx,%edi
880 - # p ^= x1
881 - xorl 104(%esp),%eax
882 - # t <<<= 7
883 - rol $7,%edx
884 - # t ^= x11
885 - xorl 144(%esp),%edx
886 - # r <<<= 7
887 - rol $7,%esi
888 - # r ^= x6
889 - xorl 124(%esp),%esi
890 - # v <<<= 7
891 - rol $7,%edi
892 - # v ^= x12
893 - xorl 148(%esp),%edi
894 - # x1 = p
895 - movl %eax,104(%esp)
896 - # x11 = t
897 - movl %edx,144(%esp)
898 - # p += x0
899 - addl 100(%esp),%eax
900 - # x6 = r
901 - movl %esi,124(%esp)
902 - # t += x10
903 - addl 140(%esp),%edx
904 - # x12 = v
905 - movl %edi,148(%esp)
906 - # p <<<= 9
907 - rol $9,%eax
908 - # p ^= x2
909 - xorl 108(%esp),%eax
910 - # t <<<= 9
911 - rol $9,%edx
912 - # t ^= x8
913 - xorl 132(%esp),%edx
914 - # s += r
915 - add %esi,%ecx
916 - # s <<<= 9
917 - rol $9,%ecx
918 - # s ^= x7
919 - xorl 128(%esp),%ecx
920 - # w += v
921 - add %edi,%ebx
922 - # w <<<= 9
923 - rol $9,%ebx
924 - # w ^= x13
925 - xorl 152(%esp),%ebx
926 - # x2 = p
927 - movl %eax,108(%esp)
928 - # x8 = t
929 - movl %edx,132(%esp)
930 - # p += x1
931 - addl 104(%esp),%eax
932 - # x7 = s
933 - movl %ecx,128(%esp)
934 - # t += x11
935 - addl 144(%esp),%edx
936 - # x13 = w
937 - movl %ebx,152(%esp)
938 - # p <<<= 13
939 - rol $13,%eax
940 - # p ^= x3
941 - xorl 112(%esp),%eax
942 - # t <<<= 13
943 - rol $13,%edx
944 - # t ^= x9
945 - xorl 136(%esp),%edx
946 - # r += s
947 - add %ecx,%esi
948 - # r <<<= 13
949 - rol $13,%esi
950 - # r ^= x4
951 - xorl 116(%esp),%esi
952 - # v += w
953 - add %ebx,%edi
954 - # v <<<= 13
955 - rol $13,%edi
956 - # v ^= x14
957 - xorl 156(%esp),%edi
958 - # x3 = p
959 - movl %eax,112(%esp)
960 - # x9 = t
961 - movl %edx,136(%esp)
962 - # p += x2
963 - addl 108(%esp),%eax
964 - # x4 = r
965 - movl %esi,116(%esp)
966 - # t += x8
967 - addl 132(%esp),%edx
968 - # x14 = v
969 - movl %edi,156(%esp)
970 - # p <<<= 18
971 - rol $18,%eax
972 - # p ^= x0
973 - xorl 100(%esp),%eax
974 - # t <<<= 18
975 - rol $18,%edx
976 - # t ^= x10
977 - xorl 140(%esp),%edx
978 - # s += r
979 - add %esi,%ecx
980 - # s <<<= 18
981 - rol $18,%ecx
982 - # s ^= x5
983 - xorl 120(%esp),%ecx
984 - # w += v
985 - add %edi,%ebx
986 - # w <<<= 18
987 - rol $18,%ebx
988 - # w ^= x15
989 - xorl 160(%esp),%ebx
990 - # i -= 4
991 - sub $4,%ebp
992 - # goto mainloop if unsigned >
993 - ja ._mainloop
994 - # x0 = p
995 - movl %eax,100(%esp)
996 - # x5 = s
997 - movl %ecx,120(%esp)
998 - # x10 = t
999 - movl %edx,140(%esp)
1000 - # x15 = w
1001 - movl %ebx,160(%esp)
1002 - # out = out_backup
1003 - movl 72(%esp),%edi
1004 - # m = m_backup
1005 - movl 68(%esp),%esi
1006 - # in0 = x0
1007 - movl 100(%esp),%eax
1008 - # in1 = x1
1009 - movl 104(%esp),%ecx
1010 - # in0 += j0
1011 - addl 164(%esp),%eax
1012 - # in1 += j1
1013 - addl 168(%esp),%ecx
1014 - # in0 ^= *(uint32 *) (m + 0)
1015 - xorl 0(%esi),%eax
1016 - # in1 ^= *(uint32 *) (m + 4)
1017 - xorl 4(%esi),%ecx
1018 - # *(uint32 *) (out + 0) = in0
1019 - movl %eax,0(%edi)
1020 - # *(uint32 *) (out + 4) = in1
1021 - movl %ecx,4(%edi)
1022 - # in2 = x2
1023 - movl 108(%esp),%eax
1024 - # in3 = x3
1025 - movl 112(%esp),%ecx
1026 - # in2 += j2
1027 - addl 172(%esp),%eax
1028 - # in3 += j3
1029 - addl 176(%esp),%ecx
1030 - # in2 ^= *(uint32 *) (m + 8)
1031 - xorl 8(%esi),%eax
1032 - # in3 ^= *(uint32 *) (m + 12)
1033 - xorl 12(%esi),%ecx
1034 - # *(uint32 *) (out + 8) = in2
1035 - movl %eax,8(%edi)
1036 - # *(uint32 *) (out + 12) = in3
1037 - movl %ecx,12(%edi)
1038 - # in4 = x4
1039 - movl 116(%esp),%eax
1040 - # in5 = x5
1041 - movl 120(%esp),%ecx
1042 - # in4 += j4
1043 - addl 180(%esp),%eax
1044 - # in5 += j5
1045 - addl 184(%esp),%ecx
1046 - # in4 ^= *(uint32 *) (m + 16)
1047 - xorl 16(%esi),%eax
1048 - # in5 ^= *(uint32 *) (m + 20)
1049 - xorl 20(%esi),%ecx
1050 - # *(uint32 *) (out + 16) = in4
1051 - movl %eax,16(%edi)
1052 - # *(uint32 *) (out + 20) = in5
1053 - movl %ecx,20(%edi)
1054 - # in6 = x6
1055 - movl 124(%esp),%eax
1056 - # in7 = x7
1057 - movl 128(%esp),%ecx
1058 - # in6 += j6
1059 - addl 188(%esp),%eax
1060 - # in7 += j7
1061 - addl 192(%esp),%ecx
1062 - # in6 ^= *(uint32 *) (m + 24)
1063 - xorl 24(%esi),%eax
1064 - # in7 ^= *(uint32 *) (m + 28)
1065 - xorl 28(%esi),%ecx
1066 - # *(uint32 *) (out + 24) = in6
1067 - movl %eax,24(%edi)
1068 - # *(uint32 *) (out + 28) = in7
1069 - movl %ecx,28(%edi)
1070 - # in8 = x8
1071 - movl 132(%esp),%eax
1072 - # in9 = x9
1073 - movl 136(%esp),%ecx
1074 - # in8 += j8
1075 - addl 196(%esp),%eax
1076 - # in9 += j9
1077 - addl 200(%esp),%ecx
1078 - # in8 ^= *(uint32 *) (m + 32)
1079 - xorl 32(%esi),%eax
1080 - # in9 ^= *(uint32 *) (m + 36)
1081 - xorl 36(%esi),%ecx
1082 - # *(uint32 *) (out + 32) = in8
1083 - movl %eax,32(%edi)
1084 - # *(uint32 *) (out + 36) = in9
1085 - movl %ecx,36(%edi)
1086 - # in10 = x10
1087 - movl 140(%esp),%eax
1088 - # in11 = x11
1089 - movl 144(%esp),%ecx
1090 - # in10 += j10
1091 - addl 204(%esp),%eax
1092 - # in11 += j11
1093 - addl 208(%esp),%ecx
1094 - # in10 ^= *(uint32 *) (m + 40)
1095 - xorl 40(%esi),%eax
1096 - # in11 ^= *(uint32 *) (m + 44)
1097 - xorl 44(%esi),%ecx
1098 - # *(uint32 *) (out + 40) = in10
1099 - movl %eax,40(%edi)
1100 - # *(uint32 *) (out + 44) = in11
1101 - movl %ecx,44(%edi)
1102 - # in12 = x12
1103 - movl 148(%esp),%eax
1104 - # in13 = x13
1105 - movl 152(%esp),%ecx
1106 - # in12 += j12
1107 - addl 212(%esp),%eax
1108 - # in13 += j13
1109 - addl 216(%esp),%ecx
1110 - # in12 ^= *(uint32 *) (m + 48)
1111 - xorl 48(%esi),%eax
1112 - # in13 ^= *(uint32 *) (m + 52)
1113 - xorl 52(%esi),%ecx
1114 - # *(uint32 *) (out + 48) = in12
1115 - movl %eax,48(%edi)
1116 - # *(uint32 *) (out + 52) = in13
1117 - movl %ecx,52(%edi)
1118 - # in14 = x14
1119 - movl 156(%esp),%eax
1120 - # in15 = x15
1121 - movl 160(%esp),%ecx
1122 - # in14 += j14
1123 - addl 220(%esp),%eax
1124 - # in15 += j15
1125 - addl 224(%esp),%ecx
1126 - # in14 ^= *(uint32 *) (m + 56)
1127 - xorl 56(%esi),%eax
1128 - # in15 ^= *(uint32 *) (m + 60)
1129 - xorl 60(%esi),%ecx
1130 - # *(uint32 *) (out + 56) = in14
1131 - movl %eax,56(%edi)
1132 - # *(uint32 *) (out + 60) = in15
1133 - movl %ecx,60(%edi)
1134 - # bytes = bytes_backup
1135 - movl 76(%esp),%ebx
1136 - # in8 = j8
1137 - movl 196(%esp),%eax
1138 - # in9 = j9
1139 - movl 200(%esp),%ecx
1140 - # in8 += 1
1141 - add $1,%eax
1142 - # in9 += 0 + carry
1143 - adc $0,%ecx
1144 - # j8 = in8
1145 - movl %eax,196(%esp)
1146 - # j9 = in9
1147 - movl %ecx,200(%esp)
1148 - # bytes - 64
1149 - cmp $64,%ebx
1150 - # goto bytesatleast65 if unsigned>
1151 - ja ._bytesatleast65
1152 - # goto bytesatleast64 if unsigned>=
1153 - jae ._bytesatleast64
1154 - # m = out
1155 - mov %edi,%esi
1156 - # out = ctarget
1157 - movl 228(%esp),%edi
1158 - # i = bytes
1159 - mov %ebx,%ecx
1160 - # while (i) { *out++ = *m++; --i }
1161 - rep movsb
1162 -._bytesatleast64:
1163 - # x = x_backup
1164 - movl 64(%esp),%eax
1165 - # in8 = j8
1166 - movl 196(%esp),%ecx
1167 - # in9 = j9
1168 - movl 200(%esp),%edx
1169 - # *(uint32 *) (x + 32) = in8
1170 - movl %ecx,32(%eax)
1171 - # *(uint32 *) (x + 36) = in9
1172 - movl %edx,36(%eax)
1173 -._done:
1174 - # eax = eax_stack
1175 - movl 80(%esp),%eax
1176 - # ebx = ebx_stack
1177 - movl 84(%esp),%ebx
1178 - # esi = esi_stack
1179 - movl 88(%esp),%esi
1180 - # edi = edi_stack
1181 - movl 92(%esp),%edi
1182 - # ebp = ebp_stack
1183 - movl 96(%esp),%ebp
1184 - # leave
1185 - add %eax,%esp
1186 - ret
1187 -._bytesatleast65:
1188 - # bytes -= 64
1189 - sub $64,%ebx
1190 - # out += 64
1191 - add $64,%edi
1192 - # m += 64
1193 - add $64,%esi
1194 - # goto bytesatleast1
1195 - jmp ._bytesatleast1
1196 -ENDPROC(salsa20_encrypt_bytes)
1197 -
1198 -# enter salsa20_keysetup
1199 -ENTRY(salsa20_keysetup)
1200 - mov %esp,%eax
1201 - and $31,%eax
1202 - add $256,%eax
1203 - sub %eax,%esp
1204 - # eax_stack = eax
1205 - movl %eax,64(%esp)
1206 - # ebx_stack = ebx
1207 - movl %ebx,68(%esp)
1208 - # esi_stack = esi
1209 - movl %esi,72(%esp)
1210 - # edi_stack = edi
1211 - movl %edi,76(%esp)
1212 - # ebp_stack = ebp
1213 - movl %ebp,80(%esp)
1214 - # k = arg2
1215 - movl 8(%esp,%eax),%ecx
1216 - # kbits = arg3
1217 - movl 12(%esp,%eax),%edx
1218 - # x = arg1
1219 - movl 4(%esp,%eax),%eax
1220 - # in1 = *(uint32 *) (k + 0)
1221 - movl 0(%ecx),%ebx
1222 - # in2 = *(uint32 *) (k + 4)
1223 - movl 4(%ecx),%esi
1224 - # in3 = *(uint32 *) (k + 8)
1225 - movl 8(%ecx),%edi
1226 - # in4 = *(uint32 *) (k + 12)
1227 - movl 12(%ecx),%ebp
1228 - # *(uint32 *) (x + 4) = in1
1229 - movl %ebx,4(%eax)
1230 - # *(uint32 *) (x + 8) = in2
1231 - movl %esi,8(%eax)
1232 - # *(uint32 *) (x + 12) = in3
1233 - movl %edi,12(%eax)
1234 - # *(uint32 *) (x + 16) = in4
1235 - movl %ebp,16(%eax)
1236 - # kbits - 256
1237 - cmp $256,%edx
1238 - # goto kbits128 if unsigned<
1239 - jb ._kbits128
1240 -._kbits256:
1241 - # in11 = *(uint32 *) (k + 16)
1242 - movl 16(%ecx),%edx
1243 - # in12 = *(uint32 *) (k + 20)
1244 - movl 20(%ecx),%ebx
1245 - # in13 = *(uint32 *) (k + 24)
1246 - movl 24(%ecx),%esi
1247 - # in14 = *(uint32 *) (k + 28)
1248 - movl 28(%ecx),%ecx
1249 - # *(uint32 *) (x + 44) = in11
1250 - movl %edx,44(%eax)
1251 - # *(uint32 *) (x + 48) = in12
1252 - movl %ebx,48(%eax)
1253 - # *(uint32 *) (x + 52) = in13
1254 - movl %esi,52(%eax)
1255 - # *(uint32 *) (x + 56) = in14
1256 - movl %ecx,56(%eax)
1257 - # in0 = 1634760805
1258 - mov $1634760805,%ecx
1259 - # in5 = 857760878
1260 - mov $857760878,%edx
1261 - # in10 = 2036477234
1262 - mov $2036477234,%ebx
1263 - # in15 = 1797285236
1264 - mov $1797285236,%esi
1265 - # *(uint32 *) (x + 0) = in0
1266 - movl %ecx,0(%eax)
1267 - # *(uint32 *) (x + 20) = in5
1268 - movl %edx,20(%eax)
1269 - # *(uint32 *) (x + 40) = in10
1270 - movl %ebx,40(%eax)
1271 - # *(uint32 *) (x + 60) = in15
1272 - movl %esi,60(%eax)
1273 - # goto keysetupdone
1274 - jmp ._keysetupdone
1275 -._kbits128:
1276 - # in11 = *(uint32 *) (k + 0)
1277 - movl 0(%ecx),%edx
1278 - # in12 = *(uint32 *) (k + 4)
1279 - movl 4(%ecx),%ebx
1280 - # in13 = *(uint32 *) (k + 8)
1281 - movl 8(%ecx),%esi
1282 - # in14 = *(uint32 *) (k + 12)
1283 - movl 12(%ecx),%ecx
1284 - # *(uint32 *) (x + 44) = in11
1285 - movl %edx,44(%eax)
1286 - # *(uint32 *) (x + 48) = in12
1287 - movl %ebx,48(%eax)
1288 - # *(uint32 *) (x + 52) = in13
1289 - movl %esi,52(%eax)
1290 - # *(uint32 *) (x + 56) = in14
1291 - movl %ecx,56(%eax)
1292 - # in0 = 1634760805
1293 - mov $1634760805,%ecx
1294 - # in5 = 824206446
1295 - mov $824206446,%edx
1296 - # in10 = 2036477238
1297 - mov $2036477238,%ebx
1298 - # in15 = 1797285236
1299 - mov $1797285236,%esi
1300 - # *(uint32 *) (x + 0) = in0
1301 - movl %ecx,0(%eax)
1302 - # *(uint32 *) (x + 20) = in5
1303 - movl %edx,20(%eax)
1304 - # *(uint32 *) (x + 40) = in10
1305 - movl %ebx,40(%eax)
1306 - # *(uint32 *) (x + 60) = in15
1307 - movl %esi,60(%eax)
1308 -._keysetupdone:
1309 - # eax = eax_stack
1310 - movl 64(%esp),%eax
1311 - # ebx = ebx_stack
1312 - movl 68(%esp),%ebx
1313 - # esi = esi_stack
1314 - movl 72(%esp),%esi
1315 - # edi = edi_stack
1316 - movl 76(%esp),%edi
1317 - # ebp = ebp_stack
1318 - movl 80(%esp),%ebp
1319 - # leave
1320 - add %eax,%esp
1321 - ret
1322 -ENDPROC(salsa20_keysetup)
1323 -
1324 -# enter salsa20_ivsetup
1325 -ENTRY(salsa20_ivsetup)
1326 - mov %esp,%eax
1327 - and $31,%eax
1328 - add $256,%eax
1329 - sub %eax,%esp
1330 - # eax_stack = eax
1331 - movl %eax,64(%esp)
1332 - # ebx_stack = ebx
1333 - movl %ebx,68(%esp)
1334 - # esi_stack = esi
1335 - movl %esi,72(%esp)
1336 - # edi_stack = edi
1337 - movl %edi,76(%esp)
1338 - # ebp_stack = ebp
1339 - movl %ebp,80(%esp)
1340 - # iv = arg2
1341 - movl 8(%esp,%eax),%ecx
1342 - # x = arg1
1343 - movl 4(%esp,%eax),%eax
1344 - # in6 = *(uint32 *) (iv + 0)
1345 - movl 0(%ecx),%edx
1346 - # in7 = *(uint32 *) (iv + 4)
1347 - movl 4(%ecx),%ecx
1348 - # in8 = 0
1349 - mov $0,%ebx
1350 - # in9 = 0
1351 - mov $0,%esi
1352 - # *(uint32 *) (x + 24) = in6
1353 - movl %edx,24(%eax)
1354 - # *(uint32 *) (x + 28) = in7
1355 - movl %ecx,28(%eax)
1356 - # *(uint32 *) (x + 32) = in8
1357 - movl %ebx,32(%eax)
1358 - # *(uint32 *) (x + 36) = in9
1359 - movl %esi,36(%eax)
1360 - # eax = eax_stack
1361 - movl 64(%esp),%eax
1362 - # ebx = ebx_stack
1363 - movl 68(%esp),%ebx
1364 - # esi = esi_stack
1365 - movl 72(%esp),%esi
1366 - # edi = edi_stack
1367 - movl 76(%esp),%edi
1368 - # ebp = ebp_stack
1369 - movl 80(%esp),%ebp
1370 - # leave
1371 - add %eax,%esp
1372 - ret
1373 -ENDPROC(salsa20_ivsetup)
1374 diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
1375 deleted file mode 100644
1376 index 10db30d58006..000000000000
1377 --- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
1378 +++ /dev/null
1379 @@ -1,919 +0,0 @@
1380 -/* SPDX-License-Identifier: GPL-2.0 */
1381 -#include <linux/linkage.h>
1382 -
1383 -# enter salsa20_encrypt_bytes
1384 -ENTRY(salsa20_encrypt_bytes)
1385 - mov %rsp,%r11
1386 - and $31,%r11
1387 - add $256,%r11
1388 - sub %r11,%rsp
1389 - # x = arg1
1390 - mov %rdi,%r8
1391 - # m = arg2
1392 - mov %rsi,%rsi
1393 - # out = arg3
1394 - mov %rdx,%rdi
1395 - # bytes = arg4
1396 - mov %rcx,%rdx
1397 - # unsigned>? bytes - 0
1398 - cmp $0,%rdx
1399 - # comment:fp stack unchanged by jump
1400 - # goto done if !unsigned>
1401 - jbe ._done
1402 - # comment:fp stack unchanged by fallthrough
1403 -# start:
1404 -._start:
1405 - # r11_stack = r11
1406 - movq %r11,0(%rsp)
1407 - # r12_stack = r12
1408 - movq %r12,8(%rsp)
1409 - # r13_stack = r13
1410 - movq %r13,16(%rsp)
1411 - # r14_stack = r14
1412 - movq %r14,24(%rsp)
1413 - # r15_stack = r15
1414 - movq %r15,32(%rsp)
1415 - # rbx_stack = rbx
1416 - movq %rbx,40(%rsp)
1417 - # rbp_stack = rbp
1418 - movq %rbp,48(%rsp)
1419 - # in0 = *(uint64 *) (x + 0)
1420 - movq 0(%r8),%rcx
1421 - # in2 = *(uint64 *) (x + 8)
1422 - movq 8(%r8),%r9
1423 - # in4 = *(uint64 *) (x + 16)
1424 - movq 16(%r8),%rax
1425 - # in6 = *(uint64 *) (x + 24)
1426 - movq 24(%r8),%r10
1427 - # in8 = *(uint64 *) (x + 32)
1428 - movq 32(%r8),%r11
1429 - # in10 = *(uint64 *) (x + 40)
1430 - movq 40(%r8),%r12
1431 - # in12 = *(uint64 *) (x + 48)
1432 - movq 48(%r8),%r13
1433 - # in14 = *(uint64 *) (x + 56)
1434 - movq 56(%r8),%r14
1435 - # j0 = in0
1436 - movq %rcx,56(%rsp)
1437 - # j2 = in2
1438 - movq %r9,64(%rsp)
1439 - # j4 = in4
1440 - movq %rax,72(%rsp)
1441 - # j6 = in6
1442 - movq %r10,80(%rsp)
1443 - # j8 = in8
1444 - movq %r11,88(%rsp)
1445 - # j10 = in10
1446 - movq %r12,96(%rsp)
1447 - # j12 = in12
1448 - movq %r13,104(%rsp)
1449 - # j14 = in14
1450 - movq %r14,112(%rsp)
1451 - # x_backup = x
1452 - movq %r8,120(%rsp)
1453 -# bytesatleast1:
1454 -._bytesatleast1:
1455 - # unsigned<? bytes - 64
1456 - cmp $64,%rdx
1457 - # comment:fp stack unchanged by jump
1458 - # goto nocopy if !unsigned<
1459 - jae ._nocopy
1460 - # ctarget = out
1461 - movq %rdi,128(%rsp)
1462 - # out = &tmp
1463 - leaq 192(%rsp),%rdi
1464 - # i = bytes
1465 - mov %rdx,%rcx
1466 - # while (i) { *out++ = *m++; --i }
1467 - rep movsb
1468 - # out = &tmp
1469 - leaq 192(%rsp),%rdi
1470 - # m = &tmp
1471 - leaq 192(%rsp),%rsi
1472 - # comment:fp stack unchanged by fallthrough
1473 -# nocopy:
1474 -._nocopy:
1475 - # out_backup = out
1476 - movq %rdi,136(%rsp)
1477 - # m_backup = m
1478 - movq %rsi,144(%rsp)
1479 - # bytes_backup = bytes
1480 - movq %rdx,152(%rsp)
1481 - # x1 = j0
1482 - movq 56(%rsp),%rdi
1483 - # x0 = x1
1484 - mov %rdi,%rdx
1485 - # (uint64) x1 >>= 32
1486 - shr $32,%rdi
1487 - # x3 = j2
1488 - movq 64(%rsp),%rsi
1489 - # x2 = x3
1490 - mov %rsi,%rcx
1491 - # (uint64) x3 >>= 32
1492 - shr $32,%rsi
1493 - # x5 = j4
1494 - movq 72(%rsp),%r8
1495 - # x4 = x5
1496 - mov %r8,%r9
1497 - # (uint64) x5 >>= 32
1498 - shr $32,%r8
1499 - # x5_stack = x5
1500 - movq %r8,160(%rsp)
1501 - # x7 = j6
1502 - movq 80(%rsp),%r8
1503 - # x6 = x7
1504 - mov %r8,%rax
1505 - # (uint64) x7 >>= 32
1506 - shr $32,%r8
1507 - # x9 = j8
1508 - movq 88(%rsp),%r10
1509 - # x8 = x9
1510 - mov %r10,%r11
1511 - # (uint64) x9 >>= 32
1512 - shr $32,%r10
1513 - # x11 = j10
1514 - movq 96(%rsp),%r12
1515 - # x10 = x11
1516 - mov %r12,%r13
1517 - # x10_stack = x10
1518 - movq %r13,168(%rsp)
1519 - # (uint64) x11 >>= 32
1520 - shr $32,%r12
1521 - # x13 = j12
1522 - movq 104(%rsp),%r13
1523 - # x12 = x13
1524 - mov %r13,%r14
1525 - # (uint64) x13 >>= 32
1526 - shr $32,%r13
1527 - # x15 = j14
1528 - movq 112(%rsp),%r15
1529 - # x14 = x15
1530 - mov %r15,%rbx
1531 - # (uint64) x15 >>= 32
1532 - shr $32,%r15
1533 - # x15_stack = x15
1534 - movq %r15,176(%rsp)
1535 - # i = 20
1536 - mov $20,%r15
1537 -# mainloop:
1538 -._mainloop:
1539 - # i_backup = i
1540 - movq %r15,184(%rsp)
1541 - # x5 = x5_stack
1542 - movq 160(%rsp),%r15
1543 - # a = x12 + x0
1544 - lea (%r14,%rdx),%rbp
1545 - # (uint32) a <<<= 7
1546 - rol $7,%ebp
1547 - # x4 ^= a
1548 - xor %rbp,%r9
1549 - # b = x1 + x5
1550 - lea (%rdi,%r15),%rbp
1551 - # (uint32) b <<<= 7
1552 - rol $7,%ebp
1553 - # x9 ^= b
1554 - xor %rbp,%r10
1555 - # a = x0 + x4
1556 - lea (%rdx,%r9),%rbp
1557 - # (uint32) a <<<= 9
1558 - rol $9,%ebp
1559 - # x8 ^= a
1560 - xor %rbp,%r11
1561 - # b = x5 + x9
1562 - lea (%r15,%r10),%rbp
1563 - # (uint32) b <<<= 9
1564 - rol $9,%ebp
1565 - # x13 ^= b
1566 - xor %rbp,%r13
1567 - # a = x4 + x8
1568 - lea (%r9,%r11),%rbp
1569 - # (uint32) a <<<= 13
1570 - rol $13,%ebp
1571 - # x12 ^= a
1572 - xor %rbp,%r14
1573 - # b = x9 + x13
1574 - lea (%r10,%r13),%rbp
1575 - # (uint32) b <<<= 13
1576 - rol $13,%ebp
1577 - # x1 ^= b
1578 - xor %rbp,%rdi
1579 - # a = x8 + x12
1580 - lea (%r11,%r14),%rbp
1581 - # (uint32) a <<<= 18
1582 - rol $18,%ebp
1583 - # x0 ^= a
1584 - xor %rbp,%rdx
1585 - # b = x13 + x1
1586 - lea (%r13,%rdi),%rbp
1587 - # (uint32) b <<<= 18
1588 - rol $18,%ebp
1589 - # x5 ^= b
1590 - xor %rbp,%r15
1591 - # x10 = x10_stack
1592 - movq 168(%rsp),%rbp
1593 - # x5_stack = x5
1594 - movq %r15,160(%rsp)
1595 - # c = x6 + x10
1596 - lea (%rax,%rbp),%r15
1597 - # (uint32) c <<<= 7
1598 - rol $7,%r15d
1599 - # x14 ^= c
1600 - xor %r15,%rbx
1601 - # c = x10 + x14
1602 - lea (%rbp,%rbx),%r15
1603 - # (uint32) c <<<= 9
1604 - rol $9,%r15d
1605 - # x2 ^= c
1606 - xor %r15,%rcx
1607 - # c = x14 + x2
1608 - lea (%rbx,%rcx),%r15
1609 - # (uint32) c <<<= 13
1610 - rol $13,%r15d
1611 - # x6 ^= c
1612 - xor %r15,%rax
1613 - # c = x2 + x6
1614 - lea (%rcx,%rax),%r15
1615 - # (uint32) c <<<= 18
1616 - rol $18,%r15d
1617 - # x10 ^= c
1618 - xor %r15,%rbp
1619 - # x15 = x15_stack
1620 - movq 176(%rsp),%r15
1621 - # x10_stack = x10
1622 - movq %rbp,168(%rsp)
1623 - # d = x11 + x15
1624 - lea (%r12,%r15),%rbp
1625 - # (uint32) d <<<= 7
1626 - rol $7,%ebp
1627 - # x3 ^= d
1628 - xor %rbp,%rsi
1629 - # d = x15 + x3
1630 - lea (%r15,%rsi),%rbp
1631 - # (uint32) d <<<= 9
1632 - rol $9,%ebp
1633 - # x7 ^= d
1634 - xor %rbp,%r8
1635 - # d = x3 + x7
1636 - lea (%rsi,%r8),%rbp
1637 - # (uint32) d <<<= 13
1638 - rol $13,%ebp
1639 - # x11 ^= d
1640 - xor %rbp,%r12
1641 - # d = x7 + x11
1642 - lea (%r8,%r12),%rbp
1643 - # (uint32) d <<<= 18
1644 - rol $18,%ebp
1645 - # x15 ^= d
1646 - xor %rbp,%r15
1647 - # x15_stack = x15
1648 - movq %r15,176(%rsp)
1649 - # x5 = x5_stack
1650 - movq 160(%rsp),%r15
1651 - # a = x3 + x0
1652 - lea (%rsi,%rdx),%rbp
1653 - # (uint32) a <<<= 7
1654 - rol $7,%ebp
1655 - # x1 ^= a
1656 - xor %rbp,%rdi
1657 - # b = x4 + x5
1658 - lea (%r9,%r15),%rbp
1659 - # (uint32) b <<<= 7
1660 - rol $7,%ebp
1661 - # x6 ^= b
1662 - xor %rbp,%rax
1663 - # a = x0 + x1
1664 - lea (%rdx,%rdi),%rbp
1665 - # (uint32) a <<<= 9
1666 - rol $9,%ebp
1667 - # x2 ^= a
1668 - xor %rbp,%rcx
1669 - # b = x5 + x6
1670 - lea (%r15,%rax),%rbp
1671 - # (uint32) b <<<= 9
1672 - rol $9,%ebp
1673 - # x7 ^= b
1674 - xor %rbp,%r8
1675 - # a = x1 + x2
1676 - lea (%rdi,%rcx),%rbp
1677 - # (uint32) a <<<= 13
1678 - rol $13,%ebp
1679 - # x3 ^= a
1680 - xor %rbp,%rsi
1681 - # b = x6 + x7
1682 - lea (%rax,%r8),%rbp
1683 - # (uint32) b <<<= 13
1684 - rol $13,%ebp
1685 - # x4 ^= b
1686 - xor %rbp,%r9
1687 - # a = x2 + x3
1688 - lea (%rcx,%rsi),%rbp
1689 - # (uint32) a <<<= 18
1690 - rol $18,%ebp
1691 - # x0 ^= a
1692 - xor %rbp,%rdx
1693 - # b = x7 + x4
1694 - lea (%r8,%r9),%rbp
1695 - # (uint32) b <<<= 18
1696 - rol $18,%ebp
1697 - # x5 ^= b
1698 - xor %rbp,%r15
1699 - # x10 = x10_stack
1700 - movq 168(%rsp),%rbp
1701 - # x5_stack = x5
1702 - movq %r15,160(%rsp)
1703 - # c = x9 + x10
1704 - lea (%r10,%rbp),%r15
1705 - # (uint32) c <<<= 7
1706 - rol $7,%r15d
1707 - # x11 ^= c
1708 - xor %r15,%r12
1709 - # c = x10 + x11
1710 - lea (%rbp,%r12),%r15
1711 - # (uint32) c <<<= 9
1712 - rol $9,%r15d
1713 - # x8 ^= c
1714 - xor %r15,%r11
1715 - # c = x11 + x8
1716 - lea (%r12,%r11),%r15
1717 - # (uint32) c <<<= 13
1718 - rol $13,%r15d
1719 - # x9 ^= c
1720 - xor %r15,%r10
1721 - # c = x8 + x9
1722 - lea (%r11,%r10),%r15
1723 - # (uint32) c <<<= 18
1724 - rol $18,%r15d
1725 - # x10 ^= c
1726 - xor %r15,%rbp
1727 - # x15 = x15_stack
1728 - movq 176(%rsp),%r15
1729 - # x10_stack = x10
1730 - movq %rbp,168(%rsp)
1731 - # d = x14 + x15
1732 - lea (%rbx,%r15),%rbp
1733 - # (uint32) d <<<= 7
1734 - rol $7,%ebp
1735 - # x12 ^= d
1736 - xor %rbp,%r14
1737 - # d = x15 + x12
1738 - lea (%r15,%r14),%rbp
1739 - # (uint32) d <<<= 9
1740 - rol $9,%ebp
1741 - # x13 ^= d
1742 - xor %rbp,%r13
1743 - # d = x12 + x13
1744 - lea (%r14,%r13),%rbp
1745 - # (uint32) d <<<= 13
1746 - rol $13,%ebp
1747 - # x14 ^= d
1748 - xor %rbp,%rbx
1749 - # d = x13 + x14
1750 - lea (%r13,%rbx),%rbp
1751 - # (uint32) d <<<= 18
1752 - rol $18,%ebp
1753 - # x15 ^= d
1754 - xor %rbp,%r15
1755 - # x15_stack = x15
1756 - movq %r15,176(%rsp)
1757 - # x5 = x5_stack
1758 - movq 160(%rsp),%r15
1759 - # a = x12 + x0
1760 - lea (%r14,%rdx),%rbp
1761 - # (uint32) a <<<= 7
1762 - rol $7,%ebp
1763 - # x4 ^= a
1764 - xor %rbp,%r9
1765 - # b = x1 + x5
1766 - lea (%rdi,%r15),%rbp
1767 - # (uint32) b <<<= 7
1768 - rol $7,%ebp
1769 - # x9 ^= b
1770 - xor %rbp,%r10
1771 - # a = x0 + x4
1772 - lea (%rdx,%r9),%rbp
1773 - # (uint32) a <<<= 9
1774 - rol $9,%ebp
1775 - # x8 ^= a
1776 - xor %rbp,%r11
1777 - # b = x5 + x9
1778 - lea (%r15,%r10),%rbp
1779 - # (uint32) b <<<= 9
1780 - rol $9,%ebp
1781 - # x13 ^= b
1782 - xor %rbp,%r13
1783 - # a = x4 + x8
1784 - lea (%r9,%r11),%rbp
1785 - # (uint32) a <<<= 13
1786 - rol $13,%ebp
1787 - # x12 ^= a
1788 - xor %rbp,%r14
1789 - # b = x9 + x13
1790 - lea (%r10,%r13),%rbp
1791 - # (uint32) b <<<= 13
1792 - rol $13,%ebp
1793 - # x1 ^= b
1794 - xor %rbp,%rdi
1795 - # a = x8 + x12
1796 - lea (%r11,%r14),%rbp
1797 - # (uint32) a <<<= 18
1798 - rol $18,%ebp
1799 - # x0 ^= a
1800 - xor %rbp,%rdx
1801 - # b = x13 + x1
1802 - lea (%r13,%rdi),%rbp
1803 - # (uint32) b <<<= 18
1804 - rol $18,%ebp
1805 - # x5 ^= b
1806 - xor %rbp,%r15
1807 - # x10 = x10_stack
1808 - movq 168(%rsp),%rbp
1809 - # x5_stack = x5
1810 - movq %r15,160(%rsp)
1811 - # c = x6 + x10
1812 - lea (%rax,%rbp),%r15
1813 - # (uint32) c <<<= 7
1814 - rol $7,%r15d
1815 - # x14 ^= c
1816 - xor %r15,%rbx
1817 - # c = x10 + x14
1818 - lea (%rbp,%rbx),%r15
1819 - # (uint32) c <<<= 9
1820 - rol $9,%r15d
1821 - # x2 ^= c
1822 - xor %r15,%rcx
1823 - # c = x14 + x2
1824 - lea (%rbx,%rcx),%r15
1825 - # (uint32) c <<<= 13
1826 - rol $13,%r15d
1827 - # x6 ^= c
1828 - xor %r15,%rax
1829 - # c = x2 + x6
1830 - lea (%rcx,%rax),%r15
1831 - # (uint32) c <<<= 18
1832 - rol $18,%r15d
1833 - # x10 ^= c
1834 - xor %r15,%rbp
1835 - # x15 = x15_stack
1836 - movq 176(%rsp),%r15
1837 - # x10_stack = x10
1838 - movq %rbp,168(%rsp)
1839 - # d = x11 + x15
1840 - lea (%r12,%r15),%rbp
1841 - # (uint32) d <<<= 7
1842 - rol $7,%ebp
1843 - # x3 ^= d
1844 - xor %rbp,%rsi
1845 - # d = x15 + x3
1846 - lea (%r15,%rsi),%rbp
1847 - # (uint32) d <<<= 9
1848 - rol $9,%ebp
1849 - # x7 ^= d
1850 - xor %rbp,%r8
1851 - # d = x3 + x7
1852 - lea (%rsi,%r8),%rbp
1853 - # (uint32) d <<<= 13
1854 - rol $13,%ebp
1855 - # x11 ^= d
1856 - xor %rbp,%r12
1857 - # d = x7 + x11
1858 - lea (%r8,%r12),%rbp
1859 - # (uint32) d <<<= 18
1860 - rol $18,%ebp
1861 - # x15 ^= d
1862 - xor %rbp,%r15
1863 - # x15_stack = x15
1864 - movq %r15,176(%rsp)
1865 - # x5 = x5_stack
1866 - movq 160(%rsp),%r15
1867 - # a = x3 + x0
1868 - lea (%rsi,%rdx),%rbp
1869 - # (uint32) a <<<= 7
1870 - rol $7,%ebp
1871 - # x1 ^= a
1872 - xor %rbp,%rdi
1873 - # b = x4 + x5
1874 - lea (%r9,%r15),%rbp
1875 - # (uint32) b <<<= 7
1876 - rol $7,%ebp
1877 - # x6 ^= b
1878 - xor %rbp,%rax
1879 - # a = x0 + x1
1880 - lea (%rdx,%rdi),%rbp
1881 - # (uint32) a <<<= 9
1882 - rol $9,%ebp
1883 - # x2 ^= a
1884 - xor %rbp,%rcx
1885 - # b = x5 + x6
1886 - lea (%r15,%rax),%rbp
1887 - # (uint32) b <<<= 9
1888 - rol $9,%ebp
1889 - # x7 ^= b
1890 - xor %rbp,%r8
1891 - # a = x1 + x2
1892 - lea (%rdi,%rcx),%rbp
1893 - # (uint32) a <<<= 13
1894 - rol $13,%ebp
1895 - # x3 ^= a
1896 - xor %rbp,%rsi
1897 - # b = x6 + x7
1898 - lea (%rax,%r8),%rbp
1899 - # (uint32) b <<<= 13
1900 - rol $13,%ebp
1901 - # x4 ^= b
1902 - xor %rbp,%r9
1903 - # a = x2 + x3
1904 - lea (%rcx,%rsi),%rbp
1905 - # (uint32) a <<<= 18
1906 - rol $18,%ebp
1907 - # x0 ^= a
1908 - xor %rbp,%rdx
1909 - # b = x7 + x4
1910 - lea (%r8,%r9),%rbp
1911 - # (uint32) b <<<= 18
1912 - rol $18,%ebp
1913 - # x5 ^= b
1914 - xor %rbp,%r15
1915 - # x10 = x10_stack
1916 - movq 168(%rsp),%rbp
1917 - # x5_stack = x5
1918 - movq %r15,160(%rsp)
1919 - # c = x9 + x10
1920 - lea (%r10,%rbp),%r15
1921 - # (uint32) c <<<= 7
1922 - rol $7,%r15d
1923 - # x11 ^= c
1924 - xor %r15,%r12
1925 - # c = x10 + x11
1926 - lea (%rbp,%r12),%r15
1927 - # (uint32) c <<<= 9
1928 - rol $9,%r15d
1929 - # x8 ^= c
1930 - xor %r15,%r11
1931 - # c = x11 + x8
1932 - lea (%r12,%r11),%r15
1933 - # (uint32) c <<<= 13
1934 - rol $13,%r15d
1935 - # x9 ^= c
1936 - xor %r15,%r10
1937 - # c = x8 + x9
1938 - lea (%r11,%r10),%r15
1939 - # (uint32) c <<<= 18
1940 - rol $18,%r15d
1941 - # x10 ^= c
1942 - xor %r15,%rbp
1943 - # x15 = x15_stack
1944 - movq 176(%rsp),%r15
1945 - # x10_stack = x10
1946 - movq %rbp,168(%rsp)
1947 - # d = x14 + x15
1948 - lea (%rbx,%r15),%rbp
1949 - # (uint32) d <<<= 7
1950 - rol $7,%ebp
1951 - # x12 ^= d
1952 - xor %rbp,%r14
1953 - # d = x15 + x12
1954 - lea (%r15,%r14),%rbp
1955 - # (uint32) d <<<= 9
1956 - rol $9,%ebp
1957 - # x13 ^= d
1958 - xor %rbp,%r13
1959 - # d = x12 + x13
1960 - lea (%r14,%r13),%rbp
1961 - # (uint32) d <<<= 13
1962 - rol $13,%ebp
1963 - # x14 ^= d
1964 - xor %rbp,%rbx
1965 - # d = x13 + x14
1966 - lea (%r13,%rbx),%rbp
1967 - # (uint32) d <<<= 18
1968 - rol $18,%ebp
1969 - # x15 ^= d
1970 - xor %rbp,%r15
1971 - # x15_stack = x15
1972 - movq %r15,176(%rsp)
1973 - # i = i_backup
1974 - movq 184(%rsp),%r15
1975 - # unsigned>? i -= 4
1976 - sub $4,%r15
1977 - # comment:fp stack unchanged by jump
1978 - # goto mainloop if unsigned>
1979 - ja ._mainloop
1980 - # (uint32) x2 += j2
1981 - addl 64(%rsp),%ecx
1982 - # x3 <<= 32
1983 - shl $32,%rsi
1984 - # x3 += j2
1985 - addq 64(%rsp),%rsi
1986 - # (uint64) x3 >>= 32
1987 - shr $32,%rsi
1988 - # x3 <<= 32
1989 - shl $32,%rsi
1990 - # x2 += x3
1991 - add %rsi,%rcx
1992 - # (uint32) x6 += j6
1993 - addl 80(%rsp),%eax
1994 - # x7 <<= 32
1995 - shl $32,%r8
1996 - # x7 += j6
1997 - addq 80(%rsp),%r8
1998 - # (uint64) x7 >>= 32
1999 - shr $32,%r8
2000 - # x7 <<= 32
2001 - shl $32,%r8
2002 - # x6 += x7
2003 - add %r8,%rax
2004 - # (uint32) x8 += j8
2005 - addl 88(%rsp),%r11d
2006 - # x9 <<= 32
2007 - shl $32,%r10
2008 - # x9 += j8
2009 - addq 88(%rsp),%r10
2010 - # (uint64) x9 >>= 32
2011 - shr $32,%r10
2012 - # x9 <<= 32
2013 - shl $32,%r10
2014 - # x8 += x9
2015 - add %r10,%r11
2016 - # (uint32) x12 += j12
2017 - addl 104(%rsp),%r14d
2018 - # x13 <<= 32
2019 - shl $32,%r13
2020 - # x13 += j12
2021 - addq 104(%rsp),%r13
2022 - # (uint64) x13 >>= 32
2023 - shr $32,%r13
2024 - # x13 <<= 32
2025 - shl $32,%r13
2026 - # x12 += x13
2027 - add %r13,%r14
2028 - # (uint32) x0 += j0
2029 - addl 56(%rsp),%edx
2030 - # x1 <<= 32
2031 - shl $32,%rdi
2032 - # x1 += j0
2033 - addq 56(%rsp),%rdi
2034 - # (uint64) x1 >>= 32
2035 - shr $32,%rdi
2036 - # x1 <<= 32
2037 - shl $32,%rdi
2038 - # x0 += x1
2039 - add %rdi,%rdx
2040 - # x5 = x5_stack
2041 - movq 160(%rsp),%rdi
2042 - # (uint32) x4 += j4
2043 - addl 72(%rsp),%r9d
2044 - # x5 <<= 32
2045 - shl $32,%rdi
2046 - # x5 += j4
2047 - addq 72(%rsp),%rdi
2048 - # (uint64) x5 >>= 32
2049 - shr $32,%rdi
2050 - # x5 <<= 32
2051 - shl $32,%rdi
2052 - # x4 += x5
2053 - add %rdi,%r9
2054 - # x10 = x10_stack
2055 - movq 168(%rsp),%r8
2056 - # (uint32) x10 += j10
2057 - addl 96(%rsp),%r8d
2058 - # x11 <<= 32
2059 - shl $32,%r12
2060 - # x11 += j10
2061 - addq 96(%rsp),%r12
2062 - # (uint64) x11 >>= 32
2063 - shr $32,%r12
2064 - # x11 <<= 32
2065 - shl $32,%r12
2066 - # x10 += x11
2067 - add %r12,%r8
2068 - # x15 = x15_stack
2069 - movq 176(%rsp),%rdi
2070 - # (uint32) x14 += j14
2071 - addl 112(%rsp),%ebx
2072 - # x15 <<= 32
2073 - shl $32,%rdi
2074 - # x15 += j14
2075 - addq 112(%rsp),%rdi
2076 - # (uint64) x15 >>= 32
2077 - shr $32,%rdi
2078 - # x15 <<= 32
2079 - shl $32,%rdi
2080 - # x14 += x15
2081 - add %rdi,%rbx
2082 - # out = out_backup
2083 - movq 136(%rsp),%rdi
2084 - # m = m_backup
2085 - movq 144(%rsp),%rsi
2086 - # x0 ^= *(uint64 *) (m + 0)
2087 - xorq 0(%rsi),%rdx
2088 - # *(uint64 *) (out + 0) = x0
2089 - movq %rdx,0(%rdi)
2090 - # x2 ^= *(uint64 *) (m + 8)
2091 - xorq 8(%rsi),%rcx
2092 - # *(uint64 *) (out + 8) = x2
2093 - movq %rcx,8(%rdi)
2094 - # x4 ^= *(uint64 *) (m + 16)
2095 - xorq 16(%rsi),%r9
2096 - # *(uint64 *) (out + 16) = x4
2097 - movq %r9,16(%rdi)
2098 - # x6 ^= *(uint64 *) (m + 24)
2099 - xorq 24(%rsi),%rax
2100 - # *(uint64 *) (out + 24) = x6
2101 - movq %rax,24(%rdi)
2102 - # x8 ^= *(uint64 *) (m + 32)
2103 - xorq 32(%rsi),%r11
2104 - # *(uint64 *) (out + 32) = x8
2105 - movq %r11,32(%rdi)
2106 - # x10 ^= *(uint64 *) (m + 40)
2107 - xorq 40(%rsi),%r8
2108 - # *(uint64 *) (out + 40) = x10
2109 - movq %r8,40(%rdi)
2110 - # x12 ^= *(uint64 *) (m + 48)
2111 - xorq 48(%rsi),%r14
2112 - # *(uint64 *) (out + 48) = x12
2113 - movq %r14,48(%rdi)
2114 - # x14 ^= *(uint64 *) (m + 56)
2115 - xorq 56(%rsi),%rbx
2116 - # *(uint64 *) (out + 56) = x14
2117 - movq %rbx,56(%rdi)
2118 - # bytes = bytes_backup
2119 - movq 152(%rsp),%rdx
2120 - # in8 = j8
2121 - movq 88(%rsp),%rcx
2122 - # in8 += 1
2123 - add $1,%rcx
2124 - # j8 = in8
2125 - movq %rcx,88(%rsp)
2126 - # unsigned>? unsigned<? bytes - 64
2127 - cmp $64,%rdx
2128 - # comment:fp stack unchanged by jump
2129 - # goto bytesatleast65 if unsigned>
2130 - ja ._bytesatleast65
2131 - # comment:fp stack unchanged by jump
2132 - # goto bytesatleast64 if !unsigned<
2133 - jae ._bytesatleast64
2134 - # m = out
2135 - mov %rdi,%rsi
2136 - # out = ctarget
2137 - movq 128(%rsp),%rdi
2138 - # i = bytes
2139 - mov %rdx,%rcx
2140 - # while (i) { *out++ = *m++; --i }
2141 - rep movsb
2142 - # comment:fp stack unchanged by fallthrough
2143 -# bytesatleast64:
2144 -._bytesatleast64:
2145 - # x = x_backup
2146 - movq 120(%rsp),%rdi
2147 - # in8 = j8
2148 - movq 88(%rsp),%rsi
2149 - # *(uint64 *) (x + 32) = in8
2150 - movq %rsi,32(%rdi)
2151 - # r11 = r11_stack
2152 - movq 0(%rsp),%r11
2153 - # r12 = r12_stack
2154 - movq 8(%rsp),%r12
2155 - # r13 = r13_stack
2156 - movq 16(%rsp),%r13
2157 - # r14 = r14_stack
2158 - movq 24(%rsp),%r14
2159 - # r15 = r15_stack
2160 - movq 32(%rsp),%r15
2161 - # rbx = rbx_stack
2162 - movq 40(%rsp),%rbx
2163 - # rbp = rbp_stack
2164 - movq 48(%rsp),%rbp
2165 - # comment:fp stack unchanged by fallthrough
2166 -# done:
2167 -._done:
2168 - # leave
2169 - add %r11,%rsp
2170 - mov %rdi,%rax
2171 - mov %rsi,%rdx
2172 - ret
2173 -# bytesatleast65:
2174 -._bytesatleast65:
2175 - # bytes -= 64
2176 - sub $64,%rdx
2177 - # out += 64
2178 - add $64,%rdi
2179 - # m += 64
2180 - add $64,%rsi
2181 - # comment:fp stack unchanged by jump
2182 - # goto bytesatleast1
2183 - jmp ._bytesatleast1
2184 -ENDPROC(salsa20_encrypt_bytes)
2185 -
2186 -# enter salsa20_keysetup
2187 -ENTRY(salsa20_keysetup)
2188 - mov %rsp,%r11
2189 - and $31,%r11
2190 - add $256,%r11
2191 - sub %r11,%rsp
2192 - # k = arg2
2193 - mov %rsi,%rsi
2194 - # kbits = arg3
2195 - mov %rdx,%rdx
2196 - # x = arg1
2197 - mov %rdi,%rdi
2198 - # in0 = *(uint64 *) (k + 0)
2199 - movq 0(%rsi),%r8
2200 - # in2 = *(uint64 *) (k + 8)
2201 - movq 8(%rsi),%r9
2202 - # *(uint64 *) (x + 4) = in0
2203 - movq %r8,4(%rdi)
2204 - # *(uint64 *) (x + 12) = in2
2205 - movq %r9,12(%rdi)
2206 - # unsigned<? kbits - 256
2207 - cmp $256,%rdx
2208 - # comment:fp stack unchanged by jump
2209 - # goto kbits128 if unsigned<
2210 - jb ._kbits128
2211 -# kbits256:
2212 -._kbits256:
2213 - # in10 = *(uint64 *) (k + 16)
2214 - movq 16(%rsi),%rdx
2215 - # in12 = *(uint64 *) (k + 24)
2216 - movq 24(%rsi),%rsi
2217 - # *(uint64 *) (x + 44) = in10
2218 - movq %rdx,44(%rdi)
2219 - # *(uint64 *) (x + 52) = in12
2220 - movq %rsi,52(%rdi)
2221 - # in0 = 1634760805
2222 - mov $1634760805,%rsi
2223 - # in4 = 857760878
2224 - mov $857760878,%rdx
2225 - # in10 = 2036477234
2226 - mov $2036477234,%rcx
2227 - # in14 = 1797285236
2228 - mov $1797285236,%r8
2229 - # *(uint32 *) (x + 0) = in0
2230 - movl %esi,0(%rdi)
2231 - # *(uint32 *) (x + 20) = in4
2232 - movl %edx,20(%rdi)
2233 - # *(uint32 *) (x + 40) = in10
2234 - movl %ecx,40(%rdi)
2235 - # *(uint32 *) (x + 60) = in14
2236 - movl %r8d,60(%rdi)
2237 - # comment:fp stack unchanged by jump
2238 - # goto keysetupdone
2239 - jmp ._keysetupdone
2240 -# kbits128:
2241 -._kbits128:
2242 - # in10 = *(uint64 *) (k + 0)
2243 - movq 0(%rsi),%rdx
2244 - # in12 = *(uint64 *) (k + 8)
2245 - movq 8(%rsi),%rsi
2246 - # *(uint64 *) (x + 44) = in10
2247 - movq %rdx,44(%rdi)
2248 - # *(uint64 *) (x + 52) = in12
2249 - movq %rsi,52(%rdi)
2250 - # in0 = 1634760805
2251 - mov $1634760805,%rsi
2252 - # in4 = 824206446
2253 - mov $824206446,%rdx
2254 - # in10 = 2036477238
2255 - mov $2036477238,%rcx
2256 - # in14 = 1797285236
2257 - mov $1797285236,%r8
2258 - # *(uint32 *) (x + 0) = in0
2259 - movl %esi,0(%rdi)
2260 - # *(uint32 *) (x + 20) = in4
2261 - movl %edx,20(%rdi)
2262 - # *(uint32 *) (x + 40) = in10
2263 - movl %ecx,40(%rdi)
2264 - # *(uint32 *) (x + 60) = in14
2265 - movl %r8d,60(%rdi)
2266 -# keysetupdone:
2267 -._keysetupdone:
2268 - # leave
2269 - add %r11,%rsp
2270 - mov %rdi,%rax
2271 - mov %rsi,%rdx
2272 - ret
2273 -ENDPROC(salsa20_keysetup)
2274 -
2275 -# enter salsa20_ivsetup
2276 -ENTRY(salsa20_ivsetup)
2277 - mov %rsp,%r11
2278 - and $31,%r11
2279 - add $256,%r11
2280 - sub %r11,%rsp
2281 - # iv = arg2
2282 - mov %rsi,%rsi
2283 - # x = arg1
2284 - mov %rdi,%rdi
2285 - # in6 = *(uint64 *) (iv + 0)
2286 - movq 0(%rsi),%rsi
2287 - # in8 = 0
2288 - mov $0,%r8
2289 - # *(uint64 *) (x + 24) = in6
2290 - movq %rsi,24(%rdi)
2291 - # *(uint64 *) (x + 32) = in8
2292 - movq %r8,32(%rdi)
2293 - # leave
2294 - add %r11,%rsp
2295 - mov %rdi,%rax
2296 - mov %rsi,%rdx
2297 - ret
2298 -ENDPROC(salsa20_ivsetup)
2299 diff --git a/arch/x86/crypto/salsa20_glue.c b/arch/x86/crypto/salsa20_glue.c
2300 deleted file mode 100644
2301 index cb91a64a99e7..000000000000
2302 --- a/arch/x86/crypto/salsa20_glue.c
2303 +++ /dev/null
2304 @@ -1,116 +0,0 @@
2305 -/*
2306 - * Glue code for optimized assembly version of Salsa20.
2307 - *
2308 - * Copyright (c) 2007 Tan Swee Heng <thesweeheng@gmail.com>
2309 - *
2310 - * The assembly codes are public domain assembly codes written by Daniel. J.
2311 - * Bernstein <djb@cr.yp.to>. The codes are modified to include indentation
2312 - * and to remove extraneous comments and functions that are not needed.
2313 - * - i586 version, renamed as salsa20-i586-asm_32.S
2314 - * available from <http://cr.yp.to/snuffle/salsa20/x86-pm/salsa20.s>
2315 - * - x86-64 version, renamed as salsa20-x86_64-asm_64.S
2316 - * available from <http://cr.yp.to/snuffle/salsa20/amd64-3/salsa20.s>
2317 - *
2318 - * This program is free software; you can redistribute it and/or modify it
2319 - * under the terms of the GNU General Public License as published by the Free
2320 - * Software Foundation; either version 2 of the License, or (at your option)
2321 - * any later version.
2322 - *
2323 - */
2324 -
2325 -#include <crypto/algapi.h>
2326 -#include <linux/module.h>
2327 -#include <linux/crypto.h>
2328 -
2329 -#define SALSA20_IV_SIZE 8U
2330 -#define SALSA20_MIN_KEY_SIZE 16U
2331 -#define SALSA20_MAX_KEY_SIZE 32U
2332 -
2333 -struct salsa20_ctx
2334 -{
2335 - u32 input[16];
2336 -};
2337 -
2338 -asmlinkage void salsa20_keysetup(struct salsa20_ctx *ctx, const u8 *k,
2339 - u32 keysize, u32 ivsize);
2340 -asmlinkage void salsa20_ivsetup(struct salsa20_ctx *ctx, const u8 *iv);
2341 -asmlinkage void salsa20_encrypt_bytes(struct salsa20_ctx *ctx,
2342 - const u8 *src, u8 *dst, u32 bytes);
2343 -
2344 -static int setkey(struct crypto_tfm *tfm, const u8 *key,
2345 - unsigned int keysize)
2346 -{
2347 - struct salsa20_ctx *ctx = crypto_tfm_ctx(tfm);
2348 - salsa20_keysetup(ctx, key, keysize*8, SALSA20_IV_SIZE*8);
2349 - return 0;
2350 -}
2351 -
2352 -static int encrypt(struct blkcipher_desc *desc,
2353 - struct scatterlist *dst, struct scatterlist *src,
2354 - unsigned int nbytes)
2355 -{
2356 - struct blkcipher_walk walk;
2357 - struct crypto_blkcipher *tfm = desc->tfm;
2358 - struct salsa20_ctx *ctx = crypto_blkcipher_ctx(tfm);
2359 - int err;
2360 -
2361 - blkcipher_walk_init(&walk, dst, src, nbytes);
2362 - err = blkcipher_walk_virt_block(desc, &walk, 64);
2363 -
2364 - salsa20_ivsetup(ctx, walk.iv);
2365 -
2366 - while (walk.nbytes >= 64) {
2367 - salsa20_encrypt_bytes(ctx, walk.src.virt.addr,
2368 - walk.dst.virt.addr,
2369 - walk.nbytes - (walk.nbytes % 64));
2370 - err = blkcipher_walk_done(desc, &walk, walk.nbytes % 64);
2371 - }
2372 -
2373 - if (walk.nbytes) {
2374 - salsa20_encrypt_bytes(ctx, walk.src.virt.addr,
2375 - walk.dst.virt.addr, walk.nbytes);
2376 - err = blkcipher_walk_done(desc, &walk, 0);
2377 - }
2378 -
2379 - return err;
2380 -}
2381 -
2382 -static struct crypto_alg alg = {
2383 - .cra_name = "salsa20",
2384 - .cra_driver_name = "salsa20-asm",
2385 - .cra_priority = 200,
2386 - .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER,
2387 - .cra_type = &crypto_blkcipher_type,
2388 - .cra_blocksize = 1,
2389 - .cra_ctxsize = sizeof(struct salsa20_ctx),
2390 - .cra_alignmask = 3,
2391 - .cra_module = THIS_MODULE,
2392 - .cra_u = {
2393 - .blkcipher = {
2394 - .setkey = setkey,
2395 - .encrypt = encrypt,
2396 - .decrypt = encrypt,
2397 - .min_keysize = SALSA20_MIN_KEY_SIZE,
2398 - .max_keysize = SALSA20_MAX_KEY_SIZE,
2399 - .ivsize = SALSA20_IV_SIZE,
2400 - }
2401 - }
2402 -};
2403 -
2404 -static int __init init(void)
2405 -{
2406 - return crypto_register_alg(&alg);
2407 -}
2408 -
2409 -static void __exit fini(void)
2410 -{
2411 - crypto_unregister_alg(&alg);
2412 -}
2413 -
2414 -module_init(init);
2415 -module_exit(fini);
2416 -
2417 -MODULE_LICENSE("GPL");
2418 -MODULE_DESCRIPTION ("Salsa20 stream cipher algorithm (optimized assembly version)");
2419 -MODULE_ALIAS_CRYPTO("salsa20");
2420 -MODULE_ALIAS_CRYPTO("salsa20-asm");
2421 diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
2422 index e1ea13ae53b9..b9a8f34b5e5a 100644
2423 --- a/arch/x86/kernel/uprobes.c
2424 +++ b/arch/x86/kernel/uprobes.c
2425 @@ -290,7 +290,7 @@ static int uprobe_init_insn(struct arch_uprobe *auprobe, struct insn *insn, bool
2426 insn_init(insn, auprobe->insn, sizeof(auprobe->insn), x86_64);
2427 /* has the side-effect of processing the entire instruction */
2428 insn_get_length(insn);
2429 - if (WARN_ON_ONCE(!insn_complete(insn)))
2430 + if (!insn_complete(insn))
2431 return -ENOEXEC;
2432
2433 if (is_prefix_bad(insn))
2434 diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c
2435 index fcd8789470d1..fd173e6425cc 100644
2436 --- a/arch/x86/xen/enlighten_pv.c
2437 +++ b/arch/x86/xen/enlighten_pv.c
2438 @@ -1230,12 +1230,20 @@ asmlinkage __visible void __init xen_start_kernel(void)
2439
2440 xen_setup_features();
2441
2442 - xen_setup_machphys_mapping();
2443 -
2444 /* Install Xen paravirt ops */
2445 pv_info = xen_info;
2446 pv_init_ops.patch = paravirt_patch_default;
2447 pv_cpu_ops = xen_cpu_ops;
2448 + xen_init_irq_ops();
2449 +
2450 + /*
2451 + * Setup xen_vcpu early because it is needed for
2452 + * local_irq_disable(), irqs_disabled(), e.g. in printk().
2453 + *
2454 + * Don't do the full vcpu_info placement stuff until we have
2455 + * the cpu_possible_mask and a non-dummy shared_info.
2456 + */
2457 + xen_vcpu_info_reset(0);
2458
2459 x86_platform.get_nmi_reason = xen_get_nmi_reason;
2460
2461 @@ -1247,6 +1255,7 @@ asmlinkage __visible void __init xen_start_kernel(void)
2462 * Set up some pagetable state before starting to set any ptes.
2463 */
2464
2465 + xen_setup_machphys_mapping();
2466 xen_init_mmu_ops();
2467
2468 /* Prevent unwanted bits from being set in PTEs. */
2469 @@ -1271,20 +1280,9 @@ asmlinkage __visible void __init xen_start_kernel(void)
2470 get_cpu_cap(&boot_cpu_data);
2471 x86_configure_nx();
2472
2473 - xen_init_irq_ops();
2474 -
2475 /* Let's presume PV guests always boot on vCPU with id 0. */
2476 per_cpu(xen_vcpu_id, 0) = 0;
2477
2478 - /*
2479 - * Setup xen_vcpu early because idt_setup_early_handler needs it for
2480 - * local_irq_disable(), irqs_disabled().
2481 - *
2482 - * Don't do the full vcpu_info placement stuff until we have
2483 - * the cpu_possible_mask and a non-dummy shared_info.
2484 - */
2485 - xen_vcpu_info_reset(0);
2486 -
2487 idt_setup_early_handler();
2488
2489 xen_init_capabilities();
2490 diff --git a/arch/x86/xen/irq.c b/arch/x86/xen/irq.c
2491 index 74179852e46c..7515a19fd324 100644
2492 --- a/arch/x86/xen/irq.c
2493 +++ b/arch/x86/xen/irq.c
2494 @@ -128,8 +128,6 @@ static const struct pv_irq_ops xen_irq_ops __initconst = {
2495
2496 void __init xen_init_irq_ops(void)
2497 {
2498 - /* For PVH we use default pv_irq_ops settings. */
2499 - if (!xen_feature(XENFEAT_hvm_callback_vector))
2500 - pv_irq_ops = xen_irq_ops;
2501 + pv_irq_ops = xen_irq_ops;
2502 x86_init.irqs.intr_init = xen_init_IRQ;
2503 }
2504 diff --git a/crypto/Kconfig b/crypto/Kconfig
2505 index 42212b60a0ee..5579eb88d460 100644
2506 --- a/crypto/Kconfig
2507 +++ b/crypto/Kconfig
2508 @@ -1324,32 +1324,6 @@ config CRYPTO_SALSA20
2509 The Salsa20 stream cipher algorithm is designed by Daniel J.
2510 Bernstein <djb@cr.yp.to>. See <http://cr.yp.to/snuffle.html>
2511
2512 -config CRYPTO_SALSA20_586
2513 - tristate "Salsa20 stream cipher algorithm (i586)"
2514 - depends on (X86 || UML_X86) && !64BIT
2515 - select CRYPTO_BLKCIPHER
2516 - help
2517 - Salsa20 stream cipher algorithm.
2518 -
2519 - Salsa20 is a stream cipher submitted to eSTREAM, the ECRYPT
2520 - Stream Cipher Project. See <http://www.ecrypt.eu.org/stream/>
2521 -
2522 - The Salsa20 stream cipher algorithm is designed by Daniel J.
2523 - Bernstein <djb@cr.yp.to>. See <http://cr.yp.to/snuffle.html>
2524 -
2525 -config CRYPTO_SALSA20_X86_64
2526 - tristate "Salsa20 stream cipher algorithm (x86_64)"
2527 - depends on (X86 || UML_X86) && 64BIT
2528 - select CRYPTO_BLKCIPHER
2529 - help
2530 - Salsa20 stream cipher algorithm.
2531 -
2532 - Salsa20 is a stream cipher submitted to eSTREAM, the ECRYPT
2533 - Stream Cipher Project. See <http://www.ecrypt.eu.org/stream/>
2534 -
2535 - The Salsa20 stream cipher algorithm is designed by Daniel J.
2536 - Bernstein <djb@cr.yp.to>. See <http://cr.yp.to/snuffle.html>
2537 -
2538 config CRYPTO_CHACHA20
2539 tristate "ChaCha20 cipher algorithm"
2540 select CRYPTO_BLKCIPHER
2541 diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
2542 index 75eb50041c99..f003e301723a 100644
2543 --- a/drivers/ata/ahci.c
2544 +++ b/drivers/ata/ahci.c
2545 @@ -1267,6 +1267,59 @@ static bool ahci_broken_suspend(struct pci_dev *pdev)
2546 return strcmp(buf, dmi->driver_data) < 0;
2547 }
2548
2549 +static bool ahci_broken_lpm(struct pci_dev *pdev)
2550 +{
2551 + static const struct dmi_system_id sysids[] = {
2552 + /* Various Lenovo 50 series have LPM issues with older BIOSen */
2553 + {
2554 + .matches = {
2555 + DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
2556 + DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X250"),
2557 + },
2558 + .driver_data = "20180406", /* 1.31 */
2559 + },
2560 + {
2561 + .matches = {
2562 + DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
2563 + DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad L450"),
2564 + },
2565 + .driver_data = "20180420", /* 1.28 */
2566 + },
2567 + {
2568 + .matches = {
2569 + DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
2570 + DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T450s"),
2571 + },
2572 + .driver_data = "20180315", /* 1.33 */
2573 + },
2574 + {
2575 + .matches = {
2576 + DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
2577 + DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad W541"),
2578 + },
2579 + /*
2580 + * Note date based on release notes, 2.35 has been
2581 + * reported to be good, but I've been unable to get
2582 + * a hold of the reporter to get the DMI BIOS date.
2583 + * TODO: fix this.
2584 + */
2585 + .driver_data = "20180310", /* 2.35 */
2586 + },
2587 + { } /* terminate list */
2588 + };
2589 + const struct dmi_system_id *dmi = dmi_first_match(sysids);
2590 + int year, month, date;
2591 + char buf[9];
2592 +
2593 + if (!dmi)
2594 + return false;
2595 +
2596 + dmi_get_date(DMI_BIOS_DATE, &year, &month, &date);
2597 + snprintf(buf, sizeof(buf), "%04d%02d%02d", year, month, date);
2598 +
2599 + return strcmp(buf, dmi->driver_data) < 0;
2600 +}
2601 +
2602 static bool ahci_broken_online(struct pci_dev *pdev)
2603 {
2604 #define ENCODE_BUSDEVFN(bus, slot, func) \
2605 @@ -1677,6 +1730,12 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2606 "quirky BIOS, skipping spindown on poweroff\n");
2607 }
2608
2609 + if (ahci_broken_lpm(pdev)) {
2610 + pi.flags |= ATA_FLAG_NO_LPM;
2611 + dev_warn(&pdev->dev,
2612 + "BIOS update required for Link Power Management support\n");
2613 + }
2614 +
2615 if (ahci_broken_suspend(pdev)) {
2616 hpriv->flags |= AHCI_HFLAG_NO_SUSPEND;
2617 dev_warn(&pdev->dev,
2618 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
2619 index cad2530a5b52..6938bd86ff1c 100644
2620 --- a/drivers/ata/libata-core.c
2621 +++ b/drivers/ata/libata-core.c
2622 @@ -2501,6 +2501,9 @@ int ata_dev_configure(struct ata_device *dev)
2623 (id[ATA_ID_SATA_CAPABILITY] & 0xe) == 0x2)
2624 dev->horkage |= ATA_HORKAGE_NOLPM;
2625
2626 + if (ap->flags & ATA_FLAG_NO_LPM)
2627 + dev->horkage |= ATA_HORKAGE_NOLPM;
2628 +
2629 if (dev->horkage & ATA_HORKAGE_NOLPM) {
2630 ata_dev_warn(dev, "LPM support broken, forcing max_power\n");
2631 dev->link->ap->target_lpm_policy = ATA_LPM_MAX_POWER;
2632 diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
2633 index 6b0440a12c51..bf5777bc04d3 100644
2634 --- a/drivers/ata/libata-scsi.c
2635 +++ b/drivers/ata/libata-scsi.c
2636 @@ -3801,10 +3801,20 @@ static unsigned int ata_scsi_zbc_out_xlat(struct ata_queued_cmd *qc)
2637 */
2638 goto invalid_param_len;
2639 }
2640 - if (block > dev->n_sectors)
2641 - goto out_of_range;
2642
2643 all = cdb[14] & 0x1;
2644 + if (all) {
2645 + /*
2646 + * Ignore the block address (zone ID) as defined by ZBC.
2647 + */
2648 + block = 0;
2649 + } else if (block >= dev->n_sectors) {
2650 + /*
2651 + * Block must be a valid zone ID (a zone start LBA).
2652 + */
2653 + fp = 2;
2654 + goto invalid_fld;
2655 + }
2656
2657 if (ata_ncq_enabled(qc->dev) &&
2658 ata_fpdma_zac_mgmt_out_supported(qc->dev)) {
2659 @@ -3833,10 +3843,6 @@ static unsigned int ata_scsi_zbc_out_xlat(struct ata_queued_cmd *qc)
2660 invalid_fld:
2661 ata_scsi_set_invalid_field(qc->dev, scmd, fp, 0xff);
2662 return 1;
2663 - out_of_range:
2664 - /* "Logical Block Address out of range" */
2665 - ata_scsi_set_sense(qc->dev, scmd, ILLEGAL_REQUEST, 0x21, 0x00);
2666 - return 1;
2667 invalid_param_len:
2668 /* "Parameter list length error" */
2669 ata_scsi_set_sense(qc->dev, scmd, ILLEGAL_REQUEST, 0x1a, 0x0);
2670 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
2671 index 1a87f87c88d0..6d61633a7f89 100644
2672 --- a/drivers/block/loop.c
2673 +++ b/drivers/block/loop.c
2674 @@ -617,6 +617,36 @@ static void loop_reread_partitions(struct loop_device *lo,
2675 __func__, lo->lo_number, lo->lo_file_name, rc);
2676 }
2677
2678 +static inline int is_loop_device(struct file *file)
2679 +{
2680 + struct inode *i = file->f_mapping->host;
2681 +
2682 + return i && S_ISBLK(i->i_mode) && MAJOR(i->i_rdev) == LOOP_MAJOR;
2683 +}
2684 +
2685 +static int loop_validate_file(struct file *file, struct block_device *bdev)
2686 +{
2687 + struct inode *inode = file->f_mapping->host;
2688 + struct file *f = file;
2689 +
2690 + /* Avoid recursion */
2691 + while (is_loop_device(f)) {
2692 + struct loop_device *l;
2693 +
2694 + if (f->f_mapping->host->i_bdev == bdev)
2695 + return -EBADF;
2696 +
2697 + l = f->f_mapping->host->i_bdev->bd_disk->private_data;
2698 + if (l->lo_state == Lo_unbound) {
2699 + return -EINVAL;
2700 + }
2701 + f = l->lo_backing_file;
2702 + }
2703 + if (!S_ISREG(inode->i_mode) && !S_ISBLK(inode->i_mode))
2704 + return -EINVAL;
2705 + return 0;
2706 +}
2707 +
2708 /*
2709 * loop_change_fd switched the backing store of a loopback device to
2710 * a new file. This is useful for operating system installers to free up
2711 @@ -646,14 +676,15 @@ static int loop_change_fd(struct loop_device *lo, struct block_device *bdev,
2712 if (!file)
2713 goto out;
2714
2715 + error = loop_validate_file(file, bdev);
2716 + if (error)
2717 + goto out_putf;
2718 +
2719 inode = file->f_mapping->host;
2720 old_file = lo->lo_backing_file;
2721
2722 error = -EINVAL;
2723
2724 - if (!S_ISREG(inode->i_mode) && !S_ISBLK(inode->i_mode))
2725 - goto out_putf;
2726 -
2727 /* size of the new backing store needs to be the same */
2728 if (get_loop_size(lo, file) != get_loop_size(lo, old_file))
2729 goto out_putf;
2730 @@ -679,13 +710,6 @@ static int loop_change_fd(struct loop_device *lo, struct block_device *bdev,
2731 return error;
2732 }
2733
2734 -static inline int is_loop_device(struct file *file)
2735 -{
2736 - struct inode *i = file->f_mapping->host;
2737 -
2738 - return i && S_ISBLK(i->i_mode) && MAJOR(i->i_rdev) == LOOP_MAJOR;
2739 -}
2740 -
2741 /* loop sysfs attributes */
2742
2743 static ssize_t loop_attr_show(struct device *dev, char *page,
2744 @@ -782,16 +806,17 @@ static struct attribute_group loop_attribute_group = {
2745 .attrs= loop_attrs,
2746 };
2747
2748 -static int loop_sysfs_init(struct loop_device *lo)
2749 +static void loop_sysfs_init(struct loop_device *lo)
2750 {
2751 - return sysfs_create_group(&disk_to_dev(lo->lo_disk)->kobj,
2752 - &loop_attribute_group);
2753 + lo->sysfs_inited = !sysfs_create_group(&disk_to_dev(lo->lo_disk)->kobj,
2754 + &loop_attribute_group);
2755 }
2756
2757 static void loop_sysfs_exit(struct loop_device *lo)
2758 {
2759 - sysfs_remove_group(&disk_to_dev(lo->lo_disk)->kobj,
2760 - &loop_attribute_group);
2761 + if (lo->sysfs_inited)
2762 + sysfs_remove_group(&disk_to_dev(lo->lo_disk)->kobj,
2763 + &loop_attribute_group);
2764 }
2765
2766 static void loop_config_discard(struct loop_device *lo)
2767 @@ -850,7 +875,7 @@ static int loop_prepare_queue(struct loop_device *lo)
2768 static int loop_set_fd(struct loop_device *lo, fmode_t mode,
2769 struct block_device *bdev, unsigned int arg)
2770 {
2771 - struct file *file, *f;
2772 + struct file *file;
2773 struct inode *inode;
2774 struct address_space *mapping;
2775 int lo_flags = 0;
2776 @@ -869,29 +894,13 @@ static int loop_set_fd(struct loop_device *lo, fmode_t mode,
2777 if (lo->lo_state != Lo_unbound)
2778 goto out_putf;
2779
2780 - /* Avoid recursion */
2781 - f = file;
2782 - while (is_loop_device(f)) {
2783 - struct loop_device *l;
2784 -
2785 - if (f->f_mapping->host->i_bdev == bdev)
2786 - goto out_putf;
2787 -
2788 - l = f->f_mapping->host->i_bdev->bd_disk->private_data;
2789 - if (l->lo_state == Lo_unbound) {
2790 - error = -EINVAL;
2791 - goto out_putf;
2792 - }
2793 - f = l->lo_backing_file;
2794 - }
2795 + error = loop_validate_file(file, bdev);
2796 + if (error)
2797 + goto out_putf;
2798
2799 mapping = file->f_mapping;
2800 inode = mapping->host;
2801
2802 - error = -EINVAL;
2803 - if (!S_ISREG(inode->i_mode) && !S_ISBLK(inode->i_mode))
2804 - goto out_putf;
2805 -
2806 if (!(file->f_mode & FMODE_WRITE) || !(mode & FMODE_WRITE) ||
2807 !file->f_op->write_iter)
2808 lo_flags |= LO_FLAGS_READ_ONLY;
2809 diff --git a/drivers/block/loop.h b/drivers/block/loop.h
2810 index 1f3956702993..dfc54ceba410 100644
2811 --- a/drivers/block/loop.h
2812 +++ b/drivers/block/loop.h
2813 @@ -58,6 +58,7 @@ struct loop_device {
2814 struct kthread_worker worker;
2815 struct task_struct *worker_task;
2816 bool use_dio;
2817 + bool sysfs_inited;
2818
2819 struct request_queue *lo_queue;
2820 struct blk_mq_tag_set tag_set;
2821 diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
2822 index 60292d243e24..ec2d11af6c78 100644
2823 --- a/drivers/i2c/busses/i2c-tegra.c
2824 +++ b/drivers/i2c/busses/i2c-tegra.c
2825 @@ -547,6 +547,14 @@ static int tegra_i2c_disable_packet_mode(struct tegra_i2c_dev *i2c_dev)
2826 {
2827 u32 cnfg;
2828
2829 + /*
2830 + * NACK interrupt is generated before the I2C controller generates
2831 + * the STOP condition on the bus. So wait for 2 clock periods
2832 + * before disabling the controller so that the STOP condition has
2833 + * been delivered properly.
2834 + */
2835 + udelay(DIV_ROUND_UP(2 * 1000000, i2c_dev->bus_clk_rate));
2836 +
2837 cnfg = i2c_readl(i2c_dev, I2C_CNFG);
2838 if (cnfg & I2C_CNFG_PACKET_MODE_EN)
2839 i2c_writel(i2c_dev, cnfg & ~I2C_CNFG_PACKET_MODE_EN, I2C_CNFG);
2840 @@ -708,15 +716,6 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev,
2841 if (likely(i2c_dev->msg_err == I2C_ERR_NONE))
2842 return 0;
2843
2844 - /*
2845 - * NACK interrupt is generated before the I2C controller generates
2846 - * the STOP condition on the bus. So wait for 2 clock periods
2847 - * before resetting the controller so that the STOP condition has
2848 - * been delivered properly.
2849 - */
2850 - if (i2c_dev->msg_err == I2C_ERR_NO_ACK)
2851 - udelay(DIV_ROUND_UP(2 * 1000000, i2c_dev->bus_clk_rate));
2852 -
2853 tegra_i2c_init(i2c_dev);
2854 if (i2c_dev->msg_err == I2C_ERR_NO_ACK) {
2855 if (msg->flags & I2C_M_IGNORE_NAK)
2856 diff --git a/drivers/infiniband/Kconfig b/drivers/infiniband/Kconfig
2857 index 7507cc641de3..27b3c39e586a 100644
2858 --- a/drivers/infiniband/Kconfig
2859 +++ b/drivers/infiniband/Kconfig
2860 @@ -34,6 +34,18 @@ config INFINIBAND_USER_ACCESS
2861 libibverbs, libibcm and a hardware driver library from
2862 <http://www.openfabrics.org/git/>.
2863
2864 +config INFINIBAND_USER_ACCESS_UCM
2865 + bool "Userspace CM (UCM, DEPRECATED)"
2866 + depends on BROKEN
2867 + depends on INFINIBAND_USER_ACCESS
2868 + help
2869 + The UCM module has known security flaws, which no one is
2870 + interested to fix. The user-space part of this code was
2871 + dropped from the upstream a long time ago.
2872 +
2873 + This option is DEPRECATED and planned to be removed.
2874 +
2875 +
2876 config INFINIBAND_EXP_USER_ACCESS
2877 bool "Allow experimental support for Infiniband ABI"
2878 depends on INFINIBAND_USER_ACCESS
2879 diff --git a/drivers/infiniband/core/Makefile b/drivers/infiniband/core/Makefile
2880 index 9c0a2b5c834e..991c2522fb41 100644
2881 --- a/drivers/infiniband/core/Makefile
2882 +++ b/drivers/infiniband/core/Makefile
2883 @@ -5,8 +5,8 @@ user_access-$(CONFIG_INFINIBAND_ADDR_TRANS) := rdma_ucm.o
2884 obj-$(CONFIG_INFINIBAND) += ib_core.o ib_cm.o iw_cm.o \
2885 $(infiniband-y)
2886 obj-$(CONFIG_INFINIBAND_USER_MAD) += ib_umad.o
2887 -obj-$(CONFIG_INFINIBAND_USER_ACCESS) += ib_uverbs.o ib_ucm.o \
2888 - $(user_access-y)
2889 +obj-$(CONFIG_INFINIBAND_USER_ACCESS) += ib_uverbs.o $(user_access-y)
2890 +obj-$(CONFIG_INFINIBAND_USER_ACCESS_UCM) += ib_ucm.o $(user_access-y)
2891
2892 ib_core-y := packer.o ud_header.o verbs.o cq.o rw.o sysfs.o \
2893 device.o fmr_pool.o cache.o netlink.o \
2894 diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
2895 index c2fba76becd4..b5784cb145f5 100644
2896 --- a/drivers/infiniband/hw/cxgb4/mem.c
2897 +++ b/drivers/infiniband/hw/cxgb4/mem.c
2898 @@ -720,7 +720,7 @@ static int c4iw_set_page(struct ib_mr *ibmr, u64 addr)
2899 {
2900 struct c4iw_mr *mhp = to_c4iw_mr(ibmr);
2901
2902 - if (unlikely(mhp->mpl_len == mhp->max_mpl_len))
2903 + if (unlikely(mhp->mpl_len == mhp->attr.pbl_size))
2904 return -ENOMEM;
2905
2906 mhp->mpl[mhp->mpl_len++] = addr;
2907 diff --git a/drivers/infiniband/hw/hfi1/rc.c b/drivers/infiniband/hw/hfi1/rc.c
2908 index 84c6a6ff4a67..818bac1a4056 100644
2909 --- a/drivers/infiniband/hw/hfi1/rc.c
2910 +++ b/drivers/infiniband/hw/hfi1/rc.c
2911 @@ -273,7 +273,7 @@ int hfi1_make_rc_req(struct rvt_qp *qp, struct hfi1_pkt_state *ps)
2912
2913 lockdep_assert_held(&qp->s_lock);
2914 ps->s_txreq = get_txreq(ps->dev, qp);
2915 - if (IS_ERR(ps->s_txreq))
2916 + if (!ps->s_txreq)
2917 goto bail_no_tx;
2918
2919 ps->s_txreq->phdr.hdr.hdr_type = priv->hdr_type;
2920 diff --git a/drivers/infiniband/hw/hfi1/uc.c b/drivers/infiniband/hw/hfi1/uc.c
2921 index 0b646173ca22..92e033fbb048 100644
2922 --- a/drivers/infiniband/hw/hfi1/uc.c
2923 +++ b/drivers/infiniband/hw/hfi1/uc.c
2924 @@ -1,5 +1,5 @@
2925 /*
2926 - * Copyright(c) 2015, 2016 Intel Corporation.
2927 + * Copyright(c) 2015 - 2018 Intel Corporation.
2928 *
2929 * This file is provided under a dual BSD/GPLv2 license. When using or
2930 * redistributing this file, you may do so under either license.
2931 @@ -72,7 +72,7 @@ int hfi1_make_uc_req(struct rvt_qp *qp, struct hfi1_pkt_state *ps)
2932 int middle = 0;
2933
2934 ps->s_txreq = get_txreq(ps->dev, qp);
2935 - if (IS_ERR(ps->s_txreq))
2936 + if (!ps->s_txreq)
2937 goto bail_no_tx;
2938
2939 if (!(ib_rvt_state_ops[qp->state] & RVT_PROCESS_SEND_OK)) {
2940 diff --git a/drivers/infiniband/hw/hfi1/ud.c b/drivers/infiniband/hw/hfi1/ud.c
2941 index 38c7d9c456fe..37abd150fad3 100644
2942 --- a/drivers/infiniband/hw/hfi1/ud.c
2943 +++ b/drivers/infiniband/hw/hfi1/ud.c
2944 @@ -1,5 +1,5 @@
2945 /*
2946 - * Copyright(c) 2015, 2016 Intel Corporation.
2947 + * Copyright(c) 2015 - 2018 Intel Corporation.
2948 *
2949 * This file is provided under a dual BSD/GPLv2 license. When using or
2950 * redistributing this file, you may do so under either license.
2951 @@ -479,7 +479,7 @@ int hfi1_make_ud_req(struct rvt_qp *qp, struct hfi1_pkt_state *ps)
2952 u32 lid;
2953
2954 ps->s_txreq = get_txreq(ps->dev, qp);
2955 - if (IS_ERR(ps->s_txreq))
2956 + if (!ps->s_txreq)
2957 goto bail_no_tx;
2958
2959 if (!(ib_rvt_state_ops[qp->state] & RVT_PROCESS_NEXT_SEND_OK)) {
2960 diff --git a/drivers/infiniband/hw/hfi1/verbs_txreq.c b/drivers/infiniband/hw/hfi1/verbs_txreq.c
2961 index 873e48ea923f..c4ab2d5b4502 100644
2962 --- a/drivers/infiniband/hw/hfi1/verbs_txreq.c
2963 +++ b/drivers/infiniband/hw/hfi1/verbs_txreq.c
2964 @@ -1,5 +1,5 @@
2965 /*
2966 - * Copyright(c) 2016 - 2017 Intel Corporation.
2967 + * Copyright(c) 2016 - 2018 Intel Corporation.
2968 *
2969 * This file is provided under a dual BSD/GPLv2 license. When using or
2970 * redistributing this file, you may do so under either license.
2971 @@ -94,7 +94,7 @@ struct verbs_txreq *__get_txreq(struct hfi1_ibdev *dev,
2972 struct rvt_qp *qp)
2973 __must_hold(&qp->s_lock)
2974 {
2975 - struct verbs_txreq *tx = ERR_PTR(-EBUSY);
2976 + struct verbs_txreq *tx = NULL;
2977
2978 write_seqlock(&dev->txwait_lock);
2979 if (ib_rvt_state_ops[qp->state] & RVT_PROCESS_RECV_OK) {
2980 diff --git a/drivers/infiniband/hw/hfi1/verbs_txreq.h b/drivers/infiniband/hw/hfi1/verbs_txreq.h
2981 index 76216f2ef35a..22fc5ddf01ca 100644
2982 --- a/drivers/infiniband/hw/hfi1/verbs_txreq.h
2983 +++ b/drivers/infiniband/hw/hfi1/verbs_txreq.h
2984 @@ -1,5 +1,5 @@
2985 /*
2986 - * Copyright(c) 2016 Intel Corporation.
2987 + * Copyright(c) 2016 - 2018 Intel Corporation.
2988 *
2989 * This file is provided under a dual BSD/GPLv2 license. When using or
2990 * redistributing this file, you may do so under either license.
2991 @@ -83,7 +83,7 @@ static inline struct verbs_txreq *get_txreq(struct hfi1_ibdev *dev,
2992 if (unlikely(!tx)) {
2993 /* call slow path to get the lock */
2994 tx = __get_txreq(dev, qp);
2995 - if (IS_ERR(tx))
2996 + if (!tx)
2997 return tx;
2998 }
2999 tx->qp = qp;
3000 diff --git a/drivers/media/rc/ir-mce_kbd-decoder.c b/drivers/media/rc/ir-mce_kbd-decoder.c
3001 index 7c572a643656..2a1728edb3c6 100644
3002 --- a/drivers/media/rc/ir-mce_kbd-decoder.c
3003 +++ b/drivers/media/rc/ir-mce_kbd-decoder.c
3004 @@ -130,6 +130,8 @@ static void mce_kbd_rx_timeout(unsigned long data)
3005
3006 for (i = 0; i < MCIR2_MASK_KEYS_START; i++)
3007 input_report_key(mce_kbd->idev, kbd_keycodes[i], 0);
3008 +
3009 + input_sync(mce_kbd->idev);
3010 }
3011
3012 static enum mce_kbd_mode mce_kbd_mode(struct mce_kbd_dec *data)
3013 diff --git a/drivers/misc/ibmasm/ibmasmfs.c b/drivers/misc/ibmasm/ibmasmfs.c
3014 index e05c3245930a..fa840666bdd1 100644
3015 --- a/drivers/misc/ibmasm/ibmasmfs.c
3016 +++ b/drivers/misc/ibmasm/ibmasmfs.c
3017 @@ -507,35 +507,14 @@ static int remote_settings_file_close(struct inode *inode, struct file *file)
3018 static ssize_t remote_settings_file_read(struct file *file, char __user *buf, size_t count, loff_t *offset)
3019 {
3020 void __iomem *address = (void __iomem *)file->private_data;
3021 - unsigned char *page;
3022 - int retval;
3023 int len = 0;
3024 unsigned int value;
3025 -
3026 - if (*offset < 0)
3027 - return -EINVAL;
3028 - if (count == 0 || count > 1024)
3029 - return 0;
3030 - if (*offset != 0)
3031 - return 0;
3032 -
3033 - page = (unsigned char *)__get_free_page(GFP_KERNEL);
3034 - if (!page)
3035 - return -ENOMEM;
3036 + char lbuf[20];
3037
3038 value = readl(address);
3039 - len = sprintf(page, "%d\n", value);
3040 -
3041 - if (copy_to_user(buf, page, len)) {
3042 - retval = -EFAULT;
3043 - goto exit;
3044 - }
3045 - *offset += len;
3046 - retval = len;
3047 + len = snprintf(lbuf, sizeof(lbuf), "%d\n", value);
3048
3049 -exit:
3050 - free_page((unsigned long)page);
3051 - return retval;
3052 + return simple_read_from_buffer(buf, count, offset, lbuf, len);
3053 }
3054
3055 static ssize_t remote_settings_file_write(struct file *file, const char __user *ubuff, size_t count, loff_t *offset)
3056 diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw_balloon.c
3057 index efd733472a35..56c6f79a5c5a 100644
3058 --- a/drivers/misc/vmw_balloon.c
3059 +++ b/drivers/misc/vmw_balloon.c
3060 @@ -467,7 +467,7 @@ static int vmballoon_send_batched_lock(struct vmballoon *b,
3061 unsigned int num_pages, bool is_2m_pages, unsigned int *target)
3062 {
3063 unsigned long status;
3064 - unsigned long pfn = page_to_pfn(b->page);
3065 + unsigned long pfn = PHYS_PFN(virt_to_phys(b->batch_page));
3066
3067 STATS_INC(b->stats.lock[is_2m_pages]);
3068
3069 @@ -515,7 +515,7 @@ static bool vmballoon_send_batched_unlock(struct vmballoon *b,
3070 unsigned int num_pages, bool is_2m_pages, unsigned int *target)
3071 {
3072 unsigned long status;
3073 - unsigned long pfn = page_to_pfn(b->page);
3074 + unsigned long pfn = PHYS_PFN(virt_to_phys(b->batch_page));
3075
3076 STATS_INC(b->stats.unlock[is_2m_pages]);
3077
3078 diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
3079 index de31e20dc56c..6a2cbbba29aa 100644
3080 --- a/drivers/mmc/host/dw_mmc.c
3081 +++ b/drivers/mmc/host/dw_mmc.c
3082 @@ -1089,8 +1089,8 @@ static void dw_mci_ctrl_thld(struct dw_mci *host, struct mmc_data *data)
3083 * It's used when HS400 mode is enabled.
3084 */
3085 if (data->flags & MMC_DATA_WRITE &&
3086 - !(host->timing != MMC_TIMING_MMC_HS400))
3087 - return;
3088 + host->timing != MMC_TIMING_MMC_HS400)
3089 + goto disable;
3090
3091 if (data->flags & MMC_DATA_WRITE)
3092 enable = SDMMC_CARD_WR_THR_EN;
3093 @@ -1098,7 +1098,8 @@ static void dw_mci_ctrl_thld(struct dw_mci *host, struct mmc_data *data)
3094 enable = SDMMC_CARD_RD_THR_EN;
3095
3096 if (host->timing != MMC_TIMING_MMC_HS200 &&
3097 - host->timing != MMC_TIMING_UHS_SDR104)
3098 + host->timing != MMC_TIMING_UHS_SDR104 &&
3099 + host->timing != MMC_TIMING_MMC_HS400)
3100 goto disable;
3101
3102 blksz_depth = blksz / (1 << host->data_shift);
3103 diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
3104 index 8b941f814472..c81de2f25281 100644
3105 --- a/drivers/mmc/host/sdhci-esdhc-imx.c
3106 +++ b/drivers/mmc/host/sdhci-esdhc-imx.c
3107 @@ -305,6 +305,15 @@ static u32 esdhc_readl_le(struct sdhci_host *host, int reg)
3108
3109 if (imx_data->socdata->flags & ESDHC_FLAG_HS400)
3110 val |= SDHCI_SUPPORT_HS400;
3111 +
3112 + /*
3113 + * Do not advertise faster UHS modes if there are no
3114 + * pinctrl states for 100MHz/200MHz.
3115 + */
3116 + if (IS_ERR_OR_NULL(imx_data->pins_100mhz) ||
3117 + IS_ERR_OR_NULL(imx_data->pins_200mhz))
3118 + val &= ~(SDHCI_SUPPORT_SDR50 | SDHCI_SUPPORT_DDR50
3119 + | SDHCI_SUPPORT_SDR104 | SDHCI_SUPPORT_HS400);
3120 }
3121 }
3122
3123 @@ -1135,18 +1144,6 @@ sdhci_esdhc_imx_probe_dt(struct platform_device *pdev,
3124 ESDHC_PINCTRL_STATE_100MHZ);
3125 imx_data->pins_200mhz = pinctrl_lookup_state(imx_data->pinctrl,
3126 ESDHC_PINCTRL_STATE_200MHZ);
3127 - if (IS_ERR(imx_data->pins_100mhz) ||
3128 - IS_ERR(imx_data->pins_200mhz)) {
3129 - dev_warn(mmc_dev(host->mmc),
3130 - "could not get ultra high speed state, work on normal mode\n");
3131 - /*
3132 - * fall back to not supporting uhs by specifying no
3133 - * 1.8v quirk
3134 - */
3135 - host->quirks2 |= SDHCI_QUIRK2_NO_1_8_V;
3136 - }
3137 - } else {
3138 - host->quirks2 |= SDHCI_QUIRK2_NO_1_8_V;
3139 }
3140
3141 /* call to generic mmc_of_parse to support additional capabilities */
3142 diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
3143 index 3d4724e38aa9..4cac4755abef 100644
3144 --- a/drivers/nvme/host/pci.c
3145 +++ b/drivers/nvme/host/pci.c
3146 @@ -1233,17 +1233,15 @@ static int nvme_cmb_qdepth(struct nvme_dev *dev, int nr_io_queues,
3147 static int nvme_alloc_sq_cmds(struct nvme_dev *dev, struct nvme_queue *nvmeq,
3148 int qid, int depth)
3149 {
3150 - if (qid && dev->cmb && use_cmb_sqes && NVME_CMB_SQS(dev->cmbsz)) {
3151 - unsigned offset = (qid - 1) * roundup(SQ_SIZE(depth),
3152 - dev->ctrl.page_size);
3153 - nvmeq->sq_dma_addr = dev->cmb_bus_addr + offset;
3154 - nvmeq->sq_cmds_io = dev->cmb + offset;
3155 - } else {
3156 - nvmeq->sq_cmds = dma_alloc_coherent(dev->dev, SQ_SIZE(depth),
3157 - &nvmeq->sq_dma_addr, GFP_KERNEL);
3158 - if (!nvmeq->sq_cmds)
3159 - return -ENOMEM;
3160 - }
3161 +
3162 + /* CMB SQEs will be mapped before creation */
3163 + if (qid && dev->cmb && use_cmb_sqes && NVME_CMB_SQS(dev->cmbsz))
3164 + return 0;
3165 +
3166 + nvmeq->sq_cmds = dma_alloc_coherent(dev->dev, SQ_SIZE(depth),
3167 + &nvmeq->sq_dma_addr, GFP_KERNEL);
3168 + if (!nvmeq->sq_cmds)
3169 + return -ENOMEM;
3170
3171 return 0;
3172 }
3173 @@ -1320,6 +1318,13 @@ static int nvme_create_queue(struct nvme_queue *nvmeq, int qid)
3174 struct nvme_dev *dev = nvmeq->dev;
3175 int result;
3176
3177 + if (qid && dev->cmb && use_cmb_sqes && NVME_CMB_SQS(dev->cmbsz)) {
3178 + unsigned offset = (qid - 1) * roundup(SQ_SIZE(nvmeq->q_depth),
3179 + dev->ctrl.page_size);
3180 + nvmeq->sq_dma_addr = dev->cmb_bus_addr + offset;
3181 + nvmeq->sq_cmds_io = dev->cmb + offset;
3182 + }
3183 +
3184 nvmeq->cq_vector = qid - 1;
3185 result = adapter_alloc_cq(dev, qid, nvmeq);
3186 if (result < 0)
3187 diff --git a/drivers/scsi/megaraid/megaraid_sas.h b/drivers/scsi/megaraid/megaraid_sas.h
3188 index a6722c93a295..81de4a1fbb9b 100644
3189 --- a/drivers/scsi/megaraid/megaraid_sas.h
3190 +++ b/drivers/scsi/megaraid/megaraid_sas.h
3191 @@ -1504,6 +1504,13 @@ enum FW_BOOT_CONTEXT {
3192
3193 #define MR_CAN_HANDLE_SYNC_CACHE_OFFSET 0X01000000
3194
3195 +enum MR_ADAPTER_TYPE {
3196 + MFI_SERIES = 1,
3197 + THUNDERBOLT_SERIES = 2,
3198 + INVADER_SERIES = 3,
3199 + VENTURA_SERIES = 4,
3200 +};
3201 +
3202 /*
3203 * register set for both 1068 and 1078 controllers
3204 * structure extended for 1078 registers
3205 @@ -2092,6 +2099,7 @@ enum MR_PD_TYPE {
3206
3207 struct megasas_instance {
3208
3209 + unsigned int *reply_map;
3210 __le32 *producer;
3211 dma_addr_t producer_h;
3212 __le32 *consumer;
3213 @@ -2236,12 +2244,12 @@ struct megasas_instance {
3214 bool dev_handle;
3215 bool fw_sync_cache_support;
3216 u32 mfi_frame_size;
3217 - bool is_ventura;
3218 bool msix_combined;
3219 u16 max_raid_mapsize;
3220 /* preffered count to send as LDIO irrspective of FP capable.*/
3221 u8 r1_ldio_hint_default;
3222 u32 nvme_page_size;
3223 + u8 adapter_type;
3224 };
3225 struct MR_LD_VF_MAP {
3226 u32 size;
3227 diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
3228 index 4beb4dd2bee8..985378e4bb6f 100644
3229 --- a/drivers/scsi/megaraid/megaraid_sas_base.c
3230 +++ b/drivers/scsi/megaraid/megaraid_sas_base.c
3231 @@ -2023,7 +2023,7 @@ void megaraid_sas_kill_hba(struct megasas_instance *instance)
3232 msleep(1000);
3233 if ((instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0073SKINNY) ||
3234 (instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0071SKINNY) ||
3235 - (instance->ctrl_context)) {
3236 + (instance->adapter_type != MFI_SERIES)) {
3237 writel(MFI_STOP_ADP, &instance->reg_set->doorbell);
3238 /* Flush */
3239 readl(&instance->reg_set->doorbell);
3240 @@ -2494,7 +2494,8 @@ int megasas_sriov_start_heartbeat(struct megasas_instance *instance,
3241 dev_warn(&instance->pdev->dev, "SR-IOV: Starting heartbeat for scsi%d\n",
3242 instance->host->host_no);
3243
3244 - if (instance->ctrl_context && !instance->mask_interrupts)
3245 + if ((instance->adapter_type != MFI_SERIES) &&
3246 + !instance->mask_interrupts)
3247 retval = megasas_issue_blocked_cmd(instance, cmd,
3248 MEGASAS_ROUTINE_WAIT_TIME_VF);
3249 else
3250 @@ -2790,7 +2791,9 @@ static int megasas_reset_bus_host(struct scsi_cmnd *scmd)
3251 /*
3252 * First wait for all commands to complete
3253 */
3254 - if (instance->ctrl_context) {
3255 + if (instance->adapter_type == MFI_SERIES) {
3256 + ret = megasas_generic_reset(scmd);
3257 + } else {
3258 struct megasas_cmd_fusion *cmd;
3259 cmd = (struct megasas_cmd_fusion *)scmd->SCp.ptr;
3260 if (cmd)
3261 @@ -2798,8 +2801,7 @@ static int megasas_reset_bus_host(struct scsi_cmnd *scmd)
3262 MEGA_MPI2_RAID_DEFAULT_IO_FRAME_SIZE);
3263 ret = megasas_reset_fusion(scmd->device->host,
3264 SCSIIO_TIMEOUT_OCR);
3265 - } else
3266 - ret = megasas_generic_reset(scmd);
3267 + }
3268
3269 return ret;
3270 }
3271 @@ -2816,7 +2818,7 @@ static int megasas_task_abort(struct scsi_cmnd *scmd)
3272
3273 instance = (struct megasas_instance *)scmd->device->host->hostdata;
3274
3275 - if (instance->ctrl_context)
3276 + if (instance->adapter_type != MFI_SERIES)
3277 ret = megasas_task_abort_fusion(scmd);
3278 else {
3279 sdev_printk(KERN_NOTICE, scmd->device, "TASK ABORT not supported\n");
3280 @@ -2838,7 +2840,7 @@ static int megasas_reset_target(struct scsi_cmnd *scmd)
3281
3282 instance = (struct megasas_instance *)scmd->device->host->hostdata;
3283
3284 - if (instance->ctrl_context)
3285 + if (instance->adapter_type != MFI_SERIES)
3286 ret = megasas_reset_target_fusion(scmd);
3287 else {
3288 sdev_printk(KERN_NOTICE, scmd->device, "TARGET RESET not supported\n");
3289 @@ -3715,7 +3717,7 @@ megasas_transition_to_ready(struct megasas_instance *instance, int ocr)
3290 PCI_DEVICE_ID_LSI_SAS0073SKINNY) ||
3291 (instance->pdev->device ==
3292 PCI_DEVICE_ID_LSI_SAS0071SKINNY) ||
3293 - (instance->ctrl_context))
3294 + (instance->adapter_type != MFI_SERIES))
3295 writel(
3296 MFI_INIT_CLEAR_HANDSHAKE|MFI_INIT_HOTPLUG,
3297 &instance->reg_set->doorbell);
3298 @@ -3733,7 +3735,7 @@ megasas_transition_to_ready(struct megasas_instance *instance, int ocr)
3299 PCI_DEVICE_ID_LSI_SAS0073SKINNY) ||
3300 (instance->pdev->device ==
3301 PCI_DEVICE_ID_LSI_SAS0071SKINNY) ||
3302 - (instance->ctrl_context))
3303 + (instance->adapter_type != MFI_SERIES))
3304 writel(MFI_INIT_HOTPLUG,
3305 &instance->reg_set->doorbell);
3306 else
3307 @@ -3753,11 +3755,11 @@ megasas_transition_to_ready(struct megasas_instance *instance, int ocr)
3308 PCI_DEVICE_ID_LSI_SAS0073SKINNY) ||
3309 (instance->pdev->device ==
3310 PCI_DEVICE_ID_LSI_SAS0071SKINNY) ||
3311 - (instance->ctrl_context)) {
3312 + (instance->adapter_type != MFI_SERIES)) {
3313 writel(MFI_RESET_FLAGS,
3314 &instance->reg_set->doorbell);
3315
3316 - if (instance->ctrl_context) {
3317 + if (instance->adapter_type != MFI_SERIES) {
3318 for (i = 0; i < (10 * 1000); i += 20) {
3319 if (readl(
3320 &instance->
3321 @@ -3924,7 +3926,8 @@ static int megasas_create_frame_pool(struct megasas_instance *instance)
3322 * max_sge_sz = 12 byte (sizeof megasas_sge64)
3323 * Total 192 byte (3 MFI frame of 64 byte)
3324 */
3325 - frame_count = instance->ctrl_context ? (3 + 1) : (15 + 1);
3326 + frame_count = (instance->adapter_type == MFI_SERIES) ?
3327 + (15 + 1) : (3 + 1);
3328 instance->mfi_frame_size = MEGAMFI_FRAME_SIZE * frame_count;
3329 /*
3330 * Use DMA pool facility provided by PCI layer
3331 @@ -3979,7 +3982,7 @@ static int megasas_create_frame_pool(struct megasas_instance *instance)
3332 memset(cmd->frame, 0, instance->mfi_frame_size);
3333 cmd->frame->io.context = cpu_to_le32(cmd->index);
3334 cmd->frame->io.pad_0 = 0;
3335 - if (!instance->ctrl_context && reset_devices)
3336 + if ((instance->adapter_type == MFI_SERIES) && reset_devices)
3337 cmd->frame->hdr.cmd = MFI_CMD_INVALID;
3338 }
3339
3340 @@ -4099,7 +4102,7 @@ int megasas_alloc_cmds(struct megasas_instance *instance)
3341 inline int
3342 dcmd_timeout_ocr_possible(struct megasas_instance *instance) {
3343
3344 - if (!instance->ctrl_context)
3345 + if (instance->adapter_type == MFI_SERIES)
3346 return KILL_ADAPTER;
3347 else if (instance->unload ||
3348 test_bit(MEGASAS_FUSION_IN_RESET, &instance->reset_flags))
3349 @@ -4143,7 +4146,8 @@ megasas_get_pd_info(struct megasas_instance *instance, struct scsi_device *sdev)
3350 dcmd->sgl.sge32[0].phys_addr = cpu_to_le32(instance->pd_info_h);
3351 dcmd->sgl.sge32[0].length = cpu_to_le32(sizeof(struct MR_PD_INFO));
3352
3353 - if (instance->ctrl_context && !instance->mask_interrupts)
3354 + if ((instance->adapter_type != MFI_SERIES) &&
3355 + !instance->mask_interrupts)
3356 ret = megasas_issue_blocked_cmd(instance, cmd, MFI_IO_TIMEOUT_SECS);
3357 else
3358 ret = megasas_issue_polled(instance, cmd);
3359 @@ -4240,7 +4244,8 @@ megasas_get_pd_list(struct megasas_instance *instance)
3360 dcmd->sgl.sge32[0].phys_addr = cpu_to_le32(ci_h);
3361 dcmd->sgl.sge32[0].length = cpu_to_le32(MEGASAS_MAX_PD * sizeof(struct MR_PD_LIST));
3362
3363 - if (instance->ctrl_context && !instance->mask_interrupts)
3364 + if ((instance->adapter_type != MFI_SERIES) &&
3365 + !instance->mask_interrupts)
3366 ret = megasas_issue_blocked_cmd(instance, cmd,
3367 MFI_IO_TIMEOUT_SECS);
3368 else
3369 @@ -4251,7 +4256,7 @@ megasas_get_pd_list(struct megasas_instance *instance)
3370 dev_info(&instance->pdev->dev, "MR_DCMD_PD_LIST_QUERY "
3371 "failed/not supported by firmware\n");
3372
3373 - if (instance->ctrl_context)
3374 + if (instance->adapter_type != MFI_SERIES)
3375 megaraid_sas_kill_hba(instance);
3376 else
3377 instance->pd_list_not_supported = 1;
3378 @@ -4372,7 +4377,8 @@ megasas_get_ld_list(struct megasas_instance *instance)
3379 dcmd->sgl.sge32[0].length = cpu_to_le32(sizeof(struct MR_LD_LIST));
3380 dcmd->pad_0 = 0;
3381
3382 - if (instance->ctrl_context && !instance->mask_interrupts)
3383 + if ((instance->adapter_type != MFI_SERIES) &&
3384 + !instance->mask_interrupts)
3385 ret = megasas_issue_blocked_cmd(instance, cmd,
3386 MFI_IO_TIMEOUT_SECS);
3387 else
3388 @@ -4491,7 +4497,8 @@ megasas_ld_list_query(struct megasas_instance *instance, u8 query_type)
3389 dcmd->sgl.sge32[0].length = cpu_to_le32(sizeof(struct MR_LD_TARGETID_LIST));
3390 dcmd->pad_0 = 0;
3391
3392 - if (instance->ctrl_context && !instance->mask_interrupts)
3393 + if ((instance->adapter_type != MFI_SERIES) &&
3394 + !instance->mask_interrupts)
3395 ret = megasas_issue_blocked_cmd(instance, cmd, MFI_IO_TIMEOUT_SECS);
3396 else
3397 ret = megasas_issue_polled(instance, cmd);
3398 @@ -4664,7 +4671,8 @@ megasas_get_ctrl_info(struct megasas_instance *instance)
3399 dcmd->sgl.sge32[0].length = cpu_to_le32(sizeof(struct megasas_ctrl_info));
3400 dcmd->mbox.b[0] = 1;
3401
3402 - if (instance->ctrl_context && !instance->mask_interrupts)
3403 + if ((instance->adapter_type != MFI_SERIES) &&
3404 + !instance->mask_interrupts)
3405 ret = megasas_issue_blocked_cmd(instance, cmd, MFI_IO_TIMEOUT_SECS);
3406 else
3407 ret = megasas_issue_polled(instance, cmd);
3408 @@ -4783,7 +4791,8 @@ int megasas_set_crash_dump_params(struct megasas_instance *instance,
3409 dcmd->sgl.sge32[0].phys_addr = cpu_to_le32(instance->crash_dump_h);
3410 dcmd->sgl.sge32[0].length = cpu_to_le32(CRASH_DMA_BUF_SIZE);
3411
3412 - if (instance->ctrl_context && !instance->mask_interrupts)
3413 + if ((instance->adapter_type != MFI_SERIES) &&
3414 + !instance->mask_interrupts)
3415 ret = megasas_issue_blocked_cmd(instance, cmd, MFI_IO_TIMEOUT_SECS);
3416 else
3417 ret = megasas_issue_polled(instance, cmd);
3418 @@ -5129,6 +5138,26 @@ megasas_setup_jbod_map(struct megasas_instance *instance)
3419 instance->use_seqnum_jbod_fp = false;
3420 }
3421
3422 +static void megasas_setup_reply_map(struct megasas_instance *instance)
3423 +{
3424 + const struct cpumask *mask;
3425 + unsigned int queue, cpu;
3426 +
3427 + for (queue = 0; queue < instance->msix_vectors; queue++) {
3428 + mask = pci_irq_get_affinity(instance->pdev, queue);
3429 + if (!mask)
3430 + goto fallback;
3431 +
3432 + for_each_cpu(cpu, mask)
3433 + instance->reply_map[cpu] = queue;
3434 + }
3435 + return;
3436 +
3437 +fallback:
3438 + for_each_possible_cpu(cpu)
3439 + instance->reply_map[cpu] = cpu % instance->msix_vectors;
3440 +}
3441 +
3442 /**
3443 * megasas_init_fw - Initializes the FW
3444 * @instance: Adapter soft state
3445 @@ -5170,7 +5199,7 @@ static int megasas_init_fw(struct megasas_instance *instance)
3446
3447 reg_set = instance->reg_set;
3448
3449 - if (fusion)
3450 + if (instance->adapter_type != MFI_SERIES)
3451 instance->instancet = &megasas_instance_template_fusion;
3452 else {
3453 switch (instance->pdev->device) {
3454 @@ -5211,7 +5240,7 @@ static int megasas_init_fw(struct megasas_instance *instance)
3455 goto fail_ready_state;
3456 }
3457
3458 - if (instance->is_ventura) {
3459 + if (instance->adapter_type == VENTURA_SERIES) {
3460 scratch_pad_3 =
3461 readl(&instance->reg_set->outbound_scratch_pad_3);
3462 instance->max_raid_mapsize = ((scratch_pad_3 >>
3463 @@ -5229,7 +5258,8 @@ static int megasas_init_fw(struct megasas_instance *instance)
3464 (&instance->reg_set->outbound_scratch_pad_2);
3465 /* Check max MSI-X vectors */
3466 if (fusion) {
3467 - if (fusion->adapter_type == THUNDERBOLT_SERIES) { /* Thunderbolt Series*/
3468 + if (instance->adapter_type == THUNDERBOLT_SERIES) {
3469 + /* Thunderbolt Series*/
3470 instance->msix_vectors = (scratch_pad_2
3471 & MR_MAX_REPLY_QUEUES_OFFSET) + 1;
3472 fw_msix_count = instance->msix_vectors;
3473 @@ -5293,6 +5323,8 @@ static int megasas_init_fw(struct megasas_instance *instance)
3474 goto fail_setup_irqs;
3475 }
3476
3477 + megasas_setup_reply_map(instance);
3478 +
3479 dev_info(&instance->pdev->dev,
3480 "firmware supports msix\t: (%d)", fw_msix_count);
3481 dev_info(&instance->pdev->dev,
3482 @@ -5319,7 +5351,7 @@ static int megasas_init_fw(struct megasas_instance *instance)
3483 if (instance->instancet->init_adapter(instance))
3484 goto fail_init_adapter;
3485
3486 - if (instance->is_ventura) {
3487 + if (instance->adapter_type == VENTURA_SERIES) {
3488 scratch_pad_4 =
3489 readl(&instance->reg_set->outbound_scratch_pad_4);
3490 if ((scratch_pad_4 & MR_NVME_PAGE_SIZE_MASK) >=
3491 @@ -5355,7 +5387,7 @@ static int megasas_init_fw(struct megasas_instance *instance)
3492 memset(instance->ld_ids, 0xff, MEGASAS_MAX_LD_IDS);
3493
3494 /* stream detection initialization */
3495 - if (instance->is_ventura && fusion) {
3496 + if (instance->adapter_type == VENTURA_SERIES) {
3497 fusion->stream_detect_by_ld =
3498 kzalloc(sizeof(struct LD_STREAM_DETECT *)
3499 * MAX_LOGICAL_DRIVES_EXT,
3500 @@ -5804,7 +5836,8 @@ megasas_get_target_prop(struct megasas_instance *instance,
3501 dcmd->sgl.sge32[0].length =
3502 cpu_to_le32(sizeof(struct MR_TARGET_PROPERTIES));
3503
3504 - if (instance->ctrl_context && !instance->mask_interrupts)
3505 + if ((instance->adapter_type != MFI_SERIES) &&
3506 + !instance->mask_interrupts)
3507 ret = megasas_issue_blocked_cmd(instance,
3508 cmd, MFI_IO_TIMEOUT_SECS);
3509 else
3510 @@ -5965,6 +5998,125 @@ megasas_set_dma_mask(struct pci_dev *pdev)
3511 return 1;
3512 }
3513
3514 +/*
3515 + * megasas_set_adapter_type - Set adapter type.
3516 + * Supported controllers can be divided in
3517 + * 4 categories- enum MR_ADAPTER_TYPE {
3518 + * MFI_SERIES = 1,
3519 + * THUNDERBOLT_SERIES = 2,
3520 + * INVADER_SERIES = 3,
3521 + * VENTURA_SERIES = 4,
3522 + * };
3523 + * @instance: Adapter soft state
3524 + * return: void
3525 + */
3526 +static inline void megasas_set_adapter_type(struct megasas_instance *instance)
3527 +{
3528 + switch (instance->pdev->device) {
3529 + case PCI_DEVICE_ID_LSI_VENTURA:
3530 + case PCI_DEVICE_ID_LSI_HARPOON:
3531 + case PCI_DEVICE_ID_LSI_TOMCAT:
3532 + case PCI_DEVICE_ID_LSI_VENTURA_4PORT:
3533 + case PCI_DEVICE_ID_LSI_CRUSADER_4PORT:
3534 + instance->adapter_type = VENTURA_SERIES;
3535 + break;
3536 + case PCI_DEVICE_ID_LSI_FUSION:
3537 + case PCI_DEVICE_ID_LSI_PLASMA:
3538 + instance->adapter_type = THUNDERBOLT_SERIES;
3539 + break;
3540 + case PCI_DEVICE_ID_LSI_INVADER:
3541 + case PCI_DEVICE_ID_LSI_INTRUDER:
3542 + case PCI_DEVICE_ID_LSI_INTRUDER_24:
3543 + case PCI_DEVICE_ID_LSI_CUTLASS_52:
3544 + case PCI_DEVICE_ID_LSI_CUTLASS_53:
3545 + case PCI_DEVICE_ID_LSI_FURY:
3546 + instance->adapter_type = INVADER_SERIES;
3547 + break;
3548 + default: /* For all other supported controllers */
3549 + instance->adapter_type = MFI_SERIES;
3550 + break;
3551 + }
3552 +}
3553 +
3554 +static inline int megasas_alloc_mfi_ctrl_mem(struct megasas_instance *instance)
3555 +{
3556 + instance->producer = pci_alloc_consistent(instance->pdev, sizeof(u32),
3557 + &instance->producer_h);
3558 + instance->consumer = pci_alloc_consistent(instance->pdev, sizeof(u32),
3559 + &instance->consumer_h);
3560 +
3561 + if (!instance->producer || !instance->consumer) {
3562 + dev_err(&instance->pdev->dev,
3563 + "Failed to allocate memory for producer, consumer\n");
3564 + return -1;
3565 + }
3566 +
3567 + *instance->producer = 0;
3568 + *instance->consumer = 0;
3569 + return 0;
3570 +}
3571 +
3572 +/**
3573 + * megasas_alloc_ctrl_mem - Allocate per controller memory for core data
3574 + * structures which are not common across MFI
3575 + * adapters and fusion adapters.
3576 + * For MFI based adapters, allocate producer and
3577 + * consumer buffers. For fusion adapters, allocate
3578 + * memory for fusion context.
3579 + * @instance: Adapter soft state
3580 + * return: 0 for SUCCESS
3581 + */
3582 +static int megasas_alloc_ctrl_mem(struct megasas_instance *instance)
3583 +{
3584 + instance->reply_map = kzalloc(sizeof(unsigned int) * nr_cpu_ids,
3585 + GFP_KERNEL);
3586 + if (!instance->reply_map)
3587 + return -ENOMEM;
3588 +
3589 + switch (instance->adapter_type) {
3590 + case MFI_SERIES:
3591 + if (megasas_alloc_mfi_ctrl_mem(instance))
3592 + goto fail;
3593 + break;
3594 + case VENTURA_SERIES:
3595 + case THUNDERBOLT_SERIES:
3596 + case INVADER_SERIES:
3597 + if (megasas_alloc_fusion_context(instance))
3598 + goto fail;
3599 + break;
3600 + }
3601 +
3602 + return 0;
3603 + fail:
3604 + kfree(instance->reply_map);
3605 + instance->reply_map = NULL;
3606 + return -ENOMEM;
3607 +}
3608 +
3609 +/*
3610 + * megasas_free_ctrl_mem - Free fusion context for fusion adapters and
3611 + * producer, consumer buffers for MFI adapters
3612 + *
3613 + * @instance - Adapter soft instance
3614 + *
3615 + */
3616 +static inline void megasas_free_ctrl_mem(struct megasas_instance *instance)
3617 +{
3618 + kfree(instance->reply_map);
3619 + if (instance->adapter_type == MFI_SERIES) {
3620 + if (instance->producer)
3621 + pci_free_consistent(instance->pdev, sizeof(u32),
3622 + instance->producer,
3623 + instance->producer_h);
3624 + if (instance->consumer)
3625 + pci_free_consistent(instance->pdev, sizeof(u32),
3626 + instance->consumer,
3627 + instance->consumer_h);
3628 + } else {
3629 + megasas_free_fusion_context(instance);
3630 + }
3631 +}
3632 +
3633 /**
3634 * megasas_probe_one - PCI hotplug entry point
3635 * @pdev: PCI device structure
3636 @@ -5977,7 +6129,6 @@ static int megasas_probe_one(struct pci_dev *pdev,
3637 struct Scsi_Host *host;
3638 struct megasas_instance *instance;
3639 u16 control = 0;
3640 - struct fusion_context *fusion = NULL;
3641
3642 /* Reset MSI-X in the kdump kernel */
3643 if (reset_devices) {
3644 @@ -6022,56 +6173,10 @@ static int megasas_probe_one(struct pci_dev *pdev,
3645 atomic_set(&instance->fw_reset_no_pci_access, 0);
3646 instance->pdev = pdev;
3647
3648 - switch (instance->pdev->device) {
3649 - case PCI_DEVICE_ID_LSI_VENTURA:
3650 - case PCI_DEVICE_ID_LSI_HARPOON:
3651 - case PCI_DEVICE_ID_LSI_TOMCAT:
3652 - case PCI_DEVICE_ID_LSI_VENTURA_4PORT:
3653 - case PCI_DEVICE_ID_LSI_CRUSADER_4PORT:
3654 - instance->is_ventura = true;
3655 - case PCI_DEVICE_ID_LSI_FUSION:
3656 - case PCI_DEVICE_ID_LSI_PLASMA:
3657 - case PCI_DEVICE_ID_LSI_INVADER:
3658 - case PCI_DEVICE_ID_LSI_FURY:
3659 - case PCI_DEVICE_ID_LSI_INTRUDER:
3660 - case PCI_DEVICE_ID_LSI_INTRUDER_24:
3661 - case PCI_DEVICE_ID_LSI_CUTLASS_52:
3662 - case PCI_DEVICE_ID_LSI_CUTLASS_53:
3663 - {
3664 - if (megasas_alloc_fusion_context(instance)) {
3665 - megasas_free_fusion_context(instance);
3666 - goto fail_alloc_dma_buf;
3667 - }
3668 - fusion = instance->ctrl_context;
3669 -
3670 - if ((instance->pdev->device == PCI_DEVICE_ID_LSI_FUSION) ||
3671 - (instance->pdev->device == PCI_DEVICE_ID_LSI_PLASMA))
3672 - fusion->adapter_type = THUNDERBOLT_SERIES;
3673 - else if (instance->is_ventura)
3674 - fusion->adapter_type = VENTURA_SERIES;
3675 - else
3676 - fusion->adapter_type = INVADER_SERIES;
3677 - }
3678 - break;
3679 - default: /* For all other supported controllers */
3680 + megasas_set_adapter_type(instance);
3681
3682 - instance->producer =
3683 - pci_alloc_consistent(pdev, sizeof(u32),
3684 - &instance->producer_h);
3685 - instance->consumer =
3686 - pci_alloc_consistent(pdev, sizeof(u32),
3687 - &instance->consumer_h);
3688 -
3689 - if (!instance->producer || !instance->consumer) {
3690 - dev_printk(KERN_DEBUG, &pdev->dev, "Failed to allocate "
3691 - "memory for producer, consumer\n");
3692 - goto fail_alloc_dma_buf;
3693 - }
3694 -
3695 - *instance->producer = 0;
3696 - *instance->consumer = 0;
3697 - break;
3698 - }
3699 + if (megasas_alloc_ctrl_mem(instance))
3700 + goto fail_alloc_dma_buf;
3701
3702 /* Crash dump feature related initialisation*/
3703 instance->drv_buf_index = 0;
3704 @@ -6166,7 +6271,7 @@ static int megasas_probe_one(struct pci_dev *pdev,
3705 instance->disableOnlineCtrlReset = 1;
3706 instance->UnevenSpanSupport = 0;
3707
3708 - if (instance->ctrl_context) {
3709 + if (instance->adapter_type != MFI_SERIES) {
3710 INIT_WORK(&instance->work_init, megasas_fusion_ocr_wq);
3711 INIT_WORK(&instance->crash_init, megasas_fusion_crash_dump_wq);
3712 } else
3713 @@ -6246,7 +6351,7 @@ static int megasas_probe_one(struct pci_dev *pdev,
3714 instance->instancet->disable_intr(instance);
3715 megasas_destroy_irqs(instance);
3716
3717 - if (instance->ctrl_context)
3718 + if (instance->adapter_type != MFI_SERIES)
3719 megasas_release_fusion(instance);
3720 else
3721 megasas_release_mfi(instance);
3722 @@ -6267,14 +6372,8 @@ static int megasas_probe_one(struct pci_dev *pdev,
3723 pci_free_consistent(pdev, sizeof(struct MR_TARGET_PROPERTIES),
3724 instance->tgt_prop,
3725 instance->tgt_prop_h);
3726 - if (instance->producer)
3727 - pci_free_consistent(pdev, sizeof(u32), instance->producer,
3728 - instance->producer_h);
3729 - if (instance->consumer)
3730 - pci_free_consistent(pdev, sizeof(u32), instance->consumer,
3731 - instance->consumer_h);
3732 + megasas_free_ctrl_mem(instance);
3733 scsi_host_put(host);
3734 -
3735 fail_alloc_instance:
3736 fail_set_dma_mask:
3737 pci_disable_device(pdev);
3738 @@ -6480,7 +6579,9 @@ megasas_resume(struct pci_dev *pdev)
3739 if (rval < 0)
3740 goto fail_reenable_msix;
3741
3742 - if (instance->ctrl_context) {
3743 + megasas_setup_reply_map(instance);
3744 +
3745 + if (instance->adapter_type != MFI_SERIES) {
3746 megasas_reset_reply_desc(instance);
3747 if (megasas_ioc_init_fusion(instance)) {
3748 megasas_free_cmds(instance);
3749 @@ -6543,12 +6644,8 @@ megasas_resume(struct pci_dev *pdev)
3750 pci_free_consistent(pdev, sizeof(struct MR_TARGET_PROPERTIES),
3751 instance->tgt_prop,
3752 instance->tgt_prop_h);
3753 - if (instance->producer)
3754 - pci_free_consistent(pdev, sizeof(u32), instance->producer,
3755 - instance->producer_h);
3756 - if (instance->consumer)
3757 - pci_free_consistent(pdev, sizeof(u32), instance->consumer,
3758 - instance->consumer_h);
3759 +
3760 + megasas_free_ctrl_mem(instance);
3761 scsi_host_put(host);
3762
3763 fail_set_dma_mask:
3764 @@ -6656,7 +6753,7 @@ static void megasas_detach_one(struct pci_dev *pdev)
3765 if (instance->msix_vectors)
3766 pci_free_irq_vectors(instance->pdev);
3767
3768 - if (instance->is_ventura) {
3769 + if (instance->adapter_type == VENTURA_SERIES) {
3770 for (i = 0; i < MAX_LOGICAL_DRIVES_EXT; ++i)
3771 kfree(fusion->stream_detect_by_ld[i]);
3772 kfree(fusion->stream_detect_by_ld);
3773 @@ -6664,7 +6761,7 @@ static void megasas_detach_one(struct pci_dev *pdev)
3774 }
3775
3776
3777 - if (instance->ctrl_context) {
3778 + if (instance->adapter_type != MFI_SERIES) {
3779 megasas_release_fusion(instance);
3780 pd_seq_map_sz = sizeof(struct MR_PD_CFG_SEQ_NUM_SYNC) +
3781 (sizeof(struct MR_PD_CFG_SEQ) *
3782 @@ -6689,15 +6786,8 @@ static void megasas_detach_one(struct pci_dev *pdev)
3783 fusion->pd_seq_sync[i],
3784 fusion->pd_seq_phys[i]);
3785 }
3786 - megasas_free_fusion_context(instance);
3787 } else {
3788 megasas_release_mfi(instance);
3789 - pci_free_consistent(pdev, sizeof(u32),
3790 - instance->producer,
3791 - instance->producer_h);
3792 - pci_free_consistent(pdev, sizeof(u32),
3793 - instance->consumer,
3794 - instance->consumer_h);
3795 }
3796
3797 kfree(instance->ctrl_info);
3798 @@ -6738,6 +6828,8 @@ static void megasas_detach_one(struct pci_dev *pdev)
3799 pci_free_consistent(pdev, sizeof(struct MR_DRV_SYSTEM_INFO),
3800 instance->system_info_buf, instance->system_info_h);
3801
3802 + megasas_free_ctrl_mem(instance);
3803 +
3804 scsi_host_put(host);
3805
3806 pci_disable_device(pdev);
3807 diff --git a/drivers/scsi/megaraid/megaraid_sas_fp.c b/drivers/scsi/megaraid/megaraid_sas_fp.c
3808 index 08945142b9f8..f2ffde430ec1 100644
3809 --- a/drivers/scsi/megaraid/megaraid_sas_fp.c
3810 +++ b/drivers/scsi/megaraid/megaraid_sas_fp.c
3811 @@ -745,7 +745,7 @@ static u8 mr_spanset_get_phy_params(struct megasas_instance *instance, u32 ld,
3812 *pDevHandle = MR_PdDevHandleGet(pd, map);
3813 *pPdInterface = MR_PdInterfaceTypeGet(pd, map);
3814 /* get second pd also for raid 1/10 fast path writes*/
3815 - if (instance->is_ventura &&
3816 + if ((instance->adapter_type == VENTURA_SERIES) &&
3817 (raid->level == 1) &&
3818 !io_info->isRead) {
3819 r1_alt_pd = MR_ArPdGet(arRef, physArm + 1, map);
3820 @@ -755,8 +755,8 @@ static u8 mr_spanset_get_phy_params(struct megasas_instance *instance, u32 ld,
3821 }
3822 } else {
3823 if ((raid->level >= 5) &&
3824 - ((fusion->adapter_type == THUNDERBOLT_SERIES) ||
3825 - ((fusion->adapter_type == INVADER_SERIES) &&
3826 + ((instance->adapter_type == THUNDERBOLT_SERIES) ||
3827 + ((instance->adapter_type == INVADER_SERIES) &&
3828 (raid->regTypeReqOnRead != REGION_TYPE_UNUSED))))
3829 pRAID_Context->reg_lock_flags = REGION_TYPE_EXCLUSIVE;
3830 else if (raid->level == 1) {
3831 @@ -770,7 +770,7 @@ static u8 mr_spanset_get_phy_params(struct megasas_instance *instance, u32 ld,
3832 }
3833
3834 *pdBlock += stripRef + le64_to_cpu(MR_LdSpanPtrGet(ld, span, map)->startBlk);
3835 - if (instance->is_ventura) {
3836 + if (instance->adapter_type == VENTURA_SERIES) {
3837 ((struct RAID_CONTEXT_G35 *)pRAID_Context)->span_arm =
3838 (span << RAID_CTX_SPANARM_SPAN_SHIFT) | physArm;
3839 io_info->span_arm =
3840 @@ -861,7 +861,7 @@ u8 MR_GetPhyParams(struct megasas_instance *instance, u32 ld, u64 stripRow,
3841 *pDevHandle = MR_PdDevHandleGet(pd, map);
3842 *pPdInterface = MR_PdInterfaceTypeGet(pd, map);
3843 /* get second pd also for raid 1/10 fast path writes*/
3844 - if (instance->is_ventura &&
3845 + if ((instance->adapter_type == VENTURA_SERIES) &&
3846 (raid->level == 1) &&
3847 !io_info->isRead) {
3848 r1_alt_pd = MR_ArPdGet(arRef, physArm + 1, map);
3849 @@ -871,8 +871,8 @@ u8 MR_GetPhyParams(struct megasas_instance *instance, u32 ld, u64 stripRow,
3850 }
3851 } else {
3852 if ((raid->level >= 5) &&
3853 - ((fusion->adapter_type == THUNDERBOLT_SERIES) ||
3854 - ((fusion->adapter_type == INVADER_SERIES) &&
3855 + ((instance->adapter_type == THUNDERBOLT_SERIES) ||
3856 + ((instance->adapter_type == INVADER_SERIES) &&
3857 (raid->regTypeReqOnRead != REGION_TYPE_UNUSED))))
3858 pRAID_Context->reg_lock_flags = REGION_TYPE_EXCLUSIVE;
3859 else if (raid->level == 1) {
3860 @@ -888,7 +888,7 @@ u8 MR_GetPhyParams(struct megasas_instance *instance, u32 ld, u64 stripRow,
3861 }
3862
3863 *pdBlock += stripRef + le64_to_cpu(MR_LdSpanPtrGet(ld, span, map)->startBlk);
3864 - if (instance->is_ventura) {
3865 + if (instance->adapter_type == VENTURA_SERIES) {
3866 ((struct RAID_CONTEXT_G35 *)pRAID_Context)->span_arm =
3867 (span << RAID_CTX_SPANARM_SPAN_SHIFT) | physArm;
3868 io_info->span_arm =
3869 @@ -1096,10 +1096,10 @@ MR_BuildRaidContext(struct megasas_instance *instance,
3870 cpu_to_le16(raid->fpIoTimeoutForLd ?
3871 raid->fpIoTimeoutForLd :
3872 map->raidMap.fpPdIoTimeoutSec);
3873 - if (fusion->adapter_type == INVADER_SERIES)
3874 + if (instance->adapter_type == INVADER_SERIES)
3875 pRAID_Context->reg_lock_flags = (isRead) ?
3876 raid->regTypeReqOnRead : raid->regTypeReqOnWrite;
3877 - else if (!instance->is_ventura)
3878 + else if (instance->adapter_type == THUNDERBOLT_SERIES)
3879 pRAID_Context->reg_lock_flags = (isRead) ?
3880 REGION_TYPE_SHARED_READ : raid->regTypeReqOnWrite;
3881 pRAID_Context->virtual_disk_tgt_id = raid->targetId;
3882 diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c
3883 index 72a919179d06..d8f626567f59 100644
3884 --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
3885 +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
3886 @@ -237,7 +237,7 @@ megasas_fusion_update_can_queue(struct megasas_instance *instance, int fw_boot_c
3887 reg_set = instance->reg_set;
3888
3889 /* ventura FW does not fill outbound_scratch_pad_3 with queue depth */
3890 - if (!instance->is_ventura)
3891 + if (instance->adapter_type < VENTURA_SERIES)
3892 cur_max_fw_cmds =
3893 readl(&instance->reg_set->outbound_scratch_pad_3) & 0x00FFFF;
3894
3895 @@ -285,7 +285,7 @@ megasas_fusion_update_can_queue(struct megasas_instance *instance, int fw_boot_c
3896 instance->host->can_queue = instance->cur_can_queue;
3897 }
3898
3899 - if (instance->is_ventura)
3900 + if (instance->adapter_type == VENTURA_SERIES)
3901 instance->max_mpt_cmds =
3902 instance->max_fw_cmds * RAID_1_PEER_CMDS;
3903 else
3904 @@ -838,7 +838,7 @@ megasas_ioc_init_fusion(struct megasas_instance *instance)
3905 drv_ops = (MFI_CAPABILITIES *) &(init_frame->driver_operations);
3906
3907 /* driver support Extended MSIX */
3908 - if (fusion->adapter_type >= INVADER_SERIES)
3909 + if (instance->adapter_type >= INVADER_SERIES)
3910 drv_ops->mfi_capabilities.support_additional_msix = 1;
3911 /* driver supports HA / Remote LUN over Fast Path interface */
3912 drv_ops->mfi_capabilities.support_fp_remote_lun = 1;
3913 @@ -1789,7 +1789,7 @@ megasas_make_sgl_fusion(struct megasas_instance *instance,
3914
3915 fusion = instance->ctrl_context;
3916
3917 - if (fusion->adapter_type >= INVADER_SERIES) {
3918 + if (instance->adapter_type >= INVADER_SERIES) {
3919 struct MPI25_IEEE_SGE_CHAIN64 *sgl_ptr_end = sgl_ptr;
3920 sgl_ptr_end += fusion->max_sge_in_main_msg - 1;
3921 sgl_ptr_end->Flags = 0;
3922 @@ -1799,7 +1799,7 @@ megasas_make_sgl_fusion(struct megasas_instance *instance,
3923 sgl_ptr->Length = cpu_to_le32(sg_dma_len(os_sgl));
3924 sgl_ptr->Address = cpu_to_le64(sg_dma_address(os_sgl));
3925 sgl_ptr->Flags = 0;
3926 - if (fusion->adapter_type >= INVADER_SERIES)
3927 + if (instance->adapter_type >= INVADER_SERIES)
3928 if (i == sge_count - 1)
3929 sgl_ptr->Flags = IEEE_SGE_FLAGS_END_OF_LIST;
3930 sgl_ptr++;
3931 @@ -1809,7 +1809,7 @@ megasas_make_sgl_fusion(struct megasas_instance *instance,
3932 (sge_count > fusion->max_sge_in_main_msg)) {
3933
3934 struct MPI25_IEEE_SGE_CHAIN64 *sg_chain;
3935 - if (fusion->adapter_type >= INVADER_SERIES) {
3936 + if (instance->adapter_type >= INVADER_SERIES) {
3937 if ((le16_to_cpu(cmd->io_request->IoFlags) &
3938 MPI25_SAS_DEVICE0_FLAGS_ENABLED_FAST_PATH) !=
3939 MPI25_SAS_DEVICE0_FLAGS_ENABLED_FAST_PATH)
3940 @@ -1825,7 +1825,7 @@ megasas_make_sgl_fusion(struct megasas_instance *instance,
3941 sg_chain = sgl_ptr;
3942 /* Prepare chain element */
3943 sg_chain->NextChainOffset = 0;
3944 - if (fusion->adapter_type >= INVADER_SERIES)
3945 + if (instance->adapter_type >= INVADER_SERIES)
3946 sg_chain->Flags = IEEE_SGE_FLAGS_CHAIN_ELEMENT;
3947 else
3948 sg_chain->Flags =
3949 @@ -2341,15 +2341,12 @@ megasas_build_ldio_fusion(struct megasas_instance *instance,
3950 fp_possible = (io_info.fpOkForIo > 0) ? true : false;
3951 }
3952
3953 - /* Use raw_smp_processor_id() for now until cmd->request->cpu is CPU
3954 - id by default, not CPU group id, otherwise all MSI-X queues won't
3955 - be utilized */
3956 - cmd->request_desc->SCSIIO.MSIxIndex = instance->msix_vectors ?
3957 - raw_smp_processor_id() % instance->msix_vectors : 0;
3958 + cmd->request_desc->SCSIIO.MSIxIndex =
3959 + instance->reply_map[raw_smp_processor_id()];
3960
3961 praid_context = &io_request->RaidContext;
3962
3963 - if (instance->is_ventura) {
3964 + if (instance->adapter_type == VENTURA_SERIES) {
3965 spin_lock_irqsave(&instance->stream_lock, spinlock_flags);
3966 megasas_stream_detect(instance, cmd, &io_info);
3967 spin_unlock_irqrestore(&instance->stream_lock, spinlock_flags);
3968 @@ -2402,7 +2399,7 @@ megasas_build_ldio_fusion(struct megasas_instance *instance,
3969 cmd->request_desc->SCSIIO.RequestFlags =
3970 (MPI2_REQ_DESCRIPT_FLAGS_FP_IO
3971 << MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
3972 - if (fusion->adapter_type == INVADER_SERIES) {
3973 + if (instance->adapter_type == INVADER_SERIES) {
3974 if (io_request->RaidContext.raid_context.reg_lock_flags ==
3975 REGION_TYPE_UNUSED)
3976 cmd->request_desc->SCSIIO.RequestFlags =
3977 @@ -2415,7 +2412,7 @@ megasas_build_ldio_fusion(struct megasas_instance *instance,
3978 io_request->RaidContext.raid_context.reg_lock_flags |=
3979 (MR_RL_FLAGS_GRANT_DESTINATION_CUDA |
3980 MR_RL_FLAGS_SEQ_NUM_ENABLE);
3981 - } else if (instance->is_ventura) {
3982 + } else if (instance->adapter_type == VENTURA_SERIES) {
3983 io_request->RaidContext.raid_context_g35.nseg_type |=
3984 (1 << RAID_CONTEXT_NSEG_SHIFT);
3985 io_request->RaidContext.raid_context_g35.nseg_type |=
3986 @@ -2434,7 +2431,7 @@ megasas_build_ldio_fusion(struct megasas_instance *instance,
3987 &io_info, local_map_ptr);
3988 scp->SCp.Status |= MEGASAS_LOAD_BALANCE_FLAG;
3989 cmd->pd_r1_lb = io_info.pd_after_lb;
3990 - if (instance->is_ventura)
3991 + if (instance->adapter_type == VENTURA_SERIES)
3992 io_request->RaidContext.raid_context_g35.span_arm
3993 = io_info.span_arm;
3994 else
3995 @@ -2444,7 +2441,7 @@ megasas_build_ldio_fusion(struct megasas_instance *instance,
3996 } else
3997 scp->SCp.Status &= ~MEGASAS_LOAD_BALANCE_FLAG;
3998
3999 - if (instance->is_ventura)
4000 + if (instance->adapter_type == VENTURA_SERIES)
4001 cmd->r1_alt_dev_handle = io_info.r1_alt_dev_handle;
4002 else
4003 cmd->r1_alt_dev_handle = MR_DEVHANDLE_INVALID;
4004 @@ -2467,7 +2464,7 @@ megasas_build_ldio_fusion(struct megasas_instance *instance,
4005 cmd->request_desc->SCSIIO.RequestFlags =
4006 (MEGASAS_REQ_DESCRIPT_FLAGS_LD_IO
4007 << MEGASAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
4008 - if (fusion->adapter_type == INVADER_SERIES) {
4009 + if (instance->adapter_type == INVADER_SERIES) {
4010 if (io_info.do_fp_rlbypass ||
4011 (io_request->RaidContext.raid_context.reg_lock_flags
4012 == REGION_TYPE_UNUSED))
4013 @@ -2480,7 +2477,7 @@ megasas_build_ldio_fusion(struct megasas_instance *instance,
4014 (MR_RL_FLAGS_GRANT_DESTINATION_CPU0 |
4015 MR_RL_FLAGS_SEQ_NUM_ENABLE);
4016 io_request->RaidContext.raid_context.nseg = 0x1;
4017 - } else if (instance->is_ventura) {
4018 + } else if (instance->adapter_type == VENTURA_SERIES) {
4019 io_request->RaidContext.raid_context_g35.routing_flags |=
4020 (1 << MR_RAID_CTX_ROUTINGFLAGS_SQN_SHIFT);
4021 io_request->RaidContext.raid_context_g35.nseg_type |=
4022 @@ -2555,7 +2552,7 @@ static void megasas_build_ld_nonrw_fusion(struct megasas_instance *instance,
4023
4024 /* set RAID context values */
4025 pRAID_Context->config_seq_num = raid->seqNum;
4026 - if (!instance->is_ventura)
4027 + if (instance->adapter_type != VENTURA_SERIES)
4028 pRAID_Context->reg_lock_flags = REGION_TYPE_SHARED_READ;
4029 pRAID_Context->timeout_value =
4030 cpu_to_le16(raid->fpIoTimeoutForLd);
4031 @@ -2640,7 +2637,7 @@ megasas_build_syspd_fusion(struct megasas_instance *instance,
4032 cpu_to_le16(device_id + (MAX_PHYSICAL_DEVICES - 1));
4033 pRAID_Context->config_seq_num = pd_sync->seq[pd_index].seqNum;
4034 io_request->DevHandle = pd_sync->seq[pd_index].devHandle;
4035 - if (instance->is_ventura) {
4036 + if (instance->adapter_type == VENTURA_SERIES) {
4037 io_request->RaidContext.raid_context_g35.routing_flags |=
4038 (1 << MR_RAID_CTX_ROUTINGFLAGS_SQN_SHIFT);
4039 io_request->RaidContext.raid_context_g35.nseg_type |=
4040 @@ -2667,10 +2664,9 @@ megasas_build_syspd_fusion(struct megasas_instance *instance,
4041 }
4042
4043 cmd->request_desc->SCSIIO.DevHandle = io_request->DevHandle;
4044 - cmd->request_desc->SCSIIO.MSIxIndex =
4045 - instance->msix_vectors ?
4046 - (raw_smp_processor_id() % instance->msix_vectors) : 0;
4047
4048 + cmd->request_desc->SCSIIO.MSIxIndex =
4049 + instance->reply_map[raw_smp_processor_id()];
4050
4051 if (!fp_possible) {
4052 /* system pd firmware path */
4053 @@ -2688,7 +2684,7 @@ megasas_build_syspd_fusion(struct megasas_instance *instance,
4054 pRAID_Context->timeout_value =
4055 cpu_to_le16((os_timeout_value > timeout_limit) ?
4056 timeout_limit : os_timeout_value);
4057 - if (fusion->adapter_type >= INVADER_SERIES)
4058 + if (instance->adapter_type >= INVADER_SERIES)
4059 io_request->IoFlags |=
4060 cpu_to_le16(MPI25_SAS_DEVICE0_FLAGS_ENABLED_FAST_PATH);
4061
4062 @@ -2771,7 +2767,7 @@ megasas_build_io_fusion(struct megasas_instance *instance,
4063 return 1;
4064 }
4065
4066 - if (instance->is_ventura) {
4067 + if (instance->adapter_type == VENTURA_SERIES) {
4068 set_num_sge(&io_request->RaidContext.raid_context_g35, sge_count);
4069 cpu_to_le16s(&io_request->RaidContext.raid_context_g35.routing_flags);
4070 cpu_to_le16s(&io_request->RaidContext.raid_context_g35.nseg_type);
4071 @@ -3301,7 +3297,7 @@ build_mpt_mfi_pass_thru(struct megasas_instance *instance,
4072
4073 io_req = cmd->io_request;
4074
4075 - if (fusion->adapter_type >= INVADER_SERIES) {
4076 + if (instance->adapter_type >= INVADER_SERIES) {
4077 struct MPI25_IEEE_SGE_CHAIN64 *sgl_ptr_end =
4078 (struct MPI25_IEEE_SGE_CHAIN64 *)&io_req->SGL;
4079 sgl_ptr_end += fusion->max_sge_in_main_msg - 1;
4080 @@ -4233,7 +4229,7 @@ int megasas_reset_fusion(struct Scsi_Host *shost, int reason)
4081 for (i = 0 ; i < instance->max_scsi_cmds; i++) {
4082 cmd_fusion = fusion->cmd_list[i];
4083 /*check for extra commands issued by driver*/
4084 - if (instance->is_ventura) {
4085 + if (instance->adapter_type == VENTURA_SERIES) {
4086 r1_cmd = fusion->cmd_list[i + instance->max_fw_cmds];
4087 megasas_return_cmd_fusion(instance, r1_cmd);
4088 }
4089 @@ -4334,7 +4330,7 @@ int megasas_reset_fusion(struct Scsi_Host *shost, int reason)
4090 megasas_set_dynamic_target_properties(sdev);
4091
4092 /* reset stream detection array */
4093 - if (instance->is_ventura) {
4094 + if (instance->adapter_type == VENTURA_SERIES) {
4095 for (j = 0; j < MAX_LOGICAL_DRIVES_EXT; ++j) {
4096 memset(fusion->stream_detect_by_ld[j],
4097 0, sizeof(struct LD_STREAM_DETECT));
4098 diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.h b/drivers/scsi/megaraid/megaraid_sas_fusion.h
4099 index d78d76112501..7c1f7ccf031d 100644
4100 --- a/drivers/scsi/megaraid/megaraid_sas_fusion.h
4101 +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.h
4102 @@ -104,12 +104,6 @@ enum MR_RAID_FLAGS_IO_SUB_TYPE {
4103 #define RAID_1_PEER_CMDS 2
4104 #define JBOD_MAPS_COUNT 2
4105
4106 -enum MR_FUSION_ADAPTER_TYPE {
4107 - THUNDERBOLT_SERIES = 0,
4108 - INVADER_SERIES = 1,
4109 - VENTURA_SERIES = 2,
4110 -};
4111 -
4112 /*
4113 * Raid Context structure which describes MegaRAID specific IO Parameters
4114 * This resides at offset 0x60 where the SGL normally starts in MPT IO Frames
4115 @@ -1319,7 +1313,6 @@ struct fusion_context {
4116 struct LD_LOAD_BALANCE_INFO *load_balance_info;
4117 u32 load_balance_info_pages;
4118 LD_SPAN_INFO log_to_span[MAX_LOGICAL_DRIVES_EXT];
4119 - u8 adapter_type;
4120 struct LD_STREAM_DETECT **stream_detect_by_ld;
4121 };
4122
4123 diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c b/drivers/staging/rtl8723bs/core/rtw_ap.c
4124 index d3007c1c45e3..a84400f07a38 100644
4125 --- a/drivers/staging/rtl8723bs/core/rtw_ap.c
4126 +++ b/drivers/staging/rtl8723bs/core/rtw_ap.c
4127 @@ -1059,7 +1059,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len)
4128 return _FAIL;
4129
4130
4131 - if (len > MAX_IE_SZ)
4132 + if (len < 0 || len > MAX_IE_SZ)
4133 return _FAIL;
4134
4135 pbss_network->IELength = len;
4136 diff --git a/drivers/staging/rtlwifi/rtl8822be/hw.c b/drivers/staging/rtlwifi/rtl8822be/hw.c
4137 index 74386003044f..c6db2bd20594 100644
4138 --- a/drivers/staging/rtlwifi/rtl8822be/hw.c
4139 +++ b/drivers/staging/rtlwifi/rtl8822be/hw.c
4140 @@ -814,7 +814,7 @@ static void _rtl8822be_enable_aspm_back_door(struct ieee80211_hw *hw)
4141 return;
4142
4143 pci_read_config_byte(rtlpci->pdev, 0x70f, &tmp);
4144 - pci_write_config_byte(rtlpci->pdev, 0x70f, tmp | BIT(7));
4145 + pci_write_config_byte(rtlpci->pdev, 0x70f, tmp | ASPM_L1_LATENCY << 3);
4146
4147 pci_read_config_byte(rtlpci->pdev, 0x719, &tmp);
4148 pci_write_config_byte(rtlpci->pdev, 0x719, tmp | BIT(3) | BIT(4));
4149 diff --git a/drivers/staging/rtlwifi/wifi.h b/drivers/staging/rtlwifi/wifi.h
4150 index eb91c130b245..5f0bc363ad41 100644
4151 --- a/drivers/staging/rtlwifi/wifi.h
4152 +++ b/drivers/staging/rtlwifi/wifi.h
4153 @@ -99,6 +99,7 @@
4154 #define RTL_USB_MAX_RX_COUNT 100
4155 #define QBSS_LOAD_SIZE 5
4156 #define MAX_WMMELE_LENGTH 64
4157 +#define ASPM_L1_LATENCY 7
4158
4159 #define TOTAL_CAM_ENTRY 32
4160
4161 diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
4162 index 40ce175655e6..99f67764765f 100644
4163 --- a/drivers/usb/core/quirks.c
4164 +++ b/drivers/usb/core/quirks.c
4165 @@ -231,6 +231,10 @@ static const struct usb_device_id usb_quirk_list[] = {
4166 /* Corsair K70 RGB */
4167 { USB_DEVICE(0x1b1c, 0x1b13), .driver_info = USB_QUIRK_DELAY_INIT },
4168
4169 + /* Corsair Strafe */
4170 + { USB_DEVICE(0x1b1c, 0x1b15), .driver_info = USB_QUIRK_DELAY_INIT |
4171 + USB_QUIRK_DELAY_CTRL_MSG },
4172 +
4173 /* Corsair Strafe RGB */
4174 { USB_DEVICE(0x1b1c, 0x1b20), .driver_info = USB_QUIRK_DELAY_INIT |
4175 USB_QUIRK_DELAY_CTRL_MSG },
4176 diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
4177 index 00b710016d21..b7b55eb82714 100644
4178 --- a/drivers/usb/host/xhci-mem.c
4179 +++ b/drivers/usb/host/xhci-mem.c
4180 @@ -604,7 +604,7 @@ struct xhci_ring *xhci_stream_id_to_ring(
4181 if (!ep->stream_info)
4182 return NULL;
4183
4184 - if (stream_id > ep->stream_info->num_streams)
4185 + if (stream_id >= ep->stream_info->num_streams)
4186 return NULL;
4187 return ep->stream_info->stream_rings[stream_id];
4188 }
4189 diff --git a/drivers/usb/misc/yurex.c b/drivers/usb/misc/yurex.c
4190 index 58abdf28620a..47763311a42e 100644
4191 --- a/drivers/usb/misc/yurex.c
4192 +++ b/drivers/usb/misc/yurex.c
4193 @@ -400,8 +400,7 @@ static ssize_t yurex_read(struct file *file, char __user *buffer, size_t count,
4194 loff_t *ppos)
4195 {
4196 struct usb_yurex *dev;
4197 - int retval = 0;
4198 - int bytes_read = 0;
4199 + int len = 0;
4200 char in_buffer[20];
4201 unsigned long flags;
4202
4203 @@ -409,26 +408,16 @@ static ssize_t yurex_read(struct file *file, char __user *buffer, size_t count,
4204
4205 mutex_lock(&dev->io_mutex);
4206 if (!dev->interface) { /* already disconnected */
4207 - retval = -ENODEV;
4208 - goto exit;
4209 + mutex_unlock(&dev->io_mutex);
4210 + return -ENODEV;
4211 }
4212
4213 spin_lock_irqsave(&dev->lock, flags);
4214 - bytes_read = snprintf(in_buffer, 20, "%lld\n", dev->bbu);
4215 + len = snprintf(in_buffer, 20, "%lld\n", dev->bbu);
4216 spin_unlock_irqrestore(&dev->lock, flags);
4217 -
4218 - if (*ppos < bytes_read) {
4219 - if (copy_to_user(buffer, in_buffer + *ppos, bytes_read - *ppos))
4220 - retval = -EFAULT;
4221 - else {
4222 - retval = bytes_read - *ppos;
4223 - *ppos += bytes_read;
4224 - }
4225 - }
4226 -
4227 -exit:
4228 mutex_unlock(&dev->io_mutex);
4229 - return retval;
4230 +
4231 + return simple_read_from_buffer(buffer, count, ppos, in_buffer, len);
4232 }
4233
4234 static ssize_t yurex_write(struct file *file, const char __user *user_buffer,
4235 diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c
4236 index 351745aec0e1..578596d301b8 100644
4237 --- a/drivers/usb/serial/ch341.c
4238 +++ b/drivers/usb/serial/ch341.c
4239 @@ -131,7 +131,7 @@ static int ch341_control_in(struct usb_device *dev,
4240 r = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), request,
4241 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
4242 value, index, buf, bufsize, DEFAULT_TIMEOUT);
4243 - if (r < bufsize) {
4244 + if (r < (int)bufsize) {
4245 if (r >= 0) {
4246 dev_err(&dev->dev,
4247 "short control message received (%d < %u)\n",
4248 diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
4249 index 142a83e5974c..c931ae689a91 100644
4250 --- a/drivers/usb/serial/cp210x.c
4251 +++ b/drivers/usb/serial/cp210x.c
4252 @@ -152,6 +152,7 @@ static const struct usb_device_id id_table[] = {
4253 { USB_DEVICE(0x10C4, 0x8977) }, /* CEL MeshWorks DevKit Device */
4254 { USB_DEVICE(0x10C4, 0x8998) }, /* KCF Technologies PRN */
4255 { USB_DEVICE(0x10C4, 0x89A4) }, /* CESINEL FTBC Flexible Thyristor Bridge Controller */
4256 + { USB_DEVICE(0x10C4, 0x89FB) }, /* Qivicon ZigBee USB Radio Stick */
4257 { USB_DEVICE(0x10C4, 0x8A2A) }, /* HubZ dual ZigBee and Z-Wave dongle */
4258 { USB_DEVICE(0x10C4, 0x8A5E) }, /* CEL EM3588 ZigBee USB Stick Long Range */
4259 { USB_DEVICE(0x10C4, 0x8B34) }, /* Qivicon ZigBee USB Radio Stick */
4260 diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c
4261 index 196908dd25a1..f8e8285663a6 100644
4262 --- a/drivers/usb/serial/keyspan_pda.c
4263 +++ b/drivers/usb/serial/keyspan_pda.c
4264 @@ -373,8 +373,10 @@ static int keyspan_pda_get_modem_info(struct usb_serial *serial,
4265 3, /* get pins */
4266 USB_TYPE_VENDOR|USB_RECIP_INTERFACE|USB_DIR_IN,
4267 0, 0, data, 1, 2000);
4268 - if (rc >= 0)
4269 + if (rc == 1)
4270 *value = *data;
4271 + else if (rc >= 0)
4272 + rc = -EIO;
4273
4274 kfree(data);
4275 return rc;
4276 diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
4277 index e8669aae14b3..5e490177cf75 100644
4278 --- a/drivers/usb/serial/mos7840.c
4279 +++ b/drivers/usb/serial/mos7840.c
4280 @@ -481,6 +481,9 @@ static void mos7840_control_callback(struct urb *urb)
4281 }
4282
4283 dev_dbg(dev, "%s urb buffer size is %d\n", __func__, urb->actual_length);
4284 + if (urb->actual_length < 1)
4285 + goto out;
4286 +
4287 dev_dbg(dev, "%s mos7840_port->MsrLsr is %d port %d\n", __func__,
4288 mos7840_port->MsrLsr, mos7840_port->port_num);
4289 data = urb->transfer_buffer;
4290 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
4291 index 73b01e474fdc..c0e3f91e28e9 100644
4292 --- a/fs/binfmt_elf.c
4293 +++ b/fs/binfmt_elf.c
4294 @@ -1235,9 +1235,8 @@ static int load_elf_library(struct file *file)
4295 goto out_free_ph;
4296 }
4297
4298 - len = ELF_PAGESTART(eppnt->p_filesz + eppnt->p_vaddr +
4299 - ELF_MIN_ALIGN - 1);
4300 - bss = eppnt->p_memsz + eppnt->p_vaddr;
4301 + len = ELF_PAGEALIGN(eppnt->p_filesz + eppnt->p_vaddr);
4302 + bss = ELF_PAGEALIGN(eppnt->p_memsz + eppnt->p_vaddr);
4303 if (bss > len) {
4304 error = vm_brk(len, bss - len);
4305 if (error)
4306 diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c
4307 index e31d6ed3ec32..542364bf923e 100644
4308 --- a/fs/devpts/inode.c
4309 +++ b/fs/devpts/inode.c
4310 @@ -138,10 +138,6 @@ static int devpts_ptmx_path(struct path *path)
4311 struct super_block *sb;
4312 int err;
4313
4314 - /* Has the devpts filesystem already been found? */
4315 - if (path->mnt->mnt_sb->s_magic == DEVPTS_SUPER_MAGIC)
4316 - return 0;
4317 -
4318 /* Is a devpts filesystem at "pts" in the same directory? */
4319 err = path_pts(path);
4320 if (err)
4321 @@ -159,22 +155,32 @@ static int devpts_ptmx_path(struct path *path)
4322 struct vfsmount *devpts_mntget(struct file *filp, struct pts_fs_info *fsi)
4323 {
4324 struct path path;
4325 - int err;
4326 + int err = 0;
4327
4328 path = filp->f_path;
4329 path_get(&path);
4330
4331 - err = devpts_ptmx_path(&path);
4332 + /* Walk upward while the start point is a bind mount of
4333 + * a single file.
4334 + */
4335 + while (path.mnt->mnt_root == path.dentry)
4336 + if (follow_up(&path) == 0)
4337 + break;
4338 +
4339 + /* devpts_ptmx_path() finds a devpts fs or returns an error. */
4340 + if ((path.mnt->mnt_sb->s_magic != DEVPTS_SUPER_MAGIC) ||
4341 + (DEVPTS_SB(path.mnt->mnt_sb) != fsi))
4342 + err = devpts_ptmx_path(&path);
4343 dput(path.dentry);
4344 - if (err) {
4345 - mntput(path.mnt);
4346 - return ERR_PTR(err);
4347 - }
4348 - if (DEVPTS_SB(path.mnt->mnt_sb) != fsi) {
4349 - mntput(path.mnt);
4350 - return ERR_PTR(-ENODEV);
4351 + if (!err) {
4352 + if (DEVPTS_SB(path.mnt->mnt_sb) == fsi)
4353 + return path.mnt;
4354 +
4355 + err = -ENODEV;
4356 }
4357 - return path.mnt;
4358 +
4359 + mntput(path.mnt);
4360 + return ERR_PTR(err);
4361 }
4362
4363 struct pts_fs_info *devpts_acquire(struct file *filp)
4364 @@ -182,15 +188,19 @@ struct pts_fs_info *devpts_acquire(struct file *filp)
4365 struct pts_fs_info *result;
4366 struct path path;
4367 struct super_block *sb;
4368 - int err;
4369
4370 path = filp->f_path;
4371 path_get(&path);
4372
4373 - err = devpts_ptmx_path(&path);
4374 - if (err) {
4375 - result = ERR_PTR(err);
4376 - goto out;
4377 + /* Has the devpts filesystem already been found? */
4378 + if (path.mnt->mnt_sb->s_magic != DEVPTS_SUPER_MAGIC) {
4379 + int err;
4380 +
4381 + err = devpts_ptmx_path(&path);
4382 + if (err) {
4383 + result = ERR_PTR(err);
4384 + goto out;
4385 + }
4386 }
4387
4388 /*
4389 diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
4390 index 4b4a72f392be..3b34004a71c1 100644
4391 --- a/fs/f2fs/f2fs.h
4392 +++ b/fs/f2fs/f2fs.h
4393 @@ -1470,18 +1470,6 @@ static inline bool __exist_node_summaries(struct f2fs_sb_info *sbi)
4394 is_set_ckpt_flags(sbi, CP_FASTBOOT_FLAG));
4395 }
4396
4397 -/*
4398 - * Check whether the given nid is within node id range.
4399 - */
4400 -static inline int check_nid_range(struct f2fs_sb_info *sbi, nid_t nid)
4401 -{
4402 - if (unlikely(nid < F2FS_ROOT_INO(sbi)))
4403 - return -EINVAL;
4404 - if (unlikely(nid >= NM_I(sbi)->max_nid))
4405 - return -EINVAL;
4406 - return 0;
4407 -}
4408 -
4409 /*
4410 * Check whether the inode has blocks or not
4411 */
4412 @@ -2470,6 +2458,7 @@ f2fs_hash_t f2fs_dentry_hash(const struct qstr *name_info,
4413 struct dnode_of_data;
4414 struct node_info;
4415
4416 +int check_nid_range(struct f2fs_sb_info *sbi, nid_t nid);
4417 bool available_free_memory(struct f2fs_sb_info *sbi, int type);
4418 int need_dentry_mark(struct f2fs_sb_info *sbi, nid_t nid);
4419 bool is_checkpointed_node(struct f2fs_sb_info *sbi, nid_t nid);
4420 diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
4421 index 50c88e37ed66..259b0aa283f0 100644
4422 --- a/fs/f2fs/inode.c
4423 +++ b/fs/f2fs/inode.c
4424 @@ -188,12 +188,8 @@ static int do_read_inode(struct inode *inode)
4425 projid_t i_projid;
4426
4427 /* Check if ino is within scope */
4428 - if (check_nid_range(sbi, inode->i_ino)) {
4429 - f2fs_msg(inode->i_sb, KERN_ERR, "bad inode number: %lu",
4430 - (unsigned long) inode->i_ino);
4431 - WARN_ON(1);
4432 + if (check_nid_range(sbi, inode->i_ino))
4433 return -EINVAL;
4434 - }
4435
4436 node_page = get_node_page(sbi, inode->i_ino);
4437 if (IS_ERR(node_page))
4438 @@ -538,8 +534,11 @@ void f2fs_evict_inode(struct inode *inode)
4439 alloc_nid_failed(sbi, inode->i_ino);
4440 clear_inode_flag(inode, FI_FREE_NID);
4441 } else {
4442 - f2fs_bug_on(sbi, err &&
4443 - !exist_written_data(sbi, inode->i_ino, ORPHAN_INO));
4444 + /*
4445 + * If xattr nid is corrupted, we can reach out error condition,
4446 + * err & !exist_written_data(sbi, inode->i_ino, ORPHAN_INO)).
4447 + * In that case, check_nid_range() is enough to give a clue.
4448 + */
4449 }
4450 out_clear:
4451 fscrypt_put_encryption_info(inode, NULL);
4452 diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
4453 index fca87835a1da..f623da26159f 100644
4454 --- a/fs/f2fs/node.c
4455 +++ b/fs/f2fs/node.c
4456 @@ -29,6 +29,21 @@ static struct kmem_cache *nat_entry_slab;
4457 static struct kmem_cache *free_nid_slab;
4458 static struct kmem_cache *nat_entry_set_slab;
4459
4460 +/*
4461 + * Check whether the given nid is within node id range.
4462 + */
4463 +int check_nid_range(struct f2fs_sb_info *sbi, nid_t nid)
4464 +{
4465 + if (unlikely(nid < F2FS_ROOT_INO(sbi) || nid >= NM_I(sbi)->max_nid)) {
4466 + set_sbi_flag(sbi, SBI_NEED_FSCK);
4467 + f2fs_msg(sbi->sb, KERN_WARNING,
4468 + "%s: out-of-range nid=%x, run fsck to fix.",
4469 + __func__, nid);
4470 + return -EINVAL;
4471 + }
4472 + return 0;
4473 +}
4474 +
4475 bool available_free_memory(struct f2fs_sb_info *sbi, int type)
4476 {
4477 struct f2fs_nm_info *nm_i = NM_I(sbi);
4478 @@ -1122,7 +1137,8 @@ void ra_node_page(struct f2fs_sb_info *sbi, nid_t nid)
4479
4480 if (!nid)
4481 return;
4482 - f2fs_bug_on(sbi, check_nid_range(sbi, nid));
4483 + if (check_nid_range(sbi, nid))
4484 + return;
4485
4486 rcu_read_lock();
4487 apage = radix_tree_lookup(&NODE_MAPPING(sbi)->page_tree, nid);
4488 @@ -1146,7 +1162,8 @@ static struct page *__get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid,
4489
4490 if (!nid)
4491 return ERR_PTR(-ENOENT);
4492 - f2fs_bug_on(sbi, check_nid_range(sbi, nid));
4493 + if (check_nid_range(sbi, nid))
4494 + return ERR_PTR(-EINVAL);
4495 repeat:
4496 page = f2fs_grab_cache_page(NODE_MAPPING(sbi), nid, false);
4497 if (!page)
4498 diff --git a/fs/inode.c b/fs/inode.c
4499 index e07b3e1f5970..cfc36d11bcb3 100644
4500 --- a/fs/inode.c
4501 +++ b/fs/inode.c
4502 @@ -2006,8 +2006,14 @@ void inode_init_owner(struct inode *inode, const struct inode *dir,
4503 inode->i_uid = current_fsuid();
4504 if (dir && dir->i_mode & S_ISGID) {
4505 inode->i_gid = dir->i_gid;
4506 +
4507 + /* Directories are special, and always inherit S_ISGID */
4508 if (S_ISDIR(mode))
4509 mode |= S_ISGID;
4510 + else if ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP) &&
4511 + !in_group_p(inode->i_gid) &&
4512 + !capable_wrt_inode_uidgid(dir, CAP_FSETID))
4513 + mode &= ~S_ISGID;
4514 } else
4515 inode->i_gid = current_fsgid();
4516 inode->i_mode = mode;
4517 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
4518 index 4cd8328e4039..6f337fff38c4 100644
4519 --- a/fs/proc/task_mmu.c
4520 +++ b/fs/proc/task_mmu.c
4521 @@ -850,7 +850,7 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
4522 mss->private_hugetlb >> 10,
4523 mss->swap >> 10,
4524 (unsigned long)(mss->swap_pss >> (10 + PSS_SHIFT)),
4525 - (unsigned long)(mss->pss >> (10 + PSS_SHIFT)));
4526 + (unsigned long)(mss->pss_locked >> (10 + PSS_SHIFT)));
4527
4528 if (!rollup_mode) {
4529 arch_show_smap(m, vma);
4530 diff --git a/include/linux/libata.h b/include/linux/libata.h
4531 index 931c32f1f18d..c5188dc389c8 100644
4532 --- a/include/linux/libata.h
4533 +++ b/include/linux/libata.h
4534 @@ -211,6 +211,7 @@ enum {
4535 ATA_FLAG_SLAVE_POSS = (1 << 0), /* host supports slave dev */
4536 /* (doesn't imply presence) */
4537 ATA_FLAG_SATA = (1 << 1),
4538 + ATA_FLAG_NO_LPM = (1 << 2), /* host not happy with LPM */
4539 ATA_FLAG_NO_LOG_PAGE = (1 << 5), /* do not issue log page read */
4540 ATA_FLAG_NO_ATAPI = (1 << 6), /* No ATAPI support */
4541 ATA_FLAG_PIO_DMA = (1 << 7), /* PIO cmds via DMA */
4542 diff --git a/kernel/irq/affinity.c b/kernel/irq/affinity.c
4543 index e12d35108225..a37a3b4b6342 100644
4544 --- a/kernel/irq/affinity.c
4545 +++ b/kernel/irq/affinity.c
4546 @@ -39,7 +39,7 @@ static void irq_spread_init_one(struct cpumask *irqmsk, struct cpumask *nmsk,
4547 }
4548 }
4549
4550 -static cpumask_var_t *alloc_node_to_present_cpumask(void)
4551 +static cpumask_var_t *alloc_node_to_possible_cpumask(void)
4552 {
4553 cpumask_var_t *masks;
4554 int node;
4555 @@ -62,7 +62,7 @@ static cpumask_var_t *alloc_node_to_present_cpumask(void)
4556 return NULL;
4557 }
4558
4559 -static void free_node_to_present_cpumask(cpumask_var_t *masks)
4560 +static void free_node_to_possible_cpumask(cpumask_var_t *masks)
4561 {
4562 int node;
4563
4564 @@ -71,22 +71,22 @@ static void free_node_to_present_cpumask(cpumask_var_t *masks)
4565 kfree(masks);
4566 }
4567
4568 -static void build_node_to_present_cpumask(cpumask_var_t *masks)
4569 +static void build_node_to_possible_cpumask(cpumask_var_t *masks)
4570 {
4571 int cpu;
4572
4573 - for_each_present_cpu(cpu)
4574 + for_each_possible_cpu(cpu)
4575 cpumask_set_cpu(cpu, masks[cpu_to_node(cpu)]);
4576 }
4577
4578 -static int get_nodes_in_cpumask(cpumask_var_t *node_to_present_cpumask,
4579 +static int get_nodes_in_cpumask(cpumask_var_t *node_to_possible_cpumask,
4580 const struct cpumask *mask, nodemask_t *nodemsk)
4581 {
4582 int n, nodes = 0;
4583
4584 /* Calculate the number of nodes in the supplied affinity mask */
4585 for_each_node(n) {
4586 - if (cpumask_intersects(mask, node_to_present_cpumask[n])) {
4587 + if (cpumask_intersects(mask, node_to_possible_cpumask[n])) {
4588 node_set(n, *nodemsk);
4589 nodes++;
4590 }
4591 @@ -109,7 +109,7 @@ irq_create_affinity_masks(int nvecs, const struct irq_affinity *affd)
4592 int last_affv = affv + affd->pre_vectors;
4593 nodemask_t nodemsk = NODE_MASK_NONE;
4594 struct cpumask *masks;
4595 - cpumask_var_t nmsk, *node_to_present_cpumask;
4596 + cpumask_var_t nmsk, *node_to_possible_cpumask;
4597
4598 /*
4599 * If there aren't any vectors left after applying the pre/post
4600 @@ -125,8 +125,8 @@ irq_create_affinity_masks(int nvecs, const struct irq_affinity *affd)
4601 if (!masks)
4602 goto out;
4603
4604 - node_to_present_cpumask = alloc_node_to_present_cpumask();
4605 - if (!node_to_present_cpumask)
4606 + node_to_possible_cpumask = alloc_node_to_possible_cpumask();
4607 + if (!node_to_possible_cpumask)
4608 goto out;
4609
4610 /* Fill out vectors at the beginning that don't need affinity */
4611 @@ -135,8 +135,8 @@ irq_create_affinity_masks(int nvecs, const struct irq_affinity *affd)
4612
4613 /* Stabilize the cpumasks */
4614 get_online_cpus();
4615 - build_node_to_present_cpumask(node_to_present_cpumask);
4616 - nodes = get_nodes_in_cpumask(node_to_present_cpumask, cpu_present_mask,
4617 + build_node_to_possible_cpumask(node_to_possible_cpumask);
4618 + nodes = get_nodes_in_cpumask(node_to_possible_cpumask, cpu_possible_mask,
4619 &nodemsk);
4620
4621 /*
4622 @@ -146,7 +146,7 @@ irq_create_affinity_masks(int nvecs, const struct irq_affinity *affd)
4623 if (affv <= nodes) {
4624 for_each_node_mask(n, nodemsk) {
4625 cpumask_copy(masks + curvec,
4626 - node_to_present_cpumask[n]);
4627 + node_to_possible_cpumask[n]);
4628 if (++curvec == last_affv)
4629 break;
4630 }
4631 @@ -160,7 +160,7 @@ irq_create_affinity_masks(int nvecs, const struct irq_affinity *affd)
4632 vecs_per_node = (affv - (curvec - affd->pre_vectors)) / nodes;
4633
4634 /* Get the cpus on this node which are in the mask */
4635 - cpumask_and(nmsk, cpu_present_mask, node_to_present_cpumask[n]);
4636 + cpumask_and(nmsk, cpu_possible_mask, node_to_possible_cpumask[n]);
4637
4638 /* Calculate the number of cpus per vector */
4639 ncpus = cpumask_weight(nmsk);
4640 @@ -192,7 +192,7 @@ irq_create_affinity_masks(int nvecs, const struct irq_affinity *affd)
4641 /* Fill out vectors at the end that don't need affinity */
4642 for (; curvec < nvecs; curvec++)
4643 cpumask_copy(masks + curvec, irq_default_affinity);
4644 - free_node_to_present_cpumask(node_to_present_cpumask);
4645 + free_node_to_possible_cpumask(node_to_possible_cpumask);
4646 out:
4647 free_cpumask_var(nmsk);
4648 return masks;
4649 @@ -214,7 +214,7 @@ int irq_calc_affinity_vectors(int minvec, int maxvec, const struct irq_affinity
4650 return 0;
4651
4652 get_online_cpus();
4653 - ret = min_t(int, cpumask_weight(cpu_present_mask), vecs) + resv;
4654 + ret = min_t(int, cpumask_weight(cpu_possible_mask), vecs) + resv;
4655 put_online_cpus();
4656 return ret;
4657 }
4658 diff --git a/kernel/power/user.c b/kernel/power/user.c
4659 index 22df9f7ff672..69017a569f30 100644
4660 --- a/kernel/power/user.c
4661 +++ b/kernel/power/user.c
4662 @@ -186,6 +186,11 @@ static ssize_t snapshot_write(struct file *filp, const char __user *buf,
4663 res = PAGE_SIZE - pg_offp;
4664 }
4665
4666 + if (!data_of(data->handle)) {
4667 + res = -EINVAL;
4668 + goto unlock;
4669 + }
4670 +
4671 res = simple_write_to_buffer(data_of(data->handle), res, &pg_offp,
4672 buf, count);
4673 if (res > 0)
4674 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
4675 index 520ecaf61dc4..e268750bd4ad 100644
4676 --- a/kernel/trace/trace.c
4677 +++ b/kernel/trace/trace.c
4678 @@ -3359,8 +3359,8 @@ static void print_func_help_header(struct trace_buffer *buf, struct seq_file *m,
4679
4680 print_event_info(buf, m);
4681
4682 - seq_printf(m, "# TASK-PID CPU# %s TIMESTAMP FUNCTION\n", tgid ? "TGID " : "");
4683 - seq_printf(m, "# | | | %s | |\n", tgid ? " | " : "");
4684 + seq_printf(m, "# TASK-PID %s CPU# TIMESTAMP FUNCTION\n", tgid ? "TGID " : "");
4685 + seq_printf(m, "# | | %s | | |\n", tgid ? " | " : "");
4686 }
4687
4688 static void print_func_help_header_irq(struct trace_buffer *buf, struct seq_file *m,
4689 @@ -3380,9 +3380,9 @@ static void print_func_help_header_irq(struct trace_buffer *buf, struct seq_file
4690 tgid ? tgid_space : space);
4691 seq_printf(m, "# %s||| / delay\n",
4692 tgid ? tgid_space : space);
4693 - seq_printf(m, "# TASK-PID CPU#%s|||| TIMESTAMP FUNCTION\n",
4694 + seq_printf(m, "# TASK-PID %sCPU# |||| TIMESTAMP FUNCTION\n",
4695 tgid ? " TGID " : space);
4696 - seq_printf(m, "# | | | %s|||| | |\n",
4697 + seq_printf(m, "# | | %s | |||| | |\n",
4698 tgid ? " | " : space);
4699 }
4700
4701 diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
4702 index c738e764e2a5..4500b00e4e36 100644
4703 --- a/kernel/trace/trace_output.c
4704 +++ b/kernel/trace/trace_output.c
4705 @@ -594,8 +594,7 @@ int trace_print_context(struct trace_iterator *iter)
4706
4707 trace_find_cmdline(entry->pid, comm);
4708
4709 - trace_seq_printf(s, "%16s-%-5d [%03d] ",
4710 - comm, entry->pid, iter->cpu);
4711 + trace_seq_printf(s, "%16s-%-5d ", comm, entry->pid);
4712
4713 if (tr->trace_flags & TRACE_ITER_RECORD_TGID) {
4714 unsigned int tgid = trace_find_tgid(entry->pid);
4715 @@ -606,6 +605,8 @@ int trace_print_context(struct trace_iterator *iter)
4716 trace_seq_printf(s, "(%5d) ", tgid);
4717 }
4718
4719 + trace_seq_printf(s, "[%03d] ", iter->cpu);
4720 +
4721 if (tr->trace_flags & TRACE_ITER_IRQ_INFO)
4722 trace_print_lat_fmt(s, entry);
4723
4724 diff --git a/mm/gup.c b/mm/gup.c
4725 index 72c921da0f3b..4cc8a6ff0f56 100644
4726 --- a/mm/gup.c
4727 +++ b/mm/gup.c
4728 @@ -1235,8 +1235,6 @@ int __mm_populate(unsigned long start, unsigned long len, int ignore_errors)
4729 int locked = 0;
4730 long ret = 0;
4731
4732 - VM_BUG_ON(start & ~PAGE_MASK);
4733 - VM_BUG_ON(len != PAGE_ALIGN(len));
4734 end = start + len;
4735
4736 for (nstart = start; nstart < end; nstart = nend) {
4737 diff --git a/mm/mmap.c b/mm/mmap.c
4738 index f858b1f336af..2398776195d2 100644
4739 --- a/mm/mmap.c
4740 +++ b/mm/mmap.c
4741 @@ -177,8 +177,8 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
4742 return next;
4743 }
4744
4745 -static int do_brk(unsigned long addr, unsigned long len, struct list_head *uf);
4746 -
4747 +static int do_brk_flags(unsigned long addr, unsigned long request, unsigned long flags,
4748 + struct list_head *uf);
4749 SYSCALL_DEFINE1(brk, unsigned long, brk)
4750 {
4751 unsigned long retval;
4752 @@ -236,7 +236,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
4753 goto out;
4754
4755 /* Ok, looks good - let it rip. */
4756 - if (do_brk(oldbrk, newbrk-oldbrk, &uf) < 0)
4757 + if (do_brk_flags(oldbrk, newbrk-oldbrk, 0, &uf) < 0)
4758 goto out;
4759
4760 set_brk:
4761 @@ -2887,21 +2887,14 @@ static inline void verify_mm_writelocked(struct mm_struct *mm)
4762 * anonymous maps. eventually we may be able to do some
4763 * brk-specific accounting here.
4764 */
4765 -static int do_brk_flags(unsigned long addr, unsigned long request, unsigned long flags, struct list_head *uf)
4766 +static int do_brk_flags(unsigned long addr, unsigned long len, unsigned long flags, struct list_head *uf)
4767 {
4768 struct mm_struct *mm = current->mm;
4769 struct vm_area_struct *vma, *prev;
4770 - unsigned long len;
4771 struct rb_node **rb_link, *rb_parent;
4772 pgoff_t pgoff = addr >> PAGE_SHIFT;
4773 int error;
4774
4775 - len = PAGE_ALIGN(request);
4776 - if (len < request)
4777 - return -ENOMEM;
4778 - if (!len)
4779 - return 0;
4780 -
4781 /* Until we need other flags, refuse anything except VM_EXEC. */
4782 if ((flags & (~VM_EXEC)) != 0)
4783 return -EINVAL;
4784 @@ -2973,18 +2966,20 @@ static int do_brk_flags(unsigned long addr, unsigned long request, unsigned long
4785 return 0;
4786 }
4787
4788 -static int do_brk(unsigned long addr, unsigned long len, struct list_head *uf)
4789 -{
4790 - return do_brk_flags(addr, len, 0, uf);
4791 -}
4792 -
4793 -int vm_brk_flags(unsigned long addr, unsigned long len, unsigned long flags)
4794 +int vm_brk_flags(unsigned long addr, unsigned long request, unsigned long flags)
4795 {
4796 struct mm_struct *mm = current->mm;
4797 + unsigned long len;
4798 int ret;
4799 bool populate;
4800 LIST_HEAD(uf);
4801
4802 + len = PAGE_ALIGN(request);
4803 + if (len < request)
4804 + return -ENOMEM;
4805 + if (!len)
4806 + return 0;
4807 +
4808 if (down_write_killable(&mm->mmap_sem))
4809 return -EINTR;
4810
4811 diff --git a/mm/rmap.c b/mm/rmap.c
4812 index b874c4761e84..97edcf44d88c 100644
4813 --- a/mm/rmap.c
4814 +++ b/mm/rmap.c
4815 @@ -64,6 +64,7 @@
4816 #include <linux/backing-dev.h>
4817 #include <linux/page_idle.h>
4818 #include <linux/memremap.h>
4819 +#include <linux/userfaultfd_k.h>
4820
4821 #include <asm/tlbflush.h>
4822
4823 @@ -1476,11 +1477,16 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
4824 set_pte_at(mm, address, pvmw.pte, pteval);
4825 }
4826
4827 - } else if (pte_unused(pteval)) {
4828 + } else if (pte_unused(pteval) && !userfaultfd_armed(vma)) {
4829 /*
4830 * The guest indicated that the page content is of no
4831 * interest anymore. Simply discard the pte, vmscan
4832 * will take care of the rest.
4833 + * A future reference will then fault in a new zero
4834 + * page. When userfaultfd is active, we must not drop
4835 + * this page though, as its main user (postcopy
4836 + * migration) will not expect userfaults on already
4837 + * copied pages.
4838 */
4839 dec_mm_counter(mm, mm_counter(page));
4840 } else if (IS_ENABLED(CONFIG_MIGRATION) &&
4841 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
4842 index e27fb6e97d18..25738b20676d 100644
4843 --- a/net/bridge/netfilter/ebtables.c
4844 +++ b/net/bridge/netfilter/ebtables.c
4845 @@ -696,6 +696,8 @@ ebt_check_entry(struct ebt_entry *e, struct net *net,
4846 }
4847 i = 0;
4848
4849 + memset(&mtpar, 0, sizeof(mtpar));
4850 + memset(&tgpar, 0, sizeof(tgpar));
4851 mtpar.net = tgpar.net = net;
4852 mtpar.table = tgpar.table = name;
4853 mtpar.entryinfo = tgpar.entryinfo = e;
4854 diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
4855 index 1a925f2394ad..114d4bef1bec 100644
4856 --- a/net/ipv4/netfilter/ip_tables.c
4857 +++ b/net/ipv4/netfilter/ip_tables.c
4858 @@ -541,6 +541,7 @@ find_check_entry(struct ipt_entry *e, struct net *net, const char *name,
4859 return -ENOMEM;
4860
4861 j = 0;
4862 + memset(&mtpar, 0, sizeof(mtpar));
4863 mtpar.net = net;
4864 mtpar.table = name;
4865 mtpar.entryinfo = &e->ip;
4866 diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
4867 index c5fe42e6b7f7..2e51e0156903 100644
4868 --- a/net/ipv6/netfilter/ip6_tables.c
4869 +++ b/net/ipv6/netfilter/ip6_tables.c
4870 @@ -561,6 +561,7 @@ find_check_entry(struct ip6t_entry *e, struct net *net, const char *name,
4871 return -ENOMEM;
4872
4873 j = 0;
4874 + memset(&mtpar, 0, sizeof(mtpar));
4875 mtpar.net = net;
4876 mtpar.table = name;
4877 mtpar.entryinfo = &e->ipv6;
4878 diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c
4879 index c9796629858f..02bbc2f9f1f1 100644
4880 --- a/net/netfilter/nfnetlink_queue.c
4881 +++ b/net/netfilter/nfnetlink_queue.c
4882 @@ -1228,6 +1228,9 @@ static int nfqnl_recv_unsupp(struct net *net, struct sock *ctnl,
4883 static const struct nla_policy nfqa_cfg_policy[NFQA_CFG_MAX+1] = {
4884 [NFQA_CFG_CMD] = { .len = sizeof(struct nfqnl_msg_config_cmd) },
4885 [NFQA_CFG_PARAMS] = { .len = sizeof(struct nfqnl_msg_config_params) },
4886 + [NFQA_CFG_QUEUE_MAXLEN] = { .type = NLA_U32 },
4887 + [NFQA_CFG_MASK] = { .type = NLA_U32 },
4888 + [NFQA_CFG_FLAGS] = { .type = NLA_U32 },
4889 };
4890
4891 static const struct nf_queue_handler nfqh = {
4892 diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
4893 index 7d7eb1354eee..ffb6aba71998 100644
4894 --- a/sound/pci/hda/patch_hdmi.c
4895 +++ b/sound/pci/hda/patch_hdmi.c
4896 @@ -33,6 +33,7 @@
4897 #include <linux/delay.h>
4898 #include <linux/slab.h>
4899 #include <linux/module.h>
4900 +#include <linux/pm_runtime.h>
4901 #include <sound/core.h>
4902 #include <sound/jack.h>
4903 #include <sound/asoundef.h>
4904 @@ -764,8 +765,10 @@ static void check_presence_and_report(struct hda_codec *codec, hda_nid_t nid,
4905
4906 if (pin_idx < 0)
4907 return;
4908 + mutex_lock(&spec->pcm_lock);
4909 if (hdmi_present_sense(get_pin(spec, pin_idx), 1))
4910 snd_hda_jack_report_sync(codec);
4911 + mutex_unlock(&spec->pcm_lock);
4912 }
4913
4914 static void jack_callback(struct hda_codec *codec,
4915 @@ -1628,21 +1631,23 @@ static void sync_eld_via_acomp(struct hda_codec *codec,
4916 static bool hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll)
4917 {
4918 struct hda_codec *codec = per_pin->codec;
4919 - struct hdmi_spec *spec = codec->spec;
4920 int ret;
4921
4922 /* no temporary power up/down needed for component notifier */
4923 - if (!codec_has_acomp(codec))
4924 - snd_hda_power_up_pm(codec);
4925 + if (!codec_has_acomp(codec)) {
4926 + ret = snd_hda_power_up_pm(codec);
4927 + if (ret < 0 && pm_runtime_suspended(hda_codec_dev(codec))) {
4928 + snd_hda_power_down_pm(codec);
4929 + return false;
4930 + }
4931 + }
4932
4933 - mutex_lock(&spec->pcm_lock);
4934 if (codec_has_acomp(codec)) {
4935 sync_eld_via_acomp(codec, per_pin);
4936 ret = false; /* don't call snd_hda_jack_report_sync() */
4937 } else {
4938 ret = hdmi_present_sense_via_verbs(per_pin, repoll);
4939 }
4940 - mutex_unlock(&spec->pcm_lock);
4941
4942 if (!codec_has_acomp(codec))
4943 snd_hda_power_down_pm(codec);
4944 @@ -1654,12 +1659,16 @@ static void hdmi_repoll_eld(struct work_struct *work)
4945 {
4946 struct hdmi_spec_per_pin *per_pin =
4947 container_of(to_delayed_work(work), struct hdmi_spec_per_pin, work);
4948 + struct hda_codec *codec = per_pin->codec;
4949 + struct hdmi_spec *spec = codec->spec;
4950
4951 if (per_pin->repoll_count++ > 6)
4952 per_pin->repoll_count = 0;
4953
4954 + mutex_lock(&spec->pcm_lock);
4955 if (hdmi_present_sense(per_pin, per_pin->repoll_count))
4956 snd_hda_jack_report_sync(per_pin->codec);
4957 + mutex_unlock(&spec->pcm_lock);
4958 }
4959
4960 static void intel_haswell_fixup_connect_list(struct hda_codec *codec,
4961 diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
4962 index 02157e3d82bb..bf7737fc3b28 100644
4963 --- a/sound/pci/hda/patch_realtek.c
4964 +++ b/sound/pci/hda/patch_realtek.c
4965 @@ -6445,7 +6445,6 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
4966 SND_PCI_QUIRK(0x17aa, 0x310c, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
4967 SND_PCI_QUIRK(0x17aa, 0x312a, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
4968 SND_PCI_QUIRK(0x17aa, 0x312f, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
4969 - SND_PCI_QUIRK(0x17aa, 0x3136, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
4970 SND_PCI_QUIRK(0x17aa, 0x313c, "ThinkCentre Station", ALC294_FIXUP_LENOVO_MIC_LOCATION),
4971 SND_PCI_QUIRK(0x17aa, 0x3902, "Lenovo E50-80", ALC269_FIXUP_DMIC_THINKPAD_ACPI),
4972 SND_PCI_QUIRK(0x17aa, 0x3977, "IdeaPad S210", ALC283_FIXUP_INT_MIC),
4973 @@ -6628,6 +6627,11 @@ static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = {
4974 {0x1a, 0x02a11040},
4975 {0x1b, 0x01014020},
4976 {0x21, 0x0221101f}),
4977 + SND_HDA_PIN_QUIRK(0x10ec0235, 0x17aa, "Lenovo", ALC294_FIXUP_LENOVO_MIC_LOCATION,
4978 + {0x14, 0x90170110},
4979 + {0x19, 0x02a11020},
4980 + {0x1a, 0x02a11030},
4981 + {0x21, 0x0221101f}),
4982 SND_HDA_PIN_QUIRK(0x10ec0236, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE,
4983 {0x12, 0x90a60140},
4984 {0x14, 0x90170150},
4985 diff --git a/sound/soc/mediatek/common/mtk-afe-platform-driver.c b/sound/soc/mediatek/common/mtk-afe-platform-driver.c
4986 index 82d439c15f4e..e58fbefa5e6b 100644
4987 --- a/sound/soc/mediatek/common/mtk-afe-platform-driver.c
4988 +++ b/sound/soc/mediatek/common/mtk-afe-platform-driver.c
4989 @@ -63,13 +63,13 @@ static const struct snd_pcm_ops mtk_afe_pcm_ops = {
4990 static int mtk_afe_pcm_new(struct snd_soc_pcm_runtime *rtd)
4991 {
4992 size_t size;
4993 - struct snd_card *card = rtd->card->snd_card;
4994 struct snd_pcm *pcm = rtd->pcm;
4995 struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform);
4996
4997 size = afe->mtk_afe_hardware->buffer_bytes_max;
4998 return snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
4999 - card->dev, size, size);
5000 + rtd->platform->dev,
5001 + size, size);
5002 }
5003
5004 static void mtk_afe_pcm_free(struct snd_pcm *pcm)
5005 diff --git a/tools/build/Build.include b/tools/build/Build.include
5006 index a4bbb984941d..d9048f145f97 100644
5007 --- a/tools/build/Build.include
5008 +++ b/tools/build/Build.include
5009 @@ -63,8 +63,8 @@ dep-cmd = $(if $(wildcard $(fixdep)),
5010 $(fixdep) $(depfile) $@ '$(make-cmd)' > $(dot-target).tmp; \
5011 rm -f $(depfile); \
5012 mv -f $(dot-target).tmp $(dot-target).cmd, \
5013 - printf '\# cannot find fixdep (%s)\n' $(fixdep) > $(dot-target).cmd; \
5014 - printf '\# using basic dep data\n\n' >> $(dot-target).cmd; \
5015 + printf '$(pound) cannot find fixdep (%s)\n' $(fixdep) > $(dot-target).cmd; \
5016 + printf '$(pound) using basic dep data\n\n' >> $(dot-target).cmd; \
5017 cat $(depfile) >> $(dot-target).cmd; \
5018 printf '\n%s\n' 'cmd_$@ := $(make-cmd)' >> $(dot-target).cmd)
5019