From patchwork Sun Apr 20 19:25:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 882799 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 1A46C2147E6; Sun, 20 Apr 2025 19:27:37 +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=1745177258; cv=none; b=chndl2t9DrSRKiQTn6aEDpLYa4trqBoxQmU0CDPKK8QtUMIqYYhDxt29aZgrdkLITy4NqUcWAzXPpfcWQjZNpiKGRokPMQGMNalb645MXKKSobt6GsHwAmLgjePdOqovm6OmsNH4pC2huChBB1OMMTxsAl/50Y8B3A1DFf1Je/k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745177258; c=relaxed/simple; bh=ySujzJwEjUZrj9er8XlrWX/11KoXjZIlZ2vhV5/jq10=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Kg+jgBV+tGceGep+dv7oitBlvYGRmrCQDnGrPlIIB6Nlvwem8ki8gE1ehEMFk0jXP117ow+lXYVT0dDbWdwUcWmOKWyQNkQcEKMjHRsowPqHAUVERYZ5dlpqdP4HU31airJL/QlzExdCFNaVuenUjF6MgzQJsVXt66mml+xt6cQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=o9TI7aC0; 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="o9TI7aC0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4A345C4CEF0; Sun, 20 Apr 2025 19:27:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1745177257; bh=ySujzJwEjUZrj9er8XlrWX/11KoXjZIlZ2vhV5/jq10=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o9TI7aC0W6sDFYjdwFetT0Htr1lKbZ7CRIb92PqjTlyPCPRl834rlsPq4Upa7TwVU KUK3O17RKKGtV9jgwuXyKmuOVSZQqgsouS72xWZ2DXYXR2p3aaop7Z/twb1Pp2xNrh VSR8kglU79GjgMfqghQnbKAFMEFT6wrVHmrnbFNrAdKrNv8Ow9NZ1Wk+PQCHs+Ubwf 05CeLhHFtz4u9QqW+2DLK5sXGu72F+lpuVxsqScpn5fKKuKiGEaQkcwCdA9aHHDDv0 KmyWrMC+UAVURp3ysmv/Bn5eXgycy3Jqe2p8DBklv3xLuCGcbUhveQqhNiOlXVgRYj y//Xcbxc8AzVw== 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 v2 01/13] crypto: arm64 - drop redundant dependencies on ARM64 Date: Sun, 20 Apr 2025 12:25:57 -0700 Message-ID: <20250420192609.295075-2-ebiggers@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250420192609.295075-1-ebiggers@kernel.org> References: <20250420192609.295075-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/arm64/crypto/Kconfig is sourced only when CONFIG_ARM64=y, so there is no need for the symbols defined inside it to depend on ARM64. Acked-by: Ard Biesheuvel Signed-off-by: Eric Biggers --- arch/arm64/crypto/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/crypto/Kconfig b/arch/arm64/crypto/Kconfig index 7c2f63f2e3072..704d0b7e1d137 100644 --- a/arch/arm64/crypto/Kconfig +++ b/arch/arm64/crypto/Kconfig @@ -135,11 +135,11 @@ config CRYPTO_AES_ARM64 Architecture: arm64 config CRYPTO_AES_ARM64_CE tristate "Ciphers: AES (ARMv8 Crypto Extensions)" - depends on ARM64 && KERNEL_MODE_NEON + depends on KERNEL_MODE_NEON select CRYPTO_ALGAPI select CRYPTO_LIB_AES help Block ciphers: AES cipher algorithms (FIPS-197) @@ -252,11 +252,11 @@ config CRYPTO_SM4_ARM64_NEON_BLK Architecture: arm64 using: - NEON (Advanced SIMD) extensions config CRYPTO_AES_ARM64_CE_CCM tristate "AEAD cipher: AES in CCM mode (ARMv8 Crypto Extensions)" - depends on ARM64 && KERNEL_MODE_NEON + depends on KERNEL_MODE_NEON select CRYPTO_ALGAPI select CRYPTO_AES_ARM64_CE select CRYPTO_AES_ARM64_CE_BLK select CRYPTO_AEAD select CRYPTO_LIB_AES From patchwork Sun Apr 20 19:25:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 882798 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 9B8B62147EB; Sun, 20 Apr 2025 19:27:38 +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=1745177258; cv=none; b=hgAGJLyf7g6MiroaDwhzD+zJ5E38a/6H6kuNuEgkyUNGlm90a8JcJZd6FdJPNIj80KuT0CfoCDBh80n2ZelE5w5qAeeOhK6Ks9F/Y3h+SFWfriE1J+c+LgpKig7or+HIvU4N6r9Kk5yctgFWE5IVqghbCWSEsdEgbK8554KNV14= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745177258; c=relaxed/simple; bh=0fs52xVhkpJgVpZDJvGbv9MYJ3m4Z5mmmYA6A5muSpI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=B4jCzDru0EzqHmOKGRRBeuCcHu7BMlkS+FmRQosNHfnbyrC80JpyskndloynXN8n2A9XOzXZ/4qqx1zaVtrqdqN+Zws5VzjOY14EHeXes60lLOufoODJnON7gJis6zi7/R9TMwhzMsXfm4gOmzHo7x2/4ElapL6XxCutLTxZwrA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ON5X492w; 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="ON5X492w" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 33055C4CEEE; Sun, 20 Apr 2025 19:27:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1745177258; bh=0fs52xVhkpJgVpZDJvGbv9MYJ3m4Z5mmmYA6A5muSpI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ON5X492w+kvxjKlQGY1gmSPr8/Hxy60CHAUGMEaz8iqN0VdupswwTrEU3HYeUCg5Z 5GJLBCXqOiiQrxCIHvIYezKn4U42k58ZGeCszwfVdI8S2q7JO0cniv//wN59z8bv2p 98yiJ6Yle3+6SKiSyDh44QrfGrJ/q5eR5t6lgdPmYKSNRJ+qjaTeVyrhrxtxcTIlcX XZ8t2zcLjAS+ULJyANYBgtEq97FVrcWSBRv1A93pslXJRjex560Sdhlx/3Mudr32bM 83lkDLrLPMvyXK5hBL7LahqNgYSuQMpuGTX7npIGAFTlZKMdRjBQc9UJoM/MvMuLVX GwzmCso2fYWEg== 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 v2 03/13] crypto: s390 - drop redundant dependencies on S390 Date: Sun, 20 Apr 2025 12:25:59 -0700 Message-ID: <20250420192609.295075-4-ebiggers@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250420192609.295075-1-ebiggers@kernel.org> References: <20250420192609.295075-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 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 Sun Apr 20 19:26:01 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 882797 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 EC6A0215F6B; Sun, 20 Apr 2025 19:27:39 +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=1745177260; cv=none; b=MIsXri589E4Q77qqDpGf6bZil5d1fmMX8iXsALpuidTLwgi4Tj/o0FPCUVk4Y8gu8XSLFNeEZ54S5Dwrwb68lWKfp5CjSZo0e+SutfEkqmlFNQgZmGgfhVoFFO1j6ImiV1ZauZ0QcabjIf0I1jIog3KAp+p8S6Et/g00snZtICg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745177260; c=relaxed/simple; bh=07fhhYma+1YUcmrHOr5BYh37/3JJX1SJ3+293Aux6XM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qGLgtelp6HpEHBf/CFRapYCcdu8LJj+mmz5FY79yiu9FhC/GLAHHFSHMnJCNEcywN6Ps81Y+FsQAo7ddURVgPSA+vyF4yMoRrs+rf4TfiB4xcl66JxzsKVUlwRjGuFf2JFCR7YVH4Fpp+31Jpq7T+tAUG3zJ1aUQQerj2uL8YAU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=awAuO20g; 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="awAuO20g" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1ECC7C4CEF7; Sun, 20 Apr 2025 19:27:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1745177259; bh=07fhhYma+1YUcmrHOr5BYh37/3JJX1SJ3+293Aux6XM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=awAuO20gApCxC08ZoLWf6wa29NaGj7w2LM+jz+rpkOjmD4MqPFU/mWMoVpkHZiajP iLBgTmWQFCWfO/vtcnEXPbTjJiss35GZOL4hF+LNCsQVXeSLIvCJ+iBFld1YTen2Dg wQJDb/vQRaZwawkqsyLX/1r9DeZ/KosIKXXj9+5Kym6sUy+yu4qsfpZSIAdk0I5Q6Q YToY/1DvOGBoHkmP0hvCjnS5sRPYs8ACqSIDR5t3Q39M2qdR3WqPajYFdEjrS4IZa3 88/J3sXgGdWGvidlM/lG62UKYpFkROSowHPBBBQkhPZYpGEMlw3AZpuZEr9Dn27LaU pl9/8qNlZ/JIw== 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 v2 05/13] crypto: arm - move library functions to arch/arm/lib/crypto/ Date: Sun, 20 Apr 2025 12:26:01 -0700 Message-ID: <20250420192609.295075-6-ebiggers@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250420192609.295075-1-ebiggers@kernel.org> References: <20250420192609.295075-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 | 24 +++++++++++++++++++ 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, 60 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..dbdf376e25336 --- /dev/null +++ b/arch/arm/lib/crypto/Makefile @@ -0,0 +1,24 @@ +# 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 + +# 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 Sun Apr 20 19:26:03 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 882796 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 BC62B219318; Sun, 20 Apr 2025 19:27:40 +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=1745177260; cv=none; b=L12KGCRinvD6ihv7DEXkUPHGt2iHSZE70zBmOYUATn2thC4Qel1JHduco5EYW4l3I/AN5ZcXk+SkaACghao+4e/j46CLyCqVtFKbZlGHULryzezCtG9/NT/vdM2EXBstcSNPYkYsdZXY8uHepIPIFbOm5rwTOkZhdPYoWZWMqh4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745177260; c=relaxed/simple; bh=qN/B6X2mvQN94BK3RyJeOZTVFWohKhnnWgVazqat/cI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NxbQ+12TgE3D1E2A3zaW5kWnCVQjeOZ+bUeCZDdilzZDa3ZKBoDLctK5atfl7P9DujBFcRqA+Z4LNSKN9vsGMvDvRYwkZmvqlad84R/Q/jejP+hfQG/3VuDdw3phi1hiS6pbNcXRA6f5UjYXwDjlK6rGQFPIQ0V5xDvLVNt9wMo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=h6dG+ABp; 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="h6dG+ABp" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 10A2BC4CEE2; Sun, 20 Apr 2025 19:27:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1745177260; bh=qN/B6X2mvQN94BK3RyJeOZTVFWohKhnnWgVazqat/cI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h6dG+ABppE74ITCWwKY1e/iBpLDE6OAQ81JEKnxMExRPfYAeK3DLvhs5iwtqB9Pal sifuLdiw3iJu7jDMC3pUAV1Ce/ByP37RI2Ua+WKCCHExfJk+szUnY8WQjS+htLskcx HNBMnxUcR1OuQLJckDCjDkcDuxfl2XJWRSjRBz/TllBOPlh6JPYqZMliw2q7/RDVzU ehTb7IR4X3rA59pQygK7EIkZMPyyPedmoSQ3I8QXR7+iTVoiRuk557p9LGmzW9tuEE UH/zTjCTTke5kYyHItZNEx3NKHULyaC3ePouNyZK2maqgtd0D2RPu/gtkYLxcEpdCp EiAaUdsAIGLqg== 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 v2 07/13] crypto: mips - move library functions to arch/mips/lib/crypto/ Date: Sun, 20 Apr 2025 12:26:03 -0700 Message-ID: <20250420192609.295075-8-ebiggers@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250420192609.295075-1-ebiggers@kernel.org> References: <20250420192609.295075-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 Sun Apr 20 19:26: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: 882795 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 6B93F2147E6; Sun, 20 Apr 2025 19:27:41 +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=1745177261; cv=none; b=faJ/Oy7tZC6UxulyVtTW+n3ChDM2vCA14hq3syH1oI37cdUQpIctd5hmGtmBBQiCpSdFBkvZXBq4+BqxAbQvoBaMdNn8ELEnCN3EaZ1+9xSvINsMeEdwkW8WK3Fu7WtlkOSB9bwOkijf9gj+8TDTlCZ740PBNgvl+rcWPZg2MVg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745177261; c=relaxed/simple; bh=JceMeyvHZFS3hU3osMnM8DtDXrhU/UjeqoFMt/NCYhM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JZr1jFTTwq++N6CW0+xpsw02rfhgt/UguapcIctYX3YjGGb35Kc3o4Dgz/rPqpO8CKGpPHNqulWbK8HyltwqnmKtN8/ACM2mVa3Meum343U8ECi+VxMuQQDY3wOTptJAD5gDqEBTERzmvXdglgIX+qgmjRQLB+XEV3fgRCw8u2o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZCkUDe2S; 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="ZCkUDe2S" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F183DC4CEED; Sun, 20 Apr 2025 19:27:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1745177261; bh=JceMeyvHZFS3hU3osMnM8DtDXrhU/UjeqoFMt/NCYhM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZCkUDe2S72itq2OYuxxdcNB38pxf0twZvxcIytZW+K9b6WjYA0TAIwlMai/eahJAx w8hnWfFuUPwQIEWcmraLbu+8LuMqAmesx2H0tNclifUpqnw3RlSCtQJQXl7qosnV2B X9dfT634nEyucjsrsXXn2P/ZQhmdjtoJhC5zA8zcTDZzetaY0MekSgwZdqf1NxO2DG rGjDYkc5mRCzY0avNxgFZx69VsIWcl/xjeGBuZUOG9mWyOjDRjtgn9xGXhXEkHed9d 0Qkk02QD/yLL5xsi23VAlR3hd1WRfL/GqaURyDQikpiyFjKT3o0P20ZHdJC6pdJW+2 BorTK//xE0hgg== 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 v2 09/13] crypto: riscv - move library functions to arch/riscv/lib/crypto/ Date: Sun, 20 Apr 2025 12:26:05 -0700 Message-ID: <20250420192609.295075-10-ebiggers@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250420192609.295075-1-ebiggers@kernel.org> References: <20250420192609.295075-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 riscv ChaCha library functions into a new directory arch/riscv/lib/crypto/ that does not depend on CRYPTO. This mirrors the distinction between crypto/ and lib/crypto/. Signed-off-by: Eric Biggers --- arch/riscv/crypto/Kconfig | 7 ------- arch/riscv/crypto/Makefile | 3 --- arch/riscv/lib/Makefile | 1 + arch/riscv/lib/crypto/Kconfig | 8 ++++++++ arch/riscv/lib/crypto/Makefile | 4 ++++ arch/riscv/{ => lib}/crypto/chacha-riscv64-glue.c | 0 arch/riscv/{ => lib}/crypto/chacha-riscv64-zvkb.S | 0 lib/crypto/Kconfig | 3 +++ 8 files changed, 16 insertions(+), 10 deletions(-) create mode 100644 arch/riscv/lib/crypto/Kconfig create mode 100644 arch/riscv/lib/crypto/Makefile rename arch/riscv/{ => lib}/crypto/chacha-riscv64-glue.c (100%) rename arch/riscv/{ => lib}/crypto/chacha-riscv64-zvkb.S (100%) diff --git a/arch/riscv/crypto/Kconfig b/arch/riscv/crypto/Kconfig index 27a1f26d41bde..4863be2a4ec2f 100644 --- a/arch/riscv/crypto/Kconfig +++ b/arch/riscv/crypto/Kconfig @@ -16,17 +16,10 @@ config CRYPTO_AES_RISCV64 - Zvkned vector crypto extension - Zvbb vector extension (XTS) - Zvkb vector crypto extension (CTR) - Zvkg vector crypto extension (XTS) -config CRYPTO_CHACHA_RISCV64 - tristate - depends on 64BIT && RISCV_ISA_V && TOOLCHAIN_HAS_VECTOR_CRYPTO - select CRYPTO_ARCH_HAVE_LIB_CHACHA - select CRYPTO_LIB_CHACHA_GENERIC - default CRYPTO_LIB_CHACHA_INTERNAL - config CRYPTO_GHASH_RISCV64 tristate "Hash functions: GHASH" depends on 64BIT && RISCV_ISA_V && TOOLCHAIN_HAS_VECTOR_CRYPTO select CRYPTO_GCM help diff --git a/arch/riscv/crypto/Makefile b/arch/riscv/crypto/Makefile index 247c7bc7288ce..4ae9bf762e907 100644 --- a/arch/riscv/crypto/Makefile +++ b/arch/riscv/crypto/Makefile @@ -2,13 +2,10 @@ obj-$(CONFIG_CRYPTO_AES_RISCV64) += aes-riscv64.o aes-riscv64-y := aes-riscv64-glue.o aes-riscv64-zvkned.o \ aes-riscv64-zvkned-zvbb-zvkg.o aes-riscv64-zvkned-zvkb.o -obj-$(CONFIG_CRYPTO_CHACHA_RISCV64) += chacha-riscv64.o -chacha-riscv64-y := chacha-riscv64-glue.o chacha-riscv64-zvkb.o - obj-$(CONFIG_CRYPTO_GHASH_RISCV64) += ghash-riscv64.o ghash-riscv64-y := ghash-riscv64-glue.o ghash-riscv64-zvkg.o obj-$(CONFIG_CRYPTO_SHA256_RISCV64) += sha256-riscv64.o sha256-riscv64-y := sha256-riscv64-glue.o sha256-riscv64-zvknha_or_zvknhb-zvkb.o diff --git a/arch/riscv/lib/Makefile b/arch/riscv/lib/Makefile index b1c46153606a6..0baec92d2f55b 100644 --- a/arch/riscv/lib/Makefile +++ b/arch/riscv/lib/Makefile @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only +obj-y += crypto/ lib-y += delay.o lib-y += memcpy.o lib-y += memset.o lib-y += memmove.o ifeq ($(CONFIG_KASAN_GENERIC)$(CONFIG_KASAN_SW_TAGS),) diff --git a/arch/riscv/lib/crypto/Kconfig b/arch/riscv/lib/crypto/Kconfig new file mode 100644 index 0000000000000..46ce2a7ac1f2c --- /dev/null +++ b/arch/riscv/lib/crypto/Kconfig @@ -0,0 +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 + select CRYPTO_ARCH_HAVE_LIB_CHACHA + select CRYPTO_LIB_CHACHA_GENERIC diff --git a/arch/riscv/lib/crypto/Makefile b/arch/riscv/lib/crypto/Makefile new file mode 100644 index 0000000000000..e27b78f317fc8 --- /dev/null +++ b/arch/riscv/lib/crypto/Makefile @@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0-only + +obj-$(CONFIG_CRYPTO_CHACHA_RISCV64) += chacha-riscv64.o +chacha-riscv64-y := chacha-riscv64-glue.o chacha-riscv64-zvkb.o diff --git a/arch/riscv/crypto/chacha-riscv64-glue.c b/arch/riscv/lib/crypto/chacha-riscv64-glue.c similarity index 100% rename from arch/riscv/crypto/chacha-riscv64-glue.c rename to arch/riscv/lib/crypto/chacha-riscv64-glue.c diff --git a/arch/riscv/crypto/chacha-riscv64-zvkb.S b/arch/riscv/lib/crypto/chacha-riscv64-zvkb.S similarity index 100% rename from arch/riscv/crypto/chacha-riscv64-zvkb.S rename to arch/riscv/lib/crypto/chacha-riscv64-zvkb.S diff --git a/lib/crypto/Kconfig b/lib/crypto/Kconfig index 4b3e94ed84bb6..0b06c25eb38a5 100644 --- a/lib/crypto/Kconfig +++ b/lib/crypto/Kconfig @@ -166,8 +166,11 @@ if MIPS source "arch/mips/lib/crypto/Kconfig" endif if PPC source "arch/powerpc/lib/crypto/Kconfig" endif +if RISCV +source "arch/riscv/lib/crypto/Kconfig" +endif endif endmenu From patchwork Sun Apr 20 19:26:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 882794 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 5024A6DCE1; Sun, 20 Apr 2025 19:27:42 +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=1745177262; cv=none; b=ulh6c4JTmhPStnQfeZhPkdTxfrFRaY8dTDEhqhEHwGVE0AzsXsd5dqusP3/Fp2PLBl7FFG7aUMeH0OoRTplgZuhzXNdgquF7nazg/m8Ov9kSAEmNflNQN7AbsW32xJUM3NIxYektvzgnbr2uR568X7M/9nufcRxaWndgUXrWWVE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745177262; c=relaxed/simple; bh=5jzPL09SfE4WESjYxnB172zEQMoguedQXb5qi2BK7CI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Sm8xl73PkHjfVpR2DJMu3V47FfPoSpH5Z2BREMefHfFqSHs6e6aMgkwKZICUGVfp88Makh8gO8U6kI0oHG+C4HnqI8oUW/tJnXdrFqWP5sfjmN4bhTC12DbXKSgMJ7RZqQRNxj8QthtEPU6UFvPuUl2gloasnW/2vR5P3xu5KpM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Hs10mI3Y; 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="Hs10mI3Y" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DDF7BC4CEEF; Sun, 20 Apr 2025 19:27:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1745177262; bh=5jzPL09SfE4WESjYxnB172zEQMoguedQXb5qi2BK7CI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hs10mI3YY88QuOScEDzVdMCDo2RCAmYofMITZ5CSfexqKoLEbIvTbL0VsGgIN8tdE xmIOrSUTHarguxP+j/aFTQpx/2YWD6/UjI2JX9KlQgiiMHUJhZxhjfj4In3FeqFG20 GST12IvgLp3Zan2ATjAwgTlPuqfwrF48bAAVnSE2mhn8oYe65sMe3rncthvmoJgSjU dPQemT0noKUUfOr5ONzpWUjBsMGlVscVo6jSpXjilOSAvNHM8pX7a180YS2dLen1Cc NMM2ZCNnxubQCBMVPd8FAJKsVQs9jNQIZn9TAZrjd0/Y7m6i9HU1BGfBvc/Ym8m87B w0kNRUW3kQM9g== 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 v2 11/13] crypto: x86 - move library functions to arch/x86/lib/crypto/ Date: Sun, 20 Apr 2025 12:26:07 -0700 Message-ID: <20250420192609.295075-12-ebiggers@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250420192609.295075-1-ebiggers@kernel.org> References: <20250420192609.295075-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 x86 BLAKE2s, ChaCha, and Poly1305 library functions into a new directory arch/x86/lib/crypto/ that does not depend on CRYPTO. This mirrors the distinction between crypto/ and lib/crypto/. Signed-off-by: Eric Biggers --- arch/x86/crypto/Kconfig | 25 ------------------ arch/x86/crypto/Makefile | 15 ----------- arch/x86/lib/Makefile | 2 ++ arch/x86/lib/crypto/.gitignore | 2 ++ arch/x86/lib/crypto/Kconfig | 26 +++++++++++++++++++ arch/x86/lib/crypto/Makefile | 17 ++++++++++++ arch/x86/{ => lib}/crypto/blake2s-core.S | 0 arch/x86/{ => lib}/crypto/blake2s-glue.c | 0 .../x86/{ => lib}/crypto/chacha-avx2-x86_64.S | 0 .../{ => lib}/crypto/chacha-avx512vl-x86_64.S | 0 .../{ => lib}/crypto/chacha-ssse3-x86_64.S | 0 arch/x86/{ => lib}/crypto/chacha_glue.c | 0 .../crypto/poly1305-x86_64-cryptogams.pl | 0 arch/x86/{ => lib}/crypto/poly1305_glue.c | 0 lib/crypto/Kconfig | 3 +++ 15 files changed, 50 insertions(+), 40 deletions(-) create mode 100644 arch/x86/lib/crypto/.gitignore create mode 100644 arch/x86/lib/crypto/Kconfig create mode 100644 arch/x86/lib/crypto/Makefile rename arch/x86/{ => lib}/crypto/blake2s-core.S (100%) rename arch/x86/{ => lib}/crypto/blake2s-glue.c (100%) rename arch/x86/{ => lib}/crypto/chacha-avx2-x86_64.S (100%) rename arch/x86/{ => lib}/crypto/chacha-avx512vl-x86_64.S (100%) rename arch/x86/{ => lib}/crypto/chacha-ssse3-x86_64.S (100%) rename arch/x86/{ => lib}/crypto/chacha_glue.c (100%) rename arch/x86/{ => lib}/crypto/poly1305-x86_64-cryptogams.pl (100%) rename arch/x86/{ => lib}/crypto/poly1305_glue.c (100%) diff --git a/arch/x86/crypto/Kconfig b/arch/x86/crypto/Kconfig index b4df6cf37e0ea..9e941362e4cd5 100644 --- a/arch/x86/crypto/Kconfig +++ b/arch/x86/crypto/Kconfig @@ -333,17 +333,10 @@ config CRYPTO_ARIA_GFNI_AVX512_X86_64 - AVX512 (Advanced Vector Extensions) - GFNI (Galois Field New Instructions) Processes 64 blocks in parallel. -config CRYPTO_CHACHA20_X86_64 - tristate - depends on 64BIT - select CRYPTO_LIB_CHACHA_GENERIC - select CRYPTO_ARCH_HAVE_LIB_CHACHA - default CRYPTO_LIB_CHACHA_INTERNAL - config CRYPTO_AEGIS128_AESNI_SSE2 tristate "AEAD ciphers: AEGIS-128 (AES-NI/SSE4.1)" depends on 64BIT select CRYPTO_AEAD help @@ -371,38 +364,20 @@ config CRYPTO_NHPOLY1305_AVX2 NHPoly1305 hash function for Adiantum Architecture: x86_64 using: - AVX2 (Advanced Vector Extensions 2) -config CRYPTO_BLAKE2S_X86 - bool "Hash functions: BLAKE2s (SSSE3/AVX-512)" - depends on 64BIT - select CRYPTO_LIB_BLAKE2S_GENERIC - select CRYPTO_ARCH_HAVE_LIB_BLAKE2S - help - BLAKE2s cryptographic hash function (RFC 7693) - - Architecture: x86_64 using: - - SSSE3 (Supplemental SSE3) - - AVX-512 (Advanced Vector Extensions-512) - config CRYPTO_POLYVAL_CLMUL_NI tristate "Hash functions: POLYVAL (CLMUL-NI)" depends on 64BIT select CRYPTO_POLYVAL help POLYVAL hash function for HCTR2 Architecture: x86_64 using: - CLMUL-NI (carry-less multiplication new instructions) -config CRYPTO_POLY1305_X86_64 - tristate - depends on 64BIT - select CRYPTO_ARCH_HAVE_LIB_POLY1305 - default CRYPTO_LIB_POLY1305_INTERNAL - config CRYPTO_SHA1_SSSE3 tristate "Hash functions: SHA-1 (SSSE3/AVX/AVX2/SHA-NI)" depends on 64BIT select CRYPTO_SHA1 select CRYPTO_HASH diff --git a/arch/x86/crypto/Makefile b/arch/x86/crypto/Makefile index 2f22b381f2445..fad59a6c6c26f 100644 --- a/arch/x86/crypto/Makefile +++ b/arch/x86/crypto/Makefile @@ -40,13 +40,10 @@ obj-$(CONFIG_CRYPTO_CAST6_AVX_X86_64) += cast6-avx-x86_64.o cast6-avx-x86_64-y := cast6-avx-x86_64-asm_64.o cast6_avx_glue.o obj-$(CONFIG_CRYPTO_AEGIS128_AESNI_SSE2) += aegis128-aesni.o aegis128-aesni-y := aegis128-aesni-asm.o aegis128-aesni-glue.o -obj-$(CONFIG_CRYPTO_CHACHA20_X86_64) += chacha-x86_64.o -chacha-x86_64-y := chacha-avx2-x86_64.o chacha-ssse3-x86_64.o chacha-avx512vl-x86_64.o chacha_glue.o - obj-$(CONFIG_CRYPTO_AES_NI_INTEL) += aesni-intel.o aesni-intel-y := aesni-intel_asm.o aesni-intel_glue.o aesni-intel-$(CONFIG_64BIT) += aes-ctr-avx-x86_64.o \ aes-gcm-aesni-x86_64.o \ aes-xts-avx-x86_64.o @@ -61,23 +58,16 @@ obj-$(CONFIG_CRYPTO_SHA256_SSSE3) += sha256-ssse3.o sha256-ssse3-y := sha256-ssse3-asm.o sha256-avx-asm.o sha256-avx2-asm.o sha256_ni_asm.o sha256_ssse3_glue.o obj-$(CONFIG_CRYPTO_SHA512_SSSE3) += sha512-ssse3.o sha512-ssse3-y := sha512-ssse3-asm.o sha512-avx-asm.o sha512-avx2-asm.o sha512_ssse3_glue.o -obj-$(CONFIG_CRYPTO_BLAKE2S_X86) += libblake2s-x86_64.o -libblake2s-x86_64-y := blake2s-core.o blake2s-glue.o - obj-$(CONFIG_CRYPTO_GHASH_CLMUL_NI_INTEL) += ghash-clmulni-intel.o ghash-clmulni-intel-y := ghash-clmulni-intel_asm.o ghash-clmulni-intel_glue.o obj-$(CONFIG_CRYPTO_POLYVAL_CLMUL_NI) += polyval-clmulni.o polyval-clmulni-y := polyval-clmulni_asm.o polyval-clmulni_glue.o -obj-$(CONFIG_CRYPTO_POLY1305_X86_64) += poly1305-x86_64.o -poly1305-x86_64-y := poly1305-x86_64-cryptogams.o poly1305_glue.o -targets += poly1305-x86_64-cryptogams.S - obj-$(CONFIG_CRYPTO_NHPOLY1305_SSE2) += nhpoly1305-sse2.o nhpoly1305-sse2-y := nh-sse2-x86_64.o nhpoly1305-sse2-glue.o obj-$(CONFIG_CRYPTO_NHPOLY1305_AVX2) += nhpoly1305-avx2.o nhpoly1305-avx2-y := nh-avx2-x86_64.o nhpoly1305-avx2-glue.o @@ -99,12 +89,7 @@ obj-$(CONFIG_CRYPTO_ARIA_AESNI_AVX2_X86_64) += aria-aesni-avx2-x86_64.o aria-aesni-avx2-x86_64-y := aria-aesni-avx2-asm_64.o aria_aesni_avx2_glue.o obj-$(CONFIG_CRYPTO_ARIA_GFNI_AVX512_X86_64) += aria-gfni-avx512-x86_64.o aria-gfni-avx512-x86_64-y := aria-gfni-avx512-asm_64.o aria_gfni_avx512_glue.o -quiet_cmd_perlasm = PERLASM $@ - cmd_perlasm = $(PERL) $< > $@ -$(obj)/%.S: $(src)/%.pl FORCE - $(call if_changed,perlasm) - # Disable GCOV in odd or sensitive code GCOV_PROFILE_curve25519-x86_64.o := n diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile index 1c50352eb49f9..4f0d57a354267 100644 --- a/arch/x86/lib/Makefile +++ b/arch/x86/lib/Makefile @@ -1,10 +1,12 @@ # SPDX-License-Identifier: GPL-2.0 # # Makefile for x86 specific library files. # +obj-y += crypto/ + # Produces uninteresting flaky coverage. KCOV_INSTRUMENT_delay.o := n # KCSAN uses udelay for introducing watchpoint delay; avoid recursion. KCSAN_SANITIZE_delay.o := n diff --git a/arch/x86/lib/crypto/.gitignore b/arch/x86/lib/crypto/.gitignore new file mode 100644 index 0000000000000..580c839bb1776 --- /dev/null +++ b/arch/x86/lib/crypto/.gitignore @@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0-only +poly1305-x86_64-cryptogams.S diff --git a/arch/x86/lib/crypto/Kconfig b/arch/x86/lib/crypto/Kconfig new file mode 100644 index 0000000000000..f83aa51dd9129 --- /dev/null +++ b/arch/x86/lib/crypto/Kconfig @@ -0,0 +1,26 @@ +# SPDX-License-Identifier: GPL-2.0-only + +config CRYPTO_BLAKE2S_X86 + bool "Hash functions: BLAKE2s (SSSE3/AVX-512)" + depends on 64BIT + select CRYPTO_LIB_BLAKE2S_GENERIC + select CRYPTO_ARCH_HAVE_LIB_BLAKE2S + help + BLAKE2s cryptographic hash function (RFC 7693) + + Architecture: x86_64 using: + - SSSE3 (Supplemental SSE3) + - AVX-512 (Advanced Vector Extensions-512) + +config CRYPTO_CHACHA20_X86_64 + tristate + depends on 64BIT + default CRYPTO_LIB_CHACHA_INTERNAL + select CRYPTO_LIB_CHACHA_GENERIC + select CRYPTO_ARCH_HAVE_LIB_CHACHA + +config CRYPTO_POLY1305_X86_64 + tristate + depends on 64BIT + default CRYPTO_LIB_POLY1305_INTERNAL + select CRYPTO_ARCH_HAVE_LIB_POLY1305 diff --git a/arch/x86/lib/crypto/Makefile b/arch/x86/lib/crypto/Makefile new file mode 100644 index 0000000000000..c2ff8c5f1046e --- /dev/null +++ b/arch/x86/lib/crypto/Makefile @@ -0,0 +1,17 @@ +# SPDX-License-Identifier: GPL-2.0-only + +obj-$(CONFIG_CRYPTO_BLAKE2S_X86) += libblake2s-x86_64.o +libblake2s-x86_64-y := blake2s-core.o blake2s-glue.o + +obj-$(CONFIG_CRYPTO_CHACHA20_X86_64) += chacha-x86_64.o +chacha-x86_64-y := chacha-avx2-x86_64.o chacha-ssse3-x86_64.o chacha-avx512vl-x86_64.o chacha_glue.o + +obj-$(CONFIG_CRYPTO_POLY1305_X86_64) += poly1305-x86_64.o +poly1305-x86_64-y := poly1305-x86_64-cryptogams.o poly1305_glue.o +targets += poly1305-x86_64-cryptogams.S + +quiet_cmd_perlasm = PERLASM $@ + cmd_perlasm = $(PERL) $< > $@ + +$(obj)/%.S: $(src)/%.pl FORCE + $(call if_changed,perlasm) diff --git a/arch/x86/crypto/blake2s-core.S b/arch/x86/lib/crypto/blake2s-core.S similarity index 100% rename from arch/x86/crypto/blake2s-core.S rename to arch/x86/lib/crypto/blake2s-core.S diff --git a/arch/x86/crypto/blake2s-glue.c b/arch/x86/lib/crypto/blake2s-glue.c similarity index 100% rename from arch/x86/crypto/blake2s-glue.c rename to arch/x86/lib/crypto/blake2s-glue.c diff --git a/arch/x86/crypto/chacha-avx2-x86_64.S b/arch/x86/lib/crypto/chacha-avx2-x86_64.S similarity index 100% rename from arch/x86/crypto/chacha-avx2-x86_64.S rename to arch/x86/lib/crypto/chacha-avx2-x86_64.S diff --git a/arch/x86/crypto/chacha-avx512vl-x86_64.S b/arch/x86/lib/crypto/chacha-avx512vl-x86_64.S similarity index 100% rename from arch/x86/crypto/chacha-avx512vl-x86_64.S rename to arch/x86/lib/crypto/chacha-avx512vl-x86_64.S diff --git a/arch/x86/crypto/chacha-ssse3-x86_64.S b/arch/x86/lib/crypto/chacha-ssse3-x86_64.S similarity index 100% rename from arch/x86/crypto/chacha-ssse3-x86_64.S rename to arch/x86/lib/crypto/chacha-ssse3-x86_64.S diff --git a/arch/x86/crypto/chacha_glue.c b/arch/x86/lib/crypto/chacha_glue.c similarity index 100% rename from arch/x86/crypto/chacha_glue.c rename to arch/x86/lib/crypto/chacha_glue.c diff --git a/arch/x86/crypto/poly1305-x86_64-cryptogams.pl b/arch/x86/lib/crypto/poly1305-x86_64-cryptogams.pl similarity index 100% rename from arch/x86/crypto/poly1305-x86_64-cryptogams.pl rename to arch/x86/lib/crypto/poly1305-x86_64-cryptogams.pl diff --git a/arch/x86/crypto/poly1305_glue.c b/arch/x86/lib/crypto/poly1305_glue.c similarity index 100% rename from arch/x86/crypto/poly1305_glue.c rename to arch/x86/lib/crypto/poly1305_glue.c diff --git a/lib/crypto/Kconfig b/lib/crypto/Kconfig index db19a7acc2fbf..f321fe1a8681b 100644 --- a/lib/crypto/Kconfig +++ b/lib/crypto/Kconfig @@ -172,8 +172,11 @@ if RISCV source "arch/riscv/lib/crypto/Kconfig" endif if S390 source "arch/s390/lib/crypto/Kconfig" endif +if X86 +source "arch/x86/lib/crypto/Kconfig" +endif endif endmenu From patchwork Sun Apr 20 19:26: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: 882793 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 9F19D21D3CD; Sun, 20 Apr 2025 19:27:42 +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=1745177263; cv=none; b=HM1udxEioi5JeSwFNJCQ/aLERzAyBD/4f+E2a5fLyF2a6jbtXWXsltCjrswAuqX3FvnKE8g6n2lq6b0NDIxR1jkUthEAzMOGsuVa8DgScV8PkTys0zLr+NQ9wBJwFtmu4q8vQ9oWp2rB8Be9TKAXrdS+jEvJk7agD5iK2HmNCXk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745177263; c=relaxed/simple; bh=l+8LTIVco+dbh9d8ET+f2v59CbKZfxOmGWJmTr+W3Z8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=S+/FkhoPiyBuzgrs75uhBHUViBaSAQPhZ2Niyb4Cd2S50XRrsgKzUwivst2W1uUhQ0R5b41ygQRu7M8jhZWliuqZmdw3rivf+iHUOOJN6B5dcvq2nHLtB9/Kk+ql0s1C6S1xOt+4GlIBxHRai/+sGKr/l5LXC+fXjn9f2FSEkQc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=C7diKfMK; 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="C7diKfMK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 596DBC4CEF1; Sun, 20 Apr 2025 19:27:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1745177262; bh=l+8LTIVco+dbh9d8ET+f2v59CbKZfxOmGWJmTr+W3Z8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C7diKfMKGIqUI0dWG9OEthRgl4xcAHQPbzwEdXQkdDAw6iapoPkjDnIuTov4CMDbf 8Vwl2j6tHk2PMNcXfxndslqk9VHQe/lmTNOy2KUJKZgHQfcsIQkJdbbUc8Wgi35DRy XIu40aBLPKz8UKcmvCVfnzMBEy+CgEYJfQDmu4TgOG2xmzOHMh7LMQG8uFCYL0ahnv +dV1o6A58RMw2lO1o1iYi+RTHaqfzSISd9BzwRgOpGCneZcEI+ChZIoO+U+QFA3p/1 rerVCNXTtPw6jpiLaEVRabfe/lpWZsv8HOB8UoDj/aKhJbFm529B1bk01VVVE0xIlC oNbRlfOqmegWA== 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 v2 12/13] crypto: lib/chacha - remove INTERNAL symbol and selection of CRYPTO Date: Sun, 20 Apr 2025 12:26:08 -0700 Message-ID: <20250420192609.295075-13-ebiggers@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250420192609.295075-1-ebiggers@kernel.org> References: <20250420192609.295075-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 visible without 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.