Skip to content

Commit f3b9f36

Browse files
Elias Naurbradfitz
Elias Naur
authored andcommitted
[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 <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Keith Randall <[email protected]> Reviewed-on: https://go-review.googlesource.com/c/149557 Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent 402eb45 commit f3b9f36

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/runtime/os_linux_arm64.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,17 @@ func archauxv(tag, val uintptr) {
2929
randomNumber = uint32(startupRandomData[4]) | uint32(startupRandomData[5])<<8 |
3030
uint32(startupRandomData[6])<<16 | uint32(startupRandomData[7])<<24
3131
case _AT_HWCAP:
32-
cpu_hwcap = uint(val)
32+
// arm64 doesn't have a 'cpuid' instruction equivalent and relies on
33+
// HWCAP/HWCAP2 bits for hardware capabilities.
34+
hwcap := uint(val)
35+
if GOOS == "android" {
36+
// The Samsung S9+ kernel reports support for atomics, but not all cores
37+
// actually support them, resulting in SIGILL. See issue #28431.
38+
// TODO(elias.naur): Only disable the optimization on bad chipsets.
39+
const hwcap_ATOMICS = 1 << 8
40+
hwcap &= ^uint(hwcap_ATOMICS)
41+
}
42+
cpu_hwcap = hwcap
3343
case _AT_HWCAP2:
3444
cpu_hwcap2 = uint(val)
3545
}

0 commit comments

Comments
 (0)