feat(libkernel): implement sceKernelEnableDmemAliasing #4326

Merged
winstrex merged 1 commit from upstream-pr/4326 into main 2026-10-12 10:50:39 +00:00
winstrex commented 2026-10-12 06:13:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by winstrex on 2026-10-12T06:13:05Z.


What

ProsperoEden (PPSA99008, 1.000.110 from the homebrew catalog, an Eden Switch emulator port) does not load on main d146ec1b6:

./app.elf: symbol lookup error: ./app.elf: undefined symbol: usHTMoFoBTM

usHTMoFoBTM is sceKernelEnableDmemAliasing, the title's only absent import (tools/import_audit.py: 437 implemented, 5 throwing stubs, this one absent). ProsperoEden's public source calls it before mapping the same direct memory a second time:

It ignores the result ("Reports zero regardless; the self-test checks") and checks the mappings instead.

The function takes no arguments and returns int, as in shadPS4 and ProsperoEden's declaration (memory_pages.cpp#L35). shadPS4 sets a flag that lifts the EBUSY its MapMemory returns for direct memory that is already mapped. AnyPS5 has no such check: DoMapDirect only requires the physical pages to be allocated, and CheckDirectMemoryFollowsPhysicalPages already maps the same pages twice. So there is nothing to turn on, and the function returns 0. It is listed under Silent stubs in TechnicalDebt.md because check_conventions.py requires every export that only returns 0 to be listed there, but it does not hide missing behaviour: the aliasing it enables is always allowed in AnyPS5, and what differs from shadPS4, the EBUSY without the call, is a restriction rather than a feature (unverified on PS5).

The test calls it in CheckDirectMemoryFollowsPhysicalPages just before that test's second mapping of the same pages; without the export, guest_memory_tests does not link.

