@@ -74,7 +74,7 @@ sequentially and type id is assigned to each recognized type starting from id
7474 #define BTF_KIND_ARRAY 3 /* Array */
7575 #define BTF_KIND_STRUCT 4 /* Struct */
7676 #define BTF_KIND_UNION 5 /* Union */
77- #define BTF_KIND_ENUM 6 /* Enumeration */
77+ #define BTF_KIND_ENUM 6 /* Enumeration up to 32-bit values */
7878 #define BTF_KIND_FWD 7 /* Forward */
7979 #define BTF_KIND_TYPEDEF 8 /* Typedef */
8080 #define BTF_KIND_VOLATILE 9 /* Volatile */
@@ -87,6 +87,7 @@ sequentially and type id is assigned to each recognized type starting from id
8787 #define BTF_KIND_FLOAT 16 /* Floating point */
8888 #define BTF_KIND_DECL_TAG 17 /* Decl Tag */
8989 #define BTF_KIND_TYPE_TAG 18 /* Type Tag */
90+ #define BTF_KIND_ENUM64 19 /* Enumeration up to 64-bit values */
9091
9192Note that the type section encodes debug info, not just pure types.
9293``BTF_KIND_FUNC `` is not a type, and it represents a defined subprogram.
@@ -101,10 +102,10 @@ Each type contains the following common data::
101102 * bits 24-28: kind (e.g. int, ptr, array...etc)
102103 * bits 29-30: unused
103104 * bit 31: kind_flag, currently used by
104- * struct, union and fwd
105+ * struct, union, fwd, enum and enum64.
105106 */
106107 __u32 info;
107- /* "size" is used by INT, ENUM, STRUCT and UNION .
108+ /* "size" is used by INT, ENUM, STRUCT, UNION and ENUM64 .
108109 * "size" tells the size of the type it is describing.
109110 *
110111 * "type" is used by PTR, TYPEDEF, VOLATILE, CONST, RESTRICT,
@@ -281,10 +282,10 @@ modes exist:
281282
282283``struct btf_type `` encoding requirement:
283284 * ``name_off ``: 0 or offset to a valid C identifier
284- * ``info.kind_flag ``: 0
285+ * ``info.kind_flag ``: 0 for unsigned, 1 for signed
285286 * ``info.kind ``: BTF_KIND_ENUM
286287 * ``info.vlen ``: number of enum values
287- * ``size ``: 4
288+ * ``size ``: 1/2/4/8
288289
289290``btf_type `` is followed by ``info.vlen `` number of ``struct btf_enum ``.::
290291
@@ -297,6 +298,10 @@ The ``btf_enum`` encoding:
297298 * ``name_off ``: offset to a valid C identifier
298299 * ``val ``: any value
299300
301+ If the original enum value is signed and the size is less than 4,
302+ that value will be sign extended into 4 bytes. If the size is 8,
303+ the value will be truncated into 4 bytes.
304+
3003052.2.7 BTF_KIND_FWD
301306~~~~~~~~~~~~~~~~~~
302307
@@ -493,7 +498,7 @@ the attribute is applied to a ``struct``/``union`` member or
493498a ``func `` argument, and ``btf_decl_tag.component_idx `` should be a
494499valid index (starting from 0) pointing to a member or an argument.
495500
496- 2.2.17 BTF_KIND_TYPE_TAG
501+ 2.2.18 BTF_KIND_TYPE_TAG
497502~~~~~~~~~~~~~~~~~~~~~~~~
498503
499504``struct btf_type `` encoding requirement:
@@ -516,6 +521,32 @@ type_tag, then zero or more const/volatile/restrict/typedef
516521and finally the base type. The base type is one of
517522int, ptr, array, struct, union, enum, func_proto and float types.
518523
524+ 2.2.19 BTF_KIND_ENUM64
525+ ~~~~~~~~~~~~~~~~~~~~~~
526+
527+ ``struct btf_type `` encoding requirement:
528+ * ``name_off ``: 0 or offset to a valid C identifier
529+ * ``info.kind_flag ``: 0 for unsigned, 1 for signed
530+ * ``info.kind ``: BTF_KIND_ENUM64
531+ * ``info.vlen ``: number of enum values
532+ * ``size ``: 1/2/4/8
533+
534+ ``btf_type `` is followed by ``info.vlen `` number of ``struct btf_enum64 ``.::
535+
536+ struct btf_enum64 {
537+ __u32 name_off;
538+ __u32 val_lo32;
539+ __u32 val_hi32;
540+ };
541+
542+ The ``btf_enum64 `` encoding:
543+ * ``name_off ``: offset to a valid C identifier
544+ * ``val_lo32 ``: lower 32-bit value for a 64-bit value
545+ * ``val_hi32 ``: high 32-bit value for a 64-bit value
546+
547+ If the original enum value is signed and the size is less than 8,
548+ that value will be sign extended into 8 bytes.
549+
5195503. BTF Kernel API
520551=================
521552
0 commit comments