Skip to content

Commit 739fb75

Browse files
prattmicgopherbot
authored andcommitted
runtime: don't restore from g0.sched in systemstack on arm64
On arm64, systemstack restores the frame pointer from g0.sched to R29 prior to calling the callback. That doesn't really make any sense. The frame pointer value in g0.sched is some arbitrary BP from a prior context save, but that is not the caller of systemstack. amd64 does not do this. In fact, it leaves BP completely unmodified so frame pointer unwinders like gdb can walk through the systemstack frame and continue traceback on the caller's stack. Unlike mcall, systemstack always returns to the original goroutine, so that is safe. We should do the same on arm64. For #63630. Cq-Include-Trybots: luci.golang.try:gotip-linux-arm64-longtest Change-Id: I6a6a636c35d321dd5d7dc1c4d09e29b55b1ab621 Reviewed-on: https://go-review.googlesource.com/c/go/+/669236 Reviewed-by: Michael Knyszek <[email protected]> Reviewed-by: Cherry Mui <[email protected]> Auto-Submit: Michael Pratt <[email protected]> Reviewed-by: Nick Ripley <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent 9c1d19a commit 739fb75

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/runtime/asm_arm64.s

+4-2
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,10 @@ TEXT runtime·systemstack(SB), NOSPLIT, $0-8
276276
B runtime·abort(SB)
277277

278278
switch:
279-
// save our state in g->sched. Pretend to
279+
// Switch stacks.
280+
// The original frame pointer is stored in R29,
281+
// which is useful for stack unwinding.
282+
// Save our state in g->sched. Pretend to
280283
// be systemstack_switch if the G stack is scanned.
281284
BL gosave_systemstack_switch<>(SB)
282285

@@ -285,7 +288,6 @@ switch:
285288
BL runtime·save_g(SB)
286289
MOVD (g_sched+gobuf_sp)(g), R3
287290
MOVD R3, RSP
288-
MOVD (g_sched+gobuf_bp)(g), R29
289291

290292
// call target function
291293
MOVD 0(R26), R3 // code pointer

0 commit comments

Comments
 (0)