Commit Graph
463 Commits
Author SHA1 Message Date
Adrià 8304ccaedb Merge pull request #11341 from SteelCrab/review/emscripten-libraries
build(libs): support Emscripten memory64 compilation
2026-10-30 12:49:20 +01:00
Adrià e4f5516fd6 Merge pull request #12974 from MarcZX10/feat/host-game-mode
feat(libkernel): opt-in host game mode request (APS5_GAME_MODE)
2026-10-30 06:36:04 +01:00
Adrià 5ba6b2b917 Merge pull request #12963 from JJenkx/windows/libkernel-raise-pending-until-resume
fix(libkernel): keep sceKernelRaiseException pending on a suspended thread on Windows
2026-10-30 06:32:05 +01:00
Adrià 0c9c5db748 Merge pull request #12690 from MarcZX10/feat/host-system-report
feat(agc): host system report and an actionable missing-Vulkan-feature message
2026-10-30 02:52:18 +01:00
pista 2f49b2568d build(libs): validate current native and WebAssembly adapter sources 2026-10-30 10:50:57 +09:00
pista d64e85164b build(libs): let the system libraries compile with Emscripten
Emscripten targets wasm64 without x86 assembly, Linux-only headers or the
x87 long double. These changes add __EMSCRIPTEN__ paths beside the host
ones; native builds compile the same code as before.

- libc: long doubles in guest varargs and scanf go through
  GuestLongDouble, a plain copy where long double is the x87 format;
  APS5_EXPORT emits no assembler alias; the guest arena is one aligned
  allocation that zeroes pages when they are committed again; getifaddrs
  keeps its link-level entries on Linux; /proc lookups and the host
  stderr duplicate are left out.
- libkernel: file-backed mmap, EVFILT_VNODE watches, getcontext and
  setcontext throw; getdents replaces the raw getdents64 syscall;
  getdtablesize takes the resource limit alone.
- VideoOut leaves SDL, the display window and the HDR probe out,
  Sysmodule asks libkernel for unwind information and Net includes
  sys/time.h.
2026-10-30 10:50:57 +09:00
Adrià ec709cede3 Merge pull request #12436 from milescoviello/fix/vm-loadavg
fix(libkernel): answer vm.loadavg with the host's load averages
2026-10-30 02:31:30 +01:00
Adrià 184afa49ad Merge pull request #12563 from babyhuey/fix/setrlimit-efault
fix(libkernel): return EFAULT from setrlimit for an unreadable limit
2026-10-29 20:35:45 +01:00
JJenkxandClaude Opus 5.5 db14f7a49d fix(libkernel): keep sceKernelRaiseException pending on a suspended thread on Windows
On Windows, sceKernelRaiseException threw for a thread created suspended
and not resumed yet. FreeBSD libthr starts such a thread with signals
blocked and restores its mask on resume, so the signal stays pending and
is delivered on that thread once it runs.

The raise is now recorded in the thread's pendingException with a
compare-exchange, and the thread exchanges it for -1 when it leaves the
creation wait and delivers it to itself before its start routine. Both
sides use one atomic, so a raise racing a resume is either taken by the
thread or, after it started, delivered as for a running thread. Raises
while pending are merged, as for a standard signal.

guest_pthread_create_suspended now runs the deferred-delivery case on
every host, with a second raise while the thread is suspended.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-29 13:39:50 -04:00
MarcZX10 05fe8ad592 feat(libkernel): start the host performance session when libkernel loads
Read APS5_GAME_MODE once at load, the same point where the Windows build
raises the scheduler tick, so an invalid value stops the title at start
with an error that names the variable and an unset one changes nothing.
2026-10-29 17:14:43 +00:00
MarcZX10 ad28df623d test(libkernel): check that exits release the process session and the environment is validated
Run the process session in a test executable linked with libc and leave
through LibcExit and LibcExitWithoutHandlers: the backend is released once
in both. Check that a refused request is never released, that off never
reaches the backend, that a second session is refused, that an unset
APS5_GAME_MODE is accepted and that APS5_GAME_MODE=bogus is rejected with
an error naming the variable.
2026-10-29 17:14:38 +00:00
MarcZX10 63cb5fbd00 feat(libkernel): start the host performance session for the process
Add CreateHostBackend (the GameMode client on Linux, the activity backend
on macOS, a backend that reports itself unavailable elsewhere),
StartProcessSession, which owns the one session of the process and
releases it from the libc shutdown callbacks that every exit path runs,
and StartFromEnvironment, which reads APS5_GAME_MODE and does nothing at
all when it is unset, empty or off. Build the files into libkernel; the
session is not started yet.
2026-10-29 17:14:12 +00:00
MarcZX10 07c3fec103 feat(libkernel): add a macOS activity backend over the Objective-C runtime
macOS throttles timers and background work of a process unless it holds an
NSProcessInfo activity (Apple, Foundation, NSProcessInfo
beginActivityWithOptions:reason:, with NSActivityUserInitiated and
NSActivityLatencyCritical, which asks for the highest timer and I/O
precision available). The tree has no Objective-C sources, so call the
runtime from C++: load libobjc and Foundation with dlopen, look up
objc_getClass, sel_registerName, objc_msgSend and the autorelease pool
functions, begin one activity, retain its token, and end and release it on
End. Both library paths are injectable, and any missing piece is reported
as unavailable. Nothing uses the backend yet.
2026-10-29 17:12:09 +00:00
MarcZX10 1a4e30f7fb feat(libkernel): add a GameMode client backend that loads libgamemode at run time
Linux hosts running Feral's gamemoded switch the CPU governor and scheduler
for a registered game. The client the project ships is a header that loads
libgamemode.so.0 (then libgamemode.so) with dlopen and binds the library's
real_gamemode_request_start, real_gamemode_request_end and
real_gamemode_error_string symbols (FeralInteractive/gamemode at
a74b8106a2236d1f2696aa44c93bc4c8ef13b42e, lib/gamemode_client.h).

Do the same here with the library name list injectable: a missing library
or symbol is reported as unavailable, a failing request as refused, nothing
is linked, and the request is ended only when it was made. Nothing uses the
backend yet.
2026-10-29 17:10:52 +00:00
MarcZX10 140f7bb3ba feat(libkernel): parse the APS5_GAME_MODE setting
Accept off, on and auto, treat an unset or empty value as off so the
default stays as it is today, and reject anything else with an error that
names the variable and the accepted values.
2026-10-29 17:10:24 +00:00
MarcZX10 55587fef6c feat(libkernel): add a host performance session behind an injectable backend
A title that runs for hours would like the host to treat it as a game
(Feral GameMode on Linux, a latency-critical activity on macOS), but no
code owns that request. Add IBackend, the interface a host mechanism
implements, and Session, the state machine that requests once, releases
once, contains every backend failure and logs it once. Nothing uses it
yet.
2026-10-29 17:10:12 +00:00
MarcZX10 3a74ce471c feat(libkernel): export the host CPU probe to other libraries through extern C helpers
The patched libkernel does not hand its plain C++ functions to the other patched libraries: every cross-library call in the tree goes through an extern C helper with a _nid suffix. The host CPU probe had none, so a library that wants the CPU model or the missing feature list cannot reach it. These helpers return plain structs, as the application metadata helpers do.
2026-10-29 14:20:35 +00:00
Adrià cba260828e Merge pull request #11864 from ionut27001/fix/libkernel-get-app-info-layout
fix(libkernel): fill 0x58-byte sceKernelGetAppInfo record, throw for other pids
2026-10-29 14:33:12 +01:00
Adrià efc24518bc Merge pull request #11862 from ionut27001/fix/libkernel-setrlimit-store-limits
fix(libkernel): store setrlimit RLIMIT_CORE soft limit, ignore raised DATA/STACK hard limits
2026-10-29 13:47:57 +01:00
Adrià 5454cd2e45 Merge pull request #11130 from imellag/perf/macos-mimalloc
feat(libs): let relinked macOS games opt into mimalloc
2026-10-29 12:58:23 +01:00
Dean 3a2b919816 Merge pull request #11863 from ionut27001/fix/libkernel-soc-sensor-channels
fix(libkernel): return -49 from sceKernelGetSocSensorTemperature channel 64 as a PS5 payload process does
2026-10-29 12:17:03 +13:00
milescovielloandClaude Opus 5.5 ea0b9c1272 fix(libkernel): zero vm.loadavg's padding and clamp the scaled averages
GuestLoadAverage's braced initializer left its four bytes of padding after ldavg indeterminate, and the sysctl copies all 24 bytes to the guest. The scaled value of a load over UINT32_MAX / 2048 was converted out of range. The test now checks the padding and the exact fscale 2048 scaling against the host averages read just before and after the call.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-28 20:32:29 +00:00
ionut27001 7dc80f7f37 fix(libkernel): fill 0x58-byte sceKernelGetAppInfo record, throw for other pids 2026-10-28 20:16:32 +02:00
babyhuey 24e823c688 fix(libkernel): return EFAULT from setrlimit for an unreadable limit
setrlimit read the guest rlimit struct directly, so a non-null pointer
into unmapped memory crashed the host. It now copies the struct in with
GuestCopyIn_nid_no_patch together with the existing null check, before
the resource check, as FreeBSD's sys_setrlimit copies in before
kern_setrlimit validates the resource, and fails with EFAULT.
2026-10-28 14:16:00 -04:00
Adrià 6eae433fad Merge pull request #11801 from jotitadev/fix/macos-waitpid-child-signals
fix(libkernel): report a child's stop and kill signals correctly on macOS hosts
2026-10-28 17:35:55 +01:00
Emanuele 4c75091972 feat(libs): let relinked macOS games opt into mimalloc 2026-10-28 14:50:31 +01:00
milescovielloandClaude Opus 5.5 ef9c7a06a5 fix(libkernel): answer vm.loadavg with the host's load averages
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-28 13:11:49 +00:00
Dean 846ae118f9 Merge pull request #11861 from ionut27001/fix/libkernel-sysconf-measured-names
fix(libkernel): sysconf answers the names a PS5 payload process answers
2026-10-28 22:52:41 +13:00
Dean e4a00a5ddb Merge pull request #12069 from dantdmdarealguy/fix/raise-terminating-target-windows
fix(libkernel): treat a raise target that is already terminating as exited on Windows
2026-10-28 22:45:45 +13:00
Dean a6816811f3 Merge pull request #10975 from xXPBSXx/fix/gettimeofday-itimer-efault
fix(libkernel): fail gettimeofday, getitimer, setitimer and the sceKernel time getters with EFAULT on an unusable pointer
2026-10-28 13:02:14 +13:00
Adrià 225ebc5eee Merge pull request #11264 from Gruzzberry/fix/sysctl-faults
fix(libkernel): fail sysctl and sysctlbyname with EFAULT on an unreadable or unwritable pointer
2026-10-27 21:16:21 +01:00
dantdmdarealguy 95a785104c fix(libkernel): treat a raise target that is already terminating as exited on Windows
SuspendThread fails with STATUS_THREAD_IS_TERMINATING for a thread that
has begun to exit while its handle is not signaled yet. TryDeliver took
only the signaled handle as an exit, so the raise deliverer, which keeps
sweeping a target in host code until delivery or exit, threw "cannot
suspend the target thread" and aborted the process when that target
exited in between. The suspension now reads the NTSTATUS from
NtSuspendThread and treats a terminating target as exited; other
failures still throw.

guest_raise_exiting_thread raises at 32 threads per round that block in
a host wait and exit after it, for 100 rounds.
2026-10-27 13:38:04 -05:00
Adrià a1053d987b Merge pull request #11273 from Gruzzberry/fix/signal-pointer-faults
fix(libkernel): fail the signal action, mask, stack and pending calls with EFAULT on an unusable pointer
2026-10-27 17:55:35 +01:00
ionut27001 bfbe4043c9 fix(libkernel): store setrlimit RLIMIT_CORE soft limit, ignore raised DATA/STACK hard limits
Probe p87_libkernel lines 7-27: a payload process on a PS5 returns 0 and keeps the limits for a raised RLIMIT_DATA or RLIMIT_STACK hard limit, and reads back RLIMIT_CORE soft limits.
2026-10-27 15:50:28 +02:00
ionut27001 1004bb6828 fix(libkernel): return -49 from sceKernelGetSocSensorTemperature channel 64 as a PS5 payload process does
Probe p83_libkernel; channels 3 to 63 keep throwing.
2026-10-27 12:00:15 +02:00
ionut27001 e984b14b3f fix(libkernel): sysconf answers the names a PS5 payload process answers 2026-10-27 12:00:08 +02:00
Jota 5e75bae0ce fix(libkernel): keep the host signal numbers in waitpid on macOS hosts
waitpid translated the stop and termination signal of a child from the
Linux numbering to the FreeBSD one on every non-Windows host. Darwin
already numbers its signals like FreeBSD, so on macOS the translation
broke them: a child stopped by SIGSTOP (17) was reported as stopped by
20, SIGBUS (10) as 30, SIGSYS (12) as 31, and a child killed by SIGUSR1 (30)
made waitpid report a missing guest equivalent.

macOS now passes the host signal through. The spawn test finds its own
executable with _NSGetExecutablePath on macOS instead of /proc/self/exe,
and also checks a child killed by SIGUSR1, whose number differs between
Linux and FreeBSD and which macOS used to reject.
2026-10-27 05:05:29 -03:00
GruzzberryandClaude Sonnet 5.5 4d8fa35a5e fix(libkernel): fail sysctl and sysctlbyname with EFAULT on an unreadable or unwritable pointer
FreeBSD 11.4's sys___sysctl and userland_sysctl copy the name and the
old length in, and copy the value and the length out, so a bad pointer
gives EFAULT in that order. sysctl dereferenced them directly, and
sysctlbyname read its name with strcmp.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-27 08:30:17 +01:00
Adrià FranchandClaude Sonnet 5.5 7554d2095c fix(libkernel): keep swapcontext's finish helper externally linked
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-27 06:14:13 +01:00
Yunus Shaikh 8f007d234a feat(libkernel_sys): implement sigreturn
sigreturn applies FreeBSD 11's amd64 sys_sigreturn checks:
- EFAULT for a null context;
- EINVAL for unknown mc_flags, and for rflags bits outside
  PSL_USERCHANGE that differ from the current flags;
- set_fpcontext's FPU format and ownership cases.
It then restores the context through the path setcontext uses, which
now lives in RestoreContext. A non-user %cs and an extended FPU state
still throw.
2026-10-27 06:14:13 +01:00
Adrià 60bb466419 Merge pull request #10505 from maximilianfv/fix/libkernel-macos-itimer-terminate
fix(libkernel): reach the guest terminate handler from an ITIMER_REAL expiry on macOS
2026-10-27 04:51:54 +01:00
Dean 169f3e3e73 Merge pull request #10666 from WallisSkill/fix/libkernel-raise-at-guest-return
fix(libkernel): deliver a raised exception at the guest return of a thread in host code
2026-10-27 14:59:25 +13:00
Dean 8600cbc763 Merge pull request #11108 from orezraey/fix/libkernel-nice-stays-zero-measured-ps5
fix(libkernel): keep the nice value at 0 after setpriority as measured on a PS5
2026-10-27 11:00:52 +13:00
Dean 2da4d74cac Merge pull request #11025 from orezraey/fix/libkernel-sw-version-block-measured-ps5
fix(libkernel): accept any block size and a null block in the system software version getters as measured on a PS5
2026-10-27 10:59:21 +13:00
Dean 3c4aab5acc Merge pull request #10830 from babyhuey/feat/libkernel-kern-proc-pid
feat(libkernel): answer kern.proc.pid for the calling process
2026-10-27 10:54:49 +13:00
Dean 1ede81d911 Merge pull request #11078 from slopgobblercobbler/feat/libkernel-sysconf-limits
feat(libkernel): implement additional sysconf limits
2026-10-27 10:37:14 +13:00
Dean dd87687627 Merge pull request #10671 from pushkarreddyy/feat/libkernel-sys-kernel-queries
feat(libkernel): implement sysKernel update version and mode queries
2026-10-27 10:31:00 +13:00
xXPBSXx 506d69b015 Merge main (e0b13f2990) into fix/gettimeofday-itimer-efault
The only conflict is sceKernelGettimezone in Time.cpp: main now reports the host zone, so the zone is built from that into a local and copied out with the checked write.
2026-10-26 20:49:00 +01:00
Dean 927f3b9346 Merge pull request #11167 from Ragbie/fix/windows-sigtimedwait-precision
fix(libkernel): wait for sigtimedwait timeouts with the precise timed wait on Windows
2026-10-27 05:44:58 +13:00
Adrià 5bdda3661e Merge pull request #10132 from orezraey/fix/libkernel-sysctl-system-measured-ps5
fix(libkernel): report the sysctl system strings and integers a PS5 reports
2026-10-26 16:48:57 +01:00