PS3 emulator/debugger
Go to file
AurisDSP 6850e2e5a8 Apple Silicon: consolidate JIT W^X handling with RAII guards
Address review feedback on #18701 (cc @elad335): combine the SPU
worker fix from #18701, the SPRX Loader fix from #18703, and three
additional similar W^X leaks discovered while auditing the codebase
for the same pattern. Use Allman-style braces to match RPCS3 coding
style.

Background:
On AArch64 Apple Silicon, MAP_JIT pages enforce W^X per-thread.
pthread_jit_write_protect_np(false) enables write mode and
pthread_jit_write_protect_np(true) restores execute mode. When code
takes an early return or throws between these calls, the thread is
left in write mode, which can cause segfaults on subsequent code
fetches or inconsistent state at thread teardown.

Fixes applied (all gated on __APPLE__):

1. Emu/Cell/SPUCommonRecompiler.cpp - SPU cache worker thread
   Add RAII guard so execute mode is restored on worker exit.

2. Emu/System.cpp - SPRX Loader thread
   Enter write mode (was missing entirely) so ppu_initialize() and
   ppu_precompile() can write to MAP_JIT pages, and pair with an
   RAII guard. Reproducer: Red Dead Redemption (BLUS30418) crashes
   ~12s into boot at 0x300010000 without this fix.

3. Emu/Cell/SPULLVMRecompiler.cpp - SPU LLVM compile path
   The compile function enters write mode, then has an early
   "return nullptr" path on rebuild_ubertrampoline failure that
   skipped the explicit restore. Add RAII guard so execute mode
   is restored on every exit path. The existing explicit restore
   before the cache-flush asm directives is preserved.

4. Emu/Cell/PPUThread.cpp - PPU LLVM worker thread (operator())
   Worker entered write mode but never restored it on operator()
   return. Add RAII guard.

5. Emu/Cell/PPUThread.cpp - ppu_initialize() main path
   This scope alternates write/execute mode and contains an early
   "return compiled_new" at the empty-jits check plus a final
   return that both leak write mode. Add RAII guard so execute
   mode is always restored on exit. Intermediate explicit
   transitions for the symbol-resolver invocation are preserved.

No behavioral change on x86_64 or non-Apple ARM64 (all changes are
inside #ifdef __APPLE__ / #if defined(__APPLE__)).

Supersedes #18703.
2026-05-09 15:07:22 +03:00
.ci fix minor issues with rpath logic 2026-05-05 09:47:20 +09:00
.github ci: Bump docker version and use rpcs3 dropbox URL for vulkan SDK 2026-04-30 18:58:08 +03:00
3rdparty Update SDL to 3.4.8 2026-05-04 18:18:32 +02:00
bin Add missing hover effect in ‎GustavoGraziano's theme 2026-05-08 14:24:54 +00:00
buildfiles CMake: fix the case USE_SYSTEM_ZLIB=OFF and USE_SYSTEM_CURL=OFF 2026-03-29 14:45:53 +02:00
darwin/util MacOS: silence some warnings 2024-12-28 19:58:59 +01:00
rpcs3 Apple Silicon: consolidate JIT W^X handling with RAII guards 2026-05-09 15:07:22 +03:00
Utilities Add anaglyph settings 2026-05-08 21:42:29 +02:00
.clang-format Disable AlignConsecutiveAssignments 2022-10-22 11:32:04 +02:00
.editorconfig Set default to utf-8 for MSVC 2020-12-06 15:30:12 +03:00
.gdbinit Add .gdbinit config file 2020-11-12 23:43:38 +03:00
.gitignore Add Zed config files to gitignore 2026-03-22 13:16:58 +01:00
.gitmodules Flatbuffers to Protobuf (#18082) 2026-01-24 09:37:47 +01:00
BUILDING.md vk: Upgrade Vulkan SDK to 1.4.341 2026-04-30 18:58:08 +03:00
CMakeLists.txt add /opt/homebrew to prefix path instead 2026-05-05 09:47:20 +09:00
CMakePresets.json Add opencv to cmake 2024-11-16 15:10:20 +01:00
git-clang-format Add a git pre-commit hook running clang-format 2016-08-27 15:40:41 +02:00
LICENSE
objdump.cpp Remove std::strcpy 2025-11-02 14:22:11 +02:00
pre-commit.readme Add a git pre-commit hook running clang-format 2016-08-27 15:40:41 +02:00
README.md [CI] FreeBSD build (#17293) 2025-06-12 09:33:40 +03:00
rpcs3.sln Flatbuffers to Protobuf (#18082) 2026-01-24 09:37:47 +01:00
usertype.dat .clang-format added 2016-08-12 14:32:57 +03:00

RPCS3

GitHub Actions RPCS3 Discord Server

The world's first free and open-source PlayStation 3 emulator/debugger, written in C++ for Windows, Linux, macOS and FreeBSD.

You can find some basic information on our website. Game info is being populated on the Wiki. For discussion about this emulator, PS3 emulation, and game compatibility reports, please visit our forums and our Discord server.

Support Lead Developers Nekotekina and kd-11 on Patreon

Contributing

If you want to help the project but do not code, the best way to help out is to test games and make bug reports. See:

If you want to contribute as a developer, please take a look at the following pages:

You should also contact any of the developers in the forums or in the Discord server to learn more about the current state of the emulator.

Building

See BUILDING.md for more information about how to setup an environment to build RPCS3.

Running

Check our friendly quickstart guide to make sure your computer meets the minimum system requirements to run RPCS3.

Don't forget to have your graphics driver up to date and to install the Visual C++ Redistributable Packages for Visual Studio 2022 if you are a Windows user.

License

Most files are licensed under the terms of GNU GPL-2.0-only License; see LICENSE file for details. Some files may be licensed differently; check appropriate file headers for details.