diff options
author | Elias Naur <elias.naur@gmail.com> | 2018-11-04 09:36:25 +0100 |
---|---|---|
committer | Elias Naur <elias.naur@gmail.com> | 2018-11-04 19:34:07 +0000 |
commit | efd229238aceefdee6a00ea28b61c924c2b5f1a5 (patch) | |
tree | 45501c0a6a3003c5505e5e8e49bdcb54a7facf31 /src/runtime/os_linux_arm64.go | |
parent | 4bb9b61677e937d1f473c27607da3608d0fa7099 (diff) | |
download | go-efd229238aceefdee6a00ea28b61c924c2b5f1a5.tar.gz go-efd229238aceefdee6a00ea28b61c924c2b5f1a5.zip |
runtime: avoid arm64 8.1 atomics on Android
The kernel on some Samsung S9+ models reports support for arm64 8.1
atomics, but in reality only some of the cores support them. Go
programs scheduled to cores without support will crash with SIGILL.
This change unconditionally disables the optimization on Android.
A better fix is to precisely detect the offending chipset.
Fixes #28431
Change-Id: I35a1273e5660603824d30ebef2ce7e429241bf1f
Reviewed-on: https://go-review.googlesource.com/c/147377
Run-TryBot: Elias Naur <elias.naur@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/runtime/os_linux_arm64.go')
-rw-r--r-- | src/runtime/os_linux_arm64.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/runtime/os_linux_arm64.go b/src/runtime/os_linux_arm64.go index cbe528b4af..2d6f68bdd9 100644 --- a/src/runtime/os_linux_arm64.go +++ b/src/runtime/os_linux_arm64.go @@ -22,7 +22,15 @@ func archauxv(tag, val uintptr) { case _AT_HWCAP: // arm64 doesn't have a 'cpuid' instruction equivalent and relies on // HWCAP/HWCAP2 bits for hardware capabilities. - cpu.HWCap = uint(val) + hwcap := uint(val) + if GOOS == "android" { + // The Samsung S9+ kernel reports support for atomics, but not all cores + // actually support them, resulting in SIGILL. See issue #28431. + // TODO(elias.naur): Only disable the optimization on bad chipsets. + const hwcap_ATOMICS = 1 << 8 + hwcap &= ^uint(hwcap_ATOMICS) + } + cpu.HWCap = hwcap case _AT_HWCAP2: cpu.HWCap2 = uint(val) } |