fix(libc): reach the application map area end with the guest arena #652

Merged
Celegans12 merged 1 commit from upstream-pr/652 into main 2026-10-05 19:04:37 +00:00
Celegans12 commented 2026-10-05 11:12:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-05T11:12:42Z.


What

On Windows the guest arena ends at 0x72_0000_0000, so a fixed direct memory mapping above it throws shared mapping outside the guest arena.

  • The arena now ends at the application map area end, 0xFC_0000_0000: KytyPS5's user range ends there (HOST_USER_MAX), as does SCE_KERNEL_APP_MAP_AREA_END_ADDR in GPCS4 (PS4 reference).
  • #5 kept the arena below that end; #231 fixed it at 448 GiB from 0x2_0000_0000, the start #153 had chosen.
  • PPSA26344 v1.008 sets up its own virtual range at 0x1489dee (base 0x90_0000_0000, size 0x6c_0000_0000) and maps direct memory into it with fixed mappings, first 0x20000 bytes at 0x90_0000_0000 (prot 0xd3, flags 0x10).
  • The out-of-arena errors name the address and length; a fixed mapping over a used range says whether it hit a host region.
  • Host allocations made before libc loads (thread stacks, with high-entropy ASLR) may now sit anywhere in the arena; they stay holes, as since #231, and fixed mappings over them throw. TechnicalDebt records this and the assumed end.
  • libSceAgcDriver's write-block counters (zero-filled) grow from 84 to 188 MiB, its committed page-state table from 112 to 250 MiB.
  • #637 changes the line after this branch's message change in GuestArenaMap_nid_postfix; whichever merges second needs a one-line rebase. No behavioural overlap.

Tested

  • Windows 11, MinGW-w64 GCC 15.2.0, based on main 53dc19cf: configure -DBUILD_TESTING=ON, full build, --target libs, ctest:
  • 284/284 tests pass (ctest --output-on-failure)
  • guest_memory gains CheckFixedMappingsReachTheApplicationAreaEnd: a fixed mapping of the last two pages below 0xFC_0000_0000, read through an alias, and a refused one at the end; it fails on main at the range check.
  • PPSA26344 v1.008, past the VideoOut checks that stop it on main: without this change it aborts at that first mapping; with it, it runs on to sceAudioOut2PortCreate: data format 0xc00 is not implemented.
  • Not tested: Linux (CI), console behaviour.

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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4744021675 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/652). Originally posted by [Celegans12](https://github.com/Celegans12) on 2026-10-05T11:12:42Z. --- ### What On Windows the guest arena ends at 0x72_0000_0000, so a fixed direct memory mapping above it throws `shared mapping outside the guest arena`. - The arena now ends at the application map area end, 0xFC_0000_0000: KytyPS5's user range ends there ([`HOST_USER_MAX`](https://github.com/KytyPS5/KytyPS5/blob/72e4989b1e1643c9237ba68ae4e3fe77fa489c63/src/kernel/memoryAddressSpace.inc#L13)), as does `SCE_KERNEL_APP_MAP_AREA_END_ADDR` in [GPCS4](https://github.com/Inori/GPCS4/blob/88480de36f983c66f7dd2c5951fead1a740d47a5/GPCS4/SceModules/SceLibkernel/sce_kernel_memory.h#L56) (PS4 reference). - #5 kept the arena below that end; #231 fixed it at 448 GiB from 0x2_0000_0000, the start #153 had chosen. - PPSA26344 v1.008 sets up its own virtual range at 0x1489dee (base 0x90_0000_0000, size 0x6c_0000_0000) and maps direct memory into it with fixed mappings, first 0x20000 bytes at 0x90_0000_0000 (prot 0xd3, flags 0x10). - The out-of-arena errors name the address and length; a fixed mapping over a used range says whether it hit a host region. - Host allocations made before libc loads (thread stacks, with high-entropy ASLR) may now sit anywhere in the arena; they stay holes, as since #231, and fixed mappings over them throw. TechnicalDebt records this and the assumed end. - libSceAgcDriver's write-block counters (zero-filled) grow from 84 to 188 MiB, its committed page-state table from 112 to 250 MiB. - #637 changes the line after this branch's message change in `GuestArenaMap_nid_postfix`; whichever merges second needs a one-line rebase. No behavioural overlap. ### Tested - Windows 11, MinGW-w64 GCC 15.2.0, based on `main` 53dc19cf: configure `-DBUILD_TESTING=ON`, full build, `--target libs`, `ctest`: - 284/284 tests pass (`ctest --output-on-failure`) - `guest_memory` gains `CheckFixedMappingsReachTheApplicationAreaEnd`: a fixed mapping of the last two pages below 0xFC_0000_0000, read through an alias, and a refused one at the end; it fails on `main` at the range check. - PPSA26344 v1.008, past the VideoOut checks that stop it on `main`: without this change it aborts at that first mapping; with it, it runs on to `sceAudioOut2PortCreate: data format 0xc00 is not implemented`. - Not tested: Linux (CI), console behaviour. ### 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](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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 - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-05 13:32:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-05T13:32:29Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#637 core/libs/prx/libc/src/GuestArena.cpp L211-212
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5995514137 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/652#issuecomment-5995514137). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-05T13:32:29Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #637 | `core/libs/prx/libc/src/GuestArena.cpp` [L211-212](https://github.com/boykopovar/AnyPS5/blob/78c17a1d478a2113203106d57d9a2b2245e754bd/core/libs/prx/libc/src/GuestArena.cpp#L211-L212) | | |
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!652
No description provided.