summaryrefslogtreecommitdiff
path: root/tools/lib/bpf/btf.h
diff options
context:
space:
mode:
authorYonghong Song <yhs@fb.com>2022-06-06 23:26:36 -0700
committerAlexei Starovoitov <ast@kernel.org>2022-06-07 10:20:43 -0700
commitf2a625889bb8d153d277f557c929d43874561f10 (patch)
tree99f5cdd3421a3d03753bdb927e66317f7b6f6943 /tools/lib/bpf/btf.h
parentd90ec262b35bb6d30ae621dc15889638ba4c02be (diff)
downloadlinux-f2a625889bb8d153d277f557c929d43874561f10.tar.gz
linux-f2a625889bb8d153d277f557c929d43874561f10.tar.bz2
linux-f2a625889bb8d153d277f557c929d43874561f10.zip
libbpf: Add enum64 sanitization
When old kernel does not support enum64 but user space btf contains non-zero enum kflag or enum64, libbpf needs to do proper sanitization so modified btf can be accepted by the kernel. Sanitization for enum kflag can be achieved by clearing the kflag bit. For enum64, the type is replaced with an union of integer member types and the integer member size must be smaller than enum64 size. If such an integer type cannot be found, a new type is created and used for union members. Acked-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Yonghong Song <yhs@fb.com> Link: https://lore.kernel.org/r/20220607062636.3721375-1-yhs@fb.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'tools/lib/bpf/btf.h')
-rw-r--r--tools/lib/bpf/btf.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/tools/lib/bpf/btf.h b/tools/lib/bpf/btf.h
index dcb3f575a281..83312c34007a 100644
--- a/tools/lib/bpf/btf.h
+++ b/tools/lib/bpf/btf.h
@@ -395,9 +395,10 @@ btf_dump__dump_type_data(struct btf_dump *d, __u32 id,
#ifndef BTF_KIND_FLOAT
#define BTF_KIND_FLOAT 16 /* Floating point */
#endif
-/* The kernel header switched to enums, so these two were never #defined */
+/* The kernel header switched to enums, so the following were never #defined */
#define BTF_KIND_DECL_TAG 17 /* Decl Tag */
#define BTF_KIND_TYPE_TAG 18 /* Type Tag */
+#define BTF_KIND_ENUM64 19 /* Enum for up-to 64bit values */
static inline __u16 btf_kind(const struct btf_type *t)
{