feat(libSceNKWebKit): implement WTF::OSAllocator commit, decommit and releaseDecommitted #23725

Merged
Callimann8 merged 1 commit from upstream-pr/23725 into main 2026-11-20 16:41:41 +00:00
Callimann8 commented 2026-11-19 14:35:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Callimann8 on 2026-11-19T14:35:12Z.


What

Implements the three remaining WTF::OSAllocator exports in libSceNKWebKit. They were throwing stubs in Export.cpp:

  • WTF::OSAllocator::commit(void*, size_t, bool, bool) (_ZN3WTF11OSAllocator6commitEPvmbb, NID NeYe5cZQXg8)
  • WTF::OSAllocator::decommit(void*, size_t) (_ZN3WTF11OSAllocator8decommitEPvm, NID CFjj7pKSrS4)
  • WTF::OSAllocator::releaseDecommitted(void*, size_t) (_ZN3WTF11OSAllocator18releaseDecommittedEPvm, NID UFKtijmAhkM)

They go next to the existing hintMemoryNotNeededSoon in src/WtfPlatformDefaults.cpp. The PS5 11.x OSAllocatorPlayStation.cpp calls memory_extra::vss::commit, decommit and release and does RELEASE_ASSERT(success) on each. Here they use the guest libkernel calls:

  • commit sets the range to read, or read and write when writable is true, with mprotect. executable is ignored, as that file asserts it is false.
  • decommit sets the range to no access with mprotect. The guest madvise does nothing, so the page contents stay.
  • releaseDecommitted unmaps the range with munmap.

When the call fails they call WTFCrash, where the console code has RELEASE_ASSERT. The debt fragment adds this to the existing "WTF PlayStation platform defaults" entry and drops the three names from the callable-exports table. The three int ...() placeholders are dropped from InventoryExports.hpp.

Tested

