Commit Graph
22 Commits
Author SHA1 Message Date
Dean 7f02cb1802 Merge pull request #11402 from 00xDisaster/fix/libkernel-settime-efault
fix(libkernel): check settimeofday and clock_settime pointers
2026-10-27 21:25:30 +13:00
Dean 783b391bca Merge pull request #11534 from milescoviello/test/kernel-gettimeofday
test(libkernel): cover sceKernelGettimeofday's null check and the time it reads
2026-10-27 19:05:03 +13:00
milescovielloandClaude Opus 5.5 dc3c2def0b test(libkernel): cover sceKernelGettimeofday's null check and the time it reads
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-26 17:55:50 +00:00
Disaster 78571ca2fb fix(libkernel): check settimeofday and clock_settime pointers
Both read their caller's structures in place before validation, so an unreadable pointer crashed the host. Copy them in with a checked read first and return EFAULT, as FreeBSD 11.4 does.

Fixes #11370
2026-10-26 14:29:02 +03:00
frankea 4db6ed7635 Merge remote-tracking branch 'origin/main' into fix/kernel-gettimezone-host-zone
# Conflicts:
#	core/libs/tests/GuestFreebsdClocks.cpp
2026-10-25 20:22:45 -04:00
boykopovar f38d29fd08 refactor(sdk): add canonical headers for remaining libraries 2026-10-24 23:17:42 +03:00
frankea fabe448517 fix(libkernel): report the host zone's standard offset and daylight saving amount from sceKernelGettimezone
sceKernelGettimezone wrote {0, 0} for every zone. A PS5 on firmware
13.40 set to US Eastern returned tz_minuteswest -300 and tz_dsttime 60:
the standard offset in minutes east of UTC, without the summer time in
effect on the run date, and the zone's daylight saving amount in
minutes. Both now come from the host zone, through the same HostZoneAt
and HostDaylightAmount the calendar conversions use.

guest_freebsd_clocks checks five TZ settings (UTC0, IST-5:30, BRT+3,
EST5EDT, CET-1CEST) and the null pointer.
2026-10-23 23:27:29 -04:00
mattogepetoandClaude Sonnet 5.5 c17c6a5114 fix(libkernel): return EFAULT from clock_gettime for a null result pointer
clock_gettime threw invalid_argument when the result pointer was null,
before looking at the clock id. FreeBSD 11.4's sys_clock_gettime reads the
clock through kern_clock_gettime, which fails with EINVAL for an unknown
clock, and only then copies the result out, so a null pointer fails with
EFAULT.

Read the clock into a local value first, then fail with -1 and EFAULT when
the pointer is null. A clock that is not supported still throws before the
pointer is looked at. Test the null pointer for the supported clocks.

Written with AI assistance (Claude).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-17 15:33:47 +02:00
Claude f5d856d85e test(libkernel): take the summer time amount from the C runtime on Windows
A TZ variable does not set the UCRT's _dstbias, so after the system zone
of a CI runner without daylight saving it stays 0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017iLxaSz4qjmirfqKZdhVQk
2026-10-14 07:56:03 +00:00
Claude bb5f7d7e07 Merge remote-tracking branch 'upstream/main' into pr-main
# Conflicts:
#	core/libs/tests/GuestFreebsdClocks.cpp
2026-10-14 06:49:51 +00:00
ae9978a98e feat(libkernel): add clock_settime with FreeBSD argument checks
PS5MC (PPSA99420, Kodi 22) imports clock_settime (d7nUj1LOdDU) from
libkernel.prx, one reference, after sigwaitinfo in its import order.
Predicted stop once the imports ahead of it are covered (not a run):

  FAIL: unresolved ELF import d7nUj1LOdDU from libkernel.prx

The NID is computed with tools/nid_names.py and matches aerolib.

