Commit 9520ef37 authored by Ard Biesheuvel's avatar Ard Biesheuvel
Browse files

crypto/arm64: sm4-ce-ccm - 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().

Reviewed-by: default avatarEric Biggers <ebiggers@kernel.org>
Acked-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
Acked-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
parent e9426f3e
Loading
Loading
Loading
Loading
+6 −19
Original line number Diff line number Diff line
@@ -172,36 +172,23 @@ static int ccm_crypt(struct aead_request *req, struct skcipher_walk *walk,
	if (req->assoclen)
		ccm_calculate_auth_mac(req, mac);

	while (walk->nbytes && walk->nbytes != walk->total) {
	while (walk->nbytes) {
		unsigned int tail = walk->nbytes % SM4_BLOCK_SIZE;

		if (walk->nbytes == walk->total)
			tail = 0;

		sm4_ce_ccm_crypt(rkey_enc, walk->dst.virt.addr,
				 walk->src.virt.addr, walk->iv,
				 walk->nbytes - tail, mac);

		kernel_neon_end();

		err = skcipher_walk_done(walk, tail);

		kernel_neon_begin();
	}

	if (walk->nbytes) {
		sm4_ce_ccm_crypt(rkey_enc, walk->dst.virt.addr,
				 walk->src.virt.addr, walk->iv,
				 walk->nbytes, mac);

	sm4_ce_ccm_final(rkey_enc, ctr0, mac);

	kernel_neon_end();

		err = skcipher_walk_done(walk, 0);
	} else {
		sm4_ce_ccm_final(rkey_enc, ctr0, mac);

		kernel_neon_end();
	}

	return err;
}