linux-stable/arch/powerpc
Michael Ellerman 6a451fc5e6 powerpc/crypto/chacha-p10: Fix failure on non Power10
[ Upstream commit 6963092601 ]

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
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-05-17 12:02:18 +02:00
..
boot powerpc: dts: add missing space before { 2023-08-25 08:39:30 +10:00
configs powerpc/ps3_defconfig: Disable PPC64_BIG_ENDIAN_ELF_ABI_V2 2024-01-31 16:18:49 -08:00
crypto powerpc/crypto/chacha-p10: Fix failure on non Power10 2024-05-17 12:02:18 +02:00
include powerpc/pseries: make max polling consistent for longer H_CALLs 2024-05-17 12:02:08 +02:00
kernel powerpc/ftrace: Ignore ftrace locations in exit text sections 2024-04-27 17:11:43 +02:00
kexec powerpc/vmcore: Add MMU information to vmcoreinfo 2023-11-20 11:59:29 +01:00
kvm KVM: PPC: Book3S HV: Handle pending exceptions on guest entry with MSR_EE 2024-01-25 15:35:13 -08:00
lib powerpc: xor_vmx: Add '-mhard-float' to CFLAGS 2024-04-03 15:28:26 +02:00
math-emu
mm mm/treewide: replace pud_large() with pud_leaf() 2024-04-10 16:35:46 +02:00
net
perf powerpc/hv-gpci: Fix the H_GET_PERF_COUNTER_INFO hcall return value checks 2024-03-26 18:19:54 -04:00
platforms powerpc/pseries/iommu: LPAR panics during boot up with a frozen PE 2024-05-17 12:02:08 +02:00
purgatory
sysdev powerpc/xive: Fix endian conversion size 2023-11-20 11:59:28 +01:00
tools powerpc/ftrace: Add support for -fpatchable-function-entry 2023-08-22 00:09:06 +10:00
xmon TTY/Serial driver changes for 6.6-rc1 2023-09-01 09:38:00 -07:00
Kbuild
Kconfig powerpc/64s: Increase default stack size to 32KB 2024-01-25 15:35:42 -08:00
Kconfig.debug powerpc: allow PPC_EARLY_DEBUG_CPM only when SERIAL_CPM=y 2023-07-03 16:07:55 +10:00
Makefile powerpc/64s: Move CPU -mtune options into Kconfig 2023-08-25 08:39:29 +10:00
Makefile.postlink