125 Commits
Author SHA1 Message Date
Dean f8eb8a825b Merge pull request #23555 from malekaifa/prime-b/mqueue-timed-waits-20261119-v9
fix(libkernel): use monotonic message queue waits
2026-11-27 17:06:22 +13:00
KianandClaude Opus 5.5 6bc0fdc790 fix(libkernel): read CLOCK_VIRTUAL and CLOCK_PROF from getrusage on POSIX hosts, as FreeBSD 11.4 does
On Linux and macOS clock_gettime ids 1 and 2, and id 21 built on id 2,
came from times(), which counts in _SC_CLK_TCK ticks (usually 10 ms),
and threw when times() failed. They now read getrusage(RUSAGE_SELF)
ru_utime and ru_stime in microseconds and set the guest errno on
failure, as FreeBSD 11.4 kern_clock_gettime does through calcru and
TIMEVAL_TO_TIMESPEC.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 06:26:11 +10:00
Dean 38845546fb Merge pull request #23351 from LeandroLP23/feat/kernel-pause-clock-for-pipelines
feat(agc): hold the guest clock still while a queue waits for a compute pipeline build
2026-11-22 09:01:57 +13:00
Dean 2691c9996a Merge pull request #18471 from THEMANnt/fix/libkernel-clock-id-15
fix(libkernel): report elapsed process time for clock id 15
2026-11-22 05:44:54 +13:00
LeandroLP23andClaude Opus 5.5 bd53fc2254 fix(libkernel): read the clock origin before the clock when the guest clock is scaled
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 13:39:45 +01:00
LeandroLP23andClaude Opus 5.5 00e4c6e131 fix(libkernel): hold the non-Windows monotonic clock ids still during a guest clock pause
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 13:39:45 +01:00
LeandroLP23andClaude Opus 5.5 55a8c10f75 feat(agc): hold the guest clock still while a queue waits for a compute pipeline build
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 13:39:45 +01:00
Mohamed Malek Aifa 75fc81fdb1 test(libkernel): cover production mqueue monotonic waits 2026-11-20 05:11:57 +01:00
Mihai 6095e778ef feat(libc): implement libc++ steady clock 2026-11-19 22:01:47 +02:00
videogamer10293andClaude Opus 5.5 beb0afc706 fix(libkernel): read Windows thread CPU clocks from thread cycle time
GetThreadTimes only advances at the 15.6 ms scheduler tick, so on
Windows the thread CPU clock moved in 15.6 ms steps where clock_getres
reports 1 us, and could read ahead of the monotonic clock under load.
With an invariant TSC, read the calling thread's clock and other guest
threads' CPU clocks from QueryThreadCycleTime, converted with the
measured host TSC frequency.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 20:45:11 +00:00
Dean 7a1311eca0 Merge pull request #19794 from adam25136/fix/libkernel-timer-lateness
fix(libkernel): arm Windows timed waits early by the timer's measured lateness
2026-11-17 16:17:27 +13:00
Sher Jan c60b11642e feat(libSceRtc): implement the measured sceRtcSetConf timezone contract (#17609) 2026-11-17 08:53:30 +13:00
THEMANnt 9e93e2cc6b fix(libkernel): report elapsed process time for clock id 15 2026-11-15 23:53:46 +03:00
Kevin Ramirez f043d517ce feat(libkernel): report the clock resolutions a PS5 measured (#17958)
* feat(libkernel): report the clock resolutions a PS5 measured
* feat(libkernel): clock_getres fails the ids the console rejects with EINVAL
* docs(libkernel): keep the clock_getres debt entry UTF-8 and under the length limit
* fix(libkernel): answer EINVAL for clock ids from 32 in clock_getres
2026-11-16 09:22:12 +13:00
Stephen Cork be96cdb031 fix(libkernel): return EINVAL for invalid non-CPU clock ID in clock_getres (#14557) 2026-11-15 00:38:28 +13:00
JJenkx 61f341b616 fix(libc): count clock() as the process time, like the console (#9677) 2026-11-14 16:33:07 +13:00
AdamGalandClaude Opus 5.5 1eb9ef3d5d fix(libkernel): arm Windows timed waits early by the timer's measured lateness
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 00:48:52 +02:00
Dean 810aaf35ce Merge pull request #18466 from THEMANnt/fix/libkernel-clock-id-20
fix(libkernel): implement clock_gettime for clock id 20
2026-11-13 23:26:47 +13:00
THEMANnt f67a155140 fix(libkernel): implement clock_gettime for clock id 20 2026-11-12 19:02:26 +03:00
atinseau 271ae954c6 perf(kernel): skip the wait trace clock reads when tracing is off
sceKernelWaitSema read steady_clock before and after every wait and passed the difference to KernelTraceWait_nid_postfix, which returns at once unless APS5_TRACE_WAITS is set. The wait now reads the clock only when the variable is set, through one cached flag shared with the trace function. A signal+wait pair drops from 88 ns to 39 ns and from 1909 to 1069 instructions; with a timeout, from 147 ns to 87 ns. The result codes, the wait conditions and the trace output are unchanged.
2026-11-12 13:45:30 +01:00
THEMANnt b249a39f9a fix(libkernel): read process CPU time for clock id 21 2026-11-11 20:09:37 +03:00
Adrià 510d0bf986 Merge pull request #16677 from xXPBSXx/fix/kernel-gettimezone-null-output-v2
fix(kernel): sceKernelGettimezone returns 0 for a null output
2026-11-11 03:01:46 +01:00
JJenkx a95aa1b5e9 chore: integrate current main for PR 12592 2026-11-09 14:25:15 -05:00
Dean d792f1ad5f Merge pull request #16437 from XatiX/fix/libkernel-measured-clock-einval
fix(libkernel): answer the clock ids a PS5 measured invalid as it does
2026-11-10 02:47:56 +13:00
XatiXandClaude Opus 5.5 4c5544719f fix(libkernel): declare GUEST_EIO for every platform
The measured EIO clock ids use GUEST_EIO in the shared clock_gettime path, but
the constant was declared only inside the Windows block, so non-Windows builds
failed. It now sits with the other guest errno constants.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 13:08:59 +00:00
Dean a6255d676e Merge pull request #15797 from oberonlift/lifted-cpu-helpers
refactor: route the libraries' fenv, TSC, cpuid and pause instructions through helpers
2026-11-09 07:08:42 +13:00
XatiXandClaude Opus 5.5 90c86fb36a fix(libkernel): answer the clock ids a PS5 measured invalid as it does
clock_gettime and sceKernelClockGettime threw for every clock id they do
not map. PS5 measurements of both exports (firmware 11.60, a payload
process, #16437) settle ids 3, 6 and 16 to 31 but 20 and 21:

- ids 3, 6 and 22 to 31 fail with EINVAL before the result is written,
  as both exports did; the raw system call also failed them with EINVAL
  (CFI-1216A, firmware 12.00, #15725);
- ids 16 to 19 fail with EIO (errno 5, 0x80020005 from
  sceKernelClockGettime) before the result is written, as both exports
  did.

Ids 20 and 21 succeed on the console with a time from clocks the probes
do not identify, so they still throw; the debt entry records what was
read and closes when what they count is measured.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 14:05:17 +00:00
Adrià 9594527a0c Merge pull request #7804 from mugurc/feat/libkernel-process-clock-macos
feat(libkernel): process, thread and clock queries on macOS hosts
2026-11-08 10:59:04 +01:00
Adrià ae2b0c0614 Merge pull request #13664 from jotitadev/fix/guest-copy-preserve-errno
fix(libc): keep errno when a checked guest copy faults on Linux
2026-11-08 03:06:38 +01:00
oberonliftandClaude Opus 5.5 f7f4b6c9d8 refactor(libkernel): read the timestamp counter through GuestCpu
sceKernelReadTsc and the TSC frequency measurement read the counter
through GuestCpu::ReadTsc, which is __rdtsc.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 17:19:45 +00:00
xXPBSXxandClaude Sonnet 5.5 f474d21c86 fix(kernel): sceKernelGettimezone returns 0 for a null output
We returned EFAULT.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-07 11:21:48 +01:00
GruzzberryandClaude Sonnet 5.5 a7dee2017e fix(libkernel_sys): fail settimeofday and clock_settime with EPERM for a jailed caller
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-06 17:05:56 +00:00
Dean 946bde70ed Merge pull request #11579 from plexerPK/codex/nanosleep-guest-request
fix(libkernel): copy nanosleep requests before reading guest fields
2026-11-06 00:04:17 +13:00
Dean 430a9b5473 Merge pull request #14620 from Danigamer05/feat/libc-timespec-getres-20261101
feat(libc): forward time resolution queries to the kernel
2026-11-05 17:27:46 +13:00
Dean 5924ecf2df Merge pull request #7156 from Amoenus/codex/fix-wait-trace-empty-main47
fix(libkernel): omit inactive wait trace sites
2026-11-04 16:58:26 +13:00
Dean f806099805 Merge pull request #14618 from slopgobblercobbler/test/libkernel-clock-gettime-invalid-clock-bounds
test(libkernel): cover invalid clock ID in clock_gettime
2026-11-03 11:40:23 +13:00
Jota 17d9e63030 Merge main into fix/guest-copy-preserve-errno 2026-11-02 17:16:16 +00:00
Romans Pokrovskis 82fd54db36 chore: refresh PR7156 against current prerequisites 2026-11-02 19:04:58 +02:00
Dean 9dc910f515 Merge pull request #11042 from EagleBearerYS/fix/count-throwing-done-net-kernel
fix: report five always-throwing network and kernel exports as not implemented
2026-11-02 23:26:36 +13:00
slopgobblercobbler 4e913b7444 test(libkernel): cover invalid clock ID in clock_gettime 2026-11-01 17:25:04 +01:00
Danigamer05 e8caaeb57a feat(libc): forward time resolution queries to the kernel 2026-11-01 17:07:28 +01:00
Romans Pokrovskis 442b990f19 chore: refresh wait trace fix onto main26fa 2026-11-01 11:13:36 +02:00
DeveshB-1 132b7bad73 fix(libkernel): return EFAULT from time conversions for unwritable stores 2026-11-01 07:36:05 +01:00
Yunus Shaikh 49a05d8769 Merge main into fix/count-throwing-done-net-kernel
The conflict in core/libs/tests/GuestRudpContextLifecycle.cpp with #13799 keeps both changes: this branch's removal of the check that sceRudpActivate throws, and main's sceRudpBind(ctx, 5, 0, 2) call after it.
2026-10-31 18:38:17 -07:00
Jota 829f40c523 fix(libkernel): keep errno when libkernel guest copies fault on Linux
libkernel has its own checked guest copy helpers that call
process_vm_readv/process_vm_writev directly: ReadGuest, WriteGuest and
StoreGuestId in Process.cpp, ReadGuest/WriteGuest in Udp.cpp (also
exported as GuestSocketReadGuest), CopyIovecs in Stdio.cpp and
ReadGuestTime in Time.cpp. On EFAULT they left errno at 14, which is the
guest errno, so a caller that reports the fault through a return code
(sceKernelReadv, or sceKernelGetAppInfo in #13798) still changed the
guest's errno. Windows and macOS do not touch errno there.

Apply the same rule as GuestCopyIn/GuestCopyOut: save errno before the
call and restore it when the call fails with EFAULT. Failures other than
EFAULT behave as before.
2026-10-31 06:43:55 -03:00
Romans Pokrovskis 70f7250c3b chore: refresh wait trace fix onto main5857 2026-10-31 01:27:06 +02:00
Romans Pokrovskis 1443f0a43f chore: merge current main into PR7156 2026-10-29 00:36:39 +02:00
JJenkx 0329c61962 fix(libc): ignore unavailable positive daylight hints 2026-10-28 17:41:59 -04:00
mugurc d05d5093a4 feat(libkernel): process, thread and clock queries on macOS hosts
The process, thread and clock functions that read /proc or call glibc
extensions:

- The program arguments come from _NSGetArgc and _NSGetArgv instead of
  /proc/self/cmdline.
- The current CPU comes from pthread_cpu_number_np.
- getrusage for a thread, the CPU clock of a thread and the CPU time of a
  guest thread (clock_gettime with the thread CPU clock) read the Mach
  thread_info of the thread. macOS has no pthread_getcpuclockid, and under
  Rosetta CLOCK_THREAD_CPUTIME_ID advances by about 1/41.7 of the thread's
  CPU time (24 MHz ticks read as nanoseconds), where natively it matches
  thread_info.
- The stack limits of a thread come from pthread_get_stackaddr_np and
  pthread_get_stacksize_np.
- sleeping with nanosleep restores errno, because macOS leaves ETIMEDOUT
  in it on success and the guest's errno is the host's.

The first local of a guest thread lies 4,464 bytes below the top of its
stack on macOS, more than the frame the pthread stack test allowed, so the
test allows two frames there.
2026-10-28 20:00:02 +01:00
XairRrR 5da36327d3 fix(libkernel): scale the reported TSC frequency under APS5_TIME_SCALE
Titles that execute rdtsc themselves ignored APS5_TIME_SCALE, because
only sceKernelReadTsc scaled its ticks. The reported TSC frequency is
now divided by the scale and sceKernelReadTsc returns raw ticks, so
ticks over the reported frequency follow the scale for both. The
JobManager worker spin keeps real time through the host frequency.

AI-assisted: yes
2026-10-28 18:47:46 +01:00