Skip to content

Commit 64e756c

Browse files
antonblanchardmpe
authored andcommitted
powerpc: Fix emulation of mfocrf in emulate_step()
From POWER4 onwards, mfocrf() only places the specified CR field into the destination GPR, and the rest of it is set to 0. The PowerPC AS from version 3.0 now requires this behaviour. The emulation code currently puts the entire CR into the destination GPR. Fix it. Fixes: 6888199 ("[POWERPC] Emulate more instructions in software") Cc: stable@vger.kernel.org # v2.6.22+ Signed-off-by: Anton Blanchard <anton@samba.org> Acked-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
1 parent 87c4b83 commit 64e756c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

arch/powerpc/lib/sstep.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -966,6 +966,19 @@ int analyse_instr(struct instruction_op *op, struct pt_regs *regs,
966966
#endif
967967

968968
case 19: /* mfcr */
969+
if ((instr >> 20) & 1) {
970+
imm = 0xf0000000UL;
971+
for (sh = 0; sh < 8; ++sh) {
972+
if (instr & (0x80000 >> sh)) {
973+
regs->gpr[rd] = regs->ccr & imm;
974+
break;
975+
}
976+
imm >>= 4;
977+
}
978+
979+
goto instr_done;
980+
}
981+
969982
regs->gpr[rd] = regs->ccr;
970983
regs->gpr[rd] &= 0xffffffffUL;
971984
goto instr_done;

0 commit comments

Comments
 (0)