OSDN Git Service

powerpc/kprobes: Clean up jprobe detection in livepatch handler
authorNaveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Fri, 22 Sep 2017 09:10:45 +0000 (14:40 +0530)
committerMichael Ellerman <mpe@ellerman.id.au>
Wed, 4 Oct 2017 12:42:17 +0000 (23:42 +1100)
In commit c05b8c4474c03 ("powerpc/kprobes: Skip livepatch_handler() for
jprobes"), we added a helper is_current_kprobe_addr() to help detect if
the modified regs->nip was due to a jprobe or livepatch. Masami felt
that the function name was not quite clear. To that end, this patch
renames is_current_kprobe_addr() to __is_active_jprobe() and adds a
comment to (hopefully) better clarify the purpose of this helper. The
helper has also now been moved to kprobes-ftrace.c so that it is only
available for KPROBES_ON_FTRACE.

Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/include/asm/kprobes.h
arch/powerpc/kernel/kprobes-ftrace.c
arch/powerpc/kernel/kprobes.c
arch/powerpc/kernel/trace/ftrace_64_mprofile.S

index 8814a72..9f3be5c 100644 (file)
@@ -103,8 +103,8 @@ extern int kprobe_exceptions_notify(struct notifier_block *self,
 extern int kprobe_fault_handler(struct pt_regs *regs, int trapnr);
 extern int kprobe_handler(struct pt_regs *regs);
 extern int kprobe_post_handler(struct pt_regs *regs);
-extern int is_current_kprobe_addr(unsigned long addr);
 #ifdef CONFIG_KPROBES_ON_FTRACE
+extern int __is_active_jprobe(unsigned long addr);
 extern int skip_singlestep(struct kprobe *p, struct pt_regs *regs,
                           struct kprobe_ctlblk *kcb);
 #else
index 6c089d9..48f675a 100644 (file)
 #include <linux/preempt.h>
 #include <linux/ftrace.h>
 
+/*
+ * This is called from ftrace code after invoking registered handlers to
+ * disambiguate regs->nip changes done by jprobes and livepatch. We check if
+ * there is an active jprobe at the provided address (mcount location).
+ */
+int __is_active_jprobe(unsigned long addr)
+{
+       struct kprobe *p = kprobe_running();
+       return (p && (unsigned long)p->addr == addr) ? 1 : 0;
+}
+
 static nokprobe_inline
 int __skip_singlestep(struct kprobe *p, struct pt_regs *regs,
                      struct kprobe_ctlblk *kcb, unsigned long orig_nip)
index 4c17024..48a8161 100644 (file)
@@ -43,12 +43,6 @@ DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);
 
 struct kretprobe_blackpoint kretprobe_blacklist[] = {{NULL, NULL}};
 
-int is_current_kprobe_addr(unsigned long addr)
-{
-       struct kprobe *p = kprobe_running();
-       return (p && (unsigned long)p->addr == addr) ? 1 : 0;
-}
-
 bool arch_within_kprobe_blacklist(unsigned long addr)
 {
        return  (addr >= (unsigned long)__kprobes_text_start &&
index c98e90b..c1cfcce 100644 (file)
@@ -110,9 +110,9 @@ ftrace_call:
        /* NIP has not been altered, skip over further checks */
        beq     1f
 
-       /* Check if there is an active kprobe on us */
+       /* Check if there is an active jprobe on us */
        subi    r3, r14, 4
-       bl      is_current_kprobe_addr
+       bl      __is_active_jprobe
        nop
 
        /*