ffi: preserve link register in ppc64 trampoline - #64792
Open
trivikr wants to merge 1 commit into
Open
Conversation
The ppc64 fast FFI trampoline uses `bl` to obtain the address used to load its target literal. This overwrites the caller's link register, so optimized FFI calls return into the trampoline and loop indefinitely. Save and restore the caller's link register around the branch. Also align the target literal for both even and odd GP argument counts. Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com> Assisted-by: codex:gpt-5.6-sol
Collaborator
|
Review requested:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #64792 +/- ##
==========================================
- Coverage 90.16% 90.14% -0.02%
==========================================
Files 744 744
Lines 242518 242518
Branches 45705 45693 -12
==========================================
- Hits 218670 218622 -48
- Misses 15357 15401 +44
- Partials 8491 8495 +4 🚀 New features to boost your workflow:
|
Member
Author
|
Verified that the |
ShogunPanda
approved these changes
Jul 28, 2026
This comment was marked as outdated.
This comment was marked as outdated.
Collaborator
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.
Refs: #64639 (comment)
The PPC64LE fast FFI trampoline uses
bl .+4to obtain the addressneeded to load its target literal. The
blinstruction overwrites thecaller's link register, but the trampoline did not restore it before
tail-branching to the native target.
As a result, optimized FFI calls could return into the trampoline
instead of returning to V8, causing an infinite loop. This manifested
as 120-second timeouts on
rhel8-power9leandrhel9-ppc64le.Preserve the caller's link register in
r0and restore it before thetail branch. The target literal padding is also selected according to
the GP argument count so that the literal remains 8-byte aligned.
Assisted-by: codex:gpt-5.6-sol