fix(libc): stop write-protecting resident runs on Windows #9181
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9181"
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 Dripl1x on 2026-10-21T14:30:51Z.
What
On Windows, #7473 made clean resident runs of at least 256 KiB read-only so that a collect could skip
GetWriteWatch. The first guest store into such a run then faulted and was resumed on the guest thread. With live AVX state, the exception frame Windows builds for that fault overwrites the System V red zone belowrsp(#361). That is the fault #5596 removed for singly mapped direct memory. In Grand Theft Auto V (PPSA04264) these were 44 to 89MEM_PRIVATEresumed faults per run, up to 75 of them in the game's zlibinflate_fast, which keeps pointers in its red zone (#9136).collectResidentno longer arms the run. Resident memory is collected withGetWriteWatchonly, as before #7473; #7471's collection straight into the output buffer stays.armResident,resumeResidentWritesandRun::writeObservedare removed, andHandleWritehandles a fault on a resident view as before #7473.HostImportAccessstays. With no armed resident page it opens nothing, andView::hostImportsis counted but no longer read.docs/dev/debt/libc.mdentry for the resident clean proofs is removed.docs/dev/CONVENTIONS.mdnames the pages of shared views (shared memory, shared file mappings, and direct memory mapped at more than one guest address), not resident runs, as what the Windows write watch leaves read-only between collections.Tested
guest_memory:CheckLargeResidentWritesStopFaultingis nowCheckLargeResidentWritesDoNotFault. A 2 MiB resident mapping staysPAGE_READWRITEafter clean collects, and 16 write/collect rounds over every page raise no access violation. Withmain'sWindowsMappings.hppit fails atGuestMemory.cpp:1773, where the run is read-only after two clean collects.guest_memoryandguest_mmap_fixed_anonymous: 3/3.agc_driver_host_import_windows,agc_driver_host_import_at_map,agc_driver_host_import_teardown,agc_driver_host_import_failure_handlesandagc_host_import_retire: 3/3.agc_host_import_sparseskipped itself (exit 77).agc_resident_present,agc_host_import_unmap,agc_host_import_retirement,agc_host_import_second_mapping,agc_parked_import_unmap,agc_sparse_run_import,agc_sparse_run_import_copied,agc_driver_host_import_lifetimeandagc_driver_host_import_mutation_race: 1/1.d6e270ea9fonmain80565c594:MEM_MAPPEDMEM_PRIVATEmain7280a17ecwithAPS5_NO_DEFERRED_SETTLES=1(first post of #9136)APS5_NO_DEFERRED_SETTLES=1The
MEM_MAPPEDfaults left with default settings come from #6678's deferred settles, which #9159 covers.GetWriteWatchskip for clean resident runs. #7473'sWindowsMappings::Collectcounters were measured together with #7471, so its own share of them is unknown, and its single SuperTuxKart captures showed no FPS gain beyond run-to-run spread.WindowsMappingsis Windows-only, and the test change is inside#ifdef _WIN32.Checklist
main: one commit on80565c5942, merges cleanly with2c4b116da9; no other open PR implements the same functions (#9159 and #9098 change other parts ofWindowsMappings.hppand merge cleanly with this)NotImplemented_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)MEM_MAPPEDpart is #9159)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-21T19:18:22Z.
Independent Windows run of this PR (data only).
Environment: Windows 10 Pro 10.0.19045, Ryzen 7 5800X3D, WinLibs GCC 15.2.0 r7 (MinGW-w64 UCRT), Release, BUILD_TESTING=ON. Merge-tree of the PR head against
mainis clean. I built onlyguest_memory_tests;ctest -N -R guest_memorylists exactly one test.PR head tested:
d6e270ea9febfb05c56c3cca8e0e4a00bc4566c0.Results (3 runs each):
guest_memorypasses 3/3.core/libs/prx/libc/include/WindowsMappings.hppwith the version from the PR's merge base (80565c5942), then rebuilt. The test fails 3/3 (exit 0xc0000409). I restored the PR's files afterwards.Not run: other platforms, the other tests in the same family, the full repository CTest, and any title or console run.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T01:42:53Z.
Review: DISMISSED
I reviewed the Windows mapping change, the updated resident-write regression, the debt removal and the reported #9136 measurements. I found no code-level blocker in the submitted fix. The current hosted conventions, eligibility, relinker, register-context and write-watch checks pass; platform Windows/Linux product jobs were skipped, and I did not run a local Windows test.
One repository-rule item blocks approval: this head is based on
80565c59424190cd0f660f8097945443a0017c42, while currentmainis94fbb8cea80af91db62ab6ee7e4da23341675c40; current main is not an ancestor of the PR head. Please rebase/update to current main and rerun the relevant focused Windows tests/checks so the behavior is verified on the current base. The reported GTA V run remains useful evidence for the original commit, but does not replace that revalidation.