fix(relinker): ignore segment overrides on fixed-ES string instructions #11276
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11276"
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 plexerPK on 2026-10-25T23:32:27Z.
What
Ignore ineffective FS/GS overrides on the fixed-ES INS, STOS and SCAS opcode families while retaining their implicit memory-operand classification. Main currently rejects FS-prefixed forms as unsupported TLS accesses or replaces GS-prefixed forms with UD2. Source-string forms keep their existing segment handling.
This follows Intel SDM Volume 2, the INS, STOS and SCAS instruction descriptions, which specify the fixed ES destination/access. It follows merged #9719 as agreed with its author and preserves that change's LEA/NOP memory classification. #9719 merged at 2026-10-25T23:15:59Z as
2b5225605bd58c91fff82a7dafcb8c6e9a33d569.Tested
macOS arm64, AppleClang 21.0.0.21000334, Python 3.9.6, CMake 4.4.4 and Ninja 1.13.2.git.kitware.jobserver-pipe-1. Prepared head
bb45d3315d276b8aae4ca6eba705ea4b4d6a31e9on main2b5225605bd58c91fff82a7dafcb8c6e9a33d569.The focused tests ran at
c01f2f6f8a494d2e31bf2817b5564ad4af663290before relocating the three-line CTest registration to avoid an insertion conflict with #10946. All production and test-source blobs are byte-identical at the prepared head; CMake regeneration reports Ninja has no work, and the eight selected test names, commands and properties are unchanged.Built fresh relinker-only Release binaries and decoder_length_tests from both pinned source trees (90 Ninja steps each). Head passes 8/8 focused CTests: decoder_length, ignored_string_segments, macos_gs_traps, tls_diagnostics and the rejected/gs_traps/gs_traps_implicit/gs_non_memory TLS coverage groups. The matching seven existing groups pass 7/7 on main, including merged #9719's LEA/NOP coverage. The new conversion regression fails on main at windows-646c with the expected unsupported TLS diagnostic and passes all 96 byte-preservation conversion cases with the fix.
An additional 16 real CLI conversions compare FS INS, GS STOS and FS/GS MOVSB controls across Windows/macOS outputs on both binaries. Main rejects FS INS and emits UD2 for GS STOS; head preserves both fixed-ES forms. Source-string controls retain their previous rejection/trap behavior. Decoder coverage checks 28 FS/GS fixed-ES and neighboring source-string combinations retain their implicit memory classification and effective segment.
Conventions and whitespace checks pass. Fresh title/text/actual-file checks found no competing fixed-ES implementation; the initial official scan found only a CMake registration insertion collision with #10946, a distinct macOS TLS-export fix. Relocation removes it, and exact heads combine cleanly. The final official scan reports no detected overlapping compared regions and only the two old-base incomparable warnings below. The authored shared-CMake diffs for old-base #5021 and #6713 are unrelated fixture registrations; no full combined integration is claimed.
These are synthetic conversion, byte inspection and native arm64 tooling/metadata tests. No converted x86 guest execution, native Linux/Windows runtime, physical x86/console, title, GPU or hosted-CI result is claimed.
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 MarcZX10 on 2026-10-25T23:45:27Z.
Review: APPROVED
Reviewed exact head
bb45d3315d276b8aae4ca6eba705ea4b4d6a31e9. The fixed-ES decoder change preserves implicit memory classification while ignoring ineffective FS/GS overrides for INS/STOS/SCAS; the added conversion and decoder cases cover neighboring source-string controls. The author reports the focused native macOS arm64 tooling suite, 8/8 head tests and 7/7 baseline tests, plus cross-format conversion checks. Hosted Ubuntu/Windows relinker and ASan checks pass; macOS relinker jobs remain queued, and product jobs are skipped by path policy. No blocking code issue found.Imported from boykopovar/AnyPS5. Originally posted by thepoppfish on 2026-10-26T00:41:59Z.
Review: APPROVED
Reviewed exact head
bb45d3315d276b8aae4ca6eba705ea4b4d6a31e9and independently validated this on Windows 11 build 26200, Intel Core Ultra 7 268V, with GCC 16.2.0-6 UCRT64, CMake 4.3.1, Ninja 1.13.2 and Python 3.14.7. No blocking issue found.The change keeps the implicit-memory classification and clears only the ineffective segment metadata for the six fixed-ES opcodes. Neighboring source-string instructions retain their segment handling; vector encodings return through their existing path before this new opcode check. Intel's XED instruction definitions at 0bcb623 also use the fixed ES operand for INS/STOS/SCAS.
I built fresh relinker-only Release
relinkeranddecoder_length_testsbinaries from all three trees (92 Ninja steps each): this head, main97d33464c5ae244079d0e36d27340fc4aac276a0, and their clean local integrationf4f8b17885440d04c50d786405ec93e2f4910cb7(tree93a9d8f952c81e8212a9a165bcc0d0a8ae3403bb). Relinker sources in the integration are byte-identical to this head, and each tree was built separately with its own headers.windows-646cwithUnsupported Windows guest TLS instruction (bytes: 64 6c).Physical x86 check: I executed bounded STOS/SCAS byte sequences directly on this Intel CPU using a small Windows/Python ctypes probe, independently of the relinker. 5,040 executions, 20,160 independent state checks, and 3,360 FS/GS-versus-plain comparisons pass across 120 encodings. The probe checks all 512 data bytes, RDI, RCX and arithmetic flags against a separate Python model, rather than only comparing prefixed forms to each other. It covers byte/word/dword/qword widths, REP/REPE/REPNE where applicable, address-size override with memory at
0x10000000, counts 0/1/4, five accumulator values, and equal/mismatching scan patterns. Direction is forward (DF=0). GS:[0x30] returned a nonzero Windows TEB pointer. The probe restores nonvolatile RDI, does not change FS/GS bases, and performs no privileged I/O.INS/OUTS were not executed on hardware; INS is covered here by source inspection, decoder tests and conversion-byte checks. The hardware probe executes the instruction sequences directly, not a converted guest executable. No complete AnyPS5 product runtime, console/title, Linux/macOS execution, GPU, performance or hosted-CI result is claimed. AI-assisted: yes.
Focused replay (select the corresponding checkout/build directory; omit
ignored_string_segmentson main):Reproducible Windows x86 hardware probe (Python standard library)
Save as
probe.pyand runpython probe.py hardware.jsonusing 64-bit Windows Python. The generated function uses the Windows x64 ABI. No INS/OUTS instructions are present.Additional 84-conversion replay
Save as
check_cli.pyand runpython check_cli.py <head-checkout> <main-relinker.exe> <head-relinker.exe> <merged-relinker.exe> cli.json. This reuses the committed ELF and output parsers without modifying them.