docs(libkernel): record flexible memory flag 0x8000 as measured on a PS5 #10305

Merged
orezraey merged 6 commits from upstream-pr/10305 into main 2026-10-26 16:04:25 +00:00
orezraey commented 2026-10-23 16:58:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by orezraey on 2026-10-23T16:58:22Z.


What

Flag 0x8000 of the flexible memory maps, measured on a retail PS5 (firmware 13.60) through libkernel_sys.sprx from a payload process. The source and console log are in this gist (pflex8000). The debt entry said only that its meaning is not established.

On the console:

  • sceKernelMapNamedFlexibleMemoryInternal accepts 0x8000, and the mapping's address, sceKernelVirtualQuery record and sceKernelQueryMemoryProtection answer are the same as without it, so it has no visible effect there;
  • sceKernelMapFlexibleMemory and sceKernelMapNamedFlexibleMemory fail 0x8000 with EINVAL (0x80020016); sceKernelMapFlexibleMemory does so for every size and protection tried, and fails every other single flag tried from 0x1 to 0x100000 except 0x80 (0x10, MAP_FIXED, was not tried).

AnyPS5 accepts and ignores 0x8000 in sceKernelMapFlexibleMemory and sceKernelMapNamedFlexibleMemoryInternal, and throws for it in sceKernelMapNamedFlexibleMemory and for the other rejected flags in all three, as before. It keeps accepting 0x8000 in the first two: PPSA22520 01.000.011 passes 0x8000 to sceKernelMapFlexibleMemory, so a title is likely allowed what this payload process is not (its SDK version is the probable difference, which this probe could not show). Only the debt entry changes, to record the measurement and why the rejection is not reproduced.

