| .. | .. |
|---|
| 30 | 30 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
|---|
| 31 | 31 | |
|---|
| 32 | 32 | #include <crypto/internal/hash.h> |
|---|
| 33 | +#include <crypto/internal/simd.h> |
|---|
| 33 | 34 | #include <linux/init.h> |
|---|
| 34 | 35 | #include <linux/module.h> |
|---|
| 35 | 36 | #include <linux/mm.h> |
|---|
| 36 | | -#include <linux/cryptohash.h> |
|---|
| 37 | 37 | #include <linux/types.h> |
|---|
| 38 | 38 | #include <crypto/sha.h> |
|---|
| 39 | 39 | #include <crypto/sha256_base.h> |
|---|
| 40 | | -#include <asm/fpu/api.h> |
|---|
| 41 | 40 | #include <linux/string.h> |
|---|
| 41 | +#include <asm/simd.h> |
|---|
| 42 | 42 | |
|---|
| 43 | 43 | asmlinkage void sha256_transform_ssse3(struct sha256_state *state, |
|---|
| 44 | 44 | const u8 *data, int blocks); |
|---|
| .. | .. |
|---|
| 48 | 48 | { |
|---|
| 49 | 49 | struct sha256_state *sctx = shash_desc_ctx(desc); |
|---|
| 50 | 50 | |
|---|
| 51 | | - if (!irq_fpu_usable() || |
|---|
| 51 | + if (!crypto_simd_usable() || |
|---|
| 52 | 52 | (sctx->count % SHA256_BLOCK_SIZE) + len < SHA256_BLOCK_SIZE) |
|---|
| 53 | 53 | return crypto_sha256_update(desc, data, len); |
|---|
| 54 | 54 | |
|---|
| .. | .. |
|---|
| 68 | 68 | static int sha256_finup(struct shash_desc *desc, const u8 *data, |
|---|
| 69 | 69 | unsigned int len, u8 *out, sha256_block_fn *sha256_xform) |
|---|
| 70 | 70 | { |
|---|
| 71 | | - if (!irq_fpu_usable()) |
|---|
| 71 | + if (!crypto_simd_usable()) |
|---|
| 72 | 72 | return crypto_sha256_finup(desc, data, len, out); |
|---|
| 73 | 73 | |
|---|
| 74 | 74 | kernel_fpu_begin(); |
|---|
| .. | .. |
|---|
| 143 | 143 | ARRAY_SIZE(sha256_ssse3_algs)); |
|---|
| 144 | 144 | } |
|---|
| 145 | 145 | |
|---|
| 146 | | -#ifdef CONFIG_AS_AVX |
|---|
| 147 | 146 | asmlinkage void sha256_transform_avx(struct sha256_state *state, |
|---|
| 148 | 147 | const u8 *data, int blocks); |
|---|
| 149 | 148 | |
|---|
| .. | .. |
|---|
| 220 | 219 | ARRAY_SIZE(sha256_avx_algs)); |
|---|
| 221 | 220 | } |
|---|
| 222 | 221 | |
|---|
| 223 | | -#else |
|---|
| 224 | | -static inline int register_sha256_avx(void) { return 0; } |
|---|
| 225 | | -static inline void unregister_sha256_avx(void) { } |
|---|
| 226 | | -#endif |
|---|
| 227 | | - |
|---|
| 228 | | -#if defined(CONFIG_AS_AVX2) && defined(CONFIG_AS_AVX) |
|---|
| 229 | 222 | asmlinkage void sha256_transform_rorx(struct sha256_state *state, |
|---|
| 230 | 223 | const u8 *data, int blocks); |
|---|
| 231 | 224 | |
|---|
| .. | .. |
|---|
| 299 | 292 | crypto_unregister_shashes(sha256_avx2_algs, |
|---|
| 300 | 293 | ARRAY_SIZE(sha256_avx2_algs)); |
|---|
| 301 | 294 | } |
|---|
| 302 | | - |
|---|
| 303 | | -#else |
|---|
| 304 | | -static inline int register_sha256_avx2(void) { return 0; } |
|---|
| 305 | | -static inline void unregister_sha256_avx2(void) { } |
|---|
| 306 | | -#endif |
|---|
| 307 | 295 | |
|---|
| 308 | 296 | #ifdef CONFIG_AS_SHA256_NI |
|---|
| 309 | 297 | asmlinkage void sha256_ni_transform(struct sha256_state *digest, |
|---|