Skip to content

Commit 79afeb3

Browse files
antonblanchardgregkh
authored andcommitted
powerpc: Fix emulation of mfocrf in emulate_step()
commit 64e756c upstream. 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") Signed-off-by: Anton Blanchard <[email protected]> Acked-by: Naveen N. Rao <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 3977223 commit 79afeb3

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
@@ -969,6 +969,19 @@ int __kprobes analyse_instr(struct instruction_op *op, struct pt_regs *regs,
969969
#endif
970970

971971
case 19: /* mfcr */
972+
if ((instr >> 20) & 1) {
973+
imm = 0xf0000000UL;
974+
for (sh = 0; sh < 8; ++sh) {
975+
if (instr & (0x80000 >> sh)) {
976+
regs->gpr[rd] = regs->ccr & imm;
977+
break;
978+
}
979+
imm >>= 4;
980+
}
981+
982+
goto instr_done;
983+
}
984+
972985
regs->gpr[rd] = regs->ccr;
973986
regs->gpr[rd] &= 0xffffffffUL;
974987
goto instr_done;

0 commit comments

Comments
 (0)