Re: [PATCH] crypto: lib/Kconfig - Fix lib built-in failure when arch is modular

From: Eric Biggers
Date: Wed Feb 12 2025 - 00:09:46 EST


On Wed, Feb 12, 2025 at 12:48:55PM +0800, Herbert Xu wrote:
> On Thu, Jan 23, 2025 at 02:18:27AM +0800, kernel test robot wrote:
> > tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> > head: c4b9570cfb63501638db720f3bee9f6dfd044b82
> > commit: b42519dbba838c928e82b55f32712fbe3eed2c45 crypto: ppc/curve25519 - Update Kconfig and Makefile for ppc64le
> > date: 8 months ago
> > config: powerpc64-randconfig-r111-20250122 (https://download.01.org/0day-ci/archive/20250123/202501230223.ikroNDr1-lkp@xxxxxxxxx/config)
> > compiler: clang version 15.0.7 (https://github.com/llvm/llvm-project 8dfdcc7b7bf66834a761bd8de445840ef68e4d1a)
> > reproduce: (https://download.01.org/0day-ci/archive/20250123/202501230223.ikroNDr1-lkp@xxxxxxxxx/reproduce)
>
> Thanks for the report. This is the old built-in vs. modular Kconfig
> problem. This patch should fix it:
>
> ---8<---
> The HAVE_ARCH Kconfig options in lib/crypto try to solve the
> modular versus built-in problem, but it still fails when the
> the LIB option (e.g., CRYPTO_LIB_CURVE25519) is selected externally.
>
> Fix this by introducing a level of indirection with ARCH_MAY_HAVE
> Kconfig options, these then go on to select the ARCH_HAVE options
> if the ARCH Kconfig options matches that of the LIB option.
>
> Reported-by: kernel test robot <lkp@xxxxxxxxx>
> Closes: https://lore.kernel.org/oe-kbuild-all/202501230223.ikroNDr1-lkp@xxxxxxxxx/
> Signed-off-by: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
>
> diff --git a/arch/arm/crypto/Kconfig b/arch/arm/crypto/Kconfig
> index 32650c8431d9..47d9cc59f254 100644
> --- a/arch/arm/crypto/Kconfig
> +++ b/arch/arm/crypto/Kconfig
> @@ -6,7 +6,7 @@ config CRYPTO_CURVE25519_NEON
> tristate "Public key crypto: Curve25519 (NEON)"
> depends on KERNEL_MODE_NEON
> select CRYPTO_LIB_CURVE25519_GENERIC
> - select CRYPTO_ARCH_HAVE_LIB_CURVE25519
> + select CRYPTO_ARCH_MAY_HAVE_LIB_CURVE25519
> help
> Curve25519 algorithm

Please name these like ARCH_HAS_CURVE25519 and CRYPTO_LIB_CURVE25519_ARCH to be
consistent with the CRC library, the many other ARCH_HAS_* options, and
CRYPTO_LIB_CURVE25519_GENERIC. Nothing uses names that contain "MAY_HAVE",
which is ambiguous.

FWIW, at some point the arch optimized crypto algorithms also need to just be
enabled by default. The fact that they're not is a longstanding bug that is
really harmful to users and needs to be fixed.

- Eric