On Wed, Jun 29, 2022 at 9:56 AM Arnaldo Carvalho de Melo <acme@xxxxxxxxxx> wrote: > > Em Wed, Jun 29, 2022 at 01:30:10PM -0300, Arnaldo Carvalho de Melo escreveu: > > ⬢[acme@toolbox pahole]$ pdwtags -F btf vmlinux-v5.18-rc7+ | grep -B10 -A5 BPF_F_CTXLEN_MASK > > BTF: idx: 4173, Unknown kind 19 > > BTF: idx: 4975, Unknown kind 19 > > BTF: idx: 6673, Unknown kind 19 > > BTF: idx: 27413, Unknown kind 19 > > BTF: idx: 30626, Unknown kind 19 > > BTF: idx: 30829, Unknown kind 19 > > BTF: idx: 38040, Unknown kind 19 > > BTF: idx: 56969, Unknown kind 19 > > BTF: idx: 83004, Unknown kind 19 > > ⬢[acme@toolbox pahole]$ > > > > Ok, I need to update pahole's BTF loader to support: > > > > lib/bpf/src/btf.h:#define BTF_KIND_ENUM64 19 /* Enum for up-to 64bit values */ > > > > > > Working on it now. > > ⬢[acme@toolbox pahole]$ pdwtags -F btf vmlinux-v5.18-rc7+ | grep -B5 -A5 BPF_F_CTXLEN_MASK > > /* 27413 */ > enum { > BPF_F_INDEX_MASK = 4294967295, > BPF_F_CURRENT_CPU = 4294967295, > BPF_F_CTXLEN_MASK = 4503595332403200, > } __attribute__((__packed__)); /* size: 8 */ > > /* 27414 */ > enum { > BPF_F_GET_BRANCH_RECORDS_SIZE = 1, > ⬢[acme@toolbox pahole]$ > > Quick patch here, please Ack, if possible: > two minor nits, but looks good overall: Acked-by: Andrii Nakryiko <andrii@xxxxxxxxxx> > diff --git a/btf_loader.c b/btf_loader.c > index b5d444643adf30b1..e57ecce2cde26e4e 100644 > --- a/btf_loader.c > +++ b/btf_loader.c > @@ -312,6 +312,49 @@ out_free: > return -ENOMEM; > } > > +static struct enumerator *enumerator__new64(const char *name, uint64_t value) > +{ > + struct enumerator *en = tag__alloc(sizeof(*en)); > + > + if (en != NULL) { > + en->name = name; > + en->value = value; // Value is already 64-bit, as this is used with DWARF as well > + en->tag.tag = DW_TAG_enumerator; > + } > + > + return en; > +} > + > +static int create_new_enumeration64(struct cu *cu, const struct btf_type *tp, uint32_t id) > +{ > + struct btf_enum64 *ep = btf_enum64(tp); > + uint16_t i, vlen = btf_vlen(tp); > + struct type *enumeration = type__new(DW_TAG_enumeration_type, > + cu__btf_str(cu, tp->name_off), > + tp->size ? tp->size * 8 : (sizeof(int) * 8)); tp->size should always be valid, so this fall back to sizeof(int) isn't necessary > + > + if (enumeration == NULL) > + return -ENOMEM; > + > + for (i = 0; i < vlen; i++) { > + const char *name = cu__btf_str(cu, ep[i].name_off); > + uint64_t value = ((uint64_t)ep[i].val_hi32) << 32 | ep[i].val_lo32; use btf_enum64_value() defined in libbpf's btf.h header > + struct enumerator *enumerator = enumerator__new64(name, value); > + > + if (enumerator == NULL) > + goto out_free; > + > + enumeration__add(enumeration, enumerator); > + } > + > + cu__add_tag_with_id(cu, &enumeration->namespace.tag, id); > + > + return 0; > +out_free: > + enumeration__delete(enumeration); > + return -ENOMEM; > +} > + > static int create_new_subroutine_type(struct cu *cu, const struct btf_type *tp, uint32_t id) > { > struct ftype *proto = tag__alloc(sizeof(*proto)); > @@ -419,6 +462,9 @@ static int btf__load_types(struct btf *btf, struct cu *cu) > case BTF_KIND_ENUM: > err = create_new_enumeration(cu, type_ptr, type_index); > break; > + case BTF_KIND_ENUM64: > + err = create_new_enumeration64(cu, type_ptr, type_index); > + break; > case BTF_KIND_FWD: > err = create_new_forward_decl(cu, type_ptr, type_index); > break;