BPF List
 help / color / mirror / Atom feed
* [PATCH bpf-next v4 0/3] Signed loads from Arena
@ 2025-09-23 11:01 Puranjay Mohan
  2025-09-23 11:01 ` [PATCH bpf-next v4 1/3] bpf, x86: Add support for signed arena loads Puranjay Mohan
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Puranjay Mohan @ 2025-09-23 11:01 UTC (permalink / raw)
  To: bpf
  Cc: Puranjay Mohan, Alexei Starovoitov, Andrii Nakryiko,
	Daniel Borkmann, Martin KaFai Lau, Eduard Zingerman, kkd,
	kernel-team

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-09-23 19:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-23 11:01 [PATCH bpf-next v4 0/3] Signed loads from Arena Puranjay Mohan
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox