From 15bd3b8724bcec789f794ec3b00efd6cfd475bb8 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Thu, 2 May 2019 17:59:15 +0300 Subject: [PATCH] SPU: fix minor UB in STQD/LQD instructions --- rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp | 4 ++-- rpcs3/Emu/Cell/SPUInterpreter.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp b/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp index 1ce02d4d92..571cd42681 100644 --- a/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp +++ b/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp @@ -4359,7 +4359,7 @@ void spu_recompiler::AHI(spu_opcode_t op) void spu_recompiler::STQD(spu_opcode_t op) { c->mov(*addr, SPU_OFF_32(gpr, op.ra, &v128::_u32, 3)); - if (op.si10) c->add(*addr, op.si10 << 4); + if (op.si10) c->add(*addr, op.si10 * 16); c->and_(*addr, 0x3fff0); if (utils::has_ssse3()) @@ -4382,7 +4382,7 @@ void spu_recompiler::STQD(spu_opcode_t op) void spu_recompiler::LQD(spu_opcode_t op) { c->mov(*addr, SPU_OFF_32(gpr, op.ra, &v128::_u32, 3)); - if (op.si10) c->add(*addr, op.si10 << 4); + if (op.si10) c->add(*addr, op.si10 * 16); c->and_(*addr, 0x3fff0); if (utils::has_ssse3()) diff --git a/rpcs3/Emu/Cell/SPUInterpreter.cpp b/rpcs3/Emu/Cell/SPUInterpreter.cpp index c94ccc8852..d8d4039fe2 100644 --- a/rpcs3/Emu/Cell/SPUInterpreter.cpp +++ b/rpcs3/Emu/Cell/SPUInterpreter.cpp @@ -1516,13 +1516,13 @@ bool spu_interpreter::AHI(spu_thread& spu, spu_opcode_t op) bool spu_interpreter::STQD(spu_thread& spu, spu_opcode_t op) { - spu._ref((spu.gpr[op.ra]._s32[3] + (op.si10 << 4)) & 0x3fff0) = spu.gpr[op.rt]; + spu._ref((spu.gpr[op.ra]._s32[3] + (op.si10 * 16)) & 0x3fff0) = spu.gpr[op.rt]; return true; } bool spu_interpreter::LQD(spu_thread& spu, spu_opcode_t op) { - spu.gpr[op.rt] = spu._ref((spu.gpr[op.ra]._s32[3] + (op.si10 << 4)) & 0x3fff0); + spu.gpr[op.rt] = spu._ref((spu.gpr[op.ra]._s32[3] + (op.si10 * 16)) & 0x3fff0); return true; }