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 struct simd_aead_alg; 14 struct aead_alg; 15 16 int simd_register_aeads_compat(struct aead_alg *algs, int count, 17 struct simd_aead_alg **simd_algs); 18 19 void simd_unregister_aeads(struct aead_alg *algs, int count, 20 struct simd_aead_alg **simd_algs); 21 22 /* 23 * crypto_simd_usable() - is it allowed at this time to use SIMD instructions or 24 * access the SIMD register file? 25 * 26 * This delegates to may_use_simd(), except that this also returns false if SIMD 27 * in crypto code has been temporarily disabled on this CPU by the crypto 28 * self-tests, in order to test the no-SIMD fallback code. This override is 29 * currently limited to configurations where the "full" self-tests are enabled, 30 * because it might be a bit too invasive to be part of the "fast" self-tests. 31 */ 32 #ifdef CONFIG_CRYPTO_SELFTESTS_FULL 33 DECLARE_PER_CPU(bool, crypto_simd_disabled_for_test); 34 #define crypto_simd_usable() \ 35 (may_use_simd() && !this_cpu_read(crypto_simd_disabled_for_test)) 36 #else 37 #define crypto_simd_usable() may_use_simd() 38 #endif 39 40 #endif /* _CRYPTO_INTERNAL_SIMD_H */ 41