fix(libkernel): report a 256 GiB AMM range starting on a 64 GiB boundary #6437

Merged
fma-rc merged 1 commit from upstream-pr/6437 into main 2026-10-18 07:03:10 +00:00
fma-rc commented 2026-10-15 15:14:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-15T15:14:49Z.


What

sceAmprAmmGetVirtualAddressRanges reported a 32 GiB AMM range. Death Stranding 2 (PPSA02015, 01.015.000) starts its main heap 64 GiB above the reported start, so on current main it stops after 1 s:

Fatal error occurred: VirtualMemory: Out of address space allocating 1626341376 bytes aligned to 2097152.

The title sets its heap cursor to start + 0x1000000000. Its small-block pools sit at start + 16 GiB, one per 256 MiB, and its realloc tells a pool pointer from a heap pointer by ((ptr & 0xff0000000) - 0x400000000) >> 28 <= 0x17, which only works when the start is a multiple of 64 GiB.

This reports a 256 GiB range followed by the 32 GiB multimap range, with the start on a 64 GiB boundary. DS2's AMM use reached 84 GiB above the start in its first 160 s. KytyPS5 reports 512 GiB, and I tried that first, but the guest arena is 64 to 1008 GiB, so every 64 GiB-aligned 544 GiB window covers 448 to 608 GiB, and on Windows one host thread stack there was enough to block it: guest_ampr_markers failed 17 of 100 runs in my Windows VM, and passes 100 of 100 with 256 + 32 GiB. The console's values are not known; the TechnicalDebt entry says so. If someone has them from a console, I would rather use those.

Tested

Linux (Arch, GCC 16.2.1): guest_amm_placement, guest_ampr_markers, guest_ampr_threads and guest_ampr_cpp_error pass on an RTX 5080, on a Radeon 610M (RADV) and on lavapipe on main ff23657f3 with this change, and again on main 92e50418f. guest_amm_placement fails with main's Apr.cpp (AMM ranges are not a 256 GiB range and an adjacent 32 GiB multimap range). Windows Server 2025 VM, WinLibs GCC 15.2: the full ctest suite shows no new failure, and guest_ampr_markers passed 100 of 100 runs.

