feat(libSceNet): implement the net thread calls and refuse network emulation #8254

Merged
YossiYad merged 3 commits from upstream-pr/8254 into main 2026-10-24 16:35:47 +00:00
YossiYad commented 2026-10-20 07:09:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by YossiYad on 2026-10-20T07:09:08Z.


What

Implements five libSceNet exports that were declared without parameters and threw:

  • sceNetThreadCreate(Pthread* thread, param, const char* name) starts a guest thread (scePthreadCreate) that calls the entry(arg) of the caller's parameter block { entry, arg, reserved, flags }, and writes the thread to thread when it is not null. A null block fails with EINVAL (0x80410116, errno 22), the convention the library uses for its other failures.
  • sceNetThreadExit() ends the calling thread (scePthreadExit), and sceNetThreadJoin(Pthread) joins one (scePthreadJoin).
  • sceNetEmulationGet and sceNetEmulationSet return EOPNOTSUPP (0x8041012D, errno 45).

The signatures, the block layout and the emulation result follow shadPS4 (PS4); none is measured on a PS5. The new debt entry says so and lists where this differs from shadPS4: flags is ignored (shadPS4 ends the thread with pthread_exit when bit 0 is set, which ends it the same way), and a failing scePthreadCreate or scePthreadJoin result is returned as it is without setting the net errno. The five "unknown signature" entries are removed.

sceNetGetStatisticsInfo is left out on purpose: shadPS4 fills it with invented free-memory figures, and there is nothing measured to report instead.

Tested

