fix(libkernel): read, pread, AIO and APR write into guest memory as host writes #232
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/232"
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 MichonGoddijn231849 on 2026-10-01T17:26:01Z.
What
Replaces #182, following the review there: one read path for
read,pread, AIO and APR, chosen before the I/O, with no retry after an error.Shared guest pages are armed read-only for write tracking, and a page becomes writable again only in the access-violation handler. A file read is a kernel-mode write, which never reaches that handler:
ReadFilefails withERROR_NOACCESSand_readwithEINVAL. GTA V's Story Mode load stops withpread failed, errno=5.A file read into guest memory is now a host write into it:
GuestArenaBeginHostWriteruns before the I/O. It pins the shared views the destination covers, reopens any that are armed, and marks the pages written.Collectdoes not arm it again.GuestArenaEndHostWriteruns after the I/O. It unpins the views and marks the pages written again, so a collect that ran during the read still sees the read's data as new.GuestArena::HostWritewraps the pair around the I/O at the four call sites.Failures stay explicit:
readandpreadthrow, as for any failed read; AIO reportsSCE_KERNEL_ERROR_EFAULT; APR throws.Tested
Windows 11 Pro, AMD Ryzen 5 7600, NVIDIA GeForce RTX 5080 (driver 32.0.16.1074), 32 GB DDR5-5600, MinGW-w64 GCC 15.2.0.
guest_memory_testsgainsCheckReadsIntoSharedWriteTracking:sceKernelPread,sceKernelReadand an AIO read into armed shared direct memory land, and collect reports the pages as written;sceKernelMprotectto read-only, pread throws and AIO reports EFAULT.pread failed, errno=5, the same error as GTA V.ctest: all tests pass.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-02T13:42:04Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/tests/GuestMemory.cppL42