diff options
author | Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com> | 2017-04-12 07:18:51 -0400 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2017-04-23 06:32:25 -0400 |
commit | 71f6e58e5efe09b98a1862d4c25976e8f7763b67 (patch) | |
tree | 1f97bd06729dbaa0075b96e434517ca440f559aa /arch/powerpc/lib/code-patching.c | |
parent | 700e64377c2c8e2406e9c4c1632e2eabdb3a95a1 (diff) |
powerpc/kprobes: Convert __kprobes to NOKPROBE_SYMBOL()
Along similar lines as commit 9326638cbee2 ("kprobes, x86: Use NOKPROBE_SYMBOL()
instead of __kprobes annotation"), convert __kprobes annotation to either
NOKPROBE_SYMBOL() or nokprobe_inline. The latter forces inlining, in which case
the caller needs to be added to NOKPROBE_SYMBOL().
Also:
- blacklist arch_deref_entry_point(), and
- convert a few regular inlines to nokprobe_inline in lib/sstep.c
A key benefit is the ability to detect such symbols as being
blacklisted. Before this patch:
$ cat /sys/kernel/debug/kprobes/blacklist | grep read_mem
$ perf probe read_mem
Failed to write event: Invalid argument
Error: Failed to add events.
$ dmesg | tail -1
[ 3736.112815] Could not insert probe at _text+10014968: -22
After patch:
$ cat /sys/kernel/debug/kprobes/blacklist | grep read_mem
0xc000000000072b50-0xc000000000072d20 read_mem
$ perf probe read_mem
read_mem is blacklisted function, skip it.
Added new events:
(null):(null) (on read_mem)
probe:read_mem (on read_mem)
You can now use it in all perf tools, such as:
perf record -e probe:read_mem -aR sleep 1
$ grep " read_mem" /proc/kallsyms
c000000000072b50 t read_mem
c0000000005f3b40 t read_mem
$ cat /sys/kernel/debug/kprobes/list
c0000000005f3b48 k read_mem+0x8 [DISABLED]
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
[mpe: Minor change log formatting, fix up some conflicts]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'arch/powerpc/lib/code-patching.c')
-rw-r--r-- | arch/powerpc/lib/code-patching.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/arch/powerpc/lib/code-patching.c b/arch/powerpc/lib/code-patching.c index 0d3002b7e2b4..500b0f6a0b64 100644 --- a/arch/powerpc/lib/code-patching.c +++ b/arch/powerpc/lib/code-patching.c | |||
@@ -8,6 +8,7 @@ | |||
8 | */ | 8 | */ |
9 | 9 | ||
10 | #include <linux/kernel.h> | 10 | #include <linux/kernel.h> |
11 | #include <linux/kprobes.h> | ||
11 | #include <linux/vmalloc.h> | 12 | #include <linux/vmalloc.h> |
12 | #include <linux/init.h> | 13 | #include <linux/init.h> |
13 | #include <linux/mm.h> | 14 | #include <linux/mm.h> |
@@ -59,7 +60,7 @@ bool is_offset_in_branch_range(long offset) | |||
59 | * Helper to check if a given instruction is a conditional branch | 60 | * Helper to check if a given instruction is a conditional branch |
60 | * Derived from the conditional checks in analyse_instr() | 61 | * Derived from the conditional checks in analyse_instr() |
61 | */ | 62 | */ |
62 | bool __kprobes is_conditional_branch(unsigned int instr) | 63 | bool is_conditional_branch(unsigned int instr) |
63 | { | 64 | { |
64 | unsigned int opcode = instr >> 26; | 65 | unsigned int opcode = instr >> 26; |
65 | 66 | ||
@@ -75,6 +76,7 @@ bool __kprobes is_conditional_branch(unsigned int instr) | |||
75 | } | 76 | } |
76 | return false; | 77 | return false; |
77 | } | 78 | } |
79 | NOKPROBE_SYMBOL(is_conditional_branch); | ||
78 | 80 | ||
79 | unsigned int create_branch(const unsigned int *addr, | 81 | unsigned int create_branch(const unsigned int *addr, |
80 | unsigned long target, int flags) | 82 | unsigned long target, int flags) |