fix(libkernel): report 12 GiB of direct memory, as a PS5 does #10809
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10809"
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 frankea on 2026-10-25T02:14:36Z.
What
sceKernelGetDirectMemorySizereturnsDIRECT_MEMORY_SIZE, which has been 13824 MiB (13.5 GiB,0x360000000) since the first direct-memory commit (6ecfc3555). On a PS5 it returns0x300000000, 12 GiB.DIRECT_MEMORY_SIZEis now 12288 MiB, so the size a title reads, the physical rangesceKernelAllocateDirectMemoryandsceKernelAllocateMainDirectMemoryallocate from, the range checks of the release calls and the host pool behind them all shrink by 1.5 GiB.Titles print this value: Demon's Souls logs
Total Direct Memory: 13824.00 MiB - 0x0000000360000000 Bytesin #7203; on a PS5 that line would read 12288 MiB. Titles also size their pools from it: in @thuanquang's Persona 5 Royal (PPSA05110) run in the comments, the title maps all but 31 MiB of whatever size it reads, so with this PR it maps 12257 MiB instead of 13793 MiB (peak private bytes 19.90 instead of 21.79 GiB on that route) and still reaches New Game.Measurement: PS5 on firmware 13.40, 2026-10-24, inside Gran Turismo 7 (PPSA01317) shortly after it started. A payload attached to the game with ptrace and called the game's own
libkernelexportsceKernelGetDirectMemorySize()twice: both calls returned0x300000000. In the same sessionsceKernelIsTrinityMode()returned 0 andsceKernelGetAvailableCpumask()returned0x1fff, the values AnyPS5 already returns.Not measured: other titles, a PS5 Pro, and how much of the 12 GiB a title can allocate at start-up (
sceKernelAvailableDirectMemorySizeon the console).Also changed: the
13824ll << 20search end inGuestAprRead.cpp(the pool clamps it, so the test passed either way), the 13824 MiB inUSAGE.md's Windows commit-limit note, and the 13.5 GiB in thesceKernelAvailableFlexibleMemorySizedebt entry.guest_memorynow checks that the size is0x300000000.Tested
Windows 11 (build 26200), MinGW GCC (WinLibs 15.2) Release build with
BUILD_TESTING=ON, each test run three times (ctest --repeat until-fail:3).guest_memory_tests,guest_apr_read_tests,guest_ampr_tests,guest_flexible_memory_budget_tests,MemoryPoolTest):b5c6010f8,ad9a0c8efwithmain97d33464cmerged in): 16/16.main97d33464cwith only this PR'sGuestMemory.cpp:guest_memorystops on the new check (Guest memory check failed at .../GuestMemory.cpp:709;mainreturns0x360000000); the other 15 pass.main97d33464c: 16/16.b5c6010f8merged ontomain9c435c281:guest_memory,guest_protection_reportand theguest_apr_read_*tests pass 3 of 3 (7 tests match there, 9 on Windows), and withDirectMemory.hppfrommainguest_memoryfails on both hosts.tools/check_conventions.py --base origin/mainreports no errors; its one warning is the length of thesceKernelAvailableFlexibleMemorySizedebt entry, which was already over the limit (this PR changes one number in it).Overlap
#5021 (yabanana) rewrites the same
sceKernelAvailableFlexibleMemorySizedebt line (it adds the macOS accounting), and #11130 (imellag) inserts its mimalloc lines right before theUSAGE.mdline this PR changes; each conflicts with this PR on that one line. This PR goes first: it changes one number in each line, so the other PR keeps that number when it rebases. #9882 and #10025 change other parts ofDirectMemory.hppand the libkernel debt file and merge with this branch without conflicts. No open PR changesDIRECT_MEMORY_SIZE.Checklist
main; no other open PR implements the same functions.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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T02:21:07Z.
Review: COMMENTED
I reviewed the full diff and the consumers of
DIRECT_MEMORY_SIZE. The 12 GiB value is supported by the author's reported measurement ofsceKernelGetDirectMemorySize()on PS5 firmware 13.40, and the constant consistently governs the reported size, allocation pool, and bounds checks. The focused regression asserts0x300000000; I found no overlapping open PR for this constant.git diff --checkpasses and hosted eligibility, intake, conventions, labels, and report checks pass. Product build/test jobs are skipped by the path filters. I attempted a local full-build configure, but it stops because3rdparty/SDL2is uninitialized in this checkout (CMakeLists.txtis missing); I did not modify submodules or claim a local test run.I did not find a blocking issue in this revision.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T02:59:02Z.
Review: CHANGES_REQUESTED
I found one checklist omission during the required manual overlap review. PR #5021 is still open and also edits the
sceKernelAvailableFlexibleMemorySizedebt bullet indocs/dev/debt/libkernel.md. Both PRs replace the same physical Markdown line: #5021 adds the macOS accounting clause and this PR changes its direct-memory-size statement from 13.5 GiB to 12 GiB. Please coordinate with #5021 on merge order and record it asDepends on: #Nin both PR checklists (ornoneonly if the maintainers confirm the overlap rule does not apply here). I have not modified either branch. The direct-memory implementation and the author-reported focused test results otherwise remain consistent with my prior review.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T06:08:23Z.
Review: COMMENTED
A base refresh is now also needed: this head contains one commit over a base 70 commits behind current
main(61c55ed466).git merge-tree --write-treecurrently applies it tomainwithout conflicts, so this is not a claim of a present main-branch conflict. Please rebase before final review as required by the current-main checklist and rerun the focused direct-memory tests against the rebased tree; the reported Windows runs usedmain941ace5f3. The same-line overlap with #5021 from my existing change request remains unresolved, so please coordinate and record the agreed order in the affected checklist(s) as well.