Skip to content

fix(tools): pass every replay argument explicitly - #21326

Merged
oneandonlydean merged 2 commits into
boykopovar:mainfrom
kaiffeetasse:contrib/oracle-replay-explicit-arguments
Nov 17, 2026
Merged

oneandonlydean merged 2 commits into
boykopovar:mainfrom
kaiffeetasse:contrib/oracle-replay-explicit-arguments

Conversation

@kaiffeetasse

@kaiffeetasse kaiffeetasse commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

What

The replay called every export through an eight-argument function pointer:

using Function = std::uint64_t(APS5_VABI*)(std::uint64_t × 8);

An export that takes more parameters reads the rest from the caller's stack, so the same tree produced different packets depending on the process environment. Measured before the change: sceAgcDcbCopyData carried 0x78, 0xc9 and 1 in its write-confirm slot across three invocations of one binary, which flipped twelve known entries between throw and diff from run to run (the agcbuild_{Acb,Dcb}{CopyData,DmaData}_{a,b,c} rows).

Declare sixteen parameters and pass zeros for the ten the recording does not supply. The twelve cases now encode deterministically, and their known.tsv rows record the packet difference in the fields the recording never carries (the console's item size and write confirm for CopyData, its source address and byte count for DmaData), instead of claiming a throw that no longer happens.

tools/library-oracle/known.tsv is the only other file the change touches, and only in those twelve rows. The three DcbDmaData rows also state the number of parameters sceAgcDcbDmaData declares: twelve (DcbFlow/include/Memory.hpp), where the row text said ten; the AcbDmaData rows keep ten, which is what Acb/include/Memory.hpp declares there.

Tested

Linux (Ubuntu, i5-8500T, GCC, Ninja, Release), tree c50f19c4b8 (rebased onto current main), library_oracle_replay and libSceAgc freshly built from that tree.

With this change, two consecutive runs of the same binary, byte-identical summary:

agcbuild: compared 208 mismatched 117 skipped 1
117 known findings, 0 new, 0 now matching

Re-measured on main bb95654123 (same two targets rebuilt from that tree): with the fix and main's twelve throw rows the run reports 105 known findings, 12 new in two consecutive runs even with the sixteen-argument pointer, and with this PR's twelve rows 117 known findings, 0 new, 0 now matching. A sweep of the other families on the same tree (libc, kernel, kernelx, posix, nethttp, rtc, userservice) reports 7 known findings, 0 new, 0 now matching, so no other row went stale under the new main.

Control on the same tree and the same target, only replay.cpp reverted to main's version, three consecutive runs:

run 1: 111 known findings, 6 new
run 2: 105 known findings, 12 new
run 3: 105 known findings, 12 new

and the case that flips names its cause in the report itself: DcbDmaData_c throws reserved bits are set (value 0xd0, allowed 0x1), then 0x60, then 0x20 — the stack garbage the eight-argument pointer reads. The intermediate state (fix without the row changes) reports 105 known / 12 new: the twelve cases no longer throw, so a throw row no longer covers them. That is why the two files change together.

The rebase onto c50f19c4b8 happened after main deleted the AcbAcquireMem, AcbEventWrite, AcbJump, WaitRegMem and SET_PREDICATION rows through #19339, #19320, #19338, #19290 and others; diff origin/main tools/library-oracle/known.tsv shows exactly the twelve row changes and both files have 126 lines, so no deleted row came back and none was lost.

python3 tools/library-oracle/test_library_oracle.py: 23 tests, OK. python3 tools/check_conventions.py --base origin/main: all conventions checks passed.

python3 tools/pr_overlap.py --branch contrib/oracle-replay-explicit-arguments --jobs 8 on head 58bd96dedf probes 1614 PRs and reports 13 share files or exports with the branch; the table names #19309 (known.tsv L4-9) and #19355 (L65-74) and four comparisons fail closed (#19194, #19196, #19708, #20294). git merge-tree --write-tree answers CONFLICT for every one of them, and the changed identifiers in each rival's known.tsv diff are disjoint from this change: #19309 deletes CondExec/SetCxRegistersIndirect/SetShRegistersIndirect/SetUcRegistersIndirect, #19355 rewrites DrawIndexIndirect/DrawIndirect, #19194 deletes SetIndexBuffer/SetIndexIndirectArgs/SetIndexSize, #19196 rewrites CbMemSemaphore_c, #19708 deletes the DispatchIndirect rows, #20294 rewrites SetFlip/WaitUntilSafeForRendering. This change edits AcbCopyData (L7-9), AcbDmaData (L13-15), DcbCopyData (L59-61) and DcbDmaData (L65-67), so the overlap is only the three-line context window and a merge with any of them needs its neighbouring lines resolved by hand. Depends on: none.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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

@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.

Reviewed — looks good

The replay now supplies deterministic zero values for stack arguments omitted from recordings, and the affected known-result rows reflect the resulting packet differences.

What I ran

Reviewed head 8bfec74aac5e0299081d3136c3d96c86ef2a574e. I read review/description.md, review/commits.md, review/manifest.json, review/diff.patch, and the full changed files tools/library-oracle/replay.cpp and tools/library-oracle/known.tsv. No tests or build commands were run.

Results

Check Result Note
Diff and changed files passed Both changed files were read.
Tests and build not run No independent test run.
Description claims not verified Reported commands and measurements were not rerun.

Findings

Blocking

None.

Non-blocking

None.

Not verified

The author-reported replay summaries, test results, conventions checks, and overlap analysis were not independently verified. No other files were changed or excluded according to the manifest.

To get this to a good state

Nothing is required.

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 19309 tools/library-oracle/known.tsv L4-9
PR 19355 tools/library-oracle/known.tsv L65-74

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 19194 tools/library-oracle/known.tsv
PR 19196 tools/library-oracle/known.tsv
PR 19708 tools/library-oracle/known.tsv
PR 20294 tools/library-oracle/known.tsv

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Nov 16, 2026
The replay called each export through an eight-argument function pointer, so an
export with more parameters read the rest from the caller stack and the same
tree produced different packets depending on the process environment:
sceAgcDcbCopyData saw 0x78, 0xc9 and 1 in its write-confirm slot across three
invocations of one binary, which flipped twelve known entries between throw and
diff.

Declare sixteen parameters and pass zeros for the ten the recording does not
supply. The twelve CopyData and DmaData cases now encode deterministically, and
their known.tsv rows record the packet difference in the fields the recording
never carries.

Measured on e04bd77 with freshly built modules: 151 known / 0 new / 0 now
matching in two consecutive runs, against 145 known / 6 new before the change.
@kaiffeetasse
kaiffeetasse force-pushed the contrib/oracle-replay-explicit-arguments branch from 8bfec74 to 6a4949f Compare November 17, 2026 01:15
@kaiffeetasse

Copy link
Copy Markdown
Contributor Author

Rebased onto c50f19c4b8 after GitHub reported the branch CONFLICTING. The conflict was in tools/library-oracle/known.tsv only: main had deleted the AcbAcquireMem, AcbEventWrite and AcbJump rows through #19339/#19320/#19338/#19290, and my hunk carried them along. The rebase keeps main's deletions and only the twelve {Acb,Dcb}{CopyData,DmaData} edits; diff origin/main on that file is exactly twelve changed rows, 126 lines on both sides.

Re-measured on the new head (modules rebuilt from c50f19c4b8): with the change, twice agcbuild: compared 208 mismatched 117 skipped 1 / 117 known findings, 0 new, 0 now matching; control with main's replay.cpp on the same tree, three runs 6 new, 12 new, 12 new with reserved bits 0xd0, 0x60, 0x20 in DcbDmaData_c. test_library_oracle.py 23/23, conventions green. Overlap re-checked against the current rivals (#19309, #19355, #19194, #19196, #19708, #20294): every merge-tree conflicts, none of them touches a CopyData/DmaData row — all six changed only neighbouring rows, so Depends on: none stands.

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 17, 2026

@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.

Reviewed — no blocking findings

The replay now passes sixteen arguments, which removes the stack garbage the eight-argument call read; one note in known.tsv misstates the argument count of sceAgcDcbDmaData.

What I ran

  • Head: 6a4949f22a8e300f3c78aabe0fa203fe6470a175, base main. No merged-preview check.
  • No build and no test run in this review. The reader was used for read-only lookups:
python3 repo_read.py search sceAgcDcbCopyData
python3 repo_read.py search sceAgcDmaData
python3 repo_read.py search "DcbDmaData("
python3 repo_read.py search test_library_oracle

Results

Check Result Note
Replay call and type agree (16 and 16) passed Read in replay.cpp
sceAgcDcbCopyData has nine arguments passed Matches the note
sceAgcDcbDmaData has ten arguments failed It has twelve
Oracle test script is wired to CTest passed CMakeLists.txt
Build and the replay runs not run Author-reported only

Findings

Blocking

None.

Non-blocking

  1. tools/library-oracle/known.tsv:65: the DcbDmaData rows say "the recording passes six of the export's ten arguments". sceAgcDcbDmaData takes twelve parameters, so the gap is six, not four. The note should read "twelve". The same wording is on lines 66 and 67.

The code change itself is sound. The type and the call both carry sixteen uint64_t slots, the ten extra slots are zeros, and the export reads only the slots it declares. Calling through a pointer with more parameters than the target declares is the existing pattern in this file.

Sources

  • Export declaration:
    std::uint32_t* APS5_VABI sceAgcDcbDmaData(CommandBuffer* buf, std::uint8_t engine, std::uint8_t dst, std::uint8_t dstCachePolicy, std::uint64_t dstAddress, std::uint8_t src, std::uint8_t srcCachePolicy, std::uint64_t srcAddress, std::uint32_t numBytes, std::uint8_t waitForPrevious, std::uint8_t writeConfirm, std::uint8_t blockEngine);
  • sceAgcDcbCopyData declaration:
    uint32_t* APS5_VABI sceAgcDcbCopyData(CommandBuffer* buf, uint8_t dst, uint8_t dstCachePolicy, uint64_t dstAddress, uint8_t src, uint8_t srcCachePolicy, uint64_t srcAddressOrImmediate, uint8_t itemSize, uint8_t writeConfirm);

Not verified

  • The build, library_oracle_replay, and the byte-identical runs and control numbers in the description. These are the author's reports; I did not run them.
  • The Acb rows (known.tsv:7-9 and 13-15): the argument counts in their notes were not checked against sceAgcAcbCopyData and sceAgcAcbDmaData.
  • The stack-slot measurement (0x78, 0xc9, 1) and the console behaviour it describes. Not measured here.
  • test_library_oracle.py (23 tests) and check_conventions.py. Author-reported; not run.
  • Whether the sixteen-slot call is ABI-safe on every APS5_VABI target. I read only the Linux-side code path.
  • Files read: replay.cpp from the diff and head lines 270-309; known.tsv only from the diff hunks. The rest of both files at head was not read.

To get this to a good state

Nothing is required.

Optional: change "ten" to "twelve" on known.tsv lines 65-67 (see Non-blocking 1).

@kaiffeetasse

Copy link
Copy Markdown
Contributor Author

Applied the non-blocking note in 58bd96dedf.

The three agcbuild_DcbDmaData_{a,b,c} rows now say twelve arguments: sceAgcDcbDmaData declares twelve (core/libs/prx/libSceAgc/DcbFlow/include/Memory.hpp:17). The AcbDmaData rows keep ten, which matches sceAgcAcbDmaData (core/libs/prx/libSceAgc/Acb/include/Memory.hpp:13) — that export has no engine and no blockEngine. CopyData stays at nine for both.

Data-only commit, so no behaviour moved: python3 tools/library-oracle/test_library_oracle.py 23 tests OK, python3 tools/check_conventions.py --base origin/main all checks passed, and the relinker-only build links (276/276). Gate 1 on the new head: probed 1614/1614 … 13 share files or exports; the table names #19309 (known.tsv L4-9) and #19355 (L65-74), #19194/#19196/#19708/#20294 fail closed, and all six git merge-tree runs conflict only on the three-line context: their changed identifiers are CondExec/SetCxRegistersIndirect/SetShRegistersIndirect/SetUcRegistersIndirect, DrawIndexIndirect/DrawIndirect, SetIndexBuffer/SetIndexIndirectArgs/SetIndexSize, CbMemSemaphore_c, DispatchIndirect, SetFlip/WaitUntilSafeForRendering. Still Depends on: none.

@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.

Reviewed — looks good

Nothing blocks this; the points below are optional.

What I ran

  • Head SHA 58bd96d, base main. No merged-preview check was run.
  • Read the changed hunks of both files in the diff, plus the replay call site at head (tools/library-oracle/replay.cpp, lines 280 to 300).
  • Read through the repository reader only. No build and no test run: this review does not compile or execute anything.
  • Excluded by rule: none (files.json lists no exclusions).
Commands
repo_read.py search "APS5_VABI" tools/library-oracle
repo_read.py cat tools/library-oracle/replay.cpp 280 300
repo_read.py search "sceAgcDcbDmaData|sceAgcDcbCopyData|sceAgcAcbDmaData"

Results

Check Result Note
Diff of both changed files passed Every changed line in known.tsv and replay.cpp was read
Call site at head passed Six register arguments and ten zeros, sixteen in total
Argument counts in known.tsv rows not run The export declarations are not in the repository at head
Build and replay run not run Not part of this review
tools/library-oracle/test_library_oracle.py not run Author-reported: 23 tests, OK
tools/check_conventions.py not run Author-reported: passed

Findings

Blocking: none.

Non-blocking: none.

Sources

Not verified

  • The argument counts written into the known.tsv rows (nine for CopyData, ten for AcbDmaData, twelve for DcbDmaData). The author cites DcbFlow/include/Memory.hpp and Acb/include/Memory.hpp. Those declarations are not in the repository at head, so the search returned no matches. Not checked.
  • The author's measurements: 117 known findings with 0 new, the two-run byte-identical summary, the three-run control with the old replay.cpp, the overlap probe against other open PRs, and the rebase against main. None of these was run here.
  • Whether any export takes more than sixteen arguments. The new pointer would not pass those.
  • known.tsv was read through the diff hunks, not as its full text at head.

To get this to a good state

Nothing is required.

@oneandonlydean
oneandonlydean merged commit 385b909 into boykopovar:main Nov 17, 2026
16 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants