fix(libkernel): accept flag 0x8000 in sceKernelMapNamedFlexibleMemory #4896

Closed
nabilfp wants to merge 1 commit from upstream-pr/4896 into main
nabilfp commented 2026-10-13 02:37:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by nabilfp on 2026-10-13T02:37:55Z.


What

sceKernelMapNamedFlexibleMemory passed its flags straight to the shared flexible-mapper, so the SDK 9 heap flag 0x8000 reached MapPlaced, which rejects any bit outside its supported mask and throws:

Unsupported memory mapping flags 0x8000

The two sibling entry points already ignore it: sceKernelMapFlexibleMemory masks it off before _mapFlexible, and sceKernelMapNamedFlexibleMemoryInternal is defined as the named call with the flag stripped. So the same caller succeeds through one export and throws through another, which is the inconsistency this fixes.

The named variant now drops 0x8000 too, and the Internal variant keeps delegating to it without its own copy of the mask. The libkernel debt entry that records flag 0x8000 as accepted-and-ignored now lists the named variant alongside the other two.

Tested

Not tested on a console. The added GuestMemory case maps through the named export with 0x8000 set and checks the mapping and its range name; the existing cases for the unnamed and Internal variants (including the 0x20000 rejection) are unchanged. g++ -std=c++20 -fsyntax-only on the changed C++ files and tools/check_conventions.py --base upstream/main pass.

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: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4837558000 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4896). Originally posted by [nabilfp](https://github.com/nabilfp) on 2026-10-13T02:37:55Z. --- ### What `sceKernelMapNamedFlexibleMemory` passed its `flags` straight to the shared flexible-mapper, so the SDK 9 heap flag `0x8000` reached `MapPlaced`, which rejects any bit outside its supported mask and throws: ``` Unsupported memory mapping flags 0x8000 ``` The two sibling entry points already ignore it: `sceKernelMapFlexibleMemory` masks it off before `_mapFlexible`, and `sceKernelMapNamedFlexibleMemoryInternal` is defined as the named call with the flag stripped. So the same caller succeeds through one export and throws through another, which is the inconsistency this fixes. The named variant now drops `0x8000` too, and the Internal variant keeps delegating to it without its own copy of the mask. The libkernel debt entry that records flag `0x8000` as accepted-and-ignored now lists the named variant alongside the other two. ### Tested Not tested on a console. The added `GuestMemory` case maps through the named export with `0x8000` set and checks the mapping and its range name; the existing cases for the unnamed and Internal variants (including the `0x20000` rejection) are unchanged. `g++ -std=c++20 -fsyntax-only` on the changed C++ files and `tools/check_conventions.py --base upstream/main` pass. ### 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: none - [x] AI-assisted: yes
xXPBSXx commented 2026-10-13 08:20:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-13T08:20:47Z.


Windows test of this PR.

Environment: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, BUILD_TESTING=ON, -j2, libusb-cmake from a local checkout. Built from main c2565f014 with this PR and ten other open PRs (#4972, #4967, #4966, #4945, #4938, #4936, #4933, #4898, #4896, #4888) merged together; the merges had no conflict.

Result: guest_memory (1 of 1) pass.

Not checked: whether the test fails without the change in the library code; the PR was not tested alone, only in the combined merge; no title run; Linux not tested.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6141387827 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4896#issuecomment-6141387827). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-13T08:20:47Z. --- Windows test of this PR. Environment: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, `BUILD_TESTING=ON`, `-j2`, `libusb-cmake` from a local checkout. Built from `main` `c2565f014` with this PR and ten other open PRs (#4972, #4967, #4966, #4945, #4938, #4936, #4933, #4898, #4896, #4888) merged together; the merges had no conflict. Result: guest_memory (1 of 1) pass. Not checked: whether the test fails without the change in the library code; the PR was not tested alone, only in the combined merge; no title run; Linux not tested. AI-assisted (Claude Code).
coltken95 commented 2026-10-13 12:04:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by coltken95 on 2026-10-13T12:04:07Z.


Tested on Linux x86-64 (Release build), with c464c1216 cherry-picked onto main 5d50886ee:

  • With the PR: guest_memory passes.
  • With main's DirectMemory/Export.cpp and the PR's test: guest_memory aborts with
    std::invalid_argument: Unsupported memory mapping flags 0x8000
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6145118844 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4896#issuecomment-6145118844). Originally posted by [coltken95](https://github.com/coltken95) on 2026-10-13T12:04:07Z. --- Tested on Linux x86-64 (Release build), with c464c1216 cherry-picked onto main 5d50886ee: - With the PR: `guest_memory` passes. - With main's `DirectMemory/Export.cpp` and the PR's test: `guest_memory` aborts with `std::invalid_argument: Unsupported memory mapping flags 0x8000`
nabilfp commented 2026-10-13 12:15:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by nabilfp on 2026-10-13T12:15:20Z.


Thanks for the Linux verification. The tested head c464c1216 is the current head of this branch, so the result stands: guest_memory passes with the change and aborts on main with the PR's test (Unsupported memory mapping flags 0x8000). That is the fail-on-main / pass-with-fix evidence the PR was missing. Appreciated.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6145310446 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4896#issuecomment-6145310446). Originally posted by [nabilfp](https://github.com/nabilfp) on 2026-10-13T12:15:20Z. --- Thanks for the Linux verification. The tested head `c464c1216` is the current head of this branch, so the result stands: `guest_memory` passes with the change and aborts on `main` with the PR's test (`Unsupported memory mapping flags 0x8000`). That is the fail-on-main / pass-with-fix evidence the PR was missing. Appreciated.
oneandonlydean commented 2026-10-14 02:36:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T02:36:38Z.


Closing: no title is known to reach this. With the queue at 700+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6159630771 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4896#issuecomment-6159630771). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T02:36:38Z. --- Closing: no title is known to reach this. With the queue at 700+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line.

Pull request closed

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!4896
No description provided.