]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: align end of systemstack_switch prologue on amd64 for consistency with gosav...
authorVasily Leonenko <vasiliy.leonenko@gmail.com>
Thu, 29 Jan 2026 18:12:49 +0000 (21:12 +0300)
committerGopher Robot <gobot@golang.org>
Fri, 30 Jan 2026 17:55:05 +0000 (09:55 -0800)
gosave_systemstack_switch saves PC with fixed offset of 8 bytes from systemstack_switch to bypass prologue.
This commit makes this offset consistent with actual address of UNDEF instruction intended to be at that address.

Fixes #71440

Change-Id: Ibe6458c5bcb0bdaec228a2f13d6aec7ecc0e319e
Reviewed-on: https://go-review.googlesource.com/c/go/+/740360
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
src/runtime/asm_amd64.s

index add69aa50020d7b7bb9273bdc0ad81b3ca4487e0..39219babcc3584266c2cde22bbc3baedbc697027 100644 (file)
@@ -510,6 +510,8 @@ goodm:
 // The frame layout needs to match systemstack
 // so that it can pretend to be systemstack_switch.
 TEXT runtime·systemstack_switch(SB), NOSPLIT, $0-0
+       // Align for consistency with offset used in gosave_systemstack_switch
+       PCALIGN $8
        UNDEF
        // Make sure this function is not leaf,
        // so the frame is saved.
@@ -885,8 +887,9 @@ TEXT ·publicationBarrier<ABIInternal>(SB),NOSPLIT,$0-0
 // Smashes R9.
 TEXT gosave_systemstack_switch<>(SB),NOSPLIT|NOFRAME,$0
        // Take systemstack_switch PC and add 8 bytes to skip
-       // the prologue. The final location does not matter
-       // as long as we are between the prologue and the epilogue.
+       // the prologue. Keep 8 bytes offset consistent with
+       // PCALIGN $8 in systemstack_swtich, pointing start of
+       // UNDEF instruction beyond prologue.
        MOVQ    $runtime·systemstack_switch+8(SB), R9
        MOVQ    R9, (g_sched+gobuf_pc)(R14)
        LEAQ    8(SP), R9