fix(libSceAgc): copy packet info guest pointers safely #22137
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/22137"
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 domx4q on 2026-11-17T06:19:30Z.
What
sceAgcGetPacketSize,sceAgcGetDataPacketPayloadAddress_0090(and itssceAgcGetDataPacketPayloadAddressalias),sceAgcGetDataPacketPayloadRangeandsceAgcDcbGetSystemSoftwareVersionread the PM4 header, and the version dword, straight from the guest packet pointer, so an unmapped packet crashed the process. They now copy those words in withGuestCopyIn_nid_no_patchand compute on the host copy. An unreadable packet throws throughAgc::Command::Require("source pointer is not readable"), the way #20051 made these exports handle an unwritable output pointer. A type 1 payload address query still does not read the packet. For readable packets the results are byte-for-byte the same.No debt fragment: the existing
libSceAgc.mdentries describe only the null or unwritable output pointer, not how an unreadable packet is handled.Overlap
python3 tools/pr_overlap.py --names sceAgcDcbGetSystemSoftwareVersion sceAgcGetDataPacketPayloadAddress_0090 sceAgcGetDataPacketPayloadRange sceAgcGetPacketSize sceAgcGetDataPacketPayloadAddress: every function ismain: core/libs/prx/libSceAgc (implemented),open: none.python3 tools/pr_overlap.py --branch fix/agc-packet-info-guest-pointers: "No overlap with open pull requests."Tested
Arch Linux, GCC 16.2.1, Release,
-DBUILD_TESTING=ON.ctest --test-dir build -R 'agc_commands$|agc_packet_info|agc_payload_range|agcvsh_packet_writer': 4/4 passed (libSceAgcVshcompiles the samePacketInfo.cpp).ctest -R '^public_headers$'passed.core/libs/prx/libSceAgc/tests/PacketInfo.cpppass the unmapped address0x10(the address the library's existing tests use for unwritable outputs) as the packet to each of the four exports, and for both types ofsceAgcGetDataPacketPayloadRange.mainone at a time. Each timeagc_packet_info_testsdied withfatal SIGSEGV ... at address 0x10(rc 139), and it passes with the fix.python3 tools/guest_pointer_audit.py libSceAgcno longer lists anything inPacketInfo.cpp.python3 tools/check_conventions.py --base origin/mainpasses.python3 tools/debt_fold.py --checkfails only ondocs/dev/debt/changes/docs-nkwebkit-drop-readded-count-lines.md, which is already onmainand is not touched here.ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer ctest -R '^(agc_commands|agc_packet_info_tests|agc_payload_range_tests|agcvsh_packet_writer)$' -V, once onmain(e4caa07950) and once on this branch. Both runs passed 4/4 with 0VUID-lines and nowas not found but was requested by env var VK_INSTANCE_LAYERS. These CPU-only packet tests never create a Vulkan instance, so neither log has anInsert instance layerline. To show the layer setup works,vulkaninfo --summarywith the same environment logsInsert instance layer "VK_LAYER_KHRONOS_validation" (/usr/lib/libVkLayer_khronos_validation.so), layer 1.4.363.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)