BPF List
 help / color / mirror / Atom feed
From: Yonghong Song <yhs@fb.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: bpf <bpf@vger.kernel.org>, Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Kernel Team <kernel-team@fb.com>
Subject: Re: [PATCH bpf-next v3 00/11] bpf: add support for new btf kind BTF_KIND_TAG
Date: Tue, 14 Sep 2021 22:00:18 -0700	[thread overview]
Message-ID: <16ce08f0-351f-d515-cd6b-fbc0af965bfa@fb.com> (raw)
In-Reply-To: <CAADnVQ+aLj1897R76=TE5GueJVujnZT6G_Ow9mh9waAYfvGdfw@mail.gmail.com>



On 9/14/21 6:55 PM, Alexei Starovoitov wrote:
> On Tue, Sep 14, 2021 at 3:30 PM Yonghong Song <yhs@fb.com> wrote:
>>
>> 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.
>>
>> This new attribute can be used to add attributes
>> to kernel codes, e.g., pre- or post- conditions,
>> allow/deny info, or any other info in which only
>> the kernel is interested. Such attributes will
>> be processed by clang frontend and emitted to
>> dwarf, converting to BTF by pahole. Ultimiately
>> the verifier can use these information for
>> verification purpose.
>>
>> The new attribute can also be used for bpf
>> programs, e.g., tagging with __user attributes
>> for function parameters, specifying global
>> function preconditions, etc. Such information
>> may help verifier to detect user program
>> bugs.
>>
>> After this series, pahole dwarf->btf converter
>> will be enhanced to support new llvm tag
>> for btf_tag attribute. With pahole support,
>> we will then try to add a few real use case,
>> e.g., __user/__rcu tagging, allow/deny list,
>> some kernel function precondition, etc,
>> in the kernel.
>>
>> In the rest of the series, Patches 1-2 had
>> kernel support. Patches 3-4 added
>> libbpf support. Patch 5 added bpftool
>> support. Patches 6-10 added various selftests.
>> Patch 11 added documentation for the new 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
>>
>> Changelog:
>>    v2 -> v3:
>>      - put NR_BTF_KINDS and BTF_KIND_MAX into enum as well
>>      - check component_idx earlier (check_meta stage) in kernel
>>      - add more tests
>>      - fix misc nits
> 
> Applied. Please send an update to selftests/bpf/README.
> Since folks will be puzzled with messages:
> progs/tag.c:23:20: warning: unknown attribute 'btf_tag' ignored
> [-Wunknown-attributes]

Ya, this is not good. I too focused on the latest clang which
has btf_tag support.

> 
> Even with old clang:
> ./test_progs -t tag
> #21 btf_tag:OK
> Summary: 1/0 PASSED, 0 SKIPPED, 0 FAILED
> 
> The test probably should fail with old clang ?

I will follow atomics example, if btf_tag is not supported,
the test will be marked as SKIP. Will also update
selftests/bpf/README for when SKIP message may appear.
Will send the followup patch soon.

  reply	other threads:[~2021-09-15  5:00 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-14 22:30 [PATCH bpf-next v3 00/11] bpf: add support for new btf kind BTF_KIND_TAG Yonghong Song
2021-09-14 22:30 ` [PATCH bpf-next v3 01/11] btf: change BTF_KIND_* macros to enums Yonghong Song
2021-09-15  0:13   ` Andrii Nakryiko
2021-09-14 22:30 ` [PATCH bpf-next v3 02/11] bpf: support for new btf kind BTF_KIND_TAG Yonghong Song
2021-09-15  0:15   ` Andrii Nakryiko
2021-09-14 22:30 ` [PATCH bpf-next v3 03/11] libbpf: rename btf_{hash,equal}_int to btf_{hash,equal}_int_tag Yonghong Song
2021-09-14 22:30 ` [PATCH bpf-next v3 04/11] libbpf: add support for BTF_KIND_TAG Yonghong Song
2021-09-15  0:18   ` Andrii Nakryiko
2021-09-14 22:30 ` [PATCH bpf-next v3 05/11] bpftool: " Yonghong Song
2021-09-14 22:30 ` [PATCH bpf-next v3 06/11] selftests/bpf: test libbpf API function btf__add_tag() Yonghong Song
2021-09-14 22:30 ` [PATCH bpf-next v3 07/11] selftests/bpf: change NAME_NTH/IS_NAME_NTH for BTF_KIND_TAG format Yonghong Song
2021-09-14 22:30 ` [PATCH bpf-next v3 08/11] selftests/bpf: add BTF_KIND_TAG unit tests Yonghong Song
2021-09-15  0:19   ` Andrii Nakryiko
2021-09-14 22:30 ` [PATCH bpf-next v3 09/11] selftests/bpf: test BTF_KIND_TAG for deduplication Yonghong Song
2021-09-15  0:21   ` Andrii Nakryiko
2021-09-14 22:30 ` [PATCH bpf-next v3 10/11] selftests/bpf: add a test with a bpf program with btf_tag attributes Yonghong Song
2021-09-14 22:31 ` [PATCH bpf-next v3 11/11] docs/bpf: add documentation for BTF_KIND_TAG Yonghong Song
2021-09-15  0:22 ` [PATCH bpf-next v3 00/11] bpf: add support for new btf kind BTF_KIND_TAG Andrii Nakryiko
2021-09-15  1:55 ` Alexei Starovoitov
2021-09-15  5:00   ` Yonghong Song [this message]
2021-09-15  2:00 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=16ce08f0-351f-d515-cd6b-fbc0af965bfa@fb.com \
    --to=yhs@fb.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox