Skip to content

fix(libkernel): ignore unrecognised virtual memory mapping flags - #1392

Closed
authurtabo-byte wants to merge 1 commit into
boykopovar:mainfrom
authurtabo-byte:fix/libkernel-map-flags
Closed

authurtabo-byte wants to merge 1 commit into
boykopovar:mainfrom
authurtabo-byte:fix/libkernel-map-flags

Conversation

@authurtabo-byte

@authurtabo-byte authurtabo-byte commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

What

sceKernelMapNamedFlexibleMemory (via _mapFlexible → DoMapAnon → MapPlaced) threw Unsupported memory mapping flags for flag bit 0x8000, which the guest libc sets on its heap mappings, so titles aborted at startup.

0x8000 is not a documented SCE_KERNEL_MAP_* flag: the flag set is taken from GPCS4 and fpPS4, and no console flag is defined at 0x8000. MapPlaced now accepts 0x8000 alongside the flags that change behaviour (SCE_KERNEL_MAP_FIXED 0x10, SCE_KERNEL_MAP_NO_OVERWRITE 0x80, SCE_KERNEL_MAP_NO_COALESCE 0x400000); any other unrecognised bit is still rejected. Recorded in technical debt, updating the existing sceKernelMapNamedFlexibleMemoryInternal entry.

Tested

Windows 11, Pure Pool Pro (PPSA28502). Before: the title aborted in MapPlaced on its first libc heap mapping. After: it maps its heap, opens Out.log and /app0/, allocates 1 GiB of direct memory and starts its engine thread pool. guest_memory passes.

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
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes

@6639835 6639835 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed three patches at cbf4c50. MapPlaced removes unknown-bit rejection while retaining FIXED handling/known constants. Tests map observed 0x8000 and separate 0x10000000 flags, unmap both and restore flexible memory. No defect found within this patch scope. Guest-memory tests/builds and console behavior were not verified; other flags depend on stated compatibility assumptions.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

Please accept 0x8000 only and keep the throw for other unknown bits: add it to SupportedFlags in MapPlaced (DirectMemory.cpp:454 on main) instead of removing the check, and keep a test that expects a throw for 0x10000000. Main already has a TechnicalDebt line for 0x8000 (under sceKernelMapNamedFlexibleMemoryInternal); update that one instead of adding a new entry. The branch also needs a rebase for TechnicalDebt.md.

@authurtabo-byte
authurtabo-byte force-pushed the fix/libkernel-map-flags branch from cbf4c50 to d2de4ce Compare October 8, 2026 04:53
@authurtabo-byte

Copy link
Copy Markdown
Contributor Author

Done — rebased onto current main and applied the requested change:

  • MapPlaced now adds 0x8000 to SupportedFlags and keeps the throw for every other unrecognised bit; the rejection check is back.
  • GuestMemory.cpp keeps the 0x8000 success case and restores the expectation that 0x10000000 throws.
  • The existing sceKernelMapNamedFlexibleMemoryInternal TechnicalDebt line is updated instead of adding a new entry, and the rebase conflict in TechnicalDebt.md is resolved.

guest_memory passes. Thanks for the precise review.

@fisherjoey

Copy link
Copy Markdown
Contributor

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

@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed needs rebase Conflicts with main, rebase needed labels Oct 8, 2026
@oneandonlydean

Copy link
Copy Markdown
Collaborator

Closing: #957, merged this morning, already accepts 0x8000 in sceKernelMapNamedFlexibleMemoryInternal. If PPSA28502 still stops on main, please reopen with the log line.

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

Labels

docs libkernel needs rebase Conflicts with main, rebase needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants