Commit Graph

322 Commits

Author SHA1 Message Date
clem-gb 15c1962e82 fix(libkernel): keep ymm upper halves across a redirected raise
A thread that sceKernelRaiseException redirects resumes through
RtlRestoreContext with a CONTEXT that has no XSTATE, so the upper halves
of ymm0-ymm15 came back as the handler and the delivery path left them.
A handler or host routine that runs vzeroupper or any VEX instruction
(Zen 2 guest code, the CRT's memcpy) cleared the upper lanes of a thread
interrupted in the middle of AVX code. The entry stub now stores
ymm0-ymm15 next to the delivery when the CPU and the OS enable AVX, and
the exit loads them back right before RtlRestoreContext, which restores
only the low halves.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HeC9bA3n74TzJRYv9AgBE8
2026-10-08 10:47:33 +02:00
Adrià f6c33f0d04
Merge pull request #1131 from orbz22/feat/kernel-vectored-io-windows
feat(kernel): implement vectored file IO on Windows
2026-10-08 10:18:29 +02:00
Adrià da4027399e
Merge pull request #1125 from TideOPL/feat/ppsa16064-missing-exports
feat(libs): add the unimplemented exports PPSA16064 imports
2026-10-08 10:01:59 +02:00
Raihan Abdul Majid 87f4444441 fix(kernel): transfer each iovec directly on Windows
Gathering every iovec into one host buffer threw for a total above
INT_MAX, which a console readv/writev accepts, and copied the whole
transfer twice. Each iovec is now read or written in place, in chunks
of at most INT_MAX bytes. A readv on a pipe returns after one read so
it does not block once the available bytes are consumed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UTjpbMX7BUFMZZaxJE98zV
2026-10-08 09:52:49 +02:00
Raihan Abdul Majid a38df0f020 feat(kernel): implement vectored file IO on Windows
sceKernelReadv, sceKernelWritev, sceKernelPreadv and sceKernelPwritev threw on Windows. They now gather or scatter through one host buffer and issue a single read or write, with the same argument checks and error codes as the Linux path. Positioned transfers restore the file offset afterwards, as pread and pwrite do on POSIX, and report ESPIPE for handles that are not disk files. guest_file_vector now runs on Windows as well.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UTjpbMX7BUFMZZaxJE98zV
2026-10-08 09:52:49 +02:00
Adrià 979ae68996
Merge pull request #1095 from kjhq/feat/libkernel-write-throttling
feat(libkernel): report no write throttling in sceKernelWriteThrottlingStatus
2026-10-08 09:11:51 +02:00
Adrià f830fea754
Merge pull request #1094 from kjhq/feat/libkernel-mprotect
feat(libkernel): implement POSIX mprotect
2026-10-08 09:07:34 +02:00
Dean 08766c4e71
Merge pull request #1251 from MGXAe/arena/a135bd3b-anyps5
fix(nid): reject libraries that define symbol versions
2026-10-08 19:35:39 +13:00
kjhq 35ae8742a9 feat(libkernel): implement POSIX mprotect
mprotect changes the protection of guest memory through the same path
as sceKernelMprotect and reports failures through errno: EINVAL for a
null or overflowing range or a range the allocation tracker rejects,
ENOMEM when allocation fails. A zero length succeeds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 08:24:06 +02:00
kjhq 295780ab20 feat(libkernel): report no write throttling in sceKernelWriteThrottlingStatus
The host has no SSD write budget, so the status reports the largest budget in its first qword and zeroes the rest.
2026-10-08 08:21:23 +02:00
Adrià dcbf089d28
Merge pull request #995 from CnRJay/fix/appcontent-user-defined-params
fix(libSceAppContent): read user defined app params from param.json
2026-10-08 08:07:21 +02:00
Adrià 57b62cedf1
Merge pull request #1088 from kjhq/fix/libkernel-sockaddr-len
fix(libkernel): accept guest socket addresses whatever their sa_len
2026-10-08 08:07:17 +02:00
Chad 3b6183a208 fix(libSceAppContent): read user defined app params from param.json
sceAppContentAppParamGetInt numbers the SKU flag 0 and
USER_DEFINED_PARAM_1..4 as 1..4 (fpPS4 ps4_libsceappcontent). Id 1
returned the SKU flag and 2..5 returned zero. UFC 6 (PPSA23566) checks
that param 1 is its title number, userDefinedParam1 in param.json, and
crashes otherwise. Absent params read as zero.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 07:49:16 +02:00
Adrià 311c0493bd
Merge pull request #957 from JAB-dev/feat/kernel-flexible-internal-hint
feat(libkernel): accept flag 0x8000 in sceKernelMapNamedFlexibleMemoryInternal
2026-10-08 07:42:56 +02:00
Adrià c6bb7c1025
Merge pull request #904 from merwie/fix/kernel-module-info-for-unwind
fix(libkernel): report guest unwind tables in sceKernelGetModuleInfoForUnwind
2026-10-08 07:21:21 +02:00
Dean 2d0c53b637
Merge pull request #1209 from ZekkJJ/codex/reject-leading-zero-param-json
fix(libkernel): reject leading-zero numbers in param.json
2026-10-08 17:30:13 +13:00
MGXAe 049539ac3d fix(nid): reject libraries that define symbol versions
The patcher rewrites .dynstr in place and reorders .dynsym for
.gnu.hash, but .gnu.version_d kept pointing at name offsets that the
rewrite had recycled: a library carrying symbol version definitions
came out with renamed or blanked version names while its symbols
still advertised a version.

No library in the build defines symbol versions, so fail on
.gnu.version_d during the section scan and leave the input untouched
instead of carrying version remapping that nothing exercises. The
test covers the rejection and that a library without version
definitions is still patched.

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
2026-10-08 03:04:07 +00:00
Merijn b86370285b fix(kernel): throw on unsupported unwind tables in sceKernelGetModuleInfoForUnwind
Once an image has .ehmeta, an eh_frame_hdr version other than 1, an
eh_frame_ptr encoding other than absptr or pcrel, a 64-bit record length,
an eh_frame_ptr outside the image or a missing terminator now throw
instead of returning the empty answer. The test queries a fixture DLL
whose .ehmeta it can break, since the unwinder reads the same section.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 00:54:43 +02:00
Merijn e975d9a926 fix(libkernel): report guest unwind tables in sceKernelGetModuleInfoForUnwind
On Windows the call returned no eh_frame_hdr for every address, so a
title's own libc (its libunwind) found no frame information and
terminated on the first C++ exception thrown in guest code. PPSA12544
died that way after its intro cinematic: IL2CPP raised an
AmbiguousMatchException that Unity catches and logs, and the runtime
called terminate instead. For an address in a relinked guest image the
call now returns the PT_GNU_EH_FRAME segment named by .ehmeta, the
eh_frame it points to and its size, and the image as seg0; host images
keep the empty answer.

AI-assisted: yes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 00:52:14 +02:00
alfalfa-star 815d274736 feat(agc): import shared direct memory through udmabuf on Linux
On Linux, direct memory is a memfd mapped MAP_SHARED. amdgpu accepts only
private anonymous memory for a host pointer import (libdrm sets
AMDGPU_GEM_USERPTR_ANONONLY), so every import of direct memory failed with
VK_ERROR_INVALID_EXTERNAL_HANDLE and its ranges were copied.

When a host pointer import fails, the range's memfd slice is turned into a
dma-buf through /dev/udmabuf and imported with VK_EXT_external_memory_dma_buf.
The direct memory backing is sealed against shrinking and growing, as
udmabuf requires. libkernel reports the backing of a guest range through
GuestArenaSharedBacking. Without /dev/udmabuf, or past its size limit, the
range is copied as before. APS5_TRACE_HOST_IMPORT now prints the mappings
behind a failed import on Linux too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 23:09:16 +02:00
Adrià e674a6384d
Merge pull request #760 from merwie/feat/kernel-raise-exception-windows
feat(libkernel): deliver sceKernelRaiseException on Windows
2026-10-07 22:27:39 +02:00
Dean 43b01023e6
Merge pull request #1084 from MathiasDevelopes/claude/mingw-link-flags
build(libs): strip the MinGW static runtime flags once for all libraries
2026-10-08 09:24:20 +13:00
Dean 9e965c5cd2
Merge pull request #1115 from Fishybeing/fix/rtld-nominmax
build(windows): guard NOMINMAX in Rtld.cpp
2026-10-08 09:23:49 +13:00
Merijn 2654e3a4ca fix(kernel): drain raised exceptions when leaving an alertable wait
A raise that suspends the thread after its wait returned but before the
wait count drops queued an APC that only ran at the next alertable wait.
Pending APCs are now run right after the count drops. The 0 ms poll in
Condition::waitSignalUntil runs under queueLock and is no longer
alertable, and a target that exits during the raise returns ESRCH.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 22:11:29 +02:00
Bloxive 457f852944 fix(libkernel): reject leading-zero numbers in param.json 2026-10-07 16:06:40 -04:00
Merijn e5b44c4536 Merge branch 'main' of https://github.com/boykopovar/AnyPS5 into feat/kernel-raise-exception-windows
# Conflicts:
#	docs/dev/TechnicalDebt.md
2026-10-07 21:23:46 +02:00
Merijn 51b6079b5b fix(libkernel): no allocation while the target is suspended; own the wait count
The APC delivery was allocated after SuspendThread, so a target holding
the allocator lock deadlocked the raising thread; it is now allocated
before the suspend. The wait count a raise checks lived in the target's
thread_local storage and dangled once the thread exited; it is now a
member of PthreadPrivate, which TimedWait counts into through a
thread-local pointer bound when the thread starts, and a raise on a
thread that already finished returns ESRCH. TechnicalDebt gets one line
per unverified choice: Windows only, the FreeBSD ucontext layout, the
signal mask, the YMM upper halves, and delivery to threads outside
TimedWait.

AI-assisted: yes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 21:10:25 +02:00
Gjon Gojcevic ccc9e3c6da fix(libkernel): return EBADF from sceKernelClose for a descriptor that is not open 2026-10-07 14:10:53 -04:00
Adrià 3f7fe285a0
Merge pull request #900 from alfalfa-star/feat/libkernel-acp-protection
feat(libkernel): accept the audio coprocessor memory protection bits
2026-10-07 18:26:06 +02:00
Adrià Franch 9ab637a575 fix(libkernel): wake infinite equeue waits for timers, document timer choices
Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-07 18:14:04 +02:00
Adrià Franch d081e6749d feat(libkernel): sceKernelAddTimerEvent and sceKernelDeleteTimerEvent
Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-07 17:55:57 +02:00
Pouare514 c25ff91a65 fix(libkernel): accept GPU coherency prot bits for host mapping 2026-10-07 17:29:28 +02:00
TideOPL 3deba9fa47 Merge remote-tracking branch 'origin/main' into pr1125
# Conflicts:
#	core/libs/prx/libkernel/System/src/Coredump.cpp
2026-10-07 15:02:47 +01:00
Pouare514 4fcfd3c2b3 feat(prx): stub TextToSpeech2, Vdecsw and Coredump unknown exports 2026-10-07 15:42:04 +02:00
TideOPL cbdfcd8120 feat(libs): add the unimplemented exports PPSA16064 imports
PPSA16064 (Minecraft Dungeons II, Unreal Engine) failed to load because
these imports had no export:

- libkernel: sceCoredumpWriteUserString
- libSceSaveData: sceSaveDataConvert, sceSaveDataGetConvertProgress
- libSceVideoOut: sceVideoOutVrrPegToFixedRate,
  sceVideoOutVrrUnpegFromFixedRate

None of them is called during the title's start-up, so they are added
as unimplemented exports that throw with their name if a title calls
them. Their signatures are unknown; TechnicalDebt records them. The
built libraries export the NIDs the title imports.
2026-10-07 14:09:55 +01:00
Fishybeing cb3f3e74ff build(windows): guard NOMINMAX in Rtld.cpp
Rtld.cpp defined NOMINMAX unconditionally, which redefines the macro the build already passes and warns on MinGW. Use the #ifndef guard the rest of the tree uses.
2026-10-07 15:00:08 +02:00
kjhq afb8d8e2d7 fix(libkernel): accept guest socket addresses whatever their sa_len
The FreeBSD kernel ignores sa_len in a socket address passed in and sets
it from the length argument, so titles may leave it 0. Only the family
and the length argument decide the address kind now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 10:34:23 +00:00
Claude 121d9332b5
build(libs): strip the MinGW static runtime flags once for all libraries
Every library CMakeLists.txt ended with the same block removing -static,
-static-libgcc and -static-libstdc++ from CMAKE_EXE_LINKER_FLAGS on MinGW,
because core/libs/CMakeLists.txt only removed them after adding the library
directories. Remove them before the libc and library directories are added
so each directory inherits the stripped flags, and drop the 52 copies.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017pTZqAyVSZy2FZmaqakPHZ
2026-10-07 10:10:38 +00:00
Merijn b92894c628 Merge branch 'main' of https://github.com/boykopovar/AnyPS5 into feat/kernel-raise-exception-windows
# Conflicts:
#	core/libs/prx/libkernel/CMakeLists.txt
#	core/libs/prx/libkernel/System/src/Exception.cpp
2026-10-07 07:45:49 +02:00
alfalfa-star e91fe0f063 feat(libs): declare the exports PPSA14632 imports that no library provides
LEGO Horizon Adventures imports 19 functions that no library exports
and no open pull request adds, so it fails eager binding. They are
declared as throwing stubs. The two libSceAjmWVorbis imports have no
known name and are exported by NID from libSceAjm.native.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 07:10:13 +02:00
alfalfa-star b567bb8eed feat(libkernel): accept the audio coprocessor memory protection bits
A title maps direct memory with protection 0x3f2, which adds bits
0x100 and 0x200 to the CPU, GPU and AMPR bits, and the mapping threw.
They are the audio coprocessor (ACP) read and write bits, as named in
the KytyPS5 and etaHEN headers. The coprocessor work runs on the host
CPU, so they map to host read and read/write access like the GPU bits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 07:09:42 +02:00
JAB-dev 2dc53674f5 Merge branch 'main' of https://github.com/boykopovar/AnyPS5 into feat/kernel-flexible-internal-hint 2026-10-07 07:09:08 +02:00
Dean a89f95f4f8
Merge pull request #732 from alfalfa-star/fix/prx-runpath
fix(libs): keep a $ORIGIN runpath in the patched prx libraries
2026-10-07 16:45:29 +13:00
Dean 0c952fe574
Merge pull request #994 from CnRJay/fix/map-no-overwrite-enomem
fix(libkernel): refuse fixed no-overwrite mappings over live memory with ENOMEM
2026-10-07 15:31:12 +13:00
Dean f6f47bf1de
Merge pull request #880 from adriadam10/feat/kernel-mtypeprotect-type
feat(kernel): apply the memory type in sceKernelMtypeprotect
2026-10-07 15:28:25 +13:00
Dean 1d773dad2e
Merge pull request #722 from alfalfa-star/feat/libkernel-rtld-thread-atexit
feat(libkernel): implement the rtld thread atexit reference count
2026-10-07 15:27:44 +13:00
Dean fc5341aca2
Merge pull request #872 from Fishybeing/fix/guard-nominmax
build(windows): guard NOMINMAX before including windows.h
2026-10-07 15:24:47 +13:00
Dean fde401d41f
Merge pull request #992 from CnRJay/feat/ppsa23566-missing-exports
feat(libs): declare the exports PPSA23566 imports that no library provides
2026-10-07 13:02:56 +13:00
Adrià ab9437e34d
feat(libkernel): implement scePthreadTestcancel and pthread_testcancel (#834) 2026-10-07 11:43:32 +13:00
Dean 23ba389799
Merge pull request #993 from CnRJay/fix/mutexattr-settype-einval
fix(libkernel): return EINVAL for unknown mutex attribute types
2026-10-07 11:43:11 +13:00