]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
mips: Fix BEQC[16] and BNEC[16] instructions for nanoMIPS
authorPetar Jovanovic <mips32r2@gmail.com>
Tue, 14 Jan 2020 17:37:21 +0000 (17:37 +0000)
committerPetar Jovanovic <mips32r2@gmail.com>
Tue, 14 Jan 2020 17:37:21 +0000 (17:37 +0000)
Instruction decoding was not correct. In some cases, BEQC has been decoded
as BNEC and vice versa.

It caused problems with musl malloc() function.

Patch by Stefan Maksimovic.

VEX/priv/guest_nanomips_toIR.c

index f06370ffd6349657630620311fb1dcc0574bae5a..0cc80b0aa2f8793c6ade84cbbae17dca8fec83c5 100755 (executable)
@@ -2201,10 +2201,12 @@ static void nano_p16br(DisResult *dres, UShort cins)
       putPC(getIReg(rt));
       dres->whatNext = Dis_StopHere;
    } else {
-      UChar rt = GPR3_list[(cins >> 7) & 0x07];
-      UChar rs = GPR3_list[(cins >> 4) & 0x07];
+      UChar rt3 = (cins >> 7) & 0x07;
+      UChar rs3 = (cins >> 4) & 0x07;
+      UChar rt = GPR3_list[rt3];
+      UChar rs = GPR3_list[rs3];
 
-      if (rs < rt) {  /* beqc[16] */
+      if (rs3 < rt3) {  /* beqc[16] */
          DIP("beqc r%u, r%u, %X", rt, rs, guest_PC_curr_instr + 2 + u);
          ir_for_branch(dres, binop(Iop_CmpEQ32, getIReg(rt), getIReg(rs)),
                        2, (Int)u);