All of lore.kernel.org
 help / color / mirror / Atom feed
From: Florent Revest <revest@chromium.org>
To: linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
	bpf@vger.kernel.org
Cc: catalin.marinas@arm.com, will@kernel.org, rostedt@goodmis.org,
	mhiramat@kernel.org, mark.rutland@arm.com, ast@kernel.org,
	daniel@iogearbox.net, andrii@kernel.org, kpsingh@kernel.org,
	jolsa@kernel.org, xukuohai@huaweicloud.com, lihuafei1@huawei.com,
	Florent Revest <revest@chromium.org>
Subject: [PATCH v2 00/10] Add ftrace direct call for arm64
Date: Tue,  7 Feb 2023 19:21:25 +0100	[thread overview]
Message-ID: <20230207182135.2671106-1-revest@chromium.org> (raw)

This series adds ftrace direct call support to arm64.
This makes BPF tracing programs (fentry/fexit/fmod_ret/lsm) work on arm64.

It is meant to apply on top of the arm64 tree which contains Mark Rutland's
series on CALL_OPS [1] under the for-next/ftrace tag.
  https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git/
  git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git

The first three patches consolidate the two existing ftrace APIs for registering
direct calls. They are split to make the reviewers lives easier but if it'd be a
preferred style, I'd be happy to squash them in the next revision.
Currently, there is both a _ftrace_direct and _ftrace_direct_multi API. Apart
from samples and selftests, there are no users of the _ftrace_direct API left
in-tree so this deletes it and renames the _ftrace_direct_multi API to
_ftrace_direct for simplicity.

The main benefit of this refactoring is that, with the API that's left, an
ftrace_ops backing a direct call will only ever point to one direct call. We can
therefore store the direct called trampoline address in the ops (patch 4) and
look it up from the ftrace trampoline on arm64 (patch 7) in the case when the
destination would be out of reach of a BL instruction at the ftrace callsite.
(in this case, ftrace_caller acts as a lightweight intermediary trampoline)

