Repository navigation
internal/fakecgo: reserve threadentry's spill slot on ppc64le - #570
Merged
Merged
Conversation
Contributor
Author
|
@hajimehoshi please review |
This was referenced Nov 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What issue is this addressing?
@hajimehoshi hey,
this is the ppc64le follow-up from #568:
threadentry_trampolinesaves the C caller'sR14in the spill slot ofthreadentry's register argument, and athreadentrythat spillsvhands libcR14 = v.What type of issue is this addressing?
updates #571.
What this PR does | solves
Cause.
threadentryis ABIInternal with one register argument, and its caller reserves that argument's spill slot right after the 32-byte fixed frame, at32(R1). The trampoline'sSAVE_GPR(32)putsR14, callee-saved under ELFv2, in that slot.It is latent today: the optimized
threadentrydoesn't spillv,-Nbuilds don't link on ppc64le (nosplit overflow inx_cgo_thread_start, also onmain), and glibc'sstart_threaddoesn't readR14after the start routine returns. It is an ABI violation that only a probe shows, as in #568.Fix. Reserve 8 bytes for the slot: the saves start at
40(R1), and the frame grows from 320 to 336 bytes, rounded up to keepR116-byte aligned.Test.
TestThreadEntryTrampolinePreservesR14, the same shape as #568's test:v, which makes the compiler store it in its spill slot, and forwards any other call to the realthreadentry.callThreadEntryTrampoline, that puts a known value inR14, calls the trampoline and returnsR14. The trampoline returns to C with CR's value inR0, so the helper clearsR0, which Go code expects to be 0.R14.CI. The qemu jobs build only the root package, so the ppc64le step gets lines that build and run the fakecgo test binary, default and PIE. Without them the test doesn't run in CI.
Testing. linux/ppc64le under qemu-user 10.0.13 (Docker, Debian 13, glibc 2.41), Go 1.27.3 and 1.25.0:
R14equals the argument). With it, it passes 20 times in each, andTestThreadEntryReturnstill passes.go vetreports the same two findings as onmain(setg_trampoline,call5), which this PR doesn't touch.Notes.
test.yml, so either can merge first.STACK_AND_SAVE_HOST_TO_GO_ABI, whichcrosscall2uses. The trampoline doesn't saveV20-V31, which are callee-saved under ELFv2, and Go assembly does use them (crypto,bytealg). It is latent the same way:start_threaduses no vector registers after the call. Switching to the macro would fix that too, but it changes the frame to 528 bytes and the test; I can send it separately if you'd like.