mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-18 22:14:16 +00:00
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>
This commit is contained in:
parent
491d6024f2
commit
ee8a720e39
2 changed files with 10 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue