From 05986578812163b26672dabd9b425240ae2bb0ad Mon Sep 17 00:00:00 2001 From: Benny Siegert Date: Sat, 23 May 2020 20:33:20 +0200 Subject: [PATCH] cpu: avoid illegal instruction on netbsd/arm64 On NetBSD, this package tries to read a privileged register, which results in a SIGILL. Use the same workaround as Android and iOS. In the future, we could use sysctl(3) instead. Update golang/go#30824 Change-Id: Ifd9aa2a2cf4dac43341d013602d1ccb4b8d6eb6d Reviewed-on: https://go-review.googlesource.com/c/sys/+/235097 Reviewed-by: Tobias Klauser Run-TryBot: Tobias Klauser TryBot-Result: Gobot Gobot --- cpu/cpu_arm64.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cpu/cpu_arm64.go b/cpu/cpu_arm64.go index 9c87677a..7bcb36c7 100644 --- a/cpu/cpu_arm64.go +++ b/cpu/cpu_arm64.go @@ -10,8 +10,14 @@ const cacheLineSize = 64 func init() { switch runtime.GOOS { - case "android", "darwin": + case "android", "darwin", "netbsd": // Android and iOS don't seem to allow reading these registers. + // + // NetBSD: + // ID_AA64ISAR0_EL1 is a privileged register and cannot be read from EL0. + // It can be read via sysctl(3). Example for future implementers: + // https://nxr.netbsd.org/xref/src/usr.sbin/cpuctl/arch/aarch64.c + // // Fake the minimal features expected by // TestARM64minimalFeatures. ARM64.HasASIMD = true