From nobody Tue Jun 3 01:51:44 2025 X-Original-To: dev-commits-src-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 4bBDGS5Sgvz5xnfn; Tue, 03 Jun 2025 01:51:44 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4bBDGS4d5lz3xrr; Tue, 03 Jun 2025 01:51:44 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1748915504; 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=xTmWZQdHbGfBbp7LzIZvzlYCIJEd2xN0gci99IkOIVg=; b=KG8iqxD+BcSUKo8ZVmQNQ3boZNxXBHqe6nKbJfJp1BnD4Rk4HFPoJBnpw2kxPUwhFtR4pW 9Fn2WXV+vYz2qM7amolEa0QzBveYlIqHOzsD2CifTcNvyckwnKn+3KxWzHxF/CyCKwHYR/ WI4v7IwkqDPTriLgGx6uZz3yTvOk5ahPuW/z8tQzkZyogxPTAo5cCidvRIhj13FCIdlOW/ xJGFaZEbpiJX7wTDLgWdtK6mFzsPQ/6fYzGJnUlvO4Nmv7RAUHiEgY2K5Jd9wBn6OtE/Dk mPS6JMTskWvWIG29xCBwsMmNw1ToEUjEP2vjjFX6wo4HaYHZEOqc5OqGRi33pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1748915504; 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=xTmWZQdHbGfBbp7LzIZvzlYCIJEd2xN0gci99IkOIVg=; b=OZ/nWi89M6l2+lKby56g9IzAl3uGG4R2sKXhW0lG+DJr6YUQfHjGuwZqXff9exu7rOS4qw PQhbT3g+qO4H20jSAZzQGAYRJB3Ff1MogWqwqOQ5vFrpVcw/iqfhyut0Swc66p40dWsWCV 3Wd1QFbDuuOJghrqmy5GJmIlGle043OMTfmTTtFT/zS9N0z1xDQjYnUyEKpWKXWt+DRTk7 hMR2OAZk8LAF2B8vYqceRXITvvsjA6XV0SHMo9o3V/cSqKIEhdgz+Db+yiMfShZKnh/taq un912ddjgeCTMUTKeMt0WIsZQVY4xMgeL8Yd6/mF7zQiBR7Z/1BIrGW/YwCQTg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1748915504; a=rsa-sha256; cv=none; b=SkodYYFXLho/muhKQUMNkPGm2r6inL4E1s8KiEwUnUfl2LoIowpZDWQnVX189lzu3fGcK1 rss+Qhf+lJFGgTcWSHwHziNv0Z4ZZBGrqY0ICGTpK59C9RjjE0Zg5hu36xCHio+KJmLki3 rr4sJrLHJuepZxJa//fpXDl07umz1XEBxkcivo0go9UDWZQUtVsjdwhJsABES8reKchMuv t+JTr2+RsfwIhhv6srQ7L9VPz415M/o9Ditjv4cNY9b/ul8iPG99vcFagwybQsYcODVAGx hg01TllQF3rQps32UPyXyx4JpHyq1/2fPR6NCuJWV6nJiLw8CdN9WlZJ96UR/g== 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 4bBDGS43m4z3G6; Tue, 03 Jun 2025 01:51:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 5531piM7020798; Tue, 3 Jun 2025 01:51:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 5531pias020795; Tue, 3 Jun 2025 01:51:44 GMT (envelope-from git) Date: Tue, 3 Jun 2025 01:51:44 GMT Message-Id: <202506030151.5531pias020795@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Jessica Clarke Subject: git: 207f3b2b25ea - main - libmd: Fix amd64 AVX2 SHA-1 transcription errors List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jrtc27 X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 207f3b2b25eaa0f9d32699e664b139e5e40e5450 Auto-Submitted: auto-generated The branch main has been updated by jrtc27: URL: https://cgit.FreeBSD.org/src/commit/?id=207f3b2b25eaa0f9d32699e664b139e5e40e5450 commit 207f3b2b25eaa0f9d32699e664b139e5e40e5450 Author: Jessica Clarke AuthorDate: 2025-06-03 01:46:57 +0000 Commit: Jessica Clarke CommitDate: 2025-06-03 01:46:57 +0000 libmd: Fix amd64 AVX2 SHA-1 transcription errors This source was manually transcribed from Go's assembly syntax into FreeBSD's. Some differences exist (e.g. around stack frame allocation, but also some upstream LEAL instructions were replaced with ADDL here as getting the 64-bit super-registers of 32-bit isn't so doable, unlike Go) that were intended, but a few errors crept in. Fix these, found by comparing post-processed disassembly[1] (handling the ADDL difference above, and due to Go's assembler not optimising VP[X]OR encoding by commuting operands when it would give rise to a 2-byte VEX prefix) of a built copy of the corresponding Go source against ours. [1] In Vim: %g/\/s/\(%ymm\([89]\|1[0-5]\)\), %ymm\([0-7]\), %ymm/%ymm\3, \1, %ymm/g (to commute the VP[X]OR operands as LLVM does) %s/\\([[:space:]]\+\)(%r\(..\),%r\(..\)), %e\2/addl\1%e\3, %e\2/ (to convert LEAL to ADDL in the cases we do) %s/%e12\>/%r12d/g (as the previous conversion turns %r12 into %e12 not %r12d) Fixes: 8b4684afcde3 ("lib/libmd: add optimised SHA1 implementations for amd64") --- lib/libmd/amd64/sha1block.S | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/libmd/amd64/sha1block.S b/lib/libmd/amd64/sha1block.S index 0307dcdece32..f1291ef2647a 100644 --- a/lib/libmd/amd64/sha1block.S +++ b/lib/libmd/amd64/sha1block.S @@ -1220,7 +1220,7 @@ END(_libmd_sha1block_scalar) .macro calc116 calc_f2_pre 0x130, %eax, %edx, %edi - precalc37 %ymm5 + precalc36 %ymm5 calc_f2_post %eax, %ecx, %ebx, %edi .endm @@ -1354,7 +1354,7 @@ END(_libmd_sha1block_scalar) .endm .macro calc139 - calc_f2_pre 0x1cc, %edx, %ecx, %eax + calc_f2_pre 0x1dc, %edx, %ecx, %eax precalc35 %ymm14 calc_f2_post %edx, %ebx, %esi, %eax .endm @@ -1586,7 +1586,7 @@ ENTRY(_libmd_sha1block_avx2) add $128, %r10 // move to the next even-64-byte block cmp %r11, %r10 // is the current block the last one? - cmovae %r10, %r8 // signal the last iteration smartly + cmovae %r8, %r10 // signal the last iteration smartly calc60 calc61