nh.h 778 B

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