Avoid reservation notifications in liblv2.sprx

This commit is contained in:
Eladash 2022-09-03 06:46:16 +03:00 committed by Ivan
parent 572a2a06d1
commit 92514e33bb
2 changed files with 19 additions and 4 deletions

View file

@ -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
@ -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++)
@ -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)

View file

@ -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);
}