Skip to content

fix(ampr): return EBUSY when a command does not fit and EPERM before a buffer is bound - #7300

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
hugodearaujo:fix/ampr-busy-when-full
Oct 17, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
hugodearaujo:fix/ampr-busy-when-full

Conversation

@hugodearaujo

@hugodearaujo hugodearaujo commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

What

The AMPR recording calls (reads, nops, markers and completion writes) returned 0x8002001C both when a command did not fit in the bound buffer and when no buffer was bound. On a PS5 they return SCE_KERNEL_ERROR_EBUSY (0x80020010) when the command does not fit, with the offset and the command count left as they were, and SCE_KERNEL_ERROR_EPERM (0x80020001) when no buffer is bound. The AMM commands in the same file already return these two codes, and ampr_emu does the same.

Titles

CONTROL Resonant (PPSA34547, 01.300.300) and Alan Wake 2 (PPSA02572, 01.200.007) read their compiled effects (/app0/shaders/build/ps5/*.binrfx, 141 and 153 files) through APR command buffers of 0x400 bytes. After each read, their recorder (CONTROL Resonant eboot 0x3b41a32, 0x3b41a49, 0x3b41a78; Alan Wake 2 0x30711b2, 0x30711c9, 0x30711f8) compares the result with 0x80020010. On that value it submits the buffer, binds a new one and records the read again. On main (6005185ee) a 0x400-byte buffer holds 25 reads. The 26th returns 0x8002001C, and so does every later read of that batch, so most effects are never read (116 of 141 in CONTROL Resonant). Both titles then stop with SIGSEGV 7 s after start, with nothing in the log. CONTROL Resonant looks up shapeengine.rfx, gets no effect and reads through the null pointer (eboot 0x383f2b0).

Alternating runs of 40 s (main, this PR, main, this PR), with only libSceAmpr.prx differing:

main this PR
CONTROL Resonant SIGSEGV at 7 s, 2 of 2 running at 40 s, 2 of 2
Alan Wake 2 SIGSEGV at 7 s, 2 of 2 running at 40 s, 2 of 2

One Alan Wake 2 run with this PR was killed by my test script while it cleaned up the run before it, and was repeated.

With this PR, CONTROL Resonant shows its photosensitivity warning, then the Remedy end-user license agreement and privacy policy (they scroll with the right stick and accept with Cross). It then shows the display calibration and First Time Setup. Alan Wake 2 plays the Remedy logo and shows its end-user license agreement. Alan Wake 2's dump has no PlayGo metadata, so it ran with APS5_PLAYGO_UNLISTED_CHUNKS=installed.

Tested

  • PS5 (FW 13.60): a payload calls the console's libSceAmpr.sprx (dlopen and dlsym), and the commands are only recorded, never submitted. With 64-, 100- and 1024-byte buffers, these four calls return 0 until the next command does not fit:

    • sceAmprAprCommandBufferReadFile
    • sceAmprCommandBufferNop
    • sceAmprCommandBufferWriteAddressOnCompletion
    • sceAmprCommandBufferPushMarker

    Then they return 0x80020010, with the offset and count unchanged. A 1024-byte buffer takes 51 reads of 20 bytes. Constructed but never bound, all four return 0x80020001.

    Payload output (the lines where a call fails, plus the last read that fits in 1024 bytes)
    MEASURE|sceAmprMeasureCommandSizeReadFile|0x14
    MEASURE|sceAmprMeasureCommandSizeNop|0x4
    REC|sceAmprAprCommandBufferReadFile|bytes=64|i=3|ret=0x80020010|offset=60|count=3
    REC|sceAmprCommandBufferNop|bytes=64|i=16|ret=0x80020010|offset=64|count=16
    REC|sceAmprCommandBufferWriteAddressOnCompletion|bytes=64|i=8|ret=0x80020010|offset=64|count=8
    REC|sceAmprCommandBufferPushMarker|bytes=64|i=5|ret=0x80020010|offset=60|count=5
    REC|sceAmprAprCommandBufferReadFile|bytes=100|i=5|ret=0x80020010|offset=100|count=5
    REC|sceAmprCommandBufferNop|bytes=100|i=25|ret=0x80020010|offset=100|count=25
    REC|sceAmprCommandBufferWriteAddressOnCompletion|bytes=100|i=12|ret=0x80020010|offset=96|count=12
    REC|sceAmprCommandBufferPushMarker|bytes=100|i=8|ret=0x80020010|offset=96|count=8
    REC|sceAmprAprCommandBufferReadFile|bytes=1024|i=50|ret=0|offset=1020|count=51
    REC|sceAmprAprCommandBufferReadFile|bytes=1024|i=51|ret=0x80020010|offset=1020|count=51
    UNBOUND|sceAmprAprCommandBufferReadFile|ret=0x80020001|offset=0|count=0
    UNBOUND|sceAmprCommandBufferNop|ret=0x80020001|offset=0|count=0
    UNBOUND|sceAmprCommandBufferWriteAddressOnCompletion|ret=0x80020001|offset=0|count=0
    UNBOUND|sceAmprCommandBufferPushMarker|ret=0x80020001|offset=0|count=0
    
  • guest_ampr_markers: the full buffer case now also covers a read, a nop and a completion write, and the unbound case covers all of them. With Export.cpp as on main it fails at GuestAmpr.cpp:254.

  • Linux (Arch, kernel 7.2.9, GCC 16.2.1, Release, AMD Radeon RX 9070 XT with RADV, Mesa 26.2.4): full CTest with -j8, 1371 of 1372 pass. agc_driver_tessellation segfaults; it does not load libSceAmpr.prx, and none of its sources change here.

  • Windows Server 2025 VM, WinLibs GCC 15.2, Release, BUILD_TESTING=ON, no GPU: full CTest, no failures out of 1407; agc_driver_gated_dispatch_capture_short_timeout is skipped there.

  • The tests and runs above are on main 6005185ee. The branch was then rebased onto b4f05ab32 without conflicts (none of the 109 new commits touch these files); there guest_ampr_markers, guest_ampr_threads and guest_ampr_cpp_error pass.

  • tools/check_conventions.py passes. tools/pr_overlap.py: no overlap with open pull requests.

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: PPSA34547 CONTROL Resonant (PPSA34547) #7302, PPSA02572 Alan Wake 2 (PPSA02572) #7303
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

@github-actions

Copy link
Copy Markdown

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 6044 core/libs/tests/GuestAmpr.cpp
PR 6447 core/libs/prx/libSceAmpr/Export.cpp

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants