crypto: arm: workaround for building with old binutils
Subsystems (2)
PATCH 1/1 crypto: arm: workaround for building with old binutils
Old versions of binutils (before 2.23) do not yet understand the crypto-neon-fp-armv8 fpu instructions, and an attempt to build these files results in a build failure:
arch/arm/crypto/aes-ce-core.S:133: Error: selected processor does not support ARM mode vld1.8 {q10-q11},[ip]!' arch/arm/crypto/aes-ce-core.S:133: Error: bad instruction aese.8 q0,q8' arch/arm/crypto/aes-ce-core.S:133: Error: bad instruction aesmc.8 q0,q0' arch/arm/crypto/aes-ce-core.S:133: Error: bad instruction aese.8 q0,q9' arch/arm/crypto/aes-ce-core.S:133: Error: bad instruction `aesmc.8 q0,q0'
Since the affected versions are still in widespread use, and this breaks 'allmodconfig' builds, we should try to at least get a successful kernel build. Unfortunately, I could not come up with a way to make the Kconfig symbol depend on the binutils version, which would be the nicest solution.
This patch uses the 'as-option' Kbuild macro to find out whether the support is present in the assembler, and otherwise passes a macro definition to each affected file, which in turn disables that code entirely and results in empty modules.
In order to help users figure out what to do, we also add a #warning state in place of the removed to that tells users which version to use.
arch/arm/crypto/Makefile +4 -0
@@ -25,6 +25,10 @@ sha2-arm-ce-y := sha2-ce-core.o sha2-ce-glue.o aes-arm-ce-y := aes-ce-core.o aes-ce-glue.o ghash-arm-ce-y := ghash-ce-core.o ghash-ce-glue.o +armv8-ce-flags := $(call as-option,-Wa$(comma)-mfpu=crypto-neon-fp-armv8,-DARMV8_CE_DISABLED) +asflags-y := $(armv8-ce-flags) +ccflags-y := $(armv8-ce-flags) + quiet_cmd_perl = PERL $@ cmd_perl = $(PERL) $(<) > $(@)
arch/arm/crypto/aes-ce-core.S +6 -1
@@ -8,11 +8,14 @@ * published by the Free Software Foundation. */ +#ifdef ARMV8_CE_DISABLED +#warning ARMv8 Crypto Extensions need binutils 2.23 or higher +#else + #include <linux/linkage.h> #include <asm/assembler.h> .text - .fpu crypto-neon-fp-armv8 .align 3 .macro enc_round, state, key
@@ -516,3 +519,5 @@ ENTRY(ce_aes_invert) vst1.8 {q0}, [r0] bx lr ENDPROC(ce_aes_invert) + +#endif
arch/arm/crypto/aes-ce-glue.c +4 -1
@@ -510,13 +510,16 @@ static struct crypto_alg aes_algs[] = { {static int __init aes_init (void ) { -if (!(elf_hwcap2 &HWCAP2_AES )) +if (IS_ENABLED (ARMV8_CE_DISABLED ) || !(elf_hwcap2 &HWCAP2_AES ))return -ENODEV ;return crypto_register_algs (aes_algs,ARRAY_SIZE (aes_algs)); } static void __exit aes_exit(void) { +if (IS_ENABLED (ARMV8_CE_DISABLED )) +return ; +crypto_unregister_algs (aes_algs,ARRAY_SIZE (aes_algs)); }
arch/arm/crypto/ghash-ce-core.S +6 -2
@@ -8,6 +8,10 @@ * by the Free Software Foundation. */ +#ifdef ARMV8_CE_DISABLED +#warning ARMv8 Crypto Extensions need binutils 2.23 or higher +#else + #include <linux/linkage.h> #include <asm/assembler.h>
@@ -33,8 +37,6 @@ XH_L .req d14 .text - .fpu crypto-neon-fp-armv8 - /* * void pmull_ghash_update(int blocks, u64 dg[], const char *src, * struct ghash_key const *k, const char *head)
@@ -92,3 +94,5 @@ ENTRY(pmull_ghash_update) vst1.64 {XL}, [r1] bx lr ENDPROC(pmull_ghash_update) + +#endif
arch/arm/crypto/ghash-ce-glue.c +4 -1
@@ -293,7 +293,7 @@ static int __init ghash_ce_mod_init(void) {int err; -if (!(elf_hwcap2 &HWCAP2_PMULL )) +if (IS_ENABLED (ARMV8_CE_DISABLED ) || !(elf_hwcap2 &HWCAP2_AES ))return -ENODEV ; err =crypto_register_shash (&ghash_alg);
@@ -312,6 +312,9 @@ err_shash: static void __exit ghash_ce_mod_exit(void) { +if (IS_ENABLED (ARMV8_CE_DISABLED )) +return ; +crypto_unregister_ahash (&ghash_async_alg);crypto_unregister_shash (&ghash_alg); }
arch/arm/crypto/sha1-ce-core.S +6 -1
@@ -9,11 +9,14 @@ * published by the Free Software Foundation. */ +#ifdef ARMV8_CE_DISABLED +#warning ARMv8 Crypto Extensions need binutils 2.23 or higher +#else + #include <linux/linkage.h> #include <asm/assembler.h> .text - .fpu crypto-neon-fp-armv8 k0 .req q0 k1 .req q1
@@ -132,3 +135,5 @@ ENTRY(sha1_ce_transform) vstr dgbs, [r2, #16] bx lr ENDPROC(sha1_ce_transform) + +#endif
arch/arm/crypto/sha1-ce-glue.c +4 -1
@@ -136,13 +136,16 @@ static struct shash_alg alg = {static int __init sha1_ce_mod_init (void ) { -if (!(elf_hwcap2 &HWCAP2_SHA1 )) +if (IS_ENABLED (ARMV8_CE_DISABLED ) || !(elf_hwcap2 &HWCAP2_AES ))return -ENODEV ;return crypto_register_shash (&alg); } static void __exit sha1_ce_mod_fini(void) { +if (IS_ENABLED (ARMV8_CE_DISABLED )) +return ; +crypto_unregister_shash (&alg); }
arch/arm/crypto/sha2-ce-core.S +6 -1
@@ -9,11 +9,14 @@ * published by the Free Software Foundation. */ +#ifdef ARMV8_CE_DISABLED +#warning ARMv8 Crypto Extensions need binutils 2.23 or higher +#else + #include <linux/linkage.h> #include <asm/assembler.h> .text - .fpu crypto-neon-fp-armv8 k0 .req q7 k1 .req q8
@@ -132,3 +135,5 @@ ENTRY(sha2_ce_transform) vst1.32 {dga-dgb}, [r2] bx lr ENDPROC(sha2_ce_transform) + +#endif
arch/arm/crypto/sha2-ce-glue.c +4 -1
@@ -189,13 +189,16 @@ static struct shash_alg algs[] = { {static int __init sha2_ce_mod_init (void ) { -if (!(elf_hwcap2 &HWCAP2_SHA2 )) +if (IS_ENABLED (ARMV8_CE_DISABLED ) || !(elf_hwcap2 &HWCAP2_AES ))return -ENODEV ;return crypto_register_shashes (algs,ARRAY_SIZE (algs)); } static void __exit sha2_ce_mod_fini(void) { +if (IS_ENABLED (ARMV8_CE_DISABLED )) +return ; +crypto_unregister_shashes (algs,ARRAY_SIZE (algs)); }
Quoted 32 lines · Arnd Bergmann
Old versions of binutils (before 2.23) do not yet understand the crypto-neon-fp-armv8 fpu instructions, and an attempt to build these files results in a build failure:
arch/arm/crypto/aes-ce-core.S:133: Error: selected processor does not support ARM modevld1.8 {q10-q11},[ip]!' arch/arm/crypto/aes-ce-core.S:133: Error: bad instructionaese.8 q0,q8'arch/arm/crypto/aes-ce-core.S:133: Error: bad instructionaesmc.8 q0,q0' arch/arm/crypto/aes-ce-core.S:133: Error: bad instructionaese.8 q0,q9'arch/arm/crypto/aes-ce-core.S:133: Error: bad instruction `aesmc.8 q0,q0'Since the affected versions are still in widespread use, and this breaks 'allmodconfig' builds, we should try to at least get a successful kernel build. Unfortunately, I could not come up with a way to make the
Kconfigsymbol depend on the binutils version, which would be the nicest solution.This patch uses the 'as-option'
Kbuildmacro to find out whether the support is present in the assembler, and otherwise passes a macro definition to each affected file, which in turn disables that code entirely and results in empty modules.In order to help users figure out what to do, we also add a #warning state in place of the removed to that tells users which version to use.
Signed-off-by Arnd Bergmann <[email protected]>Fixes 864cbeed4ab22d ("crypto: arm - add support for SHA1 using ARMv8 Crypto Instructions")arch/arm/crypto/Makefile +0
-0
arch/arm/crypto/Makefile sha2-arm-ce-y := sha2-ce-core.o sha2-ce-glue.o · line 31
Quoted 7 lines
arch/arm/crypto/Makefile +4
-0@@ -25,6 +25,10 @@ sha2-arm-ce-y := sha2-ce-core.o sha2-ce-glue.o aes-arm-ce-y := aes-ce-core.o aes-ce-glue.o ghash-arm-ce-y := ghash-ce-core.o ghash-ce-glue.o +armv8-ce-flags := $(call as-option,-Wa$(comma)-mfpu=crypto-neon-fp-armv8,-DARMV8_CE_DISABLED) +asflags-y := $(armv8-ce-flags) +ccflags-y := $(armv8-ce-flags) +
Could you perhaps put the rules that build these modules inside a
ifneq ($(armv8-ce-flags),-DARMV8_CE_DISABLED)
...
endif
block?
Quoted 206 lines
arch/arm/crypto/Makefile +0
-0quiet_cmd_perl = PERL $@ cmd_perl = $(PERL) $(<) > $(@)arch/arm/crypto/aes-ce-core.S +6
-1@@ -8,11 +8,14 @@ * published by the Free Software Foundation. */ +#ifdef ARMV8_CE_DISABLED +#warning ARMv8 Crypto Extensions need binutils 2.23 or higher +#else + #include <linux/linkage.h> #include <asm/assembler.h> .text - .fpu crypto-neon-fp-armv8 .align 3 .macro enc_round, state, key@@ -516,3 +519,5 @@ ENTRY(ce_aes_invert) vst1.8 {q0}, [r0] bx lr ENDPROC(ce_aes_invert) + +#endifarch/arm/crypto/aes-ce-glue.c +4
-1@@ -510,13 +510,16 @@ static struct crypto_alg aes_algs[] = { {static int __init aes_init (void ) { -if (!(elf_hwcap2 &HWCAP2_AES )) +if (IS_ENABLED (ARMV8_CE_DISABLED ) || !(elf_hwcap2 &HWCAP2_AES ))return -ENODEV ;return crypto_register_algs (aes_algs,ARRAY_SIZE (aes_algs)); } static void __exit aes_exit(void) { +if (IS_ENABLED (ARMV8_CE_DISABLED )) +return ; +crypto_unregister_algs (aes_algs,ARRAY_SIZE (aes_algs)); }arch/arm/crypto/ghash-ce-core.S +6
-2@@ -8,6 +8,10 @@ * by the Free Software Foundation. */ +#ifdef ARMV8_CE_DISABLED +#warning ARMv8 Crypto Extensions need binutils 2.23 or higher +#else + #include <linux/linkage.h> #include <asm/assembler.h>@@ -33,8 +37,6 @@ XH_L .req d14 .text - .fpu crypto-neon-fp-armv8 - /* * void pmull_ghash_update(int blocks, u64 dg[], const char *src, * struct ghash_key const *k, const char *head)@@ -92,3 +94,5 @@ ENTRY(pmull_ghash_update) vst1.64 {XL}, [r1] bx lr ENDPROC(pmull_ghash_update) + +#endifarch/arm/crypto/ghash-ce-glue.c +4
-1@@ -293,7 +293,7 @@ static int __init ghash_ce_mod_init(void) {int err; -if (!(elf_hwcap2 &HWCAP2_PMULL )) +if (IS_ENABLED (ARMV8_CE_DISABLED ) || !(elf_hwcap2 &HWCAP2_AES ))return -ENODEV ; err =crypto_register_shash (&ghash_alg);@@ -312,6 +312,9 @@ err_shash: static void __exit ghash_ce_mod_exit(void) { +if (IS_ENABLED (ARMV8_CE_DISABLED )) +return ; +crypto_unregister_ahash (&ghash_async_alg);crypto_unregister_shash (&ghash_alg); }arch/arm/crypto/sha1-ce-core.S +6
-1@@ -9,11 +9,14 @@ * published by the Free Software Foundation. */ +#ifdef ARMV8_CE_DISABLED +#warning ARMv8 Crypto Extensions need binutils 2.23 or higher +#else + #include <linux/linkage.h> #include <asm/assembler.h> .text - .fpu crypto-neon-fp-armv8 k0 .req q0 k1 .req q1@@ -132,3 +135,5 @@ ENTRY(sha1_ce_transform) vstr dgbs, [r2, #16] bx lr ENDPROC(sha1_ce_transform) + +#endifarch/arm/crypto/sha1-ce-glue.c +4
-1@@ -136,13 +136,16 @@ static struct shash_alg alg = {static int __init sha1_ce_mod_init (void ) { -if (!(elf_hwcap2 &HWCAP2_SHA1 )) +if (IS_ENABLED (ARMV8_CE_DISABLED ) || !(elf_hwcap2 &HWCAP2_AES ))return -ENODEV ;return crypto_register_shash (&alg); } static void __exit sha1_ce_mod_fini(void) { +if (IS_ENABLED (ARMV8_CE_DISABLED )) +return ; +crypto_unregister_shash (&alg); }arch/arm/crypto/sha2-ce-core.S +6
-1@@ -9,11 +9,14 @@ * published by the Free Software Foundation. */ +#ifdef ARMV8_CE_DISABLED +#warning ARMv8 Crypto Extensions need binutils 2.23 or higher +#else + #include <linux/linkage.h> #include <asm/assembler.h> .text - .fpu crypto-neon-fp-armv8 k0 .req q7 k1 .req q8@@ -132,3 +135,5 @@ ENTRY(sha2_ce_transform) vst1.32 {dga-dgb}, [r2] bx lr ENDPROC(sha2_ce_transform) + +#endifarch/arm/crypto/sha2-ce-glue.c +4
-1@@ -189,13 +189,16 @@ static struct shash_alg algs[] = { {static int __init sha2_ce_mod_init (void ) { -if (!(elf_hwcap2 &HWCAP2_SHA2 )) +if (IS_ENABLED (ARMV8_CE_DISABLED ) || !(elf_hwcap2 &HWCAP2_AES ))return -ENODEV ;return crypto_register_shashes (algs,ARRAY_SIZE (algs)); } static void __exit sha2_ce_mod_fini(void) { +if (IS_ENABLED (ARMV8_CE_DISABLED )) +return ; +crypto_unregister_shashes (algs,ARRAY_SIZE (algs)); }_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 6 lines · On Saturday 11 April 2015 09:41:08 Ard Biesheuvel wrote:
Could you perhaps put the rules that build these modules inside a
ifneq ($(armv8-ce-flags),-DARMV8_CE_DISABLED)
...
endif
How about something like this:
ifeq ($(call as-option,-Wa$(comma)-mfpu=crypto-neon-fp-armv8),) $(warning ARMv8 Crypto Extensions need binutils 2.23 or higher) else
...
endif
That would basically be a reimplementation of the missing "as-option-yn" macro though, so we could also add that instead and do
ifeq ($(call as-option-yn,-Wa$(comma)-mfpu=crypto-neon-fp-armv8),y) $(warning ARMv8 Crypto Extensions need binutils 2.23 or higher) else
...
endif
Arnd
Quoted 18 lines · Arnd Bergmann
Quoted 7 lines · On Saturday 11 April 2015 09:41:08 Ard Biesheuvel wrote:
Could you perhaps put the rules that build these modules inside a
ifneq ($(armv8-ce-flags),-DARMV8_CE_DISABLED)
...
endifHow about something like this:
ifeq ($(call as-option,-Wa$(comma)-mfpu=crypto-neon-fp-armv8),) $(warning ARMv8 Crypto Extensions need binutils 2.23 or higher) else
...
endif
Quoted 9 lines
That would basically be a reimplementation of the missing "as-option-yn" macro though, so we could also add that instead and do
ifeq ($(call as-option-yn,-Wa$(comma)-mfpu=crypto-neon-fp-armv8),y) $(warning ARMv8 Crypto Extensions need binutils 2.23 or higher) else
...
endif
Yes, that should work. Could we also move the CE objs to ce-obj-$() and put
ifneq ($(ce-obj-y)$(ce-obj-m),)
if <as check>
obj-y += $(ce-obj-y)
obj-m += $(ce-obj-m)
else
$(warning ...)
endif
endif
around it so you only get the warning if you have selected any of these modules?
In any case, I strongly prefer to leave the .S files themselves alone if at all possible
Ard.
Quoted 12 lines · On Saturday 11 April 2015 12:35:19 Ard Biesheuvel wrote:
Yes, that should work. Could we also move the CE objs to ce-obj-$() and put
ifneq ($(ce-obj-y)$(ce-obj-m),)
if <as check>
obj-y += $(ce-obj-y)
obj-m += $(ce-obj-m)
else
$(warning ...)
endif
endif
Quoted 1 line
around it so you only get the warning if you have selected any of these modules?
Sounds good, I had not thought of that.
Quoted 1 line
In any case, I strongly prefer to leave the .S files themselves alone if at all possible
Yes, makes sense.
Arnd