fix(relinker): keep syscall blocks outside embedded data masks #11565

Merged
Mherberts merged 5 commits from upstream-pr/11565 into main 2026-11-15 02:23:43 +00:00
Mherberts commented 2026-10-26 20:27:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Mherberts on 2026-10-26T20:27:38Z.


What

A LEA-referenced data table followed by a syscall block, padding and another code block could be masked through the later padding boundary, hiding the earlier syscall from executable and bundled-module validation. Keep the padding-derived upper bound, then shorten it to an earlier syscall-containing block recognized by the existing gap analysis.

Updated with main c3a5290c7d, retaining the corrected fixture byte (0x55, not the REX prefix 0x44) requested in the reviews. This also incorporates main's wrapped-declaration class split and #15526's split of guest_none_relocations into plain/SCE runs. The latter addresses the 20 s timeout seen twice on the preceding macOS x86-64 checks without raising the timeout or reducing coverage. The syscall-boundary change and its regression fixtures remain unchanged by this integration.

Tested

Head 827267128c, Windows x64, MinGW GCC 13.2.0, Python 3.13.15, Ninja Release, ANYPS5_RELINKER_ONLY=ON, BUILD_TESTING=ON.

  • Complete relinker-only build passed. All 21 focused CTests passed in 21.33 s: control_flow_graph, both embedded-syscall conversion tests, both plain/SCE guest-relocation groups and all 16 wrapped-declaration/ABI-alias cases. The two guest-relocation groups took 2.72 s and 3.06 s on this Windows host.
  • Earlier hosted validation of the same syscall change and corrected fixture passed Windows (686/686), Linux, macOS arm64 and Linux ASan. The macOS x86-64 retry on 42432069c7 completed 670/671 tests; guest_none_relocations alone timed out. The current integration includes the upstream fix for that test (#15526).
  • This integration build executed the focused conversion tests locally, including the syscall fixtures that Windows Application Control blocked on the previous build. No Windows security setting was changed.
  • Conventions against upstream/main and git diff --check upstream/main...HEAD passed. The required comparison with the fork's outdated origin/main also ran and reports six unrelated upstream commit-subject errors and existing debt-length warnings.

Current-head CI audit on 2026-11-05: Build run 41923925977 passed all four relinker configurations (Linux, Windows, macOS arm64 and macOS x86-64) and relinker ASan on 827267128c5b2b7ab9d104b6aef133b1028d1c82. Conventions and labels also passed. Full product jobs were skipped by workflow policy. The fixture already uses 0x55, and the requested main integration is included. No retail title or GPU testing.

Current overlap audit, 2026-11-05: manually inspected newly listed base-conflicting #6149 (module-args test source), #13486 (zero-finalizer test/stub-window safety) and #15245 (executable-export test registration). Their CMake edits do not implement or modify this syscall-mask boundary fix. No source update was needed for those notices.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5024157083 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11565). Originally posted by [Mherberts](https://github.com/Mherberts) on 2026-10-26T20:27:38Z. --- ### What A LEA-referenced data table followed by a syscall block, padding and another code block could be masked through the later padding boundary, hiding the earlier syscall from executable and bundled-module validation. Keep the padding-derived upper bound, then shorten it to an earlier syscall-containing block recognized by the existing gap analysis. Updated with main `c3a5290c7d`, retaining the corrected fixture byte (`0x55`, not the REX prefix `0x44`) requested in the reviews. This also incorporates main's wrapped-declaration class split and #15526's split of `guest_none_relocations` into plain/SCE runs. The latter addresses the 20 s timeout seen twice on the preceding macOS x86-64 checks without raising the timeout or reducing coverage. The syscall-boundary change and its regression fixtures remain unchanged by this integration. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Head `827267128c`, Windows x64, MinGW GCC 13.2.0, Python 3.13.15, Ninja Release, `ANYPS5_RELINKER_ONLY=ON`, `BUILD_TESTING=ON`. - Complete relinker-only build passed. All 21 focused CTests passed in 21.33 s: `control_flow_graph`, both embedded-syscall conversion tests, both plain/SCE guest-relocation groups and all 16 wrapped-declaration/ABI-alias cases. The two guest-relocation groups took 2.72 s and 3.06 s on this Windows host. - Earlier hosted validation of the same syscall change and corrected fixture passed Windows (686/686), Linux, macOS arm64 and Linux ASan. The macOS x86-64 retry on `42432069c7` completed 670/671 tests; `guest_none_relocations` alone timed out. The current integration includes the upstream fix for that test (#15526). - This integration build executed the focused conversion tests locally, including the syscall fixtures that Windows Application Control blocked on the previous build. No Windows security setting was changed. - Conventions against `upstream/main` and `git diff --check upstream/main...HEAD` passed. The required comparison with the fork's outdated `origin/main` also ran and reports six unrelated upstream commit-subject errors and existing debt-length warnings. Current-head CI audit on 2026-11-05: [Build run 41923925977](https://github.com/boykopovar/AnyPS5/actions/runs/41923925977) passed all four relinker configurations (Linux, Windows, macOS arm64 and macOS x86-64) and relinker ASan on `827267128c5b2b7ab9d104b6aef133b1028d1c82`. Conventions and labels also passed. Full product jobs were skipped by workflow policy. The fixture already uses `0x55`, and the requested main integration is included. No retail title or GPU testing. Current overlap audit, 2026-11-05: manually inspected newly listed base-conflicting #6149 (module-args test source), #13486 (zero-finalizer test/stub-window safety) and #15245 (executable-export test registration). Their CMake edits do not implement or modify this syscall-mask boundary fix. No source update was needed for those notices. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
MarcZX10 commented 2026-10-26 22:26:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T22:26:00Z.

Review: APPROVED


Reviewed exact head 6ceab4098a3f2ee85987d10accdea78d19026278; no actionable findings. FindEmbeddedDataTableEnd now preserves the padding-derived upper bound and checks earlier trailing-code blocks for a syscall before returning it. The native cases cover syscall instruction forms, prefixes, padding bytes and optional leading padding; the conversion fixtures exercise both executable and guest-module paths across Linux, Windows and macOS outputs, with non-syscall controls. The author reports the focused native/Python tests and complete relinker-only build passed; hosted eligibility, conventions, intake, labels, all relinker platforms and ASan pass. I did not rerun the tests locally.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5659940121 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11565#pullrequestreview-5659940121). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-26T22:26:00Z. **Review:** APPROVED --- Reviewed exact head `6ceab4098a3f2ee85987d10accdea78d19026278`; no actionable findings. `FindEmbeddedDataTableEnd` now preserves the padding-derived upper bound and checks earlier trailing-code blocks for a syscall before returning it. The native cases cover syscall instruction forms, prefixes, padding bytes and optional leading padding; the conversion fixtures exercise both executable and guest-module paths across Linux, Windows and macOS outputs, with non-syscall controls. The author reports the focused native/Python tests and complete relinker-only build passed; hosted eligibility, conventions, intake, labels, all relinker platforms and ASan pass. I did not rerun the tests locally.
jotitadev commented 2026-10-30 19:01:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-30T19:01:59Z.

Review: COMMENTED


Follow-up on the main merge failure that JJenkx bisected to #10537. Checked on Linux x86-64 (Ubuntu 26.04, GCC 15.2, Release, BUILD_TESTING=ON): head 6ceab4098a3f, merged onto main 4570612f40.

  • Same result: both embedded_data_syscalls tests fail 3/3 on the merge and pass 3/3 on the head alone.
  • My own first-parent bisect also lands on 09919b040d (#10537).

The cause is the test fixture, not the RelativeJumpTables.cpp change. tail() writes 0f 78 11 22 33 44 immediately before the routine 31 c0 b0 3b 0f 05.

  • Since #10537, ActivePrefixesBefore treats that trailing 0x44 as a REX.R prefix of the 31 c0. That is how a CPU decodes it: 44 31 c0 is xor eax, r8d, which does not zero eax.
  • ConstantRaxSetEndingAt therefore no longer derives syscall number 59 from xor eax,eax; mov al,0x3b.
  • Outside the unwind functions, a syscall without a number is now skipped (Skipped 1 syscall byte pattern(s) without a syscall number ...) instead of failing with Forbidden syscall instruction.

One-byte fix, verified on the merge:

--- a/core/relinker/relinker/tests/test_embedded_data_syscalls.py
+++ b/core/relinker/relinker/tests/test_embedded_data_syscalls.py
@@ def tail(opcode, padding):
-    return b"\x0f\x78\x11\x22\x33\x44" + routine + padding * 4 + b"\x31\xc0\xc3"
+    return b"\x0f\x78\x11\x22\x33\x55" + routine + padding * 4 + b"\x31\xc0\xc3"
  • With the fix on the merge: both tests pass 3/3, and the full relinker-only suite passes 535/535.
  • Negative control: with the same fixed fixture, but RelativeJumpTables.cpp reverted to main's version, both tests still fail (sysv-syscall-00-linux and syscall-00-linux exit 0). The test still catches the masking bug after the change.

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5717336594 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11565#pullrequestreview-5717336594). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-30T19:01:59Z. **Review:** COMMENTED --- Follow-up on the `main` merge failure that JJenkx bisected to #10537. Checked on Linux x86-64 (Ubuntu 26.04, GCC 15.2, Release, `BUILD_TESTING=ON`): head `6ceab4098a3f`, merged onto `main` `4570612f40`. - Same result: both `embedded_data_syscalls` tests fail 3/3 on the merge and pass 3/3 on the head alone. - My own first-parent bisect also lands on `09919b040d` (#10537). The cause is the test fixture, not the `RelativeJumpTables.cpp` change. `tail()` writes `0f 78 11 22 33 44` immediately before the routine `31 c0 b0 3b 0f 05`. - Since #10537, `ActivePrefixesBefore` treats that trailing `0x44` as a REX.R prefix of the `31 c0`. That is how a CPU decodes it: `44 31 c0` is `xor eax, r8d`, which does not zero `eax`. - `ConstantRaxSetEndingAt` therefore no longer derives syscall number 59 from `xor eax,eax; mov al,0x3b`. - Outside the unwind functions, a syscall without a number is now skipped (`Skipped 1 syscall byte pattern(s) without a syscall number ...`) instead of failing with `Forbidden syscall instruction`. One-byte fix, verified on the merge: ```diff --- a/core/relinker/relinker/tests/test_embedded_data_syscalls.py +++ b/core/relinker/relinker/tests/test_embedded_data_syscalls.py @@ def tail(opcode, padding): - return b"\x0f\x78\x11\x22\x33\x44" + routine + padding * 4 + b"\x31\xc0\xc3" + return b"\x0f\x78\x11\x22\x33\x55" + routine + padding * 4 + b"\x31\xc0\xc3" ``` - With the fix on the merge: both tests pass 3/3, and the full relinker-only suite passes 535/535. - Negative control: with the same fixed fixture, but `RelativeJumpTables.cpp` reverted to `main`'s version, both tests still fail (`sysv-syscall-00-linux` and `syscall-00-linux` exit 0). The test still catches the masking bug after the change. Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!11565
No description provided.