diff options
| author | Eric Biggers <ebiggers@kernel.org> | 2025-07-31 15:35:10 -0700 |
|---|---|---|
| committer | Eric Biggers <ebiggers@kernel.org> | 2025-08-26 12:52:27 -0400 |
| commit | 640d31ea83c6f67133d47df9a0973f3281c91cf4 (patch) | |
| tree | f89097e80506a5e187b269fe236955b8bee727d0 /lib/crypto/riscv | |
| parent | 1b237f190eb3d36f52dffe07a40b5eb210280e00 (diff) | |
lib/crypto: sha256: Use underlying functions instead of crypto_simd_usable()
Since sha256_kunit tests the fallback code paths without using
crypto_simd_disabled_for_test, make the SHA-256 code just use the
underlying may_use_simd() and irq_fpu_usable() functions directly
instead of crypto_simd_usable(). This eliminates an unnecessary layer.
While doing this, also add likely() annotations, and fix a minor
inconsistency where the static keys in the sha256.h files were in a
different place than in the corresponding sha1.h and sha512.h files.
Link: https://lore.kernel.org/r/20250731223510.136650-1-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
Diffstat (limited to 'lib/crypto/riscv')
| -rw-r--r-- | lib/crypto/riscv/sha256.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/crypto/riscv/sha256.h b/lib/crypto/riscv/sha256.h index c0f79c18f119..f36f68d2e88c 100644 --- a/lib/crypto/riscv/sha256.h +++ b/lib/crypto/riscv/sha256.h @@ -9,19 +9,19 @@ * Author: Jerry Shih <jerry.shih@sifive.com> */ +#include <asm/simd.h> #include <asm/vector.h> -#include <crypto/internal/simd.h> + +static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_extensions); asmlinkage void sha256_transform_zvknha_or_zvknhb_zvkb(struct sha256_block_state *state, const u8 *data, size_t nblocks); -static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_extensions); - static void sha256_blocks(struct sha256_block_state *state, const u8 *data, size_t nblocks) { - if (static_branch_likely(&have_extensions) && crypto_simd_usable()) { + if (static_branch_likely(&have_extensions) && likely(may_use_simd())) { kernel_vector_begin(); sha256_transform_zvknha_or_zvknhb_zvkb(state, data, nblocks); kernel_vector_end(); |
