BPF List
 help / color / mirror / Atom feed
From: Puranjay Mohan <puranjay@kernel.org>
To: bpf@vger.kernel.org
Cc: Puranjay Mohan <puranjay@kernel.org>,
	Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Martin KaFai Lau <martin.lau@kernel.org>,
	Eduard Zingerman <eddyz87@gmail.com>,
	kkd@meta.com, kernel-team@meta.com
Subject: [PATCH bpf-next v4 0/3] Signed loads from Arena
Date: Tue, 23 Sep 2025 11:01:48 +0000	[thread overview]
Message-ID: <20250923110157.18326-1-puranjay@kernel.org> (raw)

Changelog:

v3 -> v4:
v3: https://lore.kernel.org/all/20250915162848.54282-1-puranjay@kernel.org/
- Update bpf_jit_supports_insn() in riscv jit to reject signed arena loads (Eduard)
- Fix coding style related to braces usage in an if statement in x86 jit (Eduard)

v2 -> v3:
v2: https://lore.kernel.org/bpf/20250514175415.2045783-1-memxor@gmail.com/
- Fix encoding for the generated instructions in x86 JIT (Eduard)
  The patch in v2 was generating instructions like:
        42 63 44 20 f8     movslq -0x8(%rax,%r12), %eax
  This doesn't make sense because movslq outputs a 64-bit result, but
  the destination register here is set to eax (32-bit). The fix it to
  set the REX.W bit in the opcode, that means changing
  EMIT2(add_3mod(0x40, ...)) to EMIT2(add_3mod(0x48, ...))
- Add arm64 support
- Add selftests signed laods from arena.

v1 -> v2:
v1: https://lore.kernel.org/bpf/20250509194956.1635207-1-memxor@gmail.com
- Use bpf_jit_supports_insn. (Alexei)

Currently, signed load instructions into arena memory are unsupported.
The compiler is free to generate these, and on GCC-14 we see a
corresponding error when it happens. The hurdle in supporting them is
deciding which unused opcode to use to mark them for the JIT's own
consumption. After much thinking, it appears 0xc0 / BPF_NOSPEC can be
combined with load instructions to identify signed arena loads. Use
this to recognize and JIT them appropriately, and remove the verifier
side limitation on the program if the JIT supports them.

Kumar Kartikeya Dwivedi (1):
  bpf, x86: Add support for signed arena loads

Puranjay Mohan (2):
  bpf, arm64: Add support for signed arena loads
  selftests: bpf: Add tests for signed loads from arena

 arch/arm64/net/bpf_jit_comp.c                 |  25 ++-
 arch/riscv/net/bpf_jit_comp64.c               |   5 +
 arch/s390/net/bpf_jit_comp.c                  |   5 +
 arch/x86/net/bpf_jit_comp.c                   |  40 +++-
 include/linux/filter.h                        |   3 +
 kernel/bpf/verifier.c                         |  11 +-
 .../selftests/bpf/progs/verifier_ldsx.c       | 176 ++++++++++++++++++
 7 files changed, 251 insertions(+), 14 deletions(-)

-- 
2.47.3


             reply	other threads:[~2025-09-23 11:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-23 11:01 Puranjay Mohan [this message]
2025-09-23 11:01 ` [PATCH bpf-next v4 1/3] bpf, x86: Add support for signed arena loads Puranjay Mohan
2025-09-23 11:01 ` [PATCH bpf-next v4 2/3] bpf, arm64: " Puranjay Mohan
2025-09-23 11:01 ` [PATCH bpf-next v4 3/3] selftests: bpf: Add tests for signed loads from arena Puranjay Mohan
2025-09-23 19:10 ` [PATCH bpf-next v4 0/3] Signed loads from Arena patchwork-bot+netdevbpf

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=20250923110157.18326-1-puranjay@kernel.org \
    --to=puranjay@kernel.org \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=kernel-team@meta.com \
    --cc=kkd@meta.com \
    --cc=martin.lau@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