Ratchet & Clank: Rift Apart (PPSA01474), which also uses AMM, runs the same 180 s without a stop on main and with this change (my earlier issue #3146 was about its maps and the AMM range). Death Stranding 2 on main with this change runs past the AMM stop to 24.5 s, where it stops on FLAT address register range overflow, which PR 5426 fixes.

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
  • Unblocks: PPSA02015 #5424
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4875524308 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6437). Originally posted by [fma-rc](https://github.com/fma-rc) on 2026-10-15T15:14:49Z. --- ### What `sceAmprAmmGetVirtualAddressRanges` reported a 32 GiB AMM range. Death Stranding 2 (PPSA02015, 01.015.000) starts its main heap 64 GiB above the reported start, so on current `main` it stops after 1 s: ``` Fatal error occurred: VirtualMemory: Out of address space allocating 1626341376 bytes aligned to 2097152. ``` The title sets its heap cursor to start + 0x1000000000. Its small-block pools sit at start + 16 GiB, one per 256 MiB, and its `realloc` tells a pool pointer from a heap pointer by `((ptr & 0xff0000000) - 0x400000000) >> 28 <= 0x17`, which only works when the start is a multiple of 64 GiB. This reports a 256 GiB range followed by the 32 GiB multimap range, with the start on a 64 GiB boundary. DS2's AMM use reached 84 GiB above the start in its first 160 s. KytyPS5 reports 512 GiB, and I tried that first, but the guest arena is 64 to 1008 GiB, so every 64 GiB-aligned 544 GiB window covers 448 to 608 GiB, and on Windows one host thread stack there was enough to block it: `guest_ampr_markers` failed 17 of 100 runs in my Windows VM, and passes 100 of 100 with 256 + 32 GiB. The console's values are not known; the TechnicalDebt entry says so. If someone has them from a console, I would rather use those. ### Tested Linux (Arch, GCC 16.2.1): `guest_amm_placement`, `guest_ampr_markers`, `guest_ampr_threads` and `guest_ampr_cpp_error` pass on an RTX 5080, on a Radeon 610M (RADV) and on lavapipe on `main` ff23657f3 with this change, and again on `main` 92e50418f. `guest_amm_placement` fails with `main`'s `Apr.cpp` (`AMM ranges are not a 256 GiB range and an adjacent 32 GiB multimap range`). Windows Server 2025 VM, WinLibs GCC 15.2: the full ctest suite shows no new failure, and `guest_ampr_markers` passed 100 of 100 runs. Ratchet & Clank: Rift Apart (PPSA01474), which also uses AMM, runs the same 180 s without a stop on `main` and with this change (my earlier issue #3146 was about its maps and the AMM range). Death Stranding 2 on `main` with this change runs past the AMM stop to 24.5 s, where it stops on `FLAT address register range overflow`, which PR 5426 fixes. ### 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 under Silent stubs in their library's technical 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 - [x] Unblocks: PPSA02015 #5424 - [x] GPUs tested: n/a - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-15 15:33:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T15:33:57Z.


Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 4630 docs/dev/debt/libkernel.md
PR 5021 docs/dev/debt/libkernel.md
PR 5918 docs/dev/debt/libkernel.md
PR 5999 docs/dev/debt/libkernel.md
PR 6044 core/libs/tests/GuestAmmPlacement.cpp
PR 6222 docs/dev/debt/libkernel.md
PR 6510 docs/dev/debt/libkernel.md
PR 6534 docs/dev/debt/libkernel.md
PR 6908 docs/dev/debt/libkernel.md
PR 6977 docs/dev/debt/libkernel.md
PR 7039 docs/dev/debt/libkernel.md
PR 7049 docs/dev/debt/libkernel.md
PR 7075 docs/dev/debt/libkernel.md
PR 7088 docs/dev/debt/libkernel.md
PR 7121 docs/dev/debt/libkernel.md
PR 7129 docs/dev/debt/libkernel.md
PR 7135 docs/dev/debt/libkernel.md
PR 7192 docs/dev/debt/libkernel.md
PR 7273 docs/dev/debt/libkernel.md
PR 7332 core/libs/tests/GuestAmmPlacement.cpp
docs/dev/debt/libkernel.md
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6195898991 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6437#issuecomment-6195898991). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-15T15:33:57Z. --- <!-- pr-overlap --> Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 4630](https://www.github.com/boykopovar/AnyPS5/pull/4630) | `docs/dev/debt/libkernel.md` | | [PR 5021](https://www.github.com/boykopovar/AnyPS5/pull/5021) | `docs/dev/debt/libkernel.md` | | [PR 5918](https://www.github.com/boykopovar/AnyPS5/pull/5918) | `docs/dev/debt/libkernel.md` | | [PR 5999](https://www.github.com/boykopovar/AnyPS5/pull/5999) | `docs/dev/debt/libkernel.md` | | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/tests/GuestAmmPlacement.cpp` | | [PR 6222](https://www.github.com/boykopovar/AnyPS5/pull/6222) | `docs/dev/debt/libkernel.md` | | [PR 6510](https://www.github.com/boykopovar/AnyPS5/pull/6510) | `docs/dev/debt/libkernel.md` | | [PR 6534](https://www.github.com/boykopovar/AnyPS5/pull/6534) | `docs/dev/debt/libkernel.md` | | [PR 6908](https://www.github.com/boykopovar/AnyPS5/pull/6908) | `docs/dev/debt/libkernel.md` | | [PR 6977](https://www.github.com/boykopovar/AnyPS5/pull/6977) | `docs/dev/debt/libkernel.md` | | [PR 7039](https://www.github.com/boykopovar/AnyPS5/pull/7039) | `docs/dev/debt/libkernel.md` | | [PR 7049](https://www.github.com/boykopovar/AnyPS5/pull/7049) | `docs/dev/debt/libkernel.md` | | [PR 7075](https://www.github.com/boykopovar/AnyPS5/pull/7075) | `docs/dev/debt/libkernel.md` | | [PR 7088](https://www.github.com/boykopovar/AnyPS5/pull/7088) | `docs/dev/debt/libkernel.md` | | [PR 7121](https://www.github.com/boykopovar/AnyPS5/pull/7121) | `docs/dev/debt/libkernel.md` | | [PR 7129](https://www.github.com/boykopovar/AnyPS5/pull/7129) | `docs/dev/debt/libkernel.md` | | [PR 7135](https://www.github.com/boykopovar/AnyPS5/pull/7135) | `docs/dev/debt/libkernel.md` | | [PR 7192](https://www.github.com/boykopovar/AnyPS5/pull/7192) | `docs/dev/debt/libkernel.md` | | [PR 7273](https://www.github.com/boykopovar/AnyPS5/pull/7273) | `docs/dev/debt/libkernel.md` | | [PR 7332](https://www.github.com/boykopovar/AnyPS5/pull/7332) | `core/libs/tests/GuestAmmPlacement.cpp`<br>`docs/dev/debt/libkernel.md` |
Dextroid17 commented 2026-10-15 18:10:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-15T18:10:34Z.


I ran the test this PR changes, on Linux.

Setup: head 451f11eaf merged into main at 92e50418f (no conflicts; the PR is based on that main), default CMake build (CMAKE_BUILD_TYPE empty, unoptimized), clean environment (env -i with only HOME, PATH and VK_ICD_FILENAMES set). ctest -R '^guest_amm_placement$', 3 runs each.

  • with this PR: 3 of 3 runs pass.
  • with core/libs/prx/libkernel/Apr/src/Apr.cpp put back to main's version (the PR's test changes kept): 3 of 3 runs fail, at "AMM ranges are not a 256 GiB range and an adjacent 32 GiB multimap range".

I did not check Windows or macOS.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6198993113 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6437#issuecomment-6198993113). Originally posted by [Dextroid17](https://github.com/Dextroid17) on 2026-10-15T18:10:34Z. --- I ran the test this PR changes, on Linux. Setup: head 451f11eaf merged into main at 92e50418f (no conflicts; the PR is based on that main), default CMake build (CMAKE_BUILD_TYPE empty, unoptimized), clean environment (`env -i` with only HOME, PATH and VK_ICD_FILENAMES set). `ctest -R '^guest_amm_placement$'`, 3 runs each. - with this PR: 3 of 3 runs pass. - with core/libs/prx/libkernel/Apr/src/Apr.cpp put back to main's version (the PR's test changes kept): 3 of 3 runs fail, at "AMM ranges are not a 256 GiB range and an adjacent 32 GiB multimap range". I did not check Windows or macOS. AI-assisted: yes
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!6437
No description provided.