Commit Graph
180 Commits
Author SHA1 Message Date
boykopovar e29ef3c6b5 fix(tests): cast memory unmap addresses to canonical type 2026-10-25 00:21:05 +03:00
boykopovar f38d29fd08 refactor(sdk): add canonical headers for remaining libraries 2026-10-24 23:17:42 +03:00
Dean 7dea7774d6 Merge pull request #10018 from JJenkx/fix/dmem-release-skips-free-pages
fix(libkernel): skip unallocated pages in sceKernelReleaseDirectMemory
2026-10-25 03:51:22 +13:00
Dean 5b02b41c1d Merge pull request #9876 from orezraey/fix/libkernel-aio-limits-measured-ps5
fix(libkernel): follow AIO limits, unknown ids and reported states as measured on a PS5
2026-10-25 00:21:25 +13:00
JJenkxandClaude Opus 5.5 462f8dff1f fix(libkernel): skip unallocated pages in sceKernelReleaseDirectMemory
The unchecked release passed its whole range to ForgetDirectMemory,
which throws on any page that is not allocated, so releasing a range
that is partly or wholly free aborted the process. Release only the
allocated runs, as shadPS4's unchecked free does; the checked variant
still returns ENOENT for them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-24 05:54:17 -04:00
Dean ce965ddb7b Merge pull request #9153 from orezraey/fix/libkernel-dmem-available-measured-ps5
fix(libkernel): match sceKernelAvailableDirectMemorySize arguments to PS5
2026-10-24 22:13:10 +13:00
orezraeyandClaude Opus 5.5 60135e8855 Merge main into fix/libkernel-aio-limits-measured-ps5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-23 20:06:53 -03:00
Dean 313d905437 Merge pull request #9877 from orezraey/fix/libkernel-release-flexible-measured-ps5
fix(libkernel): keep the range sceKernelReleaseFlexibleMemory releases mapped as measured on a PS5
2026-10-24 10:37:09 +13:00
orezraeyandClaude Opus 5.5 aebed518a7 Merge main into fix/libkernel-aio-limits-measured-ps5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-23 17:27:35 -03:00
QRMOE 5836873170 fix(memory): honor low guest mapping hints 2026-10-23 16:51:33 +02:00
orezraeyandClaude Opus 5.5 0db5b78405 test(libkernel): cover 4 KiB offsets in sceKernelReleaseFlexibleMemory
Measured on firmware 13.60: an address or length aligned to 4 KiB but
not to 16 KiB returns EINVAL.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-22 17:09:36 -03:00
orezraeyandClaude Opus 5.5 2f8177d7b4 fix(libkernel): keep the range sceKernelReleaseFlexibleMemory releases mapped
Measured on firmware 13.60: the released range stays mapped with its
protection and contents, and a fixed no-overwrite map over it fails
with ENOMEM; a null or unaligned address, an unaligned length or a
range that wraps returns EINVAL, checked before a zero length, which
returns 0, as does a range with nothing mapped.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-22 17:09:36 -03:00
orezraeyandClaude Opus 5.5 2730b6abe5 fix(libkernel): match the AIO batch, priority and parameter limits to PS5
Measured on firmware 13.60: submits take 1 to 128 requests at priority
1 to 3, the id lists of poll, wait, cancel and delete take 1 to 128 ids,
wait takes mode 1 or 2, and sceKernelAioSetParam takes a window and a
delayed count of 0 to 128, a split flag of 0 or 1 and, with split on,
split and chunk sizes of 1 to 0x1000000; everything else returns EINVAL
without writing. sceKernelAioInitializeParam writes the console's three
default scheduling structs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-22 16:57:51 -03:00
boykopovar 8b75d497c0 fix(kernel): reject unimplemented internal pool statistics 2026-10-21 21:56:05 +03:00
Adrià b00235dda0 Merge pull request #8439 from xXPBSXx/fix/mmap-anonymous-flags
fix(libkernel): accept MAP_ANON without MAP_PRIVATE and refuse MAP_SHARED with MAP_PRIVATE
2026-10-21 20:16:10 +02:00
Adrià 8e72738df6 Merge pull request #8437 from xXPBSXx/fix/mprotect-ignore-undefined-bits
fix(libkernel): drop undefined protection bits in mprotect
2026-10-21 20:08:57 +02:00
orezraeyandClaude Opus 5.5 39cc6af2b1 fix(libkernel): compare the search start before rounding it
Measured on firmware 13.60: a start whose rounding to 16 KiB overflows
finds nothing, and of two equal free ranges the lowest is returned.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-21 10:41:28 -03:00
orezraeyandClaude Opus 5.5 4319a7a5e7 fix(libkernel): match sceKernelAvailableDirectMemorySize arguments to PS5
Measured on firmware 13.60: an alignment that is not zero or a power of
two returns EINVAL before anything else; bounds with nothing between
them return ENOMEM, a negative start searches from the bottom, only the
start is rounded up to 16 KiB and the end is used as given; null outputs
are skipped; errors leave both outputs untouched.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-21 10:39:19 -03:00
Evgeniy KazarinandClaude Opus 5.5 69f843c910 perf(libkernel): reuse released direct-memory sections that never held data
The title allocates, maps and releases about 48 direct-memory blocks per frame.
Each allocation created a pagefile-backed section and each release closed it.
A released section whose pages were never stored to (resident pages keep their
data in private memory and saved buffers, not in the section) is still blank,
so up to 256 such sections of at most 16 MiB, 256 MiB in total, are kept by
size and handed to the next allocation of that size instead of a new
CreateFileMappingW. APS5_NO_DIRECT_MEMORY_SECTION_POOL keeps the old behaviour.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-21 10:32:44 +08:00
Dean b13183e59e Merge pull request #7473 from Dripl1x/codex/skip-clean-resident-write-watch
perf(libc): skip write-watch queries for proven clean resident ranges
2026-10-21 14:55:09 +13:00
Dean c82867c77c Merge pull request #7472 from Dripl1x/codex/reuse-unreferenced-saved-memory
perf(libc): reuse saved direct-memory buffers when unreferenced
2026-10-21 13:25:04 +13:00
Evgeniy Kazarin 7898b5bd3a fix(libc): avoid repeated resident write faults 2026-10-21 03:55:51 +08:00
Evgeniy Kazarin a627328cfa perf(libc): skip write-watch queries for proven clean resident ranges 2026-10-21 03:53:50 +08:00
Evgeniy Kazarin 9d5f8326bf perf(libc): collect resident writes directly into the output buffer 2026-10-21 03:52:09 +08:00
xXPBSXxandClaude Sonnet 5.5 8977922244 fix(libkernel): drop undefined protection bits in mprotect
FreeBSD 11.4 kern_mprotect masks the argument with VM_PROT_ALL instead of
refusing it (sys/vm/vm_mmap.c:613). sceKernelMprotect already does this
since #5770; the POSIX mprotect export still failed with EINVAL.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-20 18:51:41 +02:00
xXPBSXxandClaude Sonnet 5.5 12785e2192 fix(libkernel): accept MAP_ANON without MAP_PRIVATE and refuse MAP_SHARED with MAP_PRIVATE
FreeBSD 11.4 kern_mmap maps anonymous memory whenever MAP_ANON is set, with
or without MAP_PRIVATE (sys/vm/vm_mmap.c:339), and fails with EINVAL when
both MAP_SHARED and MAP_PRIVATE are set (vm_mmap.c:252). The guest failed
the first with ENOTSUP (45) and the second with ENOTSUP as well.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-20 14:35:04 +02:00
Seif Allah Karoui be27ffa12c test(libkernel): harden signed-byte memory protection coverage 2026-10-20 12:06:06 +01:00
Dean 49fd13a741 Merge pull request #7958 from Lindamea1/fix/libkernel-available-direct-memory-enomem
fix(libkernel): return ENOMEM from sceKernelAvailableDirectMemorySize when the range has no free block
2026-10-20 17:40:24 +13:00
Adrià a700809679 Merge pull request #7448 from Tamalero/fix/libkernel-release-direct-memory-order
fix(libkernel): unmap released direct memory views before freeing the physical range
2026-10-19 23:27:29 +02:00
Lindamea1andClaude Opus 5.5 179316c452 fix(libkernel): return ENOMEM from sceKernelAvailableDirectMemorySize when the range has no free block
A search range with no free direct memory returned EAGAIN (0x80020023).
A PS5 returns ENOMEM (0x8002000c) for an occupied range, as the
PS5_RetroArch author's console capture records, and PS5_PayloadSDK's
ps5_memory_query, which RetroArch uses for its memory status, gives up
on any other error.

