Skip to content

BPF support for global data

Daniel Borkmann bpf netdev 7 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v6 Latest posting 2/216 patches 4 repliesIn review
  2. v6 posting 1/27 of 16 patches 1 replyApplied
  3. v516 patches 2 repliesSuperseded
Earlier versions · 4
VersionPostedPatchesRepliesStatus
v416 patches7 repliesSuperseded
v3 posting 2/215 patches3 repliesSuperseded
v3 RFC posting 1/29 patches10 repliesSuperseded
v27 patches37 repliesSuperseded

Changes in v6 from the cover letter

- Removed synchronize_rcu() from map freeze (Jann)
- Rest as-is

Patches in v6 posting 2/2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/16bpf: implement lookup-free direct value access for mapsinclude/linux/bpf.h include/linux/bpf_verifier.h include/uapi/linux/bpf.h +6 more+149 -310 replies
2/16bpf: do not retain flags that are not tied to map lifetimekernel/bpf/syscall.c+13 -10 replies
3/16bpf: add program side {rd, wr}only support for mapsinclude/linux/bpf.h include/uapi/linux/bpf.h kernel/bpf/arraymap.c +6 more+96 -140 replies
4/16bpf: add syscall side map freeze supportinclude/linux/bpf.h include/uapi/linux/bpf.h kernel/bpf/syscall.c+57 -130 replies
5/16bpf: allow . char as part of the object namekernel/bpf/syscall.c+3 -30 replies
6/16bpf: add specification for BTF Var and DataSec kindsDocumentation/bpf/btf.rst include/uapi/linux/btf.h+85 -40 replies
7/16bpf: kernel side support for BTF Var and DataSeckernel/bpf/btf.c+397 -200 replies
8/16bpf: allow for key-less BTF in array mapinclude/linux/btf.h kernel/bpf/arraymap.c kernel/bpf/btf.c +1 more+27 -60 replies
9/16bpf: sync {btf, bpf}.h uapi header from tools infrastructuretools/include/uapi/linux/bpf.h tools/include/uapi/linux/btf.h+46 -60 replies
10/16bpf, libbpf: refactor relocation handlingtools/lib/bpf/libbpf.c+32 -300 replies
11/16bpf, libbpf: support global data/bss/rodata sectionstools/lib/bpf/Makefile tools/lib/bpf/bpf.c tools/lib/bpf/bpf.h +3 more+314 -484 replies
12/16bpf, libbpf: add support for BTF Var and DataSectools/lib/bpf/btf.c tools/lib/bpf/btf.h tools/lib/bpf/libbpf.c +2 more+235 -200 replies
13/16bpf: bpftool support for dumping data/bss/rodata sectionstools/bpf/bpftool/btf_dumper.c tools/bpf/bpftool/map.c+65 -40 replies
14/16bpf, selftest: test {rd, wr}only flags and direct value accesstools/include/linux/filter.h tools/testing/selftests/bpf/test_verifier.c tools/testing/selftests/bpf/verifier/array_access.c +1 more+573 -50 replies
15/16bpf, selftest: test global data/bss/rodata sectionstools/testing/selftests/bpf/bpf_helpers.h tools/testing/selftests/bpf/prog_tests/global_data.c tools/testing/selftests/bpf/progs/test_global_data.c+267 -40 replies
16/16bpf, selftest: add test cases for BTF Var and DataSectools/testing/selftests/bpf/test_btf.c+663 -20 replies

Reviews trailers per patch

15 of 16 patches have a Reviewed-by or Acked-by.

PatchMartin KaFai LauAndrii Nakryiko
1/16
2/16A-b
3/16A-b
4/16A-b
5/16A-b A-b
6/16A-b
7/16A-b
8/16A-b
9/16A-b
10/16A-b A-b
11/16A-b A-b
12/16A-b
13/16A-b
14/16A-b
15/16A-b A-b
16/16A-b

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

Read the v6 thread

Cover letter [PATCH bpf-next v6 00/16] BPF support for global data

This series is a major rework of previously submitted libbpf patches [0] in order to add global data support for BPF. The kernel has been extended to add proper infrastructure that allows for full .bss/.data/.rodata sections on BPF loader side based upon feedback from LPC discussions [1]. Latter support is then also added into libbpf in this series which allows for more natural C-like programming of BPF programs. For more information on loader, please refer to 'bpf, libbpf: support global data/bss/ rodata sections' patch in this series.

Thanks a lot!

v5 -> v6:
- Removed synchronize_rcu() from map freeze (Jann)
- Rest as-is
v4 -> v5:
- Removed index selection again for ldimm64 (Alexei)
- Adapted related test cases and added new ones to test

     rejection of off != 0

