Skip to content

Commit 88670fd

Browse files
chleroympe
authored andcommitted
powerpc/ftrace: No need to read LR from stack in _mcount()
All functions calling _mcount do it exactly the same way, with the following sequence of instructions: c07de788: 7c 08 02 a6 mflr r0 c07de78c: 90 01 00 04 stw r0,4(r1) c07de790: 4b 84 13 65 bl c001faf4 <_mcount> Allthough LR is pushed on stack, it is still in r0 while entering _mcount(). Function arguments are in r3-r10, so r11 and r12 are still available at that point. Do like PPC64 and use r12 to move LR into CTR, so that r0 is preserved and doesn't need to be restored from the stack. While at it, bring back the EXPORT_SYMBOL at the end of _mcount. Signed-off-by: Christophe Leroy <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/24a3ba7db388537c44a038026f926d885372e6d3.1635423081.git.christophe.leroy@csgroup.eu
1 parent ab85a27 commit 88670fd

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

arch/powerpc/kernel/trace/ftrace_32.S

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ _GLOBAL(mcount)
1414
_GLOBAL(_mcount)
1515
/*
1616
* It is required that _mcount on PPC32 must preserve the
17-
* link register. But we have r0 to play with. We use r0
17+
* link register. But we have r12 to play with. We use r12
1818
* to push the return address back to the caller of mcount
1919
* into the ctr register, restore the link register and
2020
* then jump back using the ctr register.
2121
*/
22-
mflr r0
23-
mtctr r0
24-
lwz r0, 4(r1)
22+
mflr r12
23+
mtctr r12
2524
mtlr r0
2625
bctr
26+
EXPORT_SYMBOL(_mcount)
2727

2828
_GLOBAL(ftrace_caller)
2929
MCOUNT_SAVE_FRAME
@@ -43,7 +43,6 @@ _GLOBAL(ftrace_graph_stub)
4343
/* old link register ends up in ctr reg */
4444
bctr
4545

46-
EXPORT_SYMBOL(_mcount)
4746

4847
_GLOBAL(ftrace_stub)
4948
blr

0 commit comments

Comments
 (0)