LargestFree now returns the error: ENOMEM when no block is found, and
EAGAIN as before for a negative start, an end at or below the start and
an alignment that overflows when rounded to a page. guest_memory expects
ENOMEM for an occupied range and EAGAIN for those arguments. The
unmeasured argument handling is recorded in the libkernel debt file.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-19 16:24:55 +01:00
TamaleroandClaude Opus 5.5 b574f2a51f fix(libkernel): claim a released direct memory range before unmapping its views
The checked release tested that the range was allocated, released the pool lock and then
unmapped a snapshot of its views. Two concurrent checked releases of one range both passed the
test and took the same snapshot; the second then unmapped views the first had already removed
and terminated on "unmap address is not registered" instead of returning ENOENT.

A release now claims its pages in the pool under the pool lock before it looks at the views,
and frees them, dropping the claim, after the unmap. A checked release of pages another release
has claimed returns ENOENT as if they were already free; a plain release waits for that release
to finish. The pages stay allocated while claimed, so they still cannot be reallocated during
the unmap's lease wait.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-18 22:40:10 -07:00
Muhammad Wasif Ali WasifandClaude Opus 5.5 ddb774ad26 feat(libkernel): map regular files with mmap on Windows
A shared mapping is a view of a file section created on the descriptor's
handle, read-write when the descriptor is, otherwise read-only. A private
mapping is a copy of the file read at mmap, as POSIX allows. Anonymous
shm_open objects and JIT shared memory descriptors are temporary files on
Windows, so mmap now maps them too (it failed with EOPNOTSUPP before).
mprotect of a mapped view above the view's protection fails with EACCES
before any bookkeeping changes. The cases Windows cannot represent are
listed in the libkernel debt.

