diff mbox series

crypto: curve25519 - Work around link failure

Message ID 20200107201327.3863345-1-arnd@arndb.de (mailing list archive)
State Superseded
Delegated to: Herbert Xu
Headers show
Series crypto: curve25519 - Work around link failure | expand

Commit Message

Arnd Bergmann Jan. 7, 2020, 8:12 p.m. UTC
The curve25519 selftest causes a link failure when one of the two
implementations is built-in and the other one is a loadable module,
as then the library gets built in as well but cannot call into the
module:

lib/crypto/curve25519-selftest.o: In function `curve25519_selftest':
curve25519-selftest.c:(.init.text+0x5c): undefined reference to `curve25519_arch'
curve25519-selftest.c:(.init.text+0xfd): undefined reference to `curve25519_base_arch'
curve25519-selftest.c:(.init.text+0x15a): undefined reference to `curve25519_arch'

There is probably a better fix, but this is the local workaround
that I used to get a clean randconfig build again, using Makefile
tricks to make all the curve25519 code built-in if any of the
implementations are.

Fixes: aa127963f1ca ("crypto: lib/curve25519 - re-add selftests")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 arch/arm/crypto/Makefile | 4 +++-
 arch/x86/crypto/Makefile | 4 +++-
 crypto/Makefile          | 5 ++++-
 3 files changed, 10 insertions(+), 3 deletions(-)

Comments

Jason A. Donenfeld Jan. 7, 2020, 8:21 p.m. UTC | #1
Hey Arnd,

Another solution to this was already posted:

https://lore.kernel.org/linux-crypto/CAHmME9pg4KWw1zNVybxn1WLGusyGCjqeAHLQXY=Dr4zznUM82g@mail.gmail.com/T/#t

That might be slightly cleaner, though yours is shorter. I'm alright
with either one.

Jason
Arnd Bergmann Jan. 7, 2020, 9:21 p.m. UTC | #2
On Tue, Jan 7, 2020 at 9:26 PM Jason A. Donenfeld <Jason@zx2c4.com> wrote:
>
> Hey Arnd,
>
> Another solution to this was already posted:
>
> https://lore.kernel.org/linux-crypto/CAHmME9pg4KWw1zNVybxn1WLGusyGCjqeAHLQXY=Dr4zznUM82g@mail.gmail.com/T/#t
>
> That might be slightly cleaner, though yours is shorter. I'm alright
> with either one.

Yes, I agree the other approach looks nicer. I've added that to my randconfig
builder in place of my patch to see if it's sufficient. If not, I'll
let you know.

        Arnd
diff mbox series

Patch

diff --git a/arch/arm/crypto/Makefile b/arch/arm/crypto/Makefile
index b745c17d356f..a7b3957aca58 100644
--- a/arch/arm/crypto/Makefile
+++ b/arch/arm/crypto/Makefile
@@ -12,7 +12,9 @@  obj-$(CONFIG_CRYPTO_SHA512_ARM) += sha512-arm.o
 obj-$(CONFIG_CRYPTO_CHACHA20_NEON) += chacha-neon.o
 obj-$(CONFIG_CRYPTO_POLY1305_ARM) += poly1305-arm.o
 obj-$(CONFIG_CRYPTO_NHPOLY1305_NEON) += nhpoly1305-neon.o
-obj-$(CONFIG_CRYPTO_CURVE25519_NEON) += curve25519-neon.o
+ifdef CONFIG_CRYPTO_CURVE25519_NEON
+obj-$(CONFIG_CRYPTO_LIB_CURVE25519_GENERIC) += curve25519-neon.o
+endif
 
 obj-$(CONFIG_CRYPTO_AES_ARM_CE) += aes-arm-ce.o
 obj-$(CONFIG_CRYPTO_SHA1_ARM_CE) += sha1-arm-ce.o
diff --git a/arch/x86/crypto/Makefile b/arch/x86/crypto/Makefile
index 958440eae27e..7546c276e2f0 100644
--- a/arch/x86/crypto/Makefile
+++ b/arch/x86/crypto/Makefile
@@ -39,7 +39,9 @@  obj-$(CONFIG_CRYPTO_AEGIS128_AESNI_SSE2) += aegis128-aesni.o
 
 obj-$(CONFIG_CRYPTO_NHPOLY1305_SSE2) += nhpoly1305-sse2.o
 obj-$(CONFIG_CRYPTO_NHPOLY1305_AVX2) += nhpoly1305-avx2.o
-obj-$(CONFIG_CRYPTO_CURVE25519_X86) += curve25519-x86_64.o
+ifdef CONFIG_CRYPTO_CURVE25519_X86
+obj-$(CONFIG_CRYPTO_LIB_CURVE25519_GENERIC) += curve25519-x86_64.o
+endif
 
 # These modules require assembler to support AVX.
 ifeq ($(avx_supported),yes)
diff --git a/crypto/Makefile b/crypto/Makefile
index 4ca12b6044f7..93ecbfe50285 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -166,7 +166,10 @@  obj-$(CONFIG_CRYPTO_ZSTD) += zstd.o
 obj-$(CONFIG_CRYPTO_OFB) += ofb.o
 obj-$(CONFIG_CRYPTO_ECC) += ecc.o
 obj-$(CONFIG_CRYPTO_ESSIV) += essiv.o
-obj-$(CONFIG_CRYPTO_CURVE25519) += curve25519-generic.o
+
+ifdef CONFIG_CRYPTO_CURVE25519
+obj-$(CONFIG_CRYPTO_LIB_CURVE25519_GENERIC) += curve25519-generic.o
+endif
 
 ecdh_generic-y += ecdh.o
 ecdh_generic-y += ecdh_helper.o