Skip to content

Commit 3977223

Browse files
antonblanchardgregkh
authored andcommitted
powerpc: Fix emulation of mcrf in emulate_step()
commit 87c4b83 upstream. The mcrf emulation code was using the CR field number directly as the shift value, without taking into account that CR fields are numbered from 0-7 starting at the high bits. That meant it was looking at the CR fields in the reverse order. Fixes: cf87c3f ("powerpc: Emulate icbi, mcrf and conditional-trap instructions") 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 3f888d1 commit 3977223

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

arch/powerpc/lib/sstep.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -687,8 +687,10 @@ int __kprobes analyse_instr(struct instruction_op *op, struct pt_regs *regs,
687687
case 19:
688688
switch ((instr >> 1) & 0x3ff) {
689689
case 0: /* mcrf */
690-
rd = (instr >> 21) & 0x1c;
691-
ra = (instr >> 16) & 0x1c;
690+
rd = 7 - ((instr >> 23) & 0x7);
691+
ra = 7 - ((instr >> 18) & 0x7);
692+
rd *= 4;
693+
ra *= 4;
692694
val = (regs->ccr >> ra) & 0xf;
693695
regs->ccr = (regs->ccr & ~(0xfUL << rd)) | (val << rd);
694696
goto instr_done;

0 commit comments

Comments
 (0)