Tested

  • Head after merging main (504ea3b53b, with #10794): 0850552608. Kept #10794's pthread_main_np and scePthreadMain entry and this PR's measured 0x8000 entry; check_conventions passes.
  • Head after merging main (cf528e78c6, with #9160): 336a738f91. Kept #9160's pthread_main_np entry and this PR's measured 0x8000 entry. Documentation only; check_conventions and pr_overlap pass.
    Not tested: documentation only (head 8ed4ce86cb).
  • The debt entry is 987 characters.
  • tools/check_conventions.py passes.
  • tools/pr_overlap.py: #9160 edit nearby libkernel.md lines; whichever lands second keeps both.

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 (#10794, which edited the adjacent pthread_main_np line, has merged and main is merged in)
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4986352732 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10305). Originally posted by [orezraey](https://github.com/orezraey) on 2026-10-23T16:58:22Z. --- ### What Flag 0x8000 of the flexible memory maps, measured on a retail PS5 (firmware 13.60) through `libkernel_sys.sprx` from a payload process. The source and console log are in [this gist](https://gist.github.com/orezraey/95e052751bbc5c199202630c9c0244da) (`pflex8000`). The debt entry said only that its meaning is not established. On the console: - `sceKernelMapNamedFlexibleMemoryInternal` accepts 0x8000, and the mapping's address, `sceKernelVirtualQuery` record and `sceKernelQueryMemoryProtection` answer are the same as without it, so it has no visible effect there; - `sceKernelMapFlexibleMemory` and `sceKernelMapNamedFlexibleMemory` fail 0x8000 with `EINVAL` (0x80020016); `sceKernelMapFlexibleMemory` does so for every size and protection tried, and fails every other single flag tried from 0x1 to 0x100000 except 0x80 (0x10, `MAP_FIXED`, was not tried). AnyPS5 accepts and ignores 0x8000 in `sceKernelMapFlexibleMemory` and `sceKernelMapNamedFlexibleMemoryInternal`, and throws for it in `sceKernelMapNamedFlexibleMemory` and for the other rejected flags in all three, as before. It keeps accepting 0x8000 in the first two: PPSA22520 01.000.011 passes 0x8000 to `sceKernelMapFlexibleMemory`, so a title is likely allowed what this payload process is not (its SDK version is the probable difference, which this probe could not show). Only the debt entry changes, to record the measurement and why the rejection is not reproduced. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> - Head after merging `main` (`504ea3b53b`, with #10794): `0850552608`. Kept #10794's `pthread_main_np and scePthreadMain` entry and this PR's measured 0x8000 entry; `check_conventions` passes. - Head after merging `main` (`cf528e78c6`, with #9160): `336a738f91`. Kept #9160's `pthread_main_np` entry and this PR's measured 0x8000 entry. Documentation only; `check_conventions` and `pr_overlap` pass. Not tested: documentation only (head `8ed4ce86cb`). - The debt entry is 987 characters. - `tools/check_conventions.py` passes. - `tools/pr_overlap.py`: #9160 edit nearby `libkernel.md` lines; whichever lands second keeps both. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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 (#10794, which edited the adjacent `pthread_main_np` line, has merged and `main` is merged in) - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
harisibrar1 commented 2026-10-24 15:44:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by harisibrar1 on 2026-10-24T15:44:35Z.

Review: COMMENTED


Checked against main c9b75825f3 and the linked gist (pflex8000.c / pflex8000.log), plus DirectMemory/Export.cpp and DirectMemory/DirectMemory.cpp on main:

  • The console results in the description match the log: the 0x8000 rejections across sizes and prots, every single flag 0x1 to 0x100000 except 0x80 (0x10 untried), and the Internal mapping identical to flags 0. The branch still merges cleanly.
  • "which all three accept here" doesn't match main. MapPlaced (DirectMemory.cpp:789-799) throws invalid_argument("Unsupported memory mapping flags …") for any flag outside 0x10 | 0x80 | 0x400000, so the other flags in that list throw in all three functions. And sceKernelMapNamedFlexibleMemory passes flags through unchanged (Export.cpp:288-292), so it throws on 0x8000 as well; only sceKernelMapFlexibleMemory and the Internal variant strip it.
  • Maybe: "…except 0x80 (0x10 was not tried); here those flags, and 0x8000 in sceKernelMapNamedFlexibleMemory, throw. 0x8000 is accepted in the other two because PPSA22520 01.000.011 passes it to sceKernelMapFlexibleMemory."
  • Small question: the rewrite drops the KytyPS5 (GUEST_MAP_UNKNOWN_8000) and sharpemu references, and the note on how the libc.prx heap uses the mapping. Was that intended? They seem like useful support for keeping 0x8000 ignored.

Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5638830104 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10305#pullrequestreview-5638830104). Originally posted by [harisibrar1](https://github.com/harisibrar1) on 2026-10-24T15:44:35Z. **Review:** COMMENTED --- Checked against main c9b75825f3 and the linked gist (`pflex8000.c` / `pflex8000.log`), plus `DirectMemory/Export.cpp` and `DirectMemory/DirectMemory.cpp` on main: - The console results in the description match the log: the 0x8000 rejections across sizes and prots, every single flag 0x1 to 0x100000 except 0x80 (0x10 untried), and the Internal mapping identical to flags 0. The branch still merges cleanly. - "which all three accept here" doesn't match main. `MapPlaced` (`DirectMemory.cpp:789-799`) throws `invalid_argument("Unsupported memory mapping flags …")` for any flag outside `0x10 | 0x80 | 0x400000`, so the other flags in that list throw in all three functions. And `sceKernelMapNamedFlexibleMemory` passes flags through unchanged (`Export.cpp:288-292`), so it throws on 0x8000 as well; only `sceKernelMapFlexibleMemory` and the Internal variant strip it. - Maybe: "…except 0x80 (0x10 was not tried); here those flags, and 0x8000 in `sceKernelMapNamedFlexibleMemory`, throw. 0x8000 is accepted in the other two because PPSA22520 01.000.011 passes it to `sceKernelMapFlexibleMemory`." - Small question: the rewrite drops the KytyPS5 (`GUEST_MAP_UNKNOWN_8000`) and sharpemu references, and the note on how the libc.prx heap uses the mapping. Was that intended? They seem like useful support for keeping 0x8000 ignored. Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.
harisibrar1 commented 2026-10-24 16:37:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by harisibrar1 on 2026-10-24T16:37:24Z.

Review: APPROVED


Re-checked head 8ed4ce86cb against main feb5059ac4:

  • The entry now matches main: the other flags, and 0x8000 in sceKernelMapNamedFlexibleMemory, throw (MapPlaced in DirectMemory.cpp; the named variant passes flags through), and 0x8000 is accepted only in sceKernelMapFlexibleMemory and the Internal variant, with PPSA22520 given as the reason.
  • The KytyPS5/sharpemu references and the libc.prx heap usage are back, alongside the 13.60 measurements, which all match the gist log.
  • It still merges cleanly into main. Thanks, LGTM.

Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5638985784 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10305#pullrequestreview-5638985784). Originally posted by [harisibrar1](https://github.com/harisibrar1) on 2026-10-24T16:37:24Z. **Review:** APPROVED --- Re-checked head 8ed4ce86cb against main feb5059ac4: - The entry now matches main: the other flags, and 0x8000 in `sceKernelMapNamedFlexibleMemory`, throw (`MapPlaced` in DirectMemory.cpp; the named variant passes flags through), and 0x8000 is accepted only in `sceKernelMapFlexibleMemory` and the Internal variant, with PPSA22520 given as the reason. - The KytyPS5/sharpemu references and the libc.prx heap usage are back, alongside the 13.60 measurements, which all match the gist log. - It still merges cleanly into main. Thanks, LGTM. Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.
MarcZX10 commented 2026-10-24 21:16:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T21:16:24Z.

Review: DISMISSED


I checked the referenced probe log. It supports the stated distinction: sceKernelMapFlexibleMemory and sceKernelMapNamedFlexibleMemory return 0x80020016 for 0x8000; the Internal variant succeeds, and its address, VirtualQuery span/tail, and reported protection match the zero-flag call. The caveat for the untried 0x10 flag and the payload-process scope are also retained.

The remaining step is integration: #9160 is still open, and this branch is based on e93ec68, 7,529 commits behind current main; docs/dev/debt/libkernel.md has changed since. Please refresh after the stated merge-order dependency lands, keep the measured distinction intact, and rerun conventions/overlap checks on the final head. This is documentation-only, so no runtime test is needed.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5640064108 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10305#pullrequestreview-5640064108). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T21:16:24Z. **Review:** DISMISSED --- I checked the referenced probe log. It supports the stated distinction: `sceKernelMapFlexibleMemory` and `sceKernelMapNamedFlexibleMemory` return `0x80020016` for `0x8000`; the Internal variant succeeds, and its address, `VirtualQuery` span/tail, and reported protection match the zero-flag call. The caveat for the untried `0x10` flag and the payload-process scope are also retained. The remaining step is integration: #9160 is still open, and this branch is based on `e93ec68`, 7,529 commits behind current `main`; `docs/dev/debt/libkernel.md` has changed since. Please refresh after the stated merge-order dependency lands, keep the measured distinction intact, and rerun conventions/overlap checks on the final head. This is documentation-only, so no runtime test is needed.
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!10305
No description provided.