Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:4.14 commit in: /
Date: Wed, 14 Nov 2018 13:49:14
Message-Id: 1542203320.5daaa2d96ad75e2c90ebbac27e9f183713cc887e.mpagano@gentoo
1 commit: 5daaa2d96ad75e2c90ebbac27e9f183713cc887e
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Fri Aug 17 19:26:38 2018 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Wed Nov 14 13:48:40 2018 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=5daaa2d9
7
8 Linux patch 4.14.64
9
10 Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org>
11
12 0000_README | 4 +
13 1063_linux-4.14.64.patch | 1527 ++++++++++++++++++++++++++++++++++++++++++++++
14 2 files changed, 1531 insertions(+)
15
16 diff --git a/0000_README b/0000_README
17 index ada5b82..41f1d75 100644
18 --- a/0000_README
19 +++ b/0000_README
20 @@ -295,6 +295,10 @@ Patch: 1062_linux-4.14.63.patch
21 From: http://www.kernel.org
22 Desc: Linux 4.14.63
23
24 +Patch: 1063_linux-4.14.64.patch
25 +From: http://www.kernel.org
26 +Desc: Linux 4.14.64
27 +
28 Patch: 1500_XATTR_USER_PREFIX.patch
29 From: https://bugs.gentoo.org/show_bug.cgi?id=470644
30 Desc: Support for namespace user.pax.* on tmpfs.
31
32 diff --git a/1063_linux-4.14.64.patch b/1063_linux-4.14.64.patch
33 new file mode 100644
34 index 0000000..b4a1f5f
35 --- /dev/null
36 +++ b/1063_linux-4.14.64.patch
37 @@ -0,0 +1,1527 @@
38 +diff --git a/Documentation/process/changes.rst b/Documentation/process/changes.rst
39 +index 560beaef5a7c..73fcdcd52b87 100644
40 +--- a/Documentation/process/changes.rst
41 ++++ b/Documentation/process/changes.rst
42 +@@ -33,7 +33,7 @@ GNU C 3.2 gcc --version
43 + GNU make 3.81 make --version
44 + binutils 2.20 ld -v
45 + util-linux 2.10o fdformat --version
46 +-module-init-tools 0.9.10 depmod -V
47 ++kmod 13 depmod -V
48 + e2fsprogs 1.41.4 e2fsck -V
49 + jfsutils 1.1.3 fsck.jfs -V
50 + reiserfsprogs 3.6.3 reiserfsck -V
51 +@@ -141,12 +141,6 @@ is not build with ``CONFIG_KALLSYMS`` and you have no way to rebuild and
52 + reproduce the Oops with that option, then you can still decode that Oops
53 + with ksymoops.
54 +
55 +-Module-Init-Tools
56 +------------------
57 +-
58 +-A new module loader is now in the kernel that requires ``module-init-tools``
59 +-to use. It is backward compatible with the 2.4.x series kernels.
60 +-
61 + Mkinitrd
62 + --------
63 +
64 +@@ -346,16 +340,17 @@ Util-linux
65 +
66 + - <https://www.kernel.org/pub/linux/utils/util-linux/>
67 +
68 ++Kmod
69 ++----
70 ++
71 ++- <https://www.kernel.org/pub/linux/utils/kernel/kmod/>
72 ++- <https://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git>
73 ++
74 + Ksymoops
75 + --------
76 +
77 + - <https://www.kernel.org/pub/linux/utils/kernel/ksymoops/v2.4/>
78 +
79 +-Module-Init-Tools
80 +------------------
81 +-
82 +-- <https://www.kernel.org/pub/linux/utils/kernel/module-init-tools/>
83 +-
84 + Mkinitrd
85 + --------
86 +
87 +diff --git a/Makefile b/Makefile
88 +index f3bb9428b3dc..025156791e90 100644
89 +--- a/Makefile
90 ++++ b/Makefile
91 +@@ -1,7 +1,7 @@
92 + # SPDX-License-Identifier: GPL-2.0
93 + VERSION = 4
94 + PATCHLEVEL = 14
95 +-SUBLEVEL = 63
96 ++SUBLEVEL = 64
97 + EXTRAVERSION =
98 + NAME = Petit Gorille
99 +
100 +diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
101 +index f6b877d2726d..6ac0d32d60a5 100644
102 +--- a/arch/arm64/mm/mmu.c
103 ++++ b/arch/arm64/mm/mmu.c
104 +@@ -938,12 +938,12 @@ int pmd_clear_huge(pmd_t *pmd)
105 + return 1;
106 + }
107 +
108 +-int pud_free_pmd_page(pud_t *pud)
109 ++int pud_free_pmd_page(pud_t *pud, unsigned long addr)
110 + {
111 + return pud_none(*pud);
112 + }
113 +
114 +-int pmd_free_pte_page(pmd_t *pmd)
115 ++int pmd_free_pte_page(pmd_t *pmd, unsigned long addr)
116 + {
117 + return pmd_none(*pmd);
118 + }
119 +diff --git a/arch/x86/crypto/sha256-mb/sha256_mb_mgr_flush_avx2.S b/arch/x86/crypto/sha256-mb/sha256_mb_mgr_flush_avx2.S
120 +index 16c4ccb1f154..d2364c55bbde 100644
121 +--- a/arch/x86/crypto/sha256-mb/sha256_mb_mgr_flush_avx2.S
122 ++++ b/arch/x86/crypto/sha256-mb/sha256_mb_mgr_flush_avx2.S
123 +@@ -265,7 +265,7 @@ ENTRY(sha256_mb_mgr_get_comp_job_avx2)
124 + vpinsrd $1, _args_digest+1*32(state, idx, 4), %xmm0, %xmm0
125 + vpinsrd $2, _args_digest+2*32(state, idx, 4), %xmm0, %xmm0
126 + vpinsrd $3, _args_digest+3*32(state, idx, 4), %xmm0, %xmm0
127 +- vmovd _args_digest(state , idx, 4) , %xmm0
128 ++ vmovd _args_digest+4*32(state, idx, 4), %xmm1
129 + vpinsrd $1, _args_digest+5*32(state, idx, 4), %xmm1, %xmm1
130 + vpinsrd $2, _args_digest+6*32(state, idx, 4), %xmm1, %xmm1
131 + vpinsrd $3, _args_digest+7*32(state, idx, 4), %xmm1, %xmm1
132 +diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
133 +index 5cdcdbd4d892..89789e8c80f6 100644
134 +--- a/arch/x86/include/asm/i8259.h
135 ++++ b/arch/x86/include/asm/i8259.h
136 +@@ -3,6 +3,7 @@
137 + #define _ASM_X86_I8259_H
138 +
139 + #include <linux/delay.h>
140 ++#include <asm/io.h>
141 +
142 + extern unsigned int cached_irq_mask;
143 +
144 +diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
145 +index edfc64a8a154..d07addb99b71 100644
146 +--- a/arch/x86/kernel/cpu/bugs.c
147 ++++ b/arch/x86/kernel/cpu/bugs.c
148 +@@ -648,10 +648,9 @@ void x86_spec_ctrl_setup_ap(void)
149 + enum l1tf_mitigations l1tf_mitigation __ro_after_init = L1TF_MITIGATION_FLUSH;
150 + #if IS_ENABLED(CONFIG_KVM_INTEL)
151 + EXPORT_SYMBOL_GPL(l1tf_mitigation);
152 +-
153 ++#endif
154 + enum vmx_l1d_flush_state l1tf_vmx_mitigation = VMENTER_L1D_FLUSH_AUTO;
155 + EXPORT_SYMBOL_GPL(l1tf_vmx_mitigation);
156 +-#endif
157 +
158 + static void __init l1tf_select_mitigation(void)
159 + {
160 +diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
161 +index c03c85e4fb6a..2bdb8e8a9d7c 100644
162 +--- a/arch/x86/mm/pgtable.c
163 ++++ b/arch/x86/mm/pgtable.c
164 +@@ -712,28 +712,50 @@ int pmd_clear_huge(pmd_t *pmd)
165 + return 0;
166 + }
167 +
168 ++#ifdef CONFIG_X86_64
169 + /**
170 + * pud_free_pmd_page - Clear pud entry and free pmd page.
171 + * @pud: Pointer to a PUD.
172 ++ * @addr: Virtual address associated with pud.
173 + *
174 +- * Context: The pud range has been unmaped and TLB purged.
175 ++ * Context: The pud range has been unmapped and TLB purged.
176 + * Return: 1 if clearing the entry succeeded. 0 otherwise.
177 ++ *
178 ++ * NOTE: Callers must allow a single page allocation.
179 + */
180 +-int pud_free_pmd_page(pud_t *pud)
181 ++int pud_free_pmd_page(pud_t *pud, unsigned long addr)
182 + {
183 +- pmd_t *pmd;
184 ++ pmd_t *pmd, *pmd_sv;
185 ++ pte_t *pte;
186 + int i;
187 +
188 + if (pud_none(*pud))
189 + return 1;
190 +
191 + pmd = (pmd_t *)pud_page_vaddr(*pud);
192 ++ pmd_sv = (pmd_t *)__get_free_page(GFP_KERNEL);
193 ++ if (!pmd_sv)
194 ++ return 0;
195 +
196 +- for (i = 0; i < PTRS_PER_PMD; i++)
197 +- if (!pmd_free_pte_page(&pmd[i]))
198 +- return 0;
199 ++ for (i = 0; i < PTRS_PER_PMD; i++) {
200 ++ pmd_sv[i] = pmd[i];
201 ++ if (!pmd_none(pmd[i]))
202 ++ pmd_clear(&pmd[i]);
203 ++ }
204 +
205 + pud_clear(pud);
206 ++
207 ++ /* INVLPG to clear all paging-structure caches */
208 ++ flush_tlb_kernel_range(addr, addr + PAGE_SIZE-1);
209 ++
210 ++ for (i = 0; i < PTRS_PER_PMD; i++) {
211 ++ if (!pmd_none(pmd_sv[i])) {
212 ++ pte = (pte_t *)pmd_page_vaddr(pmd_sv[i]);
213 ++ free_page((unsigned long)pte);
214 ++ }
215 ++ }
216 ++
217 ++ free_page((unsigned long)pmd_sv);
218 + free_page((unsigned long)pmd);
219 +
220 + return 1;
221 +@@ -742,11 +764,12 @@ int pud_free_pmd_page(pud_t *pud)
222 + /**
223 + * pmd_free_pte_page - Clear pmd entry and free pte page.
224 + * @pmd: Pointer to a PMD.
225 ++ * @addr: Virtual address associated with pmd.
226 + *
227 +- * Context: The pmd range has been unmaped and TLB purged.
228 ++ * Context: The pmd range has been unmapped and TLB purged.
229 + * Return: 1 if clearing the entry succeeded. 0 otherwise.
230 + */
231 +-int pmd_free_pte_page(pmd_t *pmd)
232 ++int pmd_free_pte_page(pmd_t *pmd, unsigned long addr)
233 + {
234 + pte_t *pte;
235 +
236 +@@ -755,8 +778,30 @@ int pmd_free_pte_page(pmd_t *pmd)
237 +
238 + pte = (pte_t *)pmd_page_vaddr(*pmd);
239 + pmd_clear(pmd);
240 ++
241 ++ /* INVLPG to clear all paging-structure caches */
242 ++ flush_tlb_kernel_range(addr, addr + PAGE_SIZE-1);
243 ++
244 + free_page((unsigned long)pte);
245 +
246 + return 1;
247 + }
248 ++
249 ++#else /* !CONFIG_X86_64 */
250 ++
251 ++int pud_free_pmd_page(pud_t *pud, unsigned long addr)
252 ++{
253 ++ return pud_none(*pud);
254 ++}
255 ++
256 ++/*
257 ++ * Disable free page handling on x86-PAE. This assures that ioremap()
258 ++ * does not update sync'd pmd entries. See vmalloc_sync_one().
259 ++ */
260 ++int pmd_free_pte_page(pmd_t *pmd, unsigned long addr)
261 ++{
262 ++ return pmd_none(*pmd);
263 ++}
264 ++
265 ++#endif /* CONFIG_X86_64 */
266 + #endif /* CONFIG_HAVE_ARCH_HUGE_VMAP */
267 +diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c
268 +index 4a4b7d3c909a..3b44bd28fc45 100644
269 +--- a/block/bfq-iosched.c
270 ++++ b/block/bfq-iosched.c
271 +@@ -1203,6 +1203,24 @@ static unsigned int bfq_wr_duration(struct bfq_data *bfqd)
272 + return dur;
273 + }
274 +
275 ++/*
276 ++ * Return the farthest future time instant according to jiffies
277 ++ * macros.
278 ++ */
279 ++static unsigned long bfq_greatest_from_now(void)
280 ++{
281 ++ return jiffies + MAX_JIFFY_OFFSET;
282 ++}
283 ++
284 ++/*
285 ++ * Return the farthest past time instant according to jiffies
286 ++ * macros.
287 ++ */
288 ++static unsigned long bfq_smallest_from_now(void)
289 ++{
290 ++ return jiffies - MAX_JIFFY_OFFSET;
291 ++}
292 ++
293 + static void bfq_update_bfqq_wr_on_rq_arrival(struct bfq_data *bfqd,
294 + struct bfq_queue *bfqq,
295 + unsigned int old_wr_coeff,
296 +@@ -1217,7 +1235,19 @@ static void bfq_update_bfqq_wr_on_rq_arrival(struct bfq_data *bfqd,
297 + bfqq->wr_coeff = bfqd->bfq_wr_coeff;
298 + bfqq->wr_cur_max_time = bfq_wr_duration(bfqd);
299 + } else {
300 +- bfqq->wr_start_at_switch_to_srt = jiffies;
301 ++ /*
302 ++ * No interactive weight raising in progress
303 ++ * here: assign minus infinity to
304 ++ * wr_start_at_switch_to_srt, to make sure
305 ++ * that, at the end of the soft-real-time
306 ++ * weight raising periods that is starting
307 ++ * now, no interactive weight-raising period
308 ++ * may be wrongly considered as still in
309 ++ * progress (and thus actually started by
310 ++ * mistake).
311 ++ */
312 ++ bfqq->wr_start_at_switch_to_srt =
313 ++ bfq_smallest_from_now();
314 + bfqq->wr_coeff = bfqd->bfq_wr_coeff *
315 + BFQ_SOFTRT_WEIGHT_FACTOR;
316 + bfqq->wr_cur_max_time =
317 +@@ -2896,24 +2926,6 @@ static unsigned long bfq_bfqq_softrt_next_start(struct bfq_data *bfqd,
318 + jiffies + nsecs_to_jiffies(bfqq->bfqd->bfq_slice_idle) + 4);
319 + }
320 +
321 +-/*
322 +- * Return the farthest future time instant according to jiffies
323 +- * macros.
324 +- */
325 +-static unsigned long bfq_greatest_from_now(void)
326 +-{
327 +- return jiffies + MAX_JIFFY_OFFSET;
328 +-}
329 +-
330 +-/*
331 +- * Return the farthest past time instant according to jiffies
332 +- * macros.
333 +- */
334 +-static unsigned long bfq_smallest_from_now(void)
335 +-{
336 +- return jiffies - MAX_JIFFY_OFFSET;
337 +-}
338 +-
339 + /**
340 + * bfq_bfqq_expire - expire a queue.
341 + * @bfqd: device owning the queue.
342 +diff --git a/crypto/ablkcipher.c b/crypto/ablkcipher.c
343 +index d880a4897159..4ee7c041bb82 100644
344 +--- a/crypto/ablkcipher.c
345 ++++ b/crypto/ablkcipher.c
346 +@@ -71,11 +71,9 @@ static inline u8 *ablkcipher_get_spot(u8 *start, unsigned int len)
347 + return max(start, end_page);
348 + }
349 +
350 +-static inline unsigned int ablkcipher_done_slow(struct ablkcipher_walk *walk,
351 +- unsigned int bsize)
352 ++static inline void ablkcipher_done_slow(struct ablkcipher_walk *walk,
353 ++ unsigned int n)
354 + {
355 +- unsigned int n = bsize;
356 +-
357 + for (;;) {
358 + unsigned int len_this_page = scatterwalk_pagelen(&walk->out);
359 +
360 +@@ -87,17 +85,13 @@ static inline unsigned int ablkcipher_done_slow(struct ablkcipher_walk *walk,
361 + n -= len_this_page;
362 + scatterwalk_start(&walk->out, sg_next(walk->out.sg));
363 + }
364 +-
365 +- return bsize;
366 + }
367 +
368 +-static inline unsigned int ablkcipher_done_fast(struct ablkcipher_walk *walk,
369 +- unsigned int n)
370 ++static inline void ablkcipher_done_fast(struct ablkcipher_walk *walk,
371 ++ unsigned int n)
372 + {
373 + scatterwalk_advance(&walk->in, n);
374 + scatterwalk_advance(&walk->out, n);
375 +-
376 +- return n;
377 + }
378 +
379 + static int ablkcipher_walk_next(struct ablkcipher_request *req,
380 +@@ -107,39 +101,40 @@ int ablkcipher_walk_done(struct ablkcipher_request *req,
381 + struct ablkcipher_walk *walk, int err)
382 + {
383 + struct crypto_tfm *tfm = req->base.tfm;
384 +- unsigned int nbytes = 0;
385 ++ unsigned int n; /* bytes processed */
386 ++ bool more;
387 +
388 +- if (likely(err >= 0)) {
389 +- unsigned int n = walk->nbytes - err;
390 ++ if (unlikely(err < 0))
391 ++ goto finish;
392 +
393 +- if (likely(!(walk->flags & ABLKCIPHER_WALK_SLOW)))
394 +- n = ablkcipher_done_fast(walk, n);
395 +- else if (WARN_ON(err)) {
396 +- err = -EINVAL;
397 +- goto err;
398 +- } else
399 +- n = ablkcipher_done_slow(walk, n);
400 ++ n = walk->nbytes - err;
401 ++ walk->total -= n;
402 ++ more = (walk->total != 0);
403 +
404 +- nbytes = walk->total - n;
405 +- err = 0;
406 ++ if (likely(!(walk->flags & ABLKCIPHER_WALK_SLOW))) {
407 ++ ablkcipher_done_fast(walk, n);
408 ++ } else {
409 ++ if (WARN_ON(err)) {
410 ++ /* unexpected case; didn't process all bytes */
411 ++ err = -EINVAL;
412 ++ goto finish;
413 ++ }
414 ++ ablkcipher_done_slow(walk, n);
415 + }
416 +
417 +- scatterwalk_done(&walk->in, 0, nbytes);
418 +- scatterwalk_done(&walk->out, 1, nbytes);
419 +-
420 +-err:
421 +- walk->total = nbytes;
422 +- walk->nbytes = nbytes;
423 ++ scatterwalk_done(&walk->in, 0, more);
424 ++ scatterwalk_done(&walk->out, 1, more);
425 +
426 +- if (nbytes) {
427 ++ if (more) {
428 + crypto_yield(req->base.flags);
429 + return ablkcipher_walk_next(req, walk);
430 + }
431 +-
432 ++ err = 0;
433 ++finish:
434 ++ walk->nbytes = 0;
435 + if (walk->iv != req->info)
436 + memcpy(req->info, walk->iv, tfm->crt_ablkcipher.ivsize);
437 + kfree(walk->iv_buffer);
438 +-
439 + return err;
440 + }
441 + EXPORT_SYMBOL_GPL(ablkcipher_walk_done);
442 +diff --git a/crypto/blkcipher.c b/crypto/blkcipher.c
443 +index 6c43a0a17a55..d84c6920ada9 100644
444 +--- a/crypto/blkcipher.c
445 ++++ b/crypto/blkcipher.c
446 +@@ -71,19 +71,18 @@ static inline u8 *blkcipher_get_spot(u8 *start, unsigned int len)
447 + return max(start, end_page);
448 + }
449 +
450 +-static inline unsigned int blkcipher_done_slow(struct blkcipher_walk *walk,
451 +- unsigned int bsize)
452 ++static inline void blkcipher_done_slow(struct blkcipher_walk *walk,
453 ++ unsigned int bsize)
454 + {
455 + u8 *addr;
456 +
457 + addr = (u8 *)ALIGN((unsigned long)walk->buffer, walk->alignmask + 1);
458 + addr = blkcipher_get_spot(addr, bsize);
459 + scatterwalk_copychunks(addr, &walk->out, bsize, 1);
460 +- return bsize;
461 + }
462 +
463 +-static inline unsigned int blkcipher_done_fast(struct blkcipher_walk *walk,
464 +- unsigned int n)
465 ++static inline void blkcipher_done_fast(struct blkcipher_walk *walk,
466 ++ unsigned int n)
467 + {
468 + if (walk->flags & BLKCIPHER_WALK_COPY) {
469 + blkcipher_map_dst(walk);
470 +@@ -97,49 +96,48 @@ static inline unsigned int blkcipher_done_fast(struct blkcipher_walk *walk,
471 +
472 + scatterwalk_advance(&walk->in, n);
473 + scatterwalk_advance(&walk->out, n);
474 +-
475 +- return n;
476 + }
477 +
478 + int blkcipher_walk_done(struct blkcipher_desc *desc,
479 + struct blkcipher_walk *walk, int err)
480 + {
481 +- unsigned int nbytes = 0;
482 ++ unsigned int n; /* bytes processed */
483 ++ bool more;
484 +
485 +- if (likely(err >= 0)) {
486 +- unsigned int n = walk->nbytes - err;
487 ++ if (unlikely(err < 0))
488 ++ goto finish;
489 +
490 +- if (likely(!(walk->flags & BLKCIPHER_WALK_SLOW)))
491 +- n = blkcipher_done_fast(walk, n);
492 +- else if (WARN_ON(err)) {
493 +- err = -EINVAL;
494 +- goto err;
495 +- } else
496 +- n = blkcipher_done_slow(walk, n);
497 ++ n = walk->nbytes - err;
498 ++ walk->total -= n;
499 ++ more = (walk->total != 0);
500 +
501 +- nbytes = walk->total - n;
502 +- err = 0;
503 ++ if (likely(!(walk->flags & BLKCIPHER_WALK_SLOW))) {
504 ++ blkcipher_done_fast(walk, n);
505 ++ } else {
506 ++ if (WARN_ON(err)) {
507 ++ /* unexpected case; didn't process all bytes */
508 ++ err = -EINVAL;
509 ++ goto finish;
510 ++ }
511 ++ blkcipher_done_slow(walk, n);
512 + }
513 +
514 +- scatterwalk_done(&walk->in, 0, nbytes);
515 +- scatterwalk_done(&walk->out, 1, nbytes);
516 ++ scatterwalk_done(&walk->in, 0, more);
517 ++ scatterwalk_done(&walk->out, 1, more);
518 +
519 +-err:
520 +- walk->total = nbytes;
521 +- walk->nbytes = nbytes;
522 +-
523 +- if (nbytes) {
524 ++ if (more) {
525 + crypto_yield(desc->flags);
526 + return blkcipher_walk_next(desc, walk);
527 + }
528 +-
529 ++ err = 0;
530 ++finish:
531 ++ walk->nbytes = 0;
532 + if (walk->iv != desc->info)
533 + memcpy(desc->info, walk->iv, walk->ivsize);
534 + if (walk->buffer != walk->page)
535 + kfree(walk->buffer);
536 + if (walk->page)
537 + free_page((unsigned long)walk->page);
538 +-
539 + return err;
540 + }
541 + EXPORT_SYMBOL_GPL(blkcipher_walk_done);
542 +diff --git a/crypto/skcipher.c b/crypto/skcipher.c
543 +index 11af5fd6a443..e319421a32e7 100644
544 +--- a/crypto/skcipher.c
545 ++++ b/crypto/skcipher.c
546 +@@ -95,7 +95,7 @@ static inline u8 *skcipher_get_spot(u8 *start, unsigned int len)
547 + return max(start, end_page);
548 + }
549 +
550 +-static int skcipher_done_slow(struct skcipher_walk *walk, unsigned int bsize)
551 ++static void skcipher_done_slow(struct skcipher_walk *walk, unsigned int bsize)
552 + {
553 + u8 *addr;
554 +
555 +@@ -103,23 +103,24 @@ static int skcipher_done_slow(struct skcipher_walk *walk, unsigned int bsize)
556 + addr = skcipher_get_spot(addr, bsize);
557 + scatterwalk_copychunks(addr, &walk->out, bsize,
558 + (walk->flags & SKCIPHER_WALK_PHYS) ? 2 : 1);
559 +- return 0;
560 + }
561 +
562 + int skcipher_walk_done(struct skcipher_walk *walk, int err)
563 + {
564 +- unsigned int n = walk->nbytes - err;
565 +- unsigned int nbytes;
566 ++ unsigned int n; /* bytes processed */
567 ++ bool more;
568 ++
569 ++ if (unlikely(err < 0))
570 ++ goto finish;
571 +
572 +- nbytes = walk->total - n;
573 ++ n = walk->nbytes - err;
574 ++ walk->total -= n;
575 ++ more = (walk->total != 0);
576 +
577 +- if (unlikely(err < 0)) {
578 +- nbytes = 0;
579 +- n = 0;
580 +- } else if (likely(!(walk->flags & (SKCIPHER_WALK_PHYS |
581 +- SKCIPHER_WALK_SLOW |
582 +- SKCIPHER_WALK_COPY |
583 +- SKCIPHER_WALK_DIFF)))) {
584 ++ if (likely(!(walk->flags & (SKCIPHER_WALK_PHYS |
585 ++ SKCIPHER_WALK_SLOW |
586 ++ SKCIPHER_WALK_COPY |
587 ++ SKCIPHER_WALK_DIFF)))) {
588 + unmap_src:
589 + skcipher_unmap_src(walk);
590 + } else if (walk->flags & SKCIPHER_WALK_DIFF) {
591 +@@ -131,28 +132,28 @@ unmap_src:
592 + skcipher_unmap_dst(walk);
593 + } else if (unlikely(walk->flags & SKCIPHER_WALK_SLOW)) {
594 + if (WARN_ON(err)) {
595 ++ /* unexpected case; didn't process all bytes */
596 + err = -EINVAL;
597 +- nbytes = 0;
598 +- } else
599 +- n = skcipher_done_slow(walk, n);
600 ++ goto finish;
601 ++ }
602 ++ skcipher_done_slow(walk, n);
603 ++ goto already_advanced;
604 + }
605 +
606 +- if (err > 0)
607 +- err = 0;
608 +-
609 +- walk->total = nbytes;
610 +- walk->nbytes = nbytes;
611 +-
612 + scatterwalk_advance(&walk->in, n);
613 + scatterwalk_advance(&walk->out, n);
614 +- scatterwalk_done(&walk->in, 0, nbytes);
615 +- scatterwalk_done(&walk->out, 1, nbytes);
616 ++already_advanced:
617 ++ scatterwalk_done(&walk->in, 0, more);
618 ++ scatterwalk_done(&walk->out, 1, more);
619 +
620 +- if (nbytes) {
621 ++ if (more) {
622 + crypto_yield(walk->flags & SKCIPHER_WALK_SLEEP ?
623 + CRYPTO_TFM_REQ_MAY_SLEEP : 0);
624 + return skcipher_walk_next(walk);
625 + }
626 ++ err = 0;
627 ++finish:
628 ++ walk->nbytes = 0;
629 +
630 + /* Short-circuit for the common/fast path. */
631 + if (!((unsigned long)walk->buffer | (unsigned long)walk->page))
632 +@@ -399,7 +400,7 @@ static int skcipher_copy_iv(struct skcipher_walk *walk)
633 + unsigned size;
634 + u8 *iv;
635 +
636 +- aligned_bs = ALIGN(bs, alignmask);
637 ++ aligned_bs = ALIGN(bs, alignmask + 1);
638 +
639 + /* Minimum size to align buffer by alignmask. */
640 + size = alignmask & ~a;
641 +diff --git a/crypto/vmac.c b/crypto/vmac.c
642 +index df76a816cfb2..bb2fc787d615 100644
643 +--- a/crypto/vmac.c
644 ++++ b/crypto/vmac.c
645 +@@ -1,6 +1,10 @@
646 + /*
647 +- * Modified to interface to the Linux kernel
648 ++ * VMAC: Message Authentication Code using Universal Hashing
649 ++ *
650 ++ * Reference: https://tools.ietf.org/html/draft-krovetz-vmac-01
651 ++ *
652 + * Copyright (c) 2009, Intel Corporation.
653 ++ * Copyright (c) 2018, Google Inc.
654 + *
655 + * This program is free software; you can redistribute it and/or modify it
656 + * under the terms and conditions of the GNU General Public License,
657 +@@ -16,14 +20,15 @@
658 + * Place - Suite 330, Boston, MA 02111-1307 USA.
659 + */
660 +
661 +-/* --------------------------------------------------------------------------
662 +- * VMAC and VHASH Implementation by Ted Krovetz (tdk@×××.org) and Wei Dai.
663 +- * This implementation is herby placed in the public domain.
664 +- * The authors offers no warranty. Use at your own risk.
665 +- * Please send bug reports to the authors.
666 +- * Last modified: 17 APR 08, 1700 PDT
667 +- * ----------------------------------------------------------------------- */
668 ++/*
669 ++ * Derived from:
670 ++ * VMAC and VHASH Implementation by Ted Krovetz (tdk@×××.org) and Wei Dai.
671 ++ * This implementation is herby placed in the public domain.
672 ++ * The authors offers no warranty. Use at your own risk.
673 ++ * Last modified: 17 APR 08, 1700 PDT
674 ++ */
675 +
676 ++#include <asm/unaligned.h>
677 + #include <linux/init.h>
678 + #include <linux/types.h>
679 + #include <linux/crypto.h>
680 +@@ -31,9 +36,35 @@
681 + #include <linux/scatterlist.h>
682 + #include <asm/byteorder.h>
683 + #include <crypto/scatterwalk.h>
684 +-#include <crypto/vmac.h>
685 + #include <crypto/internal/hash.h>
686 +
687 ++/*
688 ++ * User definable settings.
689 ++ */
690 ++#define VMAC_TAG_LEN 64
691 ++#define VMAC_KEY_SIZE 128/* Must be 128, 192 or 256 */
692 ++#define VMAC_KEY_LEN (VMAC_KEY_SIZE/8)
693 ++#define VMAC_NHBYTES 128/* Must 2^i for any 3 < i < 13 Standard = 128*/
694 ++
695 ++/* per-transform (per-key) context */
696 ++struct vmac_tfm_ctx {
697 ++ struct crypto_cipher *cipher;
698 ++ u64 nhkey[(VMAC_NHBYTES/8)+2*(VMAC_TAG_LEN/64-1)];
699 ++ u64 polykey[2*VMAC_TAG_LEN/64];
700 ++ u64 l3key[2*VMAC_TAG_LEN/64];
701 ++};
702 ++
703 ++/* per-request context */
704 ++struct vmac_desc_ctx {
705 ++ union {
706 ++ u8 partial[VMAC_NHBYTES]; /* partial block */
707 ++ __le64 partial_words[VMAC_NHBYTES / 8];
708 ++ };
709 ++ unsigned int partial_size; /* size of the partial block */
710 ++ bool first_block_processed;
711 ++ u64 polytmp[2*VMAC_TAG_LEN/64]; /* running total of L2-hash */
712 ++};
713 ++
714 + /*
715 + * Constants and masks
716 + */
717 +@@ -318,13 +349,6 @@ static void poly_step_func(u64 *ahi, u64 *alo,
718 + } while (0)
719 + #endif
720 +
721 +-static void vhash_abort(struct vmac_ctx *ctx)
722 +-{
723 +- ctx->polytmp[0] = ctx->polykey[0] ;
724 +- ctx->polytmp[1] = ctx->polykey[1] ;
725 +- ctx->first_block_processed = 0;
726 +-}
727 +-
728 + static u64 l3hash(u64 p1, u64 p2, u64 k1, u64 k2, u64 len)
729 + {
730 + u64 rh, rl, t, z = 0;
731 +@@ -364,280 +388,209 @@ static u64 l3hash(u64 p1, u64 p2, u64 k1, u64 k2, u64 len)
732 + return rl;
733 + }
734 +
735 +-static void vhash_update(const unsigned char *m,
736 +- unsigned int mbytes, /* Pos multiple of VMAC_NHBYTES */
737 +- struct vmac_ctx *ctx)
738 ++/* L1 and L2-hash one or more VMAC_NHBYTES-byte blocks */
739 ++static void vhash_blocks(const struct vmac_tfm_ctx *tctx,
740 ++ struct vmac_desc_ctx *dctx,
741 ++ const __le64 *mptr, unsigned int blocks)
742 + {
743 +- u64 rh, rl, *mptr;
744 +- const u64 *kptr = (u64 *)ctx->nhkey;
745 +- int i;
746 +- u64 ch, cl;
747 +- u64 pkh = ctx->polykey[0];
748 +- u64 pkl = ctx->polykey[1];
749 +-
750 +- if (!mbytes)
751 +- return;
752 +-
753 +- BUG_ON(mbytes % VMAC_NHBYTES);
754 +-
755 +- mptr = (u64 *)m;
756 +- i = mbytes / VMAC_NHBYTES; /* Must be non-zero */
757 +-
758 +- ch = ctx->polytmp[0];
759 +- cl = ctx->polytmp[1];
760 +-
761 +- if (!ctx->first_block_processed) {
762 +- ctx->first_block_processed = 1;
763 ++ const u64 *kptr = tctx->nhkey;
764 ++ const u64 pkh = tctx->polykey[0];
765 ++ const u64 pkl = tctx->polykey[1];
766 ++ u64 ch = dctx->polytmp[0];
767 ++ u64 cl = dctx->polytmp[1];
768 ++ u64 rh, rl;
769 ++
770 ++ if (!dctx->first_block_processed) {
771 ++ dctx->first_block_processed = true;
772 + nh_vmac_nhbytes(mptr, kptr, VMAC_NHBYTES/8, rh, rl);
773 + rh &= m62;
774 + ADD128(ch, cl, rh, rl);
775 + mptr += (VMAC_NHBYTES/sizeof(u64));
776 +- i--;
777 ++ blocks--;
778 + }
779 +
780 +- while (i--) {
781 ++ while (blocks--) {
782 + nh_vmac_nhbytes(mptr, kptr, VMAC_NHBYTES/8, rh, rl);
783 + rh &= m62;
784 + poly_step(ch, cl, pkh, pkl, rh, rl);
785 + mptr += (VMAC_NHBYTES/sizeof(u64));
786 + }
787 +
788 +- ctx->polytmp[0] = ch;
789 +- ctx->polytmp[1] = cl;
790 ++ dctx->polytmp[0] = ch;
791 ++ dctx->polytmp[1] = cl;
792 + }
793 +
794 +-static u64 vhash(unsigned char m[], unsigned int mbytes,
795 +- u64 *tagl, struct vmac_ctx *ctx)
796 ++static int vmac_setkey(struct crypto_shash *tfm,
797 ++ const u8 *key, unsigned int keylen)
798 + {
799 +- u64 rh, rl, *mptr;
800 +- const u64 *kptr = (u64 *)ctx->nhkey;
801 +- int i, remaining;
802 +- u64 ch, cl;
803 +- u64 pkh = ctx->polykey[0];
804 +- u64 pkl = ctx->polykey[1];
805 +-
806 +- mptr = (u64 *)m;
807 +- i = mbytes / VMAC_NHBYTES;
808 +- remaining = mbytes % VMAC_NHBYTES;
809 +-
810 +- if (ctx->first_block_processed) {
811 +- ch = ctx->polytmp[0];
812 +- cl = ctx->polytmp[1];
813 +- } else if (i) {
814 +- nh_vmac_nhbytes(mptr, kptr, VMAC_NHBYTES/8, ch, cl);
815 +- ch &= m62;
816 +- ADD128(ch, cl, pkh, pkl);
817 +- mptr += (VMAC_NHBYTES/sizeof(u64));
818 +- i--;
819 +- } else if (remaining) {
820 +- nh_16(mptr, kptr, 2*((remaining+15)/16), ch, cl);
821 +- ch &= m62;
822 +- ADD128(ch, cl, pkh, pkl);
823 +- mptr += (VMAC_NHBYTES/sizeof(u64));
824 +- goto do_l3;
825 +- } else {/* Empty String */
826 +- ch = pkh; cl = pkl;
827 +- goto do_l3;
828 +- }
829 +-
830 +- while (i--) {
831 +- nh_vmac_nhbytes(mptr, kptr, VMAC_NHBYTES/8, rh, rl);
832 +- rh &= m62;
833 +- poly_step(ch, cl, pkh, pkl, rh, rl);
834 +- mptr += (VMAC_NHBYTES/sizeof(u64));
835 +- }
836 +- if (remaining) {
837 +- nh_16(mptr, kptr, 2*((remaining+15)/16), rh, rl);
838 +- rh &= m62;
839 +- poly_step(ch, cl, pkh, pkl, rh, rl);
840 +- }
841 +-
842 +-do_l3:
843 +- vhash_abort(ctx);
844 +- remaining *= 8;
845 +- return l3hash(ch, cl, ctx->l3key[0], ctx->l3key[1], remaining);
846 +-}
847 ++ struct vmac_tfm_ctx *tctx = crypto_shash_ctx(tfm);
848 ++ __be64 out[2];
849 ++ u8 in[16] = { 0 };
850 ++ unsigned int i;
851 ++ int err;
852 +
853 +-static u64 vmac(unsigned char m[], unsigned int mbytes,
854 +- const unsigned char n[16], u64 *tagl,
855 +- struct vmac_ctx_t *ctx)
856 +-{
857 +- u64 *in_n, *out_p;
858 +- u64 p, h;
859 +- int i;
860 +-
861 +- in_n = ctx->__vmac_ctx.cached_nonce;
862 +- out_p = ctx->__vmac_ctx.cached_aes;
863 +-
864 +- i = n[15] & 1;
865 +- if ((*(u64 *)(n+8) != in_n[1]) || (*(u64 *)(n) != in_n[0])) {
866 +- in_n[0] = *(u64 *)(n);
867 +- in_n[1] = *(u64 *)(n+8);
868 +- ((unsigned char *)in_n)[15] &= 0xFE;
869 +- crypto_cipher_encrypt_one(ctx->child,
870 +- (unsigned char *)out_p, (unsigned char *)in_n);
871 +-
872 +- ((unsigned char *)in_n)[15] |= (unsigned char)(1-i);
873 ++ if (keylen != VMAC_KEY_LEN) {
874 ++ crypto_shash_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN);
875 ++ return -EINVAL;
876 + }
877 +- p = be64_to_cpup(out_p + i);
878 +- h = vhash(m, mbytes, (u64 *)0, &ctx->__vmac_ctx);
879 +- return le64_to_cpu(p + h);
880 +-}
881 +
882 +-static int vmac_set_key(unsigned char user_key[], struct vmac_ctx_t *ctx)
883 +-{
884 +- u64 in[2] = {0}, out[2];
885 +- unsigned i;
886 +- int err = 0;
887 +-
888 +- err = crypto_cipher_setkey(ctx->child, user_key, VMAC_KEY_LEN);
889 ++ err = crypto_cipher_setkey(tctx->cipher, key, keylen);
890 + if (err)
891 + return err;
892 +
893 + /* Fill nh key */
894 +- ((unsigned char *)in)[0] = 0x80;
895 +- for (i = 0; i < sizeof(ctx->__vmac_ctx.nhkey)/8; i += 2) {
896 +- crypto_cipher_encrypt_one(ctx->child,
897 +- (unsigned char *)out, (unsigned char *)in);
898 +- ctx->__vmac_ctx.nhkey[i] = be64_to_cpup(out);
899 +- ctx->__vmac_ctx.nhkey[i+1] = be64_to_cpup(out+1);
900 +- ((unsigned char *)in)[15] += 1;
901 ++ in[0] = 0x80;
902 ++ for (i = 0; i < ARRAY_SIZE(tctx->nhkey); i += 2) {
903 ++ crypto_cipher_encrypt_one(tctx->cipher, (u8 *)out, in);
904 ++ tctx->nhkey[i] = be64_to_cpu(out[0]);
905 ++ tctx->nhkey[i+1] = be64_to_cpu(out[1]);
906 ++ in[15]++;
907 + }
908 +
909 + /* Fill poly key */
910 +- ((unsigned char *)in)[0] = 0xC0;
911 +- in[1] = 0;
912 +- for (i = 0; i < sizeof(ctx->__vmac_ctx.polykey)/8; i += 2) {
913 +- crypto_cipher_encrypt_one(ctx->child,
914 +- (unsigned char *)out, (unsigned char *)in);
915 +- ctx->__vmac_ctx.polytmp[i] =
916 +- ctx->__vmac_ctx.polykey[i] =
917 +- be64_to_cpup(out) & mpoly;
918 +- ctx->__vmac_ctx.polytmp[i+1] =
919 +- ctx->__vmac_ctx.polykey[i+1] =
920 +- be64_to_cpup(out+1) & mpoly;
921 +- ((unsigned char *)in)[15] += 1;
922 ++ in[0] = 0xC0;
923 ++ in[15] = 0;
924 ++ for (i = 0; i < ARRAY_SIZE(tctx->polykey); i += 2) {
925 ++ crypto_cipher_encrypt_one(tctx->cipher, (u8 *)out, in);
926 ++ tctx->polykey[i] = be64_to_cpu(out[0]) & mpoly;
927 ++ tctx->polykey[i+1] = be64_to_cpu(out[1]) & mpoly;
928 ++ in[15]++;
929 + }
930 +
931 + /* Fill ip key */
932 +- ((unsigned char *)in)[0] = 0xE0;
933 +- in[1] = 0;
934 +- for (i = 0; i < sizeof(ctx->__vmac_ctx.l3key)/8; i += 2) {
935 ++ in[0] = 0xE0;
936 ++ in[15] = 0;
937 ++ for (i = 0; i < ARRAY_SIZE(tctx->l3key); i += 2) {
938 + do {
939 +- crypto_cipher_encrypt_one(ctx->child,
940 +- (unsigned char *)out, (unsigned char *)in);
941 +- ctx->__vmac_ctx.l3key[i] = be64_to_cpup(out);
942 +- ctx->__vmac_ctx.l3key[i+1] = be64_to_cpup(out+1);
943 +- ((unsigned char *)in)[15] += 1;
944 +- } while (ctx->__vmac_ctx.l3key[i] >= p64
945 +- || ctx->__vmac_ctx.l3key[i+1] >= p64);
946 ++ crypto_cipher_encrypt_one(tctx->cipher, (u8 *)out, in);
947 ++ tctx->l3key[i] = be64_to_cpu(out[0]);
948 ++ tctx->l3key[i+1] = be64_to_cpu(out[1]);
949 ++ in[15]++;
950 ++ } while (tctx->l3key[i] >= p64 || tctx->l3key[i+1] >= p64);
951 + }
952 +
953 +- /* Invalidate nonce/aes cache and reset other elements */
954 +- ctx->__vmac_ctx.cached_nonce[0] = (u64)-1; /* Ensure illegal nonce */
955 +- ctx->__vmac_ctx.cached_nonce[1] = (u64)0; /* Ensure illegal nonce */
956 +- ctx->__vmac_ctx.first_block_processed = 0;
957 +-
958 +- return err;
959 ++ return 0;
960 + }
961 +
962 +-static int vmac_setkey(struct crypto_shash *parent,
963 +- const u8 *key, unsigned int keylen)
964 ++static int vmac_init(struct shash_desc *desc)
965 + {
966 +- struct vmac_ctx_t *ctx = crypto_shash_ctx(parent);
967 ++ const struct vmac_tfm_ctx *tctx = crypto_shash_ctx(desc->tfm);
968 ++ struct vmac_desc_ctx *dctx = shash_desc_ctx(desc);
969 +
970 +- if (keylen != VMAC_KEY_LEN) {
971 +- crypto_shash_set_flags(parent, CRYPTO_TFM_RES_BAD_KEY_LEN);
972 +- return -EINVAL;
973 +- }
974 +-
975 +- return vmac_set_key((u8 *)key, ctx);
976 +-}
977 +-
978 +-static int vmac_init(struct shash_desc *pdesc)
979 +-{
980 ++ dctx->partial_size = 0;
981 ++ dctx->first_block_processed = false;
982 ++ memcpy(dctx->polytmp, tctx->polykey, sizeof(dctx->polytmp));
983 + return 0;
984 + }
985 +
986 +-static int vmac_update(struct shash_desc *pdesc, const u8 *p,
987 +- unsigned int len)
988 ++static int vmac_update(struct shash_desc *desc, const u8 *p, unsigned int len)
989 + {
990 +- struct crypto_shash *parent = pdesc->tfm;
991 +- struct vmac_ctx_t *ctx = crypto_shash_ctx(parent);
992 +- int expand;
993 +- int min;
994 +-
995 +- expand = VMAC_NHBYTES - ctx->partial_size > 0 ?
996 +- VMAC_NHBYTES - ctx->partial_size : 0;
997 +-
998 +- min = len < expand ? len : expand;
999 +-
1000 +- memcpy(ctx->partial + ctx->partial_size, p, min);
1001 +- ctx->partial_size += min;
1002 +-
1003 +- if (len < expand)
1004 +- return 0;
1005 +-
1006 +- vhash_update(ctx->partial, VMAC_NHBYTES, &ctx->__vmac_ctx);
1007 +- ctx->partial_size = 0;
1008 +-
1009 +- len -= expand;
1010 +- p += expand;
1011 ++ const struct vmac_tfm_ctx *tctx = crypto_shash_ctx(desc->tfm);
1012 ++ struct vmac_desc_ctx *dctx = shash_desc_ctx(desc);
1013 ++ unsigned int n;
1014 ++
1015 ++ if (dctx->partial_size) {
1016 ++ n = min(len, VMAC_NHBYTES - dctx->partial_size);
1017 ++ memcpy(&dctx->partial[dctx->partial_size], p, n);
1018 ++ dctx->partial_size += n;
1019 ++ p += n;
1020 ++ len -= n;
1021 ++ if (dctx->partial_size == VMAC_NHBYTES) {
1022 ++ vhash_blocks(tctx, dctx, dctx->partial_words, 1);
1023 ++ dctx->partial_size = 0;
1024 ++ }
1025 ++ }
1026 +
1027 +- if (len % VMAC_NHBYTES) {
1028 +- memcpy(ctx->partial, p + len - (len % VMAC_NHBYTES),
1029 +- len % VMAC_NHBYTES);
1030 +- ctx->partial_size = len % VMAC_NHBYTES;
1031 ++ if (len >= VMAC_NHBYTES) {
1032 ++ n = round_down(len, VMAC_NHBYTES);
1033 ++ /* TODO: 'p' may be misaligned here */
1034 ++ vhash_blocks(tctx, dctx, (const __le64 *)p, n / VMAC_NHBYTES);
1035 ++ p += n;
1036 ++ len -= n;
1037 + }
1038 +
1039 +- vhash_update(p, len - len % VMAC_NHBYTES, &ctx->__vmac_ctx);
1040 ++ if (len) {
1041 ++ memcpy(dctx->partial, p, len);
1042 ++ dctx->partial_size = len;
1043 ++ }
1044 +
1045 + return 0;
1046 + }
1047 +
1048 +-static int vmac_final(struct shash_desc *pdesc, u8 *out)
1049 ++static u64 vhash_final(const struct vmac_tfm_ctx *tctx,
1050 ++ struct vmac_desc_ctx *dctx)
1051 + {
1052 +- struct crypto_shash *parent = pdesc->tfm;
1053 +- struct vmac_ctx_t *ctx = crypto_shash_ctx(parent);
1054 +- vmac_t mac;
1055 +- u8 nonce[16] = {};
1056 +-
1057 +- /* vmac() ends up accessing outside the array bounds that
1058 +- * we specify. In appears to access up to the next 2-word
1059 +- * boundary. We'll just be uber cautious and zero the
1060 +- * unwritten bytes in the buffer.
1061 +- */
1062 +- if (ctx->partial_size) {
1063 +- memset(ctx->partial + ctx->partial_size, 0,
1064 +- VMAC_NHBYTES - ctx->partial_size);
1065 ++ unsigned int partial = dctx->partial_size;
1066 ++ u64 ch = dctx->polytmp[0];
1067 ++ u64 cl = dctx->polytmp[1];
1068 ++
1069 ++ /* L1 and L2-hash the final block if needed */
1070 ++ if (partial) {
1071 ++ /* Zero-pad to next 128-bit boundary */
1072 ++ unsigned int n = round_up(partial, 16);
1073 ++ u64 rh, rl;
1074 ++
1075 ++ memset(&dctx->partial[partial], 0, n - partial);
1076 ++ nh_16(dctx->partial_words, tctx->nhkey, n / 8, rh, rl);
1077 ++ rh &= m62;
1078 ++ if (dctx->first_block_processed)
1079 ++ poly_step(ch, cl, tctx->polykey[0], tctx->polykey[1],
1080 ++ rh, rl);
1081 ++ else
1082 ++ ADD128(ch, cl, rh, rl);
1083 + }
1084 +- mac = vmac(ctx->partial, ctx->partial_size, nonce, NULL, ctx);
1085 +- memcpy(out, &mac, sizeof(vmac_t));
1086 +- memzero_explicit(&mac, sizeof(vmac_t));
1087 +- memset(&ctx->__vmac_ctx, 0, sizeof(struct vmac_ctx));
1088 +- ctx->partial_size = 0;
1089 ++
1090 ++ /* L3-hash the 128-bit output of L2-hash */
1091 ++ return l3hash(ch, cl, tctx->l3key[0], tctx->l3key[1], partial * 8);
1092 ++}
1093 ++
1094 ++static int vmac_final(struct shash_desc *desc, u8 *out)
1095 ++{
1096 ++ const struct vmac_tfm_ctx *tctx = crypto_shash_ctx(desc->tfm);
1097 ++ struct vmac_desc_ctx *dctx = shash_desc_ctx(desc);
1098 ++ static const u8 nonce[16] = {}; /* TODO: this is insecure */
1099 ++ union {
1100 ++ u8 bytes[16];
1101 ++ __be64 pads[2];
1102 ++ } block;
1103 ++ int index;
1104 ++ u64 hash, pad;
1105 ++
1106 ++ /* Finish calculating the VHASH of the message */
1107 ++ hash = vhash_final(tctx, dctx);
1108 ++
1109 ++ /* Generate pseudorandom pad by encrypting the nonce */
1110 ++ memcpy(&block, nonce, 16);
1111 ++ index = block.bytes[15] & 1;
1112 ++ block.bytes[15] &= ~1;
1113 ++ crypto_cipher_encrypt_one(tctx->cipher, block.bytes, block.bytes);
1114 ++ pad = be64_to_cpu(block.pads[index]);
1115 ++
1116 ++ /* The VMAC is the sum of VHASH and the pseudorandom pad */
1117 ++ put_unaligned_le64(hash + pad, out);
1118 + return 0;
1119 + }
1120 +
1121 + static int vmac_init_tfm(struct crypto_tfm *tfm)
1122 + {
1123 +- struct crypto_cipher *cipher;
1124 +- struct crypto_instance *inst = (void *)tfm->__crt_alg;
1125 ++ struct crypto_instance *inst = crypto_tfm_alg_instance(tfm);
1126 + struct crypto_spawn *spawn = crypto_instance_ctx(inst);
1127 +- struct vmac_ctx_t *ctx = crypto_tfm_ctx(tfm);
1128 ++ struct vmac_tfm_ctx *tctx = crypto_tfm_ctx(tfm);
1129 ++ struct crypto_cipher *cipher;
1130 +
1131 + cipher = crypto_spawn_cipher(spawn);
1132 + if (IS_ERR(cipher))
1133 + return PTR_ERR(cipher);
1134 +
1135 +- ctx->child = cipher;
1136 ++ tctx->cipher = cipher;
1137 + return 0;
1138 + }
1139 +
1140 + static void vmac_exit_tfm(struct crypto_tfm *tfm)
1141 + {
1142 +- struct vmac_ctx_t *ctx = crypto_tfm_ctx(tfm);
1143 +- crypto_free_cipher(ctx->child);
1144 ++ struct vmac_tfm_ctx *tctx = crypto_tfm_ctx(tfm);
1145 ++
1146 ++ crypto_free_cipher(tctx->cipher);
1147 + }
1148 +
1149 + static int vmac_create(struct crypto_template *tmpl, struct rtattr **tb)
1150 +@@ -655,6 +608,10 @@ static int vmac_create(struct crypto_template *tmpl, struct rtattr **tb)
1151 + if (IS_ERR(alg))
1152 + return PTR_ERR(alg);
1153 +
1154 ++ err = -EINVAL;
1155 ++ if (alg->cra_blocksize != 16)
1156 ++ goto out_put_alg;
1157 ++
1158 + inst = shash_alloc_instance("vmac", alg);
1159 + err = PTR_ERR(inst);
1160 + if (IS_ERR(inst))
1161 +@@ -670,11 +627,12 @@ static int vmac_create(struct crypto_template *tmpl, struct rtattr **tb)
1162 + inst->alg.base.cra_blocksize = alg->cra_blocksize;
1163 + inst->alg.base.cra_alignmask = alg->cra_alignmask;
1164 +
1165 +- inst->alg.digestsize = sizeof(vmac_t);
1166 +- inst->alg.base.cra_ctxsize = sizeof(struct vmac_ctx_t);
1167 ++ inst->alg.base.cra_ctxsize = sizeof(struct vmac_tfm_ctx);
1168 + inst->alg.base.cra_init = vmac_init_tfm;
1169 + inst->alg.base.cra_exit = vmac_exit_tfm;
1170 +
1171 ++ inst->alg.descsize = sizeof(struct vmac_desc_ctx);
1172 ++ inst->alg.digestsize = VMAC_TAG_LEN / 8;
1173 + inst->alg.init = vmac_init;
1174 + inst->alg.update = vmac_update;
1175 + inst->alg.final = vmac_final;
1176 +diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
1177 +index 572b6c7303ed..f14695e744d0 100644
1178 +--- a/drivers/acpi/apei/ghes.c
1179 ++++ b/drivers/acpi/apei/ghes.c
1180 +@@ -114,19 +114,7 @@ static DEFINE_MUTEX(ghes_list_mutex);
1181 + * from BIOS to Linux can be determined only in NMI, IRQ or timer
1182 + * handler, but general ioremap can not be used in atomic context, so
1183 + * the fixmap is used instead.
1184 +- */
1185 +-
1186 +-/*
1187 +- * Two virtual pages are used, one for IRQ/PROCESS context, the other for
1188 +- * NMI context (optionally).
1189 +- */
1190 +-#define GHES_IOREMAP_PAGES 2
1191 +-#define GHES_IOREMAP_IRQ_PAGE(base) (base)
1192 +-#define GHES_IOREMAP_NMI_PAGE(base) ((base) + PAGE_SIZE)
1193 +-
1194 +-/* virtual memory area for atomic ioremap */
1195 +-static struct vm_struct *ghes_ioremap_area;
1196 +-/*
1197 ++ *
1198 + * These 2 spinlocks are used to prevent the fixmap entries from being used
1199 + * simultaneously.
1200 + */
1201 +@@ -141,23 +129,6 @@ static atomic_t ghes_estatus_cache_alloced;
1202 +
1203 + static int ghes_panic_timeout __read_mostly = 30;
1204 +
1205 +-static int ghes_ioremap_init(void)
1206 +-{
1207 +- ghes_ioremap_area = __get_vm_area(PAGE_SIZE * GHES_IOREMAP_PAGES,
1208 +- VM_IOREMAP, VMALLOC_START, VMALLOC_END);
1209 +- if (!ghes_ioremap_area) {
1210 +- pr_err(GHES_PFX "Failed to allocate virtual memory area for atomic ioremap.\n");
1211 +- return -ENOMEM;
1212 +- }
1213 +-
1214 +- return 0;
1215 +-}
1216 +-
1217 +-static void ghes_ioremap_exit(void)
1218 +-{
1219 +- free_vm_area(ghes_ioremap_area);
1220 +-}
1221 +-
1222 + static void __iomem *ghes_ioremap_pfn_nmi(u64 pfn)
1223 + {
1224 + phys_addr_t paddr;
1225 +@@ -1247,13 +1218,9 @@ static int __init ghes_init(void)
1226 +
1227 + ghes_nmi_init_cxt();
1228 +
1229 +- rc = ghes_ioremap_init();
1230 +- if (rc)
1231 +- goto err;
1232 +-
1233 + rc = ghes_estatus_pool_init();
1234 + if (rc)
1235 +- goto err_ioremap_exit;
1236 ++ goto err;
1237 +
1238 + rc = ghes_estatus_pool_expand(GHES_ESTATUS_CACHE_AVG_SIZE *
1239 + GHES_ESTATUS_CACHE_ALLOCED_MAX);
1240 +@@ -1277,8 +1244,6 @@ static int __init ghes_init(void)
1241 + return 0;
1242 + err_pool_exit:
1243 + ghes_estatus_pool_exit();
1244 +-err_ioremap_exit:
1245 +- ghes_ioremap_exit();
1246 + err:
1247 + return rc;
1248 + }
1249 +diff --git a/drivers/clk/sunxi-ng/ccu-sun4i-a10.c b/drivers/clk/sunxi-ng/ccu-sun4i-a10.c
1250 +index 286b0049b7b6..a48fde191c0a 100644
1251 +--- a/drivers/clk/sunxi-ng/ccu-sun4i-a10.c
1252 ++++ b/drivers/clk/sunxi-ng/ccu-sun4i-a10.c
1253 +@@ -223,7 +223,7 @@ static struct ccu_mux cpu_clk = {
1254 + .hw.init = CLK_HW_INIT_PARENTS("cpu",
1255 + cpu_parents,
1256 + &ccu_mux_ops,
1257 +- CLK_IS_CRITICAL),
1258 ++ CLK_SET_RATE_PARENT | CLK_IS_CRITICAL),
1259 + }
1260 + };
1261 +
1262 +diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c
1263 +index 0e2011636fbb..c53c7ac992f8 100644
1264 +--- a/drivers/firmware/qemu_fw_cfg.c
1265 ++++ b/drivers/firmware/qemu_fw_cfg.c
1266 +@@ -582,9 +582,10 @@ static int fw_cfg_sysfs_remove(struct platform_device *pdev)
1267 + {
1268 + pr_debug("fw_cfg: unloading.\n");
1269 + fw_cfg_sysfs_cache_cleanup();
1270 ++ sysfs_remove_file(fw_cfg_top_ko, &fw_cfg_rev_attr.attr);
1271 ++ fw_cfg_io_cleanup();
1272 + fw_cfg_kset_unregister_recursive(fw_cfg_fname_kset);
1273 + fw_cfg_kobj_cleanup(fw_cfg_sel_ko);
1274 +- fw_cfg_io_cleanup();
1275 + return 0;
1276 + }
1277 +
1278 +diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
1279 +index 46a2f5d9aa25..f00421dfacbd 100644
1280 +--- a/include/asm-generic/pgtable.h
1281 ++++ b/include/asm-generic/pgtable.h
1282 +@@ -991,8 +991,8 @@ int pud_set_huge(pud_t *pud, phys_addr_t addr, pgprot_t prot);
1283 + int pmd_set_huge(pmd_t *pmd, phys_addr_t addr, pgprot_t prot);
1284 + int pud_clear_huge(pud_t *pud);
1285 + int pmd_clear_huge(pmd_t *pmd);
1286 +-int pud_free_pmd_page(pud_t *pud);
1287 +-int pmd_free_pte_page(pmd_t *pmd);
1288 ++int pud_free_pmd_page(pud_t *pud, unsigned long addr);
1289 ++int pmd_free_pte_page(pmd_t *pmd, unsigned long addr);
1290 + #else /* !CONFIG_HAVE_ARCH_HUGE_VMAP */
1291 + static inline int p4d_set_huge(p4d_t *p4d, phys_addr_t addr, pgprot_t prot)
1292 + {
1293 +@@ -1018,11 +1018,11 @@ static inline int pmd_clear_huge(pmd_t *pmd)
1294 + {
1295 + return 0;
1296 + }
1297 +-static inline int pud_free_pmd_page(pud_t *pud)
1298 ++static inline int pud_free_pmd_page(pud_t *pud, unsigned long addr)
1299 + {
1300 + return 0;
1301 + }
1302 +-static inline int pmd_free_pte_page(pmd_t *pmd)
1303 ++static inline int pmd_free_pte_page(pmd_t *pmd, unsigned long addr)
1304 + {
1305 + return 0;
1306 + }
1307 +diff --git a/include/crypto/vmac.h b/include/crypto/vmac.h
1308 +deleted file mode 100644
1309 +index 6b700c7b2fe1..000000000000
1310 +--- a/include/crypto/vmac.h
1311 ++++ /dev/null
1312 +@@ -1,63 +0,0 @@
1313 +-/*
1314 +- * Modified to interface to the Linux kernel
1315 +- * Copyright (c) 2009, Intel Corporation.
1316 +- *
1317 +- * This program is free software; you can redistribute it and/or modify it
1318 +- * under the terms and conditions of the GNU General Public License,
1319 +- * version 2, as published by the Free Software Foundation.
1320 +- *
1321 +- * This program is distributed in the hope it will be useful, but WITHOUT
1322 +- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1323 +- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
1324 +- * more details.
1325 +- *
1326 +- * You should have received a copy of the GNU General Public License along with
1327 +- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
1328 +- * Place - Suite 330, Boston, MA 02111-1307 USA.
1329 +- */
1330 +-
1331 +-#ifndef __CRYPTO_VMAC_H
1332 +-#define __CRYPTO_VMAC_H
1333 +-
1334 +-/* --------------------------------------------------------------------------
1335 +- * VMAC and VHASH Implementation by Ted Krovetz (tdk@×××.org) and Wei Dai.
1336 +- * This implementation is herby placed in the public domain.
1337 +- * The authors offers no warranty. Use at your own risk.
1338 +- * Please send bug reports to the authors.
1339 +- * Last modified: 17 APR 08, 1700 PDT
1340 +- * ----------------------------------------------------------------------- */
1341 +-
1342 +-/*
1343 +- * User definable settings.
1344 +- */
1345 +-#define VMAC_TAG_LEN 64
1346 +-#define VMAC_KEY_SIZE 128/* Must be 128, 192 or 256 */
1347 +-#define VMAC_KEY_LEN (VMAC_KEY_SIZE/8)
1348 +-#define VMAC_NHBYTES 128/* Must 2^i for any 3 < i < 13 Standard = 128*/
1349 +-
1350 +-/*
1351 +- * This implementation uses u32 and u64 as names for unsigned 32-
1352 +- * and 64-bit integer types. These are defined in C99 stdint.h. The
1353 +- * following may need adaptation if you are not running a C99 or
1354 +- * Microsoft C environment.
1355 +- */
1356 +-struct vmac_ctx {
1357 +- u64 nhkey[(VMAC_NHBYTES/8)+2*(VMAC_TAG_LEN/64-1)];
1358 +- u64 polykey[2*VMAC_TAG_LEN/64];
1359 +- u64 l3key[2*VMAC_TAG_LEN/64];
1360 +- u64 polytmp[2*VMAC_TAG_LEN/64];
1361 +- u64 cached_nonce[2];
1362 +- u64 cached_aes[2];
1363 +- int first_block_processed;
1364 +-};
1365 +-
1366 +-typedef u64 vmac_t;
1367 +-
1368 +-struct vmac_ctx_t {
1369 +- struct crypto_cipher *child;
1370 +- struct vmac_ctx __vmac_ctx;
1371 +- u8 partial[VMAC_NHBYTES]; /* partial block */
1372 +- int partial_size; /* size of the partial block */
1373 +-};
1374 +-
1375 +-#endif /* __CRYPTO_VMAC_H */
1376 +diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h
1377 +index d447f24df970..0812cd5408c9 100644
1378 +--- a/include/trace/events/sched.h
1379 ++++ b/include/trace/events/sched.h
1380 +@@ -116,9 +116,9 @@ static inline long __trace_sched_switch_state(bool preempt, struct task_struct *
1381 + * RUNNING (we will not have dequeued if state != RUNNING).
1382 + */
1383 + if (preempt)
1384 +- return TASK_STATE_MAX;
1385 ++ return TASK_REPORT_MAX;
1386 +
1387 +- return __get_task_state(p);
1388 ++ return 1 << __get_task_state(p);
1389 + }
1390 + #endif /* CREATE_TRACE_POINTS */
1391 +
1392 +@@ -164,7 +164,7 @@ TRACE_EVENT(sched_switch,
1393 + { 0x40, "P" }, { 0x80, "I" }) :
1394 + "R",
1395 +
1396 +- __entry->prev_state & TASK_STATE_MAX ? "+" : "",
1397 ++ __entry->prev_state & TASK_REPORT_MAX ? "+" : "",
1398 + __entry->next_comm, __entry->next_pid, __entry->next_prio)
1399 + );
1400 +
1401 +diff --git a/lib/ioremap.c b/lib/ioremap.c
1402 +index 54e5bbaa3200..517f5853ffed 100644
1403 +--- a/lib/ioremap.c
1404 ++++ b/lib/ioremap.c
1405 +@@ -92,7 +92,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
1406 + if (ioremap_pmd_enabled() &&
1407 + ((next - addr) == PMD_SIZE) &&
1408 + IS_ALIGNED(phys_addr + addr, PMD_SIZE) &&
1409 +- pmd_free_pte_page(pmd)) {
1410 ++ pmd_free_pte_page(pmd, addr)) {
1411 + if (pmd_set_huge(pmd, phys_addr + addr, prot))
1412 + continue;
1413 + }
1414 +@@ -119,7 +119,7 @@ static inline int ioremap_pud_range(p4d_t *p4d, unsigned long addr,
1415 + if (ioremap_pud_enabled() &&
1416 + ((next - addr) == PUD_SIZE) &&
1417 + IS_ALIGNED(phys_addr + addr, PUD_SIZE) &&
1418 +- pud_free_pmd_page(pud)) {
1419 ++ pud_free_pmd_page(pud, addr)) {
1420 + if (pud_set_huge(pud, phys_addr + addr, prot))
1421 + continue;
1422 + }
1423 +diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c
1424 +index 8112893037bd..cef3754408d4 100644
1425 +--- a/net/bluetooth/hidp/core.c
1426 ++++ b/net/bluetooth/hidp/core.c
1427 +@@ -431,8 +431,8 @@ static void hidp_del_timer(struct hidp_session *session)
1428 + del_timer(&session->timer);
1429 + }
1430 +
1431 +-static void hidp_process_report(struct hidp_session *session,
1432 +- int type, const u8 *data, int len, int intr)
1433 ++static void hidp_process_report(struct hidp_session *session, int type,
1434 ++ const u8 *data, unsigned int len, int intr)
1435 + {
1436 + if (len > HID_MAX_BUFFER_SIZE)
1437 + len = HID_MAX_BUFFER_SIZE;
1438 +diff --git a/scripts/depmod.sh b/scripts/depmod.sh
1439 +index 9831cca31240..f41b0a4b575c 100755
1440 +--- a/scripts/depmod.sh
1441 ++++ b/scripts/depmod.sh
1442 +@@ -11,10 +11,16 @@ DEPMOD=$1
1443 + KERNELRELEASE=$2
1444 + SYMBOL_PREFIX=$3
1445 +
1446 +-if ! test -r System.map -a -x "$DEPMOD"; then
1447 ++if ! test -r System.map ; then
1448 + exit 0
1449 + fi
1450 +
1451 ++if [ -z $(command -v $DEPMOD) ]; then
1452 ++ echo "'make modules_install' requires $DEPMOD. Please install it." >&2
1453 ++ echo "This is probably in the kmod package." >&2
1454 ++ exit 1
1455 ++fi
1456 ++
1457 + # older versions of depmod don't support -P <symbol-prefix>
1458 + # support was added in module-init-tools 3.13
1459 + if test -n "$SYMBOL_PREFIX"; then
1460 +diff --git a/sound/soc/codecs/msm8916-wcd-digital.c b/sound/soc/codecs/msm8916-wcd-digital.c
1461 +index 694db27b11fa..13354d6304a8 100644
1462 +--- a/sound/soc/codecs/msm8916-wcd-digital.c
1463 ++++ b/sound/soc/codecs/msm8916-wcd-digital.c
1464 +@@ -238,7 +238,7 @@ static const struct soc_enum rx_mix2_inp1_chain_enum = SOC_ENUM_SINGLE(
1465 + static const struct soc_enum rx2_mix1_inp_enum[] = {
1466 + SOC_ENUM_SINGLE(LPASS_CDC_CONN_RX2_B1_CTL, 0, 6, rx_mix1_text),
1467 + SOC_ENUM_SINGLE(LPASS_CDC_CONN_RX2_B1_CTL, 3, 6, rx_mix1_text),
1468 +- SOC_ENUM_SINGLE(LPASS_CDC_CONN_RX2_B1_CTL, 0, 6, rx_mix1_text),
1469 ++ SOC_ENUM_SINGLE(LPASS_CDC_CONN_RX2_B2_CTL, 0, 6, rx_mix1_text),
1470 + };
1471 +
1472 + /* RX2 MIX2 */
1473 +@@ -249,7 +249,7 @@ static const struct soc_enum rx2_mix2_inp1_chain_enum = SOC_ENUM_SINGLE(
1474 + static const struct soc_enum rx3_mix1_inp_enum[] = {
1475 + SOC_ENUM_SINGLE(LPASS_CDC_CONN_RX3_B1_CTL, 0, 6, rx_mix1_text),
1476 + SOC_ENUM_SINGLE(LPASS_CDC_CONN_RX3_B1_CTL, 3, 6, rx_mix1_text),
1477 +- SOC_ENUM_SINGLE(LPASS_CDC_CONN_RX3_B1_CTL, 0, 6, rx_mix1_text),
1478 ++ SOC_ENUM_SINGLE(LPASS_CDC_CONN_RX3_B2_CTL, 0, 6, rx_mix1_text),
1479 + };
1480 +
1481 + /* DEC */
1482 +diff --git a/sound/soc/intel/boards/cht_bsw_max98090_ti.c b/sound/soc/intel/boards/cht_bsw_max98090_ti.c
1483 +index 20755ecc7f9e..a02dec251afe 100644
1484 +--- a/sound/soc/intel/boards/cht_bsw_max98090_ti.c
1485 ++++ b/sound/soc/intel/boards/cht_bsw_max98090_ti.c
1486 +@@ -116,23 +116,19 @@ static int cht_codec_init(struct snd_soc_pcm_runtime *runtime)
1487 + struct cht_mc_private *ctx = snd_soc_card_get_drvdata(runtime->card);
1488 + struct snd_soc_jack *jack = &ctx->jack;
1489 +
1490 +- /**
1491 +- * TI supports 4 butons headset detection
1492 +- * KEY_MEDIA
1493 +- * KEY_VOICECOMMAND
1494 +- * KEY_VOLUMEUP
1495 +- * KEY_VOLUMEDOWN
1496 +- */
1497 +- if (ctx->ts3a227e_present)
1498 +- jack_type = SND_JACK_HEADPHONE | SND_JACK_MICROPHONE |
1499 +- SND_JACK_BTN_0 | SND_JACK_BTN_1 |
1500 +- SND_JACK_BTN_2 | SND_JACK_BTN_3;
1501 +- else
1502 +- jack_type = SND_JACK_HEADPHONE | SND_JACK_MICROPHONE;
1503 ++ if (ctx->ts3a227e_present) {
1504 ++ /*
1505 ++ * The jack has already been created in the
1506 ++ * cht_max98090_headset_init() function.
1507 ++ */
1508 ++ snd_soc_jack_notifier_register(jack, &cht_jack_nb);
1509 ++ return 0;
1510 ++ }
1511 ++
1512 ++ jack_type = SND_JACK_HEADPHONE | SND_JACK_MICROPHONE;
1513 +
1514 + ret = snd_soc_card_jack_new(runtime->card, "Headset Jack",
1515 + jack_type, jack, NULL, 0);
1516 +-
1517 + if (ret) {
1518 + dev_err(runtime->dev, "Headset Jack creation failed %d\n", ret);
1519 + return ret;
1520 +@@ -188,6 +184,27 @@ static int cht_max98090_headset_init(struct snd_soc_component *component)
1521 + {
1522 + struct snd_soc_card *card = component->card;
1523 + struct cht_mc_private *ctx = snd_soc_card_get_drvdata(card);
1524 ++ struct snd_soc_jack *jack = &ctx->jack;
1525 ++ int jack_type;
1526 ++ int ret;
1527 ++
1528 ++ /*
1529 ++ * TI supports 4 butons headset detection
1530 ++ * KEY_MEDIA
1531 ++ * KEY_VOICECOMMAND
1532 ++ * KEY_VOLUMEUP
1533 ++ * KEY_VOLUMEDOWN
1534 ++ */
1535 ++ jack_type = SND_JACK_HEADPHONE | SND_JACK_MICROPHONE |
1536 ++ SND_JACK_BTN_0 | SND_JACK_BTN_1 |
1537 ++ SND_JACK_BTN_2 | SND_JACK_BTN_3;
1538 ++
1539 ++ ret = snd_soc_card_jack_new(card, "Headset Jack", jack_type,
1540 ++ jack, NULL, 0);
1541 ++ if (ret) {
1542 ++ dev_err(card->dev, "Headset Jack creation failed %d\n", ret);
1543 ++ return ret;
1544 ++ }
1545 +
1546 + return ts3a227e_enable_jack_detect(component, &ctx->jack);
1547 + }
1548 +diff --git a/sound/soc/sh/rcar/adg.c b/sound/soc/sh/rcar/adg.c
1549 +index 2684a2ba33cd..e28edb1f7263 100644
1550 +--- a/sound/soc/sh/rcar/adg.c
1551 ++++ b/sound/soc/sh/rcar/adg.c
1552 +@@ -479,10 +479,10 @@ static void rsnd_adg_get_clkout(struct rsnd_priv *priv,
1553 + }
1554 +
1555 + if (req_rate[0] % 48000 == 0)
1556 +- adg->flags = AUDIO_OUT_48;
1557 ++ adg->flags |= AUDIO_OUT_48;
1558 +
1559 + if (of_get_property(np, "clkout-lr-asynchronous", NULL))
1560 +- adg->flags = LRCLK_ASYNC;
1561 ++ adg->flags |= LRCLK_ASYNC;
1562 +
1563 + /*
1564 + * This driver is assuming that AUDIO_CLKA/AUDIO_CLKB/AUDIO_CLKC