Repository navigation
fix(libkernel): report SCM_BINTIME and SCM_TIMESTAMP from recvmsg as measured on a PS5 - #11141
Conversation
…measured on a PS5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
11f9b5a to
49bcd75
Compare
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed exact head 49bcd7549e8a4baba5bb6cfdb7ca203013c2ca94. The IPv4-only SCM_BINTIME and IPv4/IPv6 SCM_TIMESTAMP records use the expected 32-byte control-message layout, order, arrival seconds/fraction encoding, and capacity-based truncation behavior. The helper is restricted to UDP IP sockets, and the debt entry records that the timestamp is sampled after host receive rather than at kernel packet arrival.
Local checks:
- GCC 12.2 syntax-only compilation of
Udp.cppandGuestUdp.cpp: passed. python3 tools/check_conventions.py --base upstream/main --head HEADandgit diff --check upstream/main...HEAD: passed.
The author reports PS5 observations for both message types/order/truncation and Windows guest_udp coverage across IPv4/IPv6, option combinations and control-buffer sizes. Hosted eligibility, conventions, intake, labels and report pass; product build/test jobs are skipped. I did not independently run the PS5 probe or Windows runtime tests. Declared merge-order dependencies remain as documented. No blocking issue found.
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
|
We had a parallel implementation of the same control messages on Windows run of our branch, for reference: Windows 11 Pro 10.0.26340, WinLibs GCC 15.2.0 r7, Release, The part this PR leaves out is the arrival time on Linux and macOS. Our branch enables AI-assisted: yes (Claude Code) |
|
I'd keep this PR to the measured stamp and the truncation, so a separate follow-up from you on top of |
|
Tested head
Two wording points, from FreeBSD 11.4
Nit: in the AI-assisted: yes (Claude Code); results above were run on this machine. |
… FreeBSD 11.4 does Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks, both points were right. 19566db follows 11.4 for an empty control buffer with a stamp pending: |
|
Re-checked head
AI-assisted: yes (Claude Code); results above were run on this machine. |
… characters Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@wachi35676 thanks: |
|
@Ragbie #11223 and this PR conflict in |
What
recvmsgon a UDP socket now returns theSCM_BINTIMEandSCM_TIMESTAMPcontrol messages whileSO_BINTIMEorSO_TIMESTAMPis set, as a retail PS5 (firmware 13.60) does. Until nowcontrolLengthwas always 0, and the options were only kept as bits. Measured with a homebrew probe from a payload process; the source and console log are in this gist (ptstamp).On the console, over loopback:
msg_controllenis 0.SO_TIMESTAMPon IPv4 gives one 32-byte record:cmsg_len32, level0xffff(SOL_SOCKET), type 2 (SCM_TIMESTAMP), then a 16-bytetimevalholding the real time of arrival.SO_BINTIMEgives{32, 0xffff, 4}(SCM_BINTIME) and a 16-bytebintime: seconds, then a 64-bit fraction.SCM_BINTIMEcomes first, thenSCM_TIMESTAMP, andmsg_controllenis 64.msg_controllen16 or 8, andMSG_CTRUNC(0x20). The data is intact.SCM_TIMESTAMPis produced;SO_BINTIMEadds nothing, as in FreeBSD 11'sip6_savecontrol.The records are built in a new
ArrivalTimestampshelper. The fraction is computed from nanoseconds as FreeBSD'stimespec2bintimedoes.recvmsgcopies as many bytes as the guest buffer holds and setsMSG_CTRUNCwhen some are cut off, as the console did; FreeBSD 11.4'skern_recvitcopies whole messages only, so this partial copy is a measured difference from it. Four cases were not measured and follow 11.4: an empty control buffer with a stamp pending (nothing copied,msg_controllen0,MSG_CTRUNC), a nullmsg_control(nothing, no flag), and TCP and Unix sockets (no message).The time is guest
CLOCK_REALTIME, read when the host hands the datagram over. That is later than the moment it reached the socket, and the debt entry says so. Sockets created through libSceNet have their own receive path and are unchanged.Before and after
recvmsgon a UDP socketmsg_controllen0SO_TIMESTAMPSCM_TIMESTAMPrecordmsg_controllen0SCM_TIMESTAMPrecordSO_BINTIME(IPv4)SCM_BINTIMErecordmsg_controllen0SCM_BINTIMErecordSCM_BINTIMEthenSCM_TIMESTAMP, 64 bytesmsg_controllen0SCM_BINTIMEthenSCM_TIMESTAMP, 64 bytesMSG_CTRUNCmsg_controllen0MSG_CTRUNCSO_BINTIMEon IPv6msg_controllen0Tested
Windows 11, WinLibs GCC 15.2, full build.
guest_udppasses 3 times out of 3. On IPv4 and IPv6 it covers no option, each option and both, with control buffers of 0, 8, 16, 40, 64 and 80 bytes. It checks the record layout and order,msg_controllen,MSG_CTRUNC, that bytes past the copied length stay untouched, and that the seconds fall betweenCLOCK_REALTIMEreadings taken before and after the call.socket|udp|tcp|net_|recv|send|underscorepass.tools/check_conventions.pypasses.Head
49bcd7549eonmainaeff26bd97.Head
19566dbee8setsMSG_CTRUNCfor an empty control buffer with a stamp pending, as 11.4 does (wachi35676's review), andguest_udpnow expects it and checks that a nullmsg_controlgets no flag.guest_udpandguest_socket_optionspass 3 times out of 3 on Windows 11 (WinLibs GCC 15.2) and on Linux (WSL, GCC 13.3); with the oldUdp.cpplineguest_udpfails.tools/check_conventions.pypasses.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)recvmsg's receive check), feat(libkernel): pass descriptors in SCM_RIGHTS messages on Unix sockets #7090 (UnixSCM_RIGHTS) and fix(libkernel): drop the data a socket held before shutdown(SHUT_RD) in every receive path #10767 (SHUT_RD), which edit the end ofrecvmsg, and docs(libkernel): record the version stubs, kern.boottime and the SoC power block as measured on a PS5 #11116 (mine), which edits the debt entry next to theSO_TIMESTAMPone; merge order only, and the control messages are disjoint (this PR only adds them on IP datagram sockets)