| .. | .. |
|---|
| 28 | 28 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
|---|
| 29 | 29 | |
|---|
| 30 | 30 | #include <crypto/internal/hash.h> |
|---|
| 31 | +#include <crypto/internal/simd.h> |
|---|
| 31 | 32 | #include <linux/init.h> |
|---|
| 32 | 33 | #include <linux/module.h> |
|---|
| 33 | 34 | #include <linux/mm.h> |
|---|
| 34 | | -#include <linux/cryptohash.h> |
|---|
| 35 | +#include <linux/string.h> |
|---|
| 35 | 36 | #include <linux/types.h> |
|---|
| 36 | 37 | #include <crypto/sha.h> |
|---|
| 37 | 38 | #include <crypto/sha512_base.h> |
|---|
| 38 | | -#include <asm/fpu/api.h> |
|---|
| 39 | | - |
|---|
| 40 | | -#include <linux/string.h> |
|---|
| 39 | +#include <asm/simd.h> |
|---|
| 41 | 40 | |
|---|
| 42 | 41 | asmlinkage void sha512_transform_ssse3(struct sha512_state *state, |
|---|
| 43 | 42 | const u8 *data, int blocks); |
|---|
| .. | .. |
|---|
| 47 | 46 | { |
|---|
| 48 | 47 | struct sha512_state *sctx = shash_desc_ctx(desc); |
|---|
| 49 | 48 | |
|---|
| 50 | | - if (!irq_fpu_usable() || |
|---|
| 49 | + if (!crypto_simd_usable() || |
|---|
| 51 | 50 | (sctx->count[0] % SHA512_BLOCK_SIZE) + len < SHA512_BLOCK_SIZE) |
|---|
| 52 | 51 | return crypto_sha512_update(desc, data, len); |
|---|
| 53 | 52 | |
|---|
| .. | .. |
|---|
| 67 | 66 | static int sha512_finup(struct shash_desc *desc, const u8 *data, |
|---|
| 68 | 67 | unsigned int len, u8 *out, sha512_block_fn *sha512_xform) |
|---|
| 69 | 68 | { |
|---|
| 70 | | - if (!irq_fpu_usable()) |
|---|
| 69 | + if (!crypto_simd_usable()) |
|---|
| 71 | 70 | return crypto_sha512_finup(desc, data, len, out); |
|---|
| 72 | 71 | |
|---|
| 73 | 72 | kernel_fpu_begin(); |
|---|
| .. | .. |
|---|
| 142 | 141 | ARRAY_SIZE(sha512_ssse3_algs)); |
|---|
| 143 | 142 | } |
|---|
| 144 | 143 | |
|---|
| 145 | | -#ifdef CONFIG_AS_AVX |
|---|
| 146 | 144 | asmlinkage void sha512_transform_avx(struct sha512_state *state, |
|---|
| 147 | 145 | const u8 *data, int blocks); |
|---|
| 148 | 146 | static bool avx_usable(void) |
|---|
| .. | .. |
|---|
| 218 | 216 | crypto_unregister_shashes(sha512_avx_algs, |
|---|
| 219 | 217 | ARRAY_SIZE(sha512_avx_algs)); |
|---|
| 220 | 218 | } |
|---|
| 221 | | -#else |
|---|
| 222 | | -static inline int register_sha512_avx(void) { return 0; } |
|---|
| 223 | | -static inline void unregister_sha512_avx(void) { } |
|---|
| 224 | | -#endif |
|---|
| 225 | 219 | |
|---|
| 226 | | -#if defined(CONFIG_AS_AVX2) && defined(CONFIG_AS_AVX) |
|---|
| 227 | 220 | asmlinkage void sha512_transform_rorx(struct sha512_state *state, |
|---|
| 228 | 221 | const u8 *data, int blocks); |
|---|
| 229 | 222 | |
|---|
| .. | .. |
|---|
| 298 | 291 | crypto_unregister_shashes(sha512_avx2_algs, |
|---|
| 299 | 292 | ARRAY_SIZE(sha512_avx2_algs)); |
|---|
| 300 | 293 | } |
|---|
| 301 | | -#else |
|---|
| 302 | | -static inline int register_sha512_avx2(void) { return 0; } |
|---|
| 303 | | -static inline void unregister_sha512_avx2(void) { } |
|---|
| 304 | | -#endif |
|---|
| 305 | 294 | |
|---|
| 306 | 295 | static int __init sha512_ssse3_mod_init(void) |
|---|
| 307 | 296 | { |
|---|