fix(libkernel): answer sceKernelGetModuleInfoFromAddr's flags and failures as measured on a PS5 #10230

Merged
orezraey merged 3 commits from upstream-pr/10230 into main 2026-10-24 11:24:17 +00:00
orezraey commented 2026-10-23 14:54:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by orezraey on 2026-10-23T14:54:20Z.


What

sceKernelGetModuleInfoFromAddr measured on a retail PS5 (firmware 13.60) through libkernel_sys.sprx from a payload process, for flags -1 to 8, system-module, stack, heap, low and null addresses, and several input st_size values. The sources and console logs are in this gist (pmodinfo, pmodinfo2).

Case Console Before
flags 1 finds any module: libkernel_sys.sprx (id 1), libSceLibcInternal.sprx (id 2) throws
flags 2 on a system module ESRCH finds it
flags -1, 0, 3 to 8 clears the 0x1A8 bytes, EINVAL throws
any failure (ESRCH for a stack, heap or low address) clears the 0x1A8 bytes leaves the buffer
st_size on success, whatever was passed in (0, 0x160, 0x1A8, 0x10000) left 0 0x1A8
null info, flags 1 or 2 EFAULT EFAULT
null info, other flags faulted now throws

Flags 2 now refuses AnyPS5's host libraries, which stand in for the system modules, and still finds the main program and .guest.prx modules. Flags 2 finding a title module could not be measured, since a payload process has none. The two internal callers that look up any address, the Linux unwind lookup and the thread-destructor DSO lookup, now pass flags 1.

sceKernelInternalMemoryGetModuleSegmentInfo and sceKernelGetLibkernelTextLocation returned 0 with address and size 0 in the payload process. A title process may differ, so the code is unchanged and the debt entry records it.

#8658 and #9263 (macOS) touch the same function and debt lines; whichever lands second keeps both.

Tested

Windows 11, MinGW (winlibs).

  • guest_module_info checks EINVAL and the cleared buffer for flags -1, 0, 3, 4 and 8, a throw for a null info with flags 0, flags 1 and 2 on a system module's address (found, then ESRCH with a cleared buffer), flags 2 on the main program, and st_size 0. It fails on main and passes three runs in a row with the change.
  • The 84 module, TLS, unwind and libkernel_sys tests pass three runs in a row; guest_kernel_sys_module_internal and guest_force_tls_destructor were adjusted to pass flags 1 for host addresses.
  • Linux (WSL, GCC): guest_unwind_module_info_failure now expects flags 1 from the unwind lookup; it fails with the old expectation and passes three runs in a row with guest_module_info, guest_kernel_sys_module_internal and guest_force_tls_destructor.
  • Full suite: 1074 of 1075 pass; guest_kqueue fails intermittently on this machine with and without the change.
  • tools/check_conventions.py 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
  • 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:4984691376 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10230). Originally posted by [orezraey](https://github.com/orezraey) on 2026-10-23T14:54:20Z. --- ### What `sceKernelGetModuleInfoFromAddr` measured on a retail PS5 (firmware 13.60) through `libkernel_sys.sprx` from a payload process, for flags -1 to 8, system-module, stack, heap, low and null addresses, and several input `st_size` values. The sources and console logs are in [this gist](https://gist.github.com/orezraey/57196301a1f807f8496feaa1113c3471) (`pmodinfo`, `pmodinfo2`). | Case | Console | Before | |---|---|---| | flags 1 | finds any module: `libkernel_sys.sprx` (id 1), `libSceLibcInternal.sprx` (id 2) | throws | | flags 2 on a system module | `ESRCH` | finds it | | flags -1, 0, 3 to 8 | clears the 0x1A8 bytes, `EINVAL` | throws | | any failure (`ESRCH` for a stack, heap or low address) | clears the 0x1A8 bytes | leaves the buffer | | `st_size` on success, whatever was passed in (0, 0x160, 0x1A8, 0x10000) | left 0 | 0x1A8 | | null info, flags 1 or 2 | `EFAULT` | `EFAULT` | | null info, other flags | faulted | now throws | Flags 2 now refuses AnyPS5's host libraries, which stand in for the system modules, and still finds the main program and `.guest.prx` modules. Flags 2 finding a title module could not be measured, since a payload process has none. The two internal callers that look up any address, the Linux unwind lookup and the thread-destructor DSO lookup, now pass flags 1. `sceKernelInternalMemoryGetModuleSegmentInfo` and `sceKernelGetLibkernelTextLocation` returned 0 with address and size 0 in the payload process. A title process may differ, so the code is unchanged and the debt entry records it. #8658 and #9263 (macOS) touch the same function and debt lines; whichever lands second keeps both. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Windows 11, MinGW (winlibs). - `guest_module_info` checks `EINVAL` and the cleared buffer for flags -1, 0, 3, 4 and 8, a throw for a null info with flags 0, flags 1 and 2 on a system module's address (found, then `ESRCH` with a cleared buffer), flags 2 on the main program, and `st_size` 0. It fails on `main` and passes three runs in a row with the change. - The 84 module, TLS, unwind and `libkernel_sys` tests pass three runs in a row; `guest_kernel_sys_module_internal` and `guest_force_tls_destructor` were adjusted to pass flags 1 for host addresses. - Linux (WSL, GCC): `guest_unwind_module_info_failure` now expects flags 1 from the unwind lookup; it fails with the old expectation and passes three runs in a row with `guest_module_info`, `guest_kernel_sys_module_internal` and `guest_force_tls_destructor`. - Full suite: 1074 of 1075 pass; `guest_kqueue` fails intermittently on this machine with and without the change. - `tools/check_conventions.py` 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) - [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
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!10230
No description provided.