fix(libkernel): answer sceKernelGetPageTableStats #4101

Merged
xXPBSXx merged 1 commit from upstream-pr/4101 into main 2026-10-12 21:02:33 +00:00
xXPBSXx commented 2026-10-11 23:14:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-11T23:14:26Z.


What

Resonance: A Plague Tale Legacy (PPSA30601) stops at sceKernelGetPageTableStats not implemented once its imports are exported (#4067). The call now answers instead of throwing:

  • Signature int sceKernelGetPageTableStats(int* cpuTotal, int* cpuAvailable, int* gpuTotal, int* gpuAvailable), as in OpenOrbis' libkernel.h, the Orbital type database and SharpProspero (KernelMemoryQuery.cs: "how many page-table entries the module was given for each side and how many are left").
  • It reports 2048 entries on each side (a 4 GiB pool of 2 MiB entries, the constants of KytyPS5's KernelGetPageTableStats) and all of them available. KytyPS5 additionally counts the 2 MiB entries of the committed ranges as used; this PR does not. A null pointer returns SCE_KERNEL_ERROR_EFAULT, as in KytyPS5.
  • The numbers are KytyPS5's, not measured on a console. Nothing in the SDK headers or the other sources I found says what the console reports; if a plausible value from another emulator is not acceptable here, the alternative is to keep the throwing stub, with the cost that PPSA30601 stays stopped at this call. The entry is in the TechnicalDebt silent-stub list with these limits.

CheckPageTableStats in GuestMemory.cpp covers the answer and the four null-pointer cases; without the change the call throws and the test aborts.

Tested

  • Windows, MinGW GCC 15.2.0, on current main with #4021 applied (the Windows build of main is broken by HostPoll; unrelated to this change): ctest -R guest_memory passes; tools/check_conventions.py --base upstream/main passes. guest_memory_pool_stats was not built here.
  • Not tested: running PPSA30601 with this change (its other imports are in #3814, #3799 and #3773, so the title cannot reach the call from main alone), and what the title does with the numbers.

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 (Claude Code)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4823116761 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4101). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-11T23:14:26Z. --- ### What Resonance: A Plague Tale Legacy (PPSA30601) stops at `sceKernelGetPageTableStats not implemented` once its imports are exported (#4067). The call now answers instead of throwing: - Signature `int sceKernelGetPageTableStats(int* cpuTotal, int* cpuAvailable, int* gpuTotal, int* gpuAvailable)`, as in OpenOrbis' `libkernel.h`, the Orbital type database and SharpProspero (`KernelMemoryQuery.cs`: "how many page-table entries the module was given for each side and how many are left"). - It reports 2048 entries on each side (a 4 GiB pool of 2 MiB entries, the constants of [KytyPS5's `KernelGetPageTableStats`](https://github.com/KytyPS5/KytyPS5/blob/main/src/kernel/memory.cpp)) and all of them available. KytyPS5 additionally counts the 2 MiB entries of the committed ranges as used; this PR does not. A null pointer returns `SCE_KERNEL_ERROR_EFAULT`, as in KytyPS5. - **The numbers are KytyPS5's, not measured on a console.** Nothing in the SDK headers or the other sources I found says what the console reports; if a plausible value from another emulator is not acceptable here, the alternative is to keep the throwing stub, with the cost that PPSA30601 stays stopped at this call. The entry is in the TechnicalDebt silent-stub list with these limits. `CheckPageTableStats` in `GuestMemory.cpp` covers the answer and the four null-pointer cases; without the change the call throws and the test aborts. ### Tested - Windows, MinGW GCC 15.2.0, on current `main` with #4021 applied (the Windows build of `main` is broken by `HostPoll`; unrelated to this change): `ctest -R guest_memory` passes; `tools/check_conventions.py --base upstream/main` passes. `guest_memory_pool_stats` was not built here. - Not tested: running PPSA30601 with this change (its other imports are in #3814, #3799 and #3773, so the title cannot reach the call from `main` alone), and what the title does with the numbers. ### 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 (Claude Code)
github-actions[bot] commented 2026-10-11 23:15:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-11T23:15:30Z.


Progress report (529f7bf → d283d48)

📈 System libraries: 87.39% (+0.02%, +1 implemented functions)

✅ 1 implemented
Library Name
libkernel sceKernelGetPageTableStats
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6114991246 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4101#issuecomment-6114991246). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-11T23:15:30Z. --- <!-- progress-report --> ### Progress report (529f7bf → d283d48) 📈 **System libraries**: 87.39% (+0.02%, +1 implemented functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libkernel | `sceKernelGetPageTableStats` | </details>
xXPBSXx commented 2026-10-12 05:43:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-12T05:43:58Z.


Merged current main into the branch (conflict in core/libs/tests/GuestMemory.cpp only, both new test calls kept: CheckPageTableStats and CheckMunmapOverUnmappedPages). Windows, GCC: guest_memory tests pass, tools/check_conventions.py --base upstream/main passes. No code change.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6118492114 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4101#issuecomment-6118492114). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-12T05:43:58Z. --- Merged current `main` into the branch (conflict in `core/libs/tests/GuestMemory.cpp` only, both new test calls kept: `CheckPageTableStats` and `CheckMunmapOverUnmappedPages`). Windows, GCC: `guest_memory` tests pass, `tools/check_conventions.py --base upstream/main` passes. No code change. AI-assisted (Claude Code).
oneandonlydean commented 2026-10-12 08:25:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-12T08:25:15Z.


Please rebase onto main instead of merging it in: 5cec557c is a merge commit, and branches here carry none. No code change needed.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6120536337 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4101#issuecomment-6120536337). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-12T08:25:15Z. --- Please rebase onto main instead of merging it in: 5cec557c is a merge commit, and branches here carry none. No code change needed.
xXPBSXx commented 2026-10-12 17:37:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-12T17:37:13Z.


Rebased onto current main (2a5eca11c) as requested: one commit, no merge commit, the branch was force-updated with a lease. Tests on this base (Windows, MinGW, no GPU tests): guest_memory_pool_stats and guest_memory pass, check_conventions passes.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6129398946 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4101#issuecomment-6129398946). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-12T17:37:13Z. --- Rebased onto current `main` (`2a5eca11c`) as requested: one commit, no merge commit, the branch was force-updated with a lease. Tests on this base (Windows, MinGW, no GPU tests): `guest_memory_pool_stats` and `guest_memory` pass, `check_conventions` passes. AI-assisted (Claude Code).
github-actions[bot] commented 2026-10-12 20:47:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-12T20:47:38Z.


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
#4374 docs/dev/debt/libkernel.md L160
#4376 docs/dev/debt/libkernel.md L160
#4379 docs/dev/debt/libkernel.md L160
#4386 docs/dev/debt/libkernel.md L160
#4530 core/libs/tests/GuestMemory.cpp L115
#4651 docs/dev/debt/libkernel.md L160
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6132341620 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4101#issuecomment-6132341620). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-12T20:47:38Z. --- <!-- 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 | |---|---|---|---| | #4374 | `docs/dev/debt/libkernel.md` [L160](https://github.com/boykopovar/AnyPS5/blob/6f438a1c2e23dadf4c00284b4e797d02596f949e/docs/dev/debt/libkernel.md#L160) | | | | #4376 | `docs/dev/debt/libkernel.md` [L160](https://github.com/boykopovar/AnyPS5/blob/6f438a1c2e23dadf4c00284b4e797d02596f949e/docs/dev/debt/libkernel.md#L160) | | | | #4379 | `docs/dev/debt/libkernel.md` [L160](https://github.com/boykopovar/AnyPS5/blob/6f438a1c2e23dadf4c00284b4e797d02596f949e/docs/dev/debt/libkernel.md#L160) | | | | #4386 | `docs/dev/debt/libkernel.md` [L160](https://github.com/boykopovar/AnyPS5/blob/6f438a1c2e23dadf4c00284b4e797d02596f949e/docs/dev/debt/libkernel.md#L160) | | | | #4530 | `core/libs/tests/GuestMemory.cpp` [L115](https://github.com/boykopovar/AnyPS5/blob/6f438a1c2e23dadf4c00284b4e797d02596f949e/core/libs/tests/GuestMemory.cpp#L115) | | | | #4651 | `docs/dev/debt/libkernel.md` [L160](https://github.com/boykopovar/AnyPS5/blob/6f438a1c2e23dadf4c00284b4e797d02596f949e/docs/dev/debt/libkernel.md#L160) | | |
adriadam10 commented 2026-10-12 21:02:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-12T21:02:30Z.


Checked against KytyPS5 KernelGetPageTableStats (constants, EFAULT on null pointers), merged onto current main with a scoped build and ctest (141/141, guest_memory and guest_memory_pool_stats pass), and guest_memory fails without the change. The debt entry records the unmeasured values and the missing used-entry count; merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6132554034 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4101#issuecomment-6132554034). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-12T21:02:30Z. --- Checked against KytyPS5 `KernelGetPageTableStats` (constants, `EFAULT` on null pointers), merged onto current `main` with a scoped build and ctest (141/141, `guest_memory` and `guest_memory_pool_stats` pass), and `guest_memory` fails without the change. The debt entry records the unmeasured values and the missing used-entry count; merging.
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!4101
No description provided.