Skip to content

Commit

Permalink
Avoid reservation notifications in liblv2.sprx
Browse files Browse the repository at this point in the history
  • Loading branch information
elad335 committed Sep 12, 2022
1 parent 49af3a1 commit 3be6d2a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
17 changes: 17 additions & 0 deletions rpcs3/Emu/Cell/PPUModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ extern void sys_initialize_tls(ppu_thread&, u64, u32, u32, u32);
// HLE function name cache
std::vector<std::string> g_ppu_function_names;

extern atomic_t<u32> liblv2_begin = 0, liblv2_end = 0;

extern u32 ppu_generate_id(std::string_view name)
{
// Symbol name suffix
Expand Down Expand Up @@ -1367,6 +1369,12 @@ std::shared_ptr<lv2_prx> 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<u32> applied;

for (usz i = 0; i < prx->segs.size(); i++)
Expand Down Expand Up @@ -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));

Expand Down Expand Up @@ -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)
Expand Down
6 changes: 2 additions & 4 deletions rpcs3/Emu/Cell/PPUThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<u32>(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<u32> liblv2_begin, liblv2_end;

if (!may_be_lwmutex_related)
if (ppu.cia < liblv2_begin || ppu.cia >= liblv2_end)
{
res.notify_all(-128);
}
Expand Down

0 comments on commit 3be6d2a

Please sign in to comment.