powerpc32/ftrace: Unify 32-bit and 64-bit ftrace entry code
authorNaveen N Rao <naveen@kernel.org>
Wed, 30 Oct 2024 07:08:37 +0000 (12:38 +0530)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 31 Oct 2024 00:00:53 +0000 (11:00 +1100)
commit654b3fa61b817a46037197b73a7ac6d36d01df7e
tree1738d5b550b4253dce3f2d6074dd3f54432327d0
parent161d62c2b067c4071cb515efe16475171e1c051e
powerpc32/ftrace: Unify 32-bit and 64-bit ftrace entry code

On 32-bit powerpc, gcc generates a three instruction sequence for
function profiling:
mflr r0
stw r0, 4(r1)
bl _mcount

On kernel boot, the call to _mcount() is nop-ed out, to be patched back
in when ftrace is actually enabled. The 'stw' instruction therefore is
not necessary unless ftrace is enabled. Nop it out during ftrace init.

When ftrace is enabled, we want the 'stw' so that stack unwinding works
properly. Perform the same within the ftrace handler, similar to 64-bit
powerpc.

Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Naveen N Rao <naveen@kernel.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://patch.msgid.link/20241030070850.1361304-5-hbathini@linux.ibm.com
arch/powerpc/kernel/trace/ftrace.c
arch/powerpc/kernel/trace/ftrace_entry.S