Skip to content

Commit efd2292

Browse files
author
Elias Naur
committed
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>
1 parent 4bb9b61 commit efd2292

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/runtime/os_linux_arm64.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,15 @@ func archauxv(tag, val uintptr) {
2222
case _AT_HWCAP:
2323
// arm64 doesn't have a 'cpuid' instruction equivalent and relies on
2424
// HWCAP/HWCAP2 bits for hardware capabilities.
25-
cpu.HWCap = uint(val)
25+
hwcap := uint(val)
26+
if GOOS == "android" {
27+
// The Samsung S9+ kernel reports support for atomics, but not all cores
28+
// actually support them, resulting in SIGILL. See issue #28431.
29+
// TODO(elias.naur): Only disable the optimization on bad chipsets.
30+
const hwcap_ATOMICS = 1 << 8
31+
hwcap &= ^uint(hwcap_ATOMICS)
32+
}
33+
cpu.HWCap = hwcap
2634
case _AT_HWCAP2:
2735
cpu.HWCap2 = uint(val)
2836
}

0 commit comments

Comments
 (0)