On Wed, May 28, 2025 at 2:58 AM Alan Maguire <alan.maguire@xxxxxxxxxx> wrote: > > This allows BTF parsing to proceed even if we do not know the > kind. > > Signed-off-by: Alan Maguire <alan.maguire@xxxxxxxxxx> > --- > tools/lib/bpf/btf.c | 35 ++++++++++++++++++++++++++++------- > 1 file changed, 28 insertions(+), 7 deletions(-) > > diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c > index 43d1fce8977c..7a197dbfc689 100644 > --- a/tools/lib/bpf/btf.c > +++ b/tools/lib/bpf/btf.c > @@ -355,7 +355,29 @@ static int btf_parse_kind_layout_sec(struct btf *btf) > return 0; > } > > -static int btf_type_size(const struct btf_type *t) > +/* for unknown kinds, consult kind layout. */ > +static int btf_type_size_unknown(const struct btf *btf, const struct btf_type *t) > +{ > + int size = sizeof(struct btf_type); > + struct btf_kind_layout *k = NULL; > + __u16 vlen = btf_vlen(t); > + __u8 kind = btf_kind(t); > + > + if (btf->kind_layout) > + k = &((struct btf_kind_layout *)btf->kind_layout)[kind]; > + > + if (!k || (void *)k > ((void *)btf->kind_layout + btf->hdr->kind_layout_len)) { > + pr_debug("Unsupported BTF_KIND: %u\n", btf_kind(t)); > + return -EINVAL; I'm missing the point around kind_layout->flags. I was expecting that this helper and others at least would check that flags == 0, but none of it is happening. The patches say that flags is unused and do nothing. Why add flags field at all? > + } > + > + size += k->info_sz; > + size += vlen * k->elem_sz; > + > + return size; > +}