fix(libSceVideoOut): reject an unwritable EOP flip token before reserving #28646
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/28646"
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 bkoroglu1 on 2026-12-02T11:01:56Z.
What
sceVideoOutSubmitEopFlipreserved an AGC eop-flip and then wrote the returned token with a rawstd::memcpyinto the caller's guest pointer. An unmapped or read-only token therefore faulted the host, and it did so after the reservation had been consumed, so the queue slot was lost as well.VideoOutDriver::SubmitEopFlipnow rejects a null or wrapping token address, opens aGuestArena::HostWriteguard and probes withGuestWritable_nid_no_patchbefore reserving, and publishes the token throughGuestCopyOut_nid_no_patch, returningVIDEO_OUT_ERROR_INVALID_ADDRESSwhen the output cannot be written.The expected behaviour is pinned by the library's own code, not by a console guess:
sceVideoOutInitializeOutputOptions(src/Output.cpp) andsceVideoOutGetEventData(src/Event.cpp) both stage into a local and publish throughGuestCopyOut_nid_no_patch, returningVIDEO_OUT_ERROR_INVALID_ADDRESSon failure, andcore/libs/tests/GuestVideoOutPointerFaults.cppalready asserts that forInitializeOutputOptions. The guard-then-probe-then-copy chain followslibSceAgc/Misc/src/Semaphore.cpp.This also fixes an ordering bug in the old code: the raw
memcpybypassed the host-write hook, so pending GPU writes over the token range were not synced before the store, and the arena's write tracking never saw it. Both now go through the helpers.The reservation is taken only after the output is known writable. A token that turns unwritable between the probe and the copy still holds its reservation until the port closes, because the AGC driver exposes no release call; the debt entry records that rather than hiding it.
Tested
Windows 11, MSYS2 UCRT64 GCC 16.2.0, CMake 4.5.1, full build (7502 registered tests).
video_out_flip_eopfaults with an access violation insideVideoOutDriver::SubmitEopFlip(exit 139); the new assertions never run.video_out_flip_eop3/3, and the whole VideoOut family 74/74 (two skips by design).file_positionfails identically on the base commit.public_headers_compile_36andguest_pthread_mutex_contentiontime out only under-j 4and pass when run alone (39.62 s for the latter).mainand on this change, from this machine: 3/3 each,VK_LAYER_KHRONOS_validation1.4.363.0 inserted 3 times per run, no "was not found but was requested by env var", and 0VUID-on both sides. The change adds no validation error.python3 tools/debt_fold.py --checkexit 0,python3 tools/check_conventions.py"All conventions checks passed."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)mainand on this change, with the validation layer)Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-02T11:09:48Z.
Review: APPROVED
Reviewed — looks good
The change checks token writability before reserving, then publishes through the checked copy helper; all three reviewed files were read at head
91fc07973bab7da1ef187fb77996b39b72cea040.What I ran
Source inspection only; no tests or builds were run. The reader returned the requested source ranges, then reported that it could not write its read log in the read-only workspace.
Results
Negative control
Not run; no tests were run.
Findings
Blocking
None.
Non-blocking
None.
Sources
Not verified
The reported Windows test and build results, console behavior, and hardware behavior were not independently verified.
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-02T11:10:20Z.
Review: COMMENTED
Actionable comments
core/libs/prx/libSceVideoOut/src/VideoOutDriver.cpp, lines582· 🩺 Stability & Availability · ⚖️ Poor tradeoffGuestCopyOut_nid_no_patchreturns false afterAgcDriverReserveEopFlip_nid_postfixsucceeds. The function returnsVIDEO_OUT_ERROR_INVALID_ADDRESS, and the reservation stays held until the port closes. Each occurrence leaks one slot.libSceAgcDriver. Track that as a follow-up. The debt note atdocs/dev/debt/changes/fix-videoout-eop-flip-token.mdalready records this limitation.d040bc60-2a6d-4dcc-8487-65daad99cb47Reviewing files that changed from the base of the PR and between
fc294cbbb5and91fc07973b.core/libs/prx/libSceVideoOut/src/VideoOutDriver.cppcore/libs/prx/libSceVideoOut/tests/Flip.cppdocs/dev/debt/changes/fix-videoout-eop-flip-token.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T06:03:49Z.
Review: COMMENTED
Ran
ctest --test-dir build -R '^video_out_flip_eop(_main|_aftergpu)?$' -Vonmain(4d6e4f058d) and with this PR applied. All three standard cases passed in both runs on Linux X11/Xvfb with Mesa lavapipe 25.0.7 and Khronos validation 1.4.369. Both logs show layer insertion and zero missing-layer diagnostics or VUID errors under the required environment. A separate fault-injection test found a remaining reservation leak.AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by Plyxen on 2026-12-04T13:37:44Z.
Review: APPROVED
Verified on Windows 11 (GCC 15.2, Release) on main
484b0368d3, withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1and the Khronos validation layer 1.4.363. Every run log shows the loader inserting the layer and none shows "was not found". It ran on an RTX 5080 (621.24) and an AMD Radeon iGPU (26.11.2), together with #28820, #28802, #28780 and #28670.video_out_flip_eop*passed with this change on both GPUs withANYPS5_REQUIRE_DISPLAY=1, with noVUID-messages.VideoOutDriver.cppreverted to main and the test kept,video_out_flip_eopandvideo_out_flip_eop_maincrash with SEGFAULT on both GPUs. The unwritable token is written, so the test catches the bug this fixes.Not run: Linux.
AI-assisted: yes (Claude Code)
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.