diff options
author | Eric Biggers <ebiggers@google.com> | 2025-04-05 11:26:02 -0700 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2025-04-07 13:22:28 +0800 |
commit | 4aa6dc909e400b247bd3abf29f805d49a9c140bf (patch) | |
tree | a86c166bc8c691851f43489ceb97a7af89fdda62 /arch/mips | |
parent | ceba0eda831382864dc420fcab5f6079fbb26ba2 (diff) |
crypto: chacha - centralize the skcipher wrappers for arch code
Following the example of the crc32 and crc32c code, make the crypto
subsystem register both generic and architecture-optimized chacha20,
xchacha20, and xchacha12 skcipher algorithms, all implemented on top of
the appropriate library functions. This eliminates the need for every
architecture to implement the same skcipher glue code.
To register the architecture-optimized skciphers only when
architecture-optimized code is actually being used, add a function
chacha_is_arch_optimized() and make each arch implement it. Change each
architecture's ChaCha module_init function to arch_initcall so that the
CPU feature detection is guaranteed to run before
chacha_is_arch_optimized() gets called by crypto/chacha.c. In the case
of s390, remove the CPU feature based module autoloading, which is no
longer needed since the module just gets pulled in via function linkage.
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'arch/mips')
-rw-r--r-- | arch/mips/crypto/chacha-glue.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/arch/mips/crypto/chacha-glue.c b/arch/mips/crypto/chacha-glue.c index f6fc2e1079a1..64ccaeaeaa1e 100644 --- a/arch/mips/crypto/chacha-glue.c +++ b/arch/mips/crypto/chacha-glue.c @@ -120,6 +120,12 @@ static struct skcipher_alg algs[] = { } }; +bool chacha_is_arch_optimized(void) +{ + return true; +} +EXPORT_SYMBOL(chacha_is_arch_optimized); + static int __init chacha_simd_mod_init(void) { return IS_REACHABLE(CONFIG_CRYPTO_SKCIPHER) ? @@ -132,7 +138,7 @@ static void __exit chacha_simd_mod_fini(void) crypto_unregister_skciphers(algs, ARRAY_SIZE(algs)); } -module_init(chacha_simd_mod_init); +arch_initcall(chacha_simd_mod_init); module_exit(chacha_simd_mod_fini); MODULE_DESCRIPTION("ChaCha and XChaCha stream ciphers (MIPS accelerated)"); |