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.

at v6.17 46 lines 1.3 kB view raw
1/* SPDX-License-Identifier: GPL-2.0-or-later */ 2/* 3 * SHA-1 optimized for ARM 4 * 5 * Copyright 2025 Google LLC 6 */ 7#include <asm/neon.h> 8#include <asm/simd.h> 9 10static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_neon); 11static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_ce); 12 13asmlinkage void sha1_block_data_order(struct sha1_block_state *state, 14 const u8 *data, size_t nblocks); 15asmlinkage void sha1_transform_neon(struct sha1_block_state *state, 16 const u8 *data, size_t nblocks); 17asmlinkage void sha1_ce_transform(struct sha1_block_state *state, 18 const u8 *data, size_t nblocks); 19 20static void sha1_blocks(struct sha1_block_state *state, 21 const u8 *data, size_t nblocks) 22{ 23 if (IS_ENABLED(CONFIG_KERNEL_MODE_NEON) && 24 static_branch_likely(&have_neon) && likely(may_use_simd())) { 25 kernel_neon_begin(); 26 if (static_branch_likely(&have_ce)) 27 sha1_ce_transform(state, data, nblocks); 28 else 29 sha1_transform_neon(state, data, nblocks); 30 kernel_neon_end(); 31 } else { 32 sha1_block_data_order(state, data, nblocks); 33 } 34} 35 36#ifdef CONFIG_KERNEL_MODE_NEON 37#define sha1_mod_init_arch sha1_mod_init_arch 38static inline void sha1_mod_init_arch(void) 39{ 40 if (elf_hwcap & HWCAP_NEON) { 41 static_branch_enable(&have_neon); 42 if (elf_hwcap2 & HWCAP2_SHA1) 43 static_branch_enable(&have_ce); 44 } 45} 46#endif /* CONFIG_KERNEL_MODE_NEON */