Skip to content

BPF static branches

Anton Protopopov bpf 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest9 patches 22 repliesIn review

Changes in v1 from the cover letter

- converted to v1 based on the feedback (there was none)
- bpftool support was added to dump new instructions
- self-tests were added
- minor fixes & checkpatch warnings

[1] https://lpc.events/event/17/contributions/1608/attachments/1278/2578/bpf-static-keys.pdf
[2] https://lore.kernel.org/bpf/[email protected]/
[3] https://github.com/llvm/llvm-project/pull/75110

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/9bpf: fix potential error returnkernel/bpf/core.c+8 -10 replies
2/9bpf: keep track of and expose xlated insn offsetsinclude/linux/bpf.h include/linux/bpf_verifier.h include/uapi/linux/bpf.h +4 more+67 -50 replies
3/9bpf: expose how xlated insns map to jitted insnsarch/x86/net/bpf_jit_comp.c include/linux/bpf.h include/uapi/linux/bpf.h +4 more+93 -020 replies
4/9selftests/bpf: Add tests for instructions mappingstools/testing/selftests/bpf/prog_tests/bpf_insns_mappings.c tools/testing/selftests/bpf/progs/bpf_insns_mappings.c+311 -00 replies
5/9bpftool: dump new fields of bpf prog infotools/bpf/bpftool/prog.c tools/bpf/bpftool/xlated_dumper.c tools/bpf/bpftool/xlated_dumper.h+34 -00 replies
6/9bpf: add support for an extended JA instructionarch/x86/net/bpf_jit_comp.c include/uapi/linux/bpf.h kernel/bpf/verifier.c +1 more+71 -110 replies
7/9bpf: Add kernel/bpftool asm support for new instructionskernel/bpf/disasm.c+27 -60 replies
8/9bpf: add BPF_STATIC_BRANCH_UPDATE syscallarch/x86/net/bpf_jit_comp.c include/linux/bpf.h include/linux/filter.h +4 more+122 -00 replies
9/9selftests/bpf: Add tests for new ja* instructionstools/testing/selftests/bpf/prog_tests/bpf_static_branches.c+269 -00 replies

Reviews trailers per patch

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

PatchJiri Olsa
1/9A-b
2/9
3/9
4/9
5/9
6/9
7/9
8/9
9/9

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

Read the v1 thread

Cover letter [PATCH v1 bpf-next 0/9] BPF static branches

This series adds support for mapping between xlated and original instructions offsets, mapping between xlated and jitted instructions offsets (x86), support for two new BPF instruction JA[SRC=1] (goto[l]_or_nop) and JA[SRC=3] (nop_or_goto[l]), and a new syscall to configure the jitted values of such instructions.

This a follow up to the previous attempt to add static keys support (see [1], [2]) which implements lower-level functionality than what was proposed before.

The first patch .
The second patch adds xlated -> original mapping.
The third patch adds .

The fourth patch adds support for new instructions. And the fifth patch adds support for new syscall.

The following patches are included:
Patch 1 is a formal bug fix
Patch 2 adds the xlated -> original mapping
Patch 3 adds the xlated -> jitted mapping
Patch 4 adds tests for instructions mappings
Patch 5 adds bpftool support for printing new instructions Patch 6 add support for an extended JA instruction
Patch 7 add support for kernel/bpftool to display new instructions Patch 8 adds a new BPF_STATIC_BRANCH_UPDATE syscall Patch 9 adds tests for the new ja* instructions and the new syscall

Altogether this provides enough functionality to dynamically patch programs and support simple static keys.

rfc -> v1:
- converted to v1 based on the feedback (there was none)
- bpftool support was added to dump new instructions
- self-tests were added
- minor fixes & checkpatch warnings

[1] https://lpc.events/event/17/contributions/1608/attachments/1278/2578/bpf-static-keys.pdf
[2] https://lore.kernel.org/bpf/[email protected]/
[3] https://github.com/llvm/llvm-project/pull/75110

Anton Protopopov (9):
bpf: fix potential error return
bpf: keep track of and expose xlated insn offsets
bpf: expose how xlated insns map to jitted insns selftests/bpf: Add tests for instructions mappings
bpftool: dump new fields of bpf prog info
bpf: add support for an extended JA instruction
bpf: Add kernel/bpftool asm support for new instructions
bpf: add BPF_STATIC_BRANCH_UPDATE syscall selftests/bpf: Add tests for new ja* instructions

 arch/x86/net/bpf_jit_comp.c                   |  73 ++++-
 include/linux/bpf.h                           |  11 +
 include/linux/bpf_verifier.h                  |   1 -
 include/linux/filter.h                        |   1 +
 include/uapi/linux/bpf.h                      |  26 ++
 kernel/bpf/core.c                             |  67 ++++-
 kernel/bpf/disasm.c                           |  33 ++-
 kernel/bpf/syscall.c                          | 115 ++++++++
 kernel/bpf/verifier.c                         |  58 +++-
 tools/bpf/bpftool/prog.c                      |  14 +
 tools/bpf/bpftool/xlated_dumper.c             |  18 ++
 tools/bpf/bpftool/xlated_dumper.h             |   2 +
 tools/include/uapi/linux/bpf.h                |  26 ++
 .../bpf/prog_tests/bpf_insns_mappings.c       | 156 ++++++++++
 .../bpf/prog_tests/bpf_static_branches.c      | 269 ++++++++++++++++++
 .../selftests/bpf/progs/bpf_insns_mappings.c  | 155 ++++++++++
 16 files changed, 1002 insertions(+), 23 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/bpf_insns_mappings.c
 create mode 100644 tools/testing/selftests/bpf/prog_tests/bpf_static_branches.c
 create mode 100644 tools/testing/selftests/bpf/progs/bpf_insns_mappings.c
Signature · 1 line
2.34.1