Skip to content

Commit 6a40480

Browse files
mikeyozbenh
authored andcommitted
powerpc: Avoid link stack corruption in MMU on syscall entry path
Currently we use the link register to branch up high in the early MMU on syscall entry path. Unfortunately, this trashes the link stack as the address we are going to is not associated with the earlier mflr. This patch simply converts us to used the count register (volatile over syscalls anyway) instead. This is much better at predicting in this scenario and doesn't trash link stack causing a bunch of additional branch mispredicts later. Benchmarking this on POWER8 saves a bunch of cycles on Anton's null syscall benchmark here: http://ozlabs.org/~anton/junkcode/null_syscall.c Signed-off-by: Michael Neuling <[email protected]> Signed-off-by: Benjamin Herrenschmidt <[email protected]>
1 parent 9276dfd commit 6a40480

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

arch/powerpc/kernel/exceptions-64s.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,13 @@ END_FTR_SECTION_IFSET(CPU_FTR_REAL_LE) \
7474
mflr r10 ; \
7575
ld r12,PACAKBASE(r13) ; \
7676
LOAD_HANDLER(r12, system_call_entry_direct) ; \
77-
mtlr r12 ; \
77+
mtctr r12 ; \
7878
mfspr r12,SPRN_SRR1 ; \
7979
/* Re-use of r13... No spare regs to do this */ \
8080
li r13,MSR_RI ; \
8181
mtmsrd r13,1 ; \
8282
GET_PACA(r13) ; /* get r13 back */ \
83-
blr ;
83+
bctr ;
8484
#else
8585
/* We can branch directly */
8686
#define SYSCALL_PSERIES_2_DIRECT \

0 commit comments

Comments
 (0)