Commit graph

216 commits

Author SHA1 Message Date
RipleyTom cd87a64621 Headers cleanup 2025-02-11 20:38:35 +01:00
Elad 86b7078464 PPU LLVM: Fix compilation of PRX with no relocations 2025-02-07 20:27:17 +02:00
Megamouse 3187dc816e Fix some warnings 2025-02-02 17:06:39 +01:00
Megamouse 67703b49d8 Update LLVM to 18.1.8 2025-01-25 18:15:13 +01:00
Elad 5a5e475c6e PPU Analyzer: Move ppu_function::callers to lower sizeof(ppu_function) 2025-01-25 12:47:44 +02:00
Elad 857eac3d10 PPU Analyzer: Remove ppu_function::name to lower sizeof(ppu_function) 2025-01-25 12:47:44 +02:00
Elad 9d5b75bb7a LLVM: Slice PPU executable memory 2025-01-25 12:47:44 +02:00
Elad 575a245f8d
IDM: Implement lock-free smart pointers (#16403)
Replaces `std::shared_pointer` with `stx::atomic_ptr` and `stx::shared_ptr`.

Notes to programmers:

* This pr kills the use of `dynamic_cast`, `std::dynamic_pointer_cast` and `std::weak_ptr` on IDM objects, possible replacement is to save the object ID on the base object, then use idm::check/get_unlocked to the destination type via the saved ID which may be null. Null pointer check is how you can tell type mismatch (as dynamic cast) or object destruction (as weak_ptr locking).
* Double-inheritance on IDM objects should be used with care, `stx::shared_ptr` does not support constant-evaluated pointer offsetting to parent/child type.
* `idm::check/get_unlocked` can now be used anywhere.

Misc fixes:
* Fixes some segfaults with RPCN with interaction with IDM.
* Fix deadlocks in access violation handler due locking recursion.
* Fixes race condition in process exit-spawn on memory containers read.
* Fix bug that theoretically can prevent RPCS3 from booting - fix `id_manager::typeinfo` comparison to compare members instead of `memcmp` which can fail spuriously on padding bytes.
* Ensure all IDM inherited types of base, either has `id_base` or `id_type` defined locally, this allows to make getters such as `idm::get_unlocked<lv2_socket, lv2_socket_raw>()` which were broken before. (requires save-states invalidation)
* Removes broken operator[] overload of `stx::shared_ptr` and `stx::single_ptr` for non-array types.
2024-12-22 20:59:48 +02:00
kd-11 c80342e8d4 aarch64: Support calloc patch blocks 2024-08-31 13:55:58 +03:00
kd-11 4da30e9eca Add proper transform pass management 2024-08-24 14:13:14 +03:00
kd-11 fbcd8e32b8 Cleanup 2024-08-18 18:27:52 +03:00
kd-11 fc415cf32a Move to a assembler wrapper for injected asm to better handle dependencies 2024-08-18 18:27:52 +03:00
kd-11 bc1b0eb41b Improve comments 2024-08-08 13:40:07 +03:00
kd-11 7979c5d9eb Finalize PPU migration to the frame pass system 2024-08-08 13:40:07 +03:00
kd-11 cba658baba Complete PPU support 2024-08-08 13:40:07 +03:00
kd-11 34549445a8 Migrate PPU to post-process execution model 2024-08-08 13:40:07 +03:00
kd-11 a976ac3353 jit: Add aarch64 JIT backend for pre-codegen transforms 2024-08-08 13:40:07 +03:00
kd-11 56cc5d9355 Initial PPU LLVM implementation for aarch64 2024-08-08 13:40:07 +03:00
Elad Ashkenazi a2534263fe Savestates/PPU: Ensure correct PPU state on MMIO 2024-07-19 14:31:19 +03:00
Elad Ashkenazi 929be0b4e6 PPU LLVM: Implement OE for few instructions 2024-06-08 14:09:37 +03:00
Eladash b83e39a540 Fix some warnings 2024-05-04 14:15:51 +03:00
Elad Ashkenazi ad4216a3fc PPU LLVM: Do not crash on linkage of garbage code 2024-04-26 18:55:50 +03:00
Eladash 3364a46139 PPU LLVM: Remove cast to constant 2024-03-26 21:35:53 +02:00
Eladash 2f822abb47 PPU LLVM: Use symbol resolver function to resolve functions 2024-03-20 12:48:31 +02:00
Eladash 467790c8d8 PPUTranslator: Try to fix a regression 2024-01-01 11:58:00 +02:00
Megamouse f45cbdd0f7 fixes 2023-12-30 21:14:26 +01:00
Megamouse 7a02787bee fix some more warnings 2023-12-30 21:14:26 +01:00
Eladash fdbb0b0e2f PPU LLVM: Optimize branch list 2023-09-05 06:20:57 +03:00
Eladash 85773ad869 PPU LLVM: Optimize traps a bit 2023-09-05 06:20:57 +03:00
Eladash 8b212f2169 PPU: Fix LVRX bad memory access 2023-08-17 17:59:45 +03:00
Eladash e25936c1f1 PPU LLVM/RawSPU: Fixup MMIO crossing-out 2023-08-06 08:26:17 +03:00
Eladash 06c9b95e09 PPU LLVM/SPU/Non-TSX: Obnoxiously responsive and obedient PPU for SPU requests 2023-08-03 15:04:37 +03:00
Elad Ashkenazi 1219e5c244
SPU: Fix static interpreter requirement with interrupts
Removed a wrong condition in PPU LLVM as a fixup.
2023-07-07 22:39:49 +03:00
Eladash 598fe85243 PPU LLVM/RawSPU: Implement MMIO violation elimination pass 2023-07-06 19:46:36 +03:00
Eladash 554b27a82a PPU LLVM: Implement SELF precompilation
Do not use PS3 memory for precompilation.
2023-06-28 18:34:33 +03:00
Eladash 1c36156594 PPU LLVM: Fix LWSYNC according to cellSpursWakeup 2023-06-02 08:54:46 +03:00
Ivan Chikish 22bd7dcc42 PPU LLVM: disable DSE pass and use volatile store/loads 2023-04-14 07:26:30 +03:00
oltolm 6fbca1acfd remove unnecessary pointer bitcasts 2023-04-09 12:45:18 +03:00
Ivan Chikish fb88e1c1c9 Update to LLVM 16.0.0, switch to upstream LLVM 2023-04-06 10:19:31 +03:00
oltolm 520524285a
llvm: update code to new API (#13500)
* llvm: update code to new API

* llvm: remove OLDLLVM define
2023-03-11 01:57:21 +03:00
Nekotekina ae809ad320 Unexpected bugfixes
Mostly unaligned memory access.
Also includes workarounds for ubsan execution.
2022-10-31 14:20:02 +03:00
Malcolm Jestadt d8897c585d PPU/SPU LLVM: Allow Zen4 cpus to use VPERMI2B/VPERMT2B instead of the vperm2b256to128 path
- Zen4 based cpus can process VPERM2B in a single uop, unlike intel where it is 3 uops.
2022-10-01 15:38:29 +03:00
Eladash 1dd1062be1 PPU LLVM: Fix HLE function injection 2022-08-21 15:02:01 +03:00
Jeff Guo cefc37a553
PPU LLVM arm64+macOS port (#12115)
* BufferUtils: use naive function pointer on Apple arm64

Use naive function pointer on Apple arm64 because ASLR breaks asmjit.
See BufferUtils.cpp comment for explanation on why this happens and how
to fix if you want to use asmjit.

* build-macos: fix source maps for Mac

Tell Qt not to strip debug symbols when we're in debug or relwithdebinfo
modes.

* LLVM PPU: fix aarch64 on macOS

Force MachO on macOS to fix LLVM being unable to patch relocations
during codegen. Adds Aarch64 NEON intrinsics for x86 intrinsics used by
PPUTranslator/Recompiler.

* virtual memory: use 16k pages on aarch64 macOS

Temporary hack to get things working by using 16k pages instead of 4k
pages in VM emulation.

* PPU/SPU: fix NEON intrinsics and compilation for arm64 macOS

Fixes some intrinsics usage and patches usages of asmjit to properly
emit absolute jmps so ASLR doesn't cause out of bounds rel jumps. Also
patches the SPU recompiler to properly work on arm64 by telling LLVM to
target arm64.

* virtual memory: fix W^X toggles on macOS aarch64

Fixes W^X on macOS aarch64 by setting all JIT mmap'd regions to default
to RW mode. For both SPU and PPU execution threads, when initialization
finishes we toggle to RX mode. This exploits Apple's per-thread setting
for RW/RX to let us be technically compliant with the OS's W^X
    enforcement while not needing to actually separate the memory
    allocated for code/data.

* PPU: implement aarch64 specific functions

Implements ppu_gateway for arm64 and patches LLVM initialization to use
the correct triple. Adds some fixes for macOS W^X JIT restrictions when
entering/exiting JITed code.

* PPU: Mark rpcs3 calls as non-tail

Strictly speaking, rpcs3 JIT -> C++ calls are not tail calls. If you
call a function inside e.g. an L2 syscall, it will clobber LR on arm64
and subtly break returns in emulated code. Only JIT -> JIT "calls"
should be tail.

* macOS/arm64: compatibility fixes

* vm: patch virtual memory for arm64 macOS

Tag mmap calls with MAP_JIT to allow W^X on macOS. Fix mmap calls to
existing mmap'd addresses that were tagged with MAP_JIT on macOS. Fix
memory unmapping on 16K page machines with a hack to mark "unmapped"
pages as RW.

* PPU: remove wrong comment

* PPU: fix a merge regression

* vm: remove 16k page hacks

* PPU: formatting fixes

* PPU: fix arm64 null function assembly

* ppu: clean up arch-specific instructions
2022-06-14 15:28:38 +03:00
Nekotekina e243ef5907 PPU: implement accurate FRES
Implemented with an accurate lookup table.
2022-05-11 10:46:08 +03:00
doesthisusername 7b162c7513 PPU: implement quasi-accurate FRSQRTE
Denormals are handled like zeros.
NaN handling is inaccurate in some cases.

Co-authored-by: Nekotekina <nekotekina@gmail.com>
2022-05-11 10:46:08 +03:00
Nekotekina 0786a0a088 PPU LLVM: match interpreter for VEXPTEFP/VLOGEFP 2022-05-03 08:27:44 +03:00
Nekotekina 0de9960772 PPU: rewrite MFOCRF+MFCR instructions 2022-01-21 12:49:52 +03:00
Nekotekina 349f251d14 PPU LLVM: use masked stores for STVLX/STVRX
Drop maskmove intrinsic, not portable.
Its implicit NT hint may also hurt performance.
2022-01-20 21:16:00 +03:00
Nekotekina 14cca55b50 PPU: refactor vector rounding instructions
Fix: nearbyint -> roundeven
2022-01-18 00:10:32 +03:00