Skip to content

Commit

Permalink
cpu: avoid illegal instruction on netbsd/arm64
Browse files Browse the repository at this point in the history
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 <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
  • Loading branch information
bsiegert authored and tklauser committed May 23, 2020
1 parent fe76b77 commit 0598657
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cpu/cpu_arm64.go
Expand Up @@ -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
Expand Down

0 comments on commit 0598657

Please sign in to comment.