Skip to content

Commit 8bcd84a

Browse files
Douglas Leungralfbaechle
authored andcommitted
MIPS: math-emu: Fix BC1EQZ and BC1NEZ condition handling
Correct the treatment of branching conditions for BC1EQZ and BC1NEZ instructions in function isBranchInstr(). Previously, corresponding conditions were swapped, which in turn meant that, for these two instructions, function isBranchInstr() returned wrong value in its output parameter contpc. This change is actually an extension of the fix done by the commit 93583e1 ("MIPS: math-emu: Fix BC1{EQ,NE}Z emulation"). That commit dealt with a similar problem in function cop1Emulate(), while this commit deals with condition handling in function isBranchInstr(). The code styles of changes in these two commits are kept as consistent as possible. Signed-off-by: Douglas Leung <douglas.leung@imgtec.com> Signed-off-by: Miodrag Dinic <miodrag.dinic@imgtec.com> Signed-off-by: Aleksandar Markovic <aleksandar.markovic@imgtec.com> Reviewed-by: Paul Burton <paul.burton@imgtec.com> Cc: james.hogan@imgtec.com Cc: leonid.yegoshin@imgtec.com Cc: petar.jovanovic@imgtec.com Cc: goran.ferenc@imgtec.com Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/15489/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
1 parent 411dac7 commit 8bcd84a

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

arch/mips/math-emu/cp1emu.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,8 @@ int isBranchInstr(struct pt_regs *regs, struct mm_decoded_insn dec_insn,
439439
union mips_instruction insn = (union mips_instruction)dec_insn.insn;
440440
unsigned int fcr31;
441441
unsigned int bit = 0;
442+
unsigned int bit0;
443+
union fpureg *fpr;
442444

443445
switch (insn.i_format.opcode) {
444446
case spec_op:
@@ -706,14 +708,14 @@ int isBranchInstr(struct pt_regs *regs, struct mm_decoded_insn dec_insn,
706708
((insn.i_format.rs == bc1eqz_op) ||
707709
(insn.i_format.rs == bc1nez_op))) {
708710
bit = 0;
711+
fpr = &current->thread.fpu.fpr[insn.i_format.rt];
712+
bit0 = get_fpr32(fpr, 0) & 0x1;
709713
switch (insn.i_format.rs) {
710714
case bc1eqz_op:
711-
if (get_fpr32(&current->thread.fpu.fpr[insn.i_format.rt], 0) & 0x1)
712-
bit = 1;
715+
bit = bit0 == 0;
713716
break;
714717
case bc1nez_op:
715-
if (!(get_fpr32(&current->thread.fpu.fpr[insn.i_format.rt], 0) & 0x1))
716-
bit = 1;
718+
bit = bit0 != 0;
717719
break;
718720
}
719721
if (bit)

0 commit comments

Comments
 (0)