fix(libkernel): accept flag 0x8000 in sceKernelMapFlexibleMemory #4859

Merged
EagleBearerYS merged 1 commit from upstream-pr/4859 into main 2026-10-13 01:48:21 +00:00
EagleBearerYS commented 2026-10-13 00:27:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-13T00:27:45Z.


What

Animal Well (PPSA22520, content 01.000.011) bundles an SDK 9.04 libc.prx whose heap maps every arena with sceKernelMapFlexibleMemory(&addr, len, 3, 0x8000) (both of the module's calls to that import pass 0x8000). On main this throws in MapPlaced before the first frame:

[libc] unhandled exception 'St16invalid_argument' thrown from 00007fff899bf65b
terminate called after throwing an instance of 'std::invalid_argument'
  what():  Unsupported memory mapping flags 0x8000

#957 accepts the same flag in sceKernelMapNamedFlexibleMemoryInternal, where an older SDK 9 libc passes it. This libc imports no Internal NID and calls the public function instead (NID IWIBBdTHit4).

  • sceKernelMapFlexibleMemory now ignores 0x8000, as the Internal variant does. Other unknown flags still throw.
  • The flag's meaning is still not established. KytyPS5 (GUEST_MAP_UNKNOWN_8000) and sharpemu accept it in the named flexible map without reading it.
  • The existing technical debt entry now names both functions and lists the callers of each. This dump's libc imports no Internal NID, so PPSA22520 moves from the Internal variant's callers to sceKernelMapFlexibleMemory's.

Tested

  • Windows 11, WinLibs GCC 15.2.0 r7, Release, on main 43e3a70f8: guest_memory (new CheckFlexibleMappingIgnoresFlag8000). It maps with 0x8000 and checks the flexible memory accounting, maps again at the same address with 0x8090, and checks that 0x20000 still throws and leaves the output null.
    • With main's Export.cpp: fails with Unsupported memory mapping flags 0x8000.
    • With the change: passes, 5/5.
  • Linux (WSL2 Ubuntu 24.04, GCC 13.3, CI configuration, main 43e3a70f8): with main's Export.cpp, guest_memory aborts with the same message; with the change, 20/20 pass.
  • PPSA22520 on Windows 11 (RTX 3070 Laptop GPU): on main the run ends at 7.7 s with the log line above. With the change (on a test build that also carried #4693's crash reporter, which doesn't touch this path) it reaches the title screen, starts a new game and plays the first rooms; a 180 s run ended at the time limit with no error lines.
  • python3 tools/check_conventions.py --base origin/main: passed.

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
  • Unblocks: PPSA22520 #966
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4836616192 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4859). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-13T00:27:45Z. --- ### What Animal Well (PPSA22520, content 01.000.011) bundles an SDK 9.04 `libc.prx` whose heap maps every arena with `sceKernelMapFlexibleMemory(&addr, len, 3, 0x8000)` (both of the module's calls to that import pass 0x8000). On `main` this throws in `MapPlaced` before the first frame: ``` [libc] unhandled exception 'St16invalid_argument' thrown from 00007fff899bf65b terminate called after throwing an instance of 'std::invalid_argument' what(): Unsupported memory mapping flags 0x8000 ``` #957 accepts the same flag in `sceKernelMapNamedFlexibleMemoryInternal`, where an older SDK 9 libc passes it. This libc imports no Internal NID and calls the public function instead (NID `IWIBBdTHit4`). - `sceKernelMapFlexibleMemory` now ignores 0x8000, as the Internal variant does. Other unknown flags still throw. - The flag's meaning is still not established. KytyPS5 (`GUEST_MAP_UNKNOWN_8000`) and sharpemu accept it in the named flexible map without reading it. - The existing technical debt entry now names both functions and lists the callers of each. This dump's libc imports no Internal NID, so PPSA22520 moves from the Internal variant's callers to `sceKernelMapFlexibleMemory`'s. ### Tested - Windows 11, WinLibs GCC 15.2.0 r7, Release, on `main` 43e3a70f8: `guest_memory` (new `CheckFlexibleMappingIgnoresFlag8000`). It maps with 0x8000 and checks the flexible memory accounting, maps again at the same address with 0x8090, and checks that 0x20000 still throws and leaves the output null. - With `main`'s `Export.cpp`: fails with `Unsupported memory mapping flags 0x8000`. - With the change: passes, 5/5. - Linux (WSL2 Ubuntu 24.04, GCC 13.3, CI configuration, `main` 43e3a70f8): with `main`'s `Export.cpp`, `guest_memory` aborts with the same message; with the change, 20/20 pass. - PPSA22520 on Windows 11 (RTX 3070 Laptop GPU): on `main` the run ends at 7.7 s with the log line above. With the change (on a test build that also carried #4693's crash reporter, which doesn't touch this path) it reaches the title screen, starts a new game and plays the first rooms; a 180 s run ended at the time limit with no error lines. - `python3 tools/check_conventions.py --base origin/main`: passed. ### 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 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] Unblocks: PPSA22520 #966 - [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!4859
No description provided.