powerpc/64: indirect function call use bctrl rather than blrl in ret_from_kernel_thread
Nicholas Piggin
reviewerPATCH 1/1 powerpc/64: indirect function call use bctrl rather than blrl in ret_from_kernel_thread
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.
--- arch/powerpc/kernel/entry_64.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/kernel/entry_64.S +2 -2
@@ -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
Signature · 1 line
2.23.0
Le 11/06/2020 à 14:11, Nicholas Piggin a écrit :
Quoted 5 lines
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
Quoted 26 lines
Signed-off-by Nicholas Piggin <[email protected]>--- arch/powerpc/kernel/entry_64.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/powerpc/kernel/entry_64.S +2
-2@@ -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
Nicholas Piggin
reviewerExcerpts from Christophe Leroy's message of June 11, 2020 10:26 pm:
Quoted 6 lines
Le 11/06/2020 à 14:11, Nicholas Piggin a écrit :
Quoted 3 lines
blrl is not recommended to use as an indirect function call, as it may corrupt the link stack predictor.
Quoted 8 lines
Quoted 2 lines
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
Michael Ellerman
AppliedQuoted 5 lines · 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.
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