]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
crypto/arm64: aes-gcm - Switch to 'ksimd' scoped guard API
authorArd Biesheuvel <ardb@kernel.org>
Wed, 1 Oct 2025 11:43:59 +0000 (13:43 +0200)
committerArd Biesheuvel <ardb@kernel.org>
Wed, 12 Nov 2025 08:52:02 +0000 (09:52 +0100)
Switch to the more abstract 'scoped_ksimd()' API, which will be modified
in a future patch to transparently allocate a kernel mode FP/SIMD state
buffer on the stack, so that kernel mode FP/SIMD code remains
preemptible in principe, but without the memory overhead that adds 528
bytes to the size of struct task_struct.

Reviewed-by: Eric Biggers <ebiggers@kernel.org>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
arch/arm64/crypto/ghash-ce-glue.c

index 4995b6e2233501b2bb62b48c34eac2b6d35a2a56..7951557a285a9d61091a64d4e73bc87ea89e065c 100644 (file)
@@ -5,7 +5,6 @@
  * Copyright (C) 2014 - 2018 Linaro Ltd. <ard.biesheuvel@linaro.org>
  */
 
-#include <asm/neon.h>
 #include <crypto/aes.h>
 #include <crypto/b128ops.h>
 #include <crypto/gcm.h>
@@ -22,6 +21,8 @@
 #include <linux/string.h>
 #include <linux/unaligned.h>
 
+#include <asm/simd.h>
+
 MODULE_DESCRIPTION("GHASH and AES-GCM using ARMv8 Crypto Extensions");
 MODULE_AUTHOR("Ard Biesheuvel <ard.biesheuvel@linaro.org>");
 MODULE_LICENSE("GPL v2");
@@ -74,9 +75,8 @@ void ghash_do_simd_update(int blocks, u64 dg[], const char *src,
                                              u64 const h[][2],
                                              const char *head))
 {
-       kernel_neon_begin();
-       simd_update(blocks, dg, src, key->h, head);
-       kernel_neon_end();
+       scoped_ksimd()
+               simd_update(blocks, dg, src, key->h, head);
 }
 
 /* avoid hogging the CPU for too long */
@@ -329,11 +329,10 @@ static int gcm_encrypt(struct aead_request *req, char *iv, int assoclen)
                        tag = NULL;
                }
 
-               kernel_neon_begin();
-               pmull_gcm_encrypt(nbytes, dst, src, ctx->ghash_key.h,
-                                 dg, iv, ctx->aes_key.key_enc, nrounds,
-                                 tag);
-               kernel_neon_end();
+               scoped_ksimd()
+                       pmull_gcm_encrypt(nbytes, dst, src, ctx->ghash_key.h,
+                                         dg, iv, ctx->aes_key.key_enc, nrounds,
+                                         tag);
 
                if (unlikely(!nbytes))
                        break;
@@ -399,11 +398,11 @@ static int gcm_decrypt(struct aead_request *req, char *iv, int assoclen)
                        tag = NULL;
                }
 
-               kernel_neon_begin();
-               ret = pmull_gcm_decrypt(nbytes, dst, src, ctx->ghash_key.h,
-                                       dg, iv, ctx->aes_key.key_enc,
-                                       nrounds, tag, otag, authsize);
-               kernel_neon_end();
+               scoped_ksimd()
+                       ret = pmull_gcm_decrypt(nbytes, dst, src,
+                                               ctx->ghash_key.h,
+                                               dg, iv, ctx->aes_key.key_enc,
+                                               nrounds, tag, otag, authsize);
 
                if (unlikely(!nbytes))
                        break;