bpf: Add 64bit enum value support
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
- v5 Latest17 patches 0 repliesApplied 17/17
- v418 patches 8 repliesSuperseded
- v318 patches 11 repliesSuperseded
Earlier versions · 2
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v2 | 18 patches | 26 replies | Superseded | |
| v1 | 12 patches | 33 replies | Superseded |
Changes in v5 from the cover letter
- skip newly-added enum64 C test if clang version <= 14.
Patches in v5 All 17 applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/17 | bpf: Add btf enum64 supportinclude/ include/ kernel/ +2 more | +185 | 0 replies | Applied |
| 2/17 | libbpf: Permit 64bit relocation valuetools/ tools/ | +29 | 0 replies | Applied |
| 3/17 | libbpf: Fix an error in 64bit relocation value computationtools/ | +1 | 0 replies | Applied |
| 4/17 | libbpf: Refactor btf__add_enum() for future code sharingtools/ | +21 | 0 replies | Applied |
| 5/17 | libbpf: Add enum64 parsing and new enum64 public APItools/ tools/ tools/ | +117 | 0 replies | Applied |
| 6/17 | libbpf: Add enum64 deduplication supporttools/ tools/ | +65 | 0 replies | Applied |
| 7/17 | libbpf: Add enum64 support for btf_dumptools/ tools/ | +108 | 0 replies | Applied |
| 8/17 | libbpf: Add enum64 sanitizationtools/ tools/ tools/ | +56 | 0 replies | Applied |
| 9/17 | libbpf: Add enum64 support for bpf linkingtools/ | +2 | 0 replies | Applied |
| 10/17 | libbpf: Add enum64 relocation supporttools/ tools/ tools/ | +48 | 0 replies | Applied |
| 11/17 | bpftool: Add btf enum64 supporttools/ tools/ tools/ | +84 | 0 replies | Applied |
| 12/17 | selftests/bpf: Fix selftests failuretools/ | +0 | 0 replies | Applied |
| 13/17 | selftests/bpf: Test new enum kflag and enum64 API functionstools/ tools/ | +114 | 0 replies | Applied |
| 14/17 | selftests/bpf: Add BTF_KIND_ENUM64 unit teststools/ tools/ | +37 | 0 replies | Applied |
| 15/17 | selftests/bpf: Test BTF_KIND_ENUM64 for deduplicationtools/ | +95 | 0 replies | Applied |
| 16/17 | selftests/bpf: Add a test for enum64 value relocationstools/ tools/ tools/ +4 more | +218 | 0 replies | Applied |
| 17/17 | docs/bpf: Update documentation for BTF_KIND_ENUM64 supportDocumentation/ | +37 | 0 replies | Applied |
Reviews trailers per patch
All 17 patches have a Reviewed-by or Acked-by.
| Patch | Andrii Nakryiko | Dave Marchevsky |
|---|---|---|
| 1/17 | A-b | |
| 2/17 | A-b | |
| 3/17 | A-b | A-b |
| 4/17 | A-b | |
| 5/17 | A-b | |
| 6/17 | A-b | |
| 7/17 | A-b | |
| 8/17 | A-b | |
| 9/17 | A-b | |
| 10/17 | A-b | |
| 11/17 | A-b | |
| 12/17 | A-b | |
| 13/17 | A-b | |
| 14/17 | A-b | |
| 15/17 | A-b | |
| 16/17 | A-b | |
| 17/17 | A-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH bpf-next v5 00/17] bpf: Add 64bit enum value support
Currently, btf only supports upto 32bit enum value with BTF_KIND_ENUM. But in kernel, some enum has 64bit values, e.g., in uapi bpf.h, we have
enum {
BPF_F_INDEX_MASK = 0xffffffffULL,
BPF_F_CURRENT_CPU = BPF_F_INDEX_MASK,
BPF_F_CTXLEN_MASK = (0xfffffULL << 32), };
With BTF_KIND_ENUM, the value for BPF_F_CTXLEN_MASK will be encoded as 0 which is incorrect.
To solve this problem, BTF_KIND_ENUM64 is proposed in this patch set to support enum 64bit values. Also, since sometimes there is a need to generate C code from btf, e.g., vmlinux.h, btf kflag support is also added for BTF_KIND_ENUM and BTF_KIND_ENUM64 to indicate signedness, helping proper value printout.
Changelog:
v4 -> v5:
- skip newly-added enum64 C test if clang version <= 14.
v3 -> v4:
- rename btf_type_is_any_enum() to btf_is_any_enum() to favor consistency in libbpf.
- fix sign extension issue in btf_dump_get_enum_value().
- fix BPF_CORE_FIELD_SIGNED signedness issue in bpf_core_calc_field_relo().
v2 -> v3:
- Implement separate btf_equal_enum()/btf_equal_enum64() and btf_compat_enum()/btf_compat_enum64().
- Add a new enum64 placeholder type dynamicly for enum64 sanitization.
- For bpftool output and unit selftest, printed out signed/unsigned encoding as well.
- fix some issues with BTF_KIND_ENUM is doc and clarified sign extension rules for enum values.
v1 -> v2:
- Changed kflag default from signed to unsigned
- Fixed sanitization issue
- Broke down libbpf related patches for easier review
- Added more tests
- More code refactorization
- Corresponding llvm patch (to support enum64) is also updated
Yonghong Song (17):
bpf: Add btf enum64 support
libbpf: Permit 64bit relocation value
libbpf: Fix an error in 64bit relocation value computation
libbpf: Refactor btf__add_enum() for future code sharing
libbpf: Add enum64 parsing and new enum64 public API
libbpf: Add enum64 deduplication support
libbpf: Add enum64 support for btf_dump
libbpf: Add enum64 sanitization
libbpf: Add enum64 support for bpf linking
libbpf: Add enum64 relocation support
bpftool: Add btf enum64 support
selftests/bpf: Fix selftests failure selftests/bpf: Test new enum kflag and enum64 API functions selftests/bpf: Add BTF_KIND_ENUM64 unit tests selftests/bpf: Test BTF_KIND_ENUM64 for deduplication selftests/bpf: Add a test for enum64 value relocations docs/bpf: Update documentation for BTF_KIND_ENUM64 support
Documentation/bpf/btf.rst | 43 +++- include/linux/btf.h | 28 +++ include/uapi/linux/btf.h | 17 +- kernel/bpf/btf.c | 142 +++++++++++-- kernel/bpf/verifier.c | 2 +- tools/bpf/bpftool/btf.c | 57 ++++- tools/bpf/bpftool/btf_dumper.c | 29 +++ tools/bpf/bpftool/gen.c | 1 + tools/include/uapi/linux/btf.h | 17 +- tools/lib/bpf/btf.c | 201 ++++++++++++++++-- tools/lib/bpf/btf.h | 32 ++- tools/lib/bpf/btf_dump.c | 137 +++++++++--- tools/lib/bpf/libbpf.c | 63 +++++- tools/lib/bpf/libbpf.map | 2 + tools/lib/bpf/libbpf_internal.h | 2 + tools/lib/bpf/linker.c | 2 + tools/lib/bpf/relo_core.c | 105 +++++---- tools/lib/bpf/relo_core.h | 4 +- tools/testing/selftests/bpf/btf_helpers.c | 25 ++- tools/testing/selftests/bpf/prog_tests/btf.c | 153 +++++++++++-- .../selftests/bpf/prog_tests/btf_write.c | 126 ++++++++--- .../selftests/bpf/prog_tests/core_reloc.c | 58 +++++ .../bpf/progs/btf__core_reloc_enum64val.c | 3 + .../progs/btf__core_reloc_enum64val___diff.c | 3 + .../btf__core_reloc_enum64val___err_missing.c | 3 + ...btf__core_reloc_enum64val___val3_missing.c | 3 + .../selftests/bpf/progs/core_reloc_types.h | 78 +++++++ .../bpf/progs/test_core_reloc_enum64val.c | 70 ++++++ tools/testing/selftests/bpf/test_btf.h | 1 + 29 files changed, 1217 insertions(+), 190 deletions(-) create mode 100644 tools/testing/selftests/bpf/progs/btf__core_reloc_enum64val.c create mode 100644 tools/testing/selftests/bpf/progs/btf__core_reloc_enum64val___diff.c create mode 100644 tools/testing/selftests/bpf/progs/btf__core_reloc_enum64val___err_missing.c create mode 100644 tools/testing/selftests/bpf/progs/btf__core_reloc_enum64val___val3_missing.c create mode 100644 tools/testing/selftests/bpf/progs/test_core_reloc_enum64val.c
Signature · 1 line
2.30.2