.. | .. |
---|
12 | 12 | #include <crypto/algapi.h> |
---|
13 | 13 | #include <crypto/internal/hash.h> |
---|
14 | 14 | #include <crypto/internal/poly1305.h> |
---|
| 15 | +#include <crypto/internal/simd.h> |
---|
15 | 16 | #include <linux/cpufeature.h> |
---|
16 | 17 | #include <linux/crypto.h> |
---|
17 | 18 | #include <linux/jump_label.h> |
---|
.. | .. |
---|
24 | 25 | |
---|
25 | 26 | static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_neon); |
---|
26 | 27 | |
---|
27 | | -void poly1305_init_arch(struct poly1305_desc_ctx *dctx, const u8 *key) |
---|
| 28 | +void poly1305_init_arch(struct poly1305_desc_ctx *dctx, const u8 key[POLY1305_KEY_SIZE]) |
---|
28 | 29 | { |
---|
29 | 30 | poly1305_init_arm64(&dctx->h, key); |
---|
30 | 31 | dctx->s[0] = get_unaligned_le32(key + 16); |
---|
.. | .. |
---|
51 | 52 | { |
---|
52 | 53 | if (unlikely(!dctx->sset)) { |
---|
53 | 54 | if (!dctx->rset) { |
---|
54 | | - poly1305_init_arch(dctx, src); |
---|
| 55 | + poly1305_init_arm64(&dctx->h, src); |
---|
55 | 56 | src += POLY1305_BLOCK_SIZE; |
---|
56 | 57 | len -= POLY1305_BLOCK_SIZE; |
---|
57 | 58 | dctx->rset = 1; |
---|
.. | .. |
---|
110 | 111 | static int neon_poly1305_update(struct shash_desc *desc, |
---|
111 | 112 | const u8 *src, unsigned int srclen) |
---|
112 | 113 | { |
---|
113 | | - bool do_neon = may_use_simd() && srclen > 128; |
---|
| 114 | + bool do_neon = crypto_simd_usable() && srclen > 128; |
---|
114 | 115 | struct poly1305_desc_ctx *dctx = shash_desc_ctx(desc); |
---|
115 | 116 | |
---|
116 | 117 | if (static_branch_likely(&have_neon) && do_neon) |
---|
.. | .. |
---|
141 | 142 | if (likely(nbytes >= POLY1305_BLOCK_SIZE)) { |
---|
142 | 143 | unsigned int len = round_down(nbytes, POLY1305_BLOCK_SIZE); |
---|
143 | 144 | |
---|
144 | | - if (static_branch_likely(&have_neon) && may_use_simd()) { |
---|
| 145 | + if (static_branch_likely(&have_neon) && crypto_simd_usable()) { |
---|
145 | 146 | do { |
---|
146 | 147 | unsigned int todo = min_t(unsigned int, len, SZ_4K); |
---|
147 | 148 | |
---|
.. | .. |
---|
207 | 208 | |
---|
208 | 209 | static int __init neon_poly1305_mod_init(void) |
---|
209 | 210 | { |
---|
210 | | - if (!(elf_hwcap & HWCAP_ASIMD)) |
---|
| 211 | + if (!cpu_have_named_feature(ASIMD)) |
---|
211 | 212 | return 0; |
---|
212 | 213 | |
---|
213 | 214 | static_branch_enable(&have_neon); |
---|
.. | .. |
---|
218 | 219 | |
---|
219 | 220 | static void __exit neon_poly1305_mod_exit(void) |
---|
220 | 221 | { |
---|
221 | | - if (IS_REACHABLE(CONFIG_CRYPTO_HASH) && (elf_hwcap & HWCAP_ASIMD)) |
---|
| 222 | + if (IS_REACHABLE(CONFIG_CRYPTO_HASH) && cpu_have_named_feature(ASIMD)) |
---|
222 | 223 | crypto_unregister_shash(&neon_poly1305_alg); |
---|
223 | 224 | } |
---|
224 | 225 | |
---|