]> Cypherpunks repositories - gostls13.git/commitdiff
crypto: check all cpu.X86 flags for features used in assembly
authorFilippo Valsorda <filippo@golang.org>
Sat, 9 Nov 2024 18:16:13 +0000 (19:16 +0100)
committerGopher Robot <gobot@golang.org>
Tue, 19 Nov 2024 15:48:59 +0000 (15:48 +0000)
These are most likely redundant, but cmd/compile/internal/amd64's
TestGoAMD64v1 turns them off when clobbering those instructions, so we
need to know to skip the assembly in those cases.

Thankfully we have Avo now that adds a helpful comment with the list of
features used by each generated function!

Also improve the error output of TestGoAMD64v1. It had broken before in
#49402 and had required the exact same patch.

Change-Id: I7fab8f36042cdff630f806723aa1d8124c294f60
Reviewed-on: https://go-review.googlesource.com/c/go/+/626876
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

src/cmd/compile/internal/amd64/versions_test.go
src/crypto/internal/fips/sha256/sha256block_amd64.go
src/crypto/internal/fips/sha512/sha512block_amd64.go
src/crypto/sha1/sha1block_amd64.go

index fc0046aceebade784641f915884e4ca36d1c953b..92365fb365efa89863fd34879f9d9a3095ee5c98 100644 (file)
@@ -78,7 +78,7 @@ func TestGoAMD64v1(t *testing.T) {
        cmd.Env = append(cmd.Env, fmt.Sprintf("GODEBUG=%s", strings.Join(features, ",")))
        out, err := cmd.CombinedOutput()
        if err != nil {
-               t.Fatalf("couldn't execute test: %s", err)
+               t.Fatalf("couldn't execute test: %s\n%s", err, out)
        }
        // Expect to see output of the form "PASS\n", unless the test binary
        // was compiled for coverage (in which case there will be an extra line).
index a08114a8baccf3b8559a1591de4f214ffd381c9a..a3a1cae8e968ba7f13e3e7033a4f20c937f8dbec 100644 (file)
@@ -11,8 +11,8 @@ import (
        "internal/cpu"
 )
 
-var useAVX2 = cpu.X86.HasAVX2 && cpu.X86.HasBMI2
-var useSHANI = useAVX2 && cpu.X86.HasSHA
+var useAVX2 = cpu.X86.HasAVX && cpu.X86.HasAVX2 && cpu.X86.HasBMI2
+var useSHANI = cpu.X86.HasAVX && cpu.X86.HasSHA && cpu.X86.HasSSE41 && cpu.X86.HasSSSE3
 
 func init() {
        impl.Register("sha256", "AVX2", &useAVX2)
index 998b78e1a5c6fff04cccfda0d9d2166a580a8e95..1ffd34015327ac75855c8303be086ce390ff5019 100644 (file)
@@ -11,7 +11,7 @@ import (
        "internal/cpu"
 )
 
-var useAVX2 = cpu.X86.HasAVX2 && cpu.X86.HasBMI1 && cpu.X86.HasBMI2
+var useAVX2 = cpu.X86.HasAVX && cpu.X86.HasAVX2 && cpu.X86.HasBMI2
 
 func init() {
        impl.Register("sha512", "AVX2", &useAVX2)
index 92fa7a6fbc0d1401461755ddc84dfd1a5d0b136b..10376d1dcc79de1c80e690cf560d377207664fce 100644 (file)
@@ -14,7 +14,7 @@ func blockAVX2(dig *digest, p []byte)
 //go:noescape
 func blockAMD64(dig *digest, p []byte)
 
-var useAVX2 = cpu.X86.HasAVX2 && cpu.X86.HasBMI1 && cpu.X86.HasBMI2
+var useAVX2 = cpu.X86.HasAVX && cpu.X86.HasAVX2 && cpu.X86.HasBMI1 && cpu.X86.HasBMI2
 
 func block(dig *digest, p []byte) {
        if useAVX2 && len(p) >= 256 {