BPF List
 help / color / mirror / Atom feed
From: Kumar Kartikeya Dwivedi <memxor@gmail.com>
To: bpf@vger.kernel.org
Cc: Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Eduard Zingerman <eddyz87@gmail.com>,
	Emil Tsalapatis <emil@etsalapatis.com>,
	Ihor Solodrai <ihor.solodrai@linux.dev>,
	kkd@meta.com, kernel-team@meta.com
Subject: [PATCH bpf-next v1 00/14] Retire KF_ARENA_ARG kfunc flags
Date: Sat, 22 Aug 2026 01:34:54 +0200	[thread overview]
Message-ID: <20260821233516.3426127-1-memxor@gmail.com> (raw)

KF_ARENA_ARG1 and KF_ARENA_ARG2 duplicate the BTF argument-name suffix
mechanism and only cover the first two kfunc parameters. Retire the flags
from the kernel and resolve_btfids, and describe the arena allocation
kfunc arguments with __arena suffixes instead.

Suffix conversion makes the JIT responsible for translating the 32-bit
arena offset passed by BPF into a kernel address before the kfunc call.
Translate the address back inside the allocation kfuncs so the existing
arena helpers continue to receive lower-32-bit user addresses. Keep free
and reserve non-nullable: an arena starting at the 4 GiB boundary has a
valid first page whose lower 32 bits are zero.

Split the JIT capability hook because kfunc calls and struct_ops callbacks
perform opposite conversions at different boundaries. Add kfunc argument
rebasing to RISC-V, s390, LoongArch, and PowerPC64, and add the reverse
struct_ops conversion to RISC-V, s390, and LoongArch. RISC-V and LoongArch
also need independent fixes for stack-passed arguments in indirect
trampolines.

Extend the shared arena tests to every JIT advertising each capability and
update the conversion-specific expectations and large-arena coverage.

The resulting support now with these changes for __arena suffixes is:

  kfunc arguments:      x86-64, arm64, RISC-V, s390, LoongArch, PowerPC64
  struct_ops arguments: x86-64, arm64, RISC-V, s390, LoongArch

NOTE: The individual JIT patches are not tested by me, and need the acks
of individual JIT maintainers before they can be landed. However, to
truly retire this flag, these changes are necessary so that arena kfuncs
for page allocation and freeing remain functional on those architectures.

Kumar Kartikeya Dwivedi (14):
  bpf: Split arena kfunc and struct_ops JIT capabilities
  bpf, riscv: Fix stack-passed arguments for indirect trampolines
  bpf, riscv: JIT arena kfunc argument rebasing
  bpf, riscv: Convert struct_ops arena arguments in the trampoline
  bpf, s390: JIT arena kfunc argument rebasing
  bpf, s390: Convert struct_ops arena arguments
  bpf, loongarch: Fix stack arguments for indirect trampolines
  bpf, loongarch: JIT arena kfunc argument rebasing
  bpf, loongarch: Convert struct_ops arena arguments in trampolines
  bpf, powerpc: JIT arena kfunc argument rebasing
  bpf: Replace arena kfunc argument flags with suffixes
  resolve_btfids: Drop KF_ARENA_ARG flag support
  selftests/bpf: Exercise arena arguments on every capable JIT
  docs/bpf: Document split arena argument JIT capabilities

 Documentation/bpf/kfuncs.rst                  |  15 +-
 arch/arm64/net/bpf_jit_comp.c                 |   7 +-
 arch/loongarch/net/bpf_jit.c                  |  98 ++++++++++--
 arch/powerpc/net/bpf_jit_comp.c               |   5 +
 arch/powerpc/net/bpf_jit_comp64.c             |  18 ++-
 arch/riscv/net/bpf_jit_comp64.c               | 139 ++++++++++++++++--
 arch/s390/net/bpf_jit_comp.c                  | 118 ++++++++++++++-
 arch/x86/net/bpf_jit_comp.c                   |   7 +-
 include/linux/btf.h                           |   2 -
 include/linux/filter.h                        |   3 +-
 kernel/bpf/arena.c                            |  40 +++--
 kernel/bpf/core.c                             |   7 +-
 kernel/bpf/verifier.c                         |   4 +-
 tools/bpf/resolve_btfids/main.c               |  22 +--
 .../selftests/bpf/prog_tests/resolve_btfids.c |  22 +--
 .../bpf/prog_tests/test_struct_ops_arena.c    |  16 +-
 .../testing/selftests/bpf/progs/arena_kfunc.c |  36 +++++
 .../selftests/bpf/progs/arena_kfunc_jit.c     |  16 +-
 tools/testing/selftests/bpf/progs/bpf_misc.h  |   1 +
 .../selftests/bpf/progs/verifier_arena.c      |   6 +
 .../bpf/progs/verifier_arena_large.c          |   4 +-
 tools/testing/selftests/bpf/test_loader.c     |   5 +
 22 files changed, 487 insertions(+), 104 deletions(-)