Tested

  • Windows 11 26300, WinLibs GCC 15.2.0 r7, Release, on main b42ef24e0: guest_memory_tests passes; with the export removed it fails to link (undefined reference to sceKernelEnableDmemAliasing).
  • Full CI on my fork, dispatched for this commit (749541f65): run 38209311400, linux and windows (build and full ctest) plus the relinker, register-context and write-watch jobs all pass.
  • ProsperoEden on Linux x86_64 (GitHub Codespaces, Xvfb, llvmpipe), main e013f8c9c plus this change:
    • It relinks only with --trap-sdk-syscall-stubs (#3804), which traps 3 SDK syscall wrappers. Under gdb no SIGILL is raised before the stop below, so none of them runs, and none of the 5 throwing stubs is called.
    • It passes the loader, logs EDEN_SPARSE_TABLES available=1 step=ok (the aliased sparse tables work) and reaches its launcher about 2.7 s after start (opening the launcher, GL 4.6 on PS5 AGC).
    • It then stops at its first present with AGC graphics: subgroup capability 61 is unsupported for shader stage 1: llvmpipe offers no vertex-stage subgroups, the device limit #1565 handles in the AGC tests, not a failure of this change.

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:4825625152 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4326). Originally posted by [winstrex](https://github.com/winstrex) on 2026-10-12T06:13:05Z. --- ### What ProsperoEden (PPSA99008, 1.000.110 from the homebrew catalog, an Eden Switch emulator port) does not load on `main` d146ec1b6: ``` ./app.elf: symbol lookup error: ./app.elf: undefined symbol: usHTMoFoBTM ``` `usHTMoFoBTM` is `sceKernelEnableDmemAliasing`, the title's only absent import (`tools/import_audit.py`: 437 implemented, 5 throwing stubs, this one absent). ProsperoEden's [public source](https://github.com/blackbearreloaded/ProsperoEden) calls it before mapping the same direct memory a second time: - [`host_memory.cpp#L164-L167`](https://github.com/blackbearreloaded/ProsperoEden/blob/5e54c306a5b235d300b2e5225e482fa6ee37dd6f/src/host_memory.cpp#L164-L167), its fast-memory window; - [`memory_pages.cpp#L159-L163`](https://github.com/blackbearreloaded/ProsperoEden/blob/5e54c306a5b235d300b2e5225e482fa6ee37dd6f/src/memory_pages.cpp#L159-L163), a read-only alias of JIT code that it then makes executable; - [`memory_pages.cpp#L339-L340`](https://github.com/blackbearreloaded/ProsperoEden/blob/5e54c306a5b235d300b2e5225e482fa6ee37dd6f/src/memory_pages.cpp#L339-L340), sparse tables whose slots all map one [zeroed block](https://github.com/blackbearreloaded/ProsperoEden/blob/5e54c306a5b235d300b2e5225e482fa6ee37dd6f/src/memory_pages.cpp#L259-L282). It ignores the result ("Reports zero regardless; the self-test checks") and checks the mappings instead. The function takes no arguments and returns `int`, as in [shadPS4](https://github.com/shadps4-emu/shadPS4/blob/e0a466753a1aacbc8db8253be685bf7ab4d9daae/src/core/libraries/kernel/memory.cpp#L39-L43) and ProsperoEden's declaration ([`memory_pages.cpp#L35`](https://github.com/blackbearreloaded/ProsperoEden/blob/5e54c306a5b235d300b2e5225e482fa6ee37dd6f/src/memory_pages.cpp#L35)). shadPS4 sets a flag that lifts the `EBUSY` its [`MapMemory`](https://github.com/shadps4-emu/shadPS4/blob/e0a466753a1aacbc8db8253be685bf7ab4d9daae/src/core/memory.cpp#L548-L553) returns for direct memory that is already mapped. AnyPS5 has no such check: `DoMapDirect` only requires the physical pages to be allocated, and `CheckDirectMemoryFollowsPhysicalPages` already maps the same pages twice. So there is nothing to turn on, and the function returns 0. It is listed under Silent stubs in TechnicalDebt.md because `check_conventions.py` requires every export that only returns 0 to be listed there, but it does not hide missing behaviour: the aliasing it enables is always allowed in AnyPS5, and what differs from shadPS4, the `EBUSY` without the call, is a restriction rather than a feature (unverified on PS5). The test calls it in `CheckDirectMemoryFollowsPhysicalPages` just before that test's second mapping of the same pages; without the export, `guest_memory_tests` does not link. ### Tested - Windows 11 26300, WinLibs GCC 15.2.0 r7, Release, on `main` b42ef24e0: `guest_memory_tests` passes; with the export removed it fails to link (undefined reference to `sceKernelEnableDmemAliasing`). - Full CI on my fork, dispatched for this commit (749541f65): [run 38209311400](https://github.com/winstrex/AnyPS5/actions/runs/38209311400), `linux` and `windows` (build and full ctest) plus the relinker, register-context and write-watch jobs all pass. - ProsperoEden on Linux x86_64 (GitHub Codespaces, Xvfb, llvmpipe), `main` e013f8c9c plus this change: - It relinks only with `--trap-sdk-syscall-stubs` (#3804), which traps 3 SDK syscall wrappers. Under gdb no SIGILL is raised before the stop below, so none of them runs, and none of the 5 throwing stubs is called. - It passes the loader, logs `EDEN_SPARSE_TABLES available=1 step=ok` (the aliased sparse tables work) and reaches its launcher about 2.7 s after start (`opening the launcher`, GL 4.6 on `PS5 AGC`). - It then stops at its first present with `AGC graphics: subgroup capability 61 is unsupported for shader stage 1`: llvmpipe offers no vertex-stage subgroups, the device limit #1565 handles in the AGC tests, not a failure of this change. ### 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 06:14:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-12T06:14:11Z.


Progress report (2ccbd37 → 749541f)

➖ System libraries: 86.55% (+0.0%, +1 implemented functions)

✅ 1 implemented
Library Name
libkernel sceKernelEnableDmemAliasing
⚪ 1 behaviourally empty (constant return or throw)
Library Name
libkernel sceKernelEnableDmemAliasing
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6118824600 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4326#issuecomment-6118824600). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-12T06:14:11Z. --- <!-- progress-report --> ### Progress report (2ccbd37 → 749541f) ➖ **System libraries**: 86.55% (+0.0%, +1 implemented functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libkernel | `sceKernelEnableDmemAliasing` | </details> <details> <summary>⚪ 1 behaviourally empty (constant return or throw)</summary> | Library | Name | | - | - | | libkernel | `sceKernelEnableDmemAliasing` | </details>
github-actions[bot] commented 2026-10-12 10:03:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-12T10:03:28Z.


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
#4411 docs/dev/TechnicalDebt.md L15-51
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6122030514 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4326#issuecomment-6122030514). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-12T10:03:28Z. --- <!-- 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 | |---|---|---|---| | #4411 | `docs/dev/TechnicalDebt.md` [L15-51](https://github.com/boykopovar/AnyPS5/blob/c3204078e4aa5adf1bfb93798c81444a99893e20/docs/dev/TechnicalDebt.md#L15-L51) | | |
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!4326
No description provided.