Skip to content

feat(http2): complete asynchronous send and read - #170

Open
Thimo188 wants to merge 39 commits into
mainfrom
upstream-pr/11630
Open

Thimo188 wants to merge 39 commits into
mainfrom
upstream-pr/11630

Conversation

@Thimo188

@Thimo188 Thimo188 commented Dec 2, 2026

Copy link
Copy Markdown
Owner

Imported from boykopovar/AnyPS5#11630, originally opened by edubox.

Source commit: 301e49b659435752a0477f6de21a7092a142b1e1. The import branch preserves this fetched upstream PR snapshot. The description and validation below are copied from upstream; no new code changes or test runs were made for this import. Original reviews, discussions, and attachments remain at the linked upstream PR.


What

sceHttp2SendRequestAsync, sceHttp2ReadDataAsync and sceHttp2WaitAsync threw. This completes them over the existing transport:

  • sceHttp2SendRequestAsync copies the body, runs Send on a worker and queues an Http2AsyncResult whose result is the transport's result, then triggers the kqueue user event (equeue at 0, event id at 8, user data at 16, the layout inferred from PPSA17221).
  • sceHttp2ReadDataAsync does the same for Read and reports the bytes read in result.
  • sceHttp2WaitAsync waits for the oldest completion. A null timeout waits indefinitely; *timeout == 0 throws because whether zero blocks is unknown (PPSA02195 polls with a zero timeout and aborts the request on an immediate timeout, but the 11.00 kernel path is not in the dump), recorded in the debt entry; a nonzero *timeout is a microsecond deadline that returns 0x817b1079 when it expires, which is the 11.00 mapping of the kernel's 0x8002003c. A null result returns 0x817b1225 and a non-null trailing argument or a non-zero reserved field of the result returns 0x817b11fe. Each request owns a stable completion state; deleting a request or its parent retires that state, wakes waiters with the invalid-id error, and drops queued and later completions without triggering a user event. Publication and retirement share the request state lock, so a completion cannot be delivered after deletion returns.
  • event_type is 0 for send and 1 for read, confirmed by the 11.00 completion kinds (+0x1600 pairs mapped at 0x9a4f). *timeout receives the remaining microseconds, following the forwarded kernel pointer; whether a zero timeout blocks is still an open kernel question recorded in the debt entry, an unregistered user event is not detected at submission, and a transport exception is rethrown from sceHttp2WaitAsync.

Evidence

The argument and timeout contract comes from the decrypted firmware 11.00 libSceHttp2.sprx: sceHttp2SendRequestAsync at 0x1940/internal 0x4a60, sceHttp2ReadDataAsync at 0x1b20/0x4e20 and sceHttp2WaitAsync at 0x1c20/0x9a00. The wait forwards the caller's pointer to sceKernelWaitSema(sema, 1, timeout) (0x4790) and remaps the kernel timeout 0x8002003c to 0x817b1079 (0x9a79); the result and trailing-argument checks are at 0x1d21, 0x1cca and 0x1cd3, and the completion kind at +0x1600 selects event_type through the table at 0x271d0. Because the 11.00 submission bodies reject a non-null trailing pointer with 0x817b11fe while PPSA22408 passes one, the trailing pointer stays ignored and the debt entry records the version split.

Tested

Linux (CachyOS), GCC 16.2.1. guest_http2 submits an asynchronous request whose body length does not match the declared content length, then checks the user event payload and that sceHttp2WaitAsync rethrows the worker's exception. guest_http2_transport drives a real loopback HTTP/2 send and read through the asynchronous API, plus the async-failure, wait-versus-delete, two-waiter, parent-teardown, deletion-after-publication, optional-argument and expired-wait cases. The expired-wait case pins 0x817b1079, and the null-timeout case stalls the response and checks that the wait returns only after the completion. The zero-timeout case is not pinned because its console behaviour is unknown. guest_http2, guest_http2_cookies, guest_http2_transport and guest_http2_early_response pass in the Release build.

Title: PPSA02195 polls sceHttp2WaitAsync with *timeout == 0 and aborted the request as soon as it received an immediate timeout; that remains the only observation and the case stays unimplemented until a console measurement settles it. It was run with other local changes on the same tree.

