diff --git a/rpcs3/Emu/Cell/PPUModule.cpp b/rpcs3/Emu/Cell/PPUModule.cpp index f278b0e01e..9296ec0a50 100644 --- a/rpcs3/Emu/Cell/PPUModule.cpp +++ b/rpcs3/Emu/Cell/PPUModule.cpp @@ -38,6 +38,8 @@ extern void sys_initialize_tls(ppu_thread&, u64, u32, u32, u32); // HLE function name cache std::vector g_ppu_function_names; +extern atomic_t liblv2_begin = 0, liblv2_end = 0; + extern u32 ppu_generate_id(std::string_view name) { // Symbol name suffix @@ -1367,6 +1369,12 @@ std::shared_ptr ppu_load_prx(const ppu_prx_object& elf, const std::stri // Format patch name std::string hash = fmt::format("PRX-%s", fmt::base57(prx->sha1)); + if (prx->path.ends_with("sys/external/liblv2.sprx"sv)) + { + liblv2_begin = prx->segs[0].addr; + liblv2_end = prx->segs[0].addr + prx->segs[0].size; + } + std::basic_string applied; for (usz i = 0; i < prx->segs.size(); i++) @@ -1441,6 +1449,12 @@ void ppu_unload_prx(const lv2_prx& prx) // } //} + if (prx.path.ends_with("sys/external/liblv2.sprx"sv)) + { + liblv2_begin = 0; + liblv2_end = 0; + } + // Format patch name std::string hash = fmt::format("PRX-%s", fmt::base57(prx.sha1)); @@ -1935,6 +1949,9 @@ bool ppu_load_exec(const ppu_exec_object& elf, utils::serial* ar) void init_fxo_for_exec(utils::serial* ar, bool full); init_fxo_for_exec(ar, false); + liblv2_begin = 0; + liblv2_end = 0; + if (!load_libs.empty()) { for (const auto& name : load_libs) diff --git a/rpcs3/Emu/Cell/PPUThread.cpp b/rpcs3/Emu/Cell/PPUThread.cpp index 6abed133b9..7d5c0a422b 100644 --- a/rpcs3/Emu/Cell/PPUThread.cpp +++ b/rpcs3/Emu/Cell/PPUThread.cpp @@ -2642,11 +2642,9 @@ static bool ppu_store_reservation(ppu_thread& ppu, u32 addr, u64 reg_value) }()) { // Test a common pattern in lwmutex - constexpr u64 mutex_free = u64{static_cast(0 - 1)} << 32; - const bool may_be_lwmutex_related = sizeof(T) == 8 ? - (new_data == mutex_free && old_data == u64{ppu.id} << 32) : (old_data == mutex_free && new_data == u64{ppu.id} << 32); + extern atomic_t liblv2_begin, liblv2_end; - if (!may_be_lwmutex_related) + if (ppu.cia < liblv2_begin || ppu.cia >= liblv2_end) { res.notify_all(-128); }