hc
2024-02-20 e636c8d336489bf3eed5878299e6cc045bbad077
kernel/include/crypto/internal/simd.h
....@@ -6,6 +6,11 @@
66 #ifndef _CRYPTO_INTERNAL_SIMD_H
77 #define _CRYPTO_INTERNAL_SIMD_H
88
9
+#include <linux/percpu.h>
10
+#include <linux/types.h>
11
+
12
+/* skcipher support */
13
+
914 struct simd_skcipher_alg;
1015 struct skcipher_alg;
1116
....@@ -22,4 +27,43 @@
2227 void simd_unregister_skciphers(struct skcipher_alg *algs, int count,
2328 struct simd_skcipher_alg **simd_algs);
2429
30
+/* AEAD support */
31
+
32
+struct simd_aead_alg;
33
+struct aead_alg;
34
+
35
+struct simd_aead_alg *simd_aead_create_compat(const char *algname,
36
+ const char *drvname,
37
+ const char *basename);
38
+struct simd_aead_alg *simd_aead_create(const char *algname,
39
+ const char *basename);
40
+void simd_aead_free(struct simd_aead_alg *alg);
41
+
42
+int simd_register_aeads_compat(struct aead_alg *algs, int count,
43
+ struct simd_aead_alg **simd_algs);
44
+
45
+void simd_unregister_aeads(struct aead_alg *algs, int count,
46
+ struct simd_aead_alg **simd_algs);
47
+
48
+/*
49
+ * crypto_simd_usable() - is it allowed at this time to use SIMD instructions or
50
+ * access the SIMD register file?
51
+ *
52
+ * This delegates to may_use_simd(), except that this also returns false if SIMD
53
+ * in crypto code has been temporarily disabled on this CPU by the crypto
54
+ * self-tests, in order to test the no-SIMD fallback code. This override is
55
+ * currently limited to configurations where the extra self-tests are enabled,
56
+ * because it might be a bit too invasive to be part of the regular self-tests.
57
+ *
58
+ * This is a macro so that <asm/simd.h>, which some architectures don't have,
59
+ * doesn't have to be included directly here.
60
+ */
61
+#ifdef CONFIG_CRYPTO_MANAGER_EXTRA_TESTS
62
+DECLARE_PER_CPU(bool, crypto_simd_disabled_for_test);
63
+#define crypto_simd_usable() \
64
+ (may_use_simd() && !this_cpu_read(crypto_simd_disabled_for_test))
65
+#else
66
+#define crypto_simd_usable() may_use_simd()
67
+#endif
68
+
2569 #endif /* _CRYPTO_INTERNAL_SIMD_H */