From 6697b489815018feb1cdf0ceccaa539e9f295ec1 Mon Sep 17 00:00:00 2001 From: lizzie Date: Tue, 28 Apr 2026 00:07:04 +0000 Subject: [PATCH] e --- src/dynarmic/src/dynarmic/common/spin_lock_x64.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/dynarmic/src/dynarmic/common/spin_lock_x64.cpp b/src/dynarmic/src/dynarmic/common/spin_lock_x64.cpp index 48e07de507..658f227574 100644 --- a/src/dynarmic/src/dynarmic/common/spin_lock_x64.cpp +++ b/src/dynarmic/src/dynarmic/common/spin_lock_x64.cpp @@ -98,7 +98,18 @@ void EmitSpinLockLock(Xbyak::CodeGenerator& code, Xbyak::Address ptr, Xbyak::Reg // ptr operand must be a dword[ptr] void EmitSpinLockUnlock(Xbyak::CodeGenerator& code, Xbyak::Address ptr, Xbyak::Reg32 tmp) { code.xor_(tmp, tmp); - code.xchg(ptr, tmp); + if (ptr.is64bitDisp()) { + // if tmp is on eax, use ebx, otherwise use eax! + auto const other_tmp = tmp.cvt32() == Xbyak::util::eax + ? Xbyak::util::rbx + : Xbyak::util::rax; + code.push(other_tmp); + code.mov(other_tmp, ptr.getDisp()); + /*code.lock();*/ code.xchg(code.dword[other_tmp], tmp); + code.pop(other_tmp); + } else { + /*code.lock();*/ code.xchg(ptr, tmp); + } code.mfence(); }