]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
crypto: x86/camellia - stop using the SIMD helper
authorEric Biggers <ebiggers@google.com>
Wed, 2 Apr 2025 00:24:05 +0000 (17:24 -0700)
committerHerbert Xu <herbert@gondor.apana.org.au>
Mon, 7 Apr 2025 05:22:27 +0000 (13:22 +0800)
Stop wrapping skcipher and aead algorithms with the crypto SIMD helper
(crypto/simd.c).  The only purpose of doing so was to work around x86
not always supporting kernel-mode FPU in softirqs.  Specifically, if a
hardirq interrupted a task context kernel-mode FPU section and then a
softirqs were run at the end of that hardirq, those softirqs could not
use kernel-mode FPU.  This has now been fixed.  In combination with the
fact that the skcipher and aead APIs only support task and softirq
contexts, these can now just use kernel-mode FPU unconditionally on x86.

This simplifies the code and improves performance.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
arch/x86/crypto/Kconfig
arch/x86/crypto/camellia_aesni_avx2_glue.c
arch/x86/crypto/camellia_aesni_avx_glue.c

index ad00d53ab83d8c4f92e47778129e847efb44d3d9..de927df89ccf108b877cb2c34447cba09982ff7f 100644 (file)
@@ -63,7 +63,6 @@ config CRYPTO_CAMELLIA_AESNI_AVX_X86_64
        depends on X86 && 64BIT
        select CRYPTO_SKCIPHER
        select CRYPTO_CAMELLIA_X86_64
-       select CRYPTO_SIMD
        imply CRYPTO_XTS
        help
          Length-preserving ciphers: Camellia with ECB and CBC modes
index e7e4d64e9577e9956d49df01b491aac580b1fcbf..2d2f4e16537c4f329631845b0d0aa13d8f09abcf 100644 (file)
@@ -6,7 +6,6 @@
  */
 
 #include <crypto/algapi.h>
-#include <crypto/internal/simd.h>
 #include <linux/crypto.h>
 #include <linux/err.h>
 #include <linux/module.h>
@@ -69,10 +68,9 @@ static int cbc_decrypt(struct skcipher_request *req)
 
 static struct skcipher_alg camellia_algs[] = {
        {
-               .base.cra_name          = "__ecb(camellia)",
-               .base.cra_driver_name   = "__ecb-camellia-aesni-avx2",
+               .base.cra_name          = "ecb(camellia)",
+               .base.cra_driver_name   = "ecb-camellia-aesni-avx2",
                .base.cra_priority      = 500,
-               .base.cra_flags         = CRYPTO_ALG_INTERNAL,
                .base.cra_blocksize     = CAMELLIA_BLOCK_SIZE,
                .base.cra_ctxsize       = sizeof(struct camellia_ctx),
                .base.cra_module        = THIS_MODULE,
@@ -82,10 +80,9 @@ static struct skcipher_alg camellia_algs[] = {
                .encrypt                = ecb_encrypt,
                .decrypt                = ecb_decrypt,
        }, {
-               .base.cra_name          = "__cbc(camellia)",
-               .base.cra_driver_name   = "__cbc-camellia-aesni-avx2",
+               .base.cra_name          = "cbc(camellia)",
+               .base.cra_driver_name   = "cbc-camellia-aesni-avx2",
                .base.cra_priority      = 500,
-               .base.cra_flags         = CRYPTO_ALG_INTERNAL,
                .base.cra_blocksize     = CAMELLIA_BLOCK_SIZE,
                .base.cra_ctxsize       = sizeof(struct camellia_ctx),
                .base.cra_module        = THIS_MODULE,
@@ -98,8 +95,6 @@ static struct skcipher_alg camellia_algs[] = {
        },
 };
 
-static struct simd_skcipher_alg *camellia_simd_algs[ARRAY_SIZE(camellia_algs)];
-
 static int __init camellia_aesni_init(void)
 {
        const char *feature_name;
@@ -118,15 +113,13 @@ static int __init camellia_aesni_init(void)
                return -ENODEV;
        }
 
-       return simd_register_skciphers_compat(camellia_algs,
-                                             ARRAY_SIZE(camellia_algs),
-                                             camellia_simd_algs);
+       return crypto_register_skciphers(camellia_algs,
+                                        ARRAY_SIZE(camellia_algs));
 }
 
 static void __exit camellia_aesni_fini(void)
 {
-       simd_unregister_skciphers(camellia_algs, ARRAY_SIZE(camellia_algs),
-                                 camellia_simd_algs);
+       crypto_unregister_skciphers(camellia_algs, ARRAY_SIZE(camellia_algs));
 }
 
 module_init(camellia_aesni_init);
index c7ccf63e741e16a9ec3386e63a206763bf3dee45..a7d1623881424d78a2f1a647922e02f4dc4d8698 100644 (file)
@@ -6,7 +6,6 @@
  */
 
 #include <crypto/algapi.h>
-#include <crypto/internal/simd.h>
 #include <linux/crypto.h>
 #include <linux/err.h>
 #include <linux/module.h>
@@ -69,10 +68,9 @@ static int cbc_decrypt(struct skcipher_request *req)
 
 static struct skcipher_alg camellia_algs[] = {
        {
-               .base.cra_name          = "__ecb(camellia)",
-               .base.cra_driver_name   = "__ecb-camellia-aesni",
+               .base.cra_name          = "ecb(camellia)",
+               .base.cra_driver_name   = "ecb-camellia-aesni",
                .base.cra_priority      = 400,
-               .base.cra_flags         = CRYPTO_ALG_INTERNAL,
                .base.cra_blocksize     = CAMELLIA_BLOCK_SIZE,
                .base.cra_ctxsize       = sizeof(struct camellia_ctx),
                .base.cra_module        = THIS_MODULE,
@@ -82,10 +80,9 @@ static struct skcipher_alg camellia_algs[] = {
                .encrypt                = ecb_encrypt,
                .decrypt                = ecb_decrypt,
        }, {
-               .base.cra_name          = "__cbc(camellia)",
-               .base.cra_driver_name   = "__cbc-camellia-aesni",
+               .base.cra_name          = "cbc(camellia)",
+               .base.cra_driver_name   = "cbc-camellia-aesni",
                .base.cra_priority      = 400,
-               .base.cra_flags         = CRYPTO_ALG_INTERNAL,
                .base.cra_blocksize     = CAMELLIA_BLOCK_SIZE,
                .base.cra_ctxsize       = sizeof(struct camellia_ctx),
                .base.cra_module        = THIS_MODULE,
@@ -98,8 +95,6 @@ static struct skcipher_alg camellia_algs[] = {
        }
 };
 
-static struct simd_skcipher_alg *camellia_simd_algs[ARRAY_SIZE(camellia_algs)];
-
 static int __init camellia_aesni_init(void)
 {
        const char *feature_name;
@@ -117,15 +112,13 @@ static int __init camellia_aesni_init(void)
                return -ENODEV;
        }
 
-       return simd_register_skciphers_compat(camellia_algs,
-                                             ARRAY_SIZE(camellia_algs),
-                                             camellia_simd_algs);
+       return crypto_register_skciphers(camellia_algs,
+                                        ARRAY_SIZE(camellia_algs));
 }
 
 static void __exit camellia_aesni_fini(void)
 {
-       simd_unregister_skciphers(camellia_algs, ARRAY_SIZE(camellia_algs),
-                                 camellia_simd_algs);
+       crypto_unregister_skciphers(camellia_algs, ARRAY_SIZE(camellia_algs));
 }
 
 module_init(camellia_aesni_init);