Skip to content

Commit

Permalink
headers: Update kernel btf.h header file
Browse files Browse the repository at this point in the history
The libbpf btf.h header file shipped with libbpf version 1.0.0 fails to
build with older versions of the btf.h header file from the kernel because
of a missing struct btf_enum64 definition. This was not added in the
upstream kernel until the 6.0 cycle, so this header update is not yet in
any released version of the kernel. Technically this makes it a bit
premature to import this, but seeing as libbpf already introduced a
dependency on the header file, let's do so anyway to work around the buggy
upstream.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
  • Loading branch information
tohojo committed Aug 31, 2022
1 parent 7fb0af0 commit d8cd007
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions headers/linux/btf.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ struct btf_type {
/* "info" bits arrangement
* bits 0-15: vlen (e.g. # of struct's members)
* bits 16-23: unused
* bits 24-27: kind (e.g. int, ptr, array...etc)
* bits 28-30: unused
* bits 24-28: kind (e.g. int, ptr, array...etc)
* bits 29-30: unused
* bit 31: kind_flag, currently used by
* struct, union and fwd
* struct, union, enum, fwd and enum64
*/
__u32 info;
/* "size" is used by INT, ENUM, STRUCT, UNION and DATASEC.
/* "size" is used by INT, ENUM, STRUCT, UNION, DATASEC and ENUM64.
* "size" tells the size of the type it is describing.
*
* "type" is used by PTR, TYPEDEF, VOLATILE, CONST, RESTRICT,
Expand All @@ -63,7 +63,7 @@ enum {
BTF_KIND_ARRAY = 3, /* Array */
BTF_KIND_STRUCT = 4, /* Struct */
BTF_KIND_UNION = 5, /* Union */
BTF_KIND_ENUM = 6, /* Enumeration */
BTF_KIND_ENUM = 6, /* Enumeration up to 32-bit values */
BTF_KIND_FWD = 7, /* Forward */
BTF_KIND_TYPEDEF = 8, /* Typedef */
BTF_KIND_VOLATILE = 9, /* Volatile */
Expand All @@ -76,6 +76,7 @@ enum {
BTF_KIND_FLOAT = 16, /* Floating point */
BTF_KIND_DECL_TAG = 17, /* Decl Tag */
BTF_KIND_TYPE_TAG = 18, /* Type Tag */
BTF_KIND_ENUM64 = 19, /* Enumeration up to 64-bit values */

NR_BTF_KINDS,
BTF_KIND_MAX = NR_BTF_KINDS - 1,
Expand Down Expand Up @@ -186,4 +187,14 @@ struct btf_decl_tag {
__s32 component_idx;
};

/* BTF_KIND_ENUM64 is followed by multiple "struct btf_enum64".
* The exact number of btf_enum64 is stored in the vlen (of the
* info in "struct btf_type").
*/
struct btf_enum64 {
__u32 name_off;
__u32 val_lo32;
__u32 val_hi32;
};

#endif /* _UAPI__LINUX_BTF_H__ */

0 comments on commit d8cd007

Please sign in to comment.