Skip to content

bpf, arm64: support for timed may_goto

Puranjay Mohan bpf 3 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. v3 Latest2 patches 0 repliesApplied 2/2
  2. v22 patches 2 repliesSuperseded
  3. v12 patches 2 repliesSuperseded

Changes in v3 from the cover letter

v2: https://lore.kernel.org/all/[email protected]/
- Rebased on bpf-next/master
- Added Acked-by: tags from Xu and Kumar

Patches in v3 All 2 applied

#Subject and filesSizeRepliesApplied
1/2bpf, arm64: Add JIT support for timed may_gotoarch/arm64/net/Makefile arch/arm64/net/bpf_jit_comp.c arch/arm64/net/bpf_timed_may_goto.S+53 -20 repliesApplied
2/2selftests/bpf: Enable timed may_goto tests for arm64tools/testing/selftests/bpf/prog_tests/stream.c tools/testing/selftests/bpf/progs/verifier_bpf_fastcall.c tools/testing/selftests/bpf/progs/verifier_may_goto_1.c+23 -400 repliesApplied

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchKumar Kartikeya DwivediXu Kuohai
1/2A-b A-b
2/2A-b A-b

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

Read the v3 thread

Cover letter [PATCH bpf-next v3 0/2] bpf, arm64: support for timed may_goto

Changes in v2->v3:
v2: https://lore.kernel.org/all/[email protected]/
- Rebased on bpf-next/master
- Added Acked-by: tags from Xu and Kumar

Changes in v1->v2:
v1: https://lore.kernel.org/bpf/[email protected]/
- Added comment in arch_bpf_timed_may_goto() about BPF_REG_FP setup (Xu Kuohai)

This set adds support for the timed may_goto instruction for the arm64. The timed may_goto instruction is implemented by the verifier by reserving 2 8byte slots in the program stack and then calling arch_bpf_timed_may_goto() in a loop with the stack offset of these two slots in BPF_REG_AX. It expects the function to put a timestamp in the first slot and the returned count in BPF_REG_AX is put into the second slot by a store instruction emitted by the verifier.

arch_bpf_timed_may_goto() is special as it receives the parameter in BPF_REG_AX and is expected to return the result in BPF_REG_AX as well. It can't clobber any caller saved registers because verifier doesn't save anything before emitting the call.

So, arch_bpf_timed_may_goto() is implemented in assembly so the exact registers that are stored/restored can be controlled (BPF caller saved registers here) and it also needs to take care of moving arguments and return values to and from BPF_REG_AX <-> arm64 R0.

So, arch_bpf_timed_may_goto() acts as a trampoline to call bpf_check_timed_may_goto() which does the main logic of placing the timestamp and returning the count.

All tests that use may_goto instruction pass after the changing some of them in patch 2

#404 stream_errors:OK
[...]
#406/2 stream_success/stream_cond_break:OK
[...]
#494/23 verifier_bpf_fastcall/may_goto_interaction_x86_64:SKIP #494/24 verifier_bpf_fastcall/may_goto_interaction_arm64:OK [...]

 #539/1   verifier_may_goto_1/may_goto 0:OK
 #539/2   verifier_may_goto_1/batch 2 of may_goto 0:OK
 #539/3   verifier_may_goto_1/may_goto batch with offsets 2/1/0:OK
 #539/4   verifier_may_goto_1/may_goto batch with offsets 2/0:OK
 #539     verifier_may_goto_1:OK
 #540/1   verifier_may_goto_2/C code with may_goto 0:OK
 #540     verifier_may_goto_2:OK

Summary: 7/16 PASSED, 25 SKIPPED, 0 FAILED

Puranjay Mohan (2):
bpf, arm64: Add JIT support for timed may_goto selftests/bpf: Enable timed may_goto tests for arm64

 arch/arm64/net/Makefile                       |  2 +-
 arch/arm64/net/bpf_jit_comp.c                 | 13 +++++-
 arch/arm64/net/bpf_timed_may_goto.S           | 40 +++++++++++++++++++
 .../testing/selftests/bpf/prog_tests/stream.c |  2 +-
 .../bpf/progs/verifier_bpf_fastcall.c         | 27 ++++++++-----
 .../selftests/bpf/progs/verifier_may_goto_1.c | 34 +++-------------
 6 files changed, 76 insertions(+), 42 deletions(-)
 create mode 100644 arch/arm64/net/bpf_timed_may_goto.S
Signature · 1 line
2.47.3