Skip to content

Commit 93583e1

Browse files
paulburtonralfbaechle
authored andcommitted
MIPS: math-emu: Fix BC1{EQ,NE}Z emulation
The conditions for branching when emulating the BC1EQZ & BC1NEZ instructions were backwards, leading to each of those instructions being treated as the other. Fix this by reversing the conditions, and clear up the code a little for readability & checkpatch. Fixes: c909ca7 ("MIPS: math-emu: Emulate missing BC1{EQ,NE}Z instructions") Signed-off-by: Paul Burton <paul.burton@imgtec.com> Reviewed-by: James Hogan <james.hogan@imgtec.com> Cc: Maciej W. Rozycki <macro@imgtec.com> Cc: linux-mips@linux-mips.org Cc: linux-kernel@vger.kernel.org Patchwork: https://patchwork.linux-mips.org/patch/13150/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
1 parent ed47e15 commit 93583e1

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

arch/mips/math-emu/cp1emu.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -973,9 +973,10 @@ static int cop1Emulate(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
973973
struct mm_decoded_insn dec_insn, void *__user *fault_addr)
974974
{
975975
unsigned long contpc = xcp->cp0_epc + dec_insn.pc_inc;
976-
unsigned int cond, cbit;
976+
unsigned int cond, cbit, bit0;
977977
mips_instruction ir;
978978
int likely, pc_inc;
979+
union fpureg *fpr;
979980
u32 __user *wva;
980981
u64 __user *dva;
981982
u32 wval;
@@ -1187,14 +1188,14 @@ static int cop1Emulate(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
11871188
return SIGILL;
11881189

11891190
cond = likely = 0;
1191+
fpr = &current->thread.fpu.fpr[MIPSInst_RT(ir)];
1192+
bit0 = get_fpr32(fpr, 0) & 0x1;
11901193
switch (MIPSInst_RS(ir)) {
11911194
case bc1eqz_op:
1192-
if (get_fpr32(&current->thread.fpu.fpr[MIPSInst_RT(ir)], 0) & 0x1)
1193-
cond = 1;
1195+
cond = bit0 == 0;
11941196
break;
11951197
case bc1nez_op:
1196-
if (!(get_fpr32(&current->thread.fpu.fpr[MIPSInst_RT(ir)], 0) & 0x1))
1197-
cond = 1;
1198+
cond = bit0 != 0;
11981199
break;
11991200
}
12001201
goto branch_common;

0 commit comments

Comments
 (0)