Commit Graph
61 Commits
Author SHA1 Message Date
Dean 210462e2a7 Merge pull request #11838 from oneandonlydean/wolverine/amm-fragmented-pool
fix(libkernel): map AMM pages from a fragmented pool
2026-10-28 20:11:32 +13:00
Adrià 6db75895fb Merge pull request #11695 from milescoviello/test/ampr-event-queue-size
test(libSceAmpr): check the measured kernel event queue command size against the recorded one
2026-10-28 04:51:48 +01:00
Adrià 6694ea83ba Merge pull request #11687 from milescoviello/test/ampr-write-address
test(libSceAmpr): cover the versioned write-address command, its sizes and the buffer type
2026-10-28 04:40:26 +01:00
Dean 6d40d8e527 Merge pull request #11747 from milescoviello/test/apr-resolve-foreach
test(libkernel): cover the APR ForEach resolves with and without a prefix
2026-10-28 12:08:20 +13:00
Dean Galvin 74ad6b1a5f test(libkernel): read zeros from a PRT range after a failed page allocation
Allocate more pages for a PRT range than the pool holds and check the range still reads zero, then allocate one page, write it, and check the next allocation is refused the same way.
2026-10-27 23:45:02 +13:00
Dean Galvin 0344e6e209 test(libkernel): map AMM pages from a fragmented pool
Fragment the pool into single free pages, map a range no single run holds, check each page keeps its own data, and check an exhausted pool still reports no free run.
2026-10-27 22:05:24 +13:00
milescovielloandClaude Opus 5.5 4912e4c7a9 test(libkernel): cover the APR ForEach resolves with and without a prefix
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-27 06:33:48 +00:00
milescovielloandClaude Opus 5.5 72801be9fa test(libSceAmpr): check the measured kernel event queue command size against the recorded one
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-27 03:10:56 +00:00
milescovielloandClaude Opus 5.5 ffe161edde test(libSceAmpr): cover the versioned write-address command, its sizes and the buffer type
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-27 02:41:04 +00:00
Adnan Khan 0d14468ccc fix(libSceAmpr): zero the padding of a constructed Nop payload 2026-10-25 22:56:04 +05:30
Adnan Khan ada5ad0990 fix(libSceAmpr): write the console's Nop header word and report a null base first 2026-10-25 22:46:51 +05:30
Adnan Khan dc510a5279 fix(libSceAmpr): record Nop as n dwords with a one-dword header 2026-10-25 16:32:53 +05:30
boykopovar f38d29fd08 refactor(sdk): add canonical headers for remaining libraries 2026-10-24 23:17:42 +03:00
Dean b8009ac632 Merge pull request #9292 from al3w0f205/test/ampr-measure-completion-commands-coverage
test(libSceAmpr): cover completion command measurement and buffer base address query
2026-10-23 13:04:24 +13:00
boykopovar d9c2facdb9 fix(ampr): preserve nop payload when data is absent 2026-10-21 21:52:56 +03:00
al3w0f205 9c1eeedf6f test(libSceAmpr): cover completion command measurement and buffer base address query 2026-10-21 12:30:20 -05:00
lakhantheboss 2873e9c361 fix(ampr): validate null command buffer arguments 2026-10-19 18:39:10 +02:00
hugodearaujo 12813101d2 fix(ampr): return EBUSY when a command does not fit and EPERM before a buffer is bound 2026-10-17 19:23:26 -03:00
Nesyth 417ea99df5 fix(libkernel): zero-fill APR reads that reach the end of the file 2026-10-13 16:38:17 +02:00
Blazing Cook acd8c8c527 test(ampr): retain both pooled-page ownership regressions
Restore the original alias-remap regression alongside the pool-exhaustion
regression so each ownership fix remains covered after combining the series.
2026-10-13 07:50:53 +00:00
Blazing Cook a88a4c8e15 fix(ampr): reserve targets before releasing mapped pool pages
(cherry picked from commit 3e9a37eaa34c4d543f775bece42de3eb7a4647ea)
2026-10-13 07:50:53 +00:00
Blazing Cook ce98f83033 fix(ampr): retain pooled pages while remapping aliases
(cherry picked from commit a2408b5244c663849ae4f7022e7aff01f2ba5abc)
2026-10-13 07:50:53 +00:00
Adrià 955f4fbffe Merge pull request #4207 from xXPBSXx/fix/ampr-amm-usage-stats
feat(libSceAmpr): answer sceAmprAmmGetUsageStatsData
2026-10-12 22:57:04 +02:00
xXPBSXxandClaude Sonnet 5.5 4b6f463751 feat(libSceAmpr): answer sceAmprAmmGetUsageStatsData
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-12 21:14:14 +02:00
Blazing Cook c20583bd34 fix(ampr): reject command buffer offsets beyond bound memory
(cherry picked from commit b92287dc68d538d44369d2a09500b4404ca53fca)
2026-10-12 18:45:58 +00:00
Santhosh KumarandClaude Opus 5.5 6b38cdda8c fix(libkernel): report the target size of symbolic links on Windows
_wstat64, the FindFirstFileExW listing and std::filesystem::file_size
report the size of a file symbolic link itself (0). stat therefore gave
0 for linked files, and APR resolved them as empty, so Unity treated a
linked globalgamemanagers as empty and never read it.

stat takes the size from the handle it already opens, which follows the
link. The APR listing skips reparse points, and names missing from it
are sized through stat.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-12 13:48:56 +05:30
ducloc080202 2cf929db08 fix(libkernel): record AmmModifyMtypeProtect and AmmRemapIntoPrt commands 2026-10-12 10:33:45 +07:00
Adrià 4a8efe0699 Merge pull request #3808 from MarcZX100/codex/apr-command-size-validation-1930
fix(libkernel): validate APR command payload sizes
2026-10-12 00:05:34 +02:00
Adrià 153a0a58d6 Merge pull request #3588 from tv7/fix/apr-async-queue
fix(libkernel): run APR buffers past an unsatisfied wait on their own queue
2026-10-11 23:51:13 +02:00
Dean abd318d9c0 Merge pull request #3683 from Zurisen/fix/amm-below-host-regions
fix(libkernel): reserve the AMM ranges below host regions at the top of the guest arena
2026-10-12 10:43:07 +13:00
Santhosh Kumar 17827dd9ab fix(filesystem): reject invalid parent traversal on Windows 2026-10-12 01:25:02 +05:30
LexroidandClaude Opus 5.5 fbb4d3771d fix(libkernel): give AMM buffers their own queue
One queue for APR and AMM buffers kept an AMM buffer behind an APR buffer
waiting on an address that the AMM buffer writes, so neither ran.
Marvel's Wolverine does this: an APR buffer waits on a counter that the
WriteAddress commands of later AMM buffers advance, and its loading
stopped. APR and AMM buffers now keep their order within their own queue.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-11 20:32:11 +03:00
MarcZX100 7c2eba0a6d fix(libkernel): validate APR command payload sizes 2026-10-11 16:57:06 +00:00
Zurisen 3c6c5d5331 fix(libkernel): reserve the AMM ranges below host regions at the top of the guest arena
The AMM ranges were reserved at the last 64 GiB of the guest arena and
the reservation threw when that window was not free. On Windows the
stacks of the threads that exist before the arena is reserved (the main
thread and the loader's workers) are placed at random addresses and are
left in the arena as host regions; when one fell in the last 64 GiB, the
first AMM use threw "fixed guest mapping ... overlaps a host region in
the guest arena". Reserve the highest free 64 GiB window instead: the
last 64 GiB when it is free, and the window just below an occupied part
of it otherwise.
2026-10-11 17:09:12 +02:00
LexroidandClaude Opus 5.5 32a3047b5d fix(libkernel): run APR buffers past an unsatisfied wait on their own queue
sceKernelAprSubmitCommandBuffer ran the whole buffer on the submitting
thread, so a WaitOnAddress or WaitOnCounter that the submitter itself
satisfies after the submit returned never returned. A buffer now runs on
the submitting thread until such a wait; the rest of it, and every APR or
AMM buffer submitted after it, runs in order on one APR thread.
sceKernelAprWaitCommandBuffer and sceAmprAmmWaitCommandBufferCompletion
wait for that completion.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Wu3nuU87RJwjkkmxqft3sD
2026-10-11 16:37:25 +03:00
Adrià 3db4637fcc Merge pull request #2789 from tototomate123/fix/hfw-apr-split
fix(APR): correct guest resolution outputs, object layout and gather sizing
2026-10-11 09:32:21 +02:00
tototomate123 65c8ef656f fix(apr): compact gather records to avoid command buffer exhaustion 2026-10-11 07:27:52 +02:00
tototomate123 f514df98de fix(apr): match the guest command buffer object layout 2026-10-11 07:27:52 +02:00
tototomate123 68900523c4 fix(apr): report guest errors and clear failed file resolutions 2026-10-11 07:27:52 +02:00
Dean Galvin 5543c73b37 fix(libkernel): reserve the AMM virtual address ranges at the top of the guest arena
The AMM ranges were reserved address-less on first use, so they took the
lowest free address of the arena, directly after the title's last mapping,
where the title's next hinted maps go. They are now reserved at a fixed
place, the last 64 GiB of the guest arena, which maps without MAP_FIXED and
the hints derived from them do not reach; a reservation that cannot be made
there throws.

Fixes #3146
2026-10-11 13:56:11 +13:00
Nahuel GenchiandClaude Opus 5.5 6c81134f79 fix(libkernel): submit APR command buffers that were not constructed
sceKernelAprSubmitCommandBuffer rejected a buffer object with EINVAL
unless sceAmprAprCommandBufferConstructor had tagged it. The tag is
AnyPS5's own: in the retail layout the type word only carries state
bits and the constructors zero the object, so a zero-filled object
bound with SetBuffer is a valid APR buffer.

CRI's file system in Sonic Origins (PPSA05324) lays out its
AprCommandBuffer objects in its own zeroed work memory and never calls
the constructors. Its first read submit failed with 0x80020016, and the
CRI file system stopped there.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-09 13:10:44 -03:00
jdmagicandClaude Opus 5.5 8ae350caaa fix(libSceAmpr): sceAmprCommandBufferClearBuffer returns the detached buffer
sceAmprCommandBufferClearBuffer detaches a command buffer's memory and
returns it so the caller can free it. It returned 0. PPSA01289 (Sackboy: A
Big Adventure) frees the result after every streaming read, so each read
leaked its 16 KiB command buffer until the allocator ran out of memory
during the first world load.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-09 01:58:38 -04:00
Gjon Gojcevic c95721f701 fix(libkernel): report AMPR completion events with the AMPR filter
AMPR events were registered and raised as EVFILT_USER. Titles that
dispatch their AMPR queue by filter ignore those events, so reads that
complete through WriteKernelEventQueue never finish. Add, delete and
trigger them with EVFILT_AMPR (-25).
2026-10-07 19:37:40 -04:00
Chad 4d10fd1796 Merge branch 'feat/amm-remap-protect' into feat/amm-prt 2026-10-05 16:00:02 -05:00
Chad e15c039ef8 Merge branch 'feat/amm-core' into feat/amm-remap-protect 2026-10-05 16:00:01 -05:00
ChadandClaude Opus 5.5 710369f3d3 test(libs): access aliased AMM mappings through volatile references
The AMM test writes through one mapping of a physical page and reads it
through another. The two addresses are distinct to the compiler, so GCC
13 at -O2 moved the read ahead of the write and the Linux CI check saw
the old value. The test's At helper now returns a volatile reference.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-05 15:59:59 -05:00
Chad 453874d1d8 Merge branch 'feat/amm-remap-protect' into feat/amm-prt 2026-10-05 15:56:51 -05:00
Chad 11e9f6e0ab Merge branch 'feat/amm-core' into feat/amm-remap-protect 2026-10-05 15:56:49 -05:00
ChadandClaude Opus 5.5 164fcf7a05 test(libs): report the failing line of the AMPR tests
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-05 15:56:48 -05:00
ChadandClaude Opus 5.5 cf3d0f6fc7 feat(libs): implement the AMM PRT commands
sceAmprAmmCommandBufferMapAsPrt, AllocatePaForPrt, RemapIntoPrt and
UnmapToPrt, with the MapAsPrt and AllocatePaForPrt measures. Signatures,
checks and their order follow ampr_emu.

The executor keeps the PRT pages of the AMM ranges. Unbacked PRT pages
are zero-filled with GPU read access; AllocatePaForPrt backs each
unbacked page with a pool page and changes the type and protection of
backed ones; RemapIntoPrt moves a mapped range into a PRT range; and
UnmapToPrt returns the pages to the pool and zero-fills them again. A
plain map, unmap or remap over a PRT range ends it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-05 15:45:28 -05:00