[PATCH 2/5] crypto/arm64: sm4-ce-ccm - Avoid pointless yield of the NEON unit

From: Ard Biesheuvel

Date: Thu Sep 18 2025 - 02:36:34 EST


From: Ard Biesheuvel <ardb@xxxxxxxxxx>

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().

Signed-off-by: Ard Biesheuvel <ardb@xxxxxxxxxx>
---
arch/arm64/crypto/sm4-ce-ccm-glue.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/arch/arm64/crypto/sm4-ce-ccm-glue.c b/arch/arm64/crypto/sm4-ce-ccm-glue.c
index e9cc1c1364ec..f9771ab2a05f 100644
--- a/arch/arm64/crypto/sm4-ce-ccm-glue.c
+++ b/arch/arm64/crypto/sm4-ce-ccm-glue.c
@@ -179,11 +179,7 @@ static int ccm_crypt(struct aead_request *req, struct skcipher_walk *walk,
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) {
@@ -193,15 +189,13 @@ static int ccm_crypt(struct aead_request *req, struct skcipher_walk *walk,

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();
}

+ kernel_neon_end();
+
return err;
}

--
2.51.0.384.g4c02a37b29-goog