Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * ARM32 accelerated implementation of NH
4 *
5 * Copyright 2018 Google LLC
6 */
7
8#include <asm/neon.h>
9#include <asm/simd.h>
10
11static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_neon);
12
13asmlinkage void nh_neon(const u32 *key, const u8 *message, size_t message_len,
14 __le64 hash[NH_NUM_PASSES]);
15
16static bool nh_arch(const u32 *key, const u8 *message, size_t message_len,
17 __le64 hash[NH_NUM_PASSES])
18{
19 if (static_branch_likely(&have_neon) && message_len >= 64 &&
20 may_use_simd()) {
21 scoped_ksimd()
22 nh_neon(key, message, message_len, hash);
23 return true;
24 }
25 return false;
26}
27
28#define nh_mod_init_arch nh_mod_init_arch
29static void nh_mod_init_arch(void)
30{
31 if (elf_hwcap & HWCAP_NEON)
32 static_branch_enable(&have_neon);
33}