crypto: x86/twofish - stop using the SIMD helper
authorEric Biggers <ebiggers@google.com>
Wed, 2 Apr 2025 00:24:09 +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/twofish_avx_glue.c

index afc1a05e663ddca4d0df6cab6bc15397f4e67e3d..f9e46e83440f18187fb5055bdbfba09714cb284f 100644 (file)
@@ -270,7 +270,6 @@ config CRYPTO_TWOFISH_AVX_X86_64
        tristate "Ciphers: Twofish with modes: ECB, CBC (AVX)"
        depends on X86 && 64BIT
        select CRYPTO_SKCIPHER
-       select CRYPTO_SIMD
        select CRYPTO_TWOFISH_COMMON
        select CRYPTO_TWOFISH_X86_64
        select CRYPTO_TWOFISH_X86_64_3WAY
index 3eb3440b477a8e19f7326f3ff17365e421be5164..9e20db01375011947f15ebed75c8898968050653 100644 (file)
@@ -13,7 +13,6 @@
 #include <linux/crypto.h>
 #include <linux/err.h>
 #include <crypto/algapi.h>
-#include <crypto/internal/simd.h>
 #include <crypto/twofish.h>
 
 #include "twofish.h"
@@ -74,10 +73,9 @@ static int cbc_decrypt(struct skcipher_request *req)
 
 static struct skcipher_alg twofish_algs[] = {
        {
-               .base.cra_name          = "__ecb(twofish)",
-               .base.cra_driver_name   = "__ecb-twofish-avx",
+               .base.cra_name          = "ecb(twofish)",
+               .base.cra_driver_name   = "ecb-twofish-avx",
                .base.cra_priority      = 400,
-               .base.cra_flags         = CRYPTO_ALG_INTERNAL,
                .base.cra_blocksize     = TF_BLOCK_SIZE,
                .base.cra_ctxsize       = sizeof(struct twofish_ctx),
                .base.cra_module        = THIS_MODULE,
@@ -87,10 +85,9 @@ static struct skcipher_alg twofish_algs[] = {
                .encrypt                = ecb_encrypt,
                .decrypt                = ecb_decrypt,
        }, {
-               .base.cra_name          = "__cbc(twofish)",
-               .base.cra_driver_name   = "__cbc-twofish-avx",
+               .base.cra_name          = "cbc(twofish)",
+               .base.cra_driver_name   = "cbc-twofish-avx",
                .base.cra_priority      = 400,
-               .base.cra_flags         = CRYPTO_ALG_INTERNAL,
                .base.cra_blocksize     = TF_BLOCK_SIZE,
                .base.cra_ctxsize       = sizeof(struct twofish_ctx),
                .base.cra_module        = THIS_MODULE,
@@ -103,8 +100,6 @@ static struct skcipher_alg twofish_algs[] = {
        },
 };
 
-static struct simd_skcipher_alg *twofish_simd_algs[ARRAY_SIZE(twofish_algs)];
-
 static int __init twofish_init(void)
 {
        const char *feature_name;
@@ -114,15 +109,13 @@ static int __init twofish_init(void)
                return -ENODEV;
        }
 
-       return simd_register_skciphers_compat(twofish_algs,
-                                             ARRAY_SIZE(twofish_algs),
-                                             twofish_simd_algs);
+       return crypto_register_skciphers(twofish_algs,
+                                        ARRAY_SIZE(twofish_algs));
 }
 
 static void __exit twofish_exit(void)
 {
-       simd_unregister_skciphers(twofish_algs, ARRAY_SIZE(twofish_algs),
-                                 twofish_simd_algs);
+       crypto_unregister_skciphers(twofish_algs, ARRAY_SIZE(twofish_algs));
 }
 
 module_init(twofish_init);