Make crypto/internal/simd.h resilient
Subsystems (6)
Herbert Xu
maintainercover Make crypto/internal/simd.h resilient
If you include crypto/internal/simd.h without asm/simd.h the build may fail because may_use_simd isn't defined. Fix this by including asm/simd.h in crypto/internal/simd.h.
It turns out that there is a generic simd.h, it just couldn't be included twice. Thiat patch series fixes this problem.
Herbert Xu (4):
asm-generic: Make simd.h more resilient
arm: Make simd.h more resilient
x86: Make simd.h more resilient
crypto: simd - Include asm/simd.h in internal/simd.h
arch/arm/include/asm/simd.h | 8 +++++++- arch/x86/include/asm/simd.h | 6 ++++++ include/asm-generic/simd.h | 8 +++++++- include/crypto/internal/simd.h | 4 +--- 4 files changed, 21 insertions(+), 5 deletions(-)
Signature · 1 line
2.39.5
Herbert Xu
maintainerPATCH 1/4 asm-generic: Make simd.h more resilient
Add missing header inclusions and protect against double inclusion.
--- include/asm-generic/simd.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
include/asm-generic/simd.h +7 -1
@@ -1,6 +1,10 @@/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_GENERIC_SIMD_H +#define _ASM_GENERIC_SIMD_H -#include <linux/hardirq.h> +#include <linux/compiler_attributes.h> +#include <linux/preempt.h> +#include <linux/types.h> /* * may_use_simd - whether it is allowable at this time to issue SIMD
@@ -13,3 +17,5 @@ static __must_check inline bool may_use_simd(void) {return !in_interrupt (); } + +#endif /* _ASM_GENERIC_SIMD_H */
Signature · 1 line
2.39.5
Re: [PATCH 1/4] asm-generic: Make simd.h more resilient
Quoted 24 lines · Herbert Xu
Add missing header inclusions and protect against double inclusion.
Signed-off-by Herbert Xu <[email protected]>--- include/asm-generic/simd.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)include/asm-generic/simd.h +5
-1@@ -1,6 +1,10 @@/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_GENERIC_SIMD_H +#define _ASM_GENERIC_SIMD_H -#include <linux/hardirq.h> +#include <linux/compiler_attributes.h> +#include <linux/preempt.h> +#include <linux/types.h> /* * may_use_simd - whether it is allowable at this time to issue SIMD
include/asm-generic/simd.h static __must_check inline bool may_use_simd(void) · line 21
Quoted 5 lines
include/asm-generic/simd.h +2
-0@@ -13,3 +17,5 @@ static __must_check inline bool may_use_simd(void) {return !in_interrupt (); } + +#endif /* _ASM_GENERIC_SIMD_H */
This patch broke the powerpc build:
../arch/powerpc/lib/crc32-glue.c: In function 'crc32c_arch':../arch/powerpc/lib/crc32-glue.c:44:17: error: implicit declaration of function 'pagefault_disable'; did you mean 'preempt_disable'? [-Wimplicit-function-declaration]
44 | pagefault_disable();
| ^~~~~~~~~~~~~~~~~
| preempt_disable
../arch/powerpc/lib/crc-t10dif-glue.c: In function 'crc_t10dif_arch':
../arch/powerpc/lib/crc-t10dif-glue.c:48:17: error: implicit declaration of function 'pagefault_disable'; did you mean 'preempt_disable'? [-Wimplicit-function-declaration]
48 | pagefault_disable();
| ^~~~~~~~~~~~~~~~~
| preempt_disable
../arch/powerpc/lib/crc32-glue.c:48:17: error: implicit declaration of function 'pagefault_enable'; did you mean 'preempt_enable'? [-Wimplicit-function-declaration]
48 | pagefault_enable();
| ^~~~~~~~~~~~~~~~
| preempt_enable
../arch/powerpc/lib/crc-t10dif-glue.c:52:17: error: implicit declaration of function 'pagefault_enable'; did you mean 'preempt_enable'? [-Wimplicit-function-declaration]
52 | pagefault_enable();
| ^~~~~~~~~~~~~~~~
| preempt_enableHerbert Xu
maintainerPATCH 1/1 powerpc/crc: Include uaccess.h and others
Quoted 6 lines · Eric Biggers
This patch broke the powerpc build:
../arch/powerpc/lib/crc32-glue.c: In function 'crc32c_arch':../arch/powerpc/lib/crc32-glue.c:44:17: error: implicit declaration of function 'pagefault_disable'; did you mean 'preempt_disable'? [-Wimplicit-function-declaration]
44 |pagefault_disable();
Sorry, I should've done a grep for asm/simd.h.
---8<---
The powerpc crc code was relying on pagefault_disable from being pulled in by random header files.
Fix this by explicitly including uaccess.h. Also add other missing header files to prevent similar problems in future.
arch/powerpc/lib/crc-t10dif-glue.c +8 -8
@@ -6,15 +6,15 @@* [based on crc32c-vpmsum_glue.c] */ -#include <linux/crc-t10dif.h> -#include <crypto/internal/simd.h> -#include <linux/init.h> -#include <linux/module.h> -#include <linux/string.h> -#include <linux/kernel.h> -#include <linux/cpufeature.h> -#include <asm/simd.h> #include <asm/switch_to.h> +#include <crypto/internal/simd.h> +#include <linux/cpufeature.h> +#include <linux/crc-t10dif.h> +#include <linux/jump_label.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/preempt.h> +#include <linux/uaccess.h> #define VMX_ALIGN 16#define VMX_ALIGN_MASK (VMX_ALIGN-1)
arch/powerpc/lib/crc32-glue.c +8 -7
@@ -1,12 +1,13 @@// SPDX-License-Identifier: GPL-2.0-only -#include <linux/crc32.h> -#include <crypto/internal/simd.h> -#include <linux/init.h> -#include <linux/module.h> -#include <linux/kernel.h> -#include <linux/cpufeature.h> -#include <asm/simd.h> #include <asm/switch_to.h> +#include <crypto/internal/simd.h> +#include <linux/cpufeature.h> +#include <linux/crc32.h> +#include <linux/jump_label.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/preempt.h> +#include <linux/uaccess.h> #define VMX_ALIGN 16#define VMX_ALIGN_MASK (VMX_ALIGN-1)
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Herbert Xu
maintainerPATCH 2/4 arm: Make simd.h more resilient
In reply to Herbert XuAdd missing header inclusions and protect against double inclusion.
--- arch/arm/include/asm/simd.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
arch/arm/include/asm/simd.h +7 -1
@@ -1,8 +1,14 @@/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_SIMD_H +#define _ASM_SIMD_H -#include <linux/hardirq.h> +#include <linux/compiler_attributes.h> +#include <linux/preempt.h> +#include <linux/types.h> static __must_check inline bool may_use_simd (void ) {return IS_ENABLED (CONFIG_KERNEL_MODE_NEON ) && !in_hardirq (); } + +#endif /* _ASM_SIMD_H */
Signature · 1 line
2.39.5
Herbert Xu
maintainerPATCH 3/4 x86: Make simd.h more resilient
In reply to Herbert XuAdd missing header inclusions and protect against double inclusion.
--- arch/x86/include/asm/simd.h | 6 ++++++ 1 file changed, 6 insertions(+)
arch/x86/include/asm/simd.h +6 -0
@@ -1,6 +1,10 @@/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_SIMD_H +#define _ASM_SIMD_H#include <asm/fpu/api.h> +#include <linux/compiler_attributes.h> +#include <linux/types.h> /* * may_use_simd - whether it is allowable at this time to issue SIMD
@@ -10,3 +14,5 @@ static __must_check inline bool may_use_simd(void) {return irq_fpu_usable (); } + +#endif /* _ASM_SIMD_H */
Signature · 1 line
2.39.5
Herbert Xu
maintainerPATCH 4/4 crypto: simd - Include asm/simd.h in internal/simd.h
In reply to Herbert XuNow that the asm/simd.h files have been made safe against double inclusion, include it directly in internal/simd.h.
--- include/crypto/internal/simd.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
include/crypto/internal/simd.h +1 -3
@@ -6,6 +6,7 @@#ifndef _CRYPTO_INTERNAL_SIMD_H#define _CRYPTO_INTERNAL_SIMD_H +#include <asm/simd.h> #include <linux/percpu.h> #include <linux/types.h>
@@ -46,9 +47,6 @@ void simd_unregister_aeads(struct aead_alg *algs, int count,* self-tests, in order to test the no-SIMD fallback code. This override is * currently limited to configurations where the extra self-tests are enabled, * because it might be a bit too invasive to be part of the regular self-tests. -* -* This is a macro so that <asm/simd.h>, which some architectures don't have, -* doesn't have to be included directly here. */ #ifdef CONFIG_CRYPTO_MANAGER_EXTRA_TESTS DECLARE_PER_CPU (bool, crypto_simd_disabled_for_test);
Signature · 1 line
2.39.5