From 59e60aa80a0c64fa4b088976ee16ad7f04252c25 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Fri, 17 Jan 2020 15:32:12 +0100 Subject: [PATCH] cpu: don't read ARM64 registers on Android It seems like on Android we're not allowed in all cases to read the registers ISAR0, ISAR1 and PFR0 to detect CPU features. Fixes golang/go#36622 Change-Id: I577bd928a5a4dcd6e908cf059faa15fc0c80e3e5 Reviewed-on: https://go-review.googlesource.com/c/sys/+/215237 Run-TryBot: Tobias Klauser TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- cpu/cpu_arm64.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cpu/cpu_arm64.go b/cpu/cpu_arm64.go index 6ac0b353..9c87677a 100644 --- a/cpu/cpu_arm64.go +++ b/cpu/cpu_arm64.go @@ -10,9 +10,13 @@ const cacheLineSize = 64 func init() { switch runtime.GOOS { - case "darwin": - // iOS does not seem to allow reading these registers - case "android", "linux": + case "android", "darwin": + // Android and iOS don't seem to allow reading these registers. + // Fake the minimal features expected by + // TestARM64minimalFeatures. + ARM64.HasASIMD = true + ARM64.HasFP = true + case "linux": doinit() default: readARM64Registers()