Add support for kprobes on ftrace
Subsystems (3)
cover Add support for kprobes on ftrace
Hi,
these patches add support for running Kprobes on ftrace infrastructure. While at it i also fixed on bug in the code patching function and add Jump labels to the supported features list for PA-RISC.
Regards
Sven
Sven Schnelle (4):
parisc/ftrace: Add ARCH_SUPPORTS_FTRACE_OPS support parisc/ftrace: Add KPROBES_ON_FTRACE
parisc: Update feature list
parisc: fix race condition in patching code
.../core/jump-labels/arch-support.txt | 2 +- .../debug/kprobes-on-ftrace/arch-support.txt | 2 +- arch/parisc/Kconfig | 2 + arch/parisc/include/asm/ftrace.h | 1 + arch/parisc/kernel/entry.S | 99 +++++++++++++++++++ arch/parisc/kernel/ftrace.c | 67 ++++++++++++- 6 files changed, 166 insertions(+), 7 deletions(-)
Signature · 1 line
2.20.1
PATCH 1/4 parisc/ftrace: Add ARCH_SUPPORTS_FTRACE_OPS support
Pass ftrace_ops to ftrace functions to ftrace_trace_function().
--- arch/parisc/include/asm/ftrace.h | 1 + arch/parisc/kernel/ftrace.c | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-)
arch/parisc/include/asm/ftrace.h +1 -0
@@ -8,6 +8,7 @@ extern void mcount(void);#define MCOUNT_ADDR ((unsigned long)mcount)#define MCOUNT_INSN_SIZE 4#define CC_USING_NOP_MCOUNT +#define ARCH_SUPPORTS_FTRACE_OPS 1extern unsigned long sys_call_table[];extern unsigned long return_address (unsigned int );
arch/parisc/kernel/ftrace.c +6 -2
@@ -53,8 +53,12 @@ void notrace __hot ftrace_function_trampoline(unsigned long parent,#ifndef CONFIG_DYNAMIC_FTRACE extern ftrace_func_t ftrace_trace_function;#endif -if (ftrace_trace_function != ftrace_stub) -ftrace_trace_function (self_addr, parent,NULL ,NULL ); +extern struct ftrace_ops *function_trace_op; + +if (function_trace_op->flags &FTRACE_OPS_FL_ENABLED && + ftrace_trace_function != ftrace_stub) +ftrace_trace_function (self_addr, parent, + function_trace_op,NULL );#ifdef CONFIG_FUNCTION_GRAPH_TRACER if (ftrace_graph_return != (trace_func_graph_ret_t) ftrace_stub ||
Signature · 1 line
2.20.1
PATCH 2/4 parisc/ftrace: Add KPROBES_ON_FTRACE
In reply to Sven SchnelleAllow KPROBES to use the ftrace infrastructure on PA-RISC.
--- .../debug/kprobes-on-ftrace/arch-support.txt | 2 +- arch/parisc/Kconfig | 2 + arch/parisc/kernel/entry.S | 99 +++++++++++++++++++ arch/parisc/kernel/ftrace.c | 58 ++++++++++- 4 files changed, 157 insertions(+), 4 deletions(-)
Documentation/features/debug/kprobes-on-ftrace/arch-support.txt +1 -1
@@ -21,7 +21,7 @@ | nds32: | TODO | | nios2: | TODO | | openrisc: | TODO | - | parisc: | TODO | + | parisc: | ok | | powerpc: | ok | | riscv: | TODO | | s390: | TODO |
arch/parisc/Kconfig +2 -0
@@ -61,6 +61,8 @@ config PARISC select HAVE_KRETPROBES select HAVE_DYNAMIC_FTRACE if $(cc-option,-fpatchable-function-entry=1,1) select HAVE_FTRACE_MCOUNT_RECORD if HAVE_DYNAMIC_FTRACE + select HAVE_KPROBES_ON_FTRACE + select HAVE_DYNAMIC_FTRACE_WITH_REGS help The PA-RISC microprocessor is designed by Hewlett-Packard and used
arch/parisc/kernel/entry.S +99 -0
117 lines not on this page · raw message
arch/parisc/kernel/ftrace.c +55 -3
88 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH 3/4 parisc: Update feature list
In reply to Sven SchnelleAdd jump labels to the list of supported features.
--- Documentation/features/core/jump-labels/arch-support.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/features/core/jump-labels/arch-support.txt +1 -1
@@ -21,7 +21,7 @@ | nds32: | TODO | | nios2: | TODO | | openrisc: | TODO | - | parisc: | TODO | + | parisc: | ok | | powerpc: | ok | | riscv: | TODO | | s390: | ok |
Signature · 1 line
2.20.1
PATCH 4/4 parisc: fix race condition in patching code
In reply to Sven SchnelleAssume the following ftrace code sequence that was patched in earlier by ftrace_make_call():
PAGE A:
ffc: addr of ftrace_caller()
PAGE B:
000: 0x6fc10080 /* stw,ma r1,40(sp) */
004: 0x48213fd1 /* ldw -18(r1),r1 */
008: 0xe820c002 /* bv,n r0(r1) */
00c: 0xe83f1fdf /* b,l,n .-c,r1 */
When a Code sequences that is to be patched spans a page break, we might have already cleared the part on the PAGE A. If an interrupt is coming in during the remap of the fixed mapping to PAGE B, it might execute the patched function with only parts of the FTRACE code cleared. To prevent this, clear the jump to our mini trampoline first, and clear the remaining parts after this. This might also happen when patch_text() patches a function that it calls during remap.
--- arch/parisc/kernel/ftrace.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/parisc/kernel/ftrace.c +2 -1
@@ -194,8 +194,9 @@ int ftrace_make_nop(struct module *mod, struct dyn_ftrace *rec,for (i =0 ; i <ARRAY_SIZE (insn); i++) insn[i] =INSN_NOP ; +__patch_text ((void *)rec->ip,INSN_NOP );__patch_text_multiple ((void *)rec->ip +4 -sizeof (insn), - insn,sizeof (insn)); + insn,sizeof (insn)-4 ); return 0; }#endif
Signature · 1 line
2.20.1