Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/include/crypto/internal/simd.h
26292 views
1
/* SPDX-License-Identifier: GPL-2.0 */
2
/*
3
* Shared crypto simd helpers
4
*/
5
6
#ifndef _CRYPTO_INTERNAL_SIMD_H
7
#define _CRYPTO_INTERNAL_SIMD_H
8
9
#include <asm/simd.h>
10
#include <linux/percpu.h>
11
#include <linux/types.h>
12
13
/* skcipher support */
14
15
struct simd_skcipher_alg;
16
struct skcipher_alg;
17
18
struct simd_skcipher_alg *simd_skcipher_create_compat(struct skcipher_alg *ialg,
19
const char *algname,
20
const char *drvname,
21
const char *basename);
22
void simd_skcipher_free(struct simd_skcipher_alg *alg);
23
24
int simd_register_skciphers_compat(struct skcipher_alg *algs, int count,
25
struct simd_skcipher_alg **simd_algs);
26
27
void simd_unregister_skciphers(struct skcipher_alg *algs, int count,
28
struct simd_skcipher_alg **simd_algs);
29
30
/* AEAD support */
31
32
struct simd_aead_alg;
33
struct aead_alg;
34
35
int simd_register_aeads_compat(struct aead_alg *algs, int count,
36
struct simd_aead_alg **simd_algs);
37
38
void simd_unregister_aeads(struct aead_alg *algs, int count,
39
struct simd_aead_alg **simd_algs);
40
41
/*
42
* crypto_simd_usable() - is it allowed at this time to use SIMD instructions or
43
* access the SIMD register file?
44
*
45
* This delegates to may_use_simd(), except that this also returns false if SIMD
46
* in crypto code has been temporarily disabled on this CPU by the crypto
47
* self-tests, in order to test the no-SIMD fallback code. This override is
48
* currently limited to configurations where the "full" self-tests are enabled,
49
* because it might be a bit too invasive to be part of the "fast" self-tests.
50
*/
51
#ifdef CONFIG_CRYPTO_SELFTESTS_FULL
52
DECLARE_PER_CPU(bool, crypto_simd_disabled_for_test);
53
#define crypto_simd_usable() \
54
(may_use_simd() && !this_cpu_read(crypto_simd_disabled_for_test))
55
#else
56
#define crypto_simd_usable() may_use_simd()
57
#endif
58
59
#endif /* _CRYPTO_INTERNAL_SIMD_H */
60
61