base-commit: 669e4fa766000ae4137bb02eb22ce75ba78ad32d
-- 
2.53.0


             reply	other threads:[~2026-08-21 23:35 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-21 23:34 Kumar Kartikeya Dwivedi [this message]
2026-08-21 23:34 ` [PATCH bpf-next v1 01/14] bpf: Split arena kfunc and struct_ops JIT capabilities Kumar Kartikeya Dwivedi
2026-08-22  0:46   ` bot+bpf-ci
2026-08-24 22:28   ` Eduard Zingerman
2026-08-24 22:37     ` Kumar Kartikeya Dwivedi
2026-08-21 23:34 ` [PATCH bpf-next v1 02/14] bpf, riscv: Fix stack-passed arguments for indirect trampolines Kumar Kartikeya Dwivedi
2026-08-24  6:21   ` Pu Lehui
2026-08-21 23:34 ` [PATCH bpf-next v1 03/14] bpf, riscv: JIT arena kfunc argument rebasing Kumar Kartikeya Dwivedi
2026-08-24  6:36   ` Pu Lehui
2026-08-21 23:34 ` [PATCH bpf-next v1 04/14] bpf, riscv: Convert struct_ops arena arguments in the trampoline Kumar Kartikeya Dwivedi
2026-08-21 23:44   ` sashiko-bot
2026-08-24  6:38   ` Pu Lehui
2026-08-21 23:34 ` [PATCH bpf-next v1 05/14] bpf, s390: JIT arena kfunc argument rebasing Kumar Kartikeya Dwivedi
2026-08-21 23:35 ` [PATCH bpf-next v1 06/14] bpf, s390: Convert struct_ops arena arguments Kumar Kartikeya Dwivedi
2026-08-22  0:46   ` bot+bpf-ci
2026-08-21 23:35 ` [PATCH bpf-next v1 07/14] bpf, loongarch: Fix stack arguments for indirect trampolines Kumar Kartikeya Dwivedi
2026-08-22  0:46   ` bot+bpf-ci
2026-08-21 23:35 ` [PATCH bpf-next v1 08/14] bpf, loongarch: JIT arena kfunc argument rebasing Kumar Kartikeya Dwivedi
2026-08-21 23:46   ` sashiko-bot
2026-08-21 23:35 ` [PATCH bpf-next v1 09/14] bpf, loongarch: Convert struct_ops arena arguments in trampolines Kumar Kartikeya Dwivedi
2026-08-21 23:51   ` sashiko-bot
2026-08-21 23:35 ` [PATCH bpf-next v1 10/14] bpf, powerpc: JIT arena kfunc argument rebasing Kumar Kartikeya Dwivedi
2026-08-22  0:46   ` bot+bpf-ci
2026-08-21 23:35 ` [PATCH bpf-next v1 11/14] bpf: Replace arena kfunc argument flags with suffixes Kumar Kartikeya Dwivedi
2026-08-21 23:58   ` sashiko-bot
2026-08-22  0:46   ` bot+bpf-ci
2026-08-24 22:15   ` Eduard Zingerman
2026-08-24 22:52     ` Kumar Kartikeya Dwivedi
2026-08-21 23:35 ` [PATCH bpf-next v1 12/14] resolve_btfids: Drop KF_ARENA_ARG flag support Kumar Kartikeya Dwivedi
2026-08-22  0:46   ` bot+bpf-ci
2026-08-24 22:25   ` Eduard Zingerman
2026-08-24 22:53     ` Kumar Kartikeya Dwivedi
2026-08-21 23:35 ` [PATCH bpf-next v1 13/14] selftests/bpf: Exercise arena arguments on every capable JIT Kumar Kartikeya Dwivedi
2026-08-22  0:46   ` bot+bpf-ci
2026-08-21 23:35 ` [PATCH bpf-next v1 14/14] docs/bpf: Document split arena argument JIT capabilities Kumar Kartikeya Dwivedi

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=20260821233516.3426127-1-memxor@gmail.com \
    --to=memxor@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=emil@etsalapatis.com \
    --cc=ihor.solodrai@linux.dev \
    --cc=kernel-team@meta.com \
    --cc=kkd@meta.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox