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

Configure Feed

Select the types of activity you want to include in your feed.

crypto: x86/aes-gcm - use the new scatterwalk functions

In gcm_process_assoc(), use scatterwalk_next() which consolidates
scatterwalk_clamp() and scatterwalk_map(). Use scatterwalk_done_src()
which consolidates scatterwalk_unmap(), scatterwalk_advance(), and
scatterwalk_done().

Also rename some variables to avoid implying that anything is actually
mapped (it's not), or that the loop is going page by page (it is for
now, but nothing actually requires that to be the case).

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Eric Biggers and committed by
Herbert Xu
e9787def 95c47514

+14 -14
+14 -14
arch/x86/crypto/aesni-intel_glue.c
··· 1306 1306 scatterwalk_start(&walk, sg_src); 1307 1307 1308 1308 while (assoclen) { 1309 - unsigned int len_this_page = scatterwalk_clamp(&walk, assoclen); 1310 - void *mapped = scatterwalk_map(&walk); 1311 - const void *src = mapped; 1309 + unsigned int orig_len_this_step; 1310 + const u8 *orig_src = scatterwalk_next(&walk, assoclen, 1311 + &orig_len_this_step); 1312 + unsigned int len_this_step = orig_len_this_step; 1312 1313 unsigned int len; 1314 + const u8 *src = orig_src; 1313 1315 1314 - assoclen -= len_this_page; 1315 - scatterwalk_advance(&walk, len_this_page); 1316 1316 if (unlikely(pos)) { 1317 - len = min(len_this_page, 16 - pos); 1317 + len = min(len_this_step, 16 - pos); 1318 1318 memcpy(&buf[pos], src, len); 1319 1319 pos += len; 1320 1320 src += len; 1321 - len_this_page -= len; 1321 + len_this_step -= len; 1322 1322 if (pos < 16) 1323 1323 goto next; 1324 1324 aes_gcm_aad_update(key, ghash_acc, buf, 16, flags); 1325 1325 pos = 0; 1326 1326 } 1327 - len = len_this_page; 1327 + len = len_this_step; 1328 1328 if (unlikely(assoclen)) /* Not the last segment yet? */ 1329 1329 len = round_down(len, 16); 1330 1330 aes_gcm_aad_update(key, ghash_acc, src, len, flags); 1331 1331 src += len; 1332 - len_this_page -= len; 1333 - if (unlikely(len_this_page)) { 1334 - memcpy(buf, src, len_this_page); 1335 - pos = len_this_page; 1332 + len_this_step -= len; 1333 + if (unlikely(len_this_step)) { 1334 + memcpy(buf, src, len_this_step); 1335 + pos = len_this_step; 1336 1336 } 1337 1337 next: 1338 - scatterwalk_unmap(mapped); 1339 - scatterwalk_pagedone(&walk, 0, assoclen); 1338 + scatterwalk_done_src(&walk, orig_src, orig_len_this_step); 1340 1339 if (need_resched()) { 1341 1340 kernel_fpu_end(); 1342 1341 kernel_fpu_begin(); 1343 1342 } 1343 + assoclen -= orig_len_this_step; 1344 1344 } 1345 1345 if (unlikely(pos)) 1346 1346 aes_gcm_aad_update(key, ghash_acc, buf, pos, flags);