feat(libkernel): implement sceKernelMapNamedSystemFlexibleMemory #11190
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11190"
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 zaryabzip on 2026-10-25T21:14:39Z.
What
Implements
sceKernelMapNamedSystemFlexibleMemoryin libkernel, beside its twinsceKernelMapNamedFlexibleMemory. ps5-payload-dev/sdk'ssce_stubs/libkernel.candlibkernel_sys.cboth export it. The Windows import builder falls back from libkernel_sys to libkernel but never the other way, so the throwing libkernel_sys stub and its(void)declaration are removed and the full signature goes inprx/libkernel/include/Api.hpp.The only sources are two PS4 emulators: fpPS4 (export) and shadPS4. No PS5 measurement exists.
DoMapAnon). Flags other thanMAP_FIXED,MAP_NO_OVERWRITEandMAP_NO_COALESCEthrow, the same set fpPS4's mask0xffbfff6fallows. Flag 0x8000 throws, as insceKernelMapNamedFlexibleMemory(#10305 measured it rejected there on a PS5; the system variant was not probed). fpPS4's 0x880000000 default and both emulators' SDK 1.70MAP_FIXED-at-null gate are not imported, because the twin has neither.MAP_SYSTEMto a virtual manager that ignores it, so it does charge it there (mm_adr_virtual.pas L655-L660, ps4_map_mm.pas L429-L457). AMAP_FIXEDmap over game flexible memory releases that charge, as direct maps do.EINVALfirst, as in both emulators. A null name, or a name of 32 bytes or more, then throws before anything is mapped. shadPS4 returnsEFAULTorENAMETOOLONGbefore mapping. fpPS4 maps the range and leaves it unnamed. The twin skips a null name and truncates a long one.sceKernelVirtualQueryreports the mapping as flexible, as fpPS4 does (L1096). shadPS4 reports it as not flexible (memory.cpp L1209).Unverified on a PS5: the system budget and whether this map is charged to the game budget, the
sceKernelVirtualQueryflags of a system map, the null and over-long name results, flag 0x8000 and the other flag and protection bits for this function, default placement, andMAP_FIXEDwith a null address. All of this is recorded indocs/dev/debt/libkernel.md.Tested
Windows 11 Home 25H2 (i7-11800H, WinLibs MinGW-w64 GCC 15.2.0 UCRT r7, CMake 4.3.1, Ninja 1.13.2, Release,
BUILD_TESTING=ON) atb8ab1b1a5c, and Ubuntu 24.04.5 on WSL2 (GCC 13.3.0, CMake 3.28.3) with the PR merged intomain4e43321bd6as the Linux CI job does:ctest -R "guest_system_flexible_memory|guest_memory|guest_flexible_memory|guest_kernel_sys|windows_kernel_variant_sys":100% tests passed, 0 tests failed out of 31on Windows andout of 34on Linux. Those includeguest_system_flexible_memory,guest_memory, the fiveguest_flexible_memory_*tests, theguest_kernel_sys*tests and, on Windows only,windows_kernel_variant_sys.guest_system_flexible_memorywith--repeat until-fail:3: 3 of 3 on both hosts.mainwith only the new test file and itsadd_testblock, the test builds and then aborts withsceKernelMapNamedSystemFlexibleMemory is not exported by libkernelon both hosts (Windows exit 0xc0000409).libkernel/include/Api.hpporlibkernel_sys/include/Api.hppcompiled and linked.Earlier checks on an arm64 Mac:
x86_64-w64-mingw32-g++ -std=c++20 -fsyntax-only -Wall -Wextraon every changed.cppreports no diagnostics, the same as onmain.tools/check_conventions.pypasses.git merge-treeagainst #11005, #10889, #10898, #9882, #7105, #11042, #10305 and each of the 44 PRstools/pr_overlap.pycould not compare: no changed file has more conflict regions than the same merge withmain, where #10898, #7105 and others already conflict. None of their diffs mentionsceKernelMapNamedSystemFlexibleMemory.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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T21:27:09Z.
Review: COMMENTED
Reviewed exact head
bda99550443b634a492ebc6c839e8261c668a276. The new export delegates mapping validation and placement toDoMapAnon, releases the existing game-flexible accounting only after a successful map, and applies the name after mapping; the documented differences from the twin (including unverified system-map behavior) are called out rather than presented as console facts. I found no functional defect in the diff. Eligibility, conventions, intake, labels, and the progress report pass; the Linux, Windows, and relinker product jobs are skipped by the current PR gate. The PR reports focused tests on Windows and WSL, but I did not independently rerun them locally.