diff --git a/rpcs3/Emu/Cell/PPUThread.cpp b/rpcs3/Emu/Cell/PPUThread.cpp index 702c470266..2d3f26b559 100644 --- a/rpcs3/Emu/Cell/PPUThread.cpp +++ b/rpcs3/Emu/Cell/PPUThread.cpp @@ -1378,10 +1378,14 @@ const auto ppu_stcx_accurate_tx = build_function_asm(cpu_flag::pause)); + c.mov(x86::eax, _XABORT_EXPLICIT); + c.jc(fall); c.xbegin(tx0); c.mov(x86::rax, x86::qword_ptr(x86::rbx)); - c.test(x86::eax, 127); + c.test(x86::eax, vm::rsrv_unique_lock); c.jnz(skip); + c.and_(x86::rax, -128); c.cmp(x86::rax, x86::r13); c.jne(fail); @@ -1479,7 +1483,7 @@ const auto ppu_stcx_accurate_tx = build_function_asm(cpu_flag::pause)); c.jc(fall2); c.mov(x86::rax, x86::qword_ptr(x86::rbx)); + c.test(x86::rax, 127 - 1); + c.jnz(fall2); c.and_(x86::rax, -128); c.cmp(x86::rax, x86::r13); c.jne(fail2); @@ -1681,7 +1687,7 @@ static bool ppu_store_reservation(ppu_thread& ppu, u32 addr, u64 reg_value) } } - return cpu_thread::suspend_all(&ppu, [&] + return cpu_thread::suspend_all<+1>(&ppu, [&] { if ((res & -128) == rtime && cmp_rdata(ppu.rdata, vm::_ref(addr & -128))) { diff --git a/rpcs3/Emu/Cell/SPUThread.cpp b/rpcs3/Emu/Cell/SPUThread.cpp index 35d702a860..079aa45395 100644 --- a/rpcs3/Emu/Cell/SPUThread.cpp +++ b/rpcs3/Emu/Cell/SPUThread.cpp @@ -398,10 +398,14 @@ const auto spu_putllc_tx = build_function_asm(cpu_flag::pause)); + c.mov(x86::eax, _XABORT_EXPLICIT); + c.jc(fall); c.xbegin(tx0); c.mov(x86::rax, x86::qword_ptr(x86::rbx)); - c.test(x86::eax, 127); + c.test(x86::eax, vm::rsrv_unique_lock); c.jnz(skip); + c.and_(x86::rax, -128); c.cmp(x86::rax, x86::r13); c.jne(fail); @@ -514,7 +518,7 @@ const auto spu_putllc_tx = build_function_asm(cpu_flag::pause)); c.jc(fall2); c.mov(x86::rax, x86::qword_ptr(x86::rbx)); + c.test(x86::rax, 127 - 1); + c.jnz(fall2); c.and_(x86::rax, -128); c.cmp(x86::rax, x86::r13); c.jne(fail2); @@ -784,6 +790,9 @@ const auto spu_putlluc_tx = build_function_asm(cpu_flag::pause)); c.jc(fall2); + // Check contention + c.test(x86::qword_ptr(x86::rbx), 127 - 1); + c.jc(fall2); c.xbegin(tx1); if (s_tsx_avx) @@ -2283,7 +2292,7 @@ bool spu_thread::do_putllc(const spu_mfc_cmd& args) { case UINT32_MAX: { - const bool ok = cpu_thread::suspend_all(this, [&]() + const bool ok = cpu_thread::suspend_all<+1>(this, [&]() { if ((res & -128) == rtime) { @@ -2397,7 +2406,7 @@ void do_cell_atomic_128_store(u32 addr, const void* to_write) if (result == 0) { // Execute with increased priority - cpu_thread::suspend_all<+1>(cpu, [&] + cpu_thread::suspend_all<0>(cpu, [&] { mov_rdata(vm::_ref(addr), *static_cast(to_write)); vm::reservation_acquire(addr, 128) += 127;