Dusklight (PPSA99305) uses SQLite in WAL mode, which maps its -shm file.
On Windows main f0634088b every start logged "Failed to start
transaction: disk I/O error" for its Dawn and pipeline caches (3 of 3
runs); with this change the caches initialise and their WAL files fill
(4 of 4 runs). The title reaches its menu either way.

A shared mapping may end inside the 16 KiB page that holds the end of
the file, as POSIX mmap allows: the view ends with the file's last 4 KiB
host page, which Windows zero-fills past the end, the rest of the guest
page is private zero pages, and the file never grows. A mapping that
reaches a whole page past the end still fails with EOPNOTSUPP.

PS5LM Plus (PPSA99581) loads its model with llama.cpp, which maps the
whole GGUF file shared and read-only. With a 491,400,032-byte model,
Windows main 5de7a46e0 and this change without the last page logged
"llama_model_load: error loading model: mmap failed: Operation not
supported" (3 of 3 runs); now the model loads and the completion of
"The capital of France is" starts with " Paris" (3 of 3 runs).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-19 05:02:25 +05:00
TamaleroandClaude Opus 5.5 9f5efd4f97 test(libkernel): pass the release under test with its declared calling convention
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-18 00:46:13 -07:00
TamaleroandClaude Opus 5.5 268e96df8b fix(libkernel): unmap released direct memory views before freeing the physical range
sceKernelReleaseDirectMemory and sceKernelCheckedReleaseDirectMemory returned the range to the
allocator before unmapping its views. The unmap waits for GPU leases on the views, and during
that wait another allocation could take the freed pages and map them while the old view was
still mapped and host-imported, so GPU writes through it landed in the new owner's memory.
Both calls now unmap the views first; the checked call still reports ENOENT for an unallocated
range before it touches any view.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-17 23:51:55 -07:00
Dean 1b0c7cfa02 Merge pull request #7112 from Pouare514/fix/flexible-release-scope
fix(libkernel): scope flexible release to tracked ranges with release-then-record
2026-10-18 19:22:54 +13:00
Evgeniy Kazarin 1d9bf1e029 perf(libc): reuse saved direct-memory buffers when unreferenced 2026-10-18 06:10:30 +03:00
Dean 5a86770667 Merge pull request #7242 from MarcZX100/codex/fix-mmap-flexible-replacement-7120
fix(libkernel): release flexible accounting after fixed mmap
2026-10-18 12:08:50 +13:00
Dean e5961b2b35 Merge pull request #6264 from MarcZX100/codex/host-write-map-alias-6260
fix(libc): defer resident alias demotion during host writes
2026-10-18 10:32:22 +13:00
MarcZX100 a352941e77 fix(libkernel): release flexible accounting after fixed mmap 2026-10-17 20:22:14 +00:00
Pouare514 82dff58494 fix(libkernel): scope flexible release to tracked ranges with release-then-record 2026-10-17 14:03:19 +02:00
Adrià 5b70a50680 Merge pull request #5955 from fma-rc/fix/libkernel-linux-guest-module-protect
fix(libkernel): register a relinked guest module's image when Linux protects its pages
2026-10-16 23:29:46 +02:00
Adrià 02a1b772ed Merge pull request #5770 from simonbronk/fix/kernel-mprotect-undefined-bits
fix(libkernel): drop undefined protection bits in sceKernelMprotect
2026-10-15 17:53:02 +02:00
Romans Pokrovskis 50748f79f2 test(libc): retain the open-host-write alias regression
Retain the regression originally supplied by Pipodi in closed PR5851 (22091410a), adapted here through e1c6af65b. Current-main-equivalent libc/kernel source returns an alias during the open HostWrite and fails this assertion five times. This test is a reproduction, not a new implementation or an upstream PR.

(cherry picked from commit 312170cd0c461104174d655911de876be341cf6a)
2026-10-15 14:52:30 +00:00
JJenkx ad78fbcdf7 fix(libkernel): stabilize virtual-query layout across hosts 2026-10-15 08:16:22 -04:00
simonbronkandClaude Opus 5.5 3da081aaad fix(libkernel): drop undefined protection bits in sceKernelMprotect
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-14 21:51:52 +02:00
fma-rc c1783f9d64 fix(libkernel): register a relinked guest module's image when Linux protects its pages 2026-10-14 18:24:45 +02:00
Yossi Yadgar cf1c80d8ce test(libkernel): cover reservation hints with no room above them
guest_memory reserves with a hint above the guest arena and with a hint
on the arena's last page for two pages, and checks that both land inside
the arena, the second below its hint.
2026-10-14 17:41:31 +03:00
Adrià 5adefa6f89 Merge pull request #5643 from Amirtheshwaran/feat/libkernel-mincore
feat(libkernel): implement mincore
2026-10-14 16:25:54 +02:00
Adrià 1b55ee4ab3 Merge pull request #5610 from Dripl1x/codex/feat-libkernel-fixed-anonymous-mmap
feat(libkernel): support fixed anonymous mmap
2026-10-14 14:52:53 +02:00
Adrià FranchandClaude 2854d51352 fix(libkernel): follow kern_mincore order and report reserved pages as not resident
Co-Authored-By: Claude <[email protected]>
2026-10-14 14:40:12 +02:00