mirror of https://github.com/torvalds/linux.git
crypto/arm64: sm4-ce-gcm - Avoid pointless yield of the NEON unit
Kernel mode NEON sections are now preemptible on arm64, and so there is no need to yield it when calling APIs that may sleep. Also, move the calls to kernel_neon_end() to the same scope as kernel_neon_begin(). This is needed for a subsequent change where a stack buffer is allocated transparently and passed to kernel_neon_begin(). While at it, simplify the logic. Reviewed-by: Eric Biggers <ebiggers@kernel.org> Acked-by: Herbert Xu <herbert@gondor.apana.org.au> Acked-by: Catalin Marinas <catalin.marinas@arm.com> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
This commit is contained in:
parent
9520ef3771
commit
c13aebfeee
|
|
@ -154,36 +154,23 @@ static int gcm_crypt(struct aead_request *req, struct skcipher_walk *walk,
|
||||||
if (req->assoclen)
|
if (req->assoclen)
|
||||||
gcm_calculate_auth_mac(req, ghash);
|
gcm_calculate_auth_mac(req, ghash);
|
||||||
|
|
||||||
while (walk->nbytes) {
|
do {
|
||||||
unsigned int tail = walk->nbytes % SM4_BLOCK_SIZE;
|
unsigned int tail = walk->nbytes % SM4_BLOCK_SIZE;
|
||||||
const u8 *src = walk->src.virt.addr;
|
const u8 *src = walk->src.virt.addr;
|
||||||
u8 *dst = walk->dst.virt.addr;
|
u8 *dst = walk->dst.virt.addr;
|
||||||
|
const u8 *l = NULL;
|
||||||
|
|
||||||
if (walk->nbytes == walk->total) {
|
if (walk->nbytes == walk->total) {
|
||||||
sm4_ce_pmull_gcm_crypt(ctx->key.rkey_enc, dst, src, iv,
|
l = (const u8 *)&lengths;
|
||||||
walk->nbytes, ghash,
|
tail = 0;
|
||||||
ctx->ghash_table,
|
|
||||||
(const u8 *)&lengths);
|
|
||||||
|
|
||||||
kernel_neon_end();
|
|
||||||
|
|
||||||
return skcipher_walk_done(walk, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sm4_ce_pmull_gcm_crypt(ctx->key.rkey_enc, dst, src, iv,
|
sm4_ce_pmull_gcm_crypt(ctx->key.rkey_enc, dst, src, iv,
|
||||||
walk->nbytes - tail, ghash,
|
walk->nbytes - tail, ghash,
|
||||||
ctx->ghash_table, NULL);
|
ctx->ghash_table, l);
|
||||||
|
|
||||||
kernel_neon_end();
|
|
||||||
|
|
||||||
err = skcipher_walk_done(walk, tail);
|
err = skcipher_walk_done(walk, tail);
|
||||||
|
} while (walk->nbytes);
|
||||||
kernel_neon_begin();
|
|
||||||
}
|
|
||||||
|
|
||||||
sm4_ce_pmull_gcm_crypt(ctx->key.rkey_enc, NULL, NULL, iv,
|
|
||||||
walk->nbytes, ghash, ctx->ghash_table,
|
|
||||||
(const u8 *)&lengths);
|
|
||||||
|
|
||||||
kernel_neon_end();
|
kernel_neon_end();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue