]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.9.40/powerpc-fix-emulation-of-mcrf-in-emulate_step.patch
3.18-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.9.40 / powerpc-fix-emulation-of-mcrf-in-emulate_step.patch
CommitLineData
96f84f2b
GKH
1From 87c4b83e0fe234a1f0eed131ab6fa232036860d5 Mon Sep 17 00:00:00 2001
2From: Anton Blanchard <anton@samba.org>
3Date: Thu, 15 Jun 2017 09:46:38 +1000
4Subject: powerpc: Fix emulation of mcrf in emulate_step()
5
6From: Anton Blanchard <anton@samba.org>
7
8commit 87c4b83e0fe234a1f0eed131ab6fa232036860d5 upstream.
9
10The mcrf emulation code was using the CR field number directly as the shift
11value, without taking into account that CR fields are numbered from 0-7 starting
12at the high bits. That meant it was looking at the CR fields in the reverse
13order.
14
15Fixes: cf87c3f6b647 ("powerpc: Emulate icbi, mcrf and conditional-trap instructions")
16Signed-off-by: Anton Blanchard <anton@samba.org>
17Acked-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
18Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
19Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
20
21---
22 arch/powerpc/lib/sstep.c | 6 ++++--
23 1 file changed, 4 insertions(+), 2 deletions(-)
24
25--- a/arch/powerpc/lib/sstep.c
26+++ b/arch/powerpc/lib/sstep.c
27@@ -687,8 +687,10 @@ int __kprobes analyse_instr(struct instr
28 case 19:
29 switch ((instr >> 1) & 0x3ff) {
30 case 0: /* mcrf */
31- rd = (instr >> 21) & 0x1c;
32- ra = (instr >> 16) & 0x1c;
33+ rd = 7 - ((instr >> 23) & 0x7);
34+ ra = 7 - ((instr >> 18) & 0x7);
35+ rd *= 4;
36+ ra *= 4;
37 val = (regs->ccr >> ra) & 0xf;
38 regs->ccr = (regs->ccr & ~(0xfUL << rd)) | (val << rd);
39 goto instr_done;