Skip to content

Signed loads from Arena

Puranjay Mohan bpf 2 versions – Applied

Status from this message: This series was applied to bpf/bpf-next.git (master)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest3 patches 0 repliesApplied 3/3
  2. v33 patches 8 repliesSuperseded

Changes in v4 from the cover letter

v3: https://lore.kernel.org/all/[email protected]/
- 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)

Patches in v4 All 3 applied

#Subject and filesSizeRepliesApplied
1/3bpf, x86: Add support for signed arena loadsarch/arm64/net/bpf_jit_comp.c arch/riscv/net/bpf_jit_comp64.c arch/s390/net/bpf_jit_comp.c +3 more+63 -60 repliesApplied
2/3bpf, arm64: Add support for signed arena loadsarch/arm64/net/bpf_jit_comp.c+17 -130 repliesApplied
3/3selftests: bpf: Add tests for signed loads from arenatools/testing/selftests/bpf/progs/verifier_ldsx.c+176 -00 repliesApplied

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v4 yet.

Read the v4 thread

Cover letter [PATCH bpf-next v4 0/3] Signed loads from Arena

Changelog:

v3 -> v4:
v3: https://lore.kernel.org/all/[email protected]/
- 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/[email protected]/
- 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/[email protected]
- 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(-)
Signature · 1 line
2.47.3