-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support BTF_KIND_TYPE_TAG for btf_type_tag attributes #2100
Commits on Nov 12, 2021
-
Nobody committed
Nov 12, 2021 Configuration menu - View commit details
-
Copy full SHA for 002eb4b - Browse repository at this point
Copy the full SHA 002eb4bView commit details -
bpf: Support BTF_KIND_TYPE_TAG for btf_type_tag attributes
LLVM patches ([1] for clang, [2] and [3] for BPF backend) added support for btf_type_tag attributes. This patch added support for the kernel. The main motivation for btf_type_tag is to bring kernel annotations __user, __rcu etc. to btf. With such information available in btf, bpf verifier can detect mis-usages and reject the program. For example, for __user tagged pointer, developers can then use proper helper like bpf_probe_read_user() etc. to read the data. BTF_KIND_TYPE_TAG may also useful for other tracing facility where instead of to require user to specify kernel/user address type, the kernel can detect it by itself with btf. [1] https://reviews.llvm.org/D111199 [2] https://reviews.llvm.org/D113222 [3] https://reviews.llvm.org/D113496 Acked-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Yonghong Song <yhs@fb.com>
Configuration menu - View commit details
-
Copy full SHA for a2559a1 - Browse repository at this point
Copy the full SHA a2559a1View commit details -
libbpf: Support BTF_KIND_TYPE_TAG
Add libbpf support for BTF_KIND_TYPE_TAG. Acked-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Yonghong Song <yhs@fb.com>
Configuration menu - View commit details
-
Copy full SHA for f2dc7d1 - Browse repository at this point
Copy the full SHA f2dc7d1View commit details -
bpftool: Support BTF_KIND_TYPE_TAG
Add bpftool support for BTF_KIND_TYPE_TAG. Acked-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Yonghong Song <yhs@fb.com>
Configuration menu - View commit details
-
Copy full SHA for b7b1016 - Browse repository at this point
Copy the full SHA b7b1016View commit details -
selftests/bpf: Test libbpf API function btf__add_type_tag()
Add unit tests for btf__add_type_tag(). Acked-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Yonghong Song <yhs@fb.com>
Configuration menu - View commit details
-
Copy full SHA for 3529294 - Browse repository at this point
Copy the full SHA 3529294View commit details -
selftests/bpf: Add BTF_KIND_TYPE_TAG unit tests
Add BTF_KIND_TYPE_TAG unit tests. Acked-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Yonghong Song <yhs@fb.com>
Configuration menu - View commit details
-
Copy full SHA for ce2f0b9 - Browse repository at this point
Copy the full SHA ce2f0b9View commit details -
selftests/bpf: Test BTF_KIND_DECL_TAG for deduplication
Add BTF_KIND_TYPE_TAG duplication unit tests. Signed-off-by: Yonghong Song <yhs@fb.com>
Configuration menu - View commit details
-
Copy full SHA for 665c5ff - Browse repository at this point
Copy the full SHA 665c5ffView commit details -
selftests/bpf: Rename progs/tag.c to progs/btf_decl_tag.c
Rename progs/tag.c to progs/btf_decl_tag.c so we can introduce progs/btf_type_tag.c in the next patch. Also create a subtest for btf_decl_tag in prog_tests/btf_tag.c so we can introduce btf_type_tag subtest in the next patch. I also took opportunity to remove the check whether __has_attribute is defined or not in progs/btf_decl_tag.c since all recent clangs should already support this macro. Acked-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Yonghong Song <yhs@fb.com>
Configuration menu - View commit details
-
Copy full SHA for 9740fae - Browse repository at this point
Copy the full SHA 9740faeView commit details -
selftests/bpf: Add a C test for btf_type_tag
The following is the main btf_type_tag usage in the C test: #define __tag1 __attribute__((btf_type_tag("tag1"))) #define __tag2 __attribute__((btf_type_tag("tag2"))) struct btf_type_tag_test { int __tag1 * __tag1 __tag2 *p; } g; The bpftool raw dump with related types: [4] INT 'int' size=4 bits_offset=0 nr_bits=32 encoding=SIGNED [11] STRUCT 'btf_type_tag_test' size=8 vlen=1 'p' type_id=14 bits_offset=0 [12] TYPE_TAG 'tag1' type_id=16 [13] TYPE_TAG 'tag2' type_id=12 [14] PTR '(anon)' type_id=13 [15] TYPE_TAG 'tag1' type_id=4 [16] PTR '(anon)' type_id=15 [17] VAR 'g' type_id=11, linkage=global With format C dump, we have struct btf_type_tag_test { int __attribute__((btf_type_tag("tag1"))) * __attribute__((btf_type_tag("tag1"))) __attribute__((btf_type_tag("tag2"))) *p; }; The result C code is identical to the original definition except macro's are gone. Signed-off-by: Yonghong Song <yhs@fb.com>
Configuration menu - View commit details
-
Copy full SHA for 41fa67c - Browse repository at this point
Copy the full SHA 41fa67cView commit details -
selftests/bpf: Clarify llvm dependency with btf_tag selftest
btf_tag selftest needs certain llvm versions (>= llvm14). Make it clear in the selftests README.rst file. Acked-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Yonghong Song <yhs@fb.com>
Configuration menu - View commit details
-
Copy full SHA for 0b9f7e7 - Browse repository at this point
Copy the full SHA 0b9f7e7View commit details -
docs/bpf: Update documentation for BTF_KIND_TYPE_TAG support
Add BTF_KIND_TYPE_TAG documentation in btf.rst. Acked-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Yonghong Song <yhs@fb.com>
Configuration menu - View commit details
-
Copy full SHA for 602c269 - Browse repository at this point
Copy the full SHA 602c269View commit details