]> Cypherpunks repositories - gostls13.git/commit
crypto/aes: Avo port of asm_amd64.s
authorGarrett Bodley <garrett.bodley@gmail.com>
Tue, 23 Jul 2024 03:39:44 +0000 (23:39 -0400)
committerRoland Shoemaker <roland@golang.org>
Wed, 4 Sep 2024 20:36:51 +0000 (20:36 +0000)
commitd61b73c1d1a74ef3132c04e5fd389a551dd58cf9
treee73b95c38d27ebbc9b3a05a21699eeeccd1b2c1d
parent6ee8c07c3cb8b20e46cd168a8bf6ebaf8243b2ac
crypto/aes: Avo port of asm_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.

The reference assembly file does not specify a frame size for some of
the defined assembly functions. Avo automatically infers the frame size
when generating TEXT directives, leading to a diff on those lines.

Commands used to verify Avo output:

GOROOT=$(go env GOROOT)
ASM_PATH="src/crypto/aes/asm_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)

1c1
< TEXT <unlinkable>.encryptBlockAsm(SB), NOSPLIT, $0
---
> TEXT <unlinkable>.encryptBlockAsm(SB), NOSPLIT, $0-32
45c45
< TEXT <unlinkable>.decryptBlockAsm(SB), NOSPLIT, $0
---
> TEXT <unlinkable>.decryptBlockAsm(SB), NOSPLIT, $0-32
89c89
< TEXT <unlinkable>.expandKeyAsm(SB), NOSPLIT, $0
---
> TEXT <unlinkable>.expandKeyAsm(SB), NOSPLIT, $0-32

Change-Id: If647584df4137146d355f91ac0f6a8285d07c932
Reviewed-on: https://go-review.googlesource.com/c/go/+/600375
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
src/cmd/compile/internal/types2/stdlib_test.go
src/crypto/aes/_asm/standard/asm_amd64.go [new file with mode: 0644]
src/crypto/aes/_asm/standard/go.mod [new file with mode: 0644]
src/crypto/aes/_asm/standard/go.sum [new file with mode: 0644]
src/crypto/aes/asm_amd64.s
src/go/types/stdlib_test.go