From 5d111a29ee42c51da59ed54f97e88c9f79813907 Mon Sep 17 00:00:00 2001 From: Jesper Dangaard Brouer Date: Fri, 2 Sep 2022 13:24:08 +0200 Subject: [PATCH] Update kernel-mirrored UAPI header file btf.h The distro kernel UAPI headers evolve too slow. Thus, maintain a mirror in headers/linux/ in this proj. Libbpf been overly-eager to get features into their releases and depend on kernel commit 6089fb325cf7 ("bpf: Add btf enum64 support"), which have not been released in an official kernel release yet. Thus, this headers/linux/btf.h update comes from bpf-next git. Signed-off-by: Jesper Dangaard Brouer --- headers/linux/btf.h | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/headers/linux/btf.h b/headers/linux/btf.h index b0d8fea..426daf5 100644 --- a/headers/linux/btf.h +++ b/headers/linux/btf.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ /* Copyright (c) 2018 Facebook */ -#ifndef _UAPI__LINUX_BTF_H__ -#define _UAPI__LINUX_BTF_H__ +#ifndef __LINUX_BTF_H__ +#define __LINUX_BTF_H__ #include @@ -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, @@ -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 */ @@ -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, @@ -186,4 +187,14 @@ struct btf_decl_tag { __s32 component_idx; }; -#endif /* _UAPI__LINUX_BTF_H__ */ +/* 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 /* __LINUX_BTF_H__ */