Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/sys/cpu: ARM64.HasAES = false on Apple Silicon (M1 Max) #68150

Closed
aadomnicai opened this issue Jun 24, 2024 · 9 comments · May be fixed by golang/sys#202
Closed

x/sys/cpu: ARM64.HasAES = false on Apple Silicon (M1 Max) #68150

aadomnicai opened this issue Jun 24, 2024 · 9 comments · May be fixed by golang/sys#202
Labels
arch-arm64 NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Darwin
Milestone

Comments

@aadomnicai
Copy link

What version of Go are you using (go version)?

$ go version
go version go1.22.2 darwin/arm64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/alexandre.adomnicai/Library/Caches/go-build'
GOENV='/Users/alexandre.adomnicai/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/alexandre.adomnicai/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/alexandre.adomnicai/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/Cellar/go/1.22.2/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/homebrew/Cellar/go/1.22.2/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.22.2'
GCCGO='gccgo'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/Users/alexandre.adomnicai/Github/test_aes/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/31/w4yrhpr51z15j6f6wml61kvr0000gp/T/go-build1310596040=/tmp/go-build -gno-record-gcc-switches -fno-common'
GOROOT/bin/go version: go version go1.22.2 darwin/arm64
GOROOT/bin/go tool compile -V: compile version go1.22.2
uname -v: Darwin Kernel Version 23.5.0: Wed May  1 20:12:58 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6000
ProductName:		macOS
ProductVersion:		14.5
BuildVersion:		23F79
lldb --version: lldb-1500.0.404.7
Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)

What did you do?

Run a simple test to check whether hardware AES is used on my machine.
The following is simply run with go test -tags ""

package aes_test

import (
	"fmt"
	"testing"

	"golang.org/x/sys/cpu"
)

func TestEncryptDecryptMessage(t *testing.T) {
	fmt.Printf("Hardware AES is used: %t\n", cpu.ARM64.HasAES)
}

What did you expect to see?

I would have expected Hardware AES is used: true since AES instructions are supported.
In go/src/internal/cpu/cpu_arm64_darwin.go, the variable cpu.ARM64.HasAES should be set to true, and I cannot understand why that is not the case since the build conditions //go:build arm64 && darwin && !ios should be satisfied?

What did you see instead?

I get Hardware AES is used: false instead.

@seankhliao seankhliao changed the title cpu/cpu_arm64_darwin.go: No use of AES instructions on Apple Silicon (M1 Max) x/sys/cpu: ARM64.HasAES = false on Apple Silicon (M1 Max) Jun 24, 2024
@seankhliao seankhliao added OS-Darwin NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. arch-arm64 labels Jun 24, 2024
@gopherbot gopherbot added this to the Unreleased milestone Jun 24, 2024
@seankhliao
Copy link
Member

@ericlagergren
Copy link
Contributor

@aadomnicai
Copy link
Author

See https://go-review.googlesource.com/c/sys/+/397754

Thanks for pointing this out.
Any insight on why this has not been merged so far?

@ericlagergren
Copy link
Contributor

See https://go-review.googlesource.com/c/sys/+/397754

Thanks for pointing this out.

Any insight on why this has not been merged so far?

I need to make the fixes requested by the reviewers, then it needs to be reviewed again.

@ericlagergren
Copy link
Contributor

This is mostly a dupe of #43046

@aadomnicai
Copy link
Author

https://go-review.googlesource.com/c/sys/+/397754

Your responses to the remaining two issues make sense to me, and it seems that it could be merged as it is. Any idea of why the reviewer did not provide feedback?

@FiloSottile
Copy link
Contributor

Note that hardware AES is selected based on the internal/cpu package, which always sets HasAES to true. The x/sys/cpu package indeed doesn't, and that's #43046.

@FiloSottile FiloSottile closed this as not planned Won't fix, can't repro, duplicate, stale Sep 29, 2024
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/616555 mentions this issue: sha3: add SIMD implementation with ARMv8.2 features

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-arm64 NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Darwin
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants