Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

crypto: x86/twofish - stop using the SIMD helper

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>

authored by

Eric Biggers and committed by
Herbert Xu
bda5cd6e 982b72cd

+7 -15
-1
arch/x86/crypto/Kconfig
··· 270 270 tristate "Ciphers: Twofish with modes: ECB, CBC (AVX)" 271 271 depends on X86 && 64BIT 272 272 select CRYPTO_SKCIPHER 273 - select CRYPTO_SIMD 274 273 select CRYPTO_TWOFISH_COMMON 275 274 select CRYPTO_TWOFISH_X86_64 276 275 select CRYPTO_TWOFISH_X86_64_3WAY
+7 -14
arch/x86/crypto/twofish_avx_glue.c
··· 13 13 #include <linux/crypto.h> 14 14 #include <linux/err.h> 15 15 #include <crypto/algapi.h> 16 - #include <crypto/internal/simd.h> 17 16 #include <crypto/twofish.h> 18 17 19 18 #include "twofish.h" ··· 73 74 74 75 static struct skcipher_alg twofish_algs[] = { 75 76 { 76 - .base.cra_name = "__ecb(twofish)", 77 - .base.cra_driver_name = "__ecb-twofish-avx", 77 + .base.cra_name = "ecb(twofish)", 78 + .base.cra_driver_name = "ecb-twofish-avx", 78 79 .base.cra_priority = 400, 79 - .base.cra_flags = CRYPTO_ALG_INTERNAL, 80 80 .base.cra_blocksize = TF_BLOCK_SIZE, 81 81 .base.cra_ctxsize = sizeof(struct twofish_ctx), 82 82 .base.cra_module = THIS_MODULE, ··· 85 87 .encrypt = ecb_encrypt, 86 88 .decrypt = ecb_decrypt, 87 89 }, { 88 - .base.cra_name = "__cbc(twofish)", 89 - .base.cra_driver_name = "__cbc-twofish-avx", 90 + .base.cra_name = "cbc(twofish)", 91 + .base.cra_driver_name = "cbc-twofish-avx", 90 92 .base.cra_priority = 400, 91 - .base.cra_flags = CRYPTO_ALG_INTERNAL, 92 93 .base.cra_blocksize = TF_BLOCK_SIZE, 93 94 .base.cra_ctxsize = sizeof(struct twofish_ctx), 94 95 .base.cra_module = THIS_MODULE, ··· 100 103 }, 101 104 }; 102 105 103 - static struct simd_skcipher_alg *twofish_simd_algs[ARRAY_SIZE(twofish_algs)]; 104 - 105 106 static int __init twofish_init(void) 106 107 { 107 108 const char *feature_name; ··· 109 114 return -ENODEV; 110 115 } 111 116 112 - return simd_register_skciphers_compat(twofish_algs, 113 - ARRAY_SIZE(twofish_algs), 114 - twofish_simd_algs); 117 + return crypto_register_skciphers(twofish_algs, 118 + ARRAY_SIZE(twofish_algs)); 115 119 } 116 120 117 121 static void __exit twofish_exit(void) 118 122 { 119 - simd_unregister_skciphers(twofish_algs, ARRAY_SIZE(twofish_algs), 120 - twofish_simd_algs); 123 + crypto_unregister_skciphers(twofish_algs, ARRAY_SIZE(twofish_algs)); 121 124 } 122 125 123 126 module_init(twofish_init);