Skip to content

bpf, arm64: Support stack arguments

Puranjay Mohan bpf linux-arm-kernel 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest3 patches 6 repliesIn review
  2. v13 patches 3 repliesSuperseded

Changes in v2 from the cover letter

- Don't add ctx->stack_arg_size to off_adj when private stack is used. ([email protected])

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3bpf, arm64: Map BPF_REG_0 to x8 instead of x7arch/arm64/net/bpf_jit_comp.c arch/arm64/net/bpf_timed_may_goto.S tools/testing/selftests/bpf/progs/verifier_jit_inline.c +2 more+15 -151 reply
2/3bpf, arm64: Add JIT support for stack argumentsarch/arm64/net/bpf_jit_comp.c+86 -13 replies
3/3selftests/bpf: Enable stack argument tests for arm64tools/testing/selftests/bpf/progs/btf__stack_arg_precision.c tools/testing/selftests/bpf/progs/stack_arg.c tools/testing/selftests/bpf/progs/stack_arg_kfunc.c +2 more+10 -52 replies

Reviews trailers per patch

1 of 3 patches has a Reviewed-by or Acked-by.

PatchWill Deacon
1/3A-b
2/3
3/3

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH bpf-next v2 0/3] bpf, arm64: Support stack arguments

Hi Yonghong,

Please take these three patches into your next version of the stack arguments support. I have fixed the arm64 support patch so it works correctly with private stack.

Changelog:
v1: https://lore.kernel.org/all/[email protected]/
Changes in v2:
- Don't add ctx->stack_arg_size to off_adj when private stack is used. ([email protected])

This set add support of stack arguments to the arm64 JIT based on the preparatory work and x86 support in [1]. Arm64 allows passing 8 arguments in registers x0-x7 and remaining ones on stack. Currently, BPF supports passing 5 arguments all of which map to x0-x4.

BPF passes arguments in R1-R5 which map to x0-x4 on arm64, BPF reg R0 is mapped to arm64 reg x7, but as arm64 needs this register to pass arguments now, the first patch changes the mapping of BPF reg R0 to x8 which allows passing arguments in x0-x7 (8 arguments). 9+ arguments are passed on the stack.

All selftest pass:

./test_progs -t stack_arg,stack_arg_fail,stack_arg_kfunc,verifier_stack_arg

  #431/1   stack_arg/global_many_args:OK
  #431/2   stack_arg/async_cb_many_args:OK
  #431/3   stack_arg/bpf2bpf:OK
  #431/4   stack_arg/kfunc:OK
  #431     stack_arg:OK
  #432/1   stack_arg_fail/test_stack_arg_big:OK
  #432/2   stack_arg_fail/r11 in ALU instruction:OK
  #432/3   stack_arg_fail/r11 store with non-DW size:OK
  #432/4   stack_arg_fail/r11 store with unaligned offset:OK
  #432/5   stack_arg_fail/r11 store with positive offset:OK
  #432/6   stack_arg_fail/r11 load with negative offset:OK
  #432/7   stack_arg_fail/r11 load with non-DW size:OK
  #432/8   stack_arg_fail/r11 store with zero offset:OK
  #432     stack_arg_fail:OK
  #631/1   verifier_stack_arg/stack_arg: subprog with 6 args:OK
  #631/2   verifier_stack_arg/stack_arg: two subprogs with >5 args:OK
  #631/3   verifier_stack_arg/stack_arg: read from uninitialized stack arg slot:OK
  #631/4   verifier_stack_arg/stack_arg: gap at offset -8, only wrote -16:OK
  #631/5   verifier_stack_arg/stack_arg: pruning with different stack arg types:OK
  #631/6   verifier_stack_arg/stack_arg: release_reference invalidates stack arg slot:OK
  #631/7   verifier_stack_arg/stack_arg: pkt pointer in stack arg slot invalidated after pull_data:OK
  #631/8   verifier_stack_arg/stack_arg: null propagation rejects deref on null branch:OK
  #631/9   verifier_stack_arg/stack_arg: missing store on one branch:OK
  #631/10  verifier_stack_arg/stack_arg: share a store for both branches:OK
  #631/11  verifier_stack_arg/stack_arg: write beyond max outgoing depth:OK
  #631/12  verifier_stack_arg/stack_arg: sequential calls reuse slots:OK
  #631     verifier_stack_arg:OK

Summary: 3/24 PASSED, 0 SKIPPED, 0 FAILED

Puranjay Mohan (3):
bpf, arm64: Map BPF_REG_0 to x8 instead of x7 bpf, arm64: Add JIT support for stack arguments selftests/bpf: Enable stack argument tests for arm64

 arch/arm64/net/bpf_jit_comp.c                 | 91 ++++++++++++++++++-
 arch/arm64/net/bpf_timed_may_goto.S           |  8 +-
 .../bpf/progs/btf__stack_arg_precision.c      |  3 +-
 tools/testing/selftests/bpf/progs/stack_arg.c |  3 +-
 .../selftests/bpf/progs/stack_arg_kfunc.c     |  3 +-
 .../selftests/bpf/progs/stack_arg_precision.c |  3 +-
 .../selftests/bpf/progs/verifier_jit_inline.c |  2 +-
 .../selftests/bpf/progs/verifier_ldsx.c       |  6 +-
 .../bpf/progs/verifier_private_stack.c        | 10 +-
 .../selftests/bpf/progs/verifier_stack_arg.c  |  3 +-
 10 files changed, 111 insertions(+), 21 deletions(-)
Signature · 1 line
2.52.0