[PATCH 1/3] powerpc: kprobes: fix handling of function offsets on ABIv2

Naveen N. Rao naveen.n.rao at linux.vnet.ibm.com
Thu Feb 16 04:58:05 AEDT 2017


On 2017/02/16 12:17AM, Masami Hiramatsu wrote:
> On Tue, 14 Feb 2017 14:08:01 +0530
> "Naveen N. Rao" <naveen.n.rao at linux.vnet.ibm.com> wrote:
> 
> > commit 239aeba76409 ("perf powerpc: Fix kprobe and kretprobe handling
> > with kallsyms on ppc64le") changed how we use the offset field in struct
> > kprobe on ABIv2. perf now offsets from the GEP (Global entry point) if an
> > offset is specified and otherwise chooses the LEP (Local entry point).
> > 
> > Fix the same in kernel for kprobe API users. We do this by extending
> > kprobe_lookup_name() to accept an additional parameter to indicate the
> > offset specified with the kprobe registration. If offset is 0, we return
> > the local function entry and return the global entry point otherwise.
> > 

<snip>

> > diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> > index 83ad7e440417..9bc433575d98 100644
> > --- a/kernel/kprobes.c
> > +++ b/kernel/kprobes.c
> > @@ -63,7 +63,7 @@
> >   * so this must be overridable.
> >   */
> >  #ifndef kprobe_lookup_name
> > -#define kprobe_lookup_name(name, addr) \
> > +#define kprobe_lookup_name(name, addr, offset) \
> >  	addr = ((kprobe_opcode_t *)(kallsyms_lookup_name(name)))
> >  #endif
> 
> Hmm, it smells no good coding... I would like to use __weak function
> instead of this "#ifndef" trick.

Can't say I wasn't tempted. KPROBES_ON_FTRACE makes this worse. I will 
clean this up.

Thanks!
- Naveen



More information about the Linuxppc-dev mailing list