On Mon, Feb 28, 2022 at 03:07:05PM +0900, Masami Hiramatsu wrote:
Hi Peter,
So, instead of this change, can you try below?
This introduce the arch_adjust_kprobe_addr() and use it in the kprobe_addr()
so that it can handle the case that user passed the probe address in _text+OFFSET format.
It works a little... at the very least it still needs
arch_kprobe_on_func_entry() allowing offset 4.
But looking at this, we've got:
kprobe_on_func_entry(addr, sym, offset)
_kprobe_addr(addr, sym, offset)
if (sym)
addr = kprobe_lookup_name()
= kallsyms_lookup_name()
arch_adjust_kprobe_addr(addr+offset)
skip_endbr()
kallsyms_loopup_size_offset(addr, ...)
kallsyms_lookup_size_offset(addr, NULL, &offset)
arch_kprobe_on_func_entry(offset)
Which is _3_ kallsyms lookups and 3 weak/arch hooks.
Surely we can make this a little more streamlined? The below seems to
work.
I think with a little care and testing it should be possible to fold all
the magic of PowerPC's kprobe_lookup_name() into this one hook as well,
meaning we can get rid of kprobe_lookup_name() entirely. Naveen?
This then gets us down to a 1 kallsyms call and 1 arch hook. Hmm?
---
arch/powerpc/kernel/kprobes.c | 34 +++++++++++++++---------
arch/x86/kernel/kprobes/core.c | 17 ++++++++++++
include/linux/kprobes.h | 3 +-
kernel/kprobes.c | 56 ++++++++++++++++++++++++++++++++++-------
4 files changed, 87 insertions(+), 23 deletions(-)