| .. | .. |
|---|
| 21 | 21 | |
|---|
| 22 | 22 | #include <crypto/algapi.h> |
|---|
| 23 | 23 | #include <crypto/internal/chacha.h> |
|---|
| 24 | +#include <crypto/internal/simd.h> |
|---|
| 24 | 25 | #include <crypto/internal/skcipher.h> |
|---|
| 25 | 26 | #include <linux/jump_label.h> |
|---|
| 26 | 27 | #include <linux/kernel.h> |
|---|
| .. | .. |
|---|
| 63 | 64 | |
|---|
| 64 | 65 | void hchacha_block_arch(const u32 *state, u32 *stream, int nrounds) |
|---|
| 65 | 66 | { |
|---|
| 66 | | - if (!static_branch_likely(&have_neon) || !may_use_simd()) { |
|---|
| 67 | + if (!static_branch_likely(&have_neon) || !crypto_simd_usable()) { |
|---|
| 67 | 68 | hchacha_block_generic(state, stream, nrounds); |
|---|
| 68 | 69 | } else { |
|---|
| 69 | 70 | kernel_neon_begin(); |
|---|
| .. | .. |
|---|
| 83 | 84 | int nrounds) |
|---|
| 84 | 85 | { |
|---|
| 85 | 86 | if (!static_branch_likely(&have_neon) || bytes <= CHACHA_BLOCK_SIZE || |
|---|
| 86 | | - !may_use_simd()) |
|---|
| 87 | + !crypto_simd_usable()) |
|---|
| 87 | 88 | return chacha_crypt_generic(state, dst, src, bytes, nrounds); |
|---|
| 88 | 89 | |
|---|
| 89 | 90 | do { |
|---|
| .. | .. |
|---|
| 118 | 119 | nbytes = rounddown(nbytes, walk.stride); |
|---|
| 119 | 120 | |
|---|
| 120 | 121 | if (!static_branch_likely(&have_neon) || |
|---|
| 121 | | - !may_use_simd()) { |
|---|
| 122 | + !crypto_simd_usable()) { |
|---|
| 122 | 123 | chacha_crypt_generic(state, walk.dst.virt.addr, |
|---|
| 123 | 124 | walk.src.virt.addr, nbytes, |
|---|
| 124 | 125 | ctx->nrounds); |
|---|
| .. | .. |
|---|
| 213 | 214 | |
|---|
| 214 | 215 | static int __init chacha_simd_mod_init(void) |
|---|
| 215 | 216 | { |
|---|
| 216 | | - if (!(elf_hwcap & HWCAP_ASIMD)) |
|---|
| 217 | + if (!cpu_have_named_feature(ASIMD)) |
|---|
| 217 | 218 | return 0; |
|---|
| 218 | 219 | |
|---|
| 219 | 220 | static_branch_enable(&have_neon); |
|---|
| 220 | 221 | |
|---|
| 221 | | - return IS_REACHABLE(CONFIG_CRYPTO_BLKCIPHER) ? |
|---|
| 222 | + return IS_REACHABLE(CONFIG_CRYPTO_SKCIPHER) ? |
|---|
| 222 | 223 | crypto_register_skciphers(algs, ARRAY_SIZE(algs)) : 0; |
|---|
| 223 | 224 | } |
|---|
| 224 | 225 | |
|---|
| 225 | 226 | static void __exit chacha_simd_mod_fini(void) |
|---|
| 226 | 227 | { |
|---|
| 227 | | - if (IS_REACHABLE(CONFIG_CRYPTO_BLKCIPHER) && (elf_hwcap & HWCAP_ASIMD)) |
|---|
| 228 | + if (IS_REACHABLE(CONFIG_CRYPTO_SKCIPHER) && cpu_have_named_feature(ASIMD)) |
|---|
| 228 | 229 | crypto_unregister_skciphers(algs, ARRAY_SIZE(algs)); |
|---|
| 229 | 230 | } |
|---|
| 230 | 231 | |
|---|