Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:4.17 commit in: /
Date: Fri, 17 Aug 2018 19:27:51
Message-Id: 1534534056.2c2807aea9a2fb02322e1f70bedc5d2836585229.mpagano@gentoo
1 commit: 2c2807aea9a2fb02322e1f70bedc5d2836585229
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Fri Aug 17 19:27:36 2018 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Fri Aug 17 19:27:36 2018 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=2c2807ae
7
8 Linux patch 4.17.16
9
10 0000_README | 4 +
11 1015_linux-4.17.16.patch | 1663 ++++++++++++++++++++++++++++++++++++++++++++++
12 2 files changed, 1667 insertions(+)
13
14 diff --git a/0000_README b/0000_README
15 index a489588..83fccd5 100644
16 --- a/0000_README
17 +++ b/0000_README
18 @@ -103,6 +103,10 @@ Patch: 1014_linux-4.17.15.patch
19 From: http://www.kernel.org
20 Desc: Linux 4.17.15
21
22 +Patch: 1015_linux-4.17.16.patch
23 +From: http://www.kernel.org
24 +Desc: Linux 4.17.16
25 +
26 Patch: 1500_XATTR_USER_PREFIX.patch
27 From: https://bugs.gentoo.org/show_bug.cgi?id=470644
28 Desc: Support for namespace user.pax.* on tmpfs.
29
30 diff --git a/1015_linux-4.17.16.patch b/1015_linux-4.17.16.patch
31 new file mode 100644
32 index 0000000..edbea4b
33 --- /dev/null
34 +++ b/1015_linux-4.17.16.patch
35 @@ -0,0 +1,1663 @@
36 +diff --git a/Documentation/process/changes.rst b/Documentation/process/changes.rst
37 +index ddc029734b25..005d8842a503 100644
38 +--- a/Documentation/process/changes.rst
39 ++++ b/Documentation/process/changes.rst
40 +@@ -35,7 +35,7 @@ binutils 2.20 ld -v
41 + flex 2.5.35 flex --version
42 + bison 2.0 bison --version
43 + util-linux 2.10o fdformat --version
44 +-module-init-tools 0.9.10 depmod -V
45 ++kmod 13 depmod -V
46 + e2fsprogs 1.41.4 e2fsck -V
47 + jfsutils 1.1.3 fsck.jfs -V
48 + reiserfsprogs 3.6.3 reiserfsck -V
49 +@@ -156,12 +156,6 @@ is not build with ``CONFIG_KALLSYMS`` and you have no way to rebuild and
50 + reproduce the Oops with that option, then you can still decode that Oops
51 + with ksymoops.
52 +
53 +-Module-Init-Tools
54 +------------------
55 +-
56 +-A new module loader is now in the kernel that requires ``module-init-tools``
57 +-to use. It is backward compatible with the 2.4.x series kernels.
58 +-
59 + Mkinitrd
60 + --------
61 +
62 +@@ -371,16 +365,17 @@ Util-linux
63 +
64 + - <https://www.kernel.org/pub/linux/utils/util-linux/>
65 +
66 ++Kmod
67 ++----
68 ++
69 ++- <https://www.kernel.org/pub/linux/utils/kernel/kmod/>
70 ++- <https://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git>
71 ++
72 + Ksymoops
73 + --------
74 +
75 + - <https://www.kernel.org/pub/linux/utils/kernel/ksymoops/v2.4/>
76 +
77 +-Module-Init-Tools
78 +------------------
79 +-
80 +-- <https://www.kernel.org/pub/linux/utils/kernel/module-init-tools/>
81 +-
82 + Mkinitrd
83 + --------
84 +
85 +diff --git a/Makefile b/Makefile
86 +index e8cbf2dd3069..8ca595f045c4 100644
87 +--- a/Makefile
88 ++++ b/Makefile
89 +@@ -1,7 +1,7 @@
90 + # SPDX-License-Identifier: GPL-2.0
91 + VERSION = 4
92 + PATCHLEVEL = 17
93 +-SUBLEVEL = 15
94 ++SUBLEVEL = 16
95 + EXTRAVERSION =
96 + NAME = Merciless Moray
97 +
98 +diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
99 +index 493ff75670ff..8ae5d7ae4af3 100644
100 +--- a/arch/arm64/mm/mmu.c
101 ++++ b/arch/arm64/mm/mmu.c
102 +@@ -977,12 +977,12 @@ int pmd_clear_huge(pmd_t *pmdp)
103 + return 1;
104 + }
105 +
106 +-int pud_free_pmd_page(pud_t *pud)
107 ++int pud_free_pmd_page(pud_t *pud, unsigned long addr)
108 + {
109 + return pud_none(*pud);
110 + }
111 +
112 +-int pmd_free_pte_page(pmd_t *pmd)
113 ++int pmd_free_pte_page(pmd_t *pmd, unsigned long addr)
114 + {
115 + return pmd_none(*pmd);
116 + }
117 +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
118 +index 16c4ccb1f154..d2364c55bbde 100644
119 +--- a/arch/x86/crypto/sha256-mb/sha256_mb_mgr_flush_avx2.S
120 ++++ b/arch/x86/crypto/sha256-mb/sha256_mb_mgr_flush_avx2.S
121 +@@ -265,7 +265,7 @@ ENTRY(sha256_mb_mgr_get_comp_job_avx2)
122 + vpinsrd $1, _args_digest+1*32(state, idx, 4), %xmm0, %xmm0
123 + vpinsrd $2, _args_digest+2*32(state, idx, 4), %xmm0, %xmm0
124 + vpinsrd $3, _args_digest+3*32(state, idx, 4), %xmm0, %xmm0
125 +- vmovd _args_digest(state , idx, 4) , %xmm0
126 ++ vmovd _args_digest+4*32(state, idx, 4), %xmm1
127 + vpinsrd $1, _args_digest+5*32(state, idx, 4), %xmm1, %xmm1
128 + vpinsrd $2, _args_digest+6*32(state, idx, 4), %xmm1, %xmm1
129 + vpinsrd $3, _args_digest+7*32(state, idx, 4), %xmm1, %xmm1
130 +diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
131 +index 5cdcdbd4d892..89789e8c80f6 100644
132 +--- a/arch/x86/include/asm/i8259.h
133 ++++ b/arch/x86/include/asm/i8259.h
134 +@@ -3,6 +3,7 @@
135 + #define _ASM_X86_I8259_H
136 +
137 + #include <linux/delay.h>
138 ++#include <asm/io.h>
139 +
140 + extern unsigned int cached_irq_mask;
141 +
142 +diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
143 +index d492752f79e1..391f358ebb4c 100644
144 +--- a/arch/x86/kernel/apic/x2apic_uv_x.c
145 ++++ b/arch/x86/kernel/apic/x2apic_uv_x.c
146 +@@ -394,10 +394,10 @@ extern int uv_hub_info_version(void)
147 + EXPORT_SYMBOL(uv_hub_info_version);
148 +
149 + /* Default UV memory block size is 2GB */
150 +-static unsigned long mem_block_size = (2UL << 30);
151 ++static unsigned long mem_block_size __initdata = (2UL << 30);
152 +
153 + /* Kernel parameter to specify UV mem block size */
154 +-static int parse_mem_block_size(char *ptr)
155 ++static int __init parse_mem_block_size(char *ptr)
156 + {
157 + unsigned long size = memparse(ptr, NULL);
158 +
159 +diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
160 +index edfc64a8a154..d07addb99b71 100644
161 +--- a/arch/x86/kernel/cpu/bugs.c
162 ++++ b/arch/x86/kernel/cpu/bugs.c
163 +@@ -648,10 +648,9 @@ void x86_spec_ctrl_setup_ap(void)
164 + enum l1tf_mitigations l1tf_mitigation __ro_after_init = L1TF_MITIGATION_FLUSH;
165 + #if IS_ENABLED(CONFIG_KVM_INTEL)
166 + EXPORT_SYMBOL_GPL(l1tf_mitigation);
167 +-
168 ++#endif
169 + enum vmx_l1d_flush_state l1tf_vmx_mitigation = VMENTER_L1D_FLUSH_AUTO;
170 + EXPORT_SYMBOL_GPL(l1tf_vmx_mitigation);
171 +-#endif
172 +
173 + static void __init l1tf_select_mitigation(void)
174 + {
175 +diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
176 +index 6c54d8b0e5dc..ae4f5afb9095 100644
177 +--- a/arch/x86/kernel/cpu/common.c
178 ++++ b/arch/x86/kernel/cpu/common.c
179 +@@ -883,7 +883,7 @@ void get_cpu_cap(struct cpuinfo_x86 *c)
180 + apply_forced_caps(c);
181 + }
182 +
183 +-static void get_cpu_address_sizes(struct cpuinfo_x86 *c)
184 ++void get_cpu_address_sizes(struct cpuinfo_x86 *c)
185 + {
186 + u32 eax, ebx, ecx, edx;
187 +
188 +diff --git a/arch/x86/kernel/cpu/cpu.h b/arch/x86/kernel/cpu/cpu.h
189 +index cca588407dca..d0a17a438dd0 100644
190 +--- a/arch/x86/kernel/cpu/cpu.h
191 ++++ b/arch/x86/kernel/cpu/cpu.h
192 +@@ -46,6 +46,7 @@ extern const struct cpu_dev *const __x86_cpu_dev_start[],
193 + *const __x86_cpu_dev_end[];
194 +
195 + extern void get_cpu_cap(struct cpuinfo_x86 *c);
196 ++extern void get_cpu_address_sizes(struct cpuinfo_x86 *c);
197 + extern void cpu_detect_cache_sizes(struct cpuinfo_x86 *c);
198 + extern int detect_extended_topology_early(struct cpuinfo_x86 *c);
199 + extern int detect_ht_early(struct cpuinfo_x86 *c);
200 +diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
201 +index 7bb6f65c79de..29505724202a 100644
202 +--- a/arch/x86/mm/pageattr.c
203 ++++ b/arch/x86/mm/pageattr.c
204 +@@ -1784,6 +1784,12 @@ int set_memory_nonglobal(unsigned long addr, int numpages)
205 + __pgprot(_PAGE_GLOBAL), 0);
206 + }
207 +
208 ++int set_memory_global(unsigned long addr, int numpages)
209 ++{
210 ++ return change_page_attr_set(&addr, numpages,
211 ++ __pgprot(_PAGE_GLOBAL), 0);
212 ++}
213 ++
214 + static int __set_memory_enc_dec(unsigned long addr, int numpages, bool enc)
215 + {
216 + struct cpa_data cpa;
217 +diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
218 +index ffc8c13c50e4..64df979a97e2 100644
219 +--- a/arch/x86/mm/pgtable.c
220 ++++ b/arch/x86/mm/pgtable.c
221 +@@ -715,28 +715,50 @@ int pmd_clear_huge(pmd_t *pmd)
222 + return 0;
223 + }
224 +
225 ++#ifdef CONFIG_X86_64
226 + /**
227 + * pud_free_pmd_page - Clear pud entry and free pmd page.
228 + * @pud: Pointer to a PUD.
229 ++ * @addr: Virtual address associated with pud.
230 + *
231 +- * Context: The pud range has been unmaped and TLB purged.
232 ++ * Context: The pud range has been unmapped and TLB purged.
233 + * Return: 1 if clearing the entry succeeded. 0 otherwise.
234 ++ *
235 ++ * NOTE: Callers must allow a single page allocation.
236 + */
237 +-int pud_free_pmd_page(pud_t *pud)
238 ++int pud_free_pmd_page(pud_t *pud, unsigned long addr)
239 + {
240 +- pmd_t *pmd;
241 ++ pmd_t *pmd, *pmd_sv;
242 ++ pte_t *pte;
243 + int i;
244 +
245 + if (pud_none(*pud))
246 + return 1;
247 +
248 + pmd = (pmd_t *)pud_page_vaddr(*pud);
249 ++ pmd_sv = (pmd_t *)__get_free_page(GFP_KERNEL);
250 ++ if (!pmd_sv)
251 ++ return 0;
252 +
253 +- for (i = 0; i < PTRS_PER_PMD; i++)
254 +- if (!pmd_free_pte_page(&pmd[i]))
255 +- return 0;
256 ++ for (i = 0; i < PTRS_PER_PMD; i++) {
257 ++ pmd_sv[i] = pmd[i];
258 ++ if (!pmd_none(pmd[i]))
259 ++ pmd_clear(&pmd[i]);
260 ++ }
261 +
262 + pud_clear(pud);
263 ++
264 ++ /* INVLPG to clear all paging-structure caches */
265 ++ flush_tlb_kernel_range(addr, addr + PAGE_SIZE-1);
266 ++
267 ++ for (i = 0; i < PTRS_PER_PMD; i++) {
268 ++ if (!pmd_none(pmd_sv[i])) {
269 ++ pte = (pte_t *)pmd_page_vaddr(pmd_sv[i]);
270 ++ free_page((unsigned long)pte);
271 ++ }
272 ++ }
273 ++
274 ++ free_page((unsigned long)pmd_sv);
275 + free_page((unsigned long)pmd);
276 +
277 + return 1;
278 +@@ -745,11 +767,12 @@ int pud_free_pmd_page(pud_t *pud)
279 + /**
280 + * pmd_free_pte_page - Clear pmd entry and free pte page.
281 + * @pmd: Pointer to a PMD.
282 ++ * @addr: Virtual address associated with pmd.
283 + *
284 +- * Context: The pmd range has been unmaped and TLB purged.
285 ++ * Context: The pmd range has been unmapped and TLB purged.
286 + * Return: 1 if clearing the entry succeeded. 0 otherwise.
287 + */
288 +-int pmd_free_pte_page(pmd_t *pmd)
289 ++int pmd_free_pte_page(pmd_t *pmd, unsigned long addr)
290 + {
291 + pte_t *pte;
292 +
293 +@@ -758,8 +781,30 @@ int pmd_free_pte_page(pmd_t *pmd)
294 +
295 + pte = (pte_t *)pmd_page_vaddr(*pmd);
296 + pmd_clear(pmd);
297 ++
298 ++ /* INVLPG to clear all paging-structure caches */
299 ++ flush_tlb_kernel_range(addr, addr + PAGE_SIZE-1);
300 ++
301 + free_page((unsigned long)pte);
302 +
303 + return 1;
304 + }
305 ++
306 ++#else /* !CONFIG_X86_64 */
307 ++
308 ++int pud_free_pmd_page(pud_t *pud, unsigned long addr)
309 ++{
310 ++ return pud_none(*pud);
311 ++}
312 ++
313 ++/*
314 ++ * Disable free page handling on x86-PAE. This assures that ioremap()
315 ++ * does not update sync'd pmd entries. See vmalloc_sync_one().
316 ++ */
317 ++int pmd_free_pte_page(pmd_t *pmd, unsigned long addr)
318 ++{
319 ++ return pmd_none(*pmd);
320 ++}
321 ++
322 ++#endif /* CONFIG_X86_64 */
323 + #endif /* CONFIG_HAVE_ARCH_HUGE_VMAP */
324 +diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c
325 +index fb752d9a3ce9..946455e9cfef 100644
326 +--- a/arch/x86/mm/pti.c
327 ++++ b/arch/x86/mm/pti.c
328 +@@ -435,6 +435,13 @@ static inline bool pti_kernel_image_global_ok(void)
329 + return true;
330 + }
331 +
332 ++/*
333 ++ * This is the only user for these and it is not arch-generic
334 ++ * like the other set_memory.h functions. Just extern them.
335 ++ */
336 ++extern int set_memory_nonglobal(unsigned long addr, int numpages);
337 ++extern int set_memory_global(unsigned long addr, int numpages);
338 ++
339 + /*
340 + * For some configurations, map all of kernel text into the user page
341 + * tables. This reduces TLB misses, especially on non-PCID systems.
342 +@@ -447,7 +454,8 @@ void pti_clone_kernel_text(void)
343 + * clone the areas past rodata, they might contain secrets.
344 + */
345 + unsigned long start = PFN_ALIGN(_text);
346 +- unsigned long end = (unsigned long)__end_rodata_hpage_align;
347 ++ unsigned long end_clone = (unsigned long)__end_rodata_hpage_align;
348 ++ unsigned long end_global = PFN_ALIGN((unsigned long)__stop___ex_table);
349 +
350 + if (!pti_kernel_image_global_ok())
351 + return;
352 +@@ -459,14 +467,18 @@ void pti_clone_kernel_text(void)
353 + * pti_set_kernel_image_nonglobal() did to clear the
354 + * global bit.
355 + */
356 +- pti_clone_pmds(start, end, _PAGE_RW);
357 ++ pti_clone_pmds(start, end_clone, _PAGE_RW);
358 ++
359 ++ /*
360 ++ * pti_clone_pmds() will set the global bit in any PMDs
361 ++ * that it clones, but we also need to get any PTEs in
362 ++ * the last level for areas that are not huge-page-aligned.
363 ++ */
364 ++
365 ++ /* Set the global bit for normal non-__init kernel text: */
366 ++ set_memory_global(start, (end_global - start) >> PAGE_SHIFT);
367 + }
368 +
369 +-/*
370 +- * This is the only user for it and it is not arch-generic like
371 +- * the other set_memory.h functions. Just extern it.
372 +- */
373 +-extern int set_memory_nonglobal(unsigned long addr, int numpages);
374 + void pti_set_kernel_image_nonglobal(void)
375 + {
376 + /*
377 +@@ -478,9 +490,11 @@ void pti_set_kernel_image_nonglobal(void)
378 + unsigned long start = PFN_ALIGN(_text);
379 + unsigned long end = ALIGN((unsigned long)_end, PMD_PAGE_SIZE);
380 +
381 +- if (pti_kernel_image_global_ok())
382 +- return;
383 +-
384 ++ /*
385 ++ * This clears _PAGE_GLOBAL from the entire kernel image.
386 ++ * pti_clone_kernel_text() map put _PAGE_GLOBAL back for
387 ++ * areas that are mapped to userspace.
388 ++ */
389 + set_memory_nonglobal(start, (end - start) >> PAGE_SHIFT);
390 + }
391 +
392 +diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c
393 +index ce8f6a8d4ac9..ca0fce74814b 100644
394 +--- a/arch/x86/xen/enlighten_pv.c
395 ++++ b/arch/x86/xen/enlighten_pv.c
396 +@@ -1258,6 +1258,9 @@ asmlinkage __visible void __init xen_start_kernel(void)
397 + get_cpu_cap(&boot_cpu_data);
398 + x86_configure_nx();
399 +
400 ++ /* Determine virtual and physical address sizes */
401 ++ get_cpu_address_sizes(&boot_cpu_data);
402 ++
403 + /* Let's presume PV guests always boot on vCPU with id 0. */
404 + per_cpu(xen_vcpu_id, 0) = 0;
405 +
406 +diff --git a/crypto/ablkcipher.c b/crypto/ablkcipher.c
407 +index d880a4897159..4ee7c041bb82 100644
408 +--- a/crypto/ablkcipher.c
409 ++++ b/crypto/ablkcipher.c
410 +@@ -71,11 +71,9 @@ static inline u8 *ablkcipher_get_spot(u8 *start, unsigned int len)
411 + return max(start, end_page);
412 + }
413 +
414 +-static inline unsigned int ablkcipher_done_slow(struct ablkcipher_walk *walk,
415 +- unsigned int bsize)
416 ++static inline void ablkcipher_done_slow(struct ablkcipher_walk *walk,
417 ++ unsigned int n)
418 + {
419 +- unsigned int n = bsize;
420 +-
421 + for (;;) {
422 + unsigned int len_this_page = scatterwalk_pagelen(&walk->out);
423 +
424 +@@ -87,17 +85,13 @@ static inline unsigned int ablkcipher_done_slow(struct ablkcipher_walk *walk,
425 + n -= len_this_page;
426 + scatterwalk_start(&walk->out, sg_next(walk->out.sg));
427 + }
428 +-
429 +- return bsize;
430 + }
431 +
432 +-static inline unsigned int ablkcipher_done_fast(struct ablkcipher_walk *walk,
433 +- unsigned int n)
434 ++static inline void ablkcipher_done_fast(struct ablkcipher_walk *walk,
435 ++ unsigned int n)
436 + {
437 + scatterwalk_advance(&walk->in, n);
438 + scatterwalk_advance(&walk->out, n);
439 +-
440 +- return n;
441 + }
442 +
443 + static int ablkcipher_walk_next(struct ablkcipher_request *req,
444 +@@ -107,39 +101,40 @@ int ablkcipher_walk_done(struct ablkcipher_request *req,
445 + struct ablkcipher_walk *walk, int err)
446 + {
447 + struct crypto_tfm *tfm = req->base.tfm;
448 +- unsigned int nbytes = 0;
449 ++ unsigned int n; /* bytes processed */
450 ++ bool more;
451 +
452 +- if (likely(err >= 0)) {
453 +- unsigned int n = walk->nbytes - err;
454 ++ if (unlikely(err < 0))
455 ++ goto finish;
456 +
457 +- if (likely(!(walk->flags & ABLKCIPHER_WALK_SLOW)))
458 +- n = ablkcipher_done_fast(walk, n);
459 +- else if (WARN_ON(err)) {
460 +- err = -EINVAL;
461 +- goto err;
462 +- } else
463 +- n = ablkcipher_done_slow(walk, n);
464 ++ n = walk->nbytes - err;
465 ++ walk->total -= n;
466 ++ more = (walk->total != 0);
467 +
468 +- nbytes = walk->total - n;
469 +- err = 0;
470 ++ if (likely(!(walk->flags & ABLKCIPHER_WALK_SLOW))) {
471 ++ ablkcipher_done_fast(walk, n);
472 ++ } else {
473 ++ if (WARN_ON(err)) {
474 ++ /* unexpected case; didn't process all bytes */
475 ++ err = -EINVAL;
476 ++ goto finish;
477 ++ }
478 ++ ablkcipher_done_slow(walk, n);
479 + }
480 +
481 +- scatterwalk_done(&walk->in, 0, nbytes);
482 +- scatterwalk_done(&walk->out, 1, nbytes);
483 +-
484 +-err:
485 +- walk->total = nbytes;
486 +- walk->nbytes = nbytes;
487 ++ scatterwalk_done(&walk->in, 0, more);
488 ++ scatterwalk_done(&walk->out, 1, more);
489 +
490 +- if (nbytes) {
491 ++ if (more) {
492 + crypto_yield(req->base.flags);
493 + return ablkcipher_walk_next(req, walk);
494 + }
495 +-
496 ++ err = 0;
497 ++finish:
498 ++ walk->nbytes = 0;
499 + if (walk->iv != req->info)
500 + memcpy(req->info, walk->iv, tfm->crt_ablkcipher.ivsize);
501 + kfree(walk->iv_buffer);
502 +-
503 + return err;
504 + }
505 + EXPORT_SYMBOL_GPL(ablkcipher_walk_done);
506 +diff --git a/crypto/blkcipher.c b/crypto/blkcipher.c
507 +index 01c0d4aa2563..77b5fa293f66 100644
508 +--- a/crypto/blkcipher.c
509 ++++ b/crypto/blkcipher.c
510 +@@ -70,19 +70,18 @@ static inline u8 *blkcipher_get_spot(u8 *start, unsigned int len)
511 + return max(start, end_page);
512 + }
513 +
514 +-static inline unsigned int blkcipher_done_slow(struct blkcipher_walk *walk,
515 +- unsigned int bsize)
516 ++static inline void blkcipher_done_slow(struct blkcipher_walk *walk,
517 ++ unsigned int bsize)
518 + {
519 + u8 *addr;
520 +
521 + addr = (u8 *)ALIGN((unsigned long)walk->buffer, walk->alignmask + 1);
522 + addr = blkcipher_get_spot(addr, bsize);
523 + scatterwalk_copychunks(addr, &walk->out, bsize, 1);
524 +- return bsize;
525 + }
526 +
527 +-static inline unsigned int blkcipher_done_fast(struct blkcipher_walk *walk,
528 +- unsigned int n)
529 ++static inline void blkcipher_done_fast(struct blkcipher_walk *walk,
530 ++ unsigned int n)
531 + {
532 + if (walk->flags & BLKCIPHER_WALK_COPY) {
533 + blkcipher_map_dst(walk);
534 +@@ -96,49 +95,48 @@ static inline unsigned int blkcipher_done_fast(struct blkcipher_walk *walk,
535 +
536 + scatterwalk_advance(&walk->in, n);
537 + scatterwalk_advance(&walk->out, n);
538 +-
539 +- return n;
540 + }
541 +
542 + int blkcipher_walk_done(struct blkcipher_desc *desc,
543 + struct blkcipher_walk *walk, int err)
544 + {
545 +- unsigned int nbytes = 0;
546 ++ unsigned int n; /* bytes processed */
547 ++ bool more;
548 +
549 +- if (likely(err >= 0)) {
550 +- unsigned int n = walk->nbytes - err;
551 ++ if (unlikely(err < 0))
552 ++ goto finish;
553 +
554 +- if (likely(!(walk->flags & BLKCIPHER_WALK_SLOW)))
555 +- n = blkcipher_done_fast(walk, n);
556 +- else if (WARN_ON(err)) {
557 +- err = -EINVAL;
558 +- goto err;
559 +- } else
560 +- n = blkcipher_done_slow(walk, n);
561 ++ n = walk->nbytes - err;
562 ++ walk->total -= n;
563 ++ more = (walk->total != 0);
564 +
565 +- nbytes = walk->total - n;
566 +- err = 0;
567 ++ if (likely(!(walk->flags & BLKCIPHER_WALK_SLOW))) {
568 ++ blkcipher_done_fast(walk, n);
569 ++ } else {
570 ++ if (WARN_ON(err)) {
571 ++ /* unexpected case; didn't process all bytes */
572 ++ err = -EINVAL;
573 ++ goto finish;
574 ++ }
575 ++ blkcipher_done_slow(walk, n);
576 + }
577 +
578 +- scatterwalk_done(&walk->in, 0, nbytes);
579 +- scatterwalk_done(&walk->out, 1, nbytes);
580 ++ scatterwalk_done(&walk->in, 0, more);
581 ++ scatterwalk_done(&walk->out, 1, more);
582 +
583 +-err:
584 +- walk->total = nbytes;
585 +- walk->nbytes = nbytes;
586 +-
587 +- if (nbytes) {
588 ++ if (more) {
589 + crypto_yield(desc->flags);
590 + return blkcipher_walk_next(desc, walk);
591 + }
592 +-
593 ++ err = 0;
594 ++finish:
595 ++ walk->nbytes = 0;
596 + if (walk->iv != desc->info)
597 + memcpy(desc->info, walk->iv, walk->ivsize);
598 + if (walk->buffer != walk->page)
599 + kfree(walk->buffer);
600 + if (walk->page)
601 + free_page((unsigned long)walk->page);
602 +-
603 + return err;
604 + }
605 + EXPORT_SYMBOL_GPL(blkcipher_walk_done);
606 +diff --git a/crypto/skcipher.c b/crypto/skcipher.c
607 +index 0fe2a2923ad0..5dc8407bdaa9 100644
608 +--- a/crypto/skcipher.c
609 ++++ b/crypto/skcipher.c
610 +@@ -95,7 +95,7 @@ static inline u8 *skcipher_get_spot(u8 *start, unsigned int len)
611 + return max(start, end_page);
612 + }
613 +
614 +-static int skcipher_done_slow(struct skcipher_walk *walk, unsigned int bsize)
615 ++static void skcipher_done_slow(struct skcipher_walk *walk, unsigned int bsize)
616 + {
617 + u8 *addr;
618 +
619 +@@ -103,23 +103,24 @@ static int skcipher_done_slow(struct skcipher_walk *walk, unsigned int bsize)
620 + addr = skcipher_get_spot(addr, bsize);
621 + scatterwalk_copychunks(addr, &walk->out, bsize,
622 + (walk->flags & SKCIPHER_WALK_PHYS) ? 2 : 1);
623 +- return 0;
624 + }
625 +
626 + int skcipher_walk_done(struct skcipher_walk *walk, int err)
627 + {
628 +- unsigned int n = walk->nbytes - err;
629 +- unsigned int nbytes;
630 +-
631 +- nbytes = walk->total - n;
632 +-
633 +- if (unlikely(err < 0)) {
634 +- nbytes = 0;
635 +- n = 0;
636 +- } else if (likely(!(walk->flags & (SKCIPHER_WALK_PHYS |
637 +- SKCIPHER_WALK_SLOW |
638 +- SKCIPHER_WALK_COPY |
639 +- SKCIPHER_WALK_DIFF)))) {
640 ++ unsigned int n; /* bytes processed */
641 ++ bool more;
642 ++
643 ++ if (unlikely(err < 0))
644 ++ goto finish;
645 ++
646 ++ n = walk->nbytes - err;
647 ++ walk->total -= n;
648 ++ more = (walk->total != 0);
649 ++
650 ++ if (likely(!(walk->flags & (SKCIPHER_WALK_PHYS |
651 ++ SKCIPHER_WALK_SLOW |
652 ++ SKCIPHER_WALK_COPY |
653 ++ SKCIPHER_WALK_DIFF)))) {
654 + unmap_src:
655 + skcipher_unmap_src(walk);
656 + } else if (walk->flags & SKCIPHER_WALK_DIFF) {
657 +@@ -131,28 +132,28 @@ unmap_src:
658 + skcipher_unmap_dst(walk);
659 + } else if (unlikely(walk->flags & SKCIPHER_WALK_SLOW)) {
660 + if (WARN_ON(err)) {
661 ++ /* unexpected case; didn't process all bytes */
662 + err = -EINVAL;
663 +- nbytes = 0;
664 +- } else
665 +- n = skcipher_done_slow(walk, n);
666 ++ goto finish;
667 ++ }
668 ++ skcipher_done_slow(walk, n);
669 ++ goto already_advanced;
670 + }
671 +
672 +- if (err > 0)
673 +- err = 0;
674 +-
675 +- walk->total = nbytes;
676 +- walk->nbytes = nbytes;
677 +-
678 + scatterwalk_advance(&walk->in, n);
679 + scatterwalk_advance(&walk->out, n);
680 +- scatterwalk_done(&walk->in, 0, nbytes);
681 +- scatterwalk_done(&walk->out, 1, nbytes);
682 ++already_advanced:
683 ++ scatterwalk_done(&walk->in, 0, more);
684 ++ scatterwalk_done(&walk->out, 1, more);
685 +
686 +- if (nbytes) {
687 ++ if (more) {
688 + crypto_yield(walk->flags & SKCIPHER_WALK_SLEEP ?
689 + CRYPTO_TFM_REQ_MAY_SLEEP : 0);
690 + return skcipher_walk_next(walk);
691 + }
692 ++ err = 0;
693 ++finish:
694 ++ walk->nbytes = 0;
695 +
696 + /* Short-circuit for the common/fast path. */
697 + if (!((unsigned long)walk->buffer | (unsigned long)walk->page))
698 +@@ -399,7 +400,7 @@ static int skcipher_copy_iv(struct skcipher_walk *walk)
699 + unsigned size;
700 + u8 *iv;
701 +
702 +- aligned_bs = ALIGN(bs, alignmask);
703 ++ aligned_bs = ALIGN(bs, alignmask + 1);
704 +
705 + /* Minimum size to align buffer by alignmask. */
706 + size = alignmask & ~a;
707 +diff --git a/crypto/vmac.c b/crypto/vmac.c
708 +index df76a816cfb2..bb2fc787d615 100644
709 +--- a/crypto/vmac.c
710 ++++ b/crypto/vmac.c
711 +@@ -1,6 +1,10 @@
712 + /*
713 +- * Modified to interface to the Linux kernel
714 ++ * VMAC: Message Authentication Code using Universal Hashing
715 ++ *
716 ++ * Reference: https://tools.ietf.org/html/draft-krovetz-vmac-01
717 ++ *
718 + * Copyright (c) 2009, Intel Corporation.
719 ++ * Copyright (c) 2018, Google Inc.
720 + *
721 + * This program is free software; you can redistribute it and/or modify it
722 + * under the terms and conditions of the GNU General Public License,
723 +@@ -16,14 +20,15 @@
724 + * Place - Suite 330, Boston, MA 02111-1307 USA.
725 + */
726 +
727 +-/* --------------------------------------------------------------------------
728 +- * VMAC and VHASH Implementation by Ted Krovetz (tdk@×××.org) and Wei Dai.
729 +- * This implementation is herby placed in the public domain.
730 +- * The authors offers no warranty. Use at your own risk.
731 +- * Please send bug reports to the authors.
732 +- * Last modified: 17 APR 08, 1700 PDT
733 +- * ----------------------------------------------------------------------- */
734 ++/*
735 ++ * Derived from:
736 ++ * VMAC and VHASH Implementation by Ted Krovetz (tdk@×××.org) and Wei Dai.
737 ++ * This implementation is herby placed in the public domain.
738 ++ * The authors offers no warranty. Use at your own risk.
739 ++ * Last modified: 17 APR 08, 1700 PDT
740 ++ */
741 +
742 ++#include <asm/unaligned.h>
743 + #include <linux/init.h>
744 + #include <linux/types.h>
745 + #include <linux/crypto.h>
746 +@@ -31,9 +36,35 @@
747 + #include <linux/scatterlist.h>
748 + #include <asm/byteorder.h>
749 + #include <crypto/scatterwalk.h>
750 +-#include <crypto/vmac.h>
751 + #include <crypto/internal/hash.h>
752 +
753 ++/*
754 ++ * User definable settings.
755 ++ */
756 ++#define VMAC_TAG_LEN 64
757 ++#define VMAC_KEY_SIZE 128/* Must be 128, 192 or 256 */
758 ++#define VMAC_KEY_LEN (VMAC_KEY_SIZE/8)
759 ++#define VMAC_NHBYTES 128/* Must 2^i for any 3 < i < 13 Standard = 128*/
760 ++
761 ++/* per-transform (per-key) context */
762 ++struct vmac_tfm_ctx {
763 ++ struct crypto_cipher *cipher;
764 ++ u64 nhkey[(VMAC_NHBYTES/8)+2*(VMAC_TAG_LEN/64-1)];
765 ++ u64 polykey[2*VMAC_TAG_LEN/64];
766 ++ u64 l3key[2*VMAC_TAG_LEN/64];
767 ++};
768 ++
769 ++/* per-request context */
770 ++struct vmac_desc_ctx {
771 ++ union {
772 ++ u8 partial[VMAC_NHBYTES]; /* partial block */
773 ++ __le64 partial_words[VMAC_NHBYTES / 8];
774 ++ };
775 ++ unsigned int partial_size; /* size of the partial block */
776 ++ bool first_block_processed;
777 ++ u64 polytmp[2*VMAC_TAG_LEN/64]; /* running total of L2-hash */
778 ++};
779 ++
780 + /*
781 + * Constants and masks
782 + */
783 +@@ -318,13 +349,6 @@ static void poly_step_func(u64 *ahi, u64 *alo,
784 + } while (0)
785 + #endif
786 +
787 +-static void vhash_abort(struct vmac_ctx *ctx)
788 +-{
789 +- ctx->polytmp[0] = ctx->polykey[0] ;
790 +- ctx->polytmp[1] = ctx->polykey[1] ;
791 +- ctx->first_block_processed = 0;
792 +-}
793 +-
794 + static u64 l3hash(u64 p1, u64 p2, u64 k1, u64 k2, u64 len)
795 + {
796 + u64 rh, rl, t, z = 0;
797 +@@ -364,280 +388,209 @@ static u64 l3hash(u64 p1, u64 p2, u64 k1, u64 k2, u64 len)
798 + return rl;
799 + }
800 +
801 +-static void vhash_update(const unsigned char *m,
802 +- unsigned int mbytes, /* Pos multiple of VMAC_NHBYTES */
803 +- struct vmac_ctx *ctx)
804 ++/* L1 and L2-hash one or more VMAC_NHBYTES-byte blocks */
805 ++static void vhash_blocks(const struct vmac_tfm_ctx *tctx,
806 ++ struct vmac_desc_ctx *dctx,
807 ++ const __le64 *mptr, unsigned int blocks)
808 + {
809 +- u64 rh, rl, *mptr;
810 +- const u64 *kptr = (u64 *)ctx->nhkey;
811 +- int i;
812 +- u64 ch, cl;
813 +- u64 pkh = ctx->polykey[0];
814 +- u64 pkl = ctx->polykey[1];
815 +-
816 +- if (!mbytes)
817 +- return;
818 +-
819 +- BUG_ON(mbytes % VMAC_NHBYTES);
820 +-
821 +- mptr = (u64 *)m;
822 +- i = mbytes / VMAC_NHBYTES; /* Must be non-zero */
823 +-
824 +- ch = ctx->polytmp[0];
825 +- cl = ctx->polytmp[1];
826 +-
827 +- if (!ctx->first_block_processed) {
828 +- ctx->first_block_processed = 1;
829 ++ const u64 *kptr = tctx->nhkey;
830 ++ const u64 pkh = tctx->polykey[0];
831 ++ const u64 pkl = tctx->polykey[1];
832 ++ u64 ch = dctx->polytmp[0];
833 ++ u64 cl = dctx->polytmp[1];
834 ++ u64 rh, rl;
835 ++
836 ++ if (!dctx->first_block_processed) {
837 ++ dctx->first_block_processed = true;
838 + nh_vmac_nhbytes(mptr, kptr, VMAC_NHBYTES/8, rh, rl);
839 + rh &= m62;
840 + ADD128(ch, cl, rh, rl);
841 + mptr += (VMAC_NHBYTES/sizeof(u64));
842 +- i--;
843 ++ blocks--;
844 + }
845 +
846 +- while (i--) {
847 ++ while (blocks--) {
848 + nh_vmac_nhbytes(mptr, kptr, VMAC_NHBYTES/8, rh, rl);
849 + rh &= m62;
850 + poly_step(ch, cl, pkh, pkl, rh, rl);
851 + mptr += (VMAC_NHBYTES/sizeof(u64));
852 + }
853 +
854 +- ctx->polytmp[0] = ch;
855 +- ctx->polytmp[1] = cl;
856 ++ dctx->polytmp[0] = ch;
857 ++ dctx->polytmp[1] = cl;
858 + }
859 +
860 +-static u64 vhash(unsigned char m[], unsigned int mbytes,
861 +- u64 *tagl, struct vmac_ctx *ctx)
862 ++static int vmac_setkey(struct crypto_shash *tfm,
863 ++ const u8 *key, unsigned int keylen)
864 + {
865 +- u64 rh, rl, *mptr;
866 +- const u64 *kptr = (u64 *)ctx->nhkey;
867 +- int i, remaining;
868 +- u64 ch, cl;
869 +- u64 pkh = ctx->polykey[0];
870 +- u64 pkl = ctx->polykey[1];
871 +-
872 +- mptr = (u64 *)m;
873 +- i = mbytes / VMAC_NHBYTES;
874 +- remaining = mbytes % VMAC_NHBYTES;
875 +-
876 +- if (ctx->first_block_processed) {
877 +- ch = ctx->polytmp[0];
878 +- cl = ctx->polytmp[1];
879 +- } else if (i) {
880 +- nh_vmac_nhbytes(mptr, kptr, VMAC_NHBYTES/8, ch, cl);
881 +- ch &= m62;
882 +- ADD128(ch, cl, pkh, pkl);
883 +- mptr += (VMAC_NHBYTES/sizeof(u64));
884 +- i--;
885 +- } else if (remaining) {
886 +- nh_16(mptr, kptr, 2*((remaining+15)/16), ch, cl);
887 +- ch &= m62;
888 +- ADD128(ch, cl, pkh, pkl);
889 +- mptr += (VMAC_NHBYTES/sizeof(u64));
890 +- goto do_l3;
891 +- } else {/* Empty String */
892 +- ch = pkh; cl = pkl;
893 +- goto do_l3;
894 +- }
895 +-
896 +- while (i--) {
897 +- nh_vmac_nhbytes(mptr, kptr, VMAC_NHBYTES/8, rh, rl);
898 +- rh &= m62;
899 +- poly_step(ch, cl, pkh, pkl, rh, rl);
900 +- mptr += (VMAC_NHBYTES/sizeof(u64));
901 +- }
902 +- if (remaining) {
903 +- nh_16(mptr, kptr, 2*((remaining+15)/16), rh, rl);
904 +- rh &= m62;
905 +- poly_step(ch, cl, pkh, pkl, rh, rl);
906 +- }
907 +-
908 +-do_l3:
909 +- vhash_abort(ctx);
910 +- remaining *= 8;
911 +- return l3hash(ch, cl, ctx->l3key[0], ctx->l3key[1], remaining);
912 +-}
913 ++ struct vmac_tfm_ctx *tctx = crypto_shash_ctx(tfm);
914 ++ __be64 out[2];
915 ++ u8 in[16] = { 0 };
916 ++ unsigned int i;
917 ++ int err;
918 +
919 +-static u64 vmac(unsigned char m[], unsigned int mbytes,
920 +- const unsigned char n[16], u64 *tagl,
921 +- struct vmac_ctx_t *ctx)
922 +-{
923 +- u64 *in_n, *out_p;
924 +- u64 p, h;
925 +- int i;
926 +-
927 +- in_n = ctx->__vmac_ctx.cached_nonce;
928 +- out_p = ctx->__vmac_ctx.cached_aes;
929 +-
930 +- i = n[15] & 1;
931 +- if ((*(u64 *)(n+8) != in_n[1]) || (*(u64 *)(n) != in_n[0])) {
932 +- in_n[0] = *(u64 *)(n);
933 +- in_n[1] = *(u64 *)(n+8);
934 +- ((unsigned char *)in_n)[15] &= 0xFE;
935 +- crypto_cipher_encrypt_one(ctx->child,
936 +- (unsigned char *)out_p, (unsigned char *)in_n);
937 +-
938 +- ((unsigned char *)in_n)[15] |= (unsigned char)(1-i);
939 ++ if (keylen != VMAC_KEY_LEN) {
940 ++ crypto_shash_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN);
941 ++ return -EINVAL;
942 + }
943 +- p = be64_to_cpup(out_p + i);
944 +- h = vhash(m, mbytes, (u64 *)0, &ctx->__vmac_ctx);
945 +- return le64_to_cpu(p + h);
946 +-}
947 +
948 +-static int vmac_set_key(unsigned char user_key[], struct vmac_ctx_t *ctx)
949 +-{
950 +- u64 in[2] = {0}, out[2];
951 +- unsigned i;
952 +- int err = 0;
953 +-
954 +- err = crypto_cipher_setkey(ctx->child, user_key, VMAC_KEY_LEN);
955 ++ err = crypto_cipher_setkey(tctx->cipher, key, keylen);
956 + if (err)
957 + return err;
958 +
959 + /* Fill nh key */
960 +- ((unsigned char *)in)[0] = 0x80;
961 +- for (i = 0; i < sizeof(ctx->__vmac_ctx.nhkey)/8; i += 2) {
962 +- crypto_cipher_encrypt_one(ctx->child,
963 +- (unsigned char *)out, (unsigned char *)in);
964 +- ctx->__vmac_ctx.nhkey[i] = be64_to_cpup(out);
965 +- ctx->__vmac_ctx.nhkey[i+1] = be64_to_cpup(out+1);
966 +- ((unsigned char *)in)[15] += 1;
967 ++ in[0] = 0x80;
968 ++ for (i = 0; i < ARRAY_SIZE(tctx->nhkey); i += 2) {
969 ++ crypto_cipher_encrypt_one(tctx->cipher, (u8 *)out, in);
970 ++ tctx->nhkey[i] = be64_to_cpu(out[0]);
971 ++ tctx->nhkey[i+1] = be64_to_cpu(out[1]);
972 ++ in[15]++;
973 + }
974 +
975 + /* Fill poly key */
976 +- ((unsigned char *)in)[0] = 0xC0;
977 +- in[1] = 0;
978 +- for (i = 0; i < sizeof(ctx->__vmac_ctx.polykey)/8; i += 2) {
979 +- crypto_cipher_encrypt_one(ctx->child,
980 +- (unsigned char *)out, (unsigned char *)in);
981 +- ctx->__vmac_ctx.polytmp[i] =
982 +- ctx->__vmac_ctx.polykey[i] =
983 +- be64_to_cpup(out) & mpoly;
984 +- ctx->__vmac_ctx.polytmp[i+1] =
985 +- ctx->__vmac_ctx.polykey[i+1] =
986 +- be64_to_cpup(out+1) & mpoly;
987 +- ((unsigned char *)in)[15] += 1;
988 ++ in[0] = 0xC0;
989 ++ in[15] = 0;
990 ++ for (i = 0; i < ARRAY_SIZE(tctx->polykey); i += 2) {
991 ++ crypto_cipher_encrypt_one(tctx->cipher, (u8 *)out, in);
992 ++ tctx->polykey[i] = be64_to_cpu(out[0]) & mpoly;
993 ++ tctx->polykey[i+1] = be64_to_cpu(out[1]) & mpoly;
994 ++ in[15]++;
995 + }
996 +
997 + /* Fill ip key */
998 +- ((unsigned char *)in)[0] = 0xE0;
999 +- in[1] = 0;
1000 +- for (i = 0; i < sizeof(ctx->__vmac_ctx.l3key)/8; i += 2) {
1001 ++ in[0] = 0xE0;
1002 ++ in[15] = 0;
1003 ++ for (i = 0; i < ARRAY_SIZE(tctx->l3key); i += 2) {
1004 + do {
1005 +- crypto_cipher_encrypt_one(ctx->child,
1006 +- (unsigned char *)out, (unsigned char *)in);
1007 +- ctx->__vmac_ctx.l3key[i] = be64_to_cpup(out);
1008 +- ctx->__vmac_ctx.l3key[i+1] = be64_to_cpup(out+1);
1009 +- ((unsigned char *)in)[15] += 1;
1010 +- } while (ctx->__vmac_ctx.l3key[i] >= p64
1011 +- || ctx->__vmac_ctx.l3key[i+1] >= p64);
1012 ++ crypto_cipher_encrypt_one(tctx->cipher, (u8 *)out, in);
1013 ++ tctx->l3key[i] = be64_to_cpu(out[0]);
1014 ++ tctx->l3key[i+1] = be64_to_cpu(out[1]);
1015 ++ in[15]++;
1016 ++ } while (tctx->l3key[i] >= p64 || tctx->l3key[i+1] >= p64);
1017 + }
1018 +
1019 +- /* Invalidate nonce/aes cache and reset other elements */
1020 +- ctx->__vmac_ctx.cached_nonce[0] = (u64)-1; /* Ensure illegal nonce */
1021 +- ctx->__vmac_ctx.cached_nonce[1] = (u64)0; /* Ensure illegal nonce */
1022 +- ctx->__vmac_ctx.first_block_processed = 0;
1023 +-
1024 +- return err;
1025 ++ return 0;
1026 + }
1027 +
1028 +-static int vmac_setkey(struct crypto_shash *parent,
1029 +- const u8 *key, unsigned int keylen)
1030 ++static int vmac_init(struct shash_desc *desc)
1031 + {
1032 +- struct vmac_ctx_t *ctx = crypto_shash_ctx(parent);
1033 ++ const struct vmac_tfm_ctx *tctx = crypto_shash_ctx(desc->tfm);
1034 ++ struct vmac_desc_ctx *dctx = shash_desc_ctx(desc);
1035 +
1036 +- if (keylen != VMAC_KEY_LEN) {
1037 +- crypto_shash_set_flags(parent, CRYPTO_TFM_RES_BAD_KEY_LEN);
1038 +- return -EINVAL;
1039 +- }
1040 +-
1041 +- return vmac_set_key((u8 *)key, ctx);
1042 +-}
1043 +-
1044 +-static int vmac_init(struct shash_desc *pdesc)
1045 +-{
1046 ++ dctx->partial_size = 0;
1047 ++ dctx->first_block_processed = false;
1048 ++ memcpy(dctx->polytmp, tctx->polykey, sizeof(dctx->polytmp));
1049 + return 0;
1050 + }
1051 +
1052 +-static int vmac_update(struct shash_desc *pdesc, const u8 *p,
1053 +- unsigned int len)
1054 ++static int vmac_update(struct shash_desc *desc, const u8 *p, unsigned int len)
1055 + {
1056 +- struct crypto_shash *parent = pdesc->tfm;
1057 +- struct vmac_ctx_t *ctx = crypto_shash_ctx(parent);
1058 +- int expand;
1059 +- int min;
1060 +-
1061 +- expand = VMAC_NHBYTES - ctx->partial_size > 0 ?
1062 +- VMAC_NHBYTES - ctx->partial_size : 0;
1063 +-
1064 +- min = len < expand ? len : expand;
1065 +-
1066 +- memcpy(ctx->partial + ctx->partial_size, p, min);
1067 +- ctx->partial_size += min;
1068 +-
1069 +- if (len < expand)
1070 +- return 0;
1071 +-
1072 +- vhash_update(ctx->partial, VMAC_NHBYTES, &ctx->__vmac_ctx);
1073 +- ctx->partial_size = 0;
1074 +-
1075 +- len -= expand;
1076 +- p += expand;
1077 ++ const struct vmac_tfm_ctx *tctx = crypto_shash_ctx(desc->tfm);
1078 ++ struct vmac_desc_ctx *dctx = shash_desc_ctx(desc);
1079 ++ unsigned int n;
1080 ++
1081 ++ if (dctx->partial_size) {
1082 ++ n = min(len, VMAC_NHBYTES - dctx->partial_size);
1083 ++ memcpy(&dctx->partial[dctx->partial_size], p, n);
1084 ++ dctx->partial_size += n;
1085 ++ p += n;
1086 ++ len -= n;
1087 ++ if (dctx->partial_size == VMAC_NHBYTES) {
1088 ++ vhash_blocks(tctx, dctx, dctx->partial_words, 1);
1089 ++ dctx->partial_size = 0;
1090 ++ }
1091 ++ }
1092 +
1093 +- if (len % VMAC_NHBYTES) {
1094 +- memcpy(ctx->partial, p + len - (len % VMAC_NHBYTES),
1095 +- len % VMAC_NHBYTES);
1096 +- ctx->partial_size = len % VMAC_NHBYTES;
1097 ++ if (len >= VMAC_NHBYTES) {
1098 ++ n = round_down(len, VMAC_NHBYTES);
1099 ++ /* TODO: 'p' may be misaligned here */
1100 ++ vhash_blocks(tctx, dctx, (const __le64 *)p, n / VMAC_NHBYTES);
1101 ++ p += n;
1102 ++ len -= n;
1103 + }
1104 +
1105 +- vhash_update(p, len - len % VMAC_NHBYTES, &ctx->__vmac_ctx);
1106 ++ if (len) {
1107 ++ memcpy(dctx->partial, p, len);
1108 ++ dctx->partial_size = len;
1109 ++ }
1110 +
1111 + return 0;
1112 + }
1113 +
1114 +-static int vmac_final(struct shash_desc *pdesc, u8 *out)
1115 ++static u64 vhash_final(const struct vmac_tfm_ctx *tctx,
1116 ++ struct vmac_desc_ctx *dctx)
1117 + {
1118 +- struct crypto_shash *parent = pdesc->tfm;
1119 +- struct vmac_ctx_t *ctx = crypto_shash_ctx(parent);
1120 +- vmac_t mac;
1121 +- u8 nonce[16] = {};
1122 +-
1123 +- /* vmac() ends up accessing outside the array bounds that
1124 +- * we specify. In appears to access up to the next 2-word
1125 +- * boundary. We'll just be uber cautious and zero the
1126 +- * unwritten bytes in the buffer.
1127 +- */
1128 +- if (ctx->partial_size) {
1129 +- memset(ctx->partial + ctx->partial_size, 0,
1130 +- VMAC_NHBYTES - ctx->partial_size);
1131 ++ unsigned int partial = dctx->partial_size;
1132 ++ u64 ch = dctx->polytmp[0];
1133 ++ u64 cl = dctx->polytmp[1];
1134 ++
1135 ++ /* L1 and L2-hash the final block if needed */
1136 ++ if (partial) {
1137 ++ /* Zero-pad to next 128-bit boundary */
1138 ++ unsigned int n = round_up(partial, 16);
1139 ++ u64 rh, rl;
1140 ++
1141 ++ memset(&dctx->partial[partial], 0, n - partial);
1142 ++ nh_16(dctx->partial_words, tctx->nhkey, n / 8, rh, rl);
1143 ++ rh &= m62;
1144 ++ if (dctx->first_block_processed)
1145 ++ poly_step(ch, cl, tctx->polykey[0], tctx->polykey[1],
1146 ++ rh, rl);
1147 ++ else
1148 ++ ADD128(ch, cl, rh, rl);
1149 + }
1150 +- mac = vmac(ctx->partial, ctx->partial_size, nonce, NULL, ctx);
1151 +- memcpy(out, &mac, sizeof(vmac_t));
1152 +- memzero_explicit(&mac, sizeof(vmac_t));
1153 +- memset(&ctx->__vmac_ctx, 0, sizeof(struct vmac_ctx));
1154 +- ctx->partial_size = 0;
1155 ++
1156 ++ /* L3-hash the 128-bit output of L2-hash */
1157 ++ return l3hash(ch, cl, tctx->l3key[0], tctx->l3key[1], partial * 8);
1158 ++}
1159 ++
1160 ++static int vmac_final(struct shash_desc *desc, u8 *out)
1161 ++{
1162 ++ const struct vmac_tfm_ctx *tctx = crypto_shash_ctx(desc->tfm);
1163 ++ struct vmac_desc_ctx *dctx = shash_desc_ctx(desc);
1164 ++ static const u8 nonce[16] = {}; /* TODO: this is insecure */
1165 ++ union {
1166 ++ u8 bytes[16];
1167 ++ __be64 pads[2];
1168 ++ } block;
1169 ++ int index;
1170 ++ u64 hash, pad;
1171 ++
1172 ++ /* Finish calculating the VHASH of the message */
1173 ++ hash = vhash_final(tctx, dctx);
1174 ++
1175 ++ /* Generate pseudorandom pad by encrypting the nonce */
1176 ++ memcpy(&block, nonce, 16);
1177 ++ index = block.bytes[15] & 1;
1178 ++ block.bytes[15] &= ~1;
1179 ++ crypto_cipher_encrypt_one(tctx->cipher, block.bytes, block.bytes);
1180 ++ pad = be64_to_cpu(block.pads[index]);
1181 ++
1182 ++ /* The VMAC is the sum of VHASH and the pseudorandom pad */
1183 ++ put_unaligned_le64(hash + pad, out);
1184 + return 0;
1185 + }
1186 +
1187 + static int vmac_init_tfm(struct crypto_tfm *tfm)
1188 + {
1189 +- struct crypto_cipher *cipher;
1190 +- struct crypto_instance *inst = (void *)tfm->__crt_alg;
1191 ++ struct crypto_instance *inst = crypto_tfm_alg_instance(tfm);
1192 + struct crypto_spawn *spawn = crypto_instance_ctx(inst);
1193 +- struct vmac_ctx_t *ctx = crypto_tfm_ctx(tfm);
1194 ++ struct vmac_tfm_ctx *tctx = crypto_tfm_ctx(tfm);
1195 ++ struct crypto_cipher *cipher;
1196 +
1197 + cipher = crypto_spawn_cipher(spawn);
1198 + if (IS_ERR(cipher))
1199 + return PTR_ERR(cipher);
1200 +
1201 +- ctx->child = cipher;
1202 ++ tctx->cipher = cipher;
1203 + return 0;
1204 + }
1205 +
1206 + static void vmac_exit_tfm(struct crypto_tfm *tfm)
1207 + {
1208 +- struct vmac_ctx_t *ctx = crypto_tfm_ctx(tfm);
1209 +- crypto_free_cipher(ctx->child);
1210 ++ struct vmac_tfm_ctx *tctx = crypto_tfm_ctx(tfm);
1211 ++
1212 ++ crypto_free_cipher(tctx->cipher);
1213 + }
1214 +
1215 + static int vmac_create(struct crypto_template *tmpl, struct rtattr **tb)
1216 +@@ -655,6 +608,10 @@ static int vmac_create(struct crypto_template *tmpl, struct rtattr **tb)
1217 + if (IS_ERR(alg))
1218 + return PTR_ERR(alg);
1219 +
1220 ++ err = -EINVAL;
1221 ++ if (alg->cra_blocksize != 16)
1222 ++ goto out_put_alg;
1223 ++
1224 + inst = shash_alloc_instance("vmac", alg);
1225 + err = PTR_ERR(inst);
1226 + if (IS_ERR(inst))
1227 +@@ -670,11 +627,12 @@ static int vmac_create(struct crypto_template *tmpl, struct rtattr **tb)
1228 + inst->alg.base.cra_blocksize = alg->cra_blocksize;
1229 + inst->alg.base.cra_alignmask = alg->cra_alignmask;
1230 +
1231 +- inst->alg.digestsize = sizeof(vmac_t);
1232 +- inst->alg.base.cra_ctxsize = sizeof(struct vmac_ctx_t);
1233 ++ inst->alg.base.cra_ctxsize = sizeof(struct vmac_tfm_ctx);
1234 + inst->alg.base.cra_init = vmac_init_tfm;
1235 + inst->alg.base.cra_exit = vmac_exit_tfm;
1236 +
1237 ++ inst->alg.descsize = sizeof(struct vmac_desc_ctx);
1238 ++ inst->alg.digestsize = VMAC_TAG_LEN / 8;
1239 + inst->alg.init = vmac_init;
1240 + inst->alg.update = vmac_update;
1241 + inst->alg.final = vmac_final;
1242 +diff --git a/drivers/crypto/ccp/psp-dev.c b/drivers/crypto/ccp/psp-dev.c
1243 +index d95ec526587a..2867612eaf61 100644
1244 +--- a/drivers/crypto/ccp/psp-dev.c
1245 ++++ b/drivers/crypto/ccp/psp-dev.c
1246 +@@ -78,8 +78,6 @@ done:
1247 +
1248 + static void sev_wait_cmd_ioc(struct psp_device *psp, unsigned int *reg)
1249 + {
1250 +- psp->sev_int_rcvd = 0;
1251 +-
1252 + wait_event(psp->sev_int_queue, psp->sev_int_rcvd);
1253 + *reg = ioread32(psp->io_regs + PSP_CMDRESP);
1254 + }
1255 +@@ -140,6 +138,8 @@ static int __sev_do_cmd_locked(int cmd, void *data, int *psp_ret)
1256 + iowrite32(phys_lsb, psp->io_regs + PSP_CMDBUFF_ADDR_LO);
1257 + iowrite32(phys_msb, psp->io_regs + PSP_CMDBUFF_ADDR_HI);
1258 +
1259 ++ psp->sev_int_rcvd = 0;
1260 ++
1261 + reg = cmd;
1262 + reg <<= PSP_CMDRESP_CMD_SHIFT;
1263 + reg |= PSP_CMDRESP_IOC;
1264 +@@ -732,6 +732,9 @@ void psp_dev_destroy(struct sp_device *sp)
1265 + {
1266 + struct psp_device *psp = sp->psp_data;
1267 +
1268 ++ if (!psp)
1269 ++ return;
1270 ++
1271 + if (psp->sev_misc)
1272 + kref_put(&misc_dev->refcount, sev_exit);
1273 +
1274 +diff --git a/drivers/crypto/ccree/cc_cipher.c b/drivers/crypto/ccree/cc_cipher.c
1275 +index df98f7afe645..86e568a6d217 100644
1276 +--- a/drivers/crypto/ccree/cc_cipher.c
1277 ++++ b/drivers/crypto/ccree/cc_cipher.c
1278 +@@ -554,34 +554,82 @@ static void cc_setup_cipher_data(struct crypto_tfm *tfm,
1279 + }
1280 + }
1281 +
1282 ++/*
1283 ++ * Update a CTR-AES 128 bit counter
1284 ++ */
1285 ++static void cc_update_ctr(u8 *ctr, unsigned int increment)
1286 ++{
1287 ++ if (IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) ||
1288 ++ IS_ALIGNED((unsigned long)ctr, 8)) {
1289 ++
1290 ++ __be64 *high_be = (__be64 *)ctr;
1291 ++ __be64 *low_be = high_be + 1;
1292 ++ u64 orig_low = __be64_to_cpu(*low_be);
1293 ++ u64 new_low = orig_low + (u64)increment;
1294 ++
1295 ++ *low_be = __cpu_to_be64(new_low);
1296 ++
1297 ++ if (new_low < orig_low)
1298 ++ *high_be = __cpu_to_be64(__be64_to_cpu(*high_be) + 1);
1299 ++ } else {
1300 ++ u8 *pos = (ctr + AES_BLOCK_SIZE);
1301 ++ u8 val;
1302 ++ unsigned int size;
1303 ++
1304 ++ for (; increment; increment--)
1305 ++ for (size = AES_BLOCK_SIZE; size; size--) {
1306 ++ val = *--pos + 1;
1307 ++ *pos = val;
1308 ++ if (val)
1309 ++ break;
1310 ++ }
1311 ++ }
1312 ++}
1313 ++
1314 + static void cc_cipher_complete(struct device *dev, void *cc_req, int err)
1315 + {
1316 + struct skcipher_request *req = (struct skcipher_request *)cc_req;
1317 + struct scatterlist *dst = req->dst;
1318 + struct scatterlist *src = req->src;
1319 + struct cipher_req_ctx *req_ctx = skcipher_request_ctx(req);
1320 +- struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
1321 +- unsigned int ivsize = crypto_skcipher_ivsize(tfm);
1322 ++ struct crypto_skcipher *sk_tfm = crypto_skcipher_reqtfm(req);
1323 ++ struct crypto_tfm *tfm = crypto_skcipher_tfm(sk_tfm);
1324 ++ struct cc_cipher_ctx *ctx_p = crypto_tfm_ctx(tfm);
1325 ++ unsigned int ivsize = crypto_skcipher_ivsize(sk_tfm);
1326 ++ unsigned int len;
1327 +
1328 +- cc_unmap_cipher_request(dev, req_ctx, ivsize, src, dst);
1329 +- kzfree(req_ctx->iv);
1330 ++ switch (ctx_p->cipher_mode) {
1331 ++ case DRV_CIPHER_CBC:
1332 ++ /*
1333 ++ * The crypto API expects us to set the req->iv to the last
1334 ++ * ciphertext block. For encrypt, simply copy from the result.
1335 ++ * For decrypt, we must copy from a saved buffer since this
1336 ++ * could be an in-place decryption operation and the src is
1337 ++ * lost by this point.
1338 ++ */
1339 ++ if (req_ctx->gen_ctx.op_type == DRV_CRYPTO_DIRECTION_DECRYPT) {
1340 ++ memcpy(req->iv, req_ctx->backup_info, ivsize);
1341 ++ kzfree(req_ctx->backup_info);
1342 ++ } else if (!err) {
1343 ++ len = req->cryptlen - ivsize;
1344 ++ scatterwalk_map_and_copy(req->iv, req->dst, len,
1345 ++ ivsize, 0);
1346 ++ }
1347 ++ break;
1348 +
1349 +- /*
1350 +- * The crypto API expects us to set the req->iv to the last
1351 +- * ciphertext block. For encrypt, simply copy from the result.
1352 +- * For decrypt, we must copy from a saved buffer since this
1353 +- * could be an in-place decryption operation and the src is
1354 +- * lost by this point.
1355 +- */
1356 +- if (req_ctx->gen_ctx.op_type == DRV_CRYPTO_DIRECTION_DECRYPT) {
1357 +- memcpy(req->iv, req_ctx->backup_info, ivsize);
1358 +- kzfree(req_ctx->backup_info);
1359 +- } else if (!err) {
1360 +- scatterwalk_map_and_copy(req->iv, req->dst,
1361 +- (req->cryptlen - ivsize),
1362 +- ivsize, 0);
1363 ++ case DRV_CIPHER_CTR:
1364 ++ /* Compute the counter of the last block */
1365 ++ len = ALIGN(req->cryptlen, AES_BLOCK_SIZE) / AES_BLOCK_SIZE;
1366 ++ cc_update_ctr((u8 *)req->iv, len);
1367 ++ break;
1368 ++
1369 ++ default:
1370 ++ break;
1371 + }
1372 +
1373 ++ cc_unmap_cipher_request(dev, req_ctx, ivsize, src, dst);
1374 ++ kzfree(req_ctx->iv);
1375 ++
1376 + skcipher_request_complete(req, err);
1377 + }
1378 +
1379 +@@ -713,20 +761,29 @@ static int cc_cipher_encrypt(struct skcipher_request *req)
1380 + static int cc_cipher_decrypt(struct skcipher_request *req)
1381 + {
1382 + struct crypto_skcipher *sk_tfm = crypto_skcipher_reqtfm(req);
1383 ++ struct crypto_tfm *tfm = crypto_skcipher_tfm(sk_tfm);
1384 ++ struct cc_cipher_ctx *ctx_p = crypto_tfm_ctx(tfm);
1385 + struct cipher_req_ctx *req_ctx = skcipher_request_ctx(req);
1386 + unsigned int ivsize = crypto_skcipher_ivsize(sk_tfm);
1387 + gfp_t flags = cc_gfp_flags(&req->base);
1388 ++ unsigned int len;
1389 +
1390 +- /*
1391 +- * Allocate and save the last IV sized bytes of the source, which will
1392 +- * be lost in case of in-place decryption and might be needed for CTS.
1393 +- */
1394 +- req_ctx->backup_info = kmalloc(ivsize, flags);
1395 +- if (!req_ctx->backup_info)
1396 +- return -ENOMEM;
1397 ++ if (ctx_p->cipher_mode == DRV_CIPHER_CBC) {
1398 ++
1399 ++ /* Allocate and save the last IV sized bytes of the source,
1400 ++ * which will be lost in case of in-place decryption.
1401 ++ */
1402 ++ req_ctx->backup_info = kzalloc(ivsize, flags);
1403 ++ if (!req_ctx->backup_info)
1404 ++ return -ENOMEM;
1405 ++
1406 ++ len = req->cryptlen - ivsize;
1407 ++ scatterwalk_map_and_copy(req_ctx->backup_info, req->src, len,
1408 ++ ivsize, 0);
1409 ++ } else {
1410 ++ req_ctx->backup_info = NULL;
1411 ++ }
1412 +
1413 +- scatterwalk_map_and_copy(req_ctx->backup_info, req->src,
1414 +- (req->cryptlen - ivsize), ivsize, 0);
1415 + req_ctx->is_giv = false;
1416 +
1417 + return cc_cipher_process(req, DRV_CRYPTO_DIRECTION_DECRYPT);
1418 +diff --git a/drivers/crypto/ccree/cc_hash.c b/drivers/crypto/ccree/cc_hash.c
1419 +index 96ff777474d7..e4ebde05a8a0 100644
1420 +--- a/drivers/crypto/ccree/cc_hash.c
1421 ++++ b/drivers/crypto/ccree/cc_hash.c
1422 +@@ -602,66 +602,7 @@ static int cc_hash_update(struct ahash_request *req)
1423 + return rc;
1424 + }
1425 +
1426 +-static int cc_hash_finup(struct ahash_request *req)
1427 +-{
1428 +- struct ahash_req_ctx *state = ahash_request_ctx(req);
1429 +- struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
1430 +- struct cc_hash_ctx *ctx = crypto_ahash_ctx(tfm);
1431 +- u32 digestsize = crypto_ahash_digestsize(tfm);
1432 +- struct scatterlist *src = req->src;
1433 +- unsigned int nbytes = req->nbytes;
1434 +- u8 *result = req->result;
1435 +- struct device *dev = drvdata_to_dev(ctx->drvdata);
1436 +- bool is_hmac = ctx->is_hmac;
1437 +- struct cc_crypto_req cc_req = {};
1438 +- struct cc_hw_desc desc[CC_MAX_HASH_SEQ_LEN];
1439 +- unsigned int idx = 0;
1440 +- int rc;
1441 +- gfp_t flags = cc_gfp_flags(&req->base);
1442 +-
1443 +- dev_dbg(dev, "===== %s-finup (%d) ====\n", is_hmac ? "hmac" : "hash",
1444 +- nbytes);
1445 +-
1446 +- if (cc_map_req(dev, state, ctx)) {
1447 +- dev_err(dev, "map_ahash_source() failed\n");
1448 +- return -EINVAL;
1449 +- }
1450 +-
1451 +- if (cc_map_hash_request_final(ctx->drvdata, state, src, nbytes, 1,
1452 +- flags)) {
1453 +- dev_err(dev, "map_ahash_request_final() failed\n");
1454 +- cc_unmap_req(dev, state, ctx);
1455 +- return -ENOMEM;
1456 +- }
1457 +- if (cc_map_result(dev, state, digestsize)) {
1458 +- dev_err(dev, "map_ahash_digest() failed\n");
1459 +- cc_unmap_hash_request(dev, state, src, true);
1460 +- cc_unmap_req(dev, state, ctx);
1461 +- return -ENOMEM;
1462 +- }
1463 +-
1464 +- /* Setup request structure */
1465 +- cc_req.user_cb = cc_hash_complete;
1466 +- cc_req.user_arg = req;
1467 +-
1468 +- idx = cc_restore_hash(desc, ctx, state, idx);
1469 +-
1470 +- if (is_hmac)
1471 +- idx = cc_fin_hmac(desc, req, idx);
1472 +-
1473 +- idx = cc_fin_result(desc, req, idx);
1474 +-
1475 +- rc = cc_send_request(ctx->drvdata, &cc_req, desc, idx, &req->base);
1476 +- if (rc != -EINPROGRESS && rc != -EBUSY) {
1477 +- dev_err(dev, "send_request() failed (rc=%d)\n", rc);
1478 +- cc_unmap_hash_request(dev, state, src, true);
1479 +- cc_unmap_result(dev, state, digestsize, result);
1480 +- cc_unmap_req(dev, state, ctx);
1481 +- }
1482 +- return rc;
1483 +-}
1484 +-
1485 +-static int cc_hash_final(struct ahash_request *req)
1486 ++static int cc_do_finup(struct ahash_request *req, bool update)
1487 + {
1488 + struct ahash_req_ctx *state = ahash_request_ctx(req);
1489 + struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
1490 +@@ -678,21 +619,20 @@ static int cc_hash_final(struct ahash_request *req)
1491 + int rc;
1492 + gfp_t flags = cc_gfp_flags(&req->base);
1493 +
1494 +- dev_dbg(dev, "===== %s-final (%d) ====\n", is_hmac ? "hmac" : "hash",
1495 +- nbytes);
1496 ++ dev_dbg(dev, "===== %s-%s (%d) ====\n", is_hmac ? "hmac" : "hash",
1497 ++ update ? "finup" : "final", nbytes);
1498 +
1499 + if (cc_map_req(dev, state, ctx)) {
1500 + dev_err(dev, "map_ahash_source() failed\n");
1501 + return -EINVAL;
1502 + }
1503 +
1504 +- if (cc_map_hash_request_final(ctx->drvdata, state, src, nbytes, 0,
1505 ++ if (cc_map_hash_request_final(ctx->drvdata, state, src, nbytes, update,
1506 + flags)) {
1507 + dev_err(dev, "map_ahash_request_final() failed\n");
1508 + cc_unmap_req(dev, state, ctx);
1509 + return -ENOMEM;
1510 + }
1511 +-
1512 + if (cc_map_result(dev, state, digestsize)) {
1513 + dev_err(dev, "map_ahash_digest() failed\n");
1514 + cc_unmap_hash_request(dev, state, src, true);
1515 +@@ -706,7 +646,7 @@ static int cc_hash_final(struct ahash_request *req)
1516 +
1517 + idx = cc_restore_hash(desc, ctx, state, idx);
1518 +
1519 +- /* "DO-PAD" must be enabled only when writing current length to HW */
1520 ++ /* Pad the hash */
1521 + hw_desc_init(&desc[idx]);
1522 + set_cipher_do(&desc[idx], DO_PAD);
1523 + set_cipher_mode(&desc[idx], ctx->hw_mode);
1524 +@@ -731,6 +671,17 @@ static int cc_hash_final(struct ahash_request *req)
1525 + return rc;
1526 + }
1527 +
1528 ++static int cc_hash_finup(struct ahash_request *req)
1529 ++{
1530 ++ return cc_do_finup(req, true);
1531 ++}
1532 ++
1533 ++
1534 ++static int cc_hash_final(struct ahash_request *req)
1535 ++{
1536 ++ return cc_do_finup(req, false);
1537 ++}
1538 ++
1539 + static int cc_hash_init(struct ahash_request *req)
1540 + {
1541 + struct ahash_req_ctx *state = ahash_request_ctx(req);
1542 +diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
1543 +index 26ca0276b503..a75cb371cd19 100644
1544 +--- a/include/asm-generic/pgtable.h
1545 ++++ b/include/asm-generic/pgtable.h
1546 +@@ -1019,8 +1019,8 @@ int pud_set_huge(pud_t *pud, phys_addr_t addr, pgprot_t prot);
1547 + int pmd_set_huge(pmd_t *pmd, phys_addr_t addr, pgprot_t prot);
1548 + int pud_clear_huge(pud_t *pud);
1549 + int pmd_clear_huge(pmd_t *pmd);
1550 +-int pud_free_pmd_page(pud_t *pud);
1551 +-int pmd_free_pte_page(pmd_t *pmd);
1552 ++int pud_free_pmd_page(pud_t *pud, unsigned long addr);
1553 ++int pmd_free_pte_page(pmd_t *pmd, unsigned long addr);
1554 + #else /* !CONFIG_HAVE_ARCH_HUGE_VMAP */
1555 + static inline int p4d_set_huge(p4d_t *p4d, phys_addr_t addr, pgprot_t prot)
1556 + {
1557 +@@ -1046,11 +1046,11 @@ static inline int pmd_clear_huge(pmd_t *pmd)
1558 + {
1559 + return 0;
1560 + }
1561 +-static inline int pud_free_pmd_page(pud_t *pud)
1562 ++static inline int pud_free_pmd_page(pud_t *pud, unsigned long addr)
1563 + {
1564 + return 0;
1565 + }
1566 +-static inline int pmd_free_pte_page(pmd_t *pmd)
1567 ++static inline int pmd_free_pte_page(pmd_t *pmd, unsigned long addr)
1568 + {
1569 + return 0;
1570 + }
1571 +diff --git a/include/crypto/vmac.h b/include/crypto/vmac.h
1572 +deleted file mode 100644
1573 +index 6b700c7b2fe1..000000000000
1574 +--- a/include/crypto/vmac.h
1575 ++++ /dev/null
1576 +@@ -1,63 +0,0 @@
1577 +-/*
1578 +- * Modified to interface to the Linux kernel
1579 +- * Copyright (c) 2009, Intel Corporation.
1580 +- *
1581 +- * This program is free software; you can redistribute it and/or modify it
1582 +- * under the terms and conditions of the GNU General Public License,
1583 +- * version 2, as published by the Free Software Foundation.
1584 +- *
1585 +- * This program is distributed in the hope it will be useful, but WITHOUT
1586 +- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1587 +- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
1588 +- * more details.
1589 +- *
1590 +- * You should have received a copy of the GNU General Public License along with
1591 +- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
1592 +- * Place - Suite 330, Boston, MA 02111-1307 USA.
1593 +- */
1594 +-
1595 +-#ifndef __CRYPTO_VMAC_H
1596 +-#define __CRYPTO_VMAC_H
1597 +-
1598 +-/* --------------------------------------------------------------------------
1599 +- * VMAC and VHASH Implementation by Ted Krovetz (tdk@×××.org) and Wei Dai.
1600 +- * This implementation is herby placed in the public domain.
1601 +- * The authors offers no warranty. Use at your own risk.
1602 +- * Please send bug reports to the authors.
1603 +- * Last modified: 17 APR 08, 1700 PDT
1604 +- * ----------------------------------------------------------------------- */
1605 +-
1606 +-/*
1607 +- * User definable settings.
1608 +- */
1609 +-#define VMAC_TAG_LEN 64
1610 +-#define VMAC_KEY_SIZE 128/* Must be 128, 192 or 256 */
1611 +-#define VMAC_KEY_LEN (VMAC_KEY_SIZE/8)
1612 +-#define VMAC_NHBYTES 128/* Must 2^i for any 3 < i < 13 Standard = 128*/
1613 +-
1614 +-/*
1615 +- * This implementation uses u32 and u64 as names for unsigned 32-
1616 +- * and 64-bit integer types. These are defined in C99 stdint.h. The
1617 +- * following may need adaptation if you are not running a C99 or
1618 +- * Microsoft C environment.
1619 +- */
1620 +-struct vmac_ctx {
1621 +- u64 nhkey[(VMAC_NHBYTES/8)+2*(VMAC_TAG_LEN/64-1)];
1622 +- u64 polykey[2*VMAC_TAG_LEN/64];
1623 +- u64 l3key[2*VMAC_TAG_LEN/64];
1624 +- u64 polytmp[2*VMAC_TAG_LEN/64];
1625 +- u64 cached_nonce[2];
1626 +- u64 cached_aes[2];
1627 +- int first_block_processed;
1628 +-};
1629 +-
1630 +-typedef u64 vmac_t;
1631 +-
1632 +-struct vmac_ctx_t {
1633 +- struct crypto_cipher *child;
1634 +- struct vmac_ctx __vmac_ctx;
1635 +- u8 partial[VMAC_NHBYTES]; /* partial block */
1636 +- int partial_size; /* size of the partial block */
1637 +-};
1638 +-
1639 +-#endif /* __CRYPTO_VMAC_H */
1640 +diff --git a/lib/ioremap.c b/lib/ioremap.c
1641 +index 54e5bbaa3200..517f5853ffed 100644
1642 +--- a/lib/ioremap.c
1643 ++++ b/lib/ioremap.c
1644 +@@ -92,7 +92,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
1645 + if (ioremap_pmd_enabled() &&
1646 + ((next - addr) == PMD_SIZE) &&
1647 + IS_ALIGNED(phys_addr + addr, PMD_SIZE) &&
1648 +- pmd_free_pte_page(pmd)) {
1649 ++ pmd_free_pte_page(pmd, addr)) {
1650 + if (pmd_set_huge(pmd, phys_addr + addr, prot))
1651 + continue;
1652 + }
1653 +@@ -119,7 +119,7 @@ static inline int ioremap_pud_range(p4d_t *p4d, unsigned long addr,
1654 + if (ioremap_pud_enabled() &&
1655 + ((next - addr) == PUD_SIZE) &&
1656 + IS_ALIGNED(phys_addr + addr, PUD_SIZE) &&
1657 +- pud_free_pmd_page(pud)) {
1658 ++ pud_free_pmd_page(pud, addr)) {
1659 + if (pud_set_huge(pud, phys_addr + addr, prot))
1660 + continue;
1661 + }
1662 +diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c
1663 +index 1036e4fa1ea2..3bba8f4b08a9 100644
1664 +--- a/net/bluetooth/hidp/core.c
1665 ++++ b/net/bluetooth/hidp/core.c
1666 +@@ -431,8 +431,8 @@ static void hidp_del_timer(struct hidp_session *session)
1667 + del_timer(&session->timer);
1668 + }
1669 +
1670 +-static void hidp_process_report(struct hidp_session *session,
1671 +- int type, const u8 *data, int len, int intr)
1672 ++static void hidp_process_report(struct hidp_session *session, int type,
1673 ++ const u8 *data, unsigned int len, int intr)
1674 + {
1675 + if (len > HID_MAX_BUFFER_SIZE)
1676 + len = HID_MAX_BUFFER_SIZE;
1677 +diff --git a/scripts/depmod.sh b/scripts/depmod.sh
1678 +index 9831cca31240..f41b0a4b575c 100755
1679 +--- a/scripts/depmod.sh
1680 ++++ b/scripts/depmod.sh
1681 +@@ -11,10 +11,16 @@ DEPMOD=$1
1682 + KERNELRELEASE=$2
1683 + SYMBOL_PREFIX=$3
1684 +
1685 +-if ! test -r System.map -a -x "$DEPMOD"; then
1686 ++if ! test -r System.map ; then
1687 + exit 0
1688 + fi
1689 +
1690 ++if [ -z $(command -v $DEPMOD) ]; then
1691 ++ echo "'make modules_install' requires $DEPMOD. Please install it." >&2
1692 ++ echo "This is probably in the kmod package." >&2
1693 ++ exit 1
1694 ++fi
1695 ++
1696 + # older versions of depmod don't support -P <symbol-prefix>
1697 + # support was added in module-init-tools 3.13
1698 + if test -n "$SYMBOL_PREFIX"; then