at master 1.8 kB view raw
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 15struct simd_skcipher_alg; 16struct skcipher_alg; 17 18struct simd_skcipher_alg *simd_skcipher_create_compat(struct skcipher_alg *ialg, 19 const char *algname, 20 const char *drvname, 21 const char *basename); 22void simd_skcipher_free(struct simd_skcipher_alg *alg); 23 24int simd_register_skciphers_compat(struct skcipher_alg *algs, int count, 25 struct simd_skcipher_alg **simd_algs); 26 27void simd_unregister_skciphers(struct skcipher_alg *algs, int count, 28 struct simd_skcipher_alg **simd_algs); 29 30/* AEAD support */ 31 32struct simd_aead_alg; 33struct aead_alg; 34 35int simd_register_aeads_compat(struct aead_alg *algs, int count, 36 struct simd_aead_alg **simd_algs); 37 38void 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 52DECLARE_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 */