Skip to content

Commit

Permalink
crypto: arm/chacha20 - limit the preemption-disabled section
Browse files Browse the repository at this point in the history
To improve responsivesess, disable preemption for each step of the walk
(which is at most PAGE_SIZE) rather than for the entire
encryption/decryption operation.

Suggested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
  • Loading branch information
Eric Biggers authored and Herbert Xu committed Nov 20, 2018
1 parent aa76240 commit be2830b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions arch/arm/crypto/chacha20-neon-glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,22 @@ static int chacha20_neon(struct skcipher_request *req)
if (req->cryptlen <= CHACHA_BLOCK_SIZE || !may_use_simd())
return crypto_chacha_crypt(req);

err = skcipher_walk_virt(&walk, req, true);
err = skcipher_walk_virt(&walk, req, false);

crypto_chacha_init(state, ctx, walk.iv);

kernel_neon_begin();
while (walk.nbytes > 0) {
unsigned int nbytes = walk.nbytes;

if (nbytes < walk.total)
nbytes = round_down(nbytes, walk.stride);

kernel_neon_begin();
chacha20_doneon(state, walk.dst.virt.addr, walk.src.virt.addr,
nbytes);
kernel_neon_end();
err = skcipher_walk_done(&walk, walk.nbytes - nbytes);
}
kernel_neon_end();

return err;
}
Expand Down

0 comments on commit be2830b

Please sign in to comment.