Linux (Fedora 44, GCC, Ninja, -DBUILD_TESTING=ON), based on main e9cc4a8efb:

  • New guest_net_thread (core/libs/tests/GuestNetThread.cpp): a thread runs its entry with its argument and joins; a null block returns EINVAL, sets errno and leaves the output alone; a thread that calls sceNetThreadExit stops before the rest of its entry and still joins; a null thread output is accepted and the thread runs; both emulation calls return EOPNOTSUPP and set errno. It passed 20 of 20 runs. It fails when the thread does not call the entry, when sceNetThreadExit returns instead of ending the thread, and when sceNetEmulationGet returns 0.
  • guest_sce_net still passes.
  • Full ctest: 1671 of 1676 pass. The 5 failures (application_heap_scripting, application_heap_lazy, agc_driver_bda_device, agc_driver_guest_memory_lifetime, agc_driver_tessellation) fail the same way on main on this machine.
  • tools/progress.py --compare: libraries +0.09%; it counts the five exports plus the internal thread entry RunNetThread.
  • tools/check_conventions.py --base upstream/main passes. tools/pr_overlap.py lists only PRs that conflict with main and share Export.cpp, the debt file or CMakeLists.txt (#5836, #6044, #7201, #7332, #8106); none of their diffs touches these functions.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4932281636 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8254). Originally posted by [YossiYad](https://github.com/YossiYad) on 2026-10-20T07:09:08Z. --- ### What Implements five libSceNet exports that were declared without parameters and threw: - `sceNetThreadCreate(Pthread* thread, param, const char* name)` starts a guest thread (`scePthreadCreate`) that calls the `entry(arg)` of the caller's parameter block `{ entry, arg, reserved, flags }`, and writes the thread to `thread` when it is not null. A null block fails with `EINVAL` (`0x80410116`, errno 22), the convention the library uses for its other failures. - `sceNetThreadExit()` ends the calling thread (`scePthreadExit`), and `sceNetThreadJoin(Pthread)` joins one (`scePthreadJoin`). - `sceNetEmulationGet` and `sceNetEmulationSet` return `EOPNOTSUPP` (`0x8041012D`, errno 45). The signatures, the block layout and the emulation result follow [shadPS4](https://github.com/shadps4-emu/shadPS4/blob/a808e76/src/core/libraries/net/net.cpp) (PS4); none is measured on a PS5. The new debt entry says so and lists where this differs from shadPS4: `flags` is ignored (shadPS4 ends the thread with `pthread_exit` when bit 0 is set, which ends it the same way), and a failing `scePthreadCreate` or `scePthreadJoin` result is returned as it is without setting the net errno. The five "unknown signature" entries are removed. `sceNetGetStatisticsInfo` is left out on purpose: shadPS4 fills it with invented free-memory figures, and there is nothing measured to report instead. ### Tested Linux (Fedora 44, GCC, Ninja, `-DBUILD_TESTING=ON`), based on `main` `e9cc4a8efb`: - New `guest_net_thread` (`core/libs/tests/GuestNetThread.cpp`): a thread runs its entry with its argument and joins; a null block returns `EINVAL`, sets errno and leaves the output alone; a thread that calls `sceNetThreadExit` stops before the rest of its entry and still joins; a null thread output is accepted and the thread runs; both emulation calls return `EOPNOTSUPP` and set errno. It passed 20 of 20 runs. It fails when the thread does not call the entry, when `sceNetThreadExit` returns instead of ending the thread, and when `sceNetEmulationGet` returns 0. - `guest_sce_net` still passes. - Full `ctest`: 1671 of 1676 pass. The 5 failures (`application_heap_scripting`, `application_heap_lazy`, `agc_driver_bda_device`, `agc_driver_guest_memory_lifetime`, `agc_driver_tessellation`) fail the same way on `main` on this machine. - `tools/progress.py --compare`: libraries +0.09%; it counts the five exports plus the internal thread entry `RunNetThread`. - `tools/check_conventions.py --base upstream/main` passes. `tools/pr_overlap.py` lists only PRs that conflict with `main` and share `Export.cpp`, the debt file or `CMakeLists.txt` (#5836, #6044, #7201, #7332, #8106); none of their diffs touches these functions. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
YossiYad commented 2026-10-20 11:41:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by YossiYad on 2026-10-20T11:41:55Z.


Rebased onto current main (head ca1fe58df, main d50ec76da). The only conflict was in debt/libSceNet.md, where main added the sceNetEtherStrton entry at the same spot; I kept both. main still has sceNetThreadCreate, sceNetThreadExit, sceNetThreadJoin, sceNetEmulationGet and sceNetEmulationSet as stubs, and the added and removed lines match the previous head.

guest_net_thread, guest_sce_net, guest_inet_address and the datagram tests pass 3 of 3 here, and check_conventions has no findings.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6290045141 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8254#issuecomment-6290045141). Originally posted by [YossiYad](https://github.com/YossiYad) on 2026-10-20T11:41:55Z. --- Rebased onto current `main` (head `ca1fe58df`, `main` `d50ec76da`). The only conflict was in `debt/libSceNet.md`, where `main` added the `sceNetEtherStrton` entry at the same spot; I kept both. `main` still has `sceNetThreadCreate`, `sceNetThreadExit`, `sceNetThreadJoin`, `sceNetEmulationGet` and `sceNetEmulationSet` as stubs, and the added and removed lines match the previous head. `guest_net_thread`, `guest_sce_net`, `guest_inet_address` and the datagram tests pass 3 of 3 here, and `check_conventions` has no findings.
MarcZX10 commented 2026-10-22 02:07:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T02:07:08Z.


I am reviewing #9506, which adds sceNetSetDnsInfo, sceNetSetDns6Info and sceNetGetDns6Info plus a new registered test and debt entry. The overlap bot could not compare some of these branches because of base conflicts, and this PR author has not yet recorded an agreed merge order. Please confirm whether your current changes overlap these exact exports, CMake/test insertion, or debt section, and whether #9506 can land before your PR or should depend on yours. The #9506 author is being asked to record the agreed order in Depends on and the overlap note.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6330953348 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8254#issuecomment-6330953348). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T02:07:08Z. --- I am reviewing #9506, which adds `sceNetSetDnsInfo`, `sceNetSetDns6Info` and `sceNetGetDns6Info` plus a new registered test and debt entry. The overlap bot could not compare some of these branches because of base conflicts, and this PR author has not yet recorded an agreed merge order. Please confirm whether your current changes overlap these exact exports, CMake/test insertion, or debt section, and whether #9506 can land before your PR or should depend on yours. The #9506 author is being asked to record the agreed order in `Depends on` and the overlap note.
YossiYad commented 2026-10-22 05:33:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by YossiYad on 2026-10-22T05:33:56Z.


@MarcZX10 no shared exports. This PR does sceNetThreadCreate, sceNetThreadExit, sceNetThreadJoin, sceNetEmulationGet and sceNetEmulationSet, and #9506 does the DNS info calls. Both add a test registration to libSceNet/CMakeLists.txt and an entry to docs/dev/debt/libSceNet.md, so whichever lands second gets a text conflict there and nothing else. #9506 can land first, and I'll rebase this one on it.

Also rebased onto main da54c652e after #9137 (head eaa6d8655). #9137 declared NetThreadParameter without a body. This PR's { entry, arg, reserved, flags } block now completes that declaration, the calls take main's parameter types, and the debt lines this PR settles (sceNetThreadExit still returning int, and thread creation in the unsupported list) are removed. guest_net_thread passes 3 of 3.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6333560493 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8254#issuecomment-6333560493). Originally posted by [YossiYad](https://github.com/YossiYad) on 2026-10-22T05:33:56Z. --- @MarcZX10 no shared exports. This PR does `sceNetThreadCreate`, `sceNetThreadExit`, `sceNetThreadJoin`, `sceNetEmulationGet` and `sceNetEmulationSet`, and #9506 does the DNS info calls. Both add a test registration to `libSceNet/CMakeLists.txt` and an entry to `docs/dev/debt/libSceNet.md`, so whichever lands second gets a text conflict there and nothing else. #9506 can land first, and I'll rebase this one on it. Also rebased onto `main` `da54c652e` after #9137 (head `eaa6d8655`). #9137 declared `NetThreadParameter` without a body. This PR's `{ entry, arg, reserved, flags }` block now completes that declaration, the calls take `main`'s parameter types, and the debt lines this PR settles (`sceNetThreadExit` still returning int, and thread creation in the unsupported list) are removed. `guest_net_thread` passes 3 of 3.
harisibrar1 commented 2026-10-24 13:51:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by harisibrar1 on 2026-10-24T13:51:03Z.

Review: APPROVED


Checked against main 522e32e3b6 and shadPS4 a808e76 src/core/libraries/net/net.cpp:

  • It still merges cleanly with current main. The five exports still throw on main, and the debt lines you edit and remove are unchanged there.
  • The new libkernel imports (scePthreadCreate, scePthreadJoin, scePthreadExit) are all longer than 11 characters, so the Windows PE NID patcher shouldn't hit the import-name length limit, and their declarations match libkernel's definitions.
  • The parameter block, the null-param EINVAL and the emulation EOPNOTSUPP match shadPS4, which also reads the block on the new thread. The debt entry describes the one real difference accurately: errors are returned raw, where shadPS4 returns KERNEL_ERROR_UNKNOWN + e and sets the net errno.
  • No made-up success: the emulation calls fail, and the thread calls do real work. LGTM.

Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5638479833 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8254#pullrequestreview-5638479833). Originally posted by [harisibrar1](https://github.com/harisibrar1) on 2026-10-24T13:51:03Z. **Review:** APPROVED --- Checked against main 522e32e3b6 and shadPS4 a808e76 `src/core/libraries/net/net.cpp`: - It still merges cleanly with current main. The five exports still throw on main, and the debt lines you edit and remove are unchanged there. - The new libkernel imports (`scePthreadCreate`, `scePthreadJoin`, `scePthreadExit`) are all longer than 11 characters, so the Windows PE NID patcher shouldn't hit the import-name length limit, and their declarations match libkernel's definitions. - The parameter block, the null-param `EINVAL` and the emulation `EOPNOTSUPP` match shadPS4, which also reads the block on the new thread. The debt entry describes the one real difference accurately: errors are returned raw, where shadPS4 returns `KERNEL_ERROR_UNKNOWN + e` and sets the net errno. - No made-up success: the emulation calls fail, and the thread calls do real work. LGTM. Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!8254
No description provided.