]> Cypherpunks repositories - gostls13.git/commit
[dev.simd] internal/cpu: report AVX1 and 2 as supported on macOS 15 Rosetta 2
authorCherry Mui <cherryyz@google.com>
Sat, 30 Aug 2025 00:33:19 +0000 (20:33 -0400)
committerCherry Mui <cherryyz@google.com>
Tue, 2 Sep 2025 21:17:26 +0000 (14:17 -0700)
commit91253515831d1d51f9a998a743309c94e1fc4e1e
tree487d6e7758bc8d20ff69b932a9e438128470715b
parentb509516b2e96654be4e6a2dc979414df5df7d14b
[dev.simd] internal/cpu: report AVX1 and 2 as supported on macOS 15 Rosetta 2

Apparently, on macOS 15 or newer, Rosetta 2 supports AVX1 and 2.
However, neither CPUID nor the Apple-recommended sysctl says it
has AVX. If AVX is used without checking the CPU feature, it may
run fine without SIGILL, but the runtime doesn't know AVX is
available therefore save and restore its states. This may lead to
value corruption.

Check if we are running under Rosetta 2 on macOS 15 or newer. If so,
report AVX1 and 2 as supported.

Change-Id: Ib981379405b1ae28faa378f051096827d760a4cc
Reviewed-on: https://go-review.googlesource.com/c/go/+/700055
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
src/internal/cpu/cpu_arm64_darwin.go
src/internal/cpu/cpu_darwin.go [new file with mode: 0644]
src/internal/cpu/cpu_x86.go
src/internal/cpu/cpu_x86_darwin.go [new file with mode: 0644]
src/internal/cpu/cpu_x86_other.go [new file with mode: 0644]
src/runtime/cpuflags_amd64_test.go [new file with mode: 0644]
src/runtime/export_test.go
src/runtime/os_darwin.go
src/runtime/testdata/testprog/cpuflags_amd64.go [new file with mode: 0644]
src/runtime/testdata/testprog/cpuflags_amd64.s [new file with mode: 0644]