Repository navigation
Conversation
The page-state cache records the access of every page it queries in the guest arena range, and relies on libc reporting mapping and protection changes to forget them. Host-owned regions inside that range (memory in use when the arena was reserved) change without libc knowing, so their cached state went stale: a page committed after a query stayed inaccessible, and a page decommitted or made no-access stayed readable. On a machine where the test's VirtualAlloc landed in such a region, agc_driver_image_table_cache found its newly committed records still Unmapped (boykopovar#24186). Pages that overlap a host region are no longer recorded in the arena span, and the image span is looked up before the arena span so the main image keeps its cache when it lies inside the arena range. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The arena host region query is declared only on Windows, so the unconditional call broke the Linux build.
|
No actionable comments were generated in the recent review. Walkthrough
Change: Bug fix · Severity of issue fixed: Low Merge Risk:
|
What
agc_driver_image_table_cachefails on some Windows machines with "a result without Unmapped entries is not cacheable" (boykopovar#24186). The cause is the page-state cache inGuestMemory.cpp, not the compiler.The cache records the access of every page it queries inside the guest arena range, and relies on libc to report mapping and protection changes so it can forget them. Host-owned regions inside that range (memory already in use when the arena was reserved at load) change without libc knowing, so their cached state goes stale. A page committed after a query stays inaccessible, and a page that is decommitted or made no-access stays readable.
In the report, the test's
VirtualAlloc(nullptr, ...)returned0x340000, which is a host region of the arena (diagnostics). The first capture read the committed first page, which gave its cache chunk an entry, and recorded the reserved second page as inaccessible. The test then committed that page withVirtualAlloc, and the second capture still found it Unmapped. Where the test lands above the arena (0xfc00000000here), the pages are not cached and the test passes, which is why it reproduces on some machines and not others.PageStates::recordno longer stores pages that overlap a host region in the arena span (GuestArenaHostRegionOverlaps_nid_postfix). Those pages are queried every time.PageStates::spanOflooks up the image span before the arena span. The main image is a host region when it loads inside the arena range (the test executables' preferred base is0x140000000), and it keeps its cache through the image span, which registry mutations invalidate as before.agc_page_state_host_region(new mode ofagc_page_state_tests): takes two pages of a process-heap block, which is a host region of the arena. It decommits the second, reads the first, checks that the second is inaccessible, commits it again and checks that it is accessible. Then it makes the first no-access and checks that it is inaccessible. It returns 77 (skipped) when the process heap is not in a host region.Tested
Windows 11 Pro 10.0.26300, AMD Ryzen 7 9800X3D, Release, Ninja.
agc_page_state_host_regionfails 3 of 3 runs with "a host-region page committed again kept its inaccessible state", the failure in agc_driver_image_table_cache fails on Windows (GCC 16.2.0): "a result without Unmapped entries is not cacheable" boykopovar/AnyPS5#24186. With the stale direction checked on its own, it fails with "a host-region page made no-access kept its accessible state". With the change it passes 3 of 3, with WinLibs GCC 15.2.0 r7 and with GCC 16.2.0 r2 (the compiler in agc_driver_image_table_cache fails on Windows (GCC 16.2.0): "a result without Unmapped entries is not cacheable" boykopovar/AnyPS5#24186).agc_driver_image_table_cacheand the otheragc_page_state*tests pass with both compilers. I could not get the test's own reservation into a host region on this machine, because the arena already holds the low range here. The new test reproduces the same sequence throughGuestMemory::Accessible.ctest -j16(GCC 15.2): no new failures against the last run onmain. The 25 failures are the ones this machine always has (long paths,subst, missing git metadata, and AGC GPU issues with open reports).tools/check_conventions.py --base origin/mainpasses.tools/pr_overlap.py --branch: perf(libSceAgcDriver): invalidate draw input snapshots by range boykopovar/AnyPS5#16879 and perf(agc): scope an image table's write stamp to mapping changes of its own range boykopovar/AnyPS5#18390 add a test to the sameset_tests_propertiesline inagc_page_state_tests.cmake, a one-line merge. perf(agc): run queue-0 REWIND segments from a validated packet table and hand draw lookup and vertex decode to the finishers under APS5_LEAN_FRONT boykopovar/AnyPS5#22434 and perf(agc): commit draws from records resolved on the finisher, with the finisher's job slimmed, under APS5_DIRECT_DRAWS boykopovar/AnyPS5#22647 callGuestArenaHostRegionOverlaps_nid_postfixelsewhere inGuestMemory.cpp, and do not touch these lines.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)🤖 Generated with Claude Code
Summary by CodeRabbit