Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

crypto: skcipher - Use scatterwalk (un)map interface for dst and src buffers

The skcipher walk API implementation avoids scatterwalk_map() for
mapping the source and destination buffers, and invokes kmap_atomic()
directly if the buffer in question is not in low memory (which can only
happen on 32-bit architectures). This avoids some overhead on 64-bit
architectures, and most notably, permits the skcipher code to run with
preemption enabled.

Now that scatterwalk_map() has been updated to use kmap_local(), none of
this is needed, so we can simply use scatterwalk_map/unmap instead.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Ard Biesheuvel and committed by
Herbert Xu
d07bd950 0781bbd7

+4 -18
+4 -18
crypto/skcipher.c
··· 42 42 43 43 static int skcipher_walk_next(struct skcipher_walk *walk); 44 44 45 - static inline void skcipher_unmap(struct scatter_walk *walk, void *vaddr) 46 - { 47 - if (PageHighMem(scatterwalk_page(walk))) 48 - kunmap_atomic(vaddr); 49 - } 50 - 51 - static inline void *skcipher_map(struct scatter_walk *walk) 52 - { 53 - struct page *page = scatterwalk_page(walk); 54 - 55 - return (PageHighMem(page) ? kmap_atomic(page) : page_address(page)) + 56 - offset_in_page(walk->offset); 57 - } 58 - 59 45 static inline void skcipher_map_src(struct skcipher_walk *walk) 60 46 { 61 - walk->src.virt.addr = skcipher_map(&walk->in); 47 + walk->src.virt.addr = scatterwalk_map(&walk->in); 62 48 } 63 49 64 50 static inline void skcipher_map_dst(struct skcipher_walk *walk) 65 51 { 66 - walk->dst.virt.addr = skcipher_map(&walk->out); 52 + walk->dst.virt.addr = scatterwalk_map(&walk->out); 67 53 } 68 54 69 55 static inline void skcipher_unmap_src(struct skcipher_walk *walk) 70 56 { 71 - skcipher_unmap(&walk->in, walk->src.virt.addr); 57 + scatterwalk_unmap(walk->src.virt.addr); 72 58 } 73 59 74 60 static inline void skcipher_unmap_dst(struct skcipher_walk *walk) 75 61 { 76 - skcipher_unmap(&walk->out, walk->dst.virt.addr); 62 + scatterwalk_unmap(walk->dst.virt.addr); 77 63 } 78 64 79 65 static inline gfp_t skcipher_walk_gfp(struct skcipher_walk *walk)