Skip to content

fix(relinker): name --trap-sdk-syscall-stubs when a refused syscall is an SDK stub - #9549

Merged
adriadam10 merged 3 commits into
boykopovar:mainfrom
DavidSamir:fix/relinker-name-trap-flag
Nov 9, 2026
Merged

adriadam10 merged 3 commits into
boykopovar:mainfrom
DavidSamir:fix/relinker-name-trap-flag

Conversation

@DavidSamir

@DavidSamir DavidSamir commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

What

A converted title that carries the ps5-payload-dev SDK syscall stubs is refused with Forbidden syscall instruction at code offset 0x..., and nothing in the message says that --trap-sdk-syscall-stubs converts it. The scanner already has the matchers for the sequences that option traps, so when the refused instruction is one of them the message now ends with ; it is a ps5-payload-dev SDK syscall stub, which --trap-sdk-syscall-stubs replaces with UD2. Any other syscall keeps the message it had, so a real syscall never suggests the flag.

Titles whose refusal now names the flag (catalog, Linux relinker, --to-intel, no trap option):

  • PPSA99061 Spot5: Forbidden syscall instruction at code offset 0xdeb8f7; it is a ps5-payload-dev SDK syscall stub, ...
  • PPSA99186 ForgeNX: ... at code offset 0x214385a: syscall number 9; it is a ps5-payload-dev SDK syscall stub, ...
  • the trap list of the catalog sweep: PPSA99004 (0x1108bf7), PPSA99203 (0x10a2d37), PPSA99360 (0x1699f07) and PPSA99288 (0x24a67ba) show the hint in the same way; the other titles of that list are not re-run here.

Spot5 and ForgeNX convert and run for 60 s once --trap-sdk-syscall-stubs is given (Linux, same harness as the other sweeps): first frame, no stderr.

The change is in SyscallScanner.cpp: the SDK-stub test that decided whether to trap is evaluated once into sdkStub and used for both the trap and the hint. Nothing else in the conversion changes.