This series has been tested on both arm64 and x86_64 with:
1- CONFIG_FTRACE_SELFTEST (cf: patch 6)
2- samples/ftrace/*.ko (cf: patch 9)
3- tools/testing/selftests/bpf/test_progs (cf: patch 10)

Changes since v1 [2]:
- Updated the bpf selftests denylist according to newly passing tests
- Refactored the ftrace_caller assembly according to Mark's feedback
- Replaced Xu's stub trampoline patch for selftests with Mark's take on this
- Fixed direct calls on arch WITH_REGS=y and WITH_ARGS=n (x86 32-bit)
- Fixed the ftrace_regs stack alignment
- Simplified get_ftrace_plt() (cf: patch 8)
- Fixed a possible race when writing ops->direct_call
- Renamed "custom_tramp" to "direct_tramp"
- Referenced the commit id when mentioning a previous commit
- Linked the arm64 tree in the cover letter

This followed up on prior series by Xu Kuohai [3] and a RFC by me [4].

1: https://lore.kernel.org/all/20230123134603.1064407-1-mark.rutland@arm.com/
2: https://lore.kernel.org/all/20230201163420.1579014-1-revest@chromium.org/
3: https://lore.kernel.org/all/20220913162732.163631-1-xukuohai@huaweicloud.com/
4: https://lore.kernel.org/all/20221108220651.24492-1-revest@chromium.org/

Florent Revest (9):
  ftrace: Replace uses of _ftrace_direct APIs with _ftrace_direct_multi
  ftrace: Remove the legacy _ftrace_direct API
  ftrace: Rename _ftrace_direct_multi APIs to _ftrace_direct APIs
  ftrace: Store direct called addresses in their ops
  ftrace: Make DIRECT_CALLS work WITH_ARGS and !WITH_REGS
  arm64: ftrace: Add direct call support
  arm64: ftrace: Simplify get_ftrace_plt
  arm64: ftrace: Add direct call trampoline samples support
  selftests/bpf: Update the tests deny list on aarch64

Mark Rutland (1):
  ftrace: selftest: remove broken trace_direct_tramp

 arch/arm64/Kconfig                           |   4 +
 arch/arm64/include/asm/ftrace.h              |  22 +
 arch/arm64/kernel/asm-offsets.c              |   6 +
 arch/arm64/kernel/entry-ftrace.S             |  90 +++-
 arch/arm64/kernel/ftrace.c                   |  46 +-
 arch/s390/kernel/mcount.S                    |   5 +
 arch/x86/kernel/ftrace_32.S                  |   5 +
 arch/x86/kernel/ftrace_64.S                  |   4 +
 include/linux/ftrace.h                       |  59 +--
 kernel/bpf/trampoline.c                      |  14 +-
 kernel/trace/Kconfig                         |   2 +-
 kernel/trace/ftrace.c                        | 433 +------------------
 kernel/trace/trace_selftest.c                |  23 +-
 samples/Kconfig                              |   2 +-
 samples/ftrace/ftrace-direct-modify.c        |  42 +-
 samples/ftrace/ftrace-direct-multi-modify.c  |  44 +-
 samples/ftrace/ftrace-direct-multi.c         |  26 +-
 samples/ftrace/ftrace-direct-too.c           |  35 +-
 samples/ftrace/ftrace-direct.c               |  33 +-
 tools/testing/selftests/bpf/DENYLIST.aarch64 |  82 +---
 20 files changed, 382 insertions(+), 595 deletions(-)

-- 
2.39.1.519.gcb327c4b5f-goog


WARNING: multiple messages have this Message-ID (diff)
From: Florent Revest <revest@chromium.org>
To: linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
	bpf@vger.kernel.org
Cc: catalin.marinas@arm.com, will@kernel.org, rostedt@goodmis.org,
	mhiramat@kernel.org, mark.rutland@arm.com, ast@kernel.org,
	daniel@iogearbox.net, andrii@kernel.org, kpsingh@kernel.org,
	jolsa@kernel.org, xukuohai@huaweicloud.com, lihuafei1@huawei.com,
	Florent Revest <revest@chromium.org>
Subject: [PATCH v2 00/10] Add ftrace direct call for arm64
Date: Tue,  7 Feb 2023 19:21:25 +0100	[thread overview]
Message-ID: <20230207182135.2671106-1-revest@chromium.org> (raw)

This series adds ftrace direct call support to arm64.
This makes BPF tracing programs (fentry/fexit/fmod_ret/lsm) work on arm64.

It is meant to apply on top of the arm64 tree which contains Mark Rutland's
series on CALL_OPS [1] under the for-next/ftrace tag.
  https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git/
  git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git

The first three patches consolidate the two existing ftrace APIs for registering
direct calls. They are split to make the reviewers lives easier but if it'd be a
preferred style, I'd be happy to squash them in the next revision.
Currently, there is both a _ftrace_direct and _ftrace_direct_multi API. Apart
from samples and selftests, there are no users of the _ftrace_direct API left
in-tree so this deletes it and renames the _ftrace_direct_multi API to
_ftrace_direct for simplicity.

The main benefit of this refactoring is that, with the API that's left, an
ftrace_ops backing a direct call will only ever point to one direct call. We can
therefore store the direct called trampoline address in the ops (patch 4) and
look it up from the ftrace trampoline on arm64 (patch 7) in the case when the
destination would be out of reach of a BL instruction at the ftrace callsite.
(in this case, ftrace_caller acts as a lightweight intermediary trampoline)

This series has been tested on both arm64 and x86_64 with:
1- CONFIG_FTRACE_SELFTEST (cf: patch 6)
2- samples/ftrace/*.ko (cf: patch 9)
3- tools/testing/selftests/bpf/test_progs (cf: patch 10)

Changes since v1 [2]:
- Updated the bpf selftests denylist according to newly passing tests
- Refactored the ftrace_caller assembly according to Mark's feedback
- Replaced Xu's stub trampoline patch for selftests with Mark's take on this
- Fixed direct calls on arch WITH_REGS=y and WITH_ARGS=n (x86 32-bit)
- Fixed the ftrace_regs stack alignment
- Simplified get_ftrace_plt() (cf: patch 8)
- Fixed a possible race when writing ops->direct_call
- Renamed "custom_tramp" to "direct_tramp"
- Referenced the commit id when mentioning a previous commit
- Linked the arm64 tree in the cover letter

This followed up on prior series by Xu Kuohai [3] and a RFC by me [4].

1: https://lore.kernel.org/all/20230123134603.1064407-1-mark.rutland@arm.com/
2: https://lore.kernel.org/all/20230201163420.1579014-1-revest@chromium.org/
3: https://lore.kernel.org/all/20220913162732.163631-1-xukuohai@huaweicloud.com/
4: https://lore.kernel.org/all/20221108220651.24492-1-revest@chromium.org/

Florent Revest (9):
  ftrace: Replace uses of _ftrace_direct APIs with _ftrace_direct_multi
  ftrace: Remove the legacy _ftrace_direct API
  ftrace: Rename _ftrace_direct_multi APIs to _ftrace_direct APIs
  ftrace: Store direct called addresses in their ops
  ftrace: Make DIRECT_CALLS work WITH_ARGS and !WITH_REGS
  arm64: ftrace: Add direct call support
  arm64: ftrace: Simplify get_ftrace_plt
  arm64: ftrace: Add direct call trampoline samples support
  selftests/bpf: Update the tests deny list on aarch64

Mark Rutland (1):
  ftrace: selftest: remove broken trace_direct_tramp

 arch/arm64/Kconfig                           |   4 +
 arch/arm64/include/asm/ftrace.h              |  22 +
 arch/arm64/kernel/asm-offsets.c              |   6 +
 arch/arm64/kernel/entry-ftrace.S             |  90 +++-
 arch/arm64/kernel/ftrace.c                   |  46 +-
 arch/s390/kernel/mcount.S                    |   5 +
 arch/x86/kernel/ftrace_32.S                  |   5 +
 arch/x86/kernel/ftrace_64.S                  |   4 +
 include/linux/ftrace.h                       |  59 +--
 kernel/bpf/trampoline.c                      |  14 +-
 kernel/trace/Kconfig                         |   2 +-
 kernel/trace/ftrace.c                        | 433 +------------------
 kernel/trace/trace_selftest.c                |  23 +-
 samples/Kconfig                              |   2 +-
 samples/ftrace/ftrace-direct-modify.c        |  42 +-
 samples/ftrace/ftrace-direct-multi-modify.c  |  44 +-
 samples/ftrace/ftrace-direct-multi.c         |  26 +-
 samples/ftrace/ftrace-direct-too.c           |  35 +-
 samples/ftrace/ftrace-direct.c               |  33 +-
 tools/testing/selftests/bpf/DENYLIST.aarch64 |  82 +---
 20 files changed, 382 insertions(+), 595 deletions(-)

-- 
2.39.1.519.gcb327c4b5f-goog


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

             reply	other threads:[~2023-02-07 18:22 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-07 18:21 Florent Revest [this message]
2023-02-07 18:21 ` [PATCH v2 00/10] Add ftrace direct call for arm64 Florent Revest
2023-02-07 18:21 ` [PATCH v2 01/10] ftrace: Replace uses of _ftrace_direct APIs with _ftrace_direct_multi Florent Revest
2023-02-07 18:21   ` Florent Revest
2023-03-15 23:33   ` Steven Rostedt
2023-03-15 23:33     ` Steven Rostedt
2023-03-16 15:40     ` Florent Revest
2023-03-16 15:40       ` Florent Revest
2023-02-07 18:21 ` [PATCH v2 02/10] ftrace: Remove the legacy _ftrace_direct API Florent Revest
2023-02-07 18:21   ` Florent Revest
2023-02-07 18:21 ` [PATCH v2 03/10] ftrace: Rename _ftrace_direct_multi APIs to _ftrace_direct APIs Florent Revest
2023-02-07 18:21   ` Florent Revest
2023-02-07 18:21 ` [PATCH v2 04/10] ftrace: Store direct called addresses in their ops Florent Revest
2023-02-07 18:21   ` Florent Revest
2023-03-15 23:43   ` Steven Rostedt
2023-03-15 23:43     ` Steven Rostedt
2023-03-16 15:40     ` Florent Revest
2023-03-16 15:40       ` Florent Revest
2023-03-16 15:45       ` Steven Rostedt
2023-03-16 15:45         ` Steven Rostedt
2023-03-16 16:15         ` Florent Revest
2023-03-16 16:15           ` Florent Revest
2023-02-07 18:21 ` [PATCH v2 05/10] ftrace: Make DIRECT_CALLS work WITH_ARGS and !WITH_REGS Florent Revest
2023-02-07 18:21   ` Florent Revest
2023-02-07 18:21 ` [PATCH v2 06/10] ftrace: selftest: remove broken trace_direct_tramp Florent Revest
2023-02-07 18:21   ` Florent Revest
2023-03-15 23:51   ` Steven Rostedt
2023-03-15 23:51     ` Steven Rostedt
2023-03-16 15:41     ` Florent Revest
2023-03-16 15:41       ` Florent Revest
2023-02-07 18:21 ` [PATCH v2 07/10] arm64: ftrace: Add direct call support Florent Revest
2023-02-07 18:21   ` Florent Revest
2023-02-07 18:21 ` [PATCH v2 08/10] arm64: ftrace: Simplify get_ftrace_plt Florent Revest
2023-02-07 18:21   ` Florent Revest
2023-02-07 18:21 ` [PATCH v2 09/10] arm64: ftrace: Add direct call trampoline samples support Florent Revest
2023-02-07 18:21   ` Florent Revest
2023-02-07 18:21 ` [PATCH v2 10/10] selftests/bpf: Update the tests deny list on aarch64 Florent Revest
2023-02-07 18:21   ` Florent Revest

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=20230207182135.2671106-1-revest@chromium.org \
    --to=revest@chromium.org \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=daniel@iogearbox.net \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=lihuafei1@huawei.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mhiramat@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=will@kernel.org \
    --cc=xukuohai@huaweicloud.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.