Follows FreeBSD 11.4 sys/kern/kern_time.c sys_clock_settime and
kern_clock_settime (8c639945a44588f6cfdddfb057bb5aad88735da0) for a
root caller: EFAULT for a null time (copyin), EINVAL for any clock but
CLOCK_REALTIME and for a negative tv_sec or a tv_nsec outside 0 to
999999999. A valid CLOCK_REALTIME request throws with the requested
time named, since the host clock must not be set and no guest clock
offset is kept.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

Co-authored-by: David <[email protected]>
2026-10-13 14:57:46 +01:00
Claude 15969f2753 fix(libkernel): report the zone's daylight saving amount from sceKernelConvertLocaltimeToUtc
libc mktime subtracts it when tm_isdst is set outside summer time, so it
must not be zero there.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017iLxaSz4qjmirfqKZdhVQk
2026-10-13 12:19:55 +00:00
Claude ae7f5e3aaa fix(libkernel): report west_sec as seconds east of UTC
PPSA99203 (PS5SX2) documents that the console fills west_sec with the
offset east of UTC despite the field's name.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017iLxaSz4qjmirfqKZdhVQk
2026-10-13 11:37:12 +00:00
Claude 56c8f346fb fix(libkernel): convert local time with the host time zone
sceKernelConvertUtcToLocaltime and sceKernelConvertLocaltimeToUtc returned
the time unchanged while libc localtime follows the host zone, so a title
that mixes them shows UTC as local time (#5067).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017iLxaSz4qjmirfqKZdhVQk
2026-10-13 11:27:28 +00:00
Dean f3abf38307 Merge pull request #3855 from Lorkydey/fix/libkernel-utc-dst-width
fix(libkernel): limit UTC-to-local DST output to 32 bits
2026-10-12 16:07:49 +13:00
Lorkydey 36d37a062a fix(libkernel): limit UTC-to-local DST output to 32 bits 2026-10-11 19:56:47 +02:00
QRMOE 10e822cf04 test(libkernel): cover omitted clock resolution
Cover 20 clock IDs, preserved guest errno, non-null unsupported clocks and the SCE null-output fault. The regression fails against main and passes with the accompanying fix.

AI-assisted: yes
2026-10-11 15:53:15 +02:00
Dean 50cea78f6b Merge pull request #2291 from AchrafReyani/fix/libkernel-null-time-results
fix(libkernel): accept null results in gettimeofday and clock_getres
2026-10-10 20:07:40 +13:00
Achraf ReyaniandClaude Opus 5.5 70d6382e33 fix(libkernel): accept null results in gettimeofday and clock_getres
FreeBSD's gettimeofday stores the time only when tp is not null, and
clock_getres the resolution only when res is not null; both succeed
otherwise. Both threw, which aborted a title probing a clock or only
asking for the time zone. Write into a local result instead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-10 12:24:29 +09:00
authurtabo-byte 035b675e6d fix(libkernel): initialize the full local-time conversion state 2026-10-09 15:43:24 -07:00
Adrià FranchandClaude 3f2e5150c2 feat(libc): implement _Xtime_get_ticks
Co-Authored-By: Claude <[email protected]>
2026-10-05 20:16:11 +02:00
DotDebianandClaude Opus 5.5 096bdb38c2 fix(libkernel): give CLOCK_VIRTUAL, CLOCK_PROF and CLOCK_SECOND their FreeBSD meaning
clock_gettime and clock_getres served three FreeBSD clock ids with the wrong
clock or not at all:

- CLOCK_VIRTUAL (1) was the monotonic clock on Windows and threw on Linux; it
  is the user CPU time of the process.
- CLOCK_PROF (2) threw on both hosts; it is the user plus system CPU time of
  the process.
- CLOCK_SECOND (13) returned the coarse realtime clock with nanoseconds and a
  sub-second resolution; it is the current second with tv_nsec 0 and a
  resolution of one second.

Behaviour follows FreeBSD 11 clock_gettime(2) and kern_clock_gettime /
kern_clock_getres in sys/kern/kern_time.c.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-05 10:24:22 +02:00