Tested

  • syscall_scanner (Linux; SyscallScannerTests.cpp, registered on Linux only): the numbered and the generic SDK stubs are refused with the hint, and the seven bare syscall shapes of the existing tests (unsigned constant, register, int 0x80, sysenter, sysret, clobbered, prefixed) are refused without it. The existing prefix and syscall number N checks are unchanged and pass.
  • Negative control: with SyscallScanner.cpp from before the change and the same test, syscall_scanner fails with Relinker did not name --trap-sdk-syscall-stubs for the numbered SDK stub. With the change it passes.
  • Linux (Ubuntu 24.04 in WSL2, GCC, Release): syscall_scanner, syscall_number, sdk_mman_syscall, conversion_diagnostics, executable_segments and sce_code_gaps pass, 6 of 6.
  • Windows 11 (WinLibs GCC 15.2.0, Release): the Windows-registered tests among those pass, 6 of 6 (syscall_scanner itself is not registered on Windows).
  • python tools/check_conventions.py --base origin/main passes.
  • Merge check with git merge-tree: clean against main. fix(relinker): trap inline SDK mount syscall #8729 renames IsSdkMmanSyscallStub to IsSdkInlineSyscallStub and edits the trap condition, so it conflicts with this change on that line; whichever merges second only needs the function name in const bool sdkStub = ... brought up to date.
  • python tools/pr_overlap.py --branch fix/relinker-name-trap-flag (the version from fix(tools): merge only the pull requests that share files or exports with the branch in pr_overlap #9539, which merges only the pull requests that share files with the branch; 1 min 18 s): fix(relinker): trap inline SDK mount syscall #8729 conflicts on SyscallScanner.cpp L293-294, the trap condition this change turns into sdkStub, and fix(relinker): resync the syscall scan past undecodable data regions #8042 could not be compared because it conflicts with main itself. Nothing else overlaps.

Not run on macOS.

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: fix(relinker): trap int 0x80 in a software interrupt table instead of refusing the image #10479
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

…s an SDK stub

A title whose binary carries the ps5-payload-dev syscall stubs, such as PPSA99061 and PPSA99186, was refused with 'Forbidden syscall instruction at code offset 0x...' and no way to know that --trap-sdk-syscall-stubs converts it. The scanner already knows which sequences that option would trap, so it now appends that to the message only when the refused instruction is one of them. Every other syscall keeps the message it had.
The numbered and the generic SDK stubs are refused with the hint, and the seven bare syscall shapes of the scanner tests are refused without it.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The message change and negative-control coverage are narrowly scoped and the PR is based on current main. I manually inspected the two reported overlap candidates. #8042 changes only the scanner construction/resynchronization option earlier in SyscallScanner.cpp; it is separate from this PR’s SDK-stub classification and message hunk, so I found no ordering requirement there.

#8729 does change the same trap-condition line and renames IsSdkMmanSyscallStub to IsSdkInlineSyscallStub. This branch still calls the old name. If #8729 lands first, this PR will need that call updated; the checklist currently says Depends on: none, and I found no landing-order agreement in the PR discussion. Please coordinate with @hyvvs on which change lands first, update the Depends on entry to reflect that agreement, then rebase/recheck the combined line. The current hosted relinker matrix is still running on Windows; Ubuntu, macOS x86_64/arm64 and ASAN have passed so far, while platform product-build jobs are skipped.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding the same-line overlap explanation and recording that the second branch needs a small adaptation. The live overlap check still reports #8729 on the exact syscall predicate line. This branch continues to call IsSdkMmanSyscallStub, while #8729 renames it to IsSdkInlineSyscallStub; the checklist still says Depends on: none, and I do not see an agreed landing order in the discussion.

Please coordinate the order with #8729's author, record the required predecessor on Depends on if one must land first, then rebase/update the helper call and rerun the relinker matrix. The hosted Ubuntu, both macOS architectures and ASAN jobs pass; the hosted Windows relinker job is still running. Product Linux/Windows jobs are skipped. The PR's reported Linux and Windows focused tests are author-reported; I did not run local tests.

The #8042 shared-file result remains a non-blocker: its scanner-construction change is separate from this classification/message hunk. This request is limited to the unresolved #8729 same-line integration rule.

@MarcZX10

Copy link
Copy Markdown
Contributor

The latest update keeps the accurate same-line overlap description, but the code still calls the old helper and the checklist still says Depends on: none. Please agree the order with #8729’s author, record any required predecessor, then update the helper call after the agreed integration and rerun the matrix. The Windows relinker job has now passed along with Ubuntu, macOS x86_64/arm64 and ASAN; product builds are skipped.

@DavidSamir

Copy link
Copy Markdown
Contributor Author

@MarcZX10 thanks. I have asked @hyvvs on #8729 about the order. Their PR is a draft that its author is holding for a decision on nmount and unmount, so I proposed that this one lands first and that #8729 updates the helper name inside const bool sdkStub = ... when it is rebased, which is one word. Until they answer, Depends on: none stays, since this PR does not need #8729.

If they would rather land first, I will rebase this branch onto #8729, call IsSdkInlineSyscallStub, and change Depends on to #8729. I will update this PR as soon as the order is agreed.

@MarcZX10

Copy link
Copy Markdown
Contributor

The #8729 ordering is now settled: its author agrees this PR lands first, then #8729 rebases and adapts the helper call. Depends on: none is correct for this branch. I also built the PR snapshot with the repository relinker-only configuration in /dev/shm and ran ctest -R ^syscall_scanner$: 1/1 passed. git diff --check, current-main conventions and merge-tree pass. One remaining requirement is freshness: the branch is 2 ahead/116 behind current upstream/main 4777cac (merge base 94fbb8c). No intervening main commit changes the scanner paths, but CONTRIBUTING still requires the branch to stay current. Please update and rerun the relinker matrix/focused tests on the resulting head. Hosted Ubuntu, Windows, both macOS architectures and ASAN relinker jobs pass; product builds are skipped.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scanner message and negative-control test look sound. I built the PR snapshot with ANYPS5_RELINKER_ONLY=ON, built the relinker and scanner test target, and ran ctest -R ^syscall_scanner$: 1/1 passed. The #8729 author has now agreed this PR lands first, so the prior overlap blocker is resolved and Depends on: none is accurate. I am retaining changes requested only because this branch is 2 ahead/116 behind current upstream/main 4777cac (merge base 94fbb8c). Please update to current main and rerun the focused tests and relinker matrix. Conventions, diff-check and merge-tree pass on the current head; hosted product jobs are skipped.

@plexerPK

Copy link
Copy Markdown
Contributor

I have a local SDK-stub matcher fix that requires the candidate to start at a decoded instruction boundary and keeps its suffix within the scanned code range. It touches the matcher calls changed here, but addresses a different bug.

Would landing this PR first, then adapting the follow-up to pass the additional bounds through your shared sdkStub expression, work for you? This preserves your diagnostic and need not alter the order already discussed with #8729. I tested the combined resolution with #9719 and our fixed-ES decoder follow-up on main 4c06b21681bc46b762255ca25b7749f66b881ab4: all 237 relinker CTest tests passed on macOS arm64. This covers synthetic ELF conversion and native tooling; converted Linux/Windows programs were not executed. Analysis, implementation and testing were AI-assisted with Codex.

@MarcZX10

Copy link
Copy Markdown
Contributor

Follow-up on the overlap report for #10792: the overlap check marks this PR and #10792/#10479 on the same SyscallScanner.cpp lines. All three current checklists say Depends on: none. CONTRIBUTING.md asks authors to agree on merge order and record it with Depends on; please coordinate with #10792 and #10479 so the affected checklists reflect the agreed order. I have not modified your branch.

@MarcZX10

Copy link
Copy Markdown
Contributor

Merge-order follow-up from the current overlap discussion: #10479 is proposed first, this PR second, and #10792 third; #10792’s author agreed and now lists both predecessors. The #10479 author’s earlier note also says #9549 should depend on #10479. Could you confirm that order and, if agreed, update this checklist to Depends on: #10479? That would make the declared order consistent across the overlapping SyscallScanner changes.

@adriadam10 adriadam10 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MarcZX10's CHANGES_REQUESTED (2026-10-22, on this head) is still open, and the queue will not merge past it:

  • Merge order: #10479 is proposed first, this PR second and #10792 third (MarcZX10, 2026-10-25; #10792's author agreed and lists both predecessors). plexerPK proposed this PR first on 2026-10-24. Please confirm one order with the #10479 author. If #10479 goes first, set Depends on: #10479; if this PR goes first, say so in the thread so the other two lists match. The code needs no change either way: whichever lands later adapts the sdkStub expression.
  • Freshness: the branch is 3939 commits behind main. Rebase it and rerun syscall_scanner and the relinker matrix; the scanner paths themselves have no intervening change.

The change itself (sdkStub hoisting, hint text, RequireHint failing without the change) is fine; once the order is recorded and the branch is current this is a merge.

@Felipebmaitan

Copy link
Copy Markdown
Contributor

@plexerPK I read your SDK matcher boundary/range proposal above. A fresh review of #10861 composed with #10792 (607bcb9291) independently reproduced the numbered pathconf matcher starting inside a movabs operand. I am adding decoded-prefix and scanned-range checks for this local composition so it cannot publish a corrupt route. This overlaps the matcher work you described; I will share the repair pin and tests once validated. I will not edit #9549 or your branch, and will preserve its diagnostic when composing that declared predecessor.

@blawesom

Copy link
Copy Markdown
Contributor

Static review plus an independent Linux run (CachyOS, kernel 7.2.10, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON, Ryzen 7 9800X3D). No findings.

What I checked (static)

  • SyscallScanner::ScanCodeSectionForSyscalls computes sdkStub once (was inlined into the trapSdkStubs arm) and reuses it in the exception-message path so a refused (non-trapping) syscall that is nonetheless an SDK stub names the flag that would have replaced it with UD2. The suffix is added only when sdkStub is true — plain refused syscalls (kUnsignedStub, kRegisterStub, kInt80Stub, kSysenterStub, kSysretStub, kClobberedStub, kPrefixedConstantStub) must not mention it. The new RequireHint helper pins both polarities: kConstantStub and kSdkGenericStub name the hint; the bare-syscall loop pins 7 negative cases.
  • Message grammar reads well (; it is a ps5-payload-dev SDK syscall stub, which --trap-sdk-syscall-stubs replaces with UD2) — same vocabulary as the trap path's existing wording, so tooling grepping for that name sees consistency.

Focused test run

tree result
this head d339df76c8 1/1 syscall_scanner Passed (0.01s)

Note on run history (same class as #7985/#8912/#6146): my first pass reported syscall_scanner FAIL. Cause was a stale build/core/relinker/relinker binary carried over from a prior checkout — syscall_scanner_tests shells out to that binary, which ctest does not rebuild transitively when the checked-out source/backtrace does not match. After cmake --build build --target relinker, the fixture passes immediately. Same recipe applies anywhere a Python/relinker-driver fixture fails with (paraphrasing either message) Relinker did not name --trap-sdk-syscall-stubs / does not match its expected output after a branch switch: build the relinker target explicitly before suspecting the change under test.

Not covered

This change affects only the human-readable refusal text for one class of syscalls (the trap path and the broad refused-syscall path are unchanged). No paired Vulkan-execution run is required for a relinker/diagnostics-only fix; the focused syscall_scanner fixture is the enclosing check here, and the hint polarity is fully pinned (true-fixture count 2, false-fixture count 7).

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 29, 2026
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 4, 2026
@JJenkx

JJenkx commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Windows check of head 98da885559, merged onto main 9fb2d9bb83 (081b0a00ab).

Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release.

syscall_scanner fails in 3 of 3 runs:

syscall_scanner_tests: Relinker did not name --trap-sdk-syscall-stubs for the numbered SDK stub:
...
FAIL: Forbidden syscall instruction at code offset 0xa: syscall number 9 (offset 0xa)

The same test passes on main on this machine (full Windows sweep of main 988ee6d3db), so the failure comes with this PR. The branch is old, though, so it may be an interaction with later main changes rather than the PR's own code.

AI-assisted: yes.

@adriadam10
adriadam10 dismissed MarcZX10’s stale review November 9, 2026 21:49

Dismissing a stale review: the requested changes were addressed after it (new head) and the merge queue blocks on it. Please request changes again if anything is still open.

@adriadam10
adriadam10 merged commit e7c3bfd into boykopovar:main Nov 9, 2026
13 checks passed
@adriadam10

Copy link
Copy Markdown
Collaborator

Rechecked on current main now that #10479 (the declared Depends on) has merged: the head merges cleanly, the sdkStub hint and the int 0x80 table branch from #10479 do not interact (the hint only applies to syscall SDK stubs), and RequireHint still pins both polarities (two SDK stub shapes get the hint, seven bare syscall shapes do not, so it fails without the change). CI is green on the head. The Windows failure reported on 11-08 matches the stale-relinker-binary pattern from the Linux run above, and syscall_scanner is registered on Linux only; merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants