fix(relinker): trap int 0x80 in a software interrupt table instead of refusing the image #10479

Merged
babyhuey merged 5 commits from upstream-pr/10479 into main 2026-11-09 21:36:06 +00:00
babyhuey commented 2026-10-24 02:46:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-24T02:46:36Z.


What

The syscall scan now replaces an int 0x80 with ud2 when it is one entry of a software interrupt table, instead of refusing the whole image. A table entry here is an int 0x80; ret that is decoded right after int 0x7f; ret and is followed by int 0x81; ret.

Bedlam 2 (PPSA94003) can't be relinked on main, with or without --trap-sdk-syscall-stubs:

FAIL: Forbidden syscall instruction at code offset 0xc3726 (offset 0xc3726)

That offset is the int 0x80 entry of a table with one 3-byte entry for each vector from 0x00 to 0xff, from 0xc35a6 up to 0xc38a6 (exclusive, 256 entries). Every entry is int N; ret except vector 3, which is int3; nop; ret:

0xc35a6: cd 00 c3 cd 01 c3 cd 02 c3 cc 90 c3 cd 04 c3 ...
0xc3720: cd 7e c3 cd 7f c3 cd 80 c3 cd 81 c3 ...
0xc389d: cd fd c3 cd fe c3 cd ff c3 | e8 d5 f6 f8 ff c3

No syscall number is loaded before any of the entries, so it is an interrupt dispatcher and not a system call stub. The title is a homebrew ELF without PT_SCE_DYNLIBDATA, so the scan has no unwind ranges for it, and the rule from #8166 that skips patterns outside unwind functions doesn't apply.

  • Rule: IsInterruptTableEntry in SyscallScanner.cpp matches the 9 bytes cd 7f c3 cd 80 c3 cd 81 c3 around the instruction. It also requires int 0x7f to be a decoded instruction start, the same guard the SDK inline stubs use, so the bytes inside a longer instruction don't match. The offset goes into the scan's existing trapped list, which the pipeline already patches to 0f 0b, and the scan prints Trapping int 0x80 in a software interrupt table at code offset 0x....
  • Default path: this applies without an option. --trap-sdk-syscall-stubs is for SDK stubs and is documented as a debugging option, and the web converter can't pass --skip-syscall-check.
  • Unchanged: a lone int 0x80, or one with a table entry on only one side, is still refused. syscall, sysenter and sysret are unchanged.
  • Docs: docs/dev/debt/relinker.md records that whether the console would run the entry as a system call isn't measured, and the rule; ud2 keeps a Linux host from running it as the 32-bit system call gate. The --trap-sdk-syscall-stubs row in docs/user/USAGE.md notes the exception.

#9549 conflicts with this PR: it rewrites the SDK-stub trap line directly below the new branch in ScanCodeSectionForSyscalls. The resolution is mechanical, because the two branches can't both match (cd 80 against 0f 05 at the opcode). #10439 has merged; this head is rebased on it and keeps both sets of constants in test_syscall_number.py.

