feat(libkernel): export sceKernelMmap #4710

Merged
babyhuey merged 1 commit from upstream-pr/4710 into main 2026-10-12 21:15:49 +00:00
babyhuey commented 2026-10-12 19:37:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-12T19:37:31Z.


What

Exports sceKernelMmap (PGhQHd-dzv8) in libkernel, next to sceKernelMunmap. It is the SCE-error form of mmap: it calls the existing mmap_nid_postfix, returns the SCE error for errno when that fails, and otherwise stores the mapping in *res and returns 0. This is the same shape as shadPS4's sceKernelMmap, with the (addr, len, prot, flags, fd, offset, res) signature. Flags, protections and descriptors are whatever mmap already supports, so nothing new is accepted or refused.

Where a title reaches it

Nuvio Max'd (PPSA99288, catalog build) relinks with --trap-sdk-syscall-stubs (#3804). Until recently its relink failed; on main 682ef0c1 it relinks, and it stops at load:

  • Linux: app.elf: symbol lookup error: app.elf: undefined symbol: PGhQHd-dzv8
  • Windows: FAIL: unresolved ELF import PGhQHd-dzv8 from libkernel.prx

With this PR every import resolves:

  • Linux: it runs until sceVideoOutOpen, which is as far as a headless run gets (gdb: VideoOutDriver::VideoOutDriver rethrows under the offscreen SDL driver). A breakpoint on sceKernelMmap shows the title doesn't call it before then; it needs the export to load.
  • Windows: it gets well past video out: it creates its Vulkan swapchain, loads its fonts, logs [nuvio] app: Nuvio Max'd 0.5.15 (native experimental) and its curl and display set-up, then stops at poll: descriptor 4 is not a socket, the stop #3649 fixes.

Tested

On the PR head db3726a8, Linux (Ubuntu 24.04, GCC 13) and Windows 11 (MinGW-w64 GCC 15.2 from WinLibs), Release:

  • guest_memory passes 5/5 (--repeat until-fail:5) on both. The new check maps an anonymous page through sceKernelMmap, writes and reads it, unmaps it, and checks that a zero length returns SCE_KERNEL_ERROR_EINVAL without touching *res.
  • No warnings in DirectMemory/Export.cpp or GuestMemory.cpp.

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 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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4834149404 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4710). Originally posted by [babyhuey](https://github.com/babyhuey) on 2026-10-12T19:37:31Z. --- ### What Exports `sceKernelMmap` (`PGhQHd-dzv8`) in libkernel, next to `sceKernelMunmap`. It is the SCE-error form of `mmap`: it calls the existing `mmap_nid_postfix`, returns the SCE error for `errno` when that fails, and otherwise stores the mapping in `*res` and returns 0. This is the same shape as shadPS4's [`sceKernelMmap`](https://github.com/shadps4-emu/shadPS4/blob/e0a466753a1aacbc8db8253be685bf7ab4d9daae/src/core/libraries/kernel/memory.cpp#L818-L830), with the `(addr, len, prot, flags, fd, offset, res)` signature. Flags, protections and descriptors are whatever `mmap` already supports, so nothing new is accepted or refused. ### Where a title reaches it Nuvio Max'd (PPSA99288, catalog build) relinks with `--trap-sdk-syscall-stubs` (#3804). Until recently its relink failed; on `main` 682ef0c1 it relinks, and it stops at load: - Linux: `app.elf: symbol lookup error: app.elf: undefined symbol: PGhQHd-dzv8` - Windows: `FAIL: unresolved ELF import PGhQHd-dzv8 from libkernel.prx` With this PR every import resolves: - Linux: it runs until `sceVideoOutOpen`, which is as far as a headless run gets (gdb: `VideoOutDriver::VideoOutDriver` rethrows under the offscreen SDL driver). A breakpoint on `sceKernelMmap` shows the title doesn't call it before then; it needs the export to load. - Windows: it gets well past video out: it creates its Vulkan swapchain, loads its fonts, logs `[nuvio] app: Nuvio Max'd 0.5.15 (native experimental)` and its curl and display set-up, then stops at `poll: descriptor 4 is not a socket`, the stop #3649 fixes. ### Tested On the PR head db3726a8, Linux (Ubuntu 24.04, GCC 13) and Windows 11 (MinGW-w64 GCC 15.2 from WinLibs), Release: - `guest_memory` passes 5/5 (`--repeat until-fail:5`) on both. The new check maps an anonymous page through `sceKernelMmap`, writes and reads it, unmaps it, and checks that a zero length returns `SCE_KERNEL_ERROR_EINVAL` without touching `*res`. - No warnings in `DirectMemory/Export.cpp` or `GuestMemory.cpp`. `check_conventions.py` passes. ### 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
github-actions[bot] commented 2026-10-12 19:38:57 +00:00 (Migrated from github.com)

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


Progress report (2f4cc89 → db3726a)

📈 System libraries: 86.37% (+0.01%, +1 implemented functions)

✅ 1 implemented
Library Name
libkernel sceKernelMmap
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6131322438 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4710#issuecomment-6131322438). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-12T19:38:57Z. --- <!-- progress-report --> ### Progress report (2f4cc89 → db3726a) 📈 **System libraries**: 86.37% (+0.01%, +1 implemented functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libkernel | `sceKernelMmap` | </details>
github-actions[bot] commented 2026-10-12 20:55:41 +00:00 (Migrated from github.com)

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


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
#4617 core/libs/prx/libkernel/DirectMemory/Export.cpp L33
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6132456736 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4710#issuecomment-6132456736). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-12T20:55:41Z. --- <!-- 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 | |---|---|---|---| | #4617 | `core/libs/prx/libkernel/DirectMemory/Export.cpp` [L33](https://github.com/boykopovar/AnyPS5/blob/e0fad55e56b0284f0588eee98c96bab05725c521/core/libs/prx/libkernel/DirectMemory/Export.cpp#L33) | | |
adriadam10 commented 2026-10-12 21:15:45 +00:00 (Migrated from github.com)

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


Checked build and ctest (141/141) on the PR merged onto main; guest_memory passes, and its new CheckSceKernelMmap does not link without the export. The wrapper matches mmap_nid_postfix + errno → SCE error (EINVAL on zero length leaves *res untouched), same shape as shadPS4's sceKernelMmap. Merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6132740333 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4710#issuecomment-6132740333). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-12T21:15:45Z. --- Checked build and ctest (141/141) on the PR merged onto main; `guest_memory` passes, and its new `CheckSceKernelMmap` does not link without the export. The wrapper matches `mmap_nid_postfix` + errno → SCE error (EINVAL on zero length leaves `*res` untouched), same shape as shadPS4's `sceKernelMmap`. 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!4710
No description provided.