| 1 |
/* SPDX-License-Identifier: GPL-2.0-or-later */ |
| 2 |
/* |
| 3 |
* arm32-optimized SHA-512 block function |
| 4 |
* |
| 5 |
* Copyright 2025 Google LLC |
| 6 |
*/ |
| 7 |
#include <asm/neon.h> |
| 8 |
#include <asm/simd.h> |
| 9 |
|
| 10 |
static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_neon); |
| 11 |
|
| 12 |
asmlinkage void sha512_block_data_order(struct sha512_block_state *state, |
| 13 |
const u8 *data, size_t nblocks); |
| 14 |
asmlinkage void sha512_block_data_order_neon(struct sha512_block_state *state, |
| 15 |
const u8 *data, size_t nblocks); |
| 16 |
|
| 17 |
static void sha512_blocks(struct sha512_block_state *state, |
| 18 |
const u8 *data, size_t nblocks) |
| 19 |
{ |
| 20 |
if (IS_ENABLED(CONFIG_KERNEL_MODE_NEON) && |
| 21 |
static_branch_likely(&have_neon) && likely(may_use_simd())) { |
| 22 |
scoped_ksimd() |
| 23 |
sha512_block_data_order_neon(state, data, nblocks); |
| 24 |
} else { |
| 25 |
sha512_block_data_order(state, data, nblocks); |
| 26 |
} |
| 27 |
} |
| 28 |
|
| 29 |
#ifdef CONFIG_KERNEL_MODE_NEON |
| 30 |
#define sha512_mod_init_arch sha512_mod_init_arch |
| 31 |
static void sha512_mod_init_arch(void) |
| 32 |
{ |
| 33 |
if (cpu_has_neon()) |
| 34 |
static_branch_enable(&have_neon); |
| 35 |
} |
| 36 |
#endif /* CONFIG_KERNEL_MODE_NEON */ |