File opal-prd-Fix-opal-prd-crash.patch of Package skiboot

From ff576aa8187b47f61f902b6a097693d00c937d4c Mon Sep 17 00:00:00 2001
From: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
Date: Mon, 30 Jul 2018 15:28:46 +0530
Subject: [PATCH] opal-prd: Fix opal-prd crash

Patch-mainline: v6.2-rc1
Git-commit: ff576aa8187b47f61f902b6a097693d00c937d4c

Presently callback function from HBRT uses r11 to point to target function
pointer. r12 is garbage. This works fine when we compile with "-no-pie" option
(as we don't use r12 to calculate TOC).

As per ABIv2 : "r12 : Function entry address at global entry point"

With "-pie" compilation option, we have to set r12 to point to global function
entry point. So that we can calculate TOC properly.

Crash log without this patch:
  opal-prd[2864]: unhandled signal 11 at 0000000000029320 nip 00000 00102012830 lr 0000000102016890 code 1

Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
CC: Jeremy Kerr <jk@ozlabs.org>
CC: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
Acked-by: Jeremy Kerr <jk@ozlabs.org>
Reviewed-by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
---
 external/opal-prd/thunk.S | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/external/opal-prd/thunk.S b/external/opal-prd/thunk.S
index e09cef940099..d0ccd6491805 100644
--- a/external/opal-prd/thunk.S
+++ b/external/opal-prd/thunk.S
@@ -119,7 +119,7 @@ call_le:
 	std %r0,(32+16)(%r1)
 
 	/* Branch to original function */
-	mtlr	%r11
+	mtlr	%r12
 	blrl
 
 	/* Restore stack and LR */
@@ -137,7 +137,7 @@ call_le:
 	/* Callback from HBRT. There is one entry point per function.
 	 *
 	 * We assume the proper r2 is already set via the OPD, so we grab our
-	 * target function pointer in r11 and jump to call_le
+	 * target function pointer in r12 and jump to call_le
 	 */
 #define CALLBACK_THUNK(name)							 \
 	.pushsection ".text","ax" 						;\
@@ -146,7 +146,7 @@ name##_thunk:									;\
 	.long 0x00000038 | le_si16(__NR_switch_endian)				;\
 			/* byteswapped li %r0,__NR_switch_endian */		;\
 	.long 0x02000044 /* byteswapped sc */					;\
-	ld %r11,name@got(%r2)							;\
+	ld %r12,name@got(%r2)							;\
 	b call_le								;\
 	.popsection								;\
 	.pushsection ".data.thunk_opd","aw" 					;\
-- 
2.19.2

openSUSE Build Service is sponsored by