fix(relinker): preserve FS/GS accesses during Windows red-zone conversion #27668
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/27668"
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 lgqdaxia on 2026-11-26T21:56:43Z.
What
Windows conversion with
--frame-red-zonecan abort withAMD-only site bytes changed before patchingwhen a proposed frame stub covers an FS or GS memory access rewritten by the Windows TLS builder. The framer now skips those overlapping frames and still frames eligible leaves whose stubs avoid the access.The Windows TLS builder translates supported guest FS accesses. It replaces recognized guest GS memory accesses with
UD2. Skipping a frame site that overlaps a GS trap can let conversion finish, and executing that trap still raises an illegal-instruction exception.Tested
Windows 11 x64, MinGW. The synthetic cases cover both FS and GS at a proposed stub site and in a leaf that can still be framed. The same cases reproduce the failure on the base commit. Both the red-zone framer suite and its native execution suite pass on the candidate. A local Windows integration conversion also completed past the original diagnostic.
pr_overlapreports #19336 (decoding past an interiorint3) and #25483 (unwind ranges that end inside an instruction). Both change the same instruction loop. Nesyth's #16371 adds whole-leaf relocation for functions an in-place frame cannot cover. This change applies to in-place framing on main.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)Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-26T22:07:00Z.
Review: APPROVED
Reviewed — looks good
The changed code protects FS/GS memory-access instructions from overlapping red-zone stubs, and the inspected implementation and tests support the stated behavior.
What I ran
Reviewed head
e6493ee87cd278537bb22eb005eff6a394b3b9e7. Read the prepared description, commit list, diff, manifest, and both changed files, plus targeted decoder metadata and framer logic. No tests or build commands were run. The description reports Windows 11 x64/MinGW test runs; those results were not independently verified.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
No tests, build, Windows conversion, or native execution suite was run in this review. No files were excluded by the manifest; both reviewed changed files were read.
files.jsonwas not available in the prepared bundle.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by Plyxen on 2026-11-27T03:55:47Z.
Review: APPROVED
Checked head
e6493ee87c. I applied it tomainad7582bad4together with #27680, #27649 and #27560, which touch different files. On Windows 11 with WinLibs GCC 15.2 (Release),tools/check_conventions.py --headon each head andtools/debt_fold.py --checkpassed, the build succeeded, and all 4,930 CPU tests passed (I left out the GPU tests). The ten relinker and codegen tests I ran for these four (amd64_only_converter,amd64_only_windows,red_zone_framer,red_zone_framer_execution,lane_split_lowering,relinker_conversionand four more) passed.With
main'sRedZoneFramer.cppand the new test,red_zone_framerfails.The framer now collects the offsets of FS- and GS-prefixed memory accesses in the leaf body, and
overlapsExistingrefuses a stub that covers one, on top of the existing trampoline check. So an access that Windows segment handling already rewrote keeps its address, and theAMD-only site bytes changed before patchingabort cannot happen there. A leaf whose stubs avoid the access is still framed, aspreservesWindowsSegmentAccesseschecks.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T07:04:45Z.
Review: COMMENTED
Ran the red-zone framer unit and execution suites and
linux_fixed_basein the Linux relinker-only build. All passed, including the new FS/GS segment cases in the unit fixture.AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-04T05:05:46Z.
Review: COMMENTED
Actionable comments
2cbfab8d-0669-4bd2-b06d-141355ce7576Reviewing files that changed from the base of the PR and between
e6493ee87candb3926f454b.core/relinker/codegen/src/x86/RedZoneFramer.cppcore/relinker/codegen/tests/RedZoneFramerTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-04T05:11:14Z.
Review: APPROVED
Reviewed — looks good
The change keeps FS/GS memory instructions outside red-zone trampoline ranges while allowing unrelated eligible functions to be framed.
What I ran
Reviewed head
b3926f454b1730179c086bc3a6de3835b6d377f0against the statedmainbase; no merged-preview check was run. I usedrepo_read.pyfor targeted source and test inspection. No tests, builds, or Windows integration conversion were run.Results
Negative control
Not run; no negative-control test was run during this review.
Findings
Blocking
None.
Non-blocking
None.
Sources
The framer records FS/GS memory instruction ranges and includes them in its existing overlap checks for trampoline sites (RedZoneFramer.cpp at the reviewed head). The decoder populates the memory-operand and segment-prefix fields used by that check (X64InstructionDecoder.cpp). The added test covers both FS and GS and checks that another eligible function can still be framed (RedZoneFramerTests.cpp).
Not verified
Read both changed files:
core/relinker/codegen/src/x86/RedZoneFramer.cppandcore/relinker/codegen/tests/RedZoneFramerTests.cpp;files.jsonlists no excluded files. The author-reported test and Windows integration results were not independently confirmed. No runtime behavior on Windows or physical console was verified.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-04T05:21:08Z.
Review: COMMENTED
Actionable comments
3202e6c6-e9d6-4708-9327-fd534c4c7787Reviewing files that changed from the base of the PR and between
b3926f454band3f79fa750d.core/relinker/codegen/src/x86/RedZoneFramer.cppcore/relinker/codegen/tests/RedZoneFramerTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-04T05:21:27Z.
Review: APPROVED
Reviewed — looks good
The reviewed changes keep FS/GS memory accesses outside red-zone trampoline ranges, and I found no verified blocking defect.
What I ran
Reviewed head
3f79fa750db04a8835e3636772ec17579b42dcedusing the pinnedrepo_read.pyreader. The workspace was read-only; no tests or builds were run.Reader output returned the requested ranges, but its audit-log append failed because the workspace is read-only. No merged-preview check was run.
Results
Negative control
Not run; no tests were executed.
Findings
Blocking
None.
Non-blocking
None.
Sources
Not verified
The reported Windows 11 x64 MinGW integration conversion and test-suite runs were not run during this review.
files.jsonlists both changed files as reviewed and no files as excluded.To get this to a good state
No follow-up is required.
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.