OSDN Git Service

bpf: Support for new btf kind BTF_KIND_TAG
authorYonghong Song <yhs@fb.com>
Tue, 14 Sep 2021 22:30:15 +0000 (15:30 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 15 Sep 2021 01:45:52 +0000 (18:45 -0700)
commitb5ea834dde6b6e7f75e51d5f66dac8cd7c97b5ef
treeb82684f92084ac8a9c1f81e860e478db4f558283
parent41ced4cd88020c9d4b71ff7c50d020f081efa4a0
bpf: Support for new btf kind BTF_KIND_TAG

LLVM14 added support for a new C attribute ([1])
  __attribute__((btf_tag("arbitrary_str")))
This attribute will be emitted to dwarf ([2]) and pahole
will convert it to BTF. Or for bpf target, this
attribute will be emitted to BTF directly ([3], [4]).
The attribute is intended to provide additional
information for
  - struct/union type or struct/union member
  - static/global variables
  - static/global function or function parameter.

For linux kernel, the btf_tag can be applied
in various places to specify user pointer,
function pre- or post- condition, function
allow/deny in certain context, etc. Such information
will be encoded in vmlinux BTF and can be used
by verifier.

The btf_tag can also be applied to bpf programs
to help global verifiable functions, e.g.,
specifying preconditions, etc.

This patch added basic parsing and checking support
in kernel for new BTF_KIND_TAG kind.

 [1] https://reviews.llvm.org/D106614
 [2] https://reviews.llvm.org/D106621
 [3] https://reviews.llvm.org/D106622
 [4] https://reviews.llvm.org/D109560

Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20210914223015.245546-1-yhs@fb.com
include/uapi/linux/btf.h
kernel/bpf/btf.c
tools/include/uapi/linux/btf.h