Skip to content

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

Closed
nabilfp wants to merge 1 commit into
boykopovar:mainfrom
nabilfp:fix/libkernel-named-flexible-flag
Closed

nabilfp wants to merge 1 commit into
boykopovar:mainfrom
nabilfp:fix/libkernel-named-flexible-flag

Conversation

@nabilfp

@nabilfp nabilfp commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

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

@xXPBSXx

xXPBSXx commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

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).

sceKernelMapNamedFlexibleMemory passed its flags straight to the shared
flexible mapper, so the SDK 9 heap flag 0x8000 reached the placement
code, which rejects any bit outside its supported mask and throws. The
unnamed sceKernelMapFlexibleMemory and the Internal variant both drop
that flag first, and the Internal variant is defined as the named entry
point with the flag stripped, so the named entry point rejecting it is
an inconsistency: the same caller fails through one export and succeeds
through another.

Ignore 0x8000 in the named variant too, as the other two already do, and
let the Internal variant keep delegating to it. Add a GuestMemory test
mapping through the named export with the flag set and its meaning still
unestablished, as recorded in the libkernel debt entry.
@nabilfp
nabilfp force-pushed the fix/libkernel-named-flexible-flag branch from e0b5f72 to c464c12 Compare October 13, 2026 10:05
@coltken95

Copy link
Copy Markdown

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

  • 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

nabilfp commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

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

Copy link
Copy Markdown
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants