Repository navigation
fix(kernel,agc): honor GPU-only memory protection bits - #23770
oneandonlydean merged 2 commits into
Conversation
Adjacent registered ranges that differ only in the GPU write bit while the CPU can write both stay one run, as on main. Ranges whose host writability differs are split. Record that frame capture still skips GPU-only memory. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — no blocking findings
The inspected changes consistently track GPU write access separately from CPU permissions, and I found no concrete defect in the reviewed paths.
What I ran
Inspected the prepared diff for head 69dc84cb083fb980ad295d38a6b9f9af28e20620 and targeted source context through repo_read.py. No commands or tests were run.
Results
| Check | Result | Note |
|---|---|---|
| Diff and targeted source review | passed | No concrete defect found in inspected paths. |
| Tests and build | not run | No execution environment was available. |
Findings
Blocking
None.
Non-blocking
None.
Not verified
Tests and builds were not run; author-reported results in the PR description were not independently confirmed. Full file text was not inspected for the oversized changed files core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp, core/libs/prx/libSceAgcDriver/tests/Graphics.cpp, and core/libs/prx/libSceAgcDriver/tests/Recorder.cpp; their changed regions were inspected. The remaining unchanged portions of other changed files were not reviewed.
To get this to a good state
Nothing is required.
|
NVIDIA Linux run with the Khronos validation layer of the current head Setup: Arch Linux (kernel 7.3.4), GCC 16.2.1, Release, NVIDIA GeForce RTX 4090 (vendor
The pattern covers the four test programs this PR changes (
Negative control: this PR's tests with No new AI-assisted: yes (Claude Code) |
|
Head No new failures and no new validation messages on either GPU.
Layer runs used AI-assisted: yes |
|
Tested on NVIDIA, to add a second vendor to the AMD run. There are no regressions, and the new test passes. System: Windows 11 Pro 10.0.26200, NVIDIA GeForce RTX 4060 (10de:2882), driver 621.01, Intel Core i5-12400F, WinLibs GCC 15.2.0 r7 (UCRT), Release, Trees: main 9d5f50b, and the same commit with head 69dc84c merged with Run:
| main | this PR
-- | -- | --
tests | 324 | 325 (+ agc_storage_gpu_only_writeback)
passed | 317 | 318
failed | 2 | the same 2
skipped | 5 | the same 5
Insert instance layer "VK_LAYER_KHRONOS_validation" | 177 | 178
was not found but was requested | 0 | 0
VUID- lines | 0 | 0
One addition to your run: with WinLibs GCC 15.2.0 r7, Not tested: Far Cry 6 (I don't have the title), Linux, and the "HostReadable/HostWritable reduced to the CPU bits" counter-check. AI-assisted: yes (Claude Code). It merged the PR, ran both builds and test sets, and drafted this comment. |
Planet Zoo (PPSA18026) marks a 32 GiB range at 0xd000000000 as PRT with the AMM, so its unbacked pages are zero pages with GPU read protection (0x10). Since the AGC driver takes GPU-only memory into its leases (#23770), every address-based build took that range in. It could neither import it (over the host import budget) nor mirror it, so it counted it as a copy and aborted: "an address-based build copies 32761 MiB of 3 registered ranges, past 64 MiB (APS5_ADDRESS_COPY_MAX_MIB)". Zero pages now keep their GPU read protection (sceKernelVirtualQuery is unchanged) but are registered without the GPU bits, so the driver leaves them out of its leases and host imports, as it left all GPU-only memory before #23770. Pages the AMM maps into the range keep their protection's bits. Outside Windows, DoMapZero now passes the zero flag to MapAnonymous instead of calling DoMapAnon; the mapping itself is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What
Far Cry 6 (PPSA01870 01.000.013) draws no text on its splash screen and main menu: the buttons are there, empty. The title maps the memory its UI text is drawn into (a 16 MiB block at
0x23f300000) with protection0x30, GPU read and write without CPU read or write, and fills it from a compute shader through storage images.LinuxProtFromScealready commits such memory read/write on the host (0x10gives read,0x20read and write).GuestAllocationsregistered it withreadable = falseandwritable = false, though, and the AGC driver only takesreadableranges into its leases. So GPU-only memory was missing from the leases, the BDA table, host imports andRegisteredReadableCovers, and storage-image results stored there were dropped as "memory no longer registered".A registered range now keeps the GPU write bit (
gpuWritable), and the driver asks two questions instead of the CPU bits:HostReadable()=readable || gpuHostWritable()=writable || gpuWritableThese are exactly the host protections
LinuxProtFromScegives the pages, so the driver reads and writes only pages the host lets it.What stays the same:
sceKernelSyncOnAddressWait32on GPU-only memory still returnsEFAULT(new case), andsceKernelVirtualQueryreports the same protection as before.AddandProtectsetgpuWritable = gpu && writable, soHostWritable()equalswritablefor every caller that does not pass the new argument.HostReadable()differs fromreadableonly for ranges with GPU access and no CPU read, which onlylibkernel's mappings andsceKernelMprotectcreate; they now pass the GPU write bit.GuestAllocationsAcquireMapped) when their CPU bits, GPU bit and host writability match, so every run that joins onmainstill joins. They split only where host writability differs, for example0x11next to0x31.main; the debt fragment records it.Changes
libc/include/GuestAllocations.hpp,libc/src/GuestAllocations.cpp:Range::gpuWritable,HostReadable()andHostWritable();GuestAllocationsAddGpu_nid_no_patchandGuestAllocationsProtectGpu_nid_no_patchbehind 6-argumentMutation::AddandMutation::Protect. The 5-argument forms forward to them;gpuWritablerequiresgpu, and survivesFind, splits and unmaps;GuestAllocationsEnd's GPU mapping notice andGuestAllocationsAcquire,AcquireMappedandAcquireRegisteredtakeHostReadable()ranges.libkernel/DirectMemory/DirectMemory.cpp:sceKernelMapDirectMemory, flexible mappings, fixed remaps andsceKernelMprotectpassprot & 0x20as the GPU write bit.libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp,Execution/src/ShaderMemory.cpp: the lease, import, mirror, BDA and registration checks useHostReadable()andHostWritable().registeredReadableCoverTests,leaseSnapshotTestsandCheckMappedLeasesPreserveReadableRuns. Those inputs now drop the GPU bit, and each test gained the GPU-only variant.0x30and0x10throughsceKernelMapDirectMemory,sceKernelMprotectandsceKernelMapNamedFlexibleMemory.EFAULTfromsceKernelSyncOnAddressWait32on GPU-only memory.agc_storage_gpu_only_writeback: a storage image in0x30memory is cleared on the GPU and written back, with and without a host import.docs/dev/debt/changes/fix-kernel-agc-gpu-only-protection.md: frame capture does not record GPU-only memory.Tested
Windows 11 Pro (build 26300), MinGW-w64 GCC 15.3.0, Release build with tests, AMD Radeon RX 6800.
Tests ran on
main77d2c4ae60and on this change, same machine and GPU. The set is 49 test programs: the four that hold the changed tests (guest_memory_tests,guest_sync_on_address_tests,agc_driver_graphics_tests,agc_driver_recorder_tests) and every other guest memory, host import, mirror, storage image, write tracking and BDA test program.main: 368 tests, 364 passed, 4 skipped.This change: 369 tests (the new
agc_storage_gpu_only_writebackincluded), 365 passed, 4 skipped. The same four skip on both sides:agc_host_import_sparse;agc_driver_copied_writer_label_order;agc_driver_copied_writer_label_order_drain;agc_driver_partially_committed_volume_page_samples.The same set again with
ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation(Vulkan SDK 1.4.363.0),VK_LOADER_DEBUG=layerandctest -V: the same results on both sides.Insert instance layer "VK_LAYER_KHRONOS_validation": 232 times onmain, 233 with this change (one more test).was not found but was requested by env var VK_INSTANCE_LAYERS.VUID-line.With this change's
HostReadable()andHostWritable()reduced to the CPU bits, which is whatmainchecks:agc_storage_gpu_only_writebackfails the way the title does:guest_memoryandagc_driver_graphicsfail on the new GPU-only cases.guest_sync_on_addresspasses either way, since the CPU result does not change.The run-joining case fails if adjacent ranges must match in the GPU write bit itself rather than in host writability.
public_headers(65 tests,GuestAllocations.hppchanged): passed.agc_shader_memory_testsdoes not link with this toolchain, onmainor with this change (ld: .rsrc merge failure: multiple non-default manifests), so its tests are not in the counts.tools/check_conventions.py --base origin/mainandtools/debt_fold.py --check: passed.tools/pr_overlap.py: two open pull requests change the same lines. Neither needs this change, nor this change them.joinedHeapRange. The only shared line is the joinedRange, where this change passesfirst.readableandfirst.gpuWritable; whichever lands second keeps both.mutation.Protectcall inRemapFixedIntoRegistered.76 pull requests that conflict with
mainshare files and could not be compared.Far Cry 6 (PPSA01870 01.000.013): with this change the splash screen and the main menu draw their text. Taken on an earlier
main(d31916ed37) with #21241; the after build also had #16053 reverted, which #20827 has since replaced onmain.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 this change, no new VUIDs🤖 Generated with Claude Code