From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.zx2c4.com (lists.zx2c4.com [165.227.139.114]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7762BCD1284 for ; Tue, 2 Apr 2024 06:36:55 +0000 (UTC) Received: by lists.zx2c4.com (ZX2C4 Mail Server) with ESMTP id e43ee3eb; Tue, 2 Apr 2024 06:36:53 +0000 (UTC) Received: from abb.hmeau.com (abb.hmeau.com [144.6.53.87]) by lists.zx2c4.com (ZX2C4 Mail Server) with ESMTPS id 991b1cc0 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Tue, 2 Apr 2024 06:36:50 +0000 (UTC) Received: from loth.rohan.me.apana.org.au ([192.168.167.2]) by formenos.hmeau.com with smtp (Exim 4.94.2 #2 (Debian)) id 1rrXl4-00DyL0-Uh; Tue, 02 Apr 2024 14:36:36 +0800 Received: by loth.rohan.me.apana.org.au (sSMTP sendmail emulation); Tue, 02 Apr 2024 14:36:51 +0800 Date: Tue, 2 Apr 2024 14:36:51 +0800 From: Herbert Xu To: Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org, msuchanek@suse.de, wireguard@lists.zx2c4.com, dtsen@linux.ibm.com Subject: Re: [PATCH] powerpc/crypto/chacha-p10: Fix failure on non Power10 Message-ID: References: <20240328130200.3041687-1-mpe@ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240328130200.3041687-1-mpe@ellerman.id.au> X-BeenThere: wireguard@lists.zx2c4.com X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: Development discussion of WireGuard List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: wireguard-bounces@lists.zx2c4.com Sender: "WireGuard" On Fri, Mar 29, 2024 at 12:02:00AM +1100, Michael Ellerman wrote: > 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 . All Rights Reserved. > > Reported-by: Michal Suchánek > Closes: https://lore.kernel.org/all/20240315122005.GG20665@kitsune.suse.cz/ > Signed-off-by: Michael Ellerman > --- > arch/powerpc/crypto/chacha-p10-glue.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) Acked-by: Herbert Xu Thanks, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt