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