feat(libkernel): accept flag 0x8000 in sceKernelMapNamedFlexibleMemoryInternal #957

Merged
JAB-dev merged 2 commits from upstream-pr/957 into main 2026-10-08 05:42:57 +00:00
JAB-dev commented 2026-10-06 20:25:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JAB-dev on 2026-10-06T20:25:04Z.


What

Follows #355, which added sceKernelMapNamedFlexibleMemoryInternal and deliberately left flag 0x8000 throwing because its meaning was unknown. Every known caller is the heap of the SDK 9 libc.prx that titles bundle. It calls (&addr, len, 3, 0x8000, name) at three sites, where an older libc.prx passes flags 0 to sceKernelMapNamedFlexibleMemory. So every title with that libc still stops at its first allocation.

  • The flag's meaning is still not established. Two reimplementations accept it without reading it:
    • KytyPS5 names it GUEST_MAP_UNKNOWN_8000 and includes it in SUPPORTED_MAP_BITS of its KernelMapNamedFlexibleMemory.
    • sharpemu's allowed mask (0xFF408490) contains it, and its Internal export forwards to the public function.
  • The flag is now accepted and ignored for the Internal variant only, where it has been seen. sceKernelMapNamedFlexibleMemory and the other mapping calls still throw on it, and other unknown flags still throw through the Internal variant too.
  • The TechnicalDebt entry is updated with the references and the known callers.

Tested

  • Windows 11, WinLibs GCC 15.2.0 r7, Release. guest_memory CheckInternalNamedFlexibleMapping:
    • maps with 0x8000, checks the name and writes the last byte;
    • checks the flexible memory accounting and unmaps;
    • checks that an unknown flag (0x20000) still throws and leaves the address null.
  • With main's Export.cpp the test fails with Unsupported memory mapping flags 0x8000.
  • Full ctest on this branch alone (on top of main): 357/357.
  • Seen in PPSA22520 (Animal Well): the bundled libc heap initializes and the title boots.
  • Linux not tested.

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

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4764241041 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/957). Originally posted by [JAB-dev](https://github.com/JAB-dev) on 2026-10-06T20:25:04Z. --- ### What Follows #355, which added `sceKernelMapNamedFlexibleMemoryInternal` and deliberately left flag `0x8000` throwing because its meaning was unknown. Every known caller is the heap of the SDK 9 `libc.prx` that titles bundle. It calls `(&addr, len, 3, 0x8000, name)` at three sites, where an older `libc.prx` passes flags 0 to `sceKernelMapNamedFlexibleMemory`. So every title with that libc still stops at its first allocation. - The flag's meaning is still not established. Two reimplementations accept it without reading it: - KytyPS5 names it `GUEST_MAP_UNKNOWN_8000` and includes it in `SUPPORTED_MAP_BITS` of its `KernelMapNamedFlexibleMemory`. - sharpemu's allowed mask (`0xFF408490`) contains it, and its Internal export forwards to the public function. - The flag is now accepted and ignored for the Internal variant only, where it has been seen. `sceKernelMapNamedFlexibleMemory` and the other mapping calls still throw on it, and other unknown flags still throw through the Internal variant too. - The TechnicalDebt entry is updated with the references and the known callers. ### Tested - Windows 11, WinLibs GCC 15.2.0 r7, Release. `guest_memory` `CheckInternalNamedFlexibleMapping`: - maps with `0x8000`, checks the name and writes the last byte; - checks the flexible memory accounting and unmaps; - checks that an unknown flag (`0x20000`) still throws and leaves the address null. - With `main`'s `Export.cpp` the test fails with `Unsupported memory mapping flags 0x8000`. - Full ctest on this branch alone (on top of `main`): 357/357. - Seen in PPSA22520 (Animal Well): the bundled libc heap initializes and the title boots. - Linux not tested. ### 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 🤖 Generated with [Claude Code](https://claude.com/claude-code)
fisherjoey commented 2026-10-08 05:24:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fisherjoey on 2026-10-08T05:24:40Z.


This looks like the same change as #1392: both make sceKernelMapNamedFlexibleMemoryInternal accept flag 0x8000, here by masking it in DirectMemory/Export.cpp (IgnoredInternalFlag), there by adding it to SupportedFlags. Both extend tests/GuestMemory.cpp. Linking so they can be compared.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6052973156 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/957#issuecomment-6052973156). Originally posted by [fisherjoey](https://github.com/fisherjoey) on 2026-10-08T05:24:40Z. --- This looks like the same change as #1392: both make `sceKernelMapNamedFlexibleMemoryInternal` accept flag `0x8000`, here by masking it in `DirectMemory/Export.cpp` (`IgnoredInternalFlag`), there by adding it to `SupportedFlags`. Both extend `tests/GuestMemory.cpp`. Linking so they can be compared.
adriadam10 commented 2026-10-08 05:42:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-08T05:42:53Z.


Checked build + full ctest on top of current main (413/413), and that guest_memory fails without the Export.cpp change. The flag is accepted only through the Internal variant, other unknown flags still throw, and KytyPS5's GUEST_MAP_UNKNOWN_8000 matches the PR's description. TechnicalDebt entry is in place; linux and windows CI are green. Merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6053207101 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/957#issuecomment-6053207101). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-08T05:42:53Z. --- Checked build + full ctest on top of current main (413/413), and that `guest_memory` fails without the `Export.cpp` change. The flag is accepted only through the Internal variant, other unknown flags still throw, and KytyPS5's `GUEST_MAP_UNKNOWN_8000` matches the PR's description. TechnicalDebt entry is in place; linux and windows CI are green. 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!957
No description provided.