hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/arch/x86/crypto/sha1_ssse3_glue.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Cryptographic API.
34 *
....@@ -11,32 +12,26 @@
1112 * Copyright (c) Jean-Francois Dive <jef@linuxbe.org>
1213 * Copyright (c) Mathias Krause <minipli@googlemail.com>
1314 * Copyright (c) Chandramouli Narayanan <mouli@linux.intel.com>
14
- *
15
- * This program is free software; you can redistribute it and/or modify it
16
- * under the terms of the GNU General Public License as published by the Free
17
- * Software Foundation; either version 2 of the License, or (at your option)
18
- * any later version.
19
- *
2015 */
2116
2217 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
2318
2419 #include <crypto/internal/hash.h>
20
+#include <crypto/internal/simd.h>
2521 #include <linux/init.h>
2622 #include <linux/module.h>
2723 #include <linux/mm.h>
28
-#include <linux/cryptohash.h>
2924 #include <linux/types.h>
3025 #include <crypto/sha.h>
3126 #include <crypto/sha1_base.h>
32
-#include <asm/fpu/api.h>
27
+#include <asm/simd.h>
3328
3429 static int sha1_update(struct shash_desc *desc, const u8 *data,
3530 unsigned int len, sha1_block_fn *sha1_xform)
3631 {
3732 struct sha1_state *sctx = shash_desc_ctx(desc);
3833
39
- if (!irq_fpu_usable() ||
34
+ if (!crypto_simd_usable() ||
4035 (sctx->count % SHA1_BLOCK_SIZE) + len < SHA1_BLOCK_SIZE)
4136 return crypto_sha1_update(desc, data, len);
4237
....@@ -56,7 +51,7 @@
5651 static int sha1_finup(struct shash_desc *desc, const u8 *data,
5752 unsigned int len, u8 *out, sha1_block_fn *sha1_xform)
5853 {
59
- if (!irq_fpu_usable())
54
+ if (!crypto_simd_usable())
6055 return crypto_sha1_finup(desc, data, len, out);
6156
6257 kernel_fpu_begin();
....@@ -118,7 +113,6 @@
118113 crypto_unregister_shash(&sha1_ssse3_alg);
119114 }
120115
121
-#ifdef CONFIG_AS_AVX
122116 asmlinkage void sha1_transform_avx(struct sha1_state *state,
123117 const u8 *data, int blocks);
124118
....@@ -179,13 +173,6 @@
179173 crypto_unregister_shash(&sha1_avx_alg);
180174 }
181175
182
-#else /* CONFIG_AS_AVX */
183
-static inline int register_sha1_avx(void) { return 0; }
184
-static inline void unregister_sha1_avx(void) { }
185
-#endif /* CONFIG_AS_AVX */
186
-
187
-
188
-#if defined(CONFIG_AS_AVX2) && (CONFIG_AS_AVX)
189176 #define SHA1_AVX2_BLOCK_OPTSIZE 4 /* optimal 4*64 bytes of SHA1 blocks */
190177
191178 asmlinkage void sha1_transform_avx2(struct sha1_state *state,
....@@ -256,11 +243,6 @@
256243 if (avx2_usable())
257244 crypto_unregister_shash(&sha1_avx2_alg);
258245 }
259
-
260
-#else
261
-static inline int register_sha1_avx2(void) { return 0; }
262
-static inline void unregister_sha1_avx2(void) { }
263
-#endif
264246
265247 #ifdef CONFIG_AS_SHA1_NI
266248 asmlinkage void sha1_ni_transform(struct sha1_state *digest, const u8 *data,