fix(libkernel): back direct memory with a memfd on Linux #203
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/203"
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 oneandonlydean on 2026-10-01T03:12:03Z.
What
Follows
abb9c852.On Linux,
PhysicalBackingcreates the shared direct memory backing withstd::tmpfile(), which glibc places in/tmp. A title's direct memory therefore counts against that filesystem's size: with/tmpon a tmpfs (half of RAM by default) a title with several GiB of direct memory can fill it, and touching a backing page past that raises SIGBUS. With/tmpon disk it costs disk space instead.memfd_creategives the same shared,ftruncate-sized,MAP_SHARED-mappable memory without a filesystem or its size limit. The handle is now a file descriptor (MFD_CLOEXEC) instead of aFILE*; Windows is unchanged.In PPSA21564 the 4.5 GiB backing file in
/tmpfilled it, and the title died with SIGBUS reading a direct memory page inGuestBufferMemory::AcquireRegistered.Tested
CheckDirectMemoryBackingNeedsNoFilesysteminguest_memory_testsmaps direct memory and reads its backing from/proc/self/maps. Without the fix it fails and printsdirect memory backing: /tmp/#889275 (deleted); with it the backing is/memfd:direct memory (deleted)and the test passes. The existing direct memory tests (aliases, protections, release and reallocation, write watch) pass unchanged./tmp.ctest --test-dir build: 79/79 pass on current main with this branch.Checklist
main; no other open PR implements the same functions (#198 also touchesDirectMemory.cpp, inDoReserveVirtual; the two merge cleanly)NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository