1
0
mirror of https://github.com/golang/go synced 2024-11-25 22:37:59 -07:00

crypto/sha512: Avo port of sha512block_amd64.s

This implementation utilizes the same registers found in the reference
implementation, aiming to produce a minimal semantic diff between the
Avo-generated output and the original hand-written assembly.

To verify the Avo implementation, the reference and Avo-generated
assembly files are fed to `go tool asm`, capturing the debug output into
corresponding temp files. The debug output contains supplementary
metadata (line numbers, instruction offsets, and source file references)
that must be removed in order to obtain a semantic diff of the two
files. This is accomplished via a small utility script written in awk.

Commands used to verify Avo output:

GOROOT=$(go env GOROOT)
ASM_PATH="src/crypto/sha512/sha512block_amd64.s"
REFERENCE="54fe0fd43fcf8609666c16ae6d15ed92873b1564"

go tool asm -o /dev/null -I "$GOROOT"/src/runtime -debug \
  <(git cat-file -p "$REFERENCE:$ASM_PATH") \
  > /tmp/reference.s

go tool asm -o /dev/null -I "$GOROOT"/src/runtime -debug \
  "$ASM_PATH" \
  > /tmp/avo.s

normalize(){
  awk '{
    $1=$2=$3="";
    print substr($0,4)
  }'
}

diff <(normalize < /tmp/reference.s) <(normalize < /tmp/avo.s)

Change-Id: I172f0cb97252635c657efe82d1b547e6b6f40ebb
Reviewed-on: https://go-review.googlesource.com/c/go/+/598958
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
This commit is contained in:
Garrett Bodley 2024-07-17 20:00:53 -04:00 committed by Roland Shoemaker
parent f9eb06c302
commit 3b78ca0626
6 changed files with 6993 additions and 1440 deletions

View File

@ -359,6 +359,7 @@ var excluded = map[string]bool{
"crypto/internal/edwards25519/field/_asm": true, "crypto/internal/edwards25519/field/_asm": true,
"crypto/sha1/_asm": true, "crypto/sha1/_asm": true,
"crypto/sha256/_asm": true, "crypto/sha256/_asm": true,
"crypto/sha512/_asm": true,
} }
// printPackageMu synchronizes the printing of type-checked package files in // printPackageMu synchronizes the printing of type-checked package files in

View File

@ -0,0 +1,11 @@
module std/crypto/sha512/_asm
go 1.24
require github.com/mmcloughlin/avo v0.6.0
require (
golang.org/x/mod v0.20.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/tools v0.24.0 // indirect
)

View File

@ -0,0 +1,8 @@
github.com/mmcloughlin/avo v0.6.0 h1:QH6FU8SKoTLaVs80GA8TJuLNkUYl4VokHKlPhVDg4YY=
github.com/mmcloughlin/avo v0.6.0/go.mod h1:8CoAGaCSYXtCPR+8y18Y9aB/kxb8JSS6FRI7mSkvD+8=
golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0=
golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24=
golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ=

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -361,6 +361,7 @@ var excluded = map[string]bool{
"crypto/internal/edwards25519/field/_asm": true, "crypto/internal/edwards25519/field/_asm": true,
"crypto/sha1/_asm": true, "crypto/sha1/_asm": true,
"crypto/sha256/_asm": true, "crypto/sha256/_asm": true,
"crypto/sha512/_asm": true,
} }
// printPackageMu synchronizes the printing of type-checked package files in // printPackageMu synchronizes the printing of type-checked package files in