1// Copyright 2015 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5// +build arm64
6
7package runtime
8
9import "internal/cpu"
10
11func archauxv(tag, val uintptr) {
12	switch tag {
13	case _AT_HWCAP:
14		// arm64 doesn't have a 'cpuid' instruction equivalent and relies on
15		// HWCAP/HWCAP2 bits for hardware capabilities.
16		hwcap := uint(val)
17		if GOOS == "android" {
18			// The Samsung S9+ kernel reports support for atomics, but not all cores
19			// actually support them, resulting in SIGILL. See issue #28431.
20			// TODO(elias.naur): Only disable the optimization on bad chipsets.
21			const hwcap_ATOMICS = 1 << 8
22			hwcap &= ^uint(hwcap_ATOMICS)
23		}
24		cpu.HWCap = hwcap
25	case _AT_HWCAP2:
26		cpu.HWCap2 = uint(val)
27	}
28}
29