All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] powerpc/64: indirect function call use bctrl rather than blrl in ret_from_kernel_thread
@ 2020-06-11 12:11 Nicholas Piggin
  2020-06-11 12:26 ` Christophe Leroy
  2020-06-26  4:46 ` Michael Ellerman
  0 siblings, 2 replies; 4+ messages in thread
From: Nicholas Piggin @ 2020-06-11 12:11 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Nicholas Piggin

blrl is not recommended to use as an indirect function call, as it may
corrupt the link stack predictor.

This is not a performance critical path but this should be fixed for
consistency.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/kernel/entry_64.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
index 223c4f008e63..f59a17471d4d 100644
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S
@@ -400,12 +400,12 @@ _GLOBAL(ret_from_fork)
 _GLOBAL(ret_from_kernel_thread)
 	bl	schedule_tail
 	REST_NVGPRS(r1)
-	mtlr	r14
+	mtctr	r14
 	mr	r3,r15
 #ifdef PPC64_ELF_ABI_v2
 	mr	r12,r14
 #endif
-	blrl
+	bctrl
 	li	r3,0
 	b	.Lsyscall_exit
 
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] powerpc/64: indirect function call use bctrl rather than blrl in ret_from_kernel_thread
  2020-06-11 12:11 [PATCH] powerpc/64: indirect function call use bctrl rather than blrl in ret_from_kernel_thread Nicholas Piggin
@ 2020-06-11 12:26 ` Christophe Leroy
  2020-06-14  9:24   ` Nicholas Piggin
  2020-06-26  4:46 ` Michael Ellerman
  1 sibling, 1 reply; 4+ messages in thread
From: Christophe Leroy @ 2020-06-11 12:26 UTC (permalink / raw)
  To: Nicholas Piggin, linuxppc-dev



Le 11/06/2020 à 14:11, Nicholas Piggin a écrit :
> blrl is not recommended to use as an indirect function call, as it may
> corrupt the link stack predictor.
> 
> This is not a performance critical path but this should be fixed for
> consistency.

There's exactly the same in entry_32.S
Should it be changed there too ... for consistency :) ?

ppc32 also uses blrl for calling syscall handler, should it be changed 
as well ?

Christophe

> 
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> ---
>   arch/powerpc/kernel/entry_64.S | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
> index 223c4f008e63..f59a17471d4d 100644
> --- a/arch/powerpc/kernel/entry_64.S
> +++ b/arch/powerpc/kernel/entry_64.S
> @@ -400,12 +400,12 @@ _GLOBAL(ret_from_fork)
>   _GLOBAL(ret_from_kernel_thread)
>   	bl	schedule_tail
>   	REST_NVGPRS(r1)
> -	mtlr	r14
> +	mtctr	r14
>   	mr	r3,r15
>   #ifdef PPC64_ELF_ABI_v2
>   	mr	r12,r14
>   #endif
> -	blrl
> +	bctrl
>   	li	r3,0
>   	b	.Lsyscall_exit
>   
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] powerpc/64: indirect function call use bctrl rather than blrl in ret_from_kernel_thread
  2020-06-11 12:26 ` Christophe Leroy
@ 2020-06-14  9:24   ` Nicholas Piggin
  0 siblings, 0 replies; 4+ messages in thread
From: Nicholas Piggin @ 2020-06-14  9:24 UTC (permalink / raw)
  To: Christophe Leroy, linuxppc-dev

Excerpts from Christophe Leroy's message of June 11, 2020 10:26 pm:
> 
> 
> Le 11/06/2020 à 14:11, Nicholas Piggin a écrit :
>> blrl is not recommended to use as an indirect function call, as it may
>> corrupt the link stack predictor.
>> 
>> This is not a performance critical path but this should be fixed for
>> consistency.
> 
> There's exactly the same in entry_32.S
> Should it be changed there too ... for consistency :) ?
> 
> ppc32 also uses blrl for calling syscall handler, should it be changed 
> as well ?

Yes I would say so. I don't know much about 32-bit implementations but
MPC7450 at least has a link stack predictor.

Thanks,
Nick

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] powerpc/64: indirect function call use bctrl rather than blrl in ret_from_kernel_thread
  2020-06-11 12:11 [PATCH] powerpc/64: indirect function call use bctrl rather than blrl in ret_from_kernel_thread Nicholas Piggin
  2020-06-11 12:26 ` Christophe Leroy
@ 2020-06-26  4:46 ` Michael Ellerman
  1 sibling, 0 replies; 4+ messages in thread
From: Michael Ellerman @ 2020-06-26  4:46 UTC (permalink / raw)
  To: linuxppc-dev, Nicholas Piggin

On Thu, 11 Jun 2020 22:11:19 +1000, Nicholas Piggin wrote:
> blrl is not recommended to use as an indirect function call, as it may
> corrupt the link stack predictor.
> 
> This is not a performance critical path but this should be fixed for
> consistency.

Applied to powerpc/next.

[1/1] powerpc/64: indirect function call use bctrl rather than blrl in ret_from_kernel_thread
      https://git.kernel.org/powerpc/c/89bbe4c798bc3a43c882179adb5222c1a972ac70

cheers

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-06-26  5:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-11 12:11 [PATCH] powerpc/64: indirect function call use bctrl rather than blrl in ret_from_kernel_thread Nicholas Piggin
2020-06-11 12:26 ` Christophe Leroy
2020-06-14  9:24   ` Nicholas Piggin
2020-06-26  4:46 ` Michael Ellerman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.