aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
authorAndrey Bokhanko <andreybokhanko@gmail.com>2024-09-03 08:19:18 +0300
committerCherry Mui <cherryyz@google.com>2024-10-22 16:16:32 +0000
commit4e7025860129b33f704634583d20539af19c344b (patch)
tree8beeb78119bc864d287a5a88638cb4b7e99544fb /src/runtime
parent38f85967873b1cd48c20681c5dff0e9f3de18516 (diff)
downloadgo-4e7025860129b33f704634583d20539af19c344b.tar.xz
runtime: Check LSE support on ARM64 at runtime init
Check presence of LSE support on ARM64 chip if we targeted it at compile time. Related to #69124 Update #60905 Change-Id: I6fe244decbb4982548982e1f88376847721a33c7 Reviewed-on: https://go-review.googlesource.com/c/go/+/610195 Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Shu-Chun Weng <scw@google.com>
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/asm_arm64.s37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/runtime/asm_arm64.s b/src/runtime/asm_arm64.s
index 64a1880589..88bfd3ce5c 100644
--- a/src/runtime/asm_arm64.s
+++ b/src/runtime/asm_arm64.s
@@ -8,6 +8,11 @@
#include "funcdata.h"
#include "textflag.h"
+#ifdef GOARM64_LSE
+DATA no_lse_msg<>+0x00(SB)/64, $"This program can only run on ARM64 processors with LSE support.\n"
+GLOBL no_lse_msg<>(SB), RODATA, $64
+#endif
+
TEXT runtime·rt0_go(SB),NOSPLIT|TOPFRAME,$0
// SP = stack; R0 = argc; R1 = argv
@@ -77,6 +82,21 @@ nocgo:
BL runtime·wintls(SB)
#endif
+ // Check that CPU we use for execution supports instructions targeted during compile-time.
+#ifdef GOARM64_LSE
+#ifndef GOOS_openbsd
+ // Read the ID_AA64ISAR0_EL1 register
+ MRS ID_AA64ISAR0_EL1, R0
+
+ // Extract the LSE field (bits [23:20])
+ LSR $20, R0, R0
+ AND $0xf, R0, R0
+
+ // LSE support is indicated by a non-zero value
+ CBZ R0, no_lse
+#endif
+#endif
+
MOVW 8(RSP), R0 // copy argc
MOVW R0, -8(RSP)
MOVD 16(RSP), R0 // copy argv
@@ -95,6 +115,23 @@ nocgo:
// start this M
BL runtime·mstart(SB)
+ RET
+
+#ifdef GOARM64_LSE
+#ifndef GOOS_openbsd
+no_lse:
+ MOVD $1, R0 // stderr
+ MOVD R0, 8(RSP)
+ MOVD $no_lse_msg<>(SB), R1 // message address
+ MOVD R1, 16(RSP)
+ MOVD $64, R2 // message length
+ MOVD R2, 24(RSP)
+ CALL runtime·write(SB)
+ CALL runtime·exit(SB)
+ CALL runtime·abort(SB)
+ RET
+#endif
+#endif
// Prevent dead-code elimination of debugCallV2 and debugPinnerV1, which are
// intended to be called by debuggers.