Commit Graph
184 Commits
Author SHA1 Message Date
libretroadmin f1208a7a5a Make threading lock-free
The core and the headless tools no longer use mutexes, condition variables,
spinlocks, std::atomic, std::thread or volatile flags. Threads hand off through
libretro-common's retro_atomic and rthreads plus a few small pieces on top of
them in Common/Thread: Thread, MpscQueue, EventCounter, ParkingLot waits and
ReaderGate. Every wait blocks until it's woken; nothing polls on a timer.

State that only one thread touches just loses its lock. The PSP filesystem,
sceIo and the savedata dialog now belong to the emulation thread: async reads
and writes run when they're queued and complete later in emulated time, and
the IO and savedata threads are gone. The friend finder only talks to the
adhoc server and hands what it gets to the emulation thread. GPU init always
runs on the thread that starts the game.

The Vulkan render and compile queues, pipeline and render pass caches, delete
list and SPIR-V cache, the GL render queue, the software renderer's jit caches,
the file loader caches, the web debugger, UPnP, input, savestates, logging and
the GE debugger all hand off through queues and atomics. The IR jit's spinning
profiler thread goes.

A CPU thread with nothing to run now sleeps until work is queued instead of
spinning. Headless with --debugger waits for a client while stopped, and ends
the run once every client that connected has left. Web server shutdown keeps
servicing the CPU queue until the server has finished.
2026-10-09 04:56:16 +02:00
Henrik RydgårdandClaude Opus 5 3a70c6b149 Install PKG game updates, and boot them
Opening a .pkg now offers to install it, the way a .zip does - see the new
InstallPkgScreen, which shows what the update patches, what it'll take up
on disk (exact, since package contents aren't compressed) and where it's
going. The package's PS3-style USRDIR/CONTENT wrapping is stripped so the
files land where the PSP expects them, in PSP/GAME/<DISC_ID>.

Booting a disc then looks for PSP/GAME/<DISC_ID>/PBOOT.PBP and boots that
instead of the disc's own EBOOT, leaving the disc mounted - so the update
overrides the files it ships and the disc supplies the rest. The update's
DISC_ID has to match; a DISC_VERSION mismatch only warns, since updates do
get used with slightly different dumps in practice.

Verified against the whole corpus: every one installs, and the
digital NP* update/base-image pairs that could be assembled all boot the
patch rather than the disc's executable. That includes Super Robot Taisen
Operation Extend from a real NPUMDIMG EBOOT.PBP, which settles that
ISO.BIN.EDAT does not re-key the PBOOT - a digital title's patched EBOOT is
encrypted exactly like a UMD one. On the UMD side, the patched
LittleBigPlanet reads PATCH.ARC out of the install alongside the disc's own
archive.

The DISC_VERSION warning turns out to be load-bearing: many of the pairs
mismatch, because the dumps in circulation are later disc revisions than the
updates were built against. docs/pkg_notes.md has the numbers, and the one
thing that doesn't work - PGD-wrapped .sprx modules, which
sceKernelLoadModuleNpDrm can't load.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-08 11:15:15 -06:00
Henrik Rydgård 5c329415a5 PSPLoaders: bound the UMD_DATA.BIN read
InitMemorySizeForGame read all of disc0:/UMD_DATA.BIN into a vector and then copied
it into a string, with no size limit, from an image we don't control - and the
DISC_ID that gets us here is equally forgeable, it just has to match one of the 16
g_HDRemasters entries. A real UMD_DATA.BIN is a few dozen bytes; anything larger is
a mistake or an attack, so check the size before reading.
2026-08-31 12:54:06 +02:00
Henrik Rydgård 1d991557e8 Extend LoadExecForKernel with real VSH loadexec/exit syscalls
Adds SceKernelLoadExecVSHParam and fills in the rest of LoadExecForKernel's
NIDs: real implementations for sceKernelExitVSHVSH/Kernel
(mirrors sceKernelExitGame) and sceKernelLoadExecBufferVSHUsbWlan (loads
an exec from an in-RAM buffer instead of a file, plus UNIMPL stubs.

sceKernelLoadExecBufferVSHUsbWlan needed __KernelLoadExec split into a
file-reading front end and a shared __KernelLoadExecFromPtr back end
that both it and the new buffer-based path call into.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PSNaZnHCjmryS3ziVN9gZU
(cherry picked from commit 4adbedec9e2e3221113c9e5ad00b248bba1153e1)
2026-08-24 10:58:34 +02:00
Henrik Rydgård 786a1530de Correct host0: mount 2026-08-24 09:30:44 +02:00
Henrik RydgårdandClaude Opus 5 15bb7b2866 PSPLoaders: handle the failure cases around mountRoot and boot detection
NormalizePath's Windows branch ignored GetFullPathName failing. A zero return
matched neither of its two branches, so the 512-character buffer was handed back
with whatever was in it.

The content-URI branch then computed its relative path by substr()ing the
decoded FilePath() of the two URIs - but the containment check above it compared
the URIs themselves, which doesn't imply the same prefix relationship for the
decoded paths. When it doesn't hold, substr() throws out_of_range, uncaught.
Checked explicitly now.

More minor fixes.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GZq8ZtJmFY7bkX5FVkr3P9
2026-08-20 00:42:01 +02:00
Henrik Rydgård e9a3449ede More MIPSState * plumbing (manual) 2026-08-12 14:02:19 +02:00
Henrik Rydgård 5e6a051952 Fix path traversal in texture pack filenames; use HasPathTraversal in savestate migration
Texture pack filenames/aliases from textures.ini were used to build read
and write paths with no '..' check, letting a malicious pack read or
write files outside the pack directory.

- LoadIniValues rejects entries with a parent dir component via
  HasParentDirComponent.
- ReplacedTexture::Prepare skips such filenames as defense in depth.
- PSPLoaders savestate migration now uses the shared HasPathTraversal
  helper instead of inline separator checks.
2026-08-01 13:16:22 +02:00
Henrik Rydgård c0f5b3d3ee Skip savestate migration if game ID strings contain a path separator
DISC_ID/DISC_VERSION/homebrewName are attacker-controlled and were used
unsanitized to build migration rename paths. Skip the migration step if
any of them contain a '/' or '\' so the destination can't escape the
savestate directory.
2026-08-01 11:41:24 +02:00
Henrik Rydgård 54618c67c6 Headless improvements 2026-07-29 16:27:33 +02:00
Henrik Rydgård 6377c0bb06 Implement optional dumping of NPDRM isos (PBP demos) on game startup 2026-03-19 16:07:24 +01:00
Henrik Rydgård 0e55129fab Prepare for dumping NPDRM isos, use shared_ptr to manage lifetime of BlockDevice 2026-03-19 13:59:04 +01:00
Henrik Rydgård 445dd0bc0c Fix support for custom game configs for homebrews
Fixes #21429
2026-03-14 14:03:33 +01:00
Henrik Rydgård c609e96a30 Fix issue where manual edits like comments were not preserved in game configs.
This allowed some simplification.
2025-11-04 23:39:56 +01:00
Henrik Rydgård 4edb8e53cd Just some renaming and cleanup 2025-11-04 23:39:56 +01:00
Henrik Rydgård 54a7095522 Fix an issue where game-specific configs didn't affect the software renderer setting properly.
Fixes #20923
2025-11-04 13:52:01 +01:00
Henrik Rydgård f89c169f8a Use the correct ID when creating game configs from the pause screen 2025-09-04 11:34:55 +02:00
Henrik Rydgård 14016f84df Comments 2025-09-04 11:24:43 +02:00
Henrik Rydgård 6c238e0109 Small upgrade to the ParamSFO window: Show the original params, add copy to clipboard 2025-09-02 00:50:12 +02:00
Henrik Rydgård 77f9a27c35 Add a way for errors to bubble up out of BlockDevice creation 2025-06-07 12:30:20 +02:00
Henrik Rydgård 339ac7b866 Don't forget to copy over the MEMSIZE flag, when parsing PARAM.SFO for homebrew. 2025-06-06 18:50:47 +02:00
Henrik Rydgård 4e1ff145a5 Logging update 2025-05-27 17:48:23 +02:00
Henrik Rydgård 088a02bfdb Cleanup a lot of the bootup state management. 2025-03-30 14:02:29 +02:00
Henrik Rydgård ee90d2acc1 PSP boot: Move more of the startup process into the loading thread. Simplifies the code a bit. 2025-03-30 11:22:16 +02:00
Henrik Rydgård 42a58eaeb7 Clean up and reorder the boot process a bit, return better errors on bad files. 2025-03-30 01:07:12 +01:00
Henrik Rydgård 0df7a850a1 Only load PARAM.SFO once during startup 2025-03-26 09:24:14 +01:00
Henrik Rydgård 05b1cf3b80 Startup cleanup, part 1 2025-03-26 09:24:14 +01:00
Henrik Rydgård 3e198c53b2 More include cleanup 2024-12-18 13:57:26 +01:00
Henrik Rydgård 4befbeac7c Move the dump playback mips code to Playback.cpp. Assorted cleanup. 2024-12-10 01:27:25 +01:00
Henrik Rydgård b3d08977d5 Delete unused code 2024-12-08 11:25:00 +01:00
Henrik Rydgård 6adf8cabae Fix regression in break-on-load functionality 2024-12-06 00:40:21 +01:00
Henrik Rydgård 96c4a10e8c Add two new core states, rename RUNNING to RUNNING_CPU and similar for stepping. 2024-12-01 21:04:21 +01:00
Henrik Rydgård 14815d9330 Fix wrong homebrew name generation 2024-11-29 14:03:46 +01:00
Henrik Rydgård df104e7e31 Fix crash due to null break reason 2024-11-12 11:25:35 +01:00
EssaBoy 1928361085 Optimisation of the smart pointer in PSPLoader and ISOFileSystem 2024-10-18 23:56:57 +02:00
Henrik Rydgård 96c4ae4457 TimeUtil: Minor cleanup, add precise_sleep() 2024-07-26 11:25:58 +02:00
Henrik Rydgård e01ca5b057 Logging API change (refactor) (#19324)
* Rename LogType to Log

* Explicitly use the Log:: enum when logging. Allows for autocomplete when editing.

* Mac/ARM64 buildfix

* Do the same with the hle result log macros

* Rename the log names to mixed case while at it.

* iOS buildfix

* Qt buildfix attempt, ARM32 buildfix
2024-07-14 14:42:59 +02:00
Herman Semenov c20cb3f4be Minor optimize methods std::string using param as char with simpler implementation 2024-04-10 17:57:05 +03:00
Herman Semenov cfb77ce83e [Core/HLE/Common/UI] Using C++17 make smart pointers 2024-04-01 18:12:27 +03:00
Henrik Rydgård 2e16fd3bcc Fix fake game ID generation to work with scoped storage 2024-01-23 01:06:56 +01:00
Henrik Rydgård d1fb213750 Cleaner way 2024-01-18 00:54:04 +01:00
Henrik Rydgård 4fea6eeaab Try a compromise with the paths 2024-01-18 00:29:27 +01:00
Henrik Rydgård ff12ff1345 Android: Fix running plain PRXs on scoped storage. Minor cleanup. 2024-01-18 00:22:51 +01:00
Henrik Rydgård e3177ac870 Make some global string pointers const, not just the strings.
Minor cleanup.
2023-12-29 14:09:45 +01:00
Henrik Rydgård 19e4de5088 Change global UI messages to use an enum instead of strings.
Makes it easier to add new ones and delete outdated ones without missing
any uses.
2023-09-30 11:37:02 +02:00
German Semenov c498a42e92 Core, UI, Windows: Removed excess converting C-string in params 2023-09-15 13:54:11 +03:00
Henrik Rydgård f27e6055f8 Fix running homebrew on Android with content URIs (scoped storage) 2023-09-08 16:42:39 +02:00
Unknown W. Brackets 9cc266b0e7 Android: Fix developer tools -> run tests. 2023-09-07 17:36:41 -07:00
Bashar Astifan 9b0577351f Review's changes, more fixes and better structure 2023-05-02 00:09:22 +04:00
Bashar Astifan d0b6935592 UWP Improved Support 2023-04-28 23:22:17 +04:00