Tested

  • New tests in syscall_scanner (Linux only) and the same cases in test_syscall_number.py, which runs on Linux, Windows and macOS:
    • A five-entry table (int 0x7e to int 0x82) relinks without options, and the output has ud2 at the int 0x80 and the neighbouring entries unchanged.
    • int 0x80 after a single table entry is still refused.
    • The same table bytes starting inside a mov al, imm8 immediate are still refused.
    • test_syscall_number.py also converts the table after five nop bytes, so the decoded-start guard is exercised with a table that doesn't start the code.
    • With main's SyscallScanner.cpp, syscall_scanner fails with Relinker refused int 0x80 in a software interrupt table, and test_syscall_number.py with main's relinker fails on the table case (Forbidden syscall instruction at code offset 0x6).
  • Linux (anyps5-build CI image, Ubuntu 24.04, GCC 13, Release, BUILD_TESTING=ON):
    • This head, rebased on main 74acfad65b3: the 5 syscall tests and all 189 tests registered from core/relinker/ pass, check_conventions.py passes, and Bedlam 2 relinks with the trap line for 0xc3726.
    • First commit b2a3cfc293, before the test and docs commit: the full ctest: 22 failures out of 2005, all of them lavapipe AGC driver tests plus guest_system_load_exec_standard_error, which fail in this container on main too. No relinker test fails.
  • Windows: Windows 11 Pro 26200, WinLibs GCC 15.2, Release, BUILD_TESTING=ON, this head: the 4 syscall tests, including the new test_syscall_number.py cases, and all 187 tests registered from core/relinker/ pass. test_syscall_number.py against a relinker built from main 74acfad65b3 fails on the table case at 0x6.
  • Bedlam 2 (PPSA94003), 45 s: on main the relink fails as above. With this head it relinks with no options and prints the trap line for 0xc3726. The title then starts and stops at its own check, because the game's data files aren't in the catalog package:
[debug:0] Bedlam2 trace: game data missing
[debug:0] Bedlam2 trace: returning to dashboard, status=4

Reaching that line with ud2 in place also shows the entry isn't executed at start-up.

On Windows (RTX 3080), this head gives the same result: the relink prints the trap line, and the title exits 0 at 2.1 s after game data missing and returning to dashboard, status=4. main db6af9e0fd refuses the same relink with Forbidden syscall instruction at code offset 0xc3726.

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 (PPSA94003 relinks and stops on its own missing game data)
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4991882256 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10479). Originally posted by [babyhuey](https://github.com/babyhuey) on 2026-10-24T02:46:36Z. --- ### What The syscall scan now replaces an `int 0x80` with `ud2` when it is one entry of a software interrupt table, instead of refusing the whole image. A table entry here is an `int 0x80; ret` that is decoded right after `int 0x7f; ret` and is followed by `int 0x81; ret`. Bedlam 2 (PPSA94003) can't be relinked on `main`, with or without `--trap-sdk-syscall-stubs`: ```text FAIL: Forbidden syscall instruction at code offset 0xc3726 (offset 0xc3726) ``` That offset is the `int 0x80` entry of a table with one 3-byte entry for each vector from `0x00` to `0xff`, from `0xc35a6` up to `0xc38a6` (exclusive, 256 entries). Every entry is `int N; ret` except vector 3, which is `int3; nop; ret`: ```text 0xc35a6: cd 00 c3 cd 01 c3 cd 02 c3 cc 90 c3 cd 04 c3 ... 0xc3720: cd 7e c3 cd 7f c3 cd 80 c3 cd 81 c3 ... 0xc389d: cd fd c3 cd fe c3 cd ff c3 | e8 d5 f6 f8 ff c3 ``` No syscall number is loaded before any of the entries, so it is an interrupt dispatcher and not a system call stub. The title is a homebrew ELF without `PT_SCE_DYNLIBDATA`, so the scan has no unwind ranges for it, and the rule from #8166 that skips patterns outside unwind functions doesn't apply. - **Rule:** `IsInterruptTableEntry` in `SyscallScanner.cpp` matches the 9 bytes `cd 7f c3 cd 80 c3 cd 81 c3` around the instruction. It also requires `int 0x7f` to be a decoded instruction start, the same guard the SDK inline stubs use, so the bytes inside a longer instruction don't match. The offset goes into the scan's existing trapped list, which the pipeline already patches to `0f 0b`, and the scan prints `Trapping int 0x80 in a software interrupt table at code offset 0x...`. - **Default path:** this applies without an option. `--trap-sdk-syscall-stubs` is for SDK stubs and is documented as a debugging option, and the web converter can't pass `--skip-syscall-check`. - **Unchanged:** a lone `int 0x80`, or one with a table entry on only one side, is still refused. `syscall`, `sysenter` and `sysret` are unchanged. - **Docs:** `docs/dev/debt/relinker.md` records that whether the console would run the entry as a system call isn't measured, and the rule; `ud2` keeps a Linux host from running it as the 32-bit system call gate. The `--trap-sdk-syscall-stubs` row in `docs/user/USAGE.md` notes the exception. #9549 conflicts with this PR: it rewrites the SDK-stub trap line directly below the new branch in `ScanCodeSectionForSyscalls`. The resolution is mechanical, because the two branches can't both match (`cd 80` against `0f 05` at the opcode). #10439 has merged; this head is rebased on it and keeps both sets of constants in `test_syscall_number.py`. ### Tested - **New tests** in `syscall_scanner` (Linux only) and the same cases in `test_syscall_number.py`, which runs on Linux, Windows and macOS: - A five-entry table (`int 0x7e` to `int 0x82`) relinks without options, and the output has `ud2` at the `int 0x80` and the neighbouring entries unchanged. - `int 0x80` after a single table entry is still refused. - The same table bytes starting inside a `mov al, imm8` immediate are still refused. - `test_syscall_number.py` also converts the table after five `nop` bytes, so the decoded-start guard is exercised with a table that doesn't start the code. - With `main`'s `SyscallScanner.cpp`, `syscall_scanner` fails with `Relinker refused int 0x80 in a software interrupt table`, and `test_syscall_number.py` with `main`'s relinker fails on the table case (`Forbidden syscall instruction at code offset 0x6`). - **Linux** (`anyps5-build` CI image, Ubuntu 24.04, GCC 13, Release, `BUILD_TESTING=ON`): - This head, rebased on `main` `74acfad65b3`: the 5 `syscall` tests and all 189 tests registered from `core/relinker/` pass, `check_conventions.py` passes, and Bedlam 2 relinks with the trap line for `0xc3726`. - First commit `b2a3cfc293`, before the test and docs commit: the full `ctest`: 22 failures out of 2005, all of them lavapipe AGC driver tests plus `guest_system_load_exec_standard_error`, which fail in this container on `main` too. No relinker test fails. - **Windows:** Windows 11 Pro 26200, WinLibs GCC 15.2, Release, `BUILD_TESTING=ON`, this head: the 4 `syscall` tests, including the new `test_syscall_number.py` cases, and all 187 tests registered from `core/relinker/` pass. `test_syscall_number.py` against a relinker built from `main` `74acfad65b3` fails on the table case at `0x6`. - **Bedlam 2 (PPSA94003), 45 s:** on `main` the relink fails as above. With this head it relinks with no options and prints the trap line for `0xc3726`. The title then starts and stops at its own check, because the game's data files aren't in the catalog package: ```text [debug:0] Bedlam2 trace: game data missing [debug:0] Bedlam2 trace: returning to dashboard, status=4 ``` Reaching that line with `ud2` in place also shows the entry isn't executed at start-up. On Windows (RTX 3080), this head gives the same result: the relink prints the trap line, and the title exits 0 at 2.1 s after `game data missing` and `returning to dashboard, status=4`. `main` `db6af9e0fd` refuses the same relink with `Forbidden syscall instruction at code offset 0xc3726`. ### Checklist - [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 - [x] Fixes: none - [x] Unblocks: none (PPSA94003 relinks and stops on its own missing game data) - [x] GPUs tested: n/a - [x] AI-assisted: yes
roboterspinne commented 2026-10-24 11:35:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by roboterspinne on 2026-10-24T11:35:00Z.

Review: COMMENTED


Reviewed head b2a3cfc merged onto upstream/main aeeaefad9 (2026-10-24); the merge is clean, and so are merges onto the current main 50aa1798e and together with #10439 and #10537 (all three merged into one tree). #9549 conflicts in SyscallScanner.cpp, see below.

Environment: Windows 11 Home 10.0.26200, WinLibs GCC 15.2.0 UCRT, CMake 4.3.1, Ninja 1.13.2, Python 3.13.9, -DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON, Release. My machine was under heavy unrelated CPU load, so I report targeted tests only; the relinker matrix is green on the PR.

Results

  • Merged tree: syscall_number, sce_code_gaps, guest_syscall_trap, sdk_mman_syscall, input_magic pass. syscall_scanner (the C++ test holding the new cases) is registered only on Linux x86-64 (CMakeLists.txt:842-856), so I reproduced its three cases by hand with test_syscall_number.fixture: the baseline refuses the five-entry table (cd7ec3 cd7fc3 cd80c3 cd81c3 cd82c3) at code offset 0x6, cd7fc3 cd80c3 90c3 at 0x3, b0cd7fc3 cd80c3 cd81c3 at 0x4 and a lone cd80c3 at 0x0; the PR build converts the table with exit 0 and Trapping int 0x80 in a software interrupt table at code offset 0x6, the output holds cd 7e c3 cd 7f c3 0f 0b c3 cd 81 c3 cd 82 c3, and the other three are still refused. Identical results with #10439 and #10537 merged on top.
  • Code: the 9-byte compare covers code[opcode-3 .. opcode+5] and both bounds checks hold, recent.Contains is the same decoded-start guard the SDK stubs use (64-entry ring, the int 0x7f start is at most two instructions back), and trapped offsets are patched to 0f 0b by RelinkerPipeline.cpp:415-417. The #8166 skip indeed does not apply without unwind ranges.
  • check_conventions.py passes; pr_overlap.py reports the #9549 conflict at SyscallScanner.cpp L292-294.

Should fix (text)

  • The table offsets do not add up: 0xc3726 − 0xc35b2 = 0x174 = 124 three-byte entries, not 0x80 = 128, and 0xc38a6 − 0xc35b2 = 0x2f4 = 252 entries, not 256 (int3 for vector 3 saves one byte, not twelve). 0xc38a6 − 0xc3726 = 0x180 = exactly 128 entries, which fits only if 0xc38a6 is the exclusive end. So "one int N; ret entry for each vector from 0 to 0xff" starting at 0xc35b2 cannot all be true; the table may start at vector 4, or the start offset is misreported. Could you attach a short hexdump of the first and last entries and correct the body and the debt sentence?

Nits

  • Coverage: the three new cases live only in SyscallScannerTests.cpp, whose helpers use posix_spawn/sys/mman.h, so the windows-latest and macos-latest jobs never ran them (your own "3 syscall tests" on Windows versus 4 on Linux shows it). f7a9629e68 mirrored the scanner cases in test_syscall_number.py for exactly this reason; adding the table, one-entry and inside-immediate cases there (it can also check the 0f 0b at 0x4006) would give all three hosts coverage. Behaviour is fine, I checked it on the Windows build.
  • Default path: the branch runs before --trap-sdk-syscall-stubs and the number lookup, so b8 0b 00 00 00 e8 07 00 00 00 c3 90 90 90 cd 7f c3 cd 80 c3 cd 81 c3 (a numbered call into the table's entry) relinks with ud2 at the entry where main refuses at 0x11, and the web converter (wasm/Bindings.cpp:70-76) cannot opt out. The body and the debt entry say so, and #8166 set the precedent of a debt-recorded default-path rule, but docs/user/USAGE.md:89 still says "Other syscall instructions still cause an error"; one sentence there about the table rule and its ud2 (SIGILL if reached) would keep the user docs honest.
  • Debt entry: CONTRIBUTING asks that an entry state the gap first; this one opens with the rule and names the unmeasured console behaviour in its third sentence.
  • Body: "#10439 changes the syscall-number lookup right after the new helper" is true, but it merges cleanly with this PR, so no rebase is needed there; #9549 does conflict (it rewrites the trapSdkStubs line directly below the new branch), and the resolution is mechanical because the two branches cannot both match (cd 80 versus 0f 05 at the opcode).

Notes

  • The rule is byte-exact for contiguous 3-byte entries: a padded table (cd 7f c3 90 cd 80 c3 ...), a prefixed 66 cd 80, a non-ret before the int 0x80 entry, or a table whose int 0x80 is the first decoded entry are still refused, and two tables in one section are both trapped. If the bytes before the table misalign the decoder, the entry is not seen at all; that is pre-existing. A test with a few bytes before the table would exercise the decoded-start guard with a non-zero start.
  • FreeBSD amd64 maps IDT vector 0x80 to its i386 compat syscall gate (sys/amd64/ia32/ia32_syscall.c); what the console does with it from a 64-bit process is not measured, as the debt entry says.
  • #8042 also touches SyscallScanner.cpp, but it is based before 45a2e3dd4a and no longer merges or compiles against main.

Not checked: the Bedlam 2 image and its runs; the C++ syscall_scanner itself; a full suite; the guest-module path with a table inside a sce_module; Windows or console behaviour of int 0x80.

I found no blocking issue; the code does what the body says and the counter-check holds. The one thing I would settle before merge is the table arithmetic in the body and debt entry. For disclosure: I have open relinker PRs (#10564, #10402, #10401, #10403, #10390, #10391); none touches SyscallScanner.cpp.

Written with AI assistance (Claude Code). I ran the builds, tests and fixture checks above on my Windows 11 machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5638095210 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10479#pullrequestreview-5638095210). Originally posted by [roboterspinne](https://github.com/roboterspinne) on 2026-10-24T11:35:00Z. **Review:** COMMENTED --- Reviewed head b2a3cfc merged onto `upstream/main` aeeaefad9 (2026-10-24); the merge is clean, and so are merges onto the current `main` 50aa1798e and together with #10439 and #10537 (all three merged into one tree). #9549 conflicts in `SyscallScanner.cpp`, see below. **Environment:** Windows 11 Home 10.0.26200, WinLibs GCC 15.2.0 UCRT, CMake 4.3.1, Ninja 1.13.2, Python 3.13.9, `-DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON`, Release. My machine was under heavy unrelated CPU load, so I report targeted tests only; the relinker matrix is green on the PR. **Results** - Merged tree: `syscall_number`, `sce_code_gaps`, `guest_syscall_trap`, `sdk_mman_syscall`, `input_magic` pass. `syscall_scanner` (the C++ test holding the new cases) is registered only on Linux x86-64 (`CMakeLists.txt:842-856`), so I reproduced its three cases by hand with `test_syscall_number.fixture`: the baseline refuses the five-entry table (`cd7ec3 cd7fc3 cd80c3 cd81c3 cd82c3`) at code offset 0x6, `cd7fc3 cd80c3 90c3` at 0x3, `b0cd7fc3 cd80c3 cd81c3` at 0x4 and a lone `cd80c3` at 0x0; the PR build converts the table with exit 0 and `Trapping int 0x80 in a software interrupt table at code offset 0x6`, the output holds `cd 7e c3 cd 7f c3 0f 0b c3 cd 81 c3 cd 82 c3`, and the other three are still refused. Identical results with #10439 and #10537 merged on top. - Code: the 9-byte compare covers `code[opcode-3 .. opcode+5]` and both bounds checks hold, `recent.Contains` is the same decoded-start guard the SDK stubs use (64-entry ring, the `int 0x7f` start is at most two instructions back), and trapped offsets are patched to `0f 0b` by `RelinkerPipeline.cpp:415-417`. The #8166 skip indeed does not apply without unwind ranges. - `check_conventions.py` passes; `pr_overlap.py` reports the #9549 conflict at `SyscallScanner.cpp` L292-294. **Should fix (text)** - The table offsets do not add up: 0xc3726 − 0xc35b2 = 0x174 = 124 three-byte entries, not 0x80 = 128, and 0xc38a6 − 0xc35b2 = 0x2f4 = 252 entries, not 256 (`int3` for vector 3 saves one byte, not twelve). 0xc38a6 − 0xc3726 = 0x180 = exactly 128 entries, which fits only if 0xc38a6 is the exclusive end. So "one `int N; ret` entry for each vector from 0 to 0xff" starting at 0xc35b2 cannot all be true; the table may start at vector 4, or the start offset is misreported. Could you attach a short hexdump of the first and last entries and correct the body and the debt sentence? **Nits** - Coverage: the three new cases live only in `SyscallScannerTests.cpp`, whose helpers use `posix_spawn`/`sys/mman.h`, so the windows-latest and macos-latest jobs never ran them (your own "3 syscall tests" on Windows versus 4 on Linux shows it). f7a9629e68 mirrored the scanner cases in `test_syscall_number.py` for exactly this reason; adding the table, one-entry and inside-immediate cases there (it can also check the `0f 0b` at 0x4006) would give all three hosts coverage. Behaviour is fine, I checked it on the Windows build. - Default path: the branch runs before `--trap-sdk-syscall-stubs` and the number lookup, so `b8 0b 00 00 00 e8 07 00 00 00 c3 90 90 90 cd 7f c3 cd 80 c3 cd 81 c3` (a numbered call into the table's entry) relinks with `ud2` at the entry where `main` refuses at 0x11, and the web converter (`wasm/Bindings.cpp:70-76`) cannot opt out. The body and the debt entry say so, and #8166 set the precedent of a debt-recorded default-path rule, but `docs/user/USAGE.md:89` still says "Other syscall instructions still cause an error"; one sentence there about the table rule and its `ud2` (SIGILL if reached) would keep the user docs honest. - Debt entry: CONTRIBUTING asks that an entry state the gap first; this one opens with the rule and names the unmeasured console behaviour in its third sentence. - Body: "#10439 changes the syscall-number lookup right after the new helper" is true, but it merges cleanly with this PR, so no rebase is needed there; #9549 does conflict (it rewrites the `trapSdkStubs` line directly below the new branch), and the resolution is mechanical because the two branches cannot both match (`cd 80` versus `0f 05` at the opcode). **Notes** - The rule is byte-exact for contiguous 3-byte entries: a padded table (`cd 7f c3 90 cd 80 c3 ...`), a prefixed `66 cd 80`, a non-`ret` before the `int 0x80` entry, or a table whose `int 0x80` is the first decoded entry are still refused, and two tables in one section are both trapped. If the bytes before the table misalign the decoder, the entry is not seen at all; that is pre-existing. A test with a few bytes before the table would exercise the decoded-start guard with a non-zero start. - FreeBSD amd64 maps IDT vector 0x80 to its i386 compat syscall gate (`sys/amd64/ia32/ia32_syscall.c`); what the console does with it from a 64-bit process is not measured, as the debt entry says. - #8042 also touches `SyscallScanner.cpp`, but it is based before 45a2e3dd4a and no longer merges or compiles against `main`. **Not checked:** the Bedlam 2 image and its runs; the C++ `syscall_scanner` itself; a full suite; the guest-module path with a table inside a `sce_module`; Windows or console behaviour of `int 0x80`. I found no blocking issue; the code does what the body says and the counter-check holds. The one thing I would settle before merge is the table arithmetic in the body and debt entry. For disclosure: I have open relinker PRs (#10564, #10402, #10401, #10403, #10390, #10391); none touches `SyscallScanner.cpp`. Written with AI assistance (Claude Code). I ran the builds, tests and fixture checks above on my Windows 11 machine.
MarcZX10 commented 2026-10-24 20:56:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T20:56:18Z.

Review: APPROVED


Reviewed exact head 742408f8a0361d135d6cd264e337ded4fc380462, including the scanner, both cross-platform regression sets, docs, and the author's follow-up clarifying the Bedlam 2 table bounds. The detector is byte-exact, checks that the preceding int 0x7f is a decoded instruction start, and only traps the middle int 0x80 when the adjacent int 0x7f and int 0x81 entries match; unmatched and immediate-byte cases remain refused. The relinker pipeline replaces only the recorded opcode with ud2.

The author reports red/green relinker tests on Linux and Windows and a Bedlam 2 relink on both platforms. The current hosted eligibility, conventions, labels, Ubuntu/Windows/macOS relinker matrix, and ASan checks pass; product jobs are skipped by policy. I independently ran python3 tools/check_conventions.py --base upstream/main --head upstream/pr-10479 and git diff --check; both pass. I did not rerun the relinker suite locally.

The separately reported #10439 overlap is still present in test_syscall_number.py when the two current heads are combined; preserve both test additions when resolving it. #9549's scanner conflict and its mechanical resolution are documented in the PR. I found no correctness blocker in this change.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5639992842 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10479#pullrequestreview-5639992842). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T20:56:18Z. **Review:** APPROVED --- Reviewed exact head `742408f8a0361d135d6cd264e337ded4fc380462`, including the scanner, both cross-platform regression sets, docs, and the author's follow-up clarifying the Bedlam 2 table bounds. The detector is byte-exact, checks that the preceding `int 0x7f` is a decoded instruction start, and only traps the middle `int 0x80` when the adjacent `int 0x7f` and `int 0x81` entries match; unmatched and immediate-byte cases remain refused. The relinker pipeline replaces only the recorded opcode with `ud2`. The author reports red/green relinker tests on Linux and Windows and a Bedlam 2 relink on both platforms. The current hosted eligibility, conventions, labels, Ubuntu/Windows/macOS relinker matrix, and ASan checks pass; product jobs are skipped by policy. I independently ran `python3 tools/check_conventions.py --base upstream/main --head upstream/pr-10479` and `git diff --check`; both pass. I did not rerun the relinker suite locally. The separately reported #10439 overlap is still present in `test_syscall_number.py` when the two current heads are combined; preserve both test additions when resolving it. #9549's scanner conflict and its mechanical resolution are documented in the PR. I found no correctness blocker in this change.
ahmadmuj commented 2026-10-25 17:18:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ahmadmuj on 2026-10-25T17:18:11Z.

Review: APPROVED


Reviewed head 742408f8a0 merged onto main b4d8e8bb3b (clean; still clean on 7e4f6e0440, which has no relinker changes since). Linux, WSL2, GCC, relinker-only Release with BUILD_TESTING=ON. This covers the two things the earlier reviews list as not checked: the Linux-only syscall_scanner cases and Bedlam 2 itself.

What I ran

  • ctest on the merged tree: 298/298 pass, including syscall_scanner and syscall_number.
  • Red/green: this branch's syscall_scanner_tests and test_syscall_number.py against a relinker built from main 0119103fa9 (no SyscallScanner.cpp change since) both fail at Forbidden syscall instruction at code offset 0x6.
  • Bedlam 2 (PPSA94003, catalog zip sha256 cdd390a4...0c229, rc.4 release): main refuses with --registry --to-intel, with or without --trap-sdk-syscall-stubs, at 0xc3726. This head relinks it and prints the trap line. The table bytes match your dump (cd 00 c3 at 0xc35a6, cc 90 c3 for vector 3).
  • The output is the same as main with --skip-syscall-check except for exactly 2 bytes: file offset 0xc7726, cd 80 -> 0f 0b. So the rule changes nothing else in the image.
  • Title run on lavapipe (llvmpipe, Xvfb, dummy audio): exit 0 at 0.2 s after Bedlam2 trace: game data missing and returning to dashboard, status=4, no SIGILL. Same as your run.
  • I also searched 121 homebrew packages from the same catalog (242 eboot and sce_module files) for cd7fc3cd80c3cd81c3. It only shows up in Bedlam 2, so the rule fires nowhere else in that set.

Note (non-blocking)

  • The new branch runs before the #8166 skip, so in an SCE image it now also patches table bytes in a gap between unwind functions. Before, main skipped and counted them as possible data. Repro: cd7fc3cd80c3cd81c3 placed at GAP with executable() from test_sce_code_gaps.py. main gives Skipped 1 syscall byte pattern(s) ... 0x213 and leaves the bytes alone. This head gives Trapping ... 0x213 and writes 0f 0b there. A 9-byte data match is very unlikely, and ud2 is the safer outcome if it's code. But the debt entry says "instead of failing", and the gap line above it says the others are skipped. Either one clause in the new entry about gaps, or gating the branch with functions.empty() || insideFunction(start), would make it consistent. Bedlam has no PT_SCE_DYNLIBDATA, so both options keep it working.

Not checked: console behaviour of int 0x80, other GPUs, Windows or macOS, and a full non-relinker build.

Approving: the rule does what the body says, and the title result reproduces on Linux.

AI-assisted (Claude Code). I ran the builds, tests, relinks and the title run above.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5644315663 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10479#pullrequestreview-5644315663). Originally posted by [ahmadmuj](https://github.com/ahmadmuj) on 2026-10-25T17:18:11Z. **Review:** APPROVED --- Reviewed head `742408f8a0` merged onto `main` `b4d8e8bb3b` (clean; still clean on `7e4f6e0440`, which has no relinker changes since). Linux, WSL2, GCC, relinker-only Release with `BUILD_TESTING=ON`. This covers the two things the earlier reviews list as not checked: the Linux-only `syscall_scanner` cases and Bedlam 2 itself. **What I ran** - `ctest` on the merged tree: 298/298 pass, including `syscall_scanner` and `syscall_number`. - Red/green: this branch's `syscall_scanner_tests` and `test_syscall_number.py` against a relinker built from `main` `0119103fa9` (no `SyscallScanner.cpp` change since) both fail at `Forbidden syscall instruction at code offset 0x6`. - Bedlam 2 (PPSA94003, catalog zip sha256 `cdd390a4...0c229`, `rc.4` release): `main` refuses with `--registry --to-intel`, with or without `--trap-sdk-syscall-stubs`, at `0xc3726`. This head relinks it and prints the trap line. The table bytes match your dump (`cd 00 c3` at `0xc35a6`, `cc 90 c3` for vector 3). - The output is the same as `main` with `--skip-syscall-check` except for exactly 2 bytes: file offset `0xc7726`, `cd 80` -> `0f 0b`. So the rule changes nothing else in the image. - Title run on lavapipe (llvmpipe, Xvfb, dummy audio): exit 0 at 0.2 s after `Bedlam2 trace: game data missing` and `returning to dashboard, status=4`, no SIGILL. Same as your run. - I also searched 121 homebrew packages from the same catalog (242 eboot and `sce_module` files) for `cd7fc3cd80c3cd81c3`. It only shows up in Bedlam 2, so the rule fires nowhere else in that set. **Note (non-blocking)** - The new branch runs before the #8166 skip, so in an SCE image it now also patches table bytes in a gap between unwind functions. Before, `main` skipped and counted them as possible data. Repro: `cd7fc3cd80c3cd81c3` placed at `GAP` with `executable()` from `test_sce_code_gaps.py`. `main` gives `Skipped 1 syscall byte pattern(s) ... 0x213` and leaves the bytes alone. This head gives `Trapping ... 0x213` and writes `0f 0b` there. A 9-byte data match is very unlikely, and `ud2` is the safer outcome if it's code. But the debt entry says "instead of failing", and the gap line above it says the others are skipped. Either one clause in the new entry about gaps, or gating the branch with `functions.empty() || insideFunction(start)`, would make it consistent. Bedlam has no `PT_SCE_DYNLIBDATA`, so both options keep it working. **Not checked:** console behaviour of `int 0x80`, other GPUs, Windows or macOS, and a full non-relinker build. Approving: the rule does what the body says, and the title result reproduces on Linux. AI-assisted (Claude Code). I ran the builds, tests, relinks and the title run above.
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!10479
No description provided.