Skip to content

Commit 87c4b83

Browse files
antonblanchardmpe
authored andcommitted
powerpc: Fix emulation of mcrf in emulate_step()
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") Cc: stable@vger.kernel.org # v3.18+ 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 3f0bd8d commit 87c4b83

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
@@ -683,8 +683,10 @@ int analyse_instr(struct instruction_op *op, struct pt_regs *regs,
683683
case 19:
684684
switch ((instr >> 1) & 0x3ff) {
685685
case 0: /* mcrf */
686-
rd = (instr >> 21) & 0x1c;
687-
ra = (instr >> 16) & 0x1c;
686+
rd = 7 - ((instr >> 23) & 0x7);
687+
ra = 7 - ((instr >> 18) & 0x7);
688+
rd *= 4;
689+
ra *= 4;
688690
val = (regs->ccr >> ra) & 0xf;
689691
regs->ccr = (regs->ccr & ~(0xfUL << rd)) | (val << rd);
690692
goto instr_done;

0 commit comments

Comments
 (0)