diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2025-05-02 13:31:07 +0800 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2025-05-05 18:20:45 +0800 |
commit | ee8a720e39ceb7495ab639c1eb6d4987fb6a52bf (patch) | |
tree | 015840a6dd1e75be9e3ead5300e5ed5fdaea14d3 | |
parent | 491d6024f2820c78216b07cec1cb47c87dcae077 (diff) |
crypto: x86/sha256 - Add simd block function
Add CRYPTO_ARCH_HAVE_LIB_SHA256_SIMD and a SIMD block function
so that the caller can decide whether to use SIMD.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r-- | arch/x86/lib/crypto/Kconfig | 1 | ||||
-rw-r--r-- | arch/x86/lib/crypto/sha256.c | 12 |
2 files changed, 10 insertions, 3 deletions
diff --git a/arch/x86/lib/crypto/Kconfig b/arch/x86/lib/crypto/Kconfig index e344579db3d8..5e94cdee492c 100644 --- a/arch/x86/lib/crypto/Kconfig +++ b/arch/x86/lib/crypto/Kconfig @@ -30,4 +30,5 @@ config CRYPTO_SHA256_X86_64 depends on 64BIT default CRYPTO_LIB_SHA256 select CRYPTO_ARCH_HAVE_LIB_SHA256 + select CRYPTO_ARCH_HAVE_LIB_SHA256_SIMD select CRYPTO_LIB_SHA256_GENERIC diff --git a/arch/x86/lib/crypto/sha256.c b/arch/x86/lib/crypto/sha256.c index baba74d7d26f..80380f8fdcee 100644 --- a/arch/x86/lib/crypto/sha256.c +++ b/arch/x86/lib/crypto/sha256.c @@ -6,7 +6,6 @@ */ #include <asm/fpu/api.h> #include <crypto/internal/sha2.h> -#include <crypto/internal/simd.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/static_call.h> @@ -24,10 +23,10 @@ static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_sha256_x86); DEFINE_STATIC_CALL(sha256_blocks_x86, sha256_transform_ssse3); -void sha256_blocks_arch(u32 state[SHA256_STATE_WORDS], +void sha256_blocks_simd(u32 state[SHA256_STATE_WORDS], const u8 *data, size_t nblocks) { - if (static_branch_likely(&have_sha256_x86) && crypto_simd_usable()) { + if (static_branch_likely(&have_sha256_x86)) { kernel_fpu_begin(); static_call(sha256_blocks_x86)(state, data, nblocks); kernel_fpu_end(); @@ -35,6 +34,13 @@ void sha256_blocks_arch(u32 state[SHA256_STATE_WORDS], sha256_blocks_generic(state, data, nblocks); } } +EXPORT_SYMBOL_GPL(sha256_blocks_simd); + +void sha256_blocks_arch(u32 state[SHA256_STATE_WORDS], + const u8 *data, size_t nblocks) +{ + sha256_blocks_generic(state, data, nblocks); +} EXPORT_SYMBOL_GPL(sha256_blocks_arch); bool sha256_is_arch_optimized(void) |