From nobody Wed Oct 12 20:14:21 2022 X-Original-To: dev-commits-ports-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4MnkQ623gjz4dxc3; Wed, 12 Oct 2022 20:14:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MnkQ61Jrnz3qtd; Wed, 12 Oct 2022 20:14:22 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1665605662; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=shizOxxBuT6C0rRdxZMndVX70ur90icJ8lACVycW56U=; b=IG8YoLK1C+Xp3jm9Z/FOUELjJFkrolJoq5kV1298O28F+JzUvZAbAovt9wSBFEkzKEF+jN C8qjBYwJskKs94q03iDTw2K2h/bzg4jNycOR7auzfwfD/Gw5eq0QXLt/AT2QuM7VLbW5lf si+03ReR0FMIrc4q49HDNia+HKSq+81FAta52m2EhH4UC/nPAR7/KqaqNPK24stDmvp+x+ vPPiZT6HlhP8WXtmWs/Ha+WPpl1w4yNMDp+QCTOIfL/wPedJP6icBm9Xqwh+krp2qeiPlN Lu2kFvBL1HmtkCvbDUi6zdmpIEsQau2h7rz+CweOH05AxGs0kwV2diWwZfsa5g== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4MnkQ605Tvz1QG0; Wed, 12 Oct 2022 20:14:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 29CKELRc069474; Wed, 12 Oct 2022 20:14:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 29CKELkC069473; Wed, 12 Oct 2022 20:14:21 GMT (envelope-from git) Date: Wed, 12 Oct 2022 20:14:21 GMT Message-Id: <202210122014.29CKELkC069473@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: Matthias Andree Subject: git: 1632d93d92d9 - main - security/putty: fix ARM NEON AES-GCM code List-Id: Commits to the main branch of the FreeBSD ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-ports-main@freebsd.org X-BeenThere: dev-commits-ports-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mandree X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 1632d93d92d9ba58401834a571ba89860963a171 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1665605662; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=shizOxxBuT6C0rRdxZMndVX70ur90icJ8lACVycW56U=; b=ChiAZJkdpCZ7KJcg8hgS3xC3hU8/n+e50vzYCTz+XoajHWIDR5wiV3I2srmnhZZjETTUwr irp+1IkIuk/QV6uyNhFQRD8PCe+MKA/5ppwIwDGJ/rXN3narYiBlQggPt91v7gWKEJK0Hw /XT1OXel3FgURGILoOB2CCXF6HMRZPg7BgDLoVE0WIUyLKCXNKyrTCYsG5G8t4Z7nzeFfy zRervv8KWzPoG5eyDGeUipMtm/Mc+eo8zYuDxLI7Rn97I3zfkPWpiqyfG6dpQY0/u/pCC0 0mRfMydWRpF1ra9z+uKm0YVV25QF15hIaQA9DYE2w3BU+KfU9KgRHfGAydTDfw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1665605662; a=rsa-sha256; cv=none; b=PxGkuvcQZL1Dx/c8jLIdvn7VTcRAdo72ao0kL/iZh/oh9AmjUkN63GCWOR0v4fiMAa+HG7 XVrjsU2rJNKGXNEio75bBdv6C12y3TtwwHnecX4ussOumUn/5+NATrR6emcvyaiHeEtGLb M3LHdex25e+3QmngmoaBP/noJ8dPPeLEUSFNSB78K7d1V3uX2K/gmeL1M75OGdlQnm6f7K V2V0bBPmR0+s9/VUF9pPdrmQeI35Cj+NceywPWgbDBJAxnK06IzDpYPkno9lFvQMJCqRbw jMyh1WxLZRHruDgKZqervKxlIc1Iy28s04Z1Cl8gz5MJ+gBGG4BNSS3xvmQjAQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mandree: URL: https://cgit.FreeBSD.org/ports/commit/?id=1632d93d92d9ba58401834a571ba89860963a171 commit 1632d93d92d9ba58401834a571ba89860963a171 Author: Matthias Andree AuthorDate: 2022-10-12 20:11:48 +0000 Commit: Matthias Andree CommitDate: 2022-10-12 20:14:20 +0000 security/putty: fix ARM NEON AES-GCM code Cherry-pick a test patch from upstream maintainer: - this uses fallback code for compilers not providing vaddq_p128 (f.i. clang-10 on FreeBSD 12.3 AMD64/aarch64) - and uses vaddq_p128 on systems that provide it, for instance, FreeBSD 13-STABLE AMD64/aarch64 with clang 14.0.5 Obtained from: Simon Tatham MFH: 2022Q4 --- security/putty/Makefile | 2 +- security/putty/files/patch-crypto_CMakeLists.txt | 15 ------ security/putty/files/patch-vaddq_p128 | 65 ++++++++++++++++++++++++ 3 files changed, 66 insertions(+), 16 deletions(-) diff --git a/security/putty/Makefile b/security/putty/Makefile index fe19c50a6f96..2819f4bccfc3 100644 --- a/security/putty/Makefile +++ b/security/putty/Makefile @@ -1,7 +1,7 @@ PORTNAME= putty PORTVERSION= 0.78~pre20220922 DISTVERSIONSUFFIX= .9fcfd67 -PORTREVISION= 0 +PORTREVISION= 1 CATEGORIES= security #MASTER_SITES= http://the.earth.li/~sgtatham/putty/${PORTVERSION}/ \ # ftp://ftp.chiark.greenend.org.uk/users/sgtatham/putty-latest/ diff --git a/security/putty/files/patch-crypto_CMakeLists.txt b/security/putty/files/patch-crypto_CMakeLists.txt deleted file mode 100644 index 82639b778fd0..000000000000 --- a/security/putty/files/patch-crypto_CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -This is a crude hack to avoid aesgcm-neon.c on FreeBSD 12.3, -which does - by way of clang 10.0.1 - not offer vaddq_p128() -through arm-neon.h. clang 13 as of FreeBSD 13.1 does. - ---- crypto/CMakeLists.txt.orig 2022-09-21 23:42:30 UTC -+++ crypto/CMakeLists.txt -@@ -192,7 +192,7 @@ if(neon) - volatile poly128_t r; - volatile poly64_t a, b; - volatile poly64x2_t u, v; -- int main(void) { r = vmull_p64(a, b); r = vmull_high_p64(u, v); }" -+ int main(void) { r = vmull_p64(a, b); r = vmull_high_p64(u, v); r = vaddq_p128(r, r); }" - ADD_SOURCES_IF_SUCCESSFUL aesgcm-neon.c) - - # The 'sha3' architecture extension, despite the name, includes diff --git a/security/putty/files/patch-vaddq_p128 b/security/putty/files/patch-vaddq_p128 new file mode 100644 index 000000000000..ed5e0ca0cca4 --- /dev/null +++ b/security/putty/files/patch-vaddq_p128 @@ -0,0 +1,65 @@ +commit 2222cd104dc5bd424fe025b98c133c91195cf9f3 +Author: Simon Tatham +Date: Wed Oct 12 12:54:36 2022 +0100 + + AES-GCM NEON: cope with missing vaddq_p128. + + In some compilers (I'm told clang 10, in particular), the NEON + intrinsic vaddq_p128 is missing, even though its input type poly128_t + is provided. + + vaddq_p128 is just an XOR of two vector registers, so that's easy to + work around by casting to a more mundane type and back. Added a + configure-time test for that intrinsic, and a workaround to be used in + its absence. + +diff --git a/cmake/cmake.h.in b/cmake/cmake.h.in +index 91d52d78..5ad32515 100644 +--- ./cmake/cmake.h.in ++++ b/cmake/cmake.h.in +@@ -54,6 +54,7 @@ + #cmakedefine01 HAVE_CLMUL + #cmakedefine01 HAVE_NEON_CRYPTO + #cmakedefine01 HAVE_NEON_PMULL ++#cmakedefine01 HAVE_NEON_VADDQ_P128 + #cmakedefine01 HAVE_NEON_SHA512 + #cmakedefine01 HAVE_NEON_SHA512_INTRINSICS + #cmakedefine01 USE_ARM64_NEON_H +diff --git a/crypto/CMakeLists.txt b/crypto/CMakeLists.txt +index ff04efb5..4b0aa907 100644 +--- ./crypto/CMakeLists.txt ++++ b/crypto/CMakeLists.txt +@@ -195,6 +195,14 @@ if(neon) + int main(void) { r = vmull_p64(a, b); r = vmull_high_p64(u, v); }" + ADD_SOURCES_IF_SUCCESSFUL aesgcm-neon.c) + ++ test_compile_with_flags(HAVE_NEON_VADDQ_P128 ++ GNU_FLAGS -march=armv8-a+crypto ++ MSVC_FLAGS -D_ARM_USE_NEW_NEON_INTRINSICS ++ TEST_SOURCE " ++ #include <${neon_header}> ++ volatile poly128_t r; ++ int main(void) { r = vaddq_p128(r, r); }") ++ + # The 'sha3' architecture extension, despite the name, includes + # support for SHA-512 (from the SHA-2 standard) as well as SHA-3 + # proper. +diff --git a/crypto/aesgcm-neon.c b/crypto/aesgcm-neon.c +index dd7b83cc..64bc8349 100644 +--- ./crypto/aesgcm-neon.c ++++ b/crypto/aesgcm-neon.c +@@ -87,6 +87,14 @@ static inline void store_p128_be(void *p, poly128_t v) + vst1q_u8(p, vrev64q_u8(vreinterpretq_u8_p128(swapped))); + } + ++#if !HAVE_NEON_VADDQ_P128 ++static inline poly128_t vaddq_p128(poly128_t a, poly128_t b) ++{ ++ return vreinterpretq_p128_u32(veorq_u32( ++ vreinterpretq_u32_p128(a), vreinterpretq_u32_p128(b))); ++} ++#endif ++ + /* + * Key setup is just like in aesgcm-ref-poly.c. There's no point using + * vector registers to accelerate this, because it happens rarely.