v3 -> v4:
- Various fixes in BTF verification e.g. to disallow
Var and DataSec to be an intermediate type during resolve (Martin)
- More BTF test cases added
- Few cleanups in key-less BTF commit (Martin)
- Bump libbpf minor version from 2 to 3
- Renamed and simplified read-only locking
- Various minor improvements all over the place
v2 -> v3:
- Implement BTF support in kernel, libbpf, bpftool, add tests
- Fix idx + off conversion (Andrii)
- Document lower / higher bits for direct value access (Andrii)
- Add tests with small value size (Andrii)
- Add index selection into ldimm64 (Andrii)
- Fix missing fdput() (Jann)
- Reject invalid flags in BPF_F_*_PROG (Jakub)
- Complete rework of libbpf support, includes:
- Add objname to map name (Stanislav)
- Make .rodata map full read-only after setup (Andrii)
- Merge relocation handling into single one (Andrii)
- Store global maps into obj->maps array (Andrii, Alexei)
- Debug message when skipping section (Andrii)
- Reject non-static global data till we have
semantics for sharing them (Yonghong, Andrii, Alexei)
- More test cases and completely reworked prog test (Alexei)
- Fixes, cleanups, etc all over the set
- Not yet addressed:
- Make BTF mandatory for these maps (Alexei)
-> Waiting till BTF support for these lands first
v1 -> v2:
- Instead of 32-bit static data, implement full global data support (Alexei)

[0] https://patchwork.ozlabs.org/cover/1040290/
[1] http://vger.kernel.org/lpc-bpf2018.html#session-3

Daniel Borkmann (14):
bpf: implement lookup-free direct value access for maps
bpf: do not retain flags that are not tied to map lifetime
bpf: add program side {rd, wr}only support for maps
bpf: add syscall side map freeze support
bpf: allow . char as part of the object name
bpf: add specification for BTF Var and DataSec kinds
bpf: kernel side support for BTF Var and DataSec
bpf: allow for key-less BTF in array map
bpf: sync {btf, bpf}.h uapi header from tools infrastructure bpf, libbpf: support global data/bss/rodata sections bpf, libbpf: add support for BTF Var and DataSec
bpf: bpftool support for dumping data/bss/rodata sections bpf, selftest: test {rd, wr}only flags and direct value access bpf, selftest: add test cases for BTF Var and DataSec

Joe Stringer (2):
bpf, libbpf: refactor relocation handling bpf, selftest: test global data/bss/rodata sections

 Documentation/bpf/btf.rst                     |  57 ++
 include/linux/bpf.h                           |  38 +-
 include/linux/bpf_verifier.h                  |   4 +
 include/linux/btf.h                           |   1 +
 include/uapi/linux/bpf.h                      |  20 +-
 include/uapi/linux/btf.h                      |  32 +-
 kernel/bpf/arraymap.c                         |  53 +-
 kernel/bpf/btf.c                              | 419 ++++++++++-
 kernel/bpf/core.c                             |   3 +-
 kernel/bpf/disasm.c                           |   5 +-
 kernel/bpf/hashtab.c                          |   6 +-
 kernel/bpf/local_storage.c                    |   6 +-
 kernel/bpf/lpm_trie.c                         |   3 +-
 kernel/bpf/queue_stack_maps.c                 |   6 +-
 kernel/bpf/syscall.c                          | 131 +++-
 kernel/bpf/verifier.c                         | 132 +++-
 tools/bpf/bpftool/btf_dumper.c                |  59 ++
 tools/bpf/bpftool/map.c                       |  10 +-
 tools/bpf/bpftool/xlated_dumper.c             |   3 +
 tools/include/linux/filter.h                  |  21 +-
 tools/include/uapi/linux/bpf.h                |  20 +-
 tools/include/uapi/linux/btf.h                |  32 +-
 tools/lib/bpf/Makefile                        |   2 +-
 tools/lib/bpf/bpf.c                           |  10 +
 tools/lib/bpf/bpf.h                           |   1 +
 tools/lib/bpf/btf.c                           |  97 ++-
 tools/lib/bpf/btf.h                           |   3 +
 tools/lib/bpf/libbpf.c                        | 546 +++++++++++---
 tools/lib/bpf/libbpf.h                        |   5 +
 tools/lib/bpf/libbpf.map                      |   7 +
 tools/testing/selftests/bpf/bpf_helpers.h     |   8 +-
 .../selftests/bpf/prog_tests/global_data.c    | 157 +++++
 .../selftests/bpf/progs/test_global_data.c    | 106 +++
 tools/testing/selftests/bpf/test_btf.c        | 665 +++++++++++++++++-
 tools/testing/selftests/bpf/test_verifier.c   |  51 +-
 .../selftests/bpf/verifier/array_access.c     | 159 +++++
 .../bpf/verifier/direct_value_access.c        | 347 +++++++++
 37 files changed, 3018 insertions(+), 207 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/global_data.c
 create mode 100644 tools/testing/selftests/bpf/progs/test_global_data.c
 create mode 100644 tools/testing/selftests/bpf/verifier/direct_value_access.c
Signature · 1 line
2.17.1