fix(agc): count read-trapped guest pages as accessible on Linux #28319
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/28319"
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 milescoviello on 2026-11-30T01:22:10Z.
What
On Linux a label read trap makes a pending storage image's pages PROT_NONE until a CPU access stores it. The driver's guest memory checks read the host protection, so a draw that binds those pages as a color target throws "guest memory is not readable" although the guest mapped them read-write. GuestWriteWatchProtection now reports the read-write protection behind a Linux read trap, and the driver's Linux page queries use it for the runs the host reports inaccessible.
Tested
Seen in PPSA99169 on Linux, NVIDIA RTX 4070 Ti (driver 615.71.09): on
main1f27e2abfits second executable (a renderer that maps its own direct memory at0x4000a00000+0x100000, read-write, and maps it again at the same address several times) stops 10 s in withAGC driver: guest memory is not readable at 0x4000a00000 (range 0x4000a00000+0x2000), called fromGraphics::DecodeColorBuffer(anaddr2lineof the caller offset thatAPS5_TRACE_UNREADABLEprinted). A local diagnostic at that throw printed/proc/self/mapsas4000a00000-4000a02000 ---s ... /memfd:direct memory, a live 1-byte read of it failing, and the driver's page cache holding it as inaccessible: the two pages were under a label read trap (a small pending storage image), and the next draw bound the same memory as a color target. The last mapping of the range before the throw was read-write, with no unmap in between.Tests, on Linux (Ubuntu 26.04, GCC 15.2, Release), at
140a47c65c0onmainb3856362f3e, then at47270402fafand at the current headd600bd27f5fonmain0ed2560d37e(after the CodeRabbit fixes):New
agc_driver_read_trapped_guest_range: commits a 64 KiB guest arena range read-write, sets a read trap on two of its pages, and checks thatGuestWriteWatchProtectionreports read-write for the trapped run and splits the untrapped run at it, thatGuestMemory::CheckRange(writable) andAccessiblepass for the trapped pages and for the whole range, that none of this runs the resolver, and that a trapped page still holds its bytes once the trap is released. It passes in 3 of 3 runs at each head, withagc_driver_compare_helpers_read_trapandagc_driver_label_trap_committer_resolve; the test logs show the new test's pass line, not a skip.Mutation check (at
140a47c65c0): withmain'sGuestWriteWatch.cppandGuestMemory.cppand the new test, only the new test fails, ata trapped page did not report read-write; the other two still pass.Mutation check (at
d600bd27f5f): with onlymain'sGuestMemory.cpp(this PR'sGuestWriteWatch.cppkept), the new test fails withAGC driver: guest memory is not readable at 0x200001000 (range 0x200001000+0x2000), the title's message; the other two still pass. Atd600bd27f5fall three pass in 3 of 3 runs.agc_driver_read_trapped_guest_range_maps_fallback, new at8aee1cd49f6(asked for by @ligmaSec): the same fixture withAPS5_NO_PROCMAP_QUERY=1, so the page walk takes the/proc/self/mapstext scan instead of thePROCMAP_QUERYioctl. It and the default registration pass in each of 3 runs at that head on Linux (GCC 15.2, Release).Windows, from @maskym (comment): Windows 11, NVIDIA RTX 2070 SUPER, WinLibs GCC 15.2.0, Release, head
d600bd27f5merged alone intomain63ee1c120a, with the validation layer: theagc,video_outandpad_sdltests give the same results and the sameVUID-set as onmain; the new test skips there, since the read traps it sets are the Linux ones, andagc_driver_pm4_stall_prompt_lock, which failed once in the parallel run, passes 3 of 3 alone.PPSA99169 with this change (
d600bd27f5f), same machine: it ran the full 64 s with 2532 frames presented and no driver error, wheremain1f27e2abfstopped at 10 s after 1 frame. The frame dumps at 0, 10.3, 20.4 and 31.3 s show the frontend's menus, changing with the scripted button presses: contact sheet (all frames). This is one run.mainon GitHub-hosted Windows Server 2022 and 2025 runners (WinLibs GCC 15.2.0). The report says nothing fails that does not also fail onmainon the same machine (it prints 2 failed tests in both counts on Windows Server 2022 and 0 and 1 on Windows Server 2025, and says 2 of the failing tests fail onmaintoo; it does not name the tests, so the failures beyond those 2 are not shown to also fail onmain).d600bd27f5merged into a pinnedmainand on thatmain:agc_driver_read_trapped_guest_rangepasses on the merge, and the scalar Vulkan control, the compare-helper read-trap test and the label trap committer test pass on both; the scalar control loaded Khronos validation 1.4.369 on both, with no missing-layer message and noVUID-. The maps-fallback run at8aee1cd49f6is queued on their side.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)Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-30T01:32:32Z.
Review: COMMENTED
Actionable comments posted: 1
Architecture findings (1)
Advisory architecture findings (1)
c4f93d18-7f13-43a6-8c80-2a2a16783c0fReviewing files that changed from the base of the PR and between
0ed2560d37and72f3f3f227.core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/tests/execution/ReadTrappedGuestRange.cppcore/libs/prx/libc/src/GuestWriteWatch.cppIncluded 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 coderabbitai[bot] on 2026-11-30T01:40:57Z.
Review: COMMENTED
Actionable comments posted: 1
Architecture findings (1)
Advisory architecture findings (1)
bc8bf15f-af36-4660-9db5-2175183a2c45Reviewing files that changed from the base of the PR and between
72f3f3f227and47270402fa.core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libc/src/GuestWriteWatch.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-30T01:45:06Z.
Review: APPROVED
Reviewed — looks good
The reviewed change is pinned to
d600bd27f5fd7233961a00e83d885f3cfe4dd1a; I found no verified blocking defect in the changed code, but did not run checks or verify the reported runtime results.What I ran
Read the prepared description, commit list, manifest and diff, then inspected the three changed files at the pinned head and the execution-test registration context using
repo_read.py. No build or tests were run.Results
Findings
Blocking
None verified.
Non-blocking
None.
Not verified
The description reports Linux tests and a mutation check, but these were not independently run. The PPSA99169 runtime run and its driver-revert mutation check were still queued in the description. The prepared
files/directory contained no files; all three changed files listed as reviewed in the manifest were read through the pinned reader. No files were excluded in the manifest.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-30T01:48:12Z.
Review: COMMENTED
Actionable comments posted: 1
5edb93db-b335-4dcb-9198-917a19357e89Reviewing files that changed from the base of the PR and between
47270402faandd600bd27f5.core/libs/prx/libc/src/GuestWriteWatch.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T19:12:41Z.
Review: COMMENTED
Correction to my earlier review: the AGC CMake loop discovers
tests/execution/ReadTrappedGuestRange.cppand registersagc_driver_read_trapped_guest_rangeautomatically. The fixture checks that the logical read-write run stops at the trap boundary, the driver accepts the whole range, and checking protection leaves the resolver untouched. Please also exercise the same fixture with the maps fallback forced, since this change has separate paths for the proc-map ioctl and the text scan.AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T20:01:05Z.
Review: COMMENTED
Correction to my earlier review. The execution-test glob already registers
ReadTrappedGuestRange.cpp. Atd600bd27f5, the integratedagc_driver_read_trapped_guest_rangeran and passed. The scalar Vulkan control, compare-helper read-trap test, and label trap committer test passed on both pinned main and the merge. The scalar control inserted validation layer 1.4.369 on both arms with no missing-layer messages orVUID-errors.The
8aee1cd49frevision adds an explicit second run withAPS5_NO_PROCMAP_QUERY=1for the text maps scan. I verified the registration in source. The new execution is queued on Linux.AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-03T20:28:29Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this; the points below are optional.
What I ran
Reviewed head
8aee1cd49f6e07c82222b6ab6ba0f737a8a47480. No merged-preview check was run; base comparison was not applicable. No tests or build commands were run, and no toolchain was used.Results
Negative control
Not run; no test was executed or modified for a negative control.
Findings
Blocking
None.
Non-blocking
None.
Sources
Not verified
The reported Linux and Windows test runs, application run, and CI results in the PR description were not independently verified. Runtime behavior on other systems and hardware was not tested. All four files listed under
reviewedinfiles.jsonwere read; no files were excluded.To get this to a good state
Nothing is required.
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.