[PATCH] powerpc/ftrace: restore r2 to caller's stack on livepatch sibling call
Michael Ellerman
mpe at ellerman.id.au
Tue Jul 30 00:17:18 AEST 2024
Hi Ryan,
Thanks for the patch.
Ryan Sullivan <rysulliv at redhat.com> writes:
> Currently, on PowerPC machines, sibling calls in livepatched functions
> cause the stack to be corrupted and are thus not supported by tools
> such as kpatch. Below is an example stack frame showing one such
> currupted stacks:
...
> diff --git a/arch/powerpc/kernel/trace/ftrace_entry.S b/arch/powerpc/kernel/trace/ftrace_entry.S
> index 76dbe9fd2c0f..4dfbe6076ad1 100644
> --- a/arch/powerpc/kernel/trace/ftrace_entry.S
> +++ b/arch/powerpc/kernel/trace/ftrace_entry.S
> @@ -244,6 +244,9 @@ livepatch_handler:
> mtlr r12
> ld r2, -24(r11)
>
> + /* Restore toc to caller's stack in case of sibling call */
> + std r2, 24(r1)
> +
It would be good to have a comment here explaining why it's safe in all
cases to store the current r2 value back to the caller's save slot.
I haven't convinced myself that it is always safe, but I need to think
about it a bit harder O_o
cheers
More information about the Linuxppc-dev
mailing list