hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/arch/arm64/crypto/chacha-neon-glue.c
....@@ -21,6 +21,7 @@
2121
2222 #include <crypto/algapi.h>
2323 #include <crypto/internal/chacha.h>
24
+#include <crypto/internal/simd.h>
2425 #include <crypto/internal/skcipher.h>
2526 #include <linux/jump_label.h>
2627 #include <linux/kernel.h>
....@@ -63,7 +64,7 @@
6364
6465 void hchacha_block_arch(const u32 *state, u32 *stream, int nrounds)
6566 {
66
- if (!static_branch_likely(&have_neon) || !may_use_simd()) {
67
+ if (!static_branch_likely(&have_neon) || !crypto_simd_usable()) {
6768 hchacha_block_generic(state, stream, nrounds);
6869 } else {
6970 kernel_neon_begin();
....@@ -83,7 +84,7 @@
8384 int nrounds)
8485 {
8586 if (!static_branch_likely(&have_neon) || bytes <= CHACHA_BLOCK_SIZE ||
86
- !may_use_simd())
87
+ !crypto_simd_usable())
8788 return chacha_crypt_generic(state, dst, src, bytes, nrounds);
8889
8990 do {
....@@ -118,7 +119,7 @@
118119 nbytes = rounddown(nbytes, walk.stride);
119120
120121 if (!static_branch_likely(&have_neon) ||
121
- !may_use_simd()) {
122
+ !crypto_simd_usable()) {
122123 chacha_crypt_generic(state, walk.dst.virt.addr,
123124 walk.src.virt.addr, nbytes,
124125 ctx->nrounds);
....@@ -213,18 +214,18 @@
213214
214215 static int __init chacha_simd_mod_init(void)
215216 {
216
- if (!(elf_hwcap & HWCAP_ASIMD))
217
+ if (!cpu_have_named_feature(ASIMD))
217218 return 0;
218219
219220 static_branch_enable(&have_neon);
220221
221
- return IS_REACHABLE(CONFIG_CRYPTO_BLKCIPHER) ?
222
+ return IS_REACHABLE(CONFIG_CRYPTO_SKCIPHER) ?
222223 crypto_register_skciphers(algs, ARRAY_SIZE(algs)) : 0;
223224 }
224225
225226 static void __exit chacha_simd_mod_fini(void)
226227 {
227
- if (IS_REACHABLE(CONFIG_CRYPTO_BLKCIPHER) && (elf_hwcap & HWCAP_ASIMD))
228
+ if (IS_REACHABLE(CONFIG_CRYPTO_SKCIPHER) && cpu_have_named_feature(ASIMD))
228229 crypto_unregister_skciphers(algs, ARRAY_SIZE(algs));
229230 }
230231