feat(libkernel): implement sceKernelReleaseFlexibleMemory #952

Merged
CnRJay merged 3 commits from upstream-pr/952 into main 2026-10-06 21:20:08 +00:00
CnRJay commented 2026-10-06 20:13:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-10-06T20:13:33Z.


What

Implements sceKernelReleaseFlexibleMemory(void* addr, size_t len) (teiItL2boFw), which threw before.

  • Forwards to sceKernelMunmap, which unmaps the range and returns its pages to the flexible memory budget. fpPS4 (ps4_sceKernelReleaseFlexibleMemory in kernel/ps4_map_mm.pas) and prosper (hle_kernel_mem.cpp) both bind it to munmap; shadPS4 and KytyPS5 have no body.
  • Whether the console keeps the virtual range reserved after the release is unverified; noted in TechnicalDebt.

Tested

Windows 11 (winlibs GCC): new CheckReleaseFlexibleMemory in guest_memory maps 64 KiB of flexible memory, checks the available size drops by 64 KiB and returns after the release, then remaps the same address with the fixed+no-overwrite flags (0x90) to show the range is free and its pages are zeroed. Passes; it fails on main because the stub throws. tools/progress.py: libraries +1. No title run.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4764123504 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/952). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-10-06T20:13:33Z. --- ### What Implements `sceKernelReleaseFlexibleMemory(void* addr, size_t len)` (`teiItL2boFw`), which threw before. - Forwards to `sceKernelMunmap`, which unmaps the range and returns its pages to the flexible memory budget. fpPS4 (`ps4_sceKernelReleaseFlexibleMemory` in `kernel/ps4_map_mm.pas`) and prosper (`hle_kernel_mem.cpp`) both bind it to munmap; shadPS4 and KytyPS5 have no body. - Whether the console keeps the virtual range reserved after the release is unverified; noted in TechnicalDebt. ### Tested Windows 11 (winlibs GCC): new `CheckReleaseFlexibleMemory` in `guest_memory` maps 64 KiB of flexible memory, checks the available size drops by 64 KiB and returns after the release, then remaps the same address with the fixed+no-overwrite flags (0x90) to show the range is free and its pages are zeroed. Passes; it fails on `main` because the stub throws. `tools/progress.py`: libraries +1. No title run. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-06 20:13:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-06T20:13:57Z.


Progress report (5b35909 → 83e3ef8)

📈 System libraries: 87.03% (+0.03%, +1 implemented functions)

✅ 1 implemented
Library Name
libkernel sceKernelReleaseFlexibleMemory
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6024608937 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/952#issuecomment-6024608937). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-06T20:13:57Z. --- <!-- progress-report --> ### Progress report (5b35909 → 83e3ef8) 📈 **System libraries**: 87.03% (+0.03%, +1 implemented functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libkernel | `sceKernelReleaseFlexibleMemory` | </details>
github-actions[bot] commented 2026-10-06 20:24:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-06T20:24:14Z.


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.

Pull request Conflicting files (lines on main) Same exports Same new files
#900 docs/dev/TechnicalDebt.md L69
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6024776433 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/952#issuecomment-6024776433). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-06T20:24:14Z. --- <!-- pr-overlap --> 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**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #900 | `docs/dev/TechnicalDebt.md` [L69](https://github.com/boykopovar/AnyPS5/blob/943be291a6bf3290875b84c8674a231ecd2a5546/docs/dev/TechnicalDebt.md#L69) | | |
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!952
No description provided.