aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElias Naur <elias.naur@gmail.com>2018-11-04 09:36:25 +0100
committerBrad Fitzpatrick <bradfitz@golang.org>2018-11-14 16:45:00 +0000
commitf3b9f362c9f81fba61663002eac7f065afd9afd1 (patch)
tree2c2f797a80516879703e97a855cb381ceacc51a9
parent402eb45b217d315840f63ed60895c256bdca04ce (diff)
downloadgo-f3b9f362c9f81fba61663002eac7f065afd9afd1.tar.gz
go-f3b9f362c9f81fba61663002eac7f065afd9afd1.zip
[release-branch.go1.11] 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 #28586 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> Reviewed-on: https://go-review.googlesource.com/c/149557 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
-rw-r--r--src/runtime/os_linux_arm64.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/runtime/os_linux_arm64.go b/src/runtime/os_linux_arm64.go
index 28a0319f10..59f3df47fe 100644
--- a/src/runtime/os_linux_arm64.go
+++ b/src/runtime/os_linux_arm64.go
@@ -29,7 +29,17 @@ func archauxv(tag, val uintptr) {
randomNumber = uint32(startupRandomData[4]) | uint32(startupRandomData[5])<<8 |
uint32(startupRandomData[6])<<16 | uint32(startupRandomData[7])<<24
case _AT_HWCAP:
- cpu_hwcap = uint(val)
+ // arm64 doesn't have a 'cpuid' instruction equivalent and relies on
+ // HWCAP/HWCAP2 bits for hardware capabilities.
+ 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)
}