feat(libkernel): export sceKernelAllocateDirectMemoryForApp and sceKernelProtectDirectMemoryForPID #12826

Merged
Nixitov merged 6 commits from upstream-pr/12826 into main 2026-11-02 16:14:05 +00:00
Nixitov commented 2026-10-29 11:42:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Nixitov on 2026-10-29T11:42:44Z.


What

Export sceKernelAllocateDirectMemoryForApp and sceKernelProtectDirectMemoryForPID from libkernel, which is where titles import them from. Both were declared only in libkernel_sys, as throwing discovery stubs, so the loader stopped before the title started.

Sources. PS5_MihawkOS (mihawk-99/PS5_MihawkOS, PPSA99170) declares both in native/pw_dmem_share.h, at commit 8a9c117:

extern int sceKernelAllocateDirectMemoryForApp(int64_t, int64_t, size_t, size_t, int, int64_t *);
extern int sceKernelProtectDirectMemoryForPID(int64_t, size_t, int, int);

Its docs/PLAN.md, section "Direct memory shared between processes", reports reading libkernel_sys.sprx 10.01: the protect call is one ioctl 0xc018800f on the dmem device carrying {offset, length, pid, prot}, the pid variant refuses pid 0, and a console run (dmem-share-2026-10-12-05; with the title, dmem-title-share-2026-10-12-01) had sceKernelProtectDirectMemoryForPID(offset, 64 MiB, 0x33, pidB) return 0, after which a second process could map the range.

  • fNoviuIwykc is sceKernelAllocateDirectMemoryForApp; the header gives the six arguments of sceKernelAllocateDirectMemory, and PLAN.md shows the same allocation reached through both calls, so it forwards to sceKernelAllocateDirectMemory and shares that validation and allocator. The forward is assumed from the shared signature: ForApp's own argument checks and error codes are not measured, and a guest has one direct memory range, so an app-specific range restriction has nothing separate to observe.
  • cBp0Ad-24LA is sceKernelProtectDirectMemoryForPID; it keeps the known prototype (int64_t offset, size_t len, int prot, int pid) and throws: the three sources are a third-party repository, a static reading of one firmware and a payload-only measurement, the error for pid 0 or a pid that does not exist is unknown, and a guest runs as the only process, so there is no second process to grant a range to.

Both entries are in docs/dev/debt/libkernel.md.

The copies in libkernel_sys are removed because the same export may live in one library only; the loader finds both NIDs in libkernel.

With the change the title loads with no unresolved import and reaches its own /app0/assets/ lookup.

Tested

Windows 11, MinGW GCC 15.2.0, current main ba5b5330b, with PS5_MihawkOS v4.0.0-alpha-4 (PPSA99170, mihawk-99/PS5_MihawkOS). On main the title stops with:

FAIL: unresolved ELF import fNoviuIwykc from libkernel.prx
FAIL: unresolved ELF import cBp0Ad-24LA from libkernel.prx

