Message ID | Z76aUfPIbhPAsHbv@gondor.apana.org.au |
---|---|
State | New |
Headers | show |
Series | crypto: lib/Kconfig - Select and hide arch options | expand |
On Wed, Feb 26, 2025 at 12:36:33PM +0800, Herbert Xu wrote: > The ARCH_MAY_HAVE patch missed arm64, mips and s390. But it may > also lead to arch options being enabled but ineffective because > of modular/built-in conflicts. > > As the primary user of all these options wireguard is selecting > the arch options anyway, make the same selections at the lib/crypto > option level and hide the arch options from the user. > > Fixes: 1047e21aecdf ("crypto: lib/Kconfig - Fix lib built-in failure when arch is modular") > Reported-by: kernel test robot <lkp@intel.com> > Reported-by: Arnd Bergmann <arnd@kernel.org> > Closes: https://lore.kernel.org/oe-kbuild-all/202502232152.JC84YDLp-lkp@intel.com/ > Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> As I said earlier, fixing the arch-optimized code to be enabled automatically is the right way to do it. There are still some issues with this patch, though: > config CRYPTO_LIB_CHACHA > tristate "ChaCha library interface" > + select CRYPTO > select CRYPTO_LIB_CHACHA_GENERIC if CRYPTO_ARCH_HAVE_LIB_CHACHA=n > + select CRYPTO_CHACHA20_X86_64 if X86 && 64BIT > + select CRYPTO_CHACHA20_NEON if ARM || (ARM64 && KERNEL_MODE_NEON) > + select CRYPTO_CHACHA_MIPS if CPU_MIPS32_R2 > + select CRYPTO_CHACHA_S390 if S390 > + select CRYPTO_CHACHA20_P10 if PPC64 && CPU_LITTLE_ENDIAN && VSX There's no need to have a select for every architecture, with the dependencies redundantly listed. Instead just 'default' each of the arch-optimized options to CRYPTO_LIB_CHACHA. > config CRYPTO_CHACHA20_X86_64 > tristate > depends on X86 && 64BIT > default CRYPTO_CHACHA20 > select CRYPTO_ARCH_HAVE_LIB_CHACHA [...] > > config CRYPTO_CHACHA20 > tristate "ChaCha" > select CRYPTO_LIB_CHACHA_GENERIC > select CRYPTO_SKCIPHER This introduces a problem where to enable optimized ChaCha in the crypto API users will now need to enable CRYPTO_LIB_CHACHA, instead of CRYPTO_CHACHA20_X86_64 etc. as was needed before. LIB symbols should never be user-selectable, so that makes no sense. The way it should work is that CRYPTO_CHACHA20 should just select CRYPTO_LIB_CHACHA (and thus also the optimized code). And similarly for the other algorithms, which should be in their patches. - Eric
Hi Herbert,
kernel test robot noticed the following build errors:
[auto build test ERROR on herbert-cryptodev-2.6/master]
[also build test ERROR on next-20250226]
[cannot apply to soc/for-next linus/master v6.14-rc4]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Herbert-Xu/crypto-lib-Kconfig-Select-and-hide-arch-options/20250226-125220
base: https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git master
patch link: https://lore.kernel.org/r/Z76aUfPIbhPAsHbv%40gondor.apana.org.au
patch subject: [PATCH] crypto: lib/Kconfig - Select and hide arch options
config: s390-randconfig-002-20250227 (https://download.01.org/0day-ci/archive/20250227/202502271317.S0YZiPk1-lkp@intel.com/config)
compiler: s390-linux-gcc (GCC) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250227/202502271317.S0YZiPk1-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202502271317.S0YZiPk1-lkp@intel.com/
All errors (new ones prefixed by >>):
s390-linux-ld: arch/s390/crypto/chacha-glue.o: in function `chacha20_s390':
>> chacha-glue.c:(.text+0x30e): undefined reference to `chacha_crypt_generic'
s390-linux-ld: arch/s390/crypto/chacha-glue.o: in function `chacha_crypt_arch':
chacha-glue.c:(.text+0x3f6): undefined reference to `chacha_crypt_generic'
On Thu, Feb 27, 2025 at 09:32:51AM +0100, Arnd Bergmann wrote: > > This looks like a good approach. Once it works correctly, > it should be possible to clean up the 'select' statements > in wireguard as well and just 'select CRYPTO_LIB_CHACHA' etc. Yes that's the idea. > I think the more common style is to put the 'default' > lines before 'select'. It is the customary place in the crypto tree. > It appears that the two above are missing a > 'depends on KERNEL_MODE_NEON' line. There is still > a runtime check that prevents it from being used on > non-neon machines, but I think you should add these > lines here since it's no longer possible to turn > them off individually when building a kernel for a > non-NEON target. Good catch. But I think this was deliberate as it also includes a non-NEON implementation: commit b36d8c09e710c71f6a9690b6586fea2d1c9e1e27 Author: Ard Biesheuvel <ardb@kernel.org> Date: Fri Nov 8 13:22:14 2019 +0100 crypto: arm/chacha - remove dependency on generic ChaCha driver Instead of falling back to the generic ChaCha skcipher driver for non-SIMD cases, use a fast scalar implementation for ARM authored by Eric Biggers. This removes the module dependency on chacha-generic altogether, which also simplifies things when we expose the ChaCha library interface from this module. Signed-off-by: Ard Biesheuvel <ardb@kernel.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> > I'm not sure why we need the extra "_INTERNAL" symbols, but I > may be missing something here. What problem does this solve > for you? Without them Kconfig will bomb out because of a loop centering on CONFIG_CRYPTO. Cheers,
On Thu, Feb 27, 2025, at 09:43, Herbert Xu wrote: > On Thu, Feb 27, 2025 at 09:32:51AM +0100, Arnd Bergmann wrote: >> It appears that the two above are missing a >> 'depends on KERNEL_MODE_NEON' line. There is still >> a runtime check that prevents it from being used on >> non-neon machines, but I think you should add these >> lines here since it's no longer possible to turn >> them off individually when building a kernel for a >> non-NEON target. > > Good catch. But I think this was deliberate as it also includes > a non-NEON implementation: > > commit b36d8c09e710c71f6a9690b6586fea2d1c9e1e27 > Author: Ard Biesheuvel <ardb@kernel.org> > Date: Fri Nov 8 13:22:14 2019 +0100 > > crypto: arm/chacha - remove dependency on generic ChaCha driver Ah, I see. That's fine then. > Instead of falling back to the generic ChaCha skcipher driver for > non-SIMD cases, use a fast scalar implementation for ARM authored > by Eric Biggers. This removes the module dependency on chacha-generic > altogether, which also simplifies things when we expose the ChaCha > library interface from this module. > > Signed-off-by: Ard Biesheuvel <ardb@kernel.org> > Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> > >> I'm not sure why we need the extra "_INTERNAL" symbols, but I >> may be missing something here. What problem does this solve >> for you? > > Without them Kconfig will bomb out because of a loop centering > on CONFIG_CRYPTO. I've tried to undo that portion here and don't run into a dependency loop so far with the patch below on top of yours (around 100 randconfigs in). I'll keep testing and will let you know when something goes wrong. One issue I've already found in your version is that removing the 'select CRYPTO_LIB_CHACHA_GENERIC' is broken in the majority of the cases where an architecture specific implementation is enabled, because the architecture code typically contains a fallback to the generic version for the case where the custom CPU instructions are not present. I've added the 'select' lines to the architecture versions here, but since it's almost always needed, we could decide to just leave the generic version built-in anyway to make it less error-prone at the cost of kernel bloat in the few cases where it's not used. An unrelated issue I noticed is that CRYPTO_LIB_CHACHA20POLY1305 depends on CRYPTO in order to pull in CRYPTO_ALGAPI, this looks like a mistake and could be resolved by moving crypto/scatterwalk.c into lib/crypto/ with its own symbol. That should be a separate patch of course. Arnd diff --git a/arch/arm/crypto/Kconfig b/arch/arm/crypto/Kconfig index 0c19317a9ce0..f2e3b62c1379 100644 --- a/arch/arm/crypto/Kconfig +++ b/arch/arm/crypto/Kconfig @@ -7,7 +7,8 @@ config CRYPTO_CURVE25519_NEON depends on KERNEL_MODE_NEON select CRYPTO_KPP select CRYPTO_ARCH_HAVE_LIB_CURVE25519 - default CRYPTO_LIB_CURVE25519_INTERNAL + select CRYPTO_LIB_CURVE25519_GENERIC + default CRYPTO_LIB_CURVE25519 help Curve25519 algorithm @@ -49,7 +50,8 @@ config CRYPTO_POLY1305_ARM tristate select CRYPTO_HASH select CRYPTO_ARCH_HAVE_LIB_POLY1305 - default CRYPTO_LIB_POLY1305_INTERNAL + select CRYPTO_LIB_POLY1305_GENERIC + default CRYPTO_LIB_POLY1305 help Poly1305 authenticator algorithm (RFC7539) @@ -217,7 +219,8 @@ config CRYPTO_CHACHA20_NEON tristate select CRYPTO_SKCIPHER select CRYPTO_ARCH_HAVE_LIB_CHACHA - default CRYPTO_LIB_CHACHA_INTERNAL + select CRYPTO_LIB_CHACHA_GENERIC + default CRYPTO_LIB_CHACHA help Length-preserving ciphers: ChaCha20, XChaCha20, and XChaCha12 stream cipher algorithms diff --git a/arch/arm64/crypto/Kconfig b/arch/arm64/crypto/Kconfig index 1b14551cc301..17f447240f9a 100644 --- a/arch/arm64/crypto/Kconfig +++ b/arch/arm64/crypto/Kconfig @@ -30,7 +30,7 @@ config CRYPTO_POLY1305_NEON depends on KERNEL_MODE_NEON select CRYPTO_HASH select CRYPTO_ARCH_HAVE_LIB_POLY1305 - default CRYPTO_LIB_POLY1305_INTERNAL + default CRYPTO_LIB_POLY1305 help Poly1305 authenticator algorithm (RFC7539) @@ -191,7 +191,8 @@ config CRYPTO_CHACHA20_NEON depends on KERNEL_MODE_NEON select CRYPTO_SKCIPHER select CRYPTO_ARCH_HAVE_LIB_CHACHA - default CRYPTO_LIB_CHACHA_INTERNAL + select CRYPTO_LIB_CHACHA_GENERIC + default CRYPTO_LIB_CHACHA help Length-preserving ciphers: ChaCha20, XChaCha20, and XChaCha12 stream cipher algorithms diff --git a/arch/mips/crypto/Kconfig b/arch/mips/crypto/Kconfig index 545fc0e12422..e0d8ee2677df 100644 --- a/arch/mips/crypto/Kconfig +++ b/arch/mips/crypto/Kconfig @@ -7,7 +7,7 @@ config CRYPTO_POLY1305_MIPS depends on MIPS select CRYPTO_HASH select CRYPTO_ARCH_HAVE_LIB_POLY1305 - default CRYPTO_LIB_POLY1305_INTERNAL + default CRYPTO_LIB_POLY1305 help Poly1305 authenticator algorithm (RFC7539) @@ -58,7 +58,7 @@ config CRYPTO_CHACHA_MIPS depends on CPU_MIPS32_R2 select CRYPTO_SKCIPHER select CRYPTO_ARCH_HAVE_LIB_CHACHA - default CRYPTO_LIB_CHACHA_INTERNAL + default CRYPTO_LIB_CHACHA help Length-preserving ciphers: ChaCha20, XChaCha20, and XChaCha12 stream cipher algorithms diff --git a/arch/powerpc/crypto/Kconfig b/arch/powerpc/crypto/Kconfig index 5beed03869c9..49f929f49e45 100644 --- a/arch/powerpc/crypto/Kconfig +++ b/arch/powerpc/crypto/Kconfig @@ -7,7 +7,8 @@ config CRYPTO_CURVE25519_PPC64 depends on PPC64 && CPU_LITTLE_ENDIAN select CRYPTO_KPP select CRYPTO_ARCH_HAVE_LIB_CURVE25519 - default CRYPTO_LIB_CURVE25519_INTERNAL + select CRYPTO_LIB_CURVE25519_GENERIC + default CRYPTO_LIB_CURVE25519 help Curve25519 algorithm @@ -96,7 +97,8 @@ config CRYPTO_CHACHA20_P10 depends on PPC64 && CPU_LITTLE_ENDIAN && VSX select CRYPTO_SKCIPHER select CRYPTO_ARCH_HAVE_LIB_CHACHA - default CRYPTO_LIB_CHACHA_INTERNAL + select CRYPTO_LIB_CHACHA_GENERIC + default CRYPTO_LIB_CHACHA help Length-preserving ciphers: ChaCha20, XChaCha20, and XChaCha12 stream cipher algorithms diff --git a/arch/s390/crypto/Kconfig b/arch/s390/crypto/Kconfig index f6f82dab3594..13245d569d4d 100644 --- a/arch/s390/crypto/Kconfig +++ b/arch/s390/crypto/Kconfig @@ -112,7 +112,8 @@ config CRYPTO_CHACHA_S390 depends on S390 select CRYPTO_SKCIPHER select CRYPTO_ARCH_HAVE_LIB_CHACHA - default CRYPTO_LIB_CHACHA_INTERNAL + select CRYPTO_LIB_CHACHA_GENERIC + default CRYPTO_LIB_CHACHA help Length-preserving cipher: ChaCha20 stream cipher (RFC 7539) diff --git a/arch/x86/crypto/Kconfig b/arch/x86/crypto/Kconfig index d3128e99bac5..1f20425f6c87 100644 --- a/arch/x86/crypto/Kconfig +++ b/arch/x86/crypto/Kconfig @@ -7,7 +7,8 @@ config CRYPTO_CURVE25519_X86 depends on X86 && 64BIT select CRYPTO_KPP select CRYPTO_ARCH_HAVE_LIB_CURVE25519 - default CRYPTO_LIB_CURVE25519_INTERNAL + select CRYPTO_LIB_CURVE25519_GENERIC + default CRYPTO_LIB_CURVE25519 help Curve25519 algorithm @@ -353,7 +354,8 @@ config CRYPTO_CHACHA20_X86_64 depends on X86 && 64BIT select CRYPTO_SKCIPHER select CRYPTO_ARCH_HAVE_LIB_CHACHA - default CRYPTO_LIB_CHACHA_INTERNAL + select CRYPTO_LIB_CHACHA_GENERIC + default CRYPTO_LIB_CHACHA help Length-preserving ciphers: ChaCha20, XChaCha20, and XChaCha12 stream cipher algorithms @@ -422,7 +424,8 @@ config CRYPTO_POLY1305_X86_64 depends on X86 && 64BIT select CRYPTO_HASH select CRYPTO_ARCH_HAVE_LIB_POLY1305 - default CRYPTO_LIB_POLY1305_INTERNAL + select CRYPTO_LIB_POLY1305_GENERIC + default CRYPTO_LIB_POLY1305 help Poly1305 authenticator algorithm (RFC7539) diff --git a/crypto/Kconfig b/crypto/Kconfig index aac27a4668fd..6013850c114c 100644 --- a/crypto/Kconfig +++ b/crypto/Kconfig @@ -317,7 +317,7 @@ config CRYPTO_ECRDSA config CRYPTO_CURVE25519 tristate "Curve25519" select CRYPTO_KPP - select CRYPTO_LIB_CURVE25519_INTERNAL + select CRYPTO_LIB_CURVE25519 help Curve25519 elliptic curve (RFC7748) @@ -615,7 +615,7 @@ config CRYPTO_ARC4 config CRYPTO_CHACHA20 tristate "ChaCha" - select CRYPTO_LIB_CHACHA_INTERNAL + select CRYPTO_LIB_CHACHA select CRYPTO_SKCIPHER help The ChaCha20, XChaCha20, and XChaCha12 stream cipher algorithms @@ -936,7 +936,7 @@ config CRYPTO_POLYVAL config CRYPTO_POLY1305 tristate "Poly1305" select CRYPTO_HASH - select CRYPTO_LIB_POLY1305_INTERNAL + select CRYPTO_LIB_POLY1305_GENERIC help Poly1305 authenticator algorithm (RFC7539) diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 1fd5acdc73c6..417b691c7c53 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -82,18 +82,6 @@ config WIREGUARD select CRYPTO select CRYPTO_LIB_CURVE25519 select CRYPTO_LIB_CHACHA20POLY1305 - select CRYPTO_CHACHA20_X86_64 if X86 && 64BIT - select CRYPTO_POLY1305_X86_64 if X86 && 64BIT - select CRYPTO_BLAKE2S_X86 if X86 && 64BIT - select CRYPTO_CURVE25519_X86 if X86 && 64BIT - select CRYPTO_CHACHA20_NEON if ARM || (ARM64 && KERNEL_MODE_NEON) - select CRYPTO_POLY1305_NEON if ARM64 && KERNEL_MODE_NEON - select CRYPTO_POLY1305_ARM if ARM - select CRYPTO_BLAKE2S_ARM if ARM - select CRYPTO_CURVE25519_NEON if ARM && KERNEL_MODE_NEON - select CRYPTO_CHACHA_MIPS if CPU_MIPS32_R2 - select CRYPTO_POLY1305_MIPS if MIPS - select CRYPTO_CHACHA_S390 if S390 help WireGuard is a secure, fast, and easy to use replacement for IPSec that uses modern cryptography and clever networking tricks. It's diff --git a/lib/crypto/Kconfig b/lib/crypto/Kconfig index b09e78da959a..8fdb1a5de909 100644 --- a/lib/crypto/Kconfig +++ b/lib/crypto/Kconfig @@ -42,7 +42,7 @@ config CRYPTO_LIB_BLAKE2S_GENERIC of CRYPTO_LIB_BLAKE2S. config CRYPTO_ARCH_HAVE_LIB_CHACHA - bool + tristate help Declares whether the architecture provides an arch-specific accelerated implementation of the ChaCha library interface, @@ -58,21 +58,16 @@ config CRYPTO_LIB_CHACHA_GENERIC implementation is enabled, this implementation serves the users of CRYPTO_LIB_CHACHA. -config CRYPTO_LIB_CHACHA_INTERNAL - tristate - select CRYPTO_LIB_CHACHA_GENERIC if CRYPTO_ARCH_HAVE_LIB_CHACHA=n - config CRYPTO_LIB_CHACHA tristate "ChaCha library interface" - select CRYPTO - select CRYPTO_LIB_CHACHA_INTERNAL + select CRYPTO_LIB_CHACHA_GENERIC if CRYPTO_ARCH_HAVE_LIB_CHACHA=n help Enable the ChaCha library interface. This interface may be fulfilled by either the generic implementation or an arch-specific one, if one is available and enabled. config CRYPTO_ARCH_HAVE_LIB_CURVE25519 - bool + tristate help Declares whether the architecture provides an arch-specific accelerated implementation of the Curve25519 library interface, @@ -88,14 +83,9 @@ config CRYPTO_LIB_CURVE25519_GENERIC implementation is enabled, this implementation serves the users of CRYPTO_LIB_CURVE25519. -config CRYPTO_LIB_CURVE25519_INTERNAL - tristate - select CRYPTO_LIB_CURVE25519_GENERIC if CRYPTO_ARCH_HAVE_LIB_CURVE25519=n - config CRYPTO_LIB_CURVE25519 tristate "Curve25519 scalar multiplication library" - select CRYPTO - select CRYPTO_LIB_CURVE25519_INTERNAL + select CRYPTO_LIB_CURVE25519_GENERIC if CRYPTO_ARCH_HAVE_LIB_CURVE25519=n help Enable the Curve25519 library interface. This interface may be fulfilled by either the generic implementation or an arch-specific @@ -112,7 +102,7 @@ config CRYPTO_LIB_POLY1305_RSIZE default 1 config CRYPTO_ARCH_HAVE_LIB_POLY1305 - bool + tristate help Declares whether the architecture provides an arch-specific accelerated implementation of the Poly1305 library interface, @@ -127,14 +117,9 @@ config CRYPTO_LIB_POLY1305_GENERIC implementation is enabled, this implementation serves the users of CRYPTO_LIB_POLY1305. -config CRYPTO_LIB_POLY1305_INTERNAL - tristate - select CRYPTO_LIB_POLY1305_GENERIC if CRYPTO_ARCH_HAVE_LIB_POLY1305=n - config CRYPTO_LIB_POLY1305 tristate "Poly1305 library interface" - select CRYPTO - select CRYPTO_LIB_POLY1305_INTERNAL + select CRYPTO_LIB_POLY1305_GENERIC if CRYPTO_ARCH_HAVE_LIB_POLY1305=n help Enable the Poly1305 library interface. This interface may be fulfilled by either the generic implementation or an arch-specific one, if one
On Thu, Feb 27, 2025 at 12:56:30PM +0100, Arnd Bergmann wrote: > > I've tried to undo that portion here and don't run into a > dependency loop so far with the patch below on top of yours > (around 100 randconfigs in). I'll keep testing and will let > you know when something goes wrong. That's because you removed 'select CRYPTO', which can cause the arch code to silently disappear just like my original patch. It's pretty much difficult to disable CRYPTO because so many random things select it. But I managed to turn CRYPTO off with some effort and indeed with your patch the arch code disappears. In the following config file, CONFIG_CRYPTO_LIB_CHACHA is modular but the X86 option for it is not selected, because CRYPTO itself is off. Cheers,
On Fri, Feb 28, 2025, at 05:11, Herbert Xu wrote: > On Thu, Feb 27, 2025 at 12:56:30PM +0100, Arnd Bergmann wrote: >> >> I've tried to undo that portion here and don't run into a >> dependency loop so far with the patch below on top of yours >> (around 100 randconfigs in). I'll keep testing and will let >> you know when something goes wrong. > > That's because you removed 'select CRYPTO', which can cause the > arch code to silently disappear just like my original patch. > > It's pretty much difficult to disable CRYPTO because so many > random things select it. But I managed to turn CRYPTO off with > some effort and indeed with your patch the arch code disappears. > > In the following config file, CONFIG_CRYPTO_LIB_CHACHA is modular but > the X86 option for it is not selected, because CRYPTO itself is off. I see. So the case of building lib/crypto code but not CONFIG_CRYPTO is something I would normally expect to work, including the architecture specific optimizations, and it's probably not too hard to get there, but it's also unclear if there is really a point in doing that. For design purity, I think we would need to split the architecture specific code the same way as the generic ones: library functions that always get selected by their users to export functions and the front-ends that are user-selectable and register the algorithm with the crypto API. Keeping the 'select CRYPTO' is clearly less effor if you prefer that. Arnd
diff --git a/arch/arm/crypto/Kconfig b/arch/arm/crypto/Kconfig index 47d9cc59f254..e28c177e63d3 100644 --- a/arch/arm/crypto/Kconfig +++ b/arch/arm/crypto/Kconfig @@ -3,10 +3,10 @@ menu "Accelerated Cryptographic Algorithms for CPU (arm)" config CRYPTO_CURVE25519_NEON - tristate "Public key crypto: Curve25519 (NEON)" + tristate depends on KERNEL_MODE_NEON - select CRYPTO_LIB_CURVE25519_GENERIC - select CRYPTO_ARCH_MAY_HAVE_LIB_CURVE25519 + select CRYPTO_KPP + select CRYPTO_ARCH_HAVE_LIB_CURVE25519 help Curve25519 algorithm @@ -45,9 +45,9 @@ config CRYPTO_NHPOLY1305_NEON - NEON (Advanced SIMD) extensions config CRYPTO_POLY1305_ARM - tristate "Hash functions: Poly1305 (NEON)" + tristate select CRYPTO_HASH - select CRYPTO_ARCH_MAY_HAVE_LIB_POLY1305 + select CRYPTO_ARCH_HAVE_LIB_POLY1305 help Poly1305 authenticator algorithm (RFC7539) @@ -212,9 +212,9 @@ config CRYPTO_AES_ARM_CE - ARMv8 Crypto Extensions config CRYPTO_CHACHA20_NEON - tristate "Ciphers: ChaCha20, XChaCha20, XChaCha12 (NEON)" + tristate select CRYPTO_SKCIPHER - select CRYPTO_ARCH_MAY_HAVE_LIB_CHACHA + select CRYPTO_ARCH_HAVE_LIB_CHACHA help Length-preserving ciphers: ChaCha20, XChaCha20, and XChaCha12 stream cipher algorithms diff --git a/arch/arm64/crypto/Kconfig b/arch/arm64/crypto/Kconfig index 5636ab83f22a..6bf844da022d 100644 --- a/arch/arm64/crypto/Kconfig +++ b/arch/arm64/crypto/Kconfig @@ -26,7 +26,7 @@ config CRYPTO_NHPOLY1305_NEON - NEON (Advanced SIMD) extensions config CRYPTO_POLY1305_NEON - tristate "Hash functions: Poly1305 (NEON)" + tristate depends on KERNEL_MODE_NEON select CRYPTO_HASH select CRYPTO_ARCH_HAVE_LIB_POLY1305 @@ -186,10 +186,9 @@ config CRYPTO_AES_ARM64_NEON_BLK - NEON (Advanced SIMD) extensions config CRYPTO_CHACHA20_NEON - tristate "Ciphers: ChaCha (NEON)" + tristate depends on KERNEL_MODE_NEON select CRYPTO_SKCIPHER - select CRYPTO_LIB_CHACHA_GENERIC select CRYPTO_ARCH_HAVE_LIB_CHACHA help Length-preserving ciphers: ChaCha20, XChaCha20, and XChaCha12 diff --git a/arch/mips/crypto/Kconfig b/arch/mips/crypto/Kconfig index 7decd40c4e20..e02481cc9c06 100644 --- a/arch/mips/crypto/Kconfig +++ b/arch/mips/crypto/Kconfig @@ -3,8 +3,9 @@ menu "Accelerated Cryptographic Algorithms for CPU (mips)" config CRYPTO_POLY1305_MIPS - tristate "Hash functions: Poly1305" + tristate depends on MIPS + select CRYPTO_HASH select CRYPTO_ARCH_HAVE_LIB_POLY1305 help Poly1305 authenticator algorithm (RFC7539) @@ -52,7 +53,7 @@ config CRYPTO_SHA512_OCTEON Architecture: mips OCTEON using crypto instructions, when available config CRYPTO_CHACHA_MIPS - tristate "Ciphers: ChaCha20, XChaCha20, XChaCha12 (MIPS32r2)" + tristate depends on CPU_MIPS32_R2 select CRYPTO_SKCIPHER select CRYPTO_ARCH_HAVE_LIB_CHACHA diff --git a/arch/powerpc/crypto/Kconfig b/arch/powerpc/crypto/Kconfig index e453cb0c82d2..589ae680a272 100644 --- a/arch/powerpc/crypto/Kconfig +++ b/arch/powerpc/crypto/Kconfig @@ -3,10 +3,10 @@ menu "Accelerated Cryptographic Algorithms for CPU (powerpc)" config CRYPTO_CURVE25519_PPC64 - tristate "Public key crypto: Curve25519 (PowerPC64)" + tristate depends on PPC64 && CPU_LITTLE_ENDIAN - select CRYPTO_LIB_CURVE25519_GENERIC - select CRYPTO_ARCH_MAY_HAVE_LIB_CURVE25519 + select CRYPTO_KPP + select CRYPTO_ARCH_HAVE_LIB_CURVE25519 help Curve25519 algorithm @@ -91,11 +91,10 @@ config CRYPTO_AES_GCM_P10 later CPU. This module supports stitched acceleration for AES/GCM. config CRYPTO_CHACHA20_P10 - tristate "Ciphers: ChaCha20, XChacha20, XChacha12 (P10 or later)" + tristate depends on PPC64 && CPU_LITTLE_ENDIAN && VSX select CRYPTO_SKCIPHER - select CRYPTO_LIB_CHACHA_GENERIC - select CRYPTO_ARCH_MAY_HAVE_LIB_CHACHA + select CRYPTO_ARCH_HAVE_LIB_CHACHA help Length-preserving ciphers: ChaCha20, XChaCha20, and XChaCha12 stream cipher algorithms diff --git a/arch/riscv/crypto/Kconfig b/arch/riscv/crypto/Kconfig index ad58dad9a580..c67095a3d669 100644 --- a/arch/riscv/crypto/Kconfig +++ b/arch/riscv/crypto/Kconfig @@ -22,7 +22,6 @@ config CRYPTO_CHACHA_RISCV64 tristate "Ciphers: ChaCha" depends on 64BIT && RISCV_ISA_V && TOOLCHAIN_HAS_VECTOR_CRYPTO select CRYPTO_SKCIPHER - select CRYPTO_LIB_CHACHA_GENERIC help Length-preserving ciphers: ChaCha20 stream cipher algorithm diff --git a/arch/s390/crypto/Kconfig b/arch/s390/crypto/Kconfig index b760232537f1..c327aeccfde7 100644 --- a/arch/s390/crypto/Kconfig +++ b/arch/s390/crypto/Kconfig @@ -108,10 +108,9 @@ config CRYPTO_DES_S390 As of z196 the CTR mode is hardware accelerated. config CRYPTO_CHACHA_S390 - tristate "Ciphers: ChaCha20" + tristate depends on S390 select CRYPTO_SKCIPHER - select CRYPTO_LIB_CHACHA_GENERIC select CRYPTO_ARCH_HAVE_LIB_CHACHA help Length-preserving cipher: ChaCha20 stream cipher (RFC 7539) diff --git a/arch/x86/crypto/Kconfig b/arch/x86/crypto/Kconfig index c189dad0969b..725105919cd3 100644 --- a/arch/x86/crypto/Kconfig +++ b/arch/x86/crypto/Kconfig @@ -3,10 +3,10 @@ menu "Accelerated Cryptographic Algorithms for CPU (x86)" config CRYPTO_CURVE25519_X86 - tristate "Public key crypto: Curve25519 (ADX)" + tristate depends on X86 && 64BIT - select CRYPTO_LIB_CURVE25519_GENERIC - select CRYPTO_ARCH_MAY_HAVE_LIB_CURVE25519 + select CRYPTO_KPP + select CRYPTO_ARCH_HAVE_LIB_CURVE25519 help Curve25519 algorithm @@ -348,11 +348,10 @@ config CRYPTO_ARIA_GFNI_AVX512_X86_64 Processes 64 blocks in parallel. config CRYPTO_CHACHA20_X86_64 - tristate "Ciphers: ChaCha20, XChaCha20, XChaCha12 (SSSE3/AVX2/AVX-512VL)" + tristate depends on X86 && 64BIT select CRYPTO_SKCIPHER - select CRYPTO_LIB_CHACHA_GENERIC - select CRYPTO_ARCH_MAY_HAVE_LIB_CHACHA + select CRYPTO_ARCH_HAVE_LIB_CHACHA help Length-preserving ciphers: ChaCha20, XChaCha20, and XChaCha12 stream cipher algorithms @@ -417,10 +416,10 @@ config CRYPTO_POLYVAL_CLMUL_NI - CLMUL-NI (carry-less multiplication new instructions) config CRYPTO_POLY1305_X86_64 - tristate "Hash functions: Poly1305 (SSE2/AVX2)" + tristate depends on X86 && 64BIT - select CRYPTO_LIB_POLY1305_GENERIC - select CRYPTO_ARCH_MAY_HAVE_LIB_POLY1305 + select CRYPTO_HASH + select CRYPTO_ARCH_HAVE_LIB_POLY1305 help Poly1305 authenticator algorithm (RFC7539) diff --git a/lib/crypto/Kconfig b/lib/crypto/Kconfig index c542ef1d64d0..f095df82f5e9 100644 --- a/lib/crypto/Kconfig +++ b/lib/crypto/Kconfig @@ -48,11 +48,6 @@ config CRYPTO_ARCH_HAVE_LIB_CHACHA accelerated implementation of the ChaCha library interface, either builtin or as a module. -config CRYPTO_ARCH_MAY_HAVE_LIB_CHACHA - tristate - select CRYPTO_ARCH_HAVE_LIB_CHACHA if CRYPTO_LIB_CHACHA=m - select CRYPTO_ARCH_HAVE_LIB_CHACHA if CRYPTO_ARCH_MAY_HAVE_LIB_CHACHA=y - config CRYPTO_LIB_CHACHA_GENERIC tristate select CRYPTO_LIB_UTILS @@ -65,7 +60,13 @@ config CRYPTO_LIB_CHACHA_GENERIC config CRYPTO_LIB_CHACHA tristate "ChaCha library interface" + select CRYPTO select CRYPTO_LIB_CHACHA_GENERIC if CRYPTO_ARCH_HAVE_LIB_CHACHA=n + select CRYPTO_CHACHA20_X86_64 if X86 && 64BIT + select CRYPTO_CHACHA20_NEON if ARM || (ARM64 && KERNEL_MODE_NEON) + select CRYPTO_CHACHA_MIPS if CPU_MIPS32_R2 + select CRYPTO_CHACHA_S390 if S390 + select CRYPTO_CHACHA20_P10 if PPC64 && CPU_LITTLE_ENDIAN && VSX help Enable the ChaCha library interface. This interface may be fulfilled by either the generic implementation or an arch-specific one, if one @@ -78,13 +79,9 @@ config CRYPTO_ARCH_HAVE_LIB_CURVE25519 accelerated implementation of the Curve25519 library interface, either builtin or as a module. -config CRYPTO_ARCH_MAY_HAVE_LIB_CURVE25519 - tristate - select CRYPTO_ARCH_HAVE_LIB_CURVE25519 if CRYPTO_LIB_CURVE25519=m - select CRYPTO_ARCH_HAVE_LIB_CURVE25519 if CRYPTO_ARCH_MAY_HAVE_LIB_CURVE25519=y - config CRYPTO_LIB_CURVE25519_GENERIC tristate + select CRYPTO_LIB_UTILS help This symbol can be depended upon by arch implementations of the Curve25519 library interface that require the generic code as a @@ -95,7 +92,9 @@ config CRYPTO_LIB_CURVE25519_GENERIC config CRYPTO_LIB_CURVE25519 tristate "Curve25519 scalar multiplication library" select CRYPTO_LIB_CURVE25519_GENERIC if CRYPTO_ARCH_HAVE_LIB_CURVE25519=n - select CRYPTO_LIB_UTILS + select CRYPTO_CURVE25519_X86 if X86 && 64BIT + select CRYPTO_CURVE25519_NEON if ARM && KERNEL_MODE_NEON + select CRYPTO_CURVE25519_PPC64 if PPC64 && CPU_LITTLE_ENDIAN help Enable the Curve25519 library interface. This interface may be fulfilled by either the generic implementation or an arch-specific @@ -118,11 +117,6 @@ config CRYPTO_ARCH_HAVE_LIB_POLY1305 accelerated implementation of the Poly1305 library interface, either builtin or as a module. -config CRYPTO_ARCH_MAY_HAVE_LIB_POLY1305 - tristate - select CRYPTO_ARCH_HAVE_LIB_POLY1305 if CRYPTO_LIB_POLY1305=m - select CRYPTO_ARCH_HAVE_LIB_POLY1305 if CRYPTO_ARCH_MAY_HAVE_LIB_POLY1305=y - config CRYPTO_LIB_POLY1305_GENERIC tristate help @@ -135,6 +129,10 @@ config CRYPTO_LIB_POLY1305_GENERIC config CRYPTO_LIB_POLY1305 tristate "Poly1305 library interface" select CRYPTO_LIB_POLY1305_GENERIC if CRYPTO_ARCH_HAVE_LIB_POLY1305=n + select CRYPTO_POLY1305_X86_64 if X86 && 64BIT + select CRYPTO_POLY1305_NEON if ARM64 && KERNEL_MODE_NEON + select CRYPTO_POLY1305_ARM if ARM + select CRYPTO_POLY1305_MIPS if MIPS help Enable the Poly1305 library interface. This interface may be fulfilled by either the generic implementation or an arch-specific one, if one @@ -142,9 +140,10 @@ config CRYPTO_LIB_POLY1305 config CRYPTO_LIB_CHACHA20POLY1305 tristate "ChaCha20-Poly1305 AEAD support (8-byte nonce library version)" - depends on CRYPTO + select CRYPTO select CRYPTO_LIB_CHACHA select CRYPTO_LIB_POLY1305 + select CRYPTO_LIB_UTILS select CRYPTO_ALGAPI config CRYPTO_LIB_SHA1
The ARCH_MAY_HAVE patch missed arm64, mips and s390. But it may also lead to arch options being enabled but ineffective because of modular/built-in conflicts. As the primary user of all these options wireguard is selecting the arch options anyway, make the same selections at the lib/crypto option level and hide the arch options from the user. Fixes: 1047e21aecdf ("crypto: lib/Kconfig - Fix lib built-in failure when arch is modular") Reported-by: kernel test robot <lkp@intel.com> Reported-by: Arnd Bergmann <arnd@kernel.org> Closes: https://lore.kernel.org/oe-kbuild-all/202502232152.JC84YDLp-lkp@intel.com/ Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>