bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Masami Hiramatsu <mhiramat@kernel.org>
To: Alexei Starovoitov <ast@kernel.org>,
	Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>,
	Shubham Bansal <illusionist.neo@gmail.com>,
	Andrii Nakryiko <andrii@kernel.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	bpf@vger.kernel.org, kernel-team@fb.com,
	Jiri Olsa <jolsa@kernel.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	"Naveen N . Rao" <naveen.n.rao@linux.ibm.com>,
	Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>,
	"David S . Miller" <davem@davemloft.net>,
	linux-kernel@vger.kernel.org, Mark Rutland <mark.rutland@arm.com>,
	Will Deacon <will@kernel.org>, Ard Biesheuvel <ardb@kernel.org>,
	Russell King <linux@armlinux.org.uk>,
	Catalin Marinas <catalin.marinas@arm.com>,
	linux-arm-kernel@lists.infradead.org
Subject: [PATCH bpf 0/4] kprobes: rethook,ARM,arm64: Replace kretprobe trampoline with rethook
Date: Tue,  5 Apr 2022 18:33:35 +0900	[thread overview]
Message-ID: <164915121498.982637.12787715964983738566.stgit@devnote2> (raw)

Hello,

Here is a series for replacing kretprobe trampoline with rethook on ARM/arm64.
This series are applicable to bpf tree (not arm tree) because the basement
patch is still only on that tree.

Actually, this series includes a trivial bugfix for the arm unwinder to
initialize an internal data structure([1/4]). This is not critical for
stack trace, but required for rethook to find LR register on the stack.
This also have an update for the rethook interface, which allows us to
check the rethook_hook() failure ([2/4]). This is also required for the
rethook on arm because unwinder is able to fail.
The rest of patches are replacing kretprobe trampoline with rethook on
ARM ([3/4]) and arm64 ([4/4]).

Background:

This rethook came from Jiri's request of multiple kprobe for bpf[1].
He tried to solve an issue that starting bpf with multiple kprobe will
take a long time because bpf-kprobe will wait for RCU grace period for
sync rcu events.

Jiri wanted to attach a single bpf handler to multiple kprobes and
he tried to introduce multiple-probe interface to kprobe. So I asked
him to use ftrace and kretprobe-like hook if it is only for the
function entry and exit, instead of adding ad-hoc interface
to kprobes.
For this purpose, I introduced the fprobe (kprobe like interface for
ftrace) with the rethook (this is a generic return hook feature for
fprobe exit handler)[2].

[1] https://lore.kernel.org/all/20220104080943.113249-1-jolsa@kernel.org/T/#u
[2] https://lore.kernel.org/all/164191321766.806991.7930388561276940676.stgit@devnote2/T/#u

The rethook is basically same as the kretprobe trampoline. I just made
it decoupled from kprobes. Eventually, the all arch dependent kretprobe
trampolines will be replaced with the rethook trampoline instead of
cloning the code.

When I port the rethook for all arch which supports kretprobe, the
legacy kretprobe specific code (which is for CONFIG_KRETPROBE_ON_RETHOOK=n)
will be removed eventually.

BTW, the arm Clang support for rethook is for kretprobes only. fprobe
and ftrace seems not working with Clang yet.

Thank you,

---

Masami Hiramatsu (4):
      ARM: unwind: Initialize the lr_addr field of unwind_ctrl_block
      rethook,fprobe,kprobes: Check a failure in the rethook_hook()
      ARM: rethook: Replace kretprobe trampoline with rethook
      arm64: rethook: Replace kretprobe trampoline with rethook


 arch/arm/Kconfig                              |    1 
 arch/arm/include/asm/stacktrace.h             |    5 +
 arch/arm/kernel/stacktrace.c                  |   13 +--
 arch/arm/kernel/unwind.c                      |    1 
 arch/arm/probes/Makefile                      |    1 
 arch/arm/probes/kprobes/core.c                |   62 ------------
 arch/arm/probes/rethook.c                     |  127 +++++++++++++++++++++++++
 arch/arm64/Kconfig                            |    1 
 arch/arm64/include/asm/kprobes.h              |    2 
 arch/arm64/include/asm/stacktrace.h           |    2 
 arch/arm64/kernel/Makefile                    |    1 
 arch/arm64/kernel/probes/Makefile             |    1 
 arch/arm64/kernel/probes/kprobes.c            |   15 ---
 arch/arm64/kernel/probes/kprobes_trampoline.S |   86 -----------------
 arch/arm64/kernel/rethook.c                   |   26 +++++
 arch/arm64/kernel/rethook_trampoline.S        |   87 +++++++++++++++++
 arch/arm64/kernel/stacktrace.c                |    9 +-
 arch/x86/kernel/rethook.c                     |    4 +
 include/linux/rethook.h                       |    4 -
 kernel/kprobes.c                              |    8 +-
 kernel/trace/fprobe.c                         |    5 +
 kernel/trace/rethook.c                        |   12 ++
 22 files changed, 285 insertions(+), 188 deletions(-)
 create mode 100644 arch/arm/probes/rethook.c
 delete mode 100644 arch/arm64/kernel/probes/kprobes_trampoline.S
 create mode 100644 arch/arm64/kernel/rethook.c
 create mode 100644 arch/arm64/kernel/rethook_trampoline.S

--
Masami Hiramatsu (Linaro) <mhiramat@kernel.org>

             reply	other threads:[~2022-04-05  9:53 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-05  9:33 Masami Hiramatsu [this message]
2022-04-05  9:33 ` [PATCH bpf 1/4] ARM: unwind: Initialize the lr_addr field of unwind_ctrl_block Masami Hiramatsu
2022-04-06 18:53   ` kernel test robot
2022-04-05  9:33 ` [PATCH bpf 2/4] rethook,fprobe,kprobes: Check a failure in the rethook_hook() Masami Hiramatsu
2022-04-05  9:34 ` [PATCH bpf 3/4] ARM: rethook: Replace kretprobe trampoline with rethook Masami Hiramatsu
2022-04-05  9:34 ` [PATCH bpf 4/4] arm64: " Masami Hiramatsu
2022-04-05 17:40   ` kernel test robot
2022-04-05 21:25   ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=164915121498.982637.12787715964983738566.stgit@devnote2 \
    --to=mhiramat@kernel.org \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=anil.s.keshavamurthy@intel.com \
    --cc=ardb@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=illusionist.neo@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kernel-team@fb.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=mark.rutland@arm.com \
    --cc=naveen.n.rao@linux.ibm.com \
    --cc=rostedt@goodmis.org \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).