Linux (Ubuntu 24.04, GCC 13), no title. Extended nkwebkit_wtfplatformdefaults_tests (now linked with libkernel). It maps a guest PROT_NONE range, commits it writable and writes both ends, commits it read-only and reads them back, decommits it, commits and decommits half of it, decommits zero bytes, and checks with mincore that the range is mapped before releaseDecommitted and gone after it. Built it in the full CMake build and ran it with ctest: it passes. python3 tools/debt_fold.py --check passes.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • 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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5396906074 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23725). Originally posted by [Callimann8](https://github.com/Callimann8) on 2026-11-19T14:35:12Z. --- ### What Implements the three remaining `WTF::OSAllocator` exports in libSceNKWebKit. They were throwing stubs in `Export.cpp`: - `WTF::OSAllocator::commit(void*, size_t, bool, bool)` (`_ZN3WTF11OSAllocator6commitEPvmbb`, NID `NeYe5cZQXg8`) - `WTF::OSAllocator::decommit(void*, size_t)` (`_ZN3WTF11OSAllocator8decommitEPvm`, NID `CFjj7pKSrS4`) - `WTF::OSAllocator::releaseDecommitted(void*, size_t)` (`_ZN3WTF11OSAllocator18releaseDecommittedEPvm`, NID `UFKtijmAhkM`) They go next to the existing `hintMemoryNotNeededSoon` in `src/WtfPlatformDefaults.cpp`. The PS5 11.x [OSAllocatorPlayStation.cpp](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/WTF/wtf/playstation/OSAllocatorPlayStation.cpp#L100-L122) calls `memory_extra::vss::commit`, `decommit` and `release` and does `RELEASE_ASSERT(success)` on each. Here they use the guest libkernel calls: - `commit` sets the range to read, or read and write when `writable` is true, with `mprotect`. `executable` is ignored, as that file asserts it is false. - `decommit` sets the range to no access with `mprotect`. The guest `madvise` does nothing, so the page contents stay. - `releaseDecommitted` unmaps the range with `munmap`. When the call fails they call `WTFCrash`, where the console code has `RELEASE_ASSERT`. The debt fragment adds this to the existing "WTF PlayStation platform defaults" entry and drops the three names from the callable-exports table. The three `int ...()` placeholders are dropped from `InventoryExports.hpp`. ### Tested Linux (Ubuntu 24.04, GCC 13), no title. Extended `nkwebkit_wtfplatformdefaults_tests` (now linked with libkernel). It maps a guest `PROT_NONE` range, commits it writable and writes both ends, commits it read-only and reads them back, decommits it, commits and decommits half of it, decommits zero bytes, and checks with `mincore` that the range is mapped before `releaseDecommitted` and gone after it. Built it in the full CMake build and ran it with ctest: it passes. `python3 tools/debt_fold.py --check` passes. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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) and the licence notice of code adapted from upstream (see AGENTS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [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] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
PrivacyOnion commented 2026-11-19 14:36:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-19T14:36:34Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against ac0a9d0f81:

  • Conventions: tools/check_conventions.py passed.
  • Build: nkwebkit_wtfplatformdefaults_tests built cleanly.
  • CTest (nkwebkit_wtfplatformdefaults):
    1/1 Test #4747: nkwebkit_wtfplatformdefaults .....   Passed    0.01 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceNKWebKit/Export.cpp, core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp, core/libs/prx/libSceNKWebKit/include/WtfPlatformDefaultsExports.hpp, core/libs/prx/libSceNKWebKit/src/WtfPlatformDefaults.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified libSceNKWebKit/src/WtfPlatformDefaults.cpp: WTF::OSAllocator::commit, decommit, and releaseDecommitted correctly forward to mprotect_nid_postfix and munmap_nid_postfix and trigger WTFCrash() on non-zero return codes
    • Verified GuestProtRead (1), GuestProtWrite (2), and GuestProtNone (0) match FreeBSD / PS5 libkernel protection flag definitions
    • Verified LP64 / LLP64 portability and type signatures match WtfPlatformDefaultsExports.hpp (void* address, std::size_t bytes, bool writable, bool executable)
    • Verified docs/dev/debt/changes/feat-nkwebkit-osallocator-commit-decommit.md accurately documents the technical debt changes and removals from callable exports
    • Verified tests/WtfPlatformDefaults.cpp properly exercises commit (read-write and read-only), decommit, zero-sized decommit, and releaseDecommitted with mincore verification

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5977020901 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23725#pullrequestreview-5977020901). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-19T14:36:34Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `ac0a9d0f81`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `nkwebkit_wtfplatformdefaults_tests` built cleanly. - **CTest** (`nkwebkit_wtfplatformdefaults`): ``` 1/1 Test #4747: nkwebkit_wtfplatformdefaults ..... Passed 0.01 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceNKWebKit/Export.cpp`, `core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp`, `core/libs/prx/libSceNKWebKit/include/WtfPlatformDefaultsExports.hpp`, `core/libs/prx/libSceNKWebKit/src/WtfPlatformDefaults.cpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Verified libSceNKWebKit/src/WtfPlatformDefaults.cpp: WTF::OSAllocator::commit, decommit, and releaseDecommitted correctly forward to mprotect_nid_postfix and munmap_nid_postfix and trigger WTFCrash() on non-zero return codes - Verified GuestProtRead (1), GuestProtWrite (2), and GuestProtNone (0) match FreeBSD / PS5 libkernel protection flag definitions - Verified LP64 / LLP64 portability and type signatures match WtfPlatformDefaultsExports.hpp (void* address, std::size_t bytes, bool writable, bool executable) - Verified docs/dev/debt/changes/feat-nkwebkit-osallocator-commit-decommit.md accurately documents the technical debt changes and removals from callable exports - Verified tests/WtfPlatformDefaults.cpp properly exercises commit (read-write and read-only), decommit, zero-sized decommit, and releaseDecommitted with mincore verification Looks Good To Me
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!23725
No description provided.