diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2023-11-09 23:16:17 +0100 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2023-11-09 23:16:17 +0100 |
| commit | 113c879d7ad51664df6172508e44377c54eb28d2 (patch) | |
| tree | dd6bed670cf303eca3f80201332ab366c6f68e05 /src | |
| parent | f13ee05c6a0a333990d14764e72b36b52af05b20 (diff) | |
| download | box64-113c879d7ad51664df6172508e44377c54eb28d2.tar.gz box64-113c879d7ad51664df6172508e44377c54eb28d2.zip | |
Allow unaligned lock xchg with rex.w
Diffstat (limited to 'src')
| -rw-r--r-- | src/emu/x64runf0.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/emu/x64runf0.c b/src/emu/x64runf0.c index 9e6426f4..b9bc2c4c 100644 --- a/src/emu/x64runf0.c +++ b/src/emu/x64runf0.c @@ -946,7 +946,18 @@ uintptr_t RunF0(x64emu_t *emu, rex_t rex, uintptr_t addr) } } else { if(rex.w) { - GD->q[0] = native_lock_xchg_dd(ED, GD->q[0]); + if((uintptr_t)ED&7) { + // unaligned + do { + tmp64u = ED->q[0] & 0xffffffffffffff00LL; + tmp64u |= native_lock_read_b(ED); + + } while(native_lock_write_b(ED, GD->byte[0])); + ED->q[0] = GD->q[0]; + GD->q[0] = tmp64u; + } else { + GD->q[0] = native_lock_xchg_dd(ED, GD->q[0]); + } } else { GD->dword[0] = native_lock_xchg_d(ED, GD->dword[0]); } |