From 77343fa646c5d2a01fb3cbeabda1b3ff008c3b03 Mon Sep 17 00:00:00 2001 From: Joel Sing Date: Thu, 6 Feb 2025 00:38:51 +1100 Subject: [PATCH] runtime: use return for async preemption resumption on arm64 Use return with register for async preemption resumption on arm64. This has the same behaviour as the current use of JMP, however is permitted when Branch Target Identification is being enforced, while a JMP with register is considered an indirect call and requires a `BTI J` marker at the resumption address. Updates #66054 Change-Id: I135ac577073467bedd9efd8df15b76c97dc08767 Reviewed-on: https://go-review.googlesource.com/c/go/+/646782 Reviewed-by: Dmitri Shuralyov LUCI-TryBot-Result: Go LUCI Reviewed-by: Cherry Mui --- src/runtime/mkpreempt.go | 2 +- src/runtime/preempt_arm64.s | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/runtime/mkpreempt.go b/src/runtime/mkpreempt.go index 08500a90d5..6a9cf77a43 100644 --- a/src/runtime/mkpreempt.go +++ b/src/runtime/mkpreempt.go @@ -370,7 +370,7 @@ func genARM64() { p("MOVD -8(RSP), R29") // restore frame pointer p("MOVD (RSP), R27") // load PC to REGTMP p("ADD $%d, RSP", l.stack+16) // pop frame (including the space pushed by sigctxt.pushCall) - p("JMP (R27)") + p("RET (R27)") } func genMIPS(_64bit bool) { diff --git a/src/runtime/preempt_arm64.s b/src/runtime/preempt_arm64.s index c27d475dee..31ec9d940f 100644 --- a/src/runtime/preempt_arm64.s +++ b/src/runtime/preempt_arm64.s @@ -82,4 +82,4 @@ TEXT ·asyncPreempt(SB),NOSPLIT|NOFRAME,$0-0 MOVD -8(RSP), R29 MOVD (RSP), R27 ADD $512, RSP - JMP (R27) + RET (R27) -- 2.51.0