linux/arch/powerpc/crypto
Michael Ellerman 6963092601 powerpc/crypto/chacha-p10: Fix failure on non Power10
The chacha-p10-crypto module provides optimised chacha routines for
Power10. It also selects CRYPTO_ARCH_HAVE_LIB_CHACHA which says it
provides chacha_crypt_arch() to generic code.

Notably the module needs to provide chacha_crypt_arch() regardless of
whether it is loaded on Power10 or an older CPU.

The implementation of chacha_crypt_arch() already has a fallback to
chacha_crypt_generic(), however the module as a whole fails to load on
pre-Power10, because of the use of module_cpu_feature_match().

This breaks for example loading wireguard:

  jostaberry-1:~ # modprobe -v wireguard
  insmod /lib/modules/6.8.0-lp155.8.g7e0e887-default/kernel/arch/powerpc/crypto/chacha-p10-crypto.ko.zst
  modprobe: ERROR: could not insert 'wireguard': No such device

Fix it by removing module_cpu_feature_match(), and instead check the
CPU feature manually. If the CPU feature is not found, the module
still loads successfully, but doesn't register the Power10 specific
algorithms. That allows chacha_crypt_generic() to remain available for
use, fixing the problem.

  [root@fedora ~]# modprobe -v wireguard
  insmod /lib/modules/6.8.0-00001-g786a790c4d79/kernel/net/ipv4/udp_tunnel.ko
  insmod /lib/modules/6.8.0-00001-g786a790c4d79/kernel/net/ipv6/ip6_udp_tunnel.ko
  insmod /lib/modules/6.8.0-00001-g786a790c4d79/kernel/lib/crypto/libchacha.ko
  insmod /lib/modules/6.8.0-00001-g786a790c4d79/kernel/arch/powerpc/crypto/chacha-p10-crypto.ko
  insmod /lib/modules/6.8.0-00001-g786a790c4d79/kernel/lib/crypto/libchacha20poly1305.ko
  insmod /lib/modules/6.8.0-00001-g786a790c4d79/kernel/drivers/net/wireguard/wireguard.ko
  [   18.910452][  T721] wireguard: allowedips self-tests: pass
  [   18.914999][  T721] wireguard: nonce counter self-tests: pass
  [   19.029066][  T721] wireguard: ratelimiter self-tests: pass
  [   19.029257][  T721] wireguard: WireGuard 1.0.0 loaded. See www.wireguard.com for information.
  [   19.029361][  T721] wireguard: Copyright (C) 2015-2019 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.

Reported-by: Michal Suchánek <msuchanek@suse.de>
Closes: https://lore.kernel.org/all/20240315122005.GG20665@kitsune.suse.cz/
Acked-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20240328130200.3041687-1-mpe@ellerman.id.au
2024-04-05 00:02:18 +11:00
..
.gitignore powerpc/crypto: Add gitignore for generated P10 AES/GCM .S files 2023-07-17 13:52:46 +10:00
aes_cbc.c crypto: vmx - Move to arch/powerpc/crypto 2024-01-26 16:36:57 +08:00
aes_ctr.c crypto: vmx - Move to arch/powerpc/crypto 2024-01-26 16:36:57 +08:00
aes_xts.c crypto: vmx - Move to arch/powerpc/crypto 2024-01-26 16:36:57 +08:00
aes-gcm-p10-glue.c crypto: p10-aes-gcm - Avoid -Wstringop-overflow warnings 2023-12-01 18:03:26 +08:00
aes-gcm-p10.S crypto: p10-aes-gcm - An accelerated AES/GCM stitched implementation 2023-03-14 17:06:43 +08:00
aes-spe-core.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
aes-spe-glue.c cyrpto: powerpc/aes - delete the rebundant word "block" in comments 2022-07-22 16:22:04 +08:00
aes-spe-keys.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
aes-spe-modes.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
aes-spe-regs.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
aes-tab-4k.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
aes.c crypto: vmx - Move to arch/powerpc/crypto 2024-01-26 16:36:57 +08:00
aesp8-ppc.h crypto: vmx - Move to arch/powerpc/crypto 2024-01-26 16:36:57 +08:00
aesp8-ppc.pl crypto: vmx - Move to arch/powerpc/crypto 2024-01-26 16:36:57 +08:00
aesp10-ppc.pl powerpc/crypto: Fix aes-gcm-p10 link errors 2023-05-30 15:50:32 +10:00
chacha-p10-glue.c powerpc/crypto/chacha-p10: Fix failure on non Power10 2024-04-05 00:02:18 +11:00
chacha-p10le-8x.S crypto: chacha20-p10 - An optimized Chacha20 implementation with 8-way unrolling for ppc64le 2023-07-14 18:21:30 +10:00
crc32-vpmsum_core.S crypto: powerpc - Use address generation helper for asm 2023-02-10 22:17:36 +11:00
crc32c-vpmsum_asm.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
crc32c-vpmsum_glue.c crypto: remove CRYPTO_TFM_RES_BAD_KEY_LEN 2020-01-09 11:30:53 +08:00
crc-vpmsum_test.c treewide: use get_random_u32_below() instead of deprecated function 2022-11-18 02:15:15 +01:00
crct10dif-vpmsum_asm.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 136 2019-05-30 11:25:15 -07:00
crct10dif-vpmsum_glue.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
ghash.c crypto: vmx - Move to arch/powerpc/crypto 2024-01-26 16:36:57 +08:00
ghashp8-ppc.pl crypto: vmx - Move to arch/powerpc/crypto 2024-01-26 16:36:57 +08:00
ghashp10-ppc.pl powerpc/crypto: Fix aes-gcm-p10 link errors 2023-05-30 15:50:32 +10:00
Kconfig crypto: vmx - Move to arch/powerpc/crypto 2024-01-26 16:36:57 +08:00
Makefile crypto: vmx - Move to arch/powerpc/crypto 2024-01-26 16:36:57 +08:00
md5-asm.S powerpc: flexible GPR range save/restore macros 2021-11-29 23:15:20 +11:00
md5-glue.c crypto: lib/sha1 - remove unnecessary includes of linux/cryptohash.h 2020-05-08 15:32:17 +10:00
poly1305-p10-glue.c crypto: poly1305-p10 - Glue code for optmized Poly1305 implementation for ppc64le 2023-07-14 18:21:31 +10:00
poly1305-p10le_64.S crypto: poly1305-p10 - An optimized Poly1305 implementation with 4-way unrolling for ppc64le 2023-07-14 18:21:31 +10:00
ppc-xlate.pl crypto: p10-aes-gcm - A perl script to process PowerPC assembler source. 2023-03-14 17:06:43 +08:00
sha1-powerpc-asm.S powerpc: flexible GPR range save/restore macros 2021-11-29 23:15:20 +11:00
sha1-spe-asm.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
sha1-spe-glue.c crypto: powerpc/sha - remove duplicate hash init function 2021-12-31 18:10:55 +11:00
sha1.c crypto: powerpc/sha - remove duplicate hash init function 2021-12-31 18:10:55 +11:00
sha256-spe-asm.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
sha256-spe-glue.c crypto: powerpc/sha - remove duplicate hash init function 2021-12-31 18:10:55 +11:00
vmx.c crypto: vmx - Move to arch/powerpc/crypto 2024-01-26 16:36:57 +08:00