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

Closed
authurtabo-byte wants to merge 1 commit from upstream-pr/1392 into main
authurtabo-byte commented 2026-10-08 01:37:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by authurtabo-byte on 2026-10-08T01:37:19Z.


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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4780600640 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1392). Originally posted by [authurtabo-byte](https://github.com/authurtabo-byte) on 2026-10-08T01:37:19Z. --- ### 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](https://github.com/Inori/GPCS4/blob/master/GPCS4/SceModules/SceLibkernel/sce_kernel_memory.h) and [fpPS4](https://github.com/red-prig/fpPS4/blob/master/rtl/mmap.pas), 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](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md), 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 - [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 - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in TechnicalDebt - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
6639835 commented 2026-10-08 02:32:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by 6639835 on 2026-10-08T02:32:16Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5450703472 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1392#pullrequestreview-5450703472). Originally posted by [6639835](https://github.com/6639835) on 2026-10-08T02:32:16Z. **Review:** COMMENTED --- 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 commented 2026-10-08 03:26:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-08T03:26:22Z.


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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6051545866 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1392#issuecomment-6051545866). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-08T03:26:22Z. --- 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 commented 2026-10-08 04:53:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by authurtabo-byte on 2026-10-08T04:53:50Z.


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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6052563534 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1392#issuecomment-6052563534). Originally posted by [authurtabo-byte](https://github.com/authurtabo-byte) on 2026-10-08T04:53:50Z. --- 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 commented 2026-10-08 05:24:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fisherjoey on 2026-10-08T05:24:41Z.


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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6052973387 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1392#issuecomment-6052973387). Originally posted by [fisherjoey](https://github.com/fisherjoey) on 2026-10-08T05:24:41Z. --- 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.
oneandonlydean commented 2026-10-08 06:37:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-08T06:37:10Z.


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

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6054008778 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1392#issuecomment-6054008778). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-08T06:37:10Z. --- Closing: #957, merged this morning, already accepts 0x8000 in `sceKernelMapNamedFlexibleMemoryInternal`. If PPSA28502 still stops on main, please reopen with 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!1392
No description provided.