fix(libkernel): account for fixed flexible memory replacements #6491
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6491"
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 Ondra97 on 2026-10-15T17:23:40Z.
What
sceKernelMapFlexibleMemoryrejects a validMAP_FIXEDreplacement when the flexible-memory budget is full, because it charges the requested range before crediting the flexible pages it replaces.The budget check now subtracts the exact overlap with existing flexible mappings. It grants no credit for holes or
MAP_NOOVERWRITE, and failed mappings retain their charge and data. The successful-map range splitting already inmainis preserved.The regression checks interior, prefix, multi-range and hole replacements, neighboring data, partial releases, full-budget interior and whole-range replacements, and rejection of growth beyond the budget. The rebase preserves the direct/reserve/POSIX accounting from #7112.
Tested
Base:
cb1d6e5bd642c496d01ac583c614c82a8c654a41. Head:393506c161a5eb8b1855e6fa77d73c3b56c8a395.BUILD_TESTING=ON.BUILD_TESTING=ON. Graphics: not exercised. All 16,142 source/dependency files were verified against the Git blobs, with zero missing files or mismatches.Windows (native host) negative control: with the final regression and unmodified base production code,
guest_flexible_memory_limitedfails at the full-budget interior-page replacement assertion. The preceding range-splitting checks pass. The final production source was restored and its SHA-256 verified before the final build.Windows (native host), one run per variant with the same final regression and a 16 MiB configured budget:
ENOMEMThe selected tests cover all five flexible-memory modes, guest mapping and fixed anonymous mapping, protection, memory-pool statistics, allocator failure handling, stacks, JIT/shared memory, page-table statistics,
mlock, and patched libraries. Windows additionally runs write-watch; Linux (VirtualBox) additionally runs mapping lifetime. Five integration checks cover fiber/thread frame chains, user contexts (including return/exit), and Linux GNU segment preservation after the latest main updates.Linux (VirtualBox) uses
--parallel 2for the build and the same CTest selection. Conventions, whitespace, main-sync and test-registration audits passed; all 985 Windows and 997 Linux (VirtualBox) test executables have CTest registrations. These audit counts are not runtime test counts.Linux graphics/Vulkan tests: NOT RUN — intentionally excluded from VirtualBox validation. Native/bare-metal Linux was not tested. Native Linux GPU validation: not tested. No console, retail/homebrew title or performance result is claimed. Hosted full platform builds require collaborator dispatch.
The shared-file review found no second implementation of this remaining accounting fix. #6515 covers direct replacements; #6044 moves the original budget fixture unchanged, so these new assertions must be preserved at its destination if it merges first. The macOS query/locking changes in #5021, #6222, #7201 and #7332 do not implement this budget credit.
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 github-actions[bot] on 2026-10-15T17:29:28Z.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/libs/prx/libkernel/DirectMemory/Export.cppcore/libs/tests/GuestFlexibleMemoryBudget.cppcore/libs/prx/libkernel/DirectMemory/Export.cppcore/libs/prx/libkernel/DirectMemory/Export.cppcore/libs/prx/libkernel/DirectMemory/Export.cppImported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-15T18:09:31Z.
Review: COMMENTED
Linux run, since the PR has no Linux runtime result.
Ubuntu 26.04, i7-8700, gcc 15.2, Release,
BUILD_TESTING=ON, full build. Head8752bd691applied onmain03c4cb5e7.GuestFlexibleMemoryBudget.cpponmain's source):guest_flexible_memory_limitedfails at the first interior-replacement check (line 80) withavailable=15564800 expected=15581184. That is the same 16 KiB extra charge as in your Windows table.guest_memory*anddirect_memory*(8 tests) 10 times in a row.-E "^agc|gpu|vulkan|video_out",-j8): same result asmain. Onlyfile_writer_binaryandfile_writer_textfail, onmaintoo (this host's coreutils rejects the command they run).Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.