[Skiboot] [PATCH] opal-prd: Fix opal-prd crash

Mahesh Jagannath Salgaonkar mahesh at linux.vnet.ibm.com
Wed Aug 1 15:01:14 AEST 2018


On 07/30/2018 03:28 PM, Vasant Hegde wrote:
> 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 at linux.vnet.ibm.com>
> CC: Jeremy Kerr <jk at ozlabs.org>
> CC: Mahesh Salgaonkar <mahesh at linux.vnet.ibm.com>

Reviewed-by: Mahesh Salgaonkar <mahesh at linux.vnet.ibm.com>

Thanks,
-Mahesh.

> ---
>  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 e09cef940..d0ccd6491 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 at got(%r2)							;\
> +	ld %r12,name at got(%r2)							;\
>  	b call_le								;\
>  	.popsection								;\
>  	.pushsection ".data.thunk_opd","aw" 					;\
> 



More information about the Skiboot mailing list