fix(libSceAgc): report a non-WRITE_DATA packet in sceAgcWriteDataPatchSetAddressOrOffset #24158
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/24158"
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 almarzn on 2026-11-20T08:22:02Z.
What
sceAgcWriteDataPatchSetAddressOrOffsetthrewnot a WRITE_DATA packetwhen the packet it is given is not a WRITE_DATA packet. It now returns0x8a6c000cand leaves the packet unchanged, before the address is checked.Sources, as reading titles and libraries lists them; no console measurement:
AgcWriteDataPatchSetAddressOrOffsetpatches dwords 2 and 3 only when the opcode is WRITE_DATA and otherwise returnsGRAPHICS5_ERROR_INVALID_PACKET(0x8a6c000c, line 810).sceAgcAcquireMemSetEnginefor a packet of the wrong type, already followed here (debt entry).The Async form,
sceAgcWriteDataPatchSetDstandsceAgcWriteDataPatchSetCachePolicystill throw for such a packet: KytyPS5 does not implement them and no other source covers them. The debt fragment records that the behaviour is not measured on a console.Why a title passes such a packet, from PPSA24913 (Ace Combat 8, UE5) on
main:At
0x6384db–0x6385e6it buildssceAgcCbNop,sceAgcDcbWriteData,sceAgcCbReleaseMemandsceAgcDcbWaitRegMeminto a 0x400-byte command buffer on the stack, copies it into another command buffer and rebases the returned pointers. At0x6386b1–0x6386ddit callssceAgcGetDataPacketPayloadAddress, thensceAgcWriteDataPatchSetAddressOrOffset,sceAgcWaitRegMemPatchAddressandsceAgcQueueEndOfPipeActionPatchAddresson the rebased pointers.The copy lands in a 0x90-byte static scratch region (
0x0d212e90in that run) that two of its threads also fill throughsceAgcDcbContextStateOp, rewinding the cursor to its start each time. A failing call receivedcmd=0x0d212eb8, inside the NOP(8) thatsceAgcDcbContextStateOpwrites:The title ignores the result. With this change it no longer stops at the logos or the world load on this call.
Tested
Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release, on
mainate825fa1492.agc_write_data_patch_tests: passes. A NOP packet, a packet body and a NOP with a misaligned address each return0x8a6c000cand stay unchanged for the graphics form; the Async form still throws. Negative control: withWaitRegMem.cppfrommainthe same test fails withsceAgcWriteDataPatchSetAddressOrOffset: not a WRITE_DATA packet.python3 tools/check_conventions.py --base origin/main: passes.python3 tools/debt_fold.py --check: passes.--to-intel, Intel i5-12600KF, NVIDIA GeForce RTX 5070 Ti, driver 32.0.16.2124): onmainit stopped in this call in most runs, from 22 s to 2.5 min. With this change it did not stop in this call in any of three runs; one of them stopped insceAgcQueueEndOfPipeActionPatchAddress: unexpected packet type, size or flags, the third call of the same sequence, which #22184 changes.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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T09:06:29Z.
Review: APPROVED
Reviewed — looks good
Nothing in the changed code blocks merging; the graphics address patch reports the invalid packet before address validation and the tests cover the new behavior.
What I ran
Reviewed head
8fcf2009a913265ed5db282c424ae12b57b6a8e3. I read the prepared description, commits, manifest, diff, and all three changed files. No commands or tests were run; reported test results below are author-supplied.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
No tests were run independently. The PR description reports the focused test, convention check, and debt check passed, and describes three title runs; these results were not independently verified. No files were excluded from review.
To get this to a good state
Nothing is required.