Thread (43 messages) 43 messages, 4 authors, 2016-02-26

Re: [PATCH 03/12] powerpc/module: Create a special stub for ftrace_caller()

From: Michael Ellerman <mpe@ellerman.id.au>
Date: 2016-02-25 10:48:22
Also in: lkml

On Thu, 2016-02-25 at 11:08 +1100, Balbir Singh wrote:
On 25/02/16 01:28, Michael Ellerman wrote:
quoted
In order to support the new -mprofile-kernel ABI, we need to be able to
call from the module back to ftrace_caller() (in the kernel) without
using the module's r2. That is because the function in this module which
is calling ftrace_caller() may not have setup r2, if it doesn't
otherwise need it (ie. it accesses no globals).

To make that work we add a new stub which is used for calling
ftrace_caller(), which uses the kernel toc instead of the module toc.
diff --git a/arch/powerpc/kernel/module_64.c b/arch/powerpc/kernel/module_64.c
index 9629966e614b..e711d40a3b8f 100644
--- a/arch/powerpc/kernel/module_64.c
+++ b/arch/powerpc/kernel/module_64.c
@@ -671,10 +671,56 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
 }
 
 #ifdef CONFIG_DYNAMIC_FTRACE
+
+#define PACATOC offsetof(struct paca_struct, kernel_toc)
+
+static unsigned long create_ftrace_stub(const Elf64_Shdr *sechdrs, struct module *me)
+{
+	struct ppc64_stub_entry *entry;
+	unsigned int i, num_stubs;
How about some comments on r2
r2 is still pointing to the module's toc, will be saved by ftrace_caller and
restored by the instruction following bl ftrace_caller (after patching
_mcount/nop)
Yeah I'll add some commentary.

I think the change log describes it fairly well but a comment is also good.

cheers
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help