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

Configure Feed

Select the types of activity you want to include in your feed.

lib/crypto: sha512: Use underlying functions instead of crypto_simd_usable()

Since sha512_kunit tests the fallback code paths without using
crypto_simd_disabled_for_test, make the SHA-512 code just use the
underlying may_use_simd() and irq_fpu_usable() functions directly
instead of crypto_simd_usable(). This eliminates an unnecessary layer.

Link: https://lore.kernel.org/r/20250731223651.136939-1-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@kernel.org>

+6 -12
+2 -3
lib/crypto/arm/sha512.h
··· 4 4 * 5 5 * Copyright 2025 Google LLC 6 6 */ 7 - 8 7 #include <asm/neon.h> 9 - #include <crypto/internal/simd.h> 8 + #include <asm/simd.h> 10 9 11 10 static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_neon); 12 11 ··· 18 19 const u8 *data, size_t nblocks) 19 20 { 20 21 if (IS_ENABLED(CONFIG_KERNEL_MODE_NEON) && 21 - static_branch_likely(&have_neon) && likely(crypto_simd_usable())) { 22 + static_branch_likely(&have_neon) && likely(may_use_simd())) { 22 23 kernel_neon_begin(); 23 24 sha512_block_data_order_neon(state, data, nblocks); 24 25 kernel_neon_end();
+2 -3
lib/crypto/arm64/sha512.h
··· 4 4 * 5 5 * Copyright 2025 Google LLC 6 6 */ 7 - 8 7 #include <asm/neon.h> 9 - #include <crypto/internal/simd.h> 8 + #include <asm/simd.h> 10 9 #include <linux/cpufeature.h> 11 10 12 11 static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_sha512_insns); ··· 20 21 { 21 22 if (IS_ENABLED(CONFIG_KERNEL_MODE_NEON) && 22 23 static_branch_likely(&have_sha512_insns) && 23 - likely(crypto_simd_usable())) { 24 + likely(may_use_simd())) { 24 25 do { 25 26 size_t rem; 26 27
+1 -3
lib/crypto/riscv/sha512.h
··· 11 11 12 12 #include <asm/simd.h> 13 13 #include <asm/vector.h> 14 - #include <crypto/internal/simd.h> 15 14 16 15 static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_extensions); 17 16 ··· 20 21 static void sha512_blocks(struct sha512_block_state *state, 21 22 const u8 *data, size_t nblocks) 22 23 { 23 - if (static_branch_likely(&have_extensions) && 24 - likely(crypto_simd_usable())) { 24 + if (static_branch_likely(&have_extensions) && likely(may_use_simd())) { 25 25 kernel_vector_begin(); 26 26 sha512_transform_zvknhb_zvkb(state, data, nblocks); 27 27 kernel_vector_end();
+1 -3
lib/crypto/x86/sha512.h
··· 4 4 * 5 5 * Copyright 2025 Google LLC 6 6 */ 7 - 8 7 #include <asm/fpu/api.h> 9 - #include <crypto/internal/simd.h> 10 8 #include <linux/static_call.h> 11 9 12 10 DEFINE_STATIC_CALL(sha512_blocks_x86, sha512_blocks_generic); ··· 15 17 static void c_fn(struct sha512_block_state *state, const u8 *data, \ 16 18 size_t nblocks) \ 17 19 { \ 18 - if (likely(crypto_simd_usable())) { \ 20 + if (likely(irq_fpu_usable())) { \ 19 21 kernel_fpu_begin(); \ 20 22 asm_fn(state, data, nblocks); \ 21 23 kernel_fpu_end(); \