With this PR the relinked title loads with 0 unresolved imports and reaches its own /app0/assets/ lookup. New test guest_direct_memory_for_app (core/libs/tests/GuestDirectMemoryForApp.cpp) covers the EINVAL cases (zero and unaligned length, null output, end before start) and an aligned allocation inside the direct memory range that is released afterwards; ctest --test-dir build -R guest_direct_memory_for_app passes, and python tools/check_conventions.py --base origin/main reports all checks passed.

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 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: PPSA99170
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5067346347 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12826). Originally posted by [Nixitov](https://github.com/Nixitov) on 2026-10-29T11:42:44Z. --- ### What Export `sceKernelAllocateDirectMemoryForApp` and `sceKernelProtectDirectMemoryForPID` from `libkernel`, which is where titles import them from. Both were declared only in `libkernel_sys`, as throwing discovery stubs, so the loader stopped before the title started. **Sources.** PS5_MihawkOS (`mihawk-99/PS5_MihawkOS`, `PPSA99170`) declares both in [`native/pw_dmem_share.h`](https://github.com/mihawk-99/PS5_MihawkOS/blob/8a9c117cb265d0f54ead53b0aa37cdc8c0dc9c91/native/pw_dmem_share.h#L4-L18), at commit `8a9c117`: ```c extern int sceKernelAllocateDirectMemoryForApp(int64_t, int64_t, size_t, size_t, int, int64_t *); extern int sceKernelProtectDirectMemoryForPID(int64_t, size_t, int, int); ``` Its [`docs/PLAN.md`](https://github.com/mihawk-99/PS5_MihawkOS/blob/8a9c117cb265d0f54ead53b0aa37cdc8c0dc9c91/docs/PLAN.md), section "Direct memory shared between processes", reports reading `libkernel_sys.sprx` 10.01: the protect call is one ioctl `0xc018800f` on the dmem device carrying `{offset, length, pid, prot}`, the pid variant refuses pid 0, and a console run (`dmem-share-2026-10-12-05`; with the title, `dmem-title-share-2026-10-12-01`) had `sceKernelProtectDirectMemoryForPID(offset, 64 MiB, 0x33, pidB)` return 0, after which a second process could map the range. - `fNoviuIwykc` is `sceKernelAllocateDirectMemoryForApp`; the header gives the six arguments of `sceKernelAllocateDirectMemory`, and `PLAN.md` shows the same allocation reached through both calls, so it forwards to `sceKernelAllocateDirectMemory` and shares that validation and allocator. The forward is assumed from the shared signature: `ForApp`'s own argument checks and error codes are not measured, and a guest has one direct memory range, so an app-specific range restriction has nothing separate to observe. - `cBp0Ad-24LA` is `sceKernelProtectDirectMemoryForPID`; it keeps the known prototype `(int64_t offset, size_t len, int prot, int pid)` and throws: the three sources are a third-party repository, a static reading of one firmware and a payload-only measurement, the error for pid 0 or a pid that does not exist is unknown, and a guest runs as the only process, so there is no second process to grant a range to. Both entries are in `docs/dev/debt/libkernel.md`. The copies in `libkernel_sys` are removed because the same export may live in one library only; the loader finds both NIDs in `libkernel`. With the change the title loads with no unresolved import and reaches its own `/app0/assets/` lookup. ### Tested Windows 11, MinGW GCC 15.2.0, current `main` `ba5b5330b`, with PS5_MihawkOS v4.0.0-alpha-4 (`PPSA99170`, `mihawk-99/PS5_MihawkOS`). On `main` the title stops with: ``` FAIL: unresolved ELF import fNoviuIwykc from libkernel.prx FAIL: unresolved ELF import cBp0Ad-24LA from libkernel.prx ``` With this PR the relinked title loads with 0 unresolved imports and reaches its own `/app0/assets/` lookup. New test `guest_direct_memory_for_app` (`core/libs/tests/GuestDirectMemoryForApp.cpp`) covers the `EINVAL` cases (zero and unaligned length, null output, end before start) and an aligned allocation inside the direct memory range that is released afterwards; `ctest --test-dir build -R guest_direct_memory_for_app` passes, and `python tools/check_conventions.py --base origin/main` reports all checks passed. ### 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 - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's technical 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: PPSA99170 - [x] GPUs tested: n/a - [x] AI-assisted: yes
XairRrR commented 2026-10-29 11:52:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-10-29T11:52:23Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

The change merges cleanly, builds, exports both NIDs from libkernel and its new test passes. It needs one documentation correction: the debt entry says no prototype or measurement exists for sceKernelProtectDirectMemoryForPID, but the public source of the title this PR unblocks has both. Neither export's signature has a cited source.

What I ran

Head bf1ae463892c7e3bde4bc81c65efafb95875f84b, merged with --no-ff onto main ba5b5330b37724bca4b99f30faab504653635a04 in a clean worktree. Arch Linux 7.2.11-zen, GCC 16.2.1, Intel Core i9-14900KF, NVIDIA GeForce RTX 4070 Ti SUPER (driver 615.78.08); Release, Ninja, BUILD_TESTING=ON.

git fetch origin main pull/12826/head:refs/review/12826
git checkout --detach origin/main
git merge --no-ff --no-edit refs/review/12826
git diff --check origin/main...refs/review/12826
python3 tools/check_conventions.py --base origin/main
cmake --build build -j10 --target libs guest_direct_memory_for_app_tests
ctest --test-dir build -j4 --output-on-failure -R "^(guest_direct_memory_for_app|guest_memory|guest_kernel_sys|guest_kernel_sys_constants|guest_memory_pool_stats|guest_memory_lifetime)$"
ctest --test-dir build -V -R "^guest_direct_memory_for_app$"
grep -c -a fNoviuIwykc build/core/libs/libs/libkernel.prx build/core/libs/libs/libkernel_sys.prx
grep -c -a cBp0Ad-24LA build/core/libs/libs/libkernel.prx build/core/libs/libs/libkernel_sys.prx
# negative control
git checkout origin/main -- core/libs/prx/libkernel/DirectMemory/Export.cpp core/libs/prx/libkernel/Unimplemented.cpp \
  core/libs/prx/libkernel/include/Api.hpp core/libs/prx/libkernel_sys/Export.Discovery.cpp core/libs/prx/libkernel_sys/include/Api.hpp
cmake --build build -j10 --target guest_direct_memory_for_app_tests

Results

Check Result
Merge onto main Clean
git diff --check No output
check_conventions.py All conventions checks passed
Build (libs, new test) OK; no new warnings in the changed files
guest_direct_memory_for_app Passed, 0.00 s
guest_memory, guest_memory_lifetime, guest_memory_pool_stats, guest_kernel_sys, guest_kernel_sys_constants Passed
NIDs in the built modules fNoviuIwykc and cBp0Ad-24LA each appear once in libkernel.prx and not in libkernel_sys.prx
Overlapping open PRs (search for both names) None besides this one
ctest
3/6 Test #2373: guest_direct_memory_for_app ......   Passed    0.00 sec
4/6 Test #2381: guest_memory_lifetime ............   Passed    0.01 sec
5/6 Test  #399: guest_kernel_sys .................   Passed    0.02 sec
6/6 Test #2584: guest_memory .....................   Passed    0.59 sec
100% tests passed out of 6

2373: allocated for-app phys=0 len=65536

Negative control

I restored the five production files from main (both Api.hpp, Export.cpp, Unimplemented.cpp, Export.Discovery.cpp) and kept the test and its CMake entry. The test no longer compiles, so it does not pass without the change. This is the compiler message, translated from the host's French locale:

GuestDirectMemoryForApp.cpp:24:13: error: 'sceKernelAllocateDirectMemoryForApp' was not declared in this scope; did you mean 'sceKernelAllocateDirectMemory'?

After that I restored the merged files, rebuilt, and the test passed again.

Findings

Blocking

  1. The debt entry says something that a public source contradicts. docs/dev/debt/libkernel.md:327 says that "no prototype, argument order or measured result was found" for sceKernelProtectDirectMemoryForPID. The public repository of the title this PR unblocks, PS5_MihawkOS, has all three:

    • native/pw_dmem_share.h declares int sceKernelProtectDirectMemoryForPID(int64_t offset, size_t length, int prot, int pid) and int sceKernelAllocateDirectMemoryForApp(int64_t, int64_t, size_t, size_t, int, int64_t*).
    • docs/PLAN.md, "Direct memory shared between processes", reports reading libkernel_sys.sprx 10.01. It says the call is one ioctl 0xc018800f with {offset, length, pid, prot} and that the PID variant refuses pid 0. It also records a console run in which sceKernelProtectDirectMemoryForPID(offset, 64 MiB, 0x33, pidB) returned 0 and a second process could then map the range.

    The reverse-engineering guide ranks a console measurement and the library's own code as the strongest sources. CONTRIBUTING.md:78 asks debt entries to record known signatures. A debt entry saying no such source exists will send the next contributor in the wrong direction.

    Suggested fix: rewrite the entry to give the known signature with these sources and their limits (static reading of firmware 10.01, one console run, a third-party repository). Then say what still throws and why. For example, it is unknown which error is returned for pid 0 or for a pid that does not exist, and a single guest process has no second process to grant. Throwing is still reasonable with that much known.

  2. Neither export cites the source of its signature or behaviour. CONTRIBUTING.md:9 and the guide's Citing it section require the PR and the debt entry to say where a signature and behaviour come from. The PR states that sceKernelAllocateDirectMemoryForApp has the six arguments of sceKernelAllocateDirectMemory and the same validation (core/libs/prx/libkernel/DirectMemory/Export.cpp:239-241), but gives no source. The header above supports the signature, and the PLAN.md section shows the compositor using both calls for the same allocation. That supports forwarding, but it is not a measurement of ForApp's own validation and error codes. Suggested fix: cite the source in the PR body. Add a debt entry saying the forward is assumed from the shared signature and that ForApp's own argument checks and errors are unmeasured.

Non-blocking

  1. core/libs/prx/libkernel/Unimplemented.cpp:131 and core/libs/prx/libkernel/include/Api.hpp:211 declare sceKernelProtectDirectMemoryForPID(void). With the prototype known, declaring (int64_t offset, size_t len, int prot, int pid) would document it and save a later signature change. The NID comes from the name, so this does not affect resolution.
  2. GuestDirectMemoryForApp.cpp only checks that the forward reaches sceKernelAllocateDirectMemory's checks. That is enough for a forward. Any ForApp-specific behaviour added later should get its own case.

Not verified

  • I did not run the title, so I did not check the claim that PPSA99170 now loads and reaches /app0/assets/. The title's header has a comment saying "Only payloads import these calls" (pw_dmem_share.h:12). I could not check whether the v4.0.0-alpha-4 eboot imports them itself, as the PR log shows.
  • No Windows or MinGW build; the WIN32 PATH branch of the new test entry was not exercised.
  • I did not check the behaviour against a console.

To get this to a good state

  1. Rewrite the sceKernelProtectDirectMemoryForPID debt entry to give the known prototype and sources, and say what is still unknown.
  2. Cite the source of sceKernelAllocateDirectMemoryForApp's signature in the PR body, and add a debt entry noting that its own validation is unmeasured.
  3. Optionally, declare the known sceKernelProtectDirectMemoryForPID parameters.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5697215909 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12826#pullrequestreview-5697215909). Originally posted by [XairRrR](https://github.com/XairRrR) on 2026-10-29T11:52:23Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested The change merges cleanly, builds, exports both NIDs from `libkernel` and its new test passes. It needs one documentation correction: the debt entry says no prototype or measurement exists for `sceKernelProtectDirectMemoryForPID`, but the public source of the title this PR unblocks has both. Neither export's signature has a cited source. ## What I ran Head `bf1ae463892c7e3bde4bc81c65efafb95875f84b`, merged with `--no-ff` onto `main` `ba5b5330b37724bca4b99f30faab504653635a04` in a clean worktree. Arch Linux 7.2.11-zen, GCC 16.2.1, Intel Core i9-14900KF, NVIDIA GeForce RTX 4070 Ti SUPER (driver 615.78.08); Release, Ninja, `BUILD_TESTING=ON`. ```sh git fetch origin main pull/12826/head:refs/review/12826 git checkout --detach origin/main git merge --no-ff --no-edit refs/review/12826 git diff --check origin/main...refs/review/12826 python3 tools/check_conventions.py --base origin/main cmake --build build -j10 --target libs guest_direct_memory_for_app_tests ctest --test-dir build -j4 --output-on-failure -R "^(guest_direct_memory_for_app|guest_memory|guest_kernel_sys|guest_kernel_sys_constants|guest_memory_pool_stats|guest_memory_lifetime)$" ctest --test-dir build -V -R "^guest_direct_memory_for_app$" grep -c -a fNoviuIwykc build/core/libs/libs/libkernel.prx build/core/libs/libs/libkernel_sys.prx grep -c -a cBp0Ad-24LA build/core/libs/libs/libkernel.prx build/core/libs/libs/libkernel_sys.prx # negative control git checkout origin/main -- core/libs/prx/libkernel/DirectMemory/Export.cpp core/libs/prx/libkernel/Unimplemented.cpp \ core/libs/prx/libkernel/include/Api.hpp core/libs/prx/libkernel_sys/Export.Discovery.cpp core/libs/prx/libkernel_sys/include/Api.hpp cmake --build build -j10 --target guest_direct_memory_for_app_tests ``` ## Results | Check | Result | | --- | --- | | Merge onto `main` | Clean | | `git diff --check` | No output | | `check_conventions.py` | All conventions checks passed | | Build (`libs`, new test) | OK; no new warnings in the changed files | | `guest_direct_memory_for_app` | Passed, 0.00 s | | `guest_memory`, `guest_memory_lifetime`, `guest_memory_pool_stats`, `guest_kernel_sys`, `guest_kernel_sys_constants` | Passed | | NIDs in the built modules | `fNoviuIwykc` and `cBp0Ad-24LA` each appear once in `libkernel.prx` and not in `libkernel_sys.prx` | | Overlapping open PRs (search for both names) | None besides this one | <details><summary>ctest</summary> ``` 3/6 Test #2373: guest_direct_memory_for_app ...... Passed 0.00 sec 4/6 Test #2381: guest_memory_lifetime ............ Passed 0.01 sec 5/6 Test #399: guest_kernel_sys ................. Passed 0.02 sec 6/6 Test #2584: guest_memory ..................... Passed 0.59 sec 100% tests passed out of 6 2373: allocated for-app phys=0 len=65536 ``` </details> ## Negative control I restored the five production files from `main` (both `Api.hpp`, `Export.cpp`, `Unimplemented.cpp`, `Export.Discovery.cpp`) and kept the test and its CMake entry. The test no longer compiles, so it does not pass without the change. This is the compiler message, translated from the host's French locale: ``` GuestDirectMemoryForApp.cpp:24:13: error: 'sceKernelAllocateDirectMemoryForApp' was not declared in this scope; did you mean 'sceKernelAllocateDirectMemory'? ``` After that I restored the merged files, rebuilt, and the test passed again. ## Findings ### Blocking 1. **The debt entry says something that a public source contradicts.** [docs/dev/debt/libkernel.md:327](https://github.com/boykopovar/AnyPS5/blob/bf1ae463892c7e3bde4bc81c65efafb95875f84b/docs/dev/debt/libkernel.md#L327-L327) says that "no prototype, argument order or measured result was found" for `sceKernelProtectDirectMemoryForPID`. The public repository of the title this PR unblocks, PS5_MihawkOS, has all three: - [native/pw_dmem_share.h](https://github.com/mihawk-99/PS5_MihawkOS/blob/8a9c117cb265d0f54ead53b0aa37cdc8c0dc9c91/native/pw_dmem_share.h#L4-L18) declares `int sceKernelProtectDirectMemoryForPID(int64_t offset, size_t length, int prot, int pid)` and `int sceKernelAllocateDirectMemoryForApp(int64_t, int64_t, size_t, size_t, int, int64_t*)`. - [docs/PLAN.md](https://github.com/mihawk-99/PS5_MihawkOS/blob/8a9c117cb265d0f54ead53b0aa37cdc8c0dc9c91/docs/PLAN.md#L3362-L3373), "Direct memory shared between processes", reports reading `libkernel_sys.sprx` 10.01. It says the call is one ioctl `0xc018800f` with `{offset, length, pid, prot}` and that the PID variant refuses pid 0. It also records a console run in which `sceKernelProtectDirectMemoryForPID(offset, 64 MiB, 0x33, pidB)` returned 0 and a second process could then map the range. The [reverse-engineering guide](https://github.com/boykopovar/AnyPS5/blob/bf1ae463892c7e3bde4bc81c65efafb95875f84b/docs/dev/REVERSE_ENGINEERING.md#L7-L21) ranks a console measurement and the library's own code as the strongest sources. [CONTRIBUTING.md:78](https://github.com/boykopovar/AnyPS5/blob/bf1ae463892c7e3bde4bc81c65efafb95875f84b/CONTRIBUTING.md#L78-L78) asks debt entries to record known signatures. A debt entry saying no such source exists will send the next contributor in the wrong direction. Suggested fix: rewrite the entry to give the known signature with these sources and their limits (static reading of firmware 10.01, one console run, a third-party repository). Then say what still throws and why. For example, it is unknown which error is returned for pid 0 or for a pid that does not exist, and a single guest process has no second process to grant. Throwing is still reasonable with that much known. 2. **Neither export cites the source of its signature or behaviour.** [CONTRIBUTING.md:9](https://github.com/boykopovar/AnyPS5/blob/bf1ae463892c7e3bde4bc81c65efafb95875f84b/CONTRIBUTING.md#L9-L9) and the guide's [Citing it](https://github.com/boykopovar/AnyPS5/blob/bf1ae463892c7e3bde4bc81c65efafb95875f84b/docs/dev/REVERSE_ENGINEERING.md#L78-L90) section require the PR and the debt entry to say where a signature and behaviour come from. The PR states that `sceKernelAllocateDirectMemoryForApp` has the six arguments of `sceKernelAllocateDirectMemory` and the same validation ([core/libs/prx/libkernel/DirectMemory/Export.cpp:239-241](https://github.com/boykopovar/AnyPS5/blob/bf1ae463892c7e3bde4bc81c65efafb95875f84b/core/libs/prx/libkernel/DirectMemory/Export.cpp#L239-L241)), but gives no source. The header above supports the signature, and the PLAN.md section shows the compositor using both calls for the same allocation. That supports forwarding, but it is not a measurement of `ForApp`'s own validation and error codes. Suggested fix: cite the source in the PR body. Add a debt entry saying the forward is assumed from the shared signature and that `ForApp`'s own argument checks and errors are unmeasured. ### Non-blocking 1. [core/libs/prx/libkernel/Unimplemented.cpp:131](https://github.com/boykopovar/AnyPS5/blob/bf1ae463892c7e3bde4bc81c65efafb95875f84b/core/libs/prx/libkernel/Unimplemented.cpp#L131-L134) and [core/libs/prx/libkernel/include/Api.hpp:211](https://github.com/boykopovar/AnyPS5/blob/bf1ae463892c7e3bde4bc81c65efafb95875f84b/core/libs/prx/libkernel/include/Api.hpp#L210-L211) declare `sceKernelProtectDirectMemoryForPID(void)`. With the prototype known, declaring `(int64_t offset, size_t len, int prot, int pid)` would document it and save a later signature change. The NID comes from the name, so this does not affect resolution. 2. `GuestDirectMemoryForApp.cpp` only checks that the forward reaches `sceKernelAllocateDirectMemory`'s checks. That is enough for a forward. Any `ForApp`-specific behaviour added later should get its own case. ## Not verified - I did not run the title, so I did not check the claim that PPSA99170 now loads and reaches `/app0/assets/`. The title's header has a comment saying "Only payloads import these calls" ([pw_dmem_share.h:12](https://github.com/mihawk-99/PS5_MihawkOS/blob/8a9c117cb265d0f54ead53b0aa37cdc8c0dc9c91/native/pw_dmem_share.h#L11-L12)). I could not check whether the v4.0.0-alpha-4 eboot imports them itself, as the PR log shows. - No Windows or MinGW build; the `WIN32` `PATH` branch of the new test entry was not exercised. - I did not check the behaviour against a console. ## To get this to a good state 1. Rewrite the `sceKernelProtectDirectMemoryForPID` debt entry to give the known prototype and sources, and say what is still unknown. 2. Cite the source of `sceKernelAllocateDirectMemoryForApp`'s signature in the PR body, and add a debt entry noting that its own validation is unmeasured. 3. Optionally, declare the known `sceKernelProtectDirectMemoryForPID` parameters.
XairRrR commented 2026-10-29 12:00:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-10-29T12:00:46Z.

Review: APPROVED


Re-checked — approved

ea1f12ccd rewrites the sceKernelProtectDirectMemoryForPID debt entry around the MihawkOS sources, adds a debt entry for the sceKernelAllocateDirectMemoryForApp forward and declares the known ProtectDirectMemoryForPID parameters; both blocking findings are resolved and the merged tree builds and passes the focused tests.

What changed since my last review

  • New commit ea1f12ccd8b2385c66d49c42f802eab84bd0f678, "docs(libkernel): cite the sources of both direct memory exports":
  • The PR body now has a Sources paragraph citing native/pw_dmem_share.h and docs/PLAN.md at MihawkOS commit 8a9c117, and saying that ForApp's own checks are unmeasured.
  • The author replied to the review and reports a rebuild, a passing guest_direct_memory_for_app, a passing check_conventions.py, and that PPSA99170 still loads. I accept the title run as author-reported.
  • main moved from ba5b5330b to 5454cd2e4. The test and its CMake entry did not change.

What I ran

Head ea1f12ccd8b2385c66d49c42f802eab84bd0f678, merged with --no-ff onto main 5454cd2e455994d992aca39335ce60507eeda1eb in a clean worktree. Same machine as before: Arch Linux 7.2.11-zen, GCC 16.2.1, Intel Core i9-14900KF, NVIDIA GeForce RTX 4070 Ti SUPER (driver 615.78.08); Release, Ninja, BUILD_TESTING=ON.

git fetch origin main pull/12826/head:refs/review/12826
git diff bf1ae463892c7e3bde4bc81c65efafb95875f84b refs/review/12826
git checkout --detach origin/main
git merge --no-ff --no-edit refs/review/12826
git diff --check origin/main...refs/review/12826
python3 tools/check_conventions.py --base origin/main
cmake --build build -j10 --target libs guest_direct_memory_for_app_tests
ctest --test-dir build -j4 --output-on-failure -R "^(guest_direct_memory_for_app|guest_memory|guest_kernel_sys|guest_kernel_sys_constants|guest_memory_pool_stats|guest_memory_lifetime)$"
grep -c -a fNoviuIwykc build/core/libs/libs/libkernel.prx build/core/libs/libs/libkernel_sys.prx
grep -c -a cBp0Ad-24LA build/core/libs/libs/libkernel.prx build/core/libs/libs/libkernel_sys.prx

I also read native/pw_dmem_share.h and docs/PLAN.md at MihawkOS 8a9c117 to check what the new debt entries say about them.

Check Result
Merge onto main Clean
git diff --check No output
check_conventions.py 0 errors, 1 warning (debt-length, see below)
Build (libs, new test) OK; no warnings from Unimplemented.cpp or DirectMemory/Export.cpp with the named, unused parameters
guest_direct_memory_for_app and the five related memory and kernel_sys tests All 6 passed
NIDs in the built modules fNoviuIwykc and cBp0Ad-24LA each once in libkernel.prx, not in libkernel_sys.prx
check_conventions.py and ctest
docs/dev/debt/libkernel.md:327: warning: [debt-length] Technical debt entry over 1000 characters: state the gap first (what differs from the console, what is unverified, what throws) and keep only the behaviour it needs: 1350 characters
1 findings, 0 errors

2/6 Test  #447: guest_memory_pool_stats ..........   Passed    0.00 sec
3/6 Test #2390: guest_direct_memory_for_app ......   Passed    0.00 sec
4/6 Test #2398: guest_memory_lifetime ............   Passed    0.01 sec
5/6 Test  #402: guest_kernel_sys .................   Passed    0.02 sec
6/6 Test #2601: guest_memory .....................   Passed    0.59 sec
100% tests passed out of 6

Negative control: the test and its CMake entry are unchanged since bf1ae46, and the new commit only renames the stub's parameters. I did not repeat the control. The earlier one still applies: without the production files the test does not compile.

Previous findings

  • Blocking 1 (the debt entry said no prototype or measurement existed): Resolved. The entry gives the prototype from pw_dmem_share.h, the ioctl 0xc018800f reading and both console runs. It also lists the limits: a third-party source, one firmware, an unknown error for pid 0 or a missing pid, and no second guest process. I checked these against the header and against PLAN.md.
  • Blocking 2 (no source for either signature): Resolved. The PR body and the new sceKernelAllocateDirectMemoryForApp entry cite the header's line 17 declaration. The entry says the forward is assumed from the shared signature, and that ForApp's own checks and errors are unmeasured.
  • Non-blocking 1 (declare the known ProtectDirectMemoryForPID parameters): Resolved in Unimplemented.cpp:131 and Api.hpp:211.
  • Non-blocking 2 (test only covers the forward): No longer applies as an action. It still holds for any later ForApp-specific behaviour.

New findings

Blocking

None.

Non-blocking

  1. docs/dev/debt/libkernel.md:327 is 1350 characters, and check_conventions.py warns about entries over 1000 (debt-length, CONTRIBUTING.md:78). My request for sources partly caused this. It could be cut without losing anything: drop the two run IDs (PLAN.md links them), and replace the PLAN.md narrative with "per a static reading of libkernel_sys.sprx 10.01 and one console run in PLAN.md". Keep the prototype, the unknown error codes and the single-process reason for throwing.

Not verified

  • I did not run PPSA99170. The claim that it loads with 0 unresolved imports is author-reported.
  • No Windows or MinGW build.
  • I did not check the behaviour of either call against a console.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5697315570 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12826#pullrequestreview-5697315570). Originally posted by [XairRrR](https://github.com/XairRrR) on 2026-10-29T12:00:46Z. **Review:** APPROVED --- # Re-checked — approved `ea1f12ccd` rewrites the `sceKernelProtectDirectMemoryForPID` debt entry around the MihawkOS sources, adds a debt entry for the `sceKernelAllocateDirectMemoryForApp` forward and declares the known `ProtectDirectMemoryForPID` parameters; both blocking findings are resolved and the merged tree builds and passes the focused tests. ## What changed since my last review - New commit `ea1f12ccd8b2385c66d49c42f802eab84bd0f678`, "docs(libkernel): cite the sources of both direct memory exports": - [docs/dev/debt/libkernel.md:327-328](https://github.com/boykopovar/AnyPS5/blob/ea1f12ccd8b2385c66d49c42f802eab84bd0f678/docs/dev/debt/libkernel.md#L327-L328): the `sceKernelProtectDirectMemoryForPID` entry is rewritten, and a new `sceKernelAllocateDirectMemoryForApp` entry is added. - [core/libs/prx/libkernel/Unimplemented.cpp:131](https://github.com/boykopovar/AnyPS5/blob/ea1f12ccd8b2385c66d49c42f802eab84bd0f678/core/libs/prx/libkernel/Unimplemented.cpp#L131-L134) and [core/libs/prx/libkernel/include/Api.hpp:211](https://github.com/boykopovar/AnyPS5/blob/ea1f12ccd8b2385c66d49c42f802eab84bd0f678/core/libs/prx/libkernel/include/Api.hpp#L211-L211) now declare `(int64_t offset, size_t len, int prot, int pid)`. The body still calls `NotImplemented_nid_no_patch`. - The PR body now has a **Sources** paragraph citing `native/pw_dmem_share.h` and `docs/PLAN.md` at MihawkOS commit `8a9c117`, and saying that `ForApp`'s own checks are unmeasured. - The author replied to the review and reports a rebuild, a passing `guest_direct_memory_for_app`, a passing `check_conventions.py`, and that PPSA99170 still loads. I accept the title run as author-reported. - `main` moved from `ba5b5330b` to `5454cd2e4`. The test and its CMake entry did not change. ## What I ran Head `ea1f12ccd8b2385c66d49c42f802eab84bd0f678`, merged with `--no-ff` onto `main` `5454cd2e455994d992aca39335ce60507eeda1eb` in a clean worktree. Same machine as before: Arch Linux 7.2.11-zen, GCC 16.2.1, Intel Core i9-14900KF, NVIDIA GeForce RTX 4070 Ti SUPER (driver 615.78.08); Release, Ninja, `BUILD_TESTING=ON`. ```sh git fetch origin main pull/12826/head:refs/review/12826 git diff bf1ae463892c7e3bde4bc81c65efafb95875f84b refs/review/12826 git checkout --detach origin/main git merge --no-ff --no-edit refs/review/12826 git diff --check origin/main...refs/review/12826 python3 tools/check_conventions.py --base origin/main cmake --build build -j10 --target libs guest_direct_memory_for_app_tests ctest --test-dir build -j4 --output-on-failure -R "^(guest_direct_memory_for_app|guest_memory|guest_kernel_sys|guest_kernel_sys_constants|guest_memory_pool_stats|guest_memory_lifetime)$" grep -c -a fNoviuIwykc build/core/libs/libs/libkernel.prx build/core/libs/libs/libkernel_sys.prx grep -c -a cBp0Ad-24LA build/core/libs/libs/libkernel.prx build/core/libs/libs/libkernel_sys.prx ``` I also read `native/pw_dmem_share.h` and `docs/PLAN.md` at MihawkOS `8a9c117` to check what the new debt entries say about them. | Check | Result | | --- | --- | | Merge onto `main` | Clean | | `git diff --check` | No output | | `check_conventions.py` | 0 errors, 1 warning (`debt-length`, see below) | | Build (`libs`, new test) | OK; no warnings from `Unimplemented.cpp` or `DirectMemory/Export.cpp` with the named, unused parameters | | `guest_direct_memory_for_app` and the five related memory and `kernel_sys` tests | All 6 passed | | NIDs in the built modules | `fNoviuIwykc` and `cBp0Ad-24LA` each once in `libkernel.prx`, not in `libkernel_sys.prx` | <details><summary>check_conventions.py and ctest</summary> ``` docs/dev/debt/libkernel.md:327: warning: [debt-length] Technical debt entry over 1000 characters: state the gap first (what differs from the console, what is unverified, what throws) and keep only the behaviour it needs: 1350 characters 1 findings, 0 errors 2/6 Test #447: guest_memory_pool_stats .......... Passed 0.00 sec 3/6 Test #2390: guest_direct_memory_for_app ...... Passed 0.00 sec 4/6 Test #2398: guest_memory_lifetime ............ Passed 0.01 sec 5/6 Test #402: guest_kernel_sys ................. Passed 0.02 sec 6/6 Test #2601: guest_memory ..................... Passed 0.59 sec 100% tests passed out of 6 ``` </details> Negative control: the test and its CMake entry are unchanged since `bf1ae46`, and the new commit only renames the stub's parameters. I did not repeat the control. The earlier one still applies: without the production files the test does not compile. ## Previous findings - Blocking 1 (the debt entry said no prototype or measurement existed): **Resolved.** The entry gives the prototype from [pw_dmem_share.h](https://github.com/mihawk-99/PS5_MihawkOS/blob/8a9c117cb265d0f54ead53b0aa37cdc8c0dc9c91/native/pw_dmem_share.h#L4-L18), the ioctl `0xc018800f` reading and both console runs. It also lists the limits: a third-party source, one firmware, an unknown error for pid 0 or a missing pid, and no second guest process. I checked these against the header and against PLAN.md. - Blocking 2 (no source for either signature): **Resolved.** The PR body and the new `sceKernelAllocateDirectMemoryForApp` entry cite the header's line 17 declaration. The entry says the forward is assumed from the shared signature, and that `ForApp`'s own checks and errors are unmeasured. - Non-blocking 1 (declare the known `ProtectDirectMemoryForPID` parameters): **Resolved** in `Unimplemented.cpp:131` and `Api.hpp:211`. - Non-blocking 2 (test only covers the forward): **No longer applies** as an action. It still holds for any later `ForApp`-specific behaviour. ## New findings ### Blocking None. ### Non-blocking 1. [docs/dev/debt/libkernel.md:327](https://github.com/boykopovar/AnyPS5/blob/ea1f12ccd8b2385c66d49c42f802eab84bd0f678/docs/dev/debt/libkernel.md#L327-L327) is 1350 characters, and `check_conventions.py` warns about entries over 1000 (`debt-length`, [CONTRIBUTING.md:78](https://github.com/boykopovar/AnyPS5/blob/ea1f12ccd8b2385c66d49c42f802eab84bd0f678/CONTRIBUTING.md#L78-L78)). My request for sources partly caused this. It could be cut without losing anything: drop the two run IDs (PLAN.md links them), and replace the PLAN.md narrative with "per a static reading of `libkernel_sys.sprx` 10.01 and one console run in PLAN.md". Keep the prototype, the unknown error codes and the single-process reason for throwing. ## Not verified - I did not run PPSA99170. The claim that it loads with 0 unresolved imports is author-reported. - No Windows or MinGW build. - I did not check the behaviour of either call against a console.
XairRrR commented 2026-10-29 12:08:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-10-29T12:08:28Z.

Review: APPROVED


Re-checked — approved

d4d53e2de cuts the sceKernelProtectDirectMemoryForPID debt entry from 1350 to 854 characters, which resolves my one remaining non-blocking finding. The change touches only documentation, so the merge preview is clean and check_conventions.py now reports no findings.

What changed since my last review

  • New commit d4d53e2deadd1e768f7d2278a40275f9445367c2, "docs(libkernel): trim the ProtectDirectMemoryForPID debt entry". It changes one line, docs/dev/debt/libkernel.md:327, and no code, tests or build files.
  • The entry keeps the prototype, the pw_dmem_share.h link, the static reading of libkernel_sys.sprx 10.01, the one console run, the unknown error for pid 0 or a missing pid, and the single-process reason. It drops the run IDs, the link to PLAN.md and the "third-party repository / one firmware / payload-only" sentence. The sceKernelAllocateDirectMemoryForApp entry on line 328 is unchanged and is 914 characters.
  • main is still 5454cd2e4.

What I ran

Head d4d53e2deadd1e768f7d2278a40275f9445367c2, main 5454cd2e455994d992aca39335ce60507eeda1eb, in a clean worktree:

git fetch origin main pull/12826/head:refs/review/12826
git diff ea1f12ccd8b2385c66d49c42f802eab84bd0f678 refs/review/12826
git merge-tree --write-tree origin/main refs/review/12826
git checkout --detach origin/main
git merge --no-ff --no-edit refs/review/12826
git diff --check origin/main...refs/review/12826
python3 tools/check_conventions.py --base origin/main
sed -n 327,328p docs/dev/debt/libkernel.md | awk '{print length($0)}'
Check Result
Merge onto main (merge-tree and a real merge) Clean
git diff --check No output
check_conventions.py All conventions checks passed. (the debt-length warning is gone)
Length of debt entries 327 and 328 854 and 914 characters
pw_dmem_share.h link in the entry Resolves (HTTP 200)

I did not rebuild or rerun the tests, because the new commit only changes documentation. The build, the six focused tests and the NID checks from my previous review on ea1f12ccd still apply to the code.

Previous findings

  • Non-blocking 1 (the ProtectDirectMemoryForPID entry was 1350 characters and triggered debt-length): Resolved. The entry is now 854 characters, and check_conventions.py passes on the merged tree. My earlier blocking findings were already resolved in ea1f12ccd, and the trimmed entry still states the prototype, its source and the open gaps.
  • The 12:00 comment from oneandonlydean asks for changes to wording ("no prototype, argument order or measured result was found", the speculative no-op wording). That wording came from bf1ae46 and was already removed in ea1f12ccd. It is not on the current head.

New findings

Blocking

None.

Non-blocking

  1. The new pw_dmem_share.h link on line 327 uses the short SHA 8a9c117, while line 328 and the PR body use the full 8a9c117cb265d0f54ead53b0aa37cdc8c0dc9c91. The link resolves today. However, a short SHA can become ambiguous as that repository grows, and the two entries would read more consistently with the full SHA. Optional.

Not verified

  • I did not rebuild or rerun tests for this documentation-only commit (see above).
  • I did not run PPSA99170. The claim that it loads with 0 unresolved imports is author-reported.
  • No Windows or MinGW build.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5697408704 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12826#pullrequestreview-5697408704). Originally posted by [XairRrR](https://github.com/XairRrR) on 2026-10-29T12:08:28Z. **Review:** APPROVED --- # Re-checked — approved `d4d53e2de` cuts the `sceKernelProtectDirectMemoryForPID` debt entry from 1350 to 854 characters, which resolves my one remaining non-blocking finding. The change touches only documentation, so the merge preview is clean and `check_conventions.py` now reports no findings. ## What changed since my last review - New commit `d4d53e2deadd1e768f7d2278a40275f9445367c2`, "docs(libkernel): trim the ProtectDirectMemoryForPID debt entry". It changes one line, [docs/dev/debt/libkernel.md:327](https://github.com/boykopovar/AnyPS5/blob/d4d53e2deadd1e768f7d2278a40275f9445367c2/docs/dev/debt/libkernel.md#L327-L327), and no code, tests or build files. - The entry keeps the prototype, the `pw_dmem_share.h` link, the static reading of `libkernel_sys.sprx` 10.01, the one console run, the unknown error for pid 0 or a missing pid, and the single-process reason. It drops the run IDs, the link to `PLAN.md` and the "third-party repository / one firmware / payload-only" sentence. The `sceKernelAllocateDirectMemoryForApp` entry on line 328 is unchanged and is 914 characters. - `main` is still `5454cd2e4`. ## What I ran Head `d4d53e2deadd1e768f7d2278a40275f9445367c2`, `main` `5454cd2e455994d992aca39335ce60507eeda1eb`, in a clean worktree: ```sh git fetch origin main pull/12826/head:refs/review/12826 git diff ea1f12ccd8b2385c66d49c42f802eab84bd0f678 refs/review/12826 git merge-tree --write-tree origin/main refs/review/12826 git checkout --detach origin/main git merge --no-ff --no-edit refs/review/12826 git diff --check origin/main...refs/review/12826 python3 tools/check_conventions.py --base origin/main sed -n 327,328p docs/dev/debt/libkernel.md | awk '{print length($0)}' ``` | Check | Result | | --- | --- | | Merge onto `main` (`merge-tree` and a real merge) | Clean | | `git diff --check` | No output | | `check_conventions.py` | `All conventions checks passed.` (the `debt-length` warning is gone) | | Length of debt entries 327 and 328 | 854 and 914 characters | | `pw_dmem_share.h` link in the entry | Resolves (HTTP 200) | I did not rebuild or rerun the tests, because the new commit only changes documentation. The build, the six focused tests and the NID checks from my previous review on `ea1f12ccd` still apply to the code. ## Previous findings - Non-blocking 1 (the `ProtectDirectMemoryForPID` entry was 1350 characters and triggered `debt-length`): **Resolved.** The entry is now 854 characters, and `check_conventions.py` passes on the merged tree. My earlier blocking findings were already resolved in `ea1f12ccd`, and the trimmed entry still states the prototype, its source and the open gaps. - The 12:00 comment from `oneandonlydean` asks for changes to wording ("no prototype, argument order or measured result was found", the speculative no-op wording). That wording came from `bf1ae46` and was already removed in `ea1f12ccd`. It is not on the current head. ## New findings ### Blocking None. ### Non-blocking 1. The new `pw_dmem_share.h` link on line 327 uses the short SHA `8a9c117`, while line 328 and the PR body use the full `8a9c117cb265d0f54ead53b0aa37cdc8c0dc9c91`. The link resolves today. However, a short SHA can become ambiguous as that repository grows, and the two entries would read more consistently with the full SHA. Optional. ## Not verified - I did not rebuild or rerun tests for this documentation-only commit (see above). - I did not run PPSA99170. The claim that it loads with 0 unresolved imports is author-reported. - No Windows or MinGW build.
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!12826
No description provided.