feat(relinker): support SSE guest GS memory accesses #11689
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11689"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by Felipebmaitan on 2026-10-27T02:53:20Z.
What
The relinker replays bounded legacy SSE memory moves through the protected guest GS frame. Native instructions supply widths, alignment, lane and MXCSR behavior. Unmodeled arithmetic, prefixes, MMX and VEX/EVEX/XOP keep the UD2 fallback.
The follow-up adds native load and store coverage for a short GS instruction followed by a borrowed
mov ebx, imm32and a GS SSE move using RBX as its base or scaled index. The first replay restores its scratch before the follower runs. The later replay reads the new RBX for address formation, then saves and restores it around the SSE instruction. The reported clobber did not reproduce and the follow-up changes only the test.This remains a draft targeting main. The latest published #11661 head
b813f34cfbbadc2d73e879b1e973491add56377cis already included. Its follow-up was unpublished when its worker ended, so current-main integration and fresh validation of that stack are pending. View the SSE increment over #11661.Tested
Fresh validation on
faf9d25c09f105a84ed01c3c9785651d9d989281used native Windows 11 Pro build 26300, an x86-64 Ryzen 7 9800X3D, WinLibs GCC 15.2.0, Ninja and Release. A clean relinker-only configure and build passed 50/50 focused CTests across scalar, short and SSE GS replay, faults, fallback, relocations, lookup, entry bounds, TLS and ELF reader bounds. The SSE address test passed all 85 cases, including the four borrowed RBX cases.With that fresh relinker and the saved production
libcand fixtures, all 85 production SSE address cases and the relocation/startup integration fixture passed. The production build did not start because the shared build mutex remained held on retry.In the earlier control run on native Windows 11 Pro build 26300 (x86-64 Ryzen 7 9800X3D), I ran the updated SSE address group against the saved WinLibs GCC 15.2 Release relinker and both the standalone and production-libc runners. Both passed 85/85 cases, including the four new cases. The saved sources matched the reviewed head
5551631d9e9263e8634e44d272d683966e1d18b5across 622 relinker, libc and build inputs after line-ending normalization. In separate controls, removing RBX from the emitted replay address record caused each new case to fail the expected vector-state or store-footprint assertion.Local conventions and diff whitespace checks passed before this head was pushed. Hosted Conventions reported the unchecked current-main checklist item. Hosted Conventions result. The function-name overlap scan searched 2,235 open PRs and reported no matches for the queried names. The candidate
faf9d25c09f105a84ed01c3c9785651d9d989281changes only the Python test relative to the reviewed head. The earlier 37/37 Windows production/relinker results and hosted checks were reported for5551631d9e9263e8634e44d272d683966e1d18b5. A fresh production libc build, a current-main merged run, hosted production checks and title execution remain pending.One independent reviewer inspected the immutable
5551631d9e..faf9d25c09range and runtime path and found no blocking issues. The current-main merge still has inherited ELF reader, bounds-test and debt conflicts. MarcZX10’s follow-up found no blocking defect in the inspected ranges and recorded a comment without formal approval. GitHub previously denied the re-review request because this account lacks upstream write access. A collaborator with upstream access can request formal review and run the production workflow once the stack can merge. MarcZX10’s follow-up review.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-11-01T19:49:26Z.
Review: COMMENTED
Correction (2026-11-01): this review's claim that maintainers close PRs without a title ID is wrong. CONTRIBUTING allows
Unblocks: none; a title is only required when the PR fixes a title. The technical points below are unaffected.No title ID and no log line. The Tested section states "No PS5, title, title-unblock or performance verification is claimed". Maintainers close PRs that name no title ID plus a log line proving a title reaches the change on main. Which title runs SSE
%gs:accesses through this path, and what does main log for it today?Stacked branch. 43 commits and 39 files (+2336) because the branch carries #11624, #11628, #11661 and the carried #11090/#11276 prerequisites. The main-target diff mixes four PRs. Please keep this draft until the prerequisites merge, or retarget it so only the SSE layer is reviewed. #11698 builds on this one in the same way, so the same applies there.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T09:28:13Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: preserve the original scratch-register value when a borrowed follower modifies it.
What I ran
Reviewed head
5551631d9e9263e8634e44d272d683966e1d18b5; no local commands or tests were run. I inspected the prepared diff and all changed-file contents listed in the review manifest. No merged-preview check was run.Results
Findings
Blocking
core/relinker/elfpatcher/src/windows/WindowsTlsBuilder.cpp:278accepts a borrowed follower that writes the scratch register selected for the preceding GS replay. For example, a GS memory instruction followed bymov ebx, 1and then a GS SSE memory instruction can borrow themovinto the latter's replay span.WindowsGuestGs::TryAppendchooses EBX as the second instruction's scratch for common vector moves (core/relinker/elfpatcher/src/windows/WindowsGuestGs.cpp:53-54). The first replay restores EBX before resuming at the second GS instruction, but the borrowedmov ebx, 1then changes EBX before the second replay computes its effective address from it. The result is a wrong memory access and potentially corrupted guest state. Reject borrowing when a follower clobbers a register used as a later replay base/index, or preserve and restore that register across the borrowed span. The borrowed-follower tests do not cover this register dependency.Non-blocking
None.
Not verified
No machine-side tests were run. The author reports focused Windows tests at the reviewed head; this review did not reproduce them. PS5/title behavior, physical non-AVX behavior, and performance remain unverified as stated in the PR description. No files were excluded by the review manifest.
To get this to a good state
Add a regression covering a borrowed follower that writes the next GS replay's base or index register, fix the register preservation or borrowing policy, and rerun the focused Windows GS tests.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T02:06:12Z.
Review: COMMENTED
Reviewed — no blocking findings
The inspected code shows no verified blocking defect, but a formal approval is not justified because the full changed-file set and fresh validation on this head were not reviewed or run.
What I ran
Head:
faf9d25c09f105a84ed01c3c9785651d9d989281. I usedrepo_read.pyto inspect the prepared review bundle and targeted repository ranges. No build or tests were run.Results
Findings
Blocking
None identified in the inspected ranges.
Non-blocking
Not verified
I read
description.md,commits.md,manifest.json, anddiff.patch, plus targeted ranges fromcore/relinker/elfpatcher/src/windows/WindowsGuestGs.cpp,core/relinker/relinker/tests/test_windows_guest_gs_sse.py, andcore/libs/tests/GuestGsLookup.cpp. The prepared file listing shows 34 changed files, all included; I did not read every changed file or every hunk.review/files.jsonwas not available as a review document. Build, tests, current-main merge, hosted checks, and title or console execution were not verified here.To get this to a good state
Nothing is required. Optional: complete current-main integration and fresh production validation on this head.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.