Checklist

edubox and others added 30 commits November 4, 2026 10:36
The 11.00 wait body passes the caller's timeout to sceKernelWaitSema, so a zero timeout polls instead of blocking, the timeout surfaces as 0x817b1079 and *timeout receives the remaining microseconds. A null result is 0x817b1225 and a non-null trailing argument or non-zero result reserved field is 0x817b11fe. The submission bodies ignore their trailing pointer, which this tree keeps doing because PPSA22408 passes one even though 11.00 rejects it.
PPSA02195 polls with a zero timeout and aborts the request on an immediate timeout, so the blocking behaviour stays. The 11.00 body forwards the pointer to sceKernelWaitSema, so whether zero blocks is a kernel question this dump cannot answer; the debt entry records it. The expired-wait code is corrected to 0x817b1079 and the result and trailing-argument validation follows the same bodies.
sceHttp2WaitAsync keeps the deadline so a timed wait writes the remaining microseconds back through the caller pointer, matching the forwarded kernel wait. The async wait test asserts the expired timeout is cleared.
Apply review request from 2026-11-05: resolve the GuestHttp2Transport Mode enum and libSceHttp2 debt-doc conflicts.
…letions

# Conflicts:
#	core/libs/tests/GuestHttp2Transport.cpp
#	docs/dev/debt/libSceHttp2.md
…letions

# Conflicts:
#	core/libs/prx/libSceHttp2/Export.cpp
…letions

# Conflicts:
#	core/libs/tests/GuestHttp2Transport.cpp
…letions

# Conflicts:
#	core/libs/prx/libSceHttp2/Export.cpp
#	core/libs/tests/GuestHttp2.cpp
#	docs/dev/debt/libSceHttp2.md
The merge of main folded the offline requests entry into the asynchronous
requests entry. Restore the two points it dropped: offline mode in PPSA24263,
and that the console's code for an offline libSceHttp2 send is not measured.
Also say that the offline send triggers the user event itself.
…ovar#15996

The merge of main took this branch's asynchronous calls over boykopovar#15996 and
dropped its debt entry. Record that these calls follow the firmware 11.00
module, that the module bundled with PPSA20397 stubs sceHttp2ReadDataAsync
with 0x80436063 and never reads the wait timeout, and that the effect on
that title is not measured. Evidence from boykopovar#15996 (akkadbakkad89).
sceHttp2WaitAsync refused every zero-timeout call before it looked at
the request's completions. With APS5_NET_DISCONNECTED=1 the send queues
its 0x80431063 completion at once, and PPSA30839 then polls for it with
a zero timeout, so the title stopped at 6 s where main runs on (main
returns any queued offline completion whatever the timeout).

A zero-timeout wait now returns a completion that is already queued:
the semaphore is signalled then, so the wait returns at once whichever
way the console reads zero. With nothing queued it still throws.

Title runs by milescoviello; fix-up on edubox's branch.
…letions

# Conflicts:
#	core/libs/tests/GuestHttp2Transport.cpp
#	docs/dev/debt/libSceHttp2.md
edubox and others added 9 commits November 13, 2026 11:44
Queue one 0x817b1080 completion per operation in flight when
sceHttp2DeleteRequest runs, after stopping the transport, so a blocked
sceHttp2WaitAsync returns 0 with the aborted result of the operation's
own kind and the read buffer is no longer written when the delete
returns. Phase deadlines also apply to a transport that ignores the
overall timeout.
A request deleted between the id lookup and the in-flight count still
started a worker that could read into the guest buffer after the delete.
ReadDataAsync and both SendRequestAsync paths now return the invalid id
error under the state lock instead. Drop the unused ERROR_NETWORK.
@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown

Progress report (5cf487d → 301e49b)

➖ System libraries: 47.94% (+0.0%, +1 implemented, -1 reverted functions)

✅ 1 implemented
Library Name
libSceHttp2 sceHttp2WaitAsync
⚠️ 1 went back to stubs
Library Name
libSceHttp2 sceHttp2ReadDataAsync

Changed libraries (implemented exports)

Library Before After Change
libSceHttp2 25/71 (35.21%) 25/71 (35.21%) +0.00%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants