Skip to content

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

Merged
adriadam10 merged 2 commits into
boykopovar:mainfrom
JAB-dev:feat/kernel-flexible-internal-hint
Oct 8, 2026
Merged

adriadam10 merged 2 commits into
boykopovar:mainfrom
JAB-dev:feat/kernel-flexible-internal-hint

Conversation

@JAB-dev

@JAB-dev JAB-dev commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

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

…yInternal

The SDK 9 libc.prx heap maps its arenas with flag 0x8000, which threw as
an unsupported flag. The flag is ignored for this function, as sharpemu
does; other unknown flags still throw.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added libkernel docs needs rebase Conflicts with main, rebase needed labels Oct 6, 2026
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 7, 2026
@fisherjoey

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Collaborator

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.

@adriadam10
adriadam10 merged commit 311c049 into boykopovar:main Oct 8, 2026
3 checks passed
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.

3 participants