From patchwork Tue Apr 22 15:27:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 883266 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1E8D828F932; Tue, 22 Apr 2025 15:28:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745335696; cv=none; b=uuxTjgQJSp510YjYuDxQLmq9s1VE+UdkODRiMmRcAjFLQ5phV3ltun/i79G0fgA4MWjasXgsKGh6qPmzIYfWmJc93oMQ7e2bdBW/LVZiS/cuCwIf8d6OMu9y45kMmKvrnpVO4+ijpZccpx27sA4B6fDh2CyBoIAsbcXzInGONv8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745335696; c=relaxed/simple; bh=Wsz8KfnWpKz3RjYagwsQwuMx7mcDuZ3DmLJCHCvCnLk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GBq/yVMRSHsTnWbCxc/GGxNGadF3a4UqJXCTFV06HXo3wohDMk+yUtqiPQeVOocgdBPZpwBwLZvJ9fqLQa6RDEXej8+RxsZAJat7A9bTFqnkXh/3Uce1hgtV9eRQapwGBkZe516IyokgnCKSod8gWG7DRk0JAA/Yb7P/slLOX2Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uBsUn+1u; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="uBsUn+1u" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 32E98C4CEE9; Tue, 22 Apr 2025 15:28:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1745335695; bh=Wsz8KfnWpKz3RjYagwsQwuMx7mcDuZ3DmLJCHCvCnLk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uBsUn+1uknnAtCvGxigHZ4JZToY6+Gy1ixr68PQvV2N71BUQl87w4yMZvlkmjCwZ0 RiCZCN4vIV2n0ynKuXxTLvrHQVn87JR/9LqXwv5UnpKrmGxngl4unZebkUVwATB/sE IaMI4ynGGpFpbI3ZRnoRy8dF2K06NBvFqAB9SziK+JLDHzV8/1oz0c8BZdihd951Qw c5+HPn83XoB+DEMH5jnPKhtWdxpTkVxm/BPC9ZhGUEnLGxZ5UomAOSh+VAoTMwUtNK 4tXgPPEpd0lYeetuHeVpKT/bTaC5YXBvG+nlQRTRr/c8aoQJpGfdjm9w+zNTOpb2JF xGv23N6geYPRQ== From: Eric Biggers To: linux-crypto@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, x86@kernel.org, "Jason A . Donenfeld" , Ard Biesheuvel Subject: [PATCH v3 02/13] crypto: powerpc - drop redundant dependencies on PPC Date: Tue, 22 Apr 2025 08:27:05 -0700 Message-ID: <20250422152716.5923-3-ebiggers@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250422152716.5923-1-ebiggers@kernel.org> References: <20250422152716.5923-1-ebiggers@kernel.org> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Eric Biggers arch/powerpc/crypto/Kconfig is sourced only when CONFIG_PPC=y, so there is no need for the symbols defined inside it to depend on PPC. Acked-by: Ard Biesheuvel Signed-off-by: Eric Biggers --- arch/powerpc/crypto/Kconfig | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/crypto/Kconfig b/arch/powerpc/crypto/Kconfig index cbcf76953d835..8bcc690134644 100644 --- a/arch/powerpc/crypto/Kconfig +++ b/arch/powerpc/crypto/Kconfig @@ -15,48 +15,46 @@ config CRYPTO_CURVE25519_PPC64 Architecture: PowerPC64 - Little-endian config CRYPTO_MD5_PPC tristate "Digests: MD5" - depends on PPC select CRYPTO_HASH help MD5 message digest algorithm (RFC1321) Architecture: powerpc config CRYPTO_SHA1_PPC tristate "Hash functions: SHA-1" - depends on PPC help SHA-1 secure hash algorithm (FIPS 180) Architecture: powerpc config CRYPTO_SHA1_PPC_SPE tristate "Hash functions: SHA-1 (SPE)" - depends on PPC && SPE + depends on SPE help SHA-1 secure hash algorithm (FIPS 180) Architecture: powerpc using - SPE (Signal Processing Engine) extensions config CRYPTO_SHA256_PPC_SPE tristate "Hash functions: SHA-224 and SHA-256 (SPE)" - depends on PPC && SPE + depends on SPE select CRYPTO_SHA256 select CRYPTO_HASH help SHA-224 and SHA-256 secure hash algorithms (FIPS 180) Architecture: powerpc using - SPE (Signal Processing Engine) extensions config CRYPTO_AES_PPC_SPE tristate "Ciphers: AES, modes: ECB/CBC/CTR/XTS (SPE)" - depends on PPC && SPE + depends on SPE select CRYPTO_SKCIPHER help Block ciphers: AES cipher algorithms (FIPS-197) Length-preserving ciphers: AES with ECB, CBC, CTR, and XTS modes From patchwork Tue Apr 22 15:27:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 883263 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 83664293458; Tue, 22 Apr 2025 15:28:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745335698; cv=none; b=YsEWy+eutI5BCFemui0PWeKsu9fYI7QUa9DUGkJqMNyXzPs7NJHGKegMaG3oqc3qgUa5Z3yVU2BC9a54U9w6cWuqUpul5WD8TIJpF6/FifgeZK/Kv/RSXOCOt2vzlla0r/qKcJAHkQhbWaNSOL79SnyuSmOyBqZMXFojDvVMV4Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745335698; c=relaxed/simple; bh=u0xVqTwc+LVSbVkgBLveEACfwQ18fyzLMscrd3BGCZk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ipq5pocjozzoCQrjyg6IP7nRpa75sjiMNH4dwP3iQbTt8P490XgVoPcZZXZoi71Qrq9X4/2oxjgEO3+aPcFex6o23Be7VTp8ItMJ8Kr4P2LBA9i+eHD2Y2MOe/LG+S7Z7tvVR73ZaHlLWXrfjtyTb/8rFWWH3ri3239L0b2pP2E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qdC0W0eL; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="qdC0W0eL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A75A0C4AF0B; Tue, 22 Apr 2025 15:28:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1745335696; bh=u0xVqTwc+LVSbVkgBLveEACfwQ18fyzLMscrd3BGCZk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qdC0W0eL6Uj1hGs8hRkxL94JtjuD44QBTP/Am8HtLUFQMxNY0qy64fWDcMMur6RGx 3aCYvzdhFOBp2e5glCXLasXgVtTZynY/hY0w7T2kUkW8SSm1ni0o2u3/VebmnJlH2m XHVfD+il9gwPYWAoJf2OApKCUX36JzNuT5hgiFvHlkrq+182eHzjXkHm5K3uBeq4px sMbyWsRQ5XPLiLXsAhbke8IFeGSAVjqooYKSX4+TJrsCgRZzMRcamWnVEqc2hJnfai vq9Elw6OEjQ636Eodl4WzFMkTcgfNzcOwC9nrVctgrMZ1mBFFZ/iz3chOnYtmROXIR uwFJTHlErgtsA== From: Eric Biggers To: linux-crypto@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, x86@kernel.org, "Jason A . Donenfeld" , Ard Biesheuvel , Heiko Carstens Subject: [PATCH v3 03/13] crypto: s390 - drop redundant dependencies on S390 Date: Tue, 22 Apr 2025 08:27:06 -0700 Message-ID: <20250422152716.5923-4-ebiggers@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250422152716.5923-1-ebiggers@kernel.org> References: <20250422152716.5923-1-ebiggers@kernel.org> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Eric Biggers arch/s390/crypto/Kconfig is sourced only when CONFIG_S390=y, so there is no need for the symbols defined inside it to depend on S390. Acked-by: Ard Biesheuvel Acked-by: Heiko Carstens Signed-off-by: Eric Biggers --- arch/s390/crypto/Kconfig | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/arch/s390/crypto/Kconfig b/arch/s390/crypto/Kconfig index 055b08f259ab2..e88d9cd256ef5 100644 --- a/arch/s390/crypto/Kconfig +++ b/arch/s390/crypto/Kconfig @@ -2,77 +2,70 @@ menu "Accelerated Cryptographic Algorithms for CPU (s390)" config CRYPTO_SHA512_S390 tristate "Hash functions: SHA-384 and SHA-512" - depends on S390 select CRYPTO_HASH help SHA-384 and SHA-512 secure hash algorithms (FIPS 180) Architecture: s390 It is available as of z10. config CRYPTO_SHA1_S390 tristate "Hash functions: SHA-1" - depends on S390 select CRYPTO_HASH help SHA-1 secure hash algorithm (FIPS 180) Architecture: s390 It is available as of z990. config CRYPTO_SHA256_S390 tristate "Hash functions: SHA-224 and SHA-256" - depends on S390 select CRYPTO_HASH help SHA-224 and SHA-256 secure hash algorithms (FIPS 180) Architecture: s390 It is available as of z9. config CRYPTO_SHA3_256_S390 tristate "Hash functions: SHA3-224 and SHA3-256" - depends on S390 select CRYPTO_HASH help SHA3-224 and SHA3-256 secure hash algorithms (FIPS 202) Architecture: s390 It is available as of z14. config CRYPTO_SHA3_512_S390 tristate "Hash functions: SHA3-384 and SHA3-512" - depends on S390 select CRYPTO_HASH help SHA3-384 and SHA3-512 secure hash algorithms (FIPS 202) Architecture: s390 It is available as of z14. config CRYPTO_GHASH_S390 tristate "Hash functions: GHASH" - depends on S390 select CRYPTO_HASH help GCM GHASH hash function (NIST SP800-38D) Architecture: s390 It is available as of z196. config CRYPTO_AES_S390 tristate "Ciphers: AES, modes: ECB, CBC, CTR, XTS, GCM" - depends on S390 select CRYPTO_ALGAPI select CRYPTO_SKCIPHER help Block cipher: AES cipher algorithms (FIPS 197) AEAD cipher: AES with GCM @@ -90,11 +83,10 @@ config CRYPTO_AES_S390 key sizes and XTS mode is hardware accelerated for 256 and 512 bit keys. config CRYPTO_DES_S390 tristate "Ciphers: DES and Triple DES EDE, modes: ECB, CBC, CTR" - depends on S390 select CRYPTO_ALGAPI select CRYPTO_SKCIPHER select CRYPTO_LIB_DES help Block ciphers: DES (FIPS 46-2) cipher algorithm @@ -107,18 +99,16 @@ config CRYPTO_DES_S390 As of z990 the ECB and CBC mode are hardware accelerated. As of z196 the CTR mode is hardware accelerated. config CRYPTO_CHACHA_S390 tristate - depends on S390 select CRYPTO_LIB_CHACHA_GENERIC select CRYPTO_ARCH_HAVE_LIB_CHACHA default CRYPTO_LIB_CHACHA_INTERNAL config CRYPTO_HMAC_S390 tristate "Keyed-hash message authentication code: HMAC" - depends on S390 select CRYPTO_HASH help s390 specific HMAC hardware support for SHA224, SHA256, SHA384 and SHA512. From patchwork Tue Apr 22 15:27:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 883265 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1C8B2290BCC; Tue, 22 Apr 2025 15:28:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745335697; cv=none; b=abtF5KEcJoU5c7KzF/Oh9+lBbz3FeO85cbULUiS+NZAj1qWci74mtmcfYwYVq6YiwNnqW0ejSt9iC4+eSV0kW+66XeqsCzXe22JtTm82MHfJQfoz6MIcLRuIYWnKxanJo2PK3CdQYRjCYA0ulUavN1lCEO5QlBB2gPtIpQ/fEvY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745335697; c=relaxed/simple; bh=GjEjmwkiG40mBHNNY0hpzCSCY6h3KNGoqBSt3c2rFfU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TgJZHX6POLia2Y943A7va4jrceMsqIGoTcLP1Bt5UOS0vAf+Bw0MpFGlVG2yRDNNbUyWUfh4FpSgWLiEy2RNIjJEmyJn+r6wKF+eCEEs/gvnksE4w4RkP2xnRd3PKLNBU2A/Tqm7Wn1SouBSIep3F2CX1BFFh4hFujBeZHID74E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TL6mg/Zt; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TL6mg/Zt" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E431C4CEF1; Tue, 22 Apr 2025 15:28:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1745335697; bh=GjEjmwkiG40mBHNNY0hpzCSCY6h3KNGoqBSt3c2rFfU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TL6mg/ZtSZDHi1heG+3zuy63dj9dKawGkDD8bzeicE5MrTZUS9Pd8eZqYL6d16oTs 9jryUk406G/+oIa32v8sNWwe0ZGdD4IFD+C7asmF0lMhcV53mOHf2Hj3DZ710BCDQS l8VBbD19T9V8eYW+VfGc3EqqAB1fhV9F3hdcdAWbX/UO2Fglba/2lN6xpzm3ZY2kAm ZCX/m7txQlh4yfz7Dbg0OJaxvNF6iJ25xzc5Trg+lUe47EcpSOuVBLlehC6BqmY1Hp mrXcvhsTVQ9amJxnZjui+0emD4MYMwIaD2zpEN4IOpPNfpUY3nbpPo2lk+ugPRoLg8 f/AsWM/F3qkUQ== From: Eric Biggers To: linux-crypto@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, x86@kernel.org, "Jason A . Donenfeld" , Ard Biesheuvel Subject: [PATCH v3 05/13] crypto: arm - move library functions to arch/arm/lib/crypto/ Date: Tue, 22 Apr 2025 08:27:08 -0700 Message-ID: <20250422152716.5923-6-ebiggers@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250422152716.5923-1-ebiggers@kernel.org> References: <20250422152716.5923-1-ebiggers@kernel.org> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Eric Biggers Continue disentangling the crypto library functions from the generic crypto infrastructure by moving the arm BLAKE2s, ChaCha, and Poly1305 library functions into a new directory arch/arm/lib/crypto/ that does not depend on CRYPTO. This mirrors the distinction between crypto/ and lib/crypto/. Signed-off-by: Eric Biggers --- MAINTAINERS | 1 + arch/arm/crypto/Kconfig | 23 ---------------- arch/arm/crypto/Makefile | 14 +--------- arch/arm/lib/Makefile | 2 ++ arch/arm/lib/crypto/.gitignore | 2 ++ arch/arm/lib/crypto/Kconfig | 24 +++++++++++++++++ arch/arm/lib/crypto/Makefile | 26 +++++++++++++++++++ arch/arm/{ => lib}/crypto/blake2s-core.S | 0 arch/arm/{ => lib}/crypto/blake2s-glue.c | 0 arch/arm/{ => lib}/crypto/chacha-glue.c | 0 arch/arm/{ => lib}/crypto/chacha-neon-core.S | 0 .../arm/{ => lib}/crypto/chacha-scalar-core.S | 0 arch/arm/{ => lib}/crypto/poly1305-armv4.pl | 0 arch/arm/{ => lib}/crypto/poly1305-glue.c | 0 lib/crypto/Kconfig | 6 +++++ 15 files changed, 62 insertions(+), 36 deletions(-) create mode 100644 arch/arm/lib/crypto/.gitignore create mode 100644 arch/arm/lib/crypto/Kconfig create mode 100644 arch/arm/lib/crypto/Makefile rename arch/arm/{ => lib}/crypto/blake2s-core.S (100%) rename arch/arm/{ => lib}/crypto/blake2s-glue.c (100%) rename arch/arm/{ => lib}/crypto/chacha-glue.c (100%) rename arch/arm/{ => lib}/crypto/chacha-neon-core.S (100%) rename arch/arm/{ => lib}/crypto/chacha-scalar-core.S (100%) rename arch/arm/{ => lib}/crypto/poly1305-armv4.pl (100%) rename arch/arm/{ => lib}/crypto/poly1305-glue.c (100%) diff --git a/MAINTAINERS b/MAINTAINERS index a2604c13f11b4..d0d1968e323aa 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -6286,10 +6286,11 @@ S: Maintained T: git git://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git T: git git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6.git F: Documentation/crypto/ F: Documentation/devicetree/bindings/crypto/ F: arch/*/crypto/ +F: arch/*/lib/crypto/ F: crypto/ F: drivers/crypto/ F: include/crypto/ F: include/linux/crypto* F: lib/crypto/ diff --git a/arch/arm/crypto/Kconfig b/arch/arm/crypto/Kconfig index 3530e7c80793a..1f889d6bab77d 100644 --- a/arch/arm/crypto/Kconfig +++ b/arch/arm/crypto/Kconfig @@ -44,28 +44,10 @@ config CRYPTO_NHPOLY1305_NEON NHPoly1305 hash function (Adiantum) Architecture: arm using: - NEON (Advanced SIMD) extensions -config CRYPTO_POLY1305_ARM - tristate - select CRYPTO_ARCH_HAVE_LIB_POLY1305 - default CRYPTO_LIB_POLY1305_INTERNAL - -config CRYPTO_BLAKE2S_ARM - bool "Hash functions: BLAKE2s" - select CRYPTO_ARCH_HAVE_LIB_BLAKE2S - help - BLAKE2s cryptographic hash function (RFC 7693) - - Architecture: arm - - This is faster than the generic implementations of BLAKE2s and - BLAKE2b, but slower than the NEON implementation of BLAKE2b. - There is no NEON implementation of BLAKE2s, since NEON doesn't - really help with it. - config CRYPTO_BLAKE2B_NEON tristate "Hash functions: BLAKE2b (NEON)" depends on KERNEL_MODE_NEON select CRYPTO_BLAKE2B help @@ -204,12 +186,7 @@ config CRYPTO_AES_ARM_CE and IEEE 1619) Architecture: arm using: - ARMv8 Crypto Extensions -config CRYPTO_CHACHA20_NEON - tristate - select CRYPTO_ARCH_HAVE_LIB_CHACHA - default CRYPTO_LIB_CHACHA_INTERNAL - endmenu diff --git a/arch/arm/crypto/Makefile b/arch/arm/crypto/Makefile index 3d0e23ff9e746..ecabe6603e080 100644 --- a/arch/arm/crypto/Makefile +++ b/arch/arm/crypto/Makefile @@ -7,14 +7,11 @@ obj-$(CONFIG_CRYPTO_AES_ARM) += aes-arm.o obj-$(CONFIG_CRYPTO_AES_ARM_BS) += aes-arm-bs.o obj-$(CONFIG_CRYPTO_SHA1_ARM) += sha1-arm.o obj-$(CONFIG_CRYPTO_SHA1_ARM_NEON) += sha1-arm-neon.o obj-$(CONFIG_CRYPTO_SHA256_ARM) += sha256-arm.o obj-$(CONFIG_CRYPTO_SHA512_ARM) += sha512-arm.o -obj-$(CONFIG_CRYPTO_BLAKE2S_ARM) += libblake2s-arm.o obj-$(CONFIG_CRYPTO_BLAKE2B_NEON) += blake2b-neon.o -obj-$(CONFIG_CRYPTO_CHACHA20_NEON) += chacha-neon.o -obj-$(CONFIG_CRYPTO_POLY1305_ARM) += poly1305-arm.o obj-$(CONFIG_CRYPTO_NHPOLY1305_NEON) += nhpoly1305-neon.o obj-$(CONFIG_CRYPTO_CURVE25519_NEON) += curve25519-neon.o obj-$(CONFIG_CRYPTO_AES_ARM_CE) += aes-arm-ce.o obj-$(CONFIG_CRYPTO_SHA1_ARM_CE) += sha1-arm-ce.o @@ -27,34 +24,25 @@ sha1-arm-y := sha1-armv4-large.o sha1_glue.o sha1-arm-neon-y := sha1-armv7-neon.o sha1_neon_glue.o sha256-arm-neon-$(CONFIG_KERNEL_MODE_NEON) := sha256_neon_glue.o sha256-arm-y := sha256-core.o sha256_glue.o $(sha256-arm-neon-y) sha512-arm-neon-$(CONFIG_KERNEL_MODE_NEON) := sha512-neon-glue.o sha512-arm-y := sha512-core.o sha512-glue.o $(sha512-arm-neon-y) -libblake2s-arm-y:= blake2s-core.o blake2s-glue.o blake2b-neon-y := blake2b-neon-core.o blake2b-neon-glue.o sha1-arm-ce-y := sha1-ce-core.o sha1-ce-glue.o sha2-arm-ce-y := sha2-ce-core.o sha2-ce-glue.o aes-arm-ce-y := aes-ce-core.o aes-ce-glue.o ghash-arm-ce-y := ghash-ce-core.o ghash-ce-glue.o -chacha-neon-y := chacha-scalar-core.o chacha-glue.o -chacha-neon-$(CONFIG_KERNEL_MODE_NEON) += chacha-neon-core.o -poly1305-arm-y := poly1305-core.o poly1305-glue.o nhpoly1305-neon-y := nh-neon-core.o nhpoly1305-neon-glue.o curve25519-neon-y := curve25519-core.o curve25519-glue.o quiet_cmd_perl = PERL $@ cmd_perl = $(PERL) $(<) > $(@) $(obj)/%-core.S: $(src)/%-armv4.pl $(call cmd,perl) -clean-files += poly1305-core.S sha256-core.S sha512-core.S +clean-files += sha256-core.S sha512-core.S aflags-thumb2-$(CONFIG_THUMB2_KERNEL) := -U__thumb2__ -D__thumb2__=1 AFLAGS_sha256-core.o += $(aflags-thumb2-y) AFLAGS_sha512-core.o += $(aflags-thumb2-y) - -# massage the perlasm code a bit so we only get the NEON routine if we need it -poly1305-aflags-$(CONFIG_CPU_V7) := -U__LINUX_ARM_ARCH__ -D__LINUX_ARM_ARCH__=5 -poly1305-aflags-$(CONFIG_KERNEL_MODE_NEON) := -U__LINUX_ARM_ARCH__ -D__LINUX_ARM_ARCH__=7 -AFLAGS_poly1305-core.o += $(poly1305-aflags-y) $(aflags-thumb2-y) diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile index 007874320937d..39ffabd3cf2a2 100644 --- a/arch/arm/lib/Makefile +++ b/arch/arm/lib/Makefile @@ -3,10 +3,12 @@ # linux/arch/arm/lib/Makefile # # Copyright (C) 1995-2000 Russell King # +obj-y += crypto/ + lib-y := changebit.o csumipv6.o csumpartial.o \ csumpartialcopy.o csumpartialcopyuser.o clearbit.o \ delay.o delay-loop.o findbit.o memchr.o memcpy.o \ memmove.o memset.o setbit.o \ strchr.o strrchr.o \ diff --git a/arch/arm/lib/crypto/.gitignore b/arch/arm/lib/crypto/.gitignore new file mode 100644 index 0000000000000..0d47d4f21c6de --- /dev/null +++ b/arch/arm/lib/crypto/.gitignore @@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0-only +poly1305-core.S diff --git a/arch/arm/lib/crypto/Kconfig b/arch/arm/lib/crypto/Kconfig new file mode 100644 index 0000000000000..181f138d563b6 --- /dev/null +++ b/arch/arm/lib/crypto/Kconfig @@ -0,0 +1,24 @@ +# SPDX-License-Identifier: GPL-2.0-only + +config CRYPTO_BLAKE2S_ARM + bool "Hash functions: BLAKE2s" + select CRYPTO_ARCH_HAVE_LIB_BLAKE2S + help + BLAKE2s cryptographic hash function (RFC 7693) + + Architecture: arm + + This is faster than the generic implementations of BLAKE2s and + BLAKE2b, but slower than the NEON implementation of BLAKE2b. + There is no NEON implementation of BLAKE2s, since NEON doesn't + really help with it. + +config CRYPTO_CHACHA20_NEON + tristate + default CRYPTO_LIB_CHACHA_INTERNAL + select CRYPTO_ARCH_HAVE_LIB_CHACHA + +config CRYPTO_POLY1305_ARM + tristate + default CRYPTO_LIB_POLY1305_INTERNAL + select CRYPTO_ARCH_HAVE_LIB_POLY1305 diff --git a/arch/arm/lib/crypto/Makefile b/arch/arm/lib/crypto/Makefile new file mode 100644 index 0000000000000..4c042a4c77ed6 --- /dev/null +++ b/arch/arm/lib/crypto/Makefile @@ -0,0 +1,26 @@ +# SPDX-License-Identifier: GPL-2.0-only + +obj-$(CONFIG_CRYPTO_BLAKE2S_ARM) += libblake2s-arm.o +libblake2s-arm-y := blake2s-core.o blake2s-glue.o + +obj-$(CONFIG_CRYPTO_CHACHA20_NEON) += chacha-neon.o +chacha-neon-y := chacha-scalar-core.o chacha-glue.o +chacha-neon-$(CONFIG_KERNEL_MODE_NEON) += chacha-neon-core.o + +obj-$(CONFIG_CRYPTO_POLY1305_ARM) += poly1305-arm.o +poly1305-arm-y := poly1305-core.o poly1305-glue.o + +quiet_cmd_perl = PERL $@ + cmd_perl = $(PERL) $(<) > $(@) + +$(obj)/%-core.S: $(src)/%-armv4.pl + $(call cmd,perl) + +clean-files += poly1305-core.S + +aflags-thumb2-$(CONFIG_THUMB2_KERNEL) := -U__thumb2__ -D__thumb2__=1 + +# massage the perlasm code a bit so we only get the NEON routine if we need it +poly1305-aflags-$(CONFIG_CPU_V7) := -U__LINUX_ARM_ARCH__ -D__LINUX_ARM_ARCH__=5 +poly1305-aflags-$(CONFIG_KERNEL_MODE_NEON) := -U__LINUX_ARM_ARCH__ -D__LINUX_ARM_ARCH__=7 +AFLAGS_poly1305-core.o += $(poly1305-aflags-y) $(aflags-thumb2-y) diff --git a/arch/arm/crypto/blake2s-core.S b/arch/arm/lib/crypto/blake2s-core.S similarity index 100% rename from arch/arm/crypto/blake2s-core.S rename to arch/arm/lib/crypto/blake2s-core.S diff --git a/arch/arm/crypto/blake2s-glue.c b/arch/arm/lib/crypto/blake2s-glue.c similarity index 100% rename from arch/arm/crypto/blake2s-glue.c rename to arch/arm/lib/crypto/blake2s-glue.c diff --git a/arch/arm/crypto/chacha-glue.c b/arch/arm/lib/crypto/chacha-glue.c similarity index 100% rename from arch/arm/crypto/chacha-glue.c rename to arch/arm/lib/crypto/chacha-glue.c diff --git a/arch/arm/crypto/chacha-neon-core.S b/arch/arm/lib/crypto/chacha-neon-core.S similarity index 100% rename from arch/arm/crypto/chacha-neon-core.S rename to arch/arm/lib/crypto/chacha-neon-core.S diff --git a/arch/arm/crypto/chacha-scalar-core.S b/arch/arm/lib/crypto/chacha-scalar-core.S similarity index 100% rename from arch/arm/crypto/chacha-scalar-core.S rename to arch/arm/lib/crypto/chacha-scalar-core.S diff --git a/arch/arm/crypto/poly1305-armv4.pl b/arch/arm/lib/crypto/poly1305-armv4.pl similarity index 100% rename from arch/arm/crypto/poly1305-armv4.pl rename to arch/arm/lib/crypto/poly1305-armv4.pl diff --git a/arch/arm/crypto/poly1305-glue.c b/arch/arm/lib/crypto/poly1305-glue.c similarity index 100% rename from arch/arm/crypto/poly1305-glue.c rename to arch/arm/lib/crypto/poly1305-glue.c diff --git a/lib/crypto/Kconfig b/lib/crypto/Kconfig index 2c6ab80e0cdc4..59135009e4f02 100644 --- a/lib/crypto/Kconfig +++ b/lib/crypto/Kconfig @@ -153,6 +153,12 @@ config CRYPTO_LIB_SHA256 tristate config CRYPTO_LIB_SM3 tristate +if !KMSAN # avoid false positives from assembly +if ARM +source "arch/arm/lib/crypto/Kconfig" +endif +endif + endmenu From patchwork Tue Apr 22 15:27:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 883264 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 09450292917; Tue, 22 Apr 2025 15:28:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745335698; cv=none; b=D4EFSQfNz9fJ+31x4z+SU6nsnDI9JPsH2T3U19EkBDirnEsIrtYgKb9JyxZBUwAGSiwes0sN6APQyZpbJH4Z//QLdOj5A3bUmZat4v2cyg/nmdLyQDqU6klO1Bro1hif/1ql7rTpibisrCLGlBrbvVFkTTLZPDOpWg6pBV3krPM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745335698; c=relaxed/simple; bh=qN/B6X2mvQN94BK3RyJeOZTVFWohKhnnWgVazqat/cI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EVsjR87/20TDp0s07Ff2VSrraq19DF5FMBEHpkuKhUKrOOOOS0zPghEqUvU8KrvqduLwJtOm6zDrRUB+pMUoSAUXocIXw4jb7IEUC2gO1m0R+/nobuIy+3QVoRICRh25y5s/zy6oz4hlSyuYgne/v/7vY/rLGIr7FdsoWqtx3G0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qCNc0DKF; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="qCNc0DKF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 901F7C4CEF0; Tue, 22 Apr 2025 15:28:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1745335697; bh=qN/B6X2mvQN94BK3RyJeOZTVFWohKhnnWgVazqat/cI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qCNc0DKFbLWtkplqTtT13CfwTQE6PaHVBBB82/X3fpAVVgtphrM7DaoQyH455ZtOA 3od7qCZHN+hjsgHwHoLLaoYUvUy0n4ZLD8MXqabiEQnfE8b0eEYnokQm4XP7Z6lAec EXcafR4+DRXVWUUo+U3YX0MI9revROjD3N+FINWhLx2ySRUQS+CtMP5XWtT7z1Bse+ sWKjSYAtxfBtHbgvbh8/qo8Ii1gZwC22fBFUmufECRvIgkgizSl0vTv5e3ZptSKsYc BMjVjUSfg43cgoox7tDqaWuq1v9tK+qmeq9iIGiYy9qynq949O7WRuHB2Su5l2kxzE OsTl37h8/3eAg== From: Eric Biggers To: linux-crypto@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, x86@kernel.org, "Jason A . Donenfeld" , Ard Biesheuvel Subject: [PATCH v3 07/13] crypto: mips - move library functions to arch/mips/lib/crypto/ Date: Tue, 22 Apr 2025 08:27:10 -0700 Message-ID: <20250422152716.5923-8-ebiggers@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250422152716.5923-1-ebiggers@kernel.org> References: <20250422152716.5923-1-ebiggers@kernel.org> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Eric Biggers Continue disentangling the crypto library functions from the generic crypto infrastructure by moving the mips ChaCha and Poly1305 library functions into a new directory arch/mips/lib/crypto/ that does not depend on CRYPTO. This mirrors the distinction between crypto/ and lib/crypto/. Signed-off-by: Eric Biggers --- arch/mips/crypto/Kconfig | 11 ----------- arch/mips/crypto/Makefile | 17 ----------------- arch/mips/lib/Makefile | 2 ++ arch/mips/lib/crypto/.gitignore | 2 ++ arch/mips/lib/crypto/Kconfig | 12 ++++++++++++ arch/mips/lib/crypto/Makefile | 19 +++++++++++++++++++ arch/mips/{ => lib}/crypto/chacha-core.S | 0 arch/mips/{ => lib}/crypto/chacha-glue.c | 0 arch/mips/{ => lib}/crypto/poly1305-glue.c | 0 arch/mips/{ => lib}/crypto/poly1305-mips.pl | 0 lib/crypto/Kconfig | 3 +++ 11 files changed, 38 insertions(+), 28 deletions(-) create mode 100644 arch/mips/lib/crypto/.gitignore create mode 100644 arch/mips/lib/crypto/Kconfig create mode 100644 arch/mips/lib/crypto/Makefile rename arch/mips/{ => lib}/crypto/chacha-core.S (100%) rename arch/mips/{ => lib}/crypto/chacha-glue.c (100%) rename arch/mips/{ => lib}/crypto/poly1305-glue.c (100%) rename arch/mips/{ => lib}/crypto/poly1305-mips.pl (100%) diff --git a/arch/mips/crypto/Kconfig b/arch/mips/crypto/Kconfig index 8283664a1f24b..9db1fd6d9f0e0 100644 --- a/arch/mips/crypto/Kconfig +++ b/arch/mips/crypto/Kconfig @@ -1,14 +1,9 @@ # SPDX-License-Identifier: GPL-2.0 menu "Accelerated Cryptographic Algorithms for CPU (mips)" -config CRYPTO_POLY1305_MIPS - tristate - select CRYPTO_ARCH_HAVE_LIB_POLY1305 - default CRYPTO_LIB_POLY1305_INTERNAL - config CRYPTO_MD5_OCTEON tristate "Digests: MD5 (OCTEON)" depends on CPU_CAVIUM_OCTEON select CRYPTO_MD5 select CRYPTO_HASH @@ -45,12 +40,6 @@ config CRYPTO_SHA512_OCTEON help SHA-384 and SHA-512 secure hash algorithms (FIPS 180) Architecture: mips OCTEON using crypto instructions, when available -config CRYPTO_CHACHA_MIPS - tristate - depends on CPU_MIPS32_R2 - select CRYPTO_ARCH_HAVE_LIB_CHACHA - default CRYPTO_LIB_CHACHA_INTERNAL - endmenu diff --git a/arch/mips/crypto/Makefile b/arch/mips/crypto/Makefile index fddc882814123..5adb631a69c18 100644 --- a/arch/mips/crypto/Makefile +++ b/arch/mips/crypto/Makefile @@ -1,22 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 # # Makefile for MIPS crypto files.. # -obj-$(CONFIG_CRYPTO_CHACHA_MIPS) += chacha-mips.o -chacha-mips-y := chacha-core.o chacha-glue.o -AFLAGS_chacha-core.o += -O2 # needed to fill branch delay slots - -obj-$(CONFIG_CRYPTO_POLY1305_MIPS) += poly1305-mips.o -poly1305-mips-y := poly1305-core.o poly1305-glue.o - -perlasm-flavour-$(CONFIG_32BIT) := o32 -perlasm-flavour-$(CONFIG_64BIT) := 64 - -quiet_cmd_perlasm = PERLASM $@ - cmd_perlasm = $(PERL) $(<) $(perlasm-flavour-y) $(@) - -$(obj)/poly1305-core.S: $(src)/poly1305-mips.pl FORCE - $(call if_changed,perlasm) - -targets += poly1305-core.S diff --git a/arch/mips/lib/Makefile b/arch/mips/lib/Makefile index 9c024e6d5e54c..9d75845ef78e1 100644 --- a/arch/mips/lib/Makefile +++ b/arch/mips/lib/Makefile @@ -1,10 +1,12 @@ # SPDX-License-Identifier: GPL-2.0 # # Makefile for MIPS-specific library files.. # +obj-y += crypto/ + lib-y += bitops.o csum_partial.o delay.o memcpy.o memset.o \ mips-atomic.o strncpy_user.o \ strnlen_user.o uncached.o obj-y += iomap_copy.o diff --git a/arch/mips/lib/crypto/.gitignore b/arch/mips/lib/crypto/.gitignore new file mode 100644 index 0000000000000..0d47d4f21c6de --- /dev/null +++ b/arch/mips/lib/crypto/.gitignore @@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0-only +poly1305-core.S diff --git a/arch/mips/lib/crypto/Kconfig b/arch/mips/lib/crypto/Kconfig new file mode 100644 index 0000000000000..5b82ba753c55c --- /dev/null +++ b/arch/mips/lib/crypto/Kconfig @@ -0,0 +1,12 @@ +# SPDX-License-Identifier: GPL-2.0-only + +config CRYPTO_CHACHA_MIPS + tristate + depends on CPU_MIPS32_R2 + default CRYPTO_LIB_CHACHA_INTERNAL + select CRYPTO_ARCH_HAVE_LIB_CHACHA + +config CRYPTO_POLY1305_MIPS + tristate + default CRYPTO_LIB_POLY1305_INTERNAL + select CRYPTO_ARCH_HAVE_LIB_POLY1305 diff --git a/arch/mips/lib/crypto/Makefile b/arch/mips/lib/crypto/Makefile new file mode 100644 index 0000000000000..804488c7adedc --- /dev/null +++ b/arch/mips/lib/crypto/Makefile @@ -0,0 +1,19 @@ +# SPDX-License-Identifier: GPL-2.0-only + +obj-$(CONFIG_CRYPTO_CHACHA_MIPS) += chacha-mips.o +chacha-mips-y := chacha-core.o chacha-glue.o +AFLAGS_chacha-core.o += -O2 # needed to fill branch delay slots + +obj-$(CONFIG_CRYPTO_POLY1305_MIPS) += poly1305-mips.o +poly1305-mips-y := poly1305-core.o poly1305-glue.o + +perlasm-flavour-$(CONFIG_32BIT) := o32 +perlasm-flavour-$(CONFIG_64BIT) := 64 + +quiet_cmd_perlasm = PERLASM $@ + cmd_perlasm = $(PERL) $(<) $(perlasm-flavour-y) $(@) + +$(obj)/poly1305-core.S: $(src)/poly1305-mips.pl FORCE + $(call if_changed,perlasm) + +targets += poly1305-core.S diff --git a/arch/mips/crypto/chacha-core.S b/arch/mips/lib/crypto/chacha-core.S similarity index 100% rename from arch/mips/crypto/chacha-core.S rename to arch/mips/lib/crypto/chacha-core.S diff --git a/arch/mips/crypto/chacha-glue.c b/arch/mips/lib/crypto/chacha-glue.c similarity index 100% rename from arch/mips/crypto/chacha-glue.c rename to arch/mips/lib/crypto/chacha-glue.c diff --git a/arch/mips/crypto/poly1305-glue.c b/arch/mips/lib/crypto/poly1305-glue.c similarity index 100% rename from arch/mips/crypto/poly1305-glue.c rename to arch/mips/lib/crypto/poly1305-glue.c diff --git a/arch/mips/crypto/poly1305-mips.pl b/arch/mips/lib/crypto/poly1305-mips.pl similarity index 100% rename from arch/mips/crypto/poly1305-mips.pl rename to arch/mips/lib/crypto/poly1305-mips.pl diff --git a/lib/crypto/Kconfig b/lib/crypto/Kconfig index 7395234d654b7..c5c01bc3569d5 100644 --- a/lib/crypto/Kconfig +++ b/lib/crypto/Kconfig @@ -160,8 +160,11 @@ if ARM source "arch/arm/lib/crypto/Kconfig" endif if ARM64 source "arch/arm64/lib/crypto/Kconfig" endif +if MIPS +source "arch/mips/lib/crypto/Kconfig" +endif endif endmenu From patchwork Tue Apr 22 15:27:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 883262 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C350A2949F5; Tue, 22 Apr 2025 15:28:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745335699; cv=none; b=DgF0+pgX84bG4+OQXQZu9aWfPiLagcGfxKEmOWBQ/I8tnCQ+FCumd77xDOfQX9dLkj/3AaT1EaAmIrh+QUELKIHcqvdzzVzkCXMVAXY3Aw1bkg1LYuIm7RwSPf+mEGzy6NrDUzIBrK4hmicaeaTw/bkAul4H00TtvpcURymymFU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745335699; c=relaxed/simple; bh=ki6Sn/ee5qgO3vhh3ZkrojeEv770iQQrw7Ukhfk4zI8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UIsAeBm3fUpFTEZKSLP/xGMufrUzUXnzow5Y7UEOfhOG6EtiKlew3bJVY+EQJIeLI4j+H/d6FjwZAPUqppEdCnz3iqqunWk9apY1Fh2rPPU2+TTFdvo7dOq7K3MCLIO3KOaCFQJlpGUroW+45Qhj6jTf0WIyH7CKu1kiCJFYpa4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cKwMSXyS; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cKwMSXyS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 04868C4CEF0; Tue, 22 Apr 2025 15:28:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1745335699; bh=ki6Sn/ee5qgO3vhh3ZkrojeEv770iQQrw7Ukhfk4zI8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cKwMSXyShmoHoJUgBOV9El8W3aUBH6B0Lz2ReK5Ym+/HXRopKgkn01mXIoaJjRjWO Rmyc7OlIJeA+Jq8fnsi9olY+0Z6qJ33MBan8XAwwZU15EexRsxco6jYkVAJpbmWUdw k0W+pKj3tOJd9n0K/kF93dD+ZqWixWfdWR2iEC2blBH7niDgSzB+Eab1g9SkEPXWPK miq+8VeFRIDQ9eKZZ6SRyjXnnrGZwZBPk4rcz3Zml+i3s+36nIv/RasGxrNX1GI9of Wo4JYKUEfdCTsdGvzQWPi78zsaclbLaPDuWsc2OgCOInv7zjSeKx10axodSTGDrhSh yIGZqaS1xAWdQ== From: Eric Biggers To: linux-crypto@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, x86@kernel.org, "Jason A . Donenfeld" , Ard Biesheuvel , Heiko Carstens Subject: [PATCH v3 10/13] crypto: s390 - move library functions to arch/s390/lib/crypto/ Date: Tue, 22 Apr 2025 08:27:13 -0700 Message-ID: <20250422152716.5923-11-ebiggers@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250422152716.5923-1-ebiggers@kernel.org> References: <20250422152716.5923-1-ebiggers@kernel.org> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Eric Biggers Continue disentangling the crypto library functions from the generic crypto infrastructure by moving the s390 ChaCha library functions into a new directory arch/s390/lib/crypto/ that does not depend on CRYPTO. This mirrors the distinction between crypto/ and lib/crypto/. Acked-by: Heiko Carstens Signed-off-by: Eric Biggers --- arch/s390/crypto/Kconfig | 6 ------ arch/s390/crypto/Makefile | 3 --- arch/s390/lib/Makefile | 1 + arch/s390/lib/crypto/Kconfig | 7 +++++++ arch/s390/lib/crypto/Makefile | 4 ++++ arch/s390/{ => lib}/crypto/chacha-glue.c | 0 arch/s390/{ => lib}/crypto/chacha-s390.S | 0 arch/s390/{ => lib}/crypto/chacha-s390.h | 0 lib/crypto/Kconfig | 3 +++ 9 files changed, 15 insertions(+), 9 deletions(-) create mode 100644 arch/s390/lib/crypto/Kconfig create mode 100644 arch/s390/lib/crypto/Makefile rename arch/s390/{ => lib}/crypto/chacha-glue.c (100%) rename arch/s390/{ => lib}/crypto/chacha-s390.S (100%) rename arch/s390/{ => lib}/crypto/chacha-s390.h (100%) diff --git a/arch/s390/crypto/Kconfig b/arch/s390/crypto/Kconfig index e88d9cd256ef5..a2bfd6eef0ca3 100644 --- a/arch/s390/crypto/Kconfig +++ b/arch/s390/crypto/Kconfig @@ -97,16 +97,10 @@ config CRYPTO_DES_S390 Architecture: s390 As of z990 the ECB and CBC mode are hardware accelerated. As of z196 the CTR mode is hardware accelerated. -config CRYPTO_CHACHA_S390 - tristate - select CRYPTO_LIB_CHACHA_GENERIC - select CRYPTO_ARCH_HAVE_LIB_CHACHA - default CRYPTO_LIB_CHACHA_INTERNAL - config CRYPTO_HMAC_S390 tristate "Keyed-hash message authentication code: HMAC" select CRYPTO_HASH help s390 specific HMAC hardware support for SHA224, SHA256, SHA384 and diff --git a/arch/s390/crypto/Makefile b/arch/s390/crypto/Makefile index 14dafadbcbed4..e3853774e1a3a 100644 --- a/arch/s390/crypto/Makefile +++ b/arch/s390/crypto/Makefile @@ -9,12 +9,9 @@ obj-$(CONFIG_CRYPTO_SHA512_S390) += sha512_s390.o sha_common.o obj-$(CONFIG_CRYPTO_SHA3_256_S390) += sha3_256_s390.o sha_common.o obj-$(CONFIG_CRYPTO_SHA3_512_S390) += sha3_512_s390.o sha_common.o obj-$(CONFIG_CRYPTO_DES_S390) += des_s390.o obj-$(CONFIG_CRYPTO_AES_S390) += aes_s390.o obj-$(CONFIG_CRYPTO_PAES_S390) += paes_s390.o -obj-$(CONFIG_CRYPTO_CHACHA_S390) += chacha_s390.o obj-$(CONFIG_S390_PRNG) += prng.o obj-$(CONFIG_CRYPTO_GHASH_S390) += ghash_s390.o obj-$(CONFIG_CRYPTO_HMAC_S390) += hmac_s390.o obj-y += arch_random.o - -chacha_s390-y := chacha-glue.o chacha-s390.o diff --git a/arch/s390/lib/Makefile b/arch/s390/lib/Makefile index 14bbfe50033c7..fce4edbe8a078 100644 --- a/arch/s390/lib/Makefile +++ b/arch/s390/lib/Makefile @@ -1,10 +1,11 @@ # SPDX-License-Identifier: GPL-2.0 # # Makefile for s390-specific library files.. # +obj-y += crypto/ lib-y += delay.o string.o uaccess.o find.o spinlock.o tishift.o lib-y += csum-partial.o obj-y += mem.o xor.o lib-$(CONFIG_KPROBES) += probes.o lib-$(CONFIG_UPROBES) += probes.o diff --git a/arch/s390/lib/crypto/Kconfig b/arch/s390/lib/crypto/Kconfig new file mode 100644 index 0000000000000..b79fd91af9fe1 --- /dev/null +++ b/arch/s390/lib/crypto/Kconfig @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0-only + +config CRYPTO_CHACHA_S390 + tristate + default CRYPTO_LIB_CHACHA_INTERNAL + select CRYPTO_LIB_CHACHA_GENERIC + select CRYPTO_ARCH_HAVE_LIB_CHACHA diff --git a/arch/s390/lib/crypto/Makefile b/arch/s390/lib/crypto/Makefile new file mode 100644 index 0000000000000..06c2cf77178ef --- /dev/null +++ b/arch/s390/lib/crypto/Makefile @@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0-only + +obj-$(CONFIG_CRYPTO_CHACHA_S390) += chacha_s390.o +chacha_s390-y := chacha-glue.o chacha-s390.o diff --git a/arch/s390/crypto/chacha-glue.c b/arch/s390/lib/crypto/chacha-glue.c similarity index 100% rename from arch/s390/crypto/chacha-glue.c rename to arch/s390/lib/crypto/chacha-glue.c diff --git a/arch/s390/crypto/chacha-s390.S b/arch/s390/lib/crypto/chacha-s390.S similarity index 100% rename from arch/s390/crypto/chacha-s390.S rename to arch/s390/lib/crypto/chacha-s390.S diff --git a/arch/s390/crypto/chacha-s390.h b/arch/s390/lib/crypto/chacha-s390.h similarity index 100% rename from arch/s390/crypto/chacha-s390.h rename to arch/s390/lib/crypto/chacha-s390.h diff --git a/lib/crypto/Kconfig b/lib/crypto/Kconfig index 0b06c25eb38a5..db19a7acc2fbf 100644 --- a/lib/crypto/Kconfig +++ b/lib/crypto/Kconfig @@ -169,8 +169,11 @@ if PPC source "arch/powerpc/lib/crypto/Kconfig" endif if RISCV source "arch/riscv/lib/crypto/Kconfig" endif +if S390 +source "arch/s390/lib/crypto/Kconfig" +endif endif endmenu From patchwork Tue Apr 22 15:27:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 883261 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D4EF2296158; Tue, 22 Apr 2025 15:28:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745335701; cv=none; b=WgEry9hTwH3hMWE3yDMo4RY2/eGBEscGHi4SxZ2LZ0ARRBg5H5e7zCPwyMZOM9JCN8XfOvt3Jy3MZiV2rXD4l+3L+5nuBoJRtWOgpWTxw/glhTKWqtUJikytYerqQvNHOg7/18Ptkq/FdzGFcx32GpS0SQHv+QHcNQK0Ds+WZLo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745335701; c=relaxed/simple; bh=/KmscafjzVVui9ZfhF2V3SnpWNzO/mZrkUglchVeyKA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nbxKqvcjq3NQy1/UUFofHhSRfitIc6is2b1aBuYXaH0bPxj6B52tBDVoCEW9CccDDqdXX1XKd5PbjSl4D3MK1aqieMQbK8gQk4cMuOFK9A5n7WUTv3AWLOtzTHFIo6q4PSQC/JmqjhhpYaiXHgNbbewzx7mWpHMKj4LWxUc8Hmc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TuNjZ/SJ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TuNjZ/SJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F0297C4CEEC; Tue, 22 Apr 2025 15:28:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1745335700; bh=/KmscafjzVVui9ZfhF2V3SnpWNzO/mZrkUglchVeyKA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TuNjZ/SJrEzQtsB5ZEn+Yk2JTaA2nrQbL/H1czw0XJaW8aTEfRMfEWhAxoPC1Ta53 lhvGkQgr5r2iGqLIT1t/I40hBfAjG3jEximHUObEJemAtwyB9JaWUj2STMJG7vAKSd jD8oyoPjpImTzR4sCm7icQMcg1YCa2D63b9Dv6AIfTmeF9iwTobfCvrXgQQgY8/h+6 0bE3bYb+vQTvq2CQnMwq50TMtXNObtXXyDZ0RL0MildTJVYCrwCBi8cdV1zHKjtmUE DFCpeD8EAO1jExvckOxytr7efqi9TiKmOMdMuDRVOUT3DoW8p628+E6qMLvOJ8DNiM iG3CBdLj+sZTA== From: Eric Biggers To: linux-crypto@vger.kernel.org Cc: linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, x86@kernel.org, "Jason A . Donenfeld" , Ard Biesheuvel Subject: [PATCH v3 12/13] crypto: lib/chacha - remove INTERNAL symbol and selection of CRYPTO Date: Tue, 22 Apr 2025 08:27:15 -0700 Message-ID: <20250422152716.5923-13-ebiggers@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250422152716.5923-1-ebiggers@kernel.org> References: <20250422152716.5923-1-ebiggers@kernel.org> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Eric Biggers Now that the architecture-optimized ChaCha kconfig symbols are defined regardless of CRYPTO, there is no need for CRYPTO_LIB_CHACHA to select CRYPTO. So, remove that. This makes the indirection through the CRYPTO_LIB_CHACHA_INTERNAL symbol unnecessary, so get rid of that and just use CRYPTO_LIB_CHACHA directly. Finally, make the fallback to the generic implementation use a default value instead of a select; this makes it consistent with how the arch-optimized code gets enabled and also with how CRYPTO_LIB_BLAKE2S_GENERIC gets enabled. Signed-off-by: Eric Biggers --- arch/arm/lib/crypto/Kconfig | 2 +- arch/arm64/lib/crypto/Kconfig | 2 +- arch/mips/lib/crypto/Kconfig | 2 +- arch/powerpc/lib/crypto/Kconfig | 2 +- arch/riscv/lib/crypto/Kconfig | 2 +- arch/s390/lib/crypto/Kconfig | 2 +- arch/x86/lib/crypto/Kconfig | 2 +- crypto/Kconfig | 2 +- lib/crypto/Kconfig | 16 +++++----------- 9 files changed, 13 insertions(+), 19 deletions(-) diff --git a/arch/arm/lib/crypto/Kconfig b/arch/arm/lib/crypto/Kconfig index 181f138d563b6..5d10bd13fc8df 100644 --- a/arch/arm/lib/crypto/Kconfig +++ b/arch/arm/lib/crypto/Kconfig @@ -13,11 +13,11 @@ config CRYPTO_BLAKE2S_ARM There is no NEON implementation of BLAKE2s, since NEON doesn't really help with it. config CRYPTO_CHACHA20_NEON tristate - default CRYPTO_LIB_CHACHA_INTERNAL + default CRYPTO_LIB_CHACHA select CRYPTO_ARCH_HAVE_LIB_CHACHA config CRYPTO_POLY1305_ARM tristate default CRYPTO_LIB_POLY1305_INTERNAL diff --git a/arch/arm64/lib/crypto/Kconfig b/arch/arm64/lib/crypto/Kconfig index 169311547efe3..2a8ff7cfc08d3 100644 --- a/arch/arm64/lib/crypto/Kconfig +++ b/arch/arm64/lib/crypto/Kconfig @@ -1,11 +1,11 @@ # SPDX-License-Identifier: GPL-2.0-only config CRYPTO_CHACHA20_NEON tristate depends on KERNEL_MODE_NEON - default CRYPTO_LIB_CHACHA_INTERNAL + default CRYPTO_LIB_CHACHA select CRYPTO_LIB_CHACHA_GENERIC select CRYPTO_ARCH_HAVE_LIB_CHACHA config CRYPTO_POLY1305_NEON tristate diff --git a/arch/mips/lib/crypto/Kconfig b/arch/mips/lib/crypto/Kconfig index 5b82ba753c55c..454354e30d76c 100644 --- a/arch/mips/lib/crypto/Kconfig +++ b/arch/mips/lib/crypto/Kconfig @@ -1,11 +1,11 @@ # SPDX-License-Identifier: GPL-2.0-only config CRYPTO_CHACHA_MIPS tristate depends on CPU_MIPS32_R2 - default CRYPTO_LIB_CHACHA_INTERNAL + default CRYPTO_LIB_CHACHA select CRYPTO_ARCH_HAVE_LIB_CHACHA config CRYPTO_POLY1305_MIPS tristate default CRYPTO_LIB_POLY1305_INTERNAL diff --git a/arch/powerpc/lib/crypto/Kconfig b/arch/powerpc/lib/crypto/Kconfig index 3f52610e45eb4..6627d28cd24e0 100644 --- a/arch/powerpc/lib/crypto/Kconfig +++ b/arch/powerpc/lib/crypto/Kconfig @@ -1,11 +1,11 @@ # SPDX-License-Identifier: GPL-2.0-only config CRYPTO_CHACHA20_P10 tristate depends on PPC64 && CPU_LITTLE_ENDIAN && VSX - default CRYPTO_LIB_CHACHA_INTERNAL + default CRYPTO_LIB_CHACHA select CRYPTO_LIB_CHACHA_GENERIC select CRYPTO_ARCH_HAVE_LIB_CHACHA config CRYPTO_POLY1305_P10 tristate diff --git a/arch/riscv/lib/crypto/Kconfig b/arch/riscv/lib/crypto/Kconfig index 46ce2a7ac1f2c..bc7a43f33eb3a 100644 --- a/arch/riscv/lib/crypto/Kconfig +++ b/arch/riscv/lib/crypto/Kconfig @@ -1,8 +1,8 @@ # SPDX-License-Identifier: GPL-2.0-only config CRYPTO_CHACHA_RISCV64 tristate depends on 64BIT && RISCV_ISA_V && TOOLCHAIN_HAS_VECTOR_CRYPTO - default CRYPTO_LIB_CHACHA_INTERNAL + default CRYPTO_LIB_CHACHA select CRYPTO_ARCH_HAVE_LIB_CHACHA select CRYPTO_LIB_CHACHA_GENERIC diff --git a/arch/s390/lib/crypto/Kconfig b/arch/s390/lib/crypto/Kconfig index b79fd91af9fe1..069b355fe51aa 100644 --- a/arch/s390/lib/crypto/Kconfig +++ b/arch/s390/lib/crypto/Kconfig @@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only config CRYPTO_CHACHA_S390 tristate - default CRYPTO_LIB_CHACHA_INTERNAL + default CRYPTO_LIB_CHACHA select CRYPTO_LIB_CHACHA_GENERIC select CRYPTO_ARCH_HAVE_LIB_CHACHA diff --git a/arch/x86/lib/crypto/Kconfig b/arch/x86/lib/crypto/Kconfig index f83aa51dd9129..e44403d9677f5 100644 --- a/arch/x86/lib/crypto/Kconfig +++ b/arch/x86/lib/crypto/Kconfig @@ -13,11 +13,11 @@ config CRYPTO_BLAKE2S_X86 - AVX-512 (Advanced Vector Extensions-512) config CRYPTO_CHACHA20_X86_64 tristate depends on 64BIT - default CRYPTO_LIB_CHACHA_INTERNAL + default CRYPTO_LIB_CHACHA select CRYPTO_LIB_CHACHA_GENERIC select CRYPTO_ARCH_HAVE_LIB_CHACHA config CRYPTO_POLY1305_X86_64 tristate diff --git a/crypto/Kconfig b/crypto/Kconfig index 9322e42e562de..832af6363951f 100644 --- a/crypto/Kconfig +++ b/crypto/Kconfig @@ -632,12 +632,12 @@ config CRYPTO_ARC4 WEP, but it should not be for other purposes because of the weakness of the algorithm. config CRYPTO_CHACHA20 tristate "ChaCha" + select CRYPTO_LIB_CHACHA select CRYPTO_LIB_CHACHA_GENERIC - select CRYPTO_LIB_CHACHA_INTERNAL select CRYPTO_SKCIPHER help The ChaCha20, XChaCha20, and XChaCha12 stream cipher algorithms ChaCha20 is a 256-bit high-speed stream cipher designed by Daniel J. diff --git a/lib/crypto/Kconfig b/lib/crypto/Kconfig index f321fe1a8681b..c6ab724c1dbd9 100644 --- a/lib/crypto/Kconfig +++ b/lib/crypto/Kconfig @@ -48,26 +48,20 @@ config CRYPTO_ARCH_HAVE_LIB_CHACHA accelerated implementation of the ChaCha library interface, either builtin or as a module. config CRYPTO_LIB_CHACHA_GENERIC tristate + default CRYPTO_LIB_CHACHA if !CRYPTO_ARCH_HAVE_LIB_CHACHA select CRYPTO_LIB_UTILS help - This symbol can be depended upon by arch implementations of the - ChaCha library interface that require the generic code as a - fallback, e.g., for SIMD implementations. If no arch specific - 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 + This symbol can be selected by arch implementations of the ChaCha + library interface that require the generic code as a fallback, e.g., + for SIMD implementations. If no arch specific implementation is + enabled, this implementation serves the users of CRYPTO_LIB_CHACHA. config CRYPTO_LIB_CHACHA tristate - select CRYPTO - select CRYPTO_LIB_CHACHA_INTERNAL 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.