]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.14.69/powerpc-pseries-fix-endianness-while-restoring-of-r3-in-mce-handler.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.14.69 / powerpc-pseries-fix-endianness-while-restoring-of-r3-in-mce-handler.patch
1 From cd813e1cd7122f2c261dce5b54d1e0c97f80e1a5 Mon Sep 17 00:00:00 2001
2 From: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
3 Date: Tue, 7 Aug 2018 19:46:46 +0530
4 Subject: powerpc/pseries: Fix endianness while restoring of r3 in MCE handler.
5
6 From: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
7
8 commit cd813e1cd7122f2c261dce5b54d1e0c97f80e1a5 upstream.
9
10 During Machine Check interrupt on pseries platform, register r3 points
11 RTAS extended event log passed by hypervisor. Since hypervisor uses r3
12 to pass pointer to rtas log, it stores the original r3 value at the
13 start of the memory (first 8 bytes) pointed by r3. Since hypervisor
14 stores this info and rtas log is in BE format, linux should make
15 sure to restore r3 value in correct endian format.
16
17 Without this patch when MCE handler, after recovery, returns to code that
18 that caused the MCE may end up with Data SLB access interrupt for invalid
19 address followed by kernel panic or hang.
20
21 Severe Machine check interrupt [Recovered]
22 NIP [d00000000ca301b8]: init_module+0x1b8/0x338 [bork_kernel]
23 Initiator: CPU
24 Error type: SLB [Multihit]
25 Effective address: d00000000ca70000
26 cpu 0xa: Vector: 380 (Data SLB Access) at [c0000000fc7775b0]
27 pc: c0000000009694c0: vsnprintf+0x80/0x480
28 lr: c0000000009698e0: vscnprintf+0x20/0x60
29 sp: c0000000fc777830
30 msr: 8000000002009033
31 dar: a803a30c000000d0
32 current = 0xc00000000bc9ef00
33 paca = 0xc00000001eca5c00 softe: 3 irq_happened: 0x01
34 pid = 8860, comm = insmod
35 vscnprintf+0x20/0x60
36 vprintk_emit+0xb4/0x4b0
37 vprintk_func+0x5c/0xd0
38 printk+0x38/0x4c
39 init_module+0x1c0/0x338 [bork_kernel]
40 do_one_initcall+0x54/0x230
41 do_init_module+0x8c/0x248
42 load_module+0x12b8/0x15b0
43 sys_finit_module+0xa8/0x110
44 system_call+0x58/0x6c
45 --- Exception: c00 (System Call) at 00007fff8bda0644
46 SP (7fffdfbfe980) is in userspace
47
48 This patch fixes this issue.
49
50 Fixes: a08a53ea4c97 ("powerpc/le: Enable RTAS events support")
51 Cc: stable@vger.kernel.org # v3.15+
52 Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
53 Signed-off-by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
54 Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
55 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
56
57 ---
58 arch/powerpc/platforms/pseries/ras.c | 2 +-
59 1 file changed, 1 insertion(+), 1 deletion(-)
60
61 --- a/arch/powerpc/platforms/pseries/ras.c
62 +++ b/arch/powerpc/platforms/pseries/ras.c
63 @@ -360,7 +360,7 @@ static struct rtas_error_log *fwnmi_get_
64 }
65
66 savep = __va(regs->gpr[3]);
67 - regs->gpr[3] = savep[0]; /* restore original r3 */
68 + regs->gpr[3] = be64_to_cpu(savep[0]); /* restore original r3 */
69
70 /* If it isn't an extended log we can use the per cpu 64bit buffer */
71 h = (struct rtas_error_log *)&savep[1];