Skip to content

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

Merged
adriadam10 merged 3 commits into
boykopovar:mainfrom
YossiYad:feat/net-threads
Oct 24, 2026
Merged

adriadam10 merged 3 commits into
boykopovar:mainfrom
YossiYad:feat/net-threads

Conversation

@YossiYad

Copy link
Copy Markdown
Contributor

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 (fix(libSceNet): stop Sackboy loading retries on peer sockets #5836, test: organize library tests and label CTest suites #6044, Macos port #7201, feat: macOS on Apple Silicon host support (Rosetta 2 and MoltenVK) #7332, feat(prx): declare the missing PS5 3.20 system exports #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

@YossiYad YossiYad changed the title feat(libSceNet): implement the net thread calls and the network emulation getters feat(libSceNet): implement the net thread calls and refuse network emulation Oct 20, 2026
@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Progress report (72fe76f → 42961e1)

📈 System libraries: 45.99% (+0.05%, +6 implemented functions)

✅ 6 implemented
Library Name
libSceNet RunNetThread
libSceNet sceNetEmulationGet
libSceNet sceNetEmulationSet
libSceNet sceNetThreadCreate
libSceNet sceNetThreadExit
libSceNet sceNetThreadJoin

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

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.

Pull request Shared files not compared
PR 5836 core/libs/prx/libSceNet/CMakeLists.txt
core/libs/prx/libSceNet/Export.cpp
docs/dev/debt/libSceNet.md
PR 7201 core/libs/prx/libSceNet/Export.cpp
PR 9727 core/libs/prx/libSceNet/Export.cpp
docs/dev/debt/libSceNet.md
PR 9733 core/libs/prx/libSceNet/Export.cpp
docs/dev/debt/libSceNet.md
PR 10502 core/libs/prx/libSceNet/Export.cpp
docs/dev/debt/libSceNet.md

@YossiYad

Copy link
Copy Markdown
Contributor Author

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.

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 20, 2026
@adriadam10 adriadam10 self-assigned this Oct 21, 2026
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 21, 2026
@MarcZX10

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor Author

@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.

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 22, 2026
@MarcZX10

Copy link
Copy Markdown
Contributor

The local deterministic resolver-test change for #9609 adds an internal test hook in libSceNet/Export.cpp; the overlap checker flags the shared include area with #8254, but the behavior is separate from the net-thread exports. Can you confirm the ordering you prefer? The hook can be rebased after #8254 if that PR lands first; I’ll declare the dependency if needed.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 22, 2026
…ceNetThreadJoin

The thread runs the entry and argument of the caller's parameter block on a guest thread; a null block fails with EINVAL.
…EmulationSet

Network emulation exists only on development units.
@YossiYad

Copy link
Copy Markdown
Contributor Author

@MarcZX10 your resolver test hook is already on main (548aecf), so there's no order to settle. I rebased this PR onto it (head 42961e1b4). The only overlap was the include block of libSceNet/Export.cpp, where both includes stay, plus a reworded line in the debt file. guest_net_thread and the other guest_net_ tests pass 3 of 3.

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 23, 2026

@harisibrar1 harisibrar1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked against main 522e32e 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.

@adriadam10
adriadam10 merged commit feb5059 into boykopovar:main Oct 24, 2026
10 checks passed
@adriadam10

Copy link
Copy Markdown
Collaborator

Re-checked against current main (e512cd5): the only main change in Export.cpp is sceNetShowPolicy, which doesn't touch these exports, so the merge is clean. The head is unchanged; EINVAL on a null block, EOPNOTSUPP for both emulation calls and the guest_net_thread assertions still hold. Merged.

danielradosa added a commit to danielradosa/AnyPS5 that referenced this pull request Oct 25, 2026
… emulation behaviour comes from

Ours already implements the net thread and emulation exports more completely (copied parameter, exit flag, ERETURN) with tests in GuestSceNet; only took the PR's RunNetThread name for our trampoline, dropped its duplicate GuestNetThread test and debt.

(cherry picked from commit 04696b6953588b26f4c8c67805e5f2c29b4a95b9)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants