Commit graph

105 commits

Author SHA1 Message Date
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
Elad Ashkenazi
91b4aaf9e1 PPU: Fix potential overflow 2024-07-28 12:36:42 +03:00
brian218
c73302f715 sys_ppu_thread: Fixed up sys_ppu_thread_join()'s check for detached threads
sys_game: Corrected sys_game_set_system_sw_version()'s error code
2024-06-10 07:44:49 +03:00
Eladash
27ea25a999 Add debug info to ENOMEMs 2024-02-16 10:42:57 +02:00
Eladash
60baa49007 sceNp/vm: Fix strings read, implement safe string reader 2023-12-12 21:23:33 +02:00
Eladash
730badd378 cellAudio: Move and partially fix _mxr000 hack 2023-08-18 11:37:29 +03:00
Eladash
75ad56338b SPU/Non-TSX: Implement cuncurrent reservations 2023-07-27 02:50:01 +03:00
Eladash
17d8f2884e Debug fixes 2023-07-09 13:33:03 +03:00
Eladash
c87a7cb2c0 PPU: Fix thread entry detection false positives 2023-06-09 14:07:37 +03:00
Eladash
52575a44b2 sys_ppu_thread: Optimize joined thread notification 2023-06-06 17:53:09 +02:00
Eladash
4af0a33f1f Fix sys_ppu_thread_detach/exit with lingering thread copies 2023-06-06 09:48:27 +02:00
Eladash
d152537e50 sys_lwcond/cond/ppu_thread: Respect scheduler in various syscalls 2023-06-02 08:54:46 +03:00
Eladash
b861a9c5d0 LV2: Implement set-priority thread requeue 2023-06-02 08:54:46 +03:00
Elad Ashkenazi
238298f695
sys_ppu_thread: Fix surmixer hack (#12689)
* sys_ppu_thread: Fix surmixer hack

* Hotfix after #12678
2022-09-21 21:10:59 +03:00
Eladash
194f7375da SPU/LV2: Fix tiny race conditions 2022-09-21 20:35:34 +03:00
Eladash
37aefe5811 sys_ppu_thread: Fix max thread name size 2022-09-12 12:57:39 +03:00
Eladash
683c1a6512 LV2: Optimize sys_ppu_thread a bit 2022-08-11 11:42:16 +03:00
Eladash
34bae90820 LV2: Move nearly all notifications out of all mutex scopes including IDM 2022-08-07 20:23:54 +03:00
Eladash
3fc2194fd5 Savestates: Fix zombie PPU threads saving 2022-07-05 08:25:36 +02:00
Elad Ashkenazi
fcd297ffb2
Savestates Support For PS3 Emulation (#10478) 2022-07-04 16:02:17 +03:00
RipleyTom
da6434a65a
Implements sys_fs_fcntl 0xC0000008 & 0xC000001A (#11957) 2022-06-11 13:12:42 +01:00
Eladash
961d41d0bd RawSPU: Reinvoke pending interrupts if missed 2022-05-25 11:46:51 +03:00
Nekotekina
5c1f79ab26 vm: remove g_mutex, use g_range_lock instead
Simplification and performance improvements.
2022-05-02 10:29:28 +03:00
DH
2981867375 sys_spu_thread: Removed unused field access 2021-12-02 21:36:57 +03:00
Eladash
98e40d12ef sys_ppu: Implement sys_ppu_thread_rename 2021-07-19 12:37:33 +02:00
Eladash
8e2c34a003 PPU debugger: Implement PPU calling history 2021-07-17 17:28:23 +02:00
Eladash
44f0ca08e2 Simplify PPU exit 2021-05-25 22:47:23 +03:00
Eladash
daa53b77cf Simplify named_thread construction 2021-05-01 18:08:03 +03:00
Nekotekina
ea5e837bd6 fixed_typemap.hpp: return reference 2021-03-02 16:08:14 +03:00
Eladash
f43260bd58
Atomic waiting refactoring (#9208)
* Use atomic waitables instead instead of global thread wait as often as possible.
* Add ::is_stopped() and and ::is_paued() which can be used in atomic loops and with atomic wait. (constexpr cpu flags test functions)
* Fix notification bug of sys_spu_thread_group_exit/terminate. (old bug, enhanced by #9117)
* Function time statistics at Emu.Stop() restored. (instead of current "X syscall failed with 0x00000000 : 0")
2021-02-13 17:50:07 +03:00
Eladash
478ae0715e Tiny fix for zombie PPU threads 2021-02-03 15:05:38 +03:00
Eladash
7f28489c70 Improve ppu_thread_cleaner a bit
Always join thread.
2021-01-21 21:32:13 +03:00
Eladash
a58c12db0b SPU: fixup after #9630
Co-Authored-By: Ivan <nekotekina@gmail.com>
2021-01-21 21:32:13 +03:00
Eladash
12e1be2626 Implement thread_ctrl::wait_on (see #9208) 2021-01-21 18:31:51 +03:00
Eladash
f81674232e Remove SPU and PPU destructors 2021-01-21 18:31:51 +03:00
Nekotekina
eec11bfba9 Move align helpers to util/asm.hpp
Also add some files:
GLTextureCache.cpp
VKTextureCache.cpp
2020-12-18 18:07:42 +03:00
Nekotekina
e055d16b2c Replace verify() with ensure() with auto src location.
Expression ensure(x) returns x.
Using comma operator removed.
2020-12-09 15:43:38 +03:00
RipleyTom
af8c661a64 Remove BOM markers 2020-12-06 15:30:12 +03:00
Nekotekina
b5d498ffda Homebrew atomic_ptr rewritten (util/shared_ptr.hpp)
It's analogous to C++20 atomic std::shared_ptr

The following things brought into global namespace:
single_ptr
shared_ptr
atomic_ptr
make_single
2020-11-26 20:11:26 +03:00
Nekotekina
34fa010601 Improve cond_var notifiers
But nobody uses it anyway, so clean up includes.
2020-11-06 00:10:16 +03:00
Nekotekina
ba5ed5f380 Fix vm::lock_range wrong check
Minor header refactoring.
2020-11-04 14:59:26 +03:00
Nekotekina
58adb6a1aa sys_ppu_thread: add cpu_flag::wait 2020-10-30 18:27:15 +03:00
Eladash
d9750e8f9f SPU/PPU reservations: Optimizations for reservation locks and check_state() (non-TSX) 2020-07-09 03:17:35 +01:00
Eladash
e45d37073a debugger: Shortend SPU/PPU thread names 2020-06-24 17:44:06 +02:00
Eladash
d86c9a2549 sys_mmapper: rewrite page fault thread notifications
* Fix a corner case where SPU thread has the same ID as a PPU thread.
* Fix a potential deadlock on Emu.Stop() while sending event in EBUSY loop.
* Thread specific notifications.
2020-06-18 20:13:54 +03:00
Eladash
dd6825a7bd Fix sys_ppu_thread_start error checking, fix rare bug in sys_ppu_thread_create
* Correct error code to EBUSY.
* lv2_obj::awake was called even when EBSUY should be returned.
* Fix sys_ppu_thread_create for a newly created thread with the same id as ppu_thread::id_base. (can happen if main thread exited before its creation)
2020-04-29 08:58:09 +03:00
Eladash
c1dc6838fa Fix sys_ppu_thread_get_priority page faults 2020-04-29 07:57:47 +03:00
Eladash
bb950cbb3b vm: Fix possible IDM deadlock with Page Fault Notifications (partial) 2020-04-12 10:30:38 +01:00
Eladash
c948c9305c sys_ppu_thread_create: read function descriptor immediately and save it 2020-04-08 19:23:13 +03:00
Eladash
dc5cdb3bb4 sys_ppu_thread: reduce global memory stats after thread creation 2020-04-05 15:23:09 +03:00