Lines Matching refs:t
276 const struct btf_type *t; member
336 const char *btf_type_str(const struct btf_type *t) in btf_type_str() argument
338 return btf_kind_str[BTF_INFO_KIND(t->info)]; in btf_type_str()
434 const struct btf_type *t,
447 const struct btf_type *t);
448 void (*show)(const struct btf *btf, const struct btf_type *t,
457 const struct btf_type *t, u32 type_id);
460 const struct btf_type *t);
462 static bool btf_type_is_modifier(const struct btf_type *t) in btf_type_is_modifier() argument
474 switch (BTF_INFO_KIND(t->info)) { in btf_type_is_modifier()
486 bool btf_type_is_void(const struct btf_type *t) in btf_type_is_void() argument
488 return t == &btf_void; in btf_type_is_void()
491 static bool btf_type_is_fwd(const struct btf_type *t) in btf_type_is_fwd() argument
493 return BTF_INFO_KIND(t->info) == BTF_KIND_FWD; in btf_type_is_fwd()
496 static bool btf_type_is_datasec(const struct btf_type *t) in btf_type_is_datasec() argument
498 return BTF_INFO_KIND(t->info) == BTF_KIND_DATASEC; in btf_type_is_datasec()
501 static bool btf_type_is_decl_tag(const struct btf_type *t) in btf_type_is_decl_tag() argument
503 return BTF_INFO_KIND(t->info) == BTF_KIND_DECL_TAG; in btf_type_is_decl_tag()
506 static bool btf_type_nosize(const struct btf_type *t) in btf_type_nosize() argument
508 return btf_type_is_void(t) || btf_type_is_fwd(t) || in btf_type_nosize()
509 btf_type_is_func(t) || btf_type_is_func_proto(t) || in btf_type_nosize()
510 btf_type_is_decl_tag(t); in btf_type_nosize()
513 static bool btf_type_nosize_or_null(const struct btf_type *t) in btf_type_nosize_or_null() argument
515 return !t || btf_type_nosize(t); in btf_type_nosize_or_null()
518 static bool btf_type_is_decl_tag_target(const struct btf_type *t) in btf_type_is_decl_tag_target() argument
520 return btf_type_is_func(t) || btf_type_is_struct(t) || in btf_type_is_decl_tag_target()
521 btf_type_is_var(t) || btf_type_is_typedef(t); in btf_type_is_decl_tag_target()
538 const struct btf_type *t; in btf_find_by_name_kind() local
544 t = btf_type_by_id(btf, i); in btf_find_by_name_kind()
545 if (BTF_INFO_KIND(t->info) != kind) in btf_find_by_name_kind()
548 tname = btf_name_by_offset(btf, t->name_off); in btf_find_by_name_kind()
603 const struct btf_type *t = btf_type_by_id(btf, id); in btf_type_skip_modifiers() local
605 while (btf_type_is_modifier(t)) { in btf_type_skip_modifiers()
606 id = t->type; in btf_type_skip_modifiers()
607 t = btf_type_by_id(btf, t->type); in btf_type_skip_modifiers()
613 return t; in btf_type_skip_modifiers()
619 const struct btf_type *t; in btf_type_resolve_ptr() local
621 t = btf_type_skip_modifiers(btf, id, NULL); in btf_type_resolve_ptr()
622 if (!btf_type_is_ptr(t)) in btf_type_resolve_ptr()
625 return btf_type_skip_modifiers(btf, t->type, res_id); in btf_type_resolve_ptr()
643 static bool btf_type_is_resolve_source_only(const struct btf_type *t) in btf_type_is_resolve_source_only() argument
645 return btf_type_is_var(t) || in btf_type_is_resolve_source_only()
646 btf_type_is_decl_tag(t) || in btf_type_is_resolve_source_only()
647 btf_type_is_datasec(t); in btf_type_is_resolve_source_only()
666 static bool btf_type_needs_resolve(const struct btf_type *t) in btf_type_needs_resolve() argument
668 return btf_type_is_modifier(t) || in btf_type_needs_resolve()
669 btf_type_is_ptr(t) || in btf_type_needs_resolve()
670 btf_type_is_struct(t) || in btf_type_needs_resolve()
671 btf_type_is_array(t) || in btf_type_needs_resolve()
672 btf_type_is_var(t) || in btf_type_needs_resolve()
673 btf_type_is_func(t) || in btf_type_needs_resolve()
674 btf_type_is_decl_tag(t) || in btf_type_needs_resolve()
675 btf_type_is_datasec(t); in btf_type_needs_resolve()
679 static bool btf_type_has_size(const struct btf_type *t) in btf_type_has_size() argument
681 switch (BTF_INFO_KIND(t->info)) { in btf_type_has_size()
709 static u32 btf_type_int(const struct btf_type *t) in btf_type_int() argument
711 return *(u32 *)(t + 1); in btf_type_int()
714 static const struct btf_array *btf_type_array(const struct btf_type *t) in btf_type_array() argument
716 return (const struct btf_array *)(t + 1); in btf_type_array()
719 static const struct btf_enum *btf_type_enum(const struct btf_type *t) in btf_type_enum() argument
721 return (const struct btf_enum *)(t + 1); in btf_type_enum()
724 static const struct btf_var *btf_type_var(const struct btf_type *t) in btf_type_var() argument
726 return (const struct btf_var *)(t + 1); in btf_type_var()
729 static const struct btf_decl_tag *btf_type_decl_tag(const struct btf_type *t) in btf_type_decl_tag() argument
731 return (const struct btf_decl_tag *)(t + 1); in btf_type_decl_tag()
734 static const struct btf_enum64 *btf_type_enum64(const struct btf_type *t) in btf_type_enum64() argument
736 return (const struct btf_enum64 *)(t + 1); in btf_type_enum64()
739 static const struct btf_kind_operations *btf_type_ops(const struct btf_type *t) in btf_type_ops() argument
741 return kind_ops[BTF_INFO_KIND(t->info)]; in btf_type_ops()
841 static bool btf_type_int_is_regular(const struct btf_type *t) in btf_type_int_is_regular() argument
846 int_data = btf_type_int(t); in btf_type_int_is_regular()
868 const struct btf_type *t; in btf_member_is_reg_int() local
873 t = btf_type_id_size(btf, &id, NULL); in btf_member_is_reg_int()
874 if (!t || !btf_type_is_int(t)) in btf_member_is_reg_int()
877 int_data = btf_type_int(t); in btf_member_is_reg_int()
905 const struct btf_type *t = btf_type_by_id(btf, id); in btf_type_skip_qualifiers() local
907 while (btf_type_is_modifier(t) && in btf_type_skip_qualifiers()
908 BTF_INFO_KIND(t->info) != BTF_KIND_TYPEDEF) { in btf_type_skip_qualifiers()
909 t = btf_type_by_id(btf, t->type); in btf_type_skip_qualifiers()
912 return t; in btf_type_skip_qualifiers()
935 const struct btf_type *t; in btf_show_name() local
967 t = btf_type_by_id(show->btf, id); in btf_show_name()
968 if (!t) in btf_show_name()
995 switch (BTF_INFO_KIND(t->info)) { in btf_show_name()
999 t->name_off); in btf_show_name()
1001 id = t->type; in btf_show_name()
1006 if (!t) in btf_show_name()
1008 array = btf_type_array(t); in btf_show_name()
1017 id = t->type; in btf_show_name()
1025 t = btf_type_skip_qualifiers(show->btf, id); in btf_show_name()
1032 name = btf_name_by_offset(show->btf, t->name_off); in btf_show_name()
1034 switch (BTF_INFO_KIND(t->info)) { in btf_show_name()
1037 prefix = BTF_INFO_KIND(t->info) == BTF_KIND_STRUCT ? in btf_show_name()
1212 const struct btf_type *t, in btf_show_obj_safe() argument
1222 rt = btf_resolve_size(show->btf, t, &size); in btf_show_obj_safe()
1288 const struct btf_type *t, in btf_show_start_type() argument
1291 show->state.type = t; in btf_show_start_type()
1295 return btf_show_obj_safe(show, t, data); in btf_show_start_type()
1306 const struct btf_type *t, in btf_show_start_aggr_type() argument
1309 void *safe_data = btf_show_start_type(show, t, type_id, data); in btf_show_start_aggr_type()
1354 const struct btf_type *t, in btf_show_start_array_type() argument
1361 return btf_show_start_aggr_type(show, t, type_id, data); in btf_show_start_array_type()
1372 const struct btf_type *t, in btf_show_start_struct_type() argument
1376 return btf_show_start_aggr_type(show, t, type_id, data); in btf_show_start_struct_type()
1409 const struct btf_type *t, in __btf_verifier_log_type() argument
1435 btf_type_str(t), in __btf_verifier_log_type()
1436 __btf_name_by_offset(btf, t->name_off), in __btf_verifier_log_type()
1440 btf_type_ops(t)->log_details(env, t); in __btf_verifier_log_type()
1452 #define btf_verifier_log_type(env, t, ...) \ argument
1453 __btf_verifier_log_type((env), (t), true, __VA_ARGS__)
1454 #define btf_verifier_log_basic(env, t, ...) \ argument
1455 __btf_verifier_log_type((env), (t), false, __VA_ARGS__)
1562 static int btf_add_type(struct btf_verifier_env *env, struct btf_type *t) in btf_add_type() argument
1602 btf->types[btf->nr_types++] = t; in btf_add_type()
1801 const struct btf_type *t, u32 type_id) in env_stack_push() argument
1816 v->t = t; in env_stack_push()
1821 if (btf_type_is_ptr(t)) in env_stack_push()
1823 else if (btf_type_is_struct(t) || btf_type_is_array(t)) in env_stack_push()
2063 btf_verifier_log_basic(env, v->t, "Unsupported resolve"); in btf_df_resolve()
2067 static void btf_df_show(const struct btf *btf, const struct btf_type *t, in btf_df_show() argument
2071 btf_show(show, "<unsupported kind:%u>", BTF_INFO_KIND(t->info)); in btf_df_show()
2169 const struct btf_type *t, in btf_int_check_meta() argument
2176 btf_verifier_log_basic(env, t, in btf_int_check_meta()
2182 if (btf_type_vlen(t)) { in btf_int_check_meta()
2183 btf_verifier_log_type(env, t, "vlen != 0"); in btf_int_check_meta()
2187 if (btf_type_kflag(t)) { in btf_int_check_meta()
2188 btf_verifier_log_type(env, t, "Invalid btf_info kind_flag"); in btf_int_check_meta()
2192 int_data = btf_type_int(t); in btf_int_check_meta()
2194 btf_verifier_log_basic(env, t, "Invalid int_data:%x", in btf_int_check_meta()
2202 btf_verifier_log_type(env, t, "nr_bits exceeds %zu", in btf_int_check_meta()
2207 if (BITS_ROUNDUP_BYTES(nr_bits) > t->size) { in btf_int_check_meta()
2208 btf_verifier_log_type(env, t, "nr_bits exceeds type_size"); in btf_int_check_meta()
2223 btf_verifier_log_type(env, t, "Unsupported encoding"); in btf_int_check_meta()
2227 btf_verifier_log_type(env, t, NULL); in btf_int_check_meta()
2233 const struct btf_type *t) in btf_int_log() argument
2235 int int_data = btf_type_int(t); in btf_int_log()
2239 t->size, BTF_INT_OFFSET(int_data), in btf_int_log()
2336 const struct btf_type *t, in btf_int_bits_show() argument
2340 u32 int_data = btf_type_int(t); in btf_int_bits_show()
2354 static void btf_int_show(const struct btf *btf, const struct btf_type *t, in btf_int_show() argument
2358 u32 int_data = btf_type_int(t); in btf_int_show()
2364 safe_data = btf_show_start_type(show, t, type_id, data); in btf_int_show()
2370 btf_int_bits_show(btf, t, safe_data, bits_offset, show); in btf_int_show()
2417 btf_int_bits_show(btf, t, safe_data, bits_offset, show); in btf_int_show()
2510 const struct btf_type *t, in btf_ref_type_check_meta() argument
2515 if (btf_type_vlen(t)) { in btf_ref_type_check_meta()
2516 btf_verifier_log_type(env, t, "vlen != 0"); in btf_ref_type_check_meta()
2520 if (btf_type_kflag(t)) { in btf_ref_type_check_meta()
2521 btf_verifier_log_type(env, t, "Invalid btf_info kind_flag"); in btf_ref_type_check_meta()
2525 if (!BTF_TYPE_ID_VALID(t->type)) { in btf_ref_type_check_meta()
2526 btf_verifier_log_type(env, t, "Invalid type_id"); in btf_ref_type_check_meta()
2533 if (BTF_INFO_KIND(t->info) == BTF_KIND_TYPEDEF) { in btf_ref_type_check_meta()
2534 if (!t->name_off || in btf_ref_type_check_meta()
2535 !btf_name_valid_identifier(env->btf, t->name_off)) { in btf_ref_type_check_meta()
2536 btf_verifier_log_type(env, t, "Invalid name"); in btf_ref_type_check_meta()
2539 } else if (BTF_INFO_KIND(t->info) == BTF_KIND_TYPE_TAG) { in btf_ref_type_check_meta()
2540 value = btf_name_by_offset(env->btf, t->name_off); in btf_ref_type_check_meta()
2542 btf_verifier_log_type(env, t, "Invalid name"); in btf_ref_type_check_meta()
2546 if (t->name_off) { in btf_ref_type_check_meta()
2547 btf_verifier_log_type(env, t, "Invalid name"); in btf_ref_type_check_meta()
2552 btf_verifier_log_type(env, t, NULL); in btf_ref_type_check_meta()
2560 const struct btf_type *t = v->t; in btf_modifier_resolve() local
2562 u32 next_type_id = t->type; in btf_modifier_resolve()
2567 btf_verifier_log_type(env, v->t, "Invalid type_id"); in btf_modifier_resolve()
2589 btf_verifier_log_type(env, v->t, "Invalid type_id"); in btf_modifier_resolve()
2603 const struct btf_type *t = v->t; in btf_var_resolve() local
2604 u32 next_type_id = t->type; in btf_var_resolve()
2609 btf_verifier_log_type(env, v->t, "Invalid type_id"); in btf_var_resolve()
2636 btf_verifier_log_type(env, v->t, "Invalid type_id"); in btf_var_resolve()
2649 const struct btf_type *t = v->t; in btf_ptr_resolve() local
2650 u32 next_type_id = t->type; in btf_ptr_resolve()
2655 btf_verifier_log_type(env, v->t, "Invalid type_id"); in btf_ptr_resolve()
2692 btf_verifier_log_type(env, v->t, "Invalid type_id"); in btf_ptr_resolve()
2703 const struct btf_type *t, in btf_modifier_show() argument
2708 t = btf_type_id_resolve(btf, &type_id); in btf_modifier_show()
2710 t = btf_type_skip_modifiers(btf, type_id, NULL); in btf_modifier_show()
2712 btf_type_ops(t)->show(btf, t, type_id, data, bits_offset, show); in btf_modifier_show()
2715 static void btf_var_show(const struct btf *btf, const struct btf_type *t, in btf_var_show() argument
2719 t = btf_type_id_resolve(btf, &type_id); in btf_var_show()
2721 btf_type_ops(t)->show(btf, t, type_id, data, bits_offset, show); in btf_var_show()
2724 static void btf_ptr_show(const struct btf *btf, const struct btf_type *t, in btf_ptr_show() argument
2730 safe_data = btf_show_start_type(show, t, type_id, data); in btf_ptr_show()
2743 const struct btf_type *t) in btf_ref_type_log() argument
2745 btf_verifier_log(env, "type_id=%u", t->type); in btf_ref_type_log()
2767 const struct btf_type *t, in btf_fwd_check_meta() argument
2770 if (btf_type_vlen(t)) { in btf_fwd_check_meta()
2771 btf_verifier_log_type(env, t, "vlen != 0"); in btf_fwd_check_meta()
2775 if (t->type) { in btf_fwd_check_meta()
2776 btf_verifier_log_type(env, t, "type != 0"); in btf_fwd_check_meta()
2781 if (!t->name_off || in btf_fwd_check_meta()
2782 !btf_name_valid_identifier(env->btf, t->name_off)) { in btf_fwd_check_meta()
2783 btf_verifier_log_type(env, t, "Invalid name"); in btf_fwd_check_meta()
2787 btf_verifier_log_type(env, t, NULL); in btf_fwd_check_meta()
2793 const struct btf_type *t) in btf_fwd_type_log() argument
2795 btf_verifier_log(env, "%s", btf_type_kflag(t) ? "union" : "struct"); in btf_fwd_type_log()
2837 const struct btf_type *t, in btf_array_check_meta() argument
2840 const struct btf_array *array = btf_type_array(t); in btf_array_check_meta()
2844 btf_verifier_log_basic(env, t, in btf_array_check_meta()
2851 if (t->name_off) { in btf_array_check_meta()
2852 btf_verifier_log_type(env, t, "Invalid name"); in btf_array_check_meta()
2856 if (btf_type_vlen(t)) { in btf_array_check_meta()
2857 btf_verifier_log_type(env, t, "vlen != 0"); in btf_array_check_meta()
2861 if (btf_type_kflag(t)) { in btf_array_check_meta()
2862 btf_verifier_log_type(env, t, "Invalid btf_info kind_flag"); in btf_array_check_meta()
2866 if (t->size) { in btf_array_check_meta()
2867 btf_verifier_log_type(env, t, "size != 0"); in btf_array_check_meta()
2875 btf_verifier_log_type(env, t, "Invalid elem"); in btf_array_check_meta()
2880 btf_verifier_log_type(env, t, "Invalid index"); in btf_array_check_meta()
2884 btf_verifier_log_type(env, t, NULL); in btf_array_check_meta()
2892 const struct btf_array *array = btf_type_array(v->t); in btf_array_resolve()
2903 btf_verifier_log_type(env, v->t, "Invalid index"); in btf_array_resolve()
2914 btf_verifier_log_type(env, v->t, "Invalid index"); in btf_array_resolve()
2923 btf_verifier_log_type(env, v->t, in btf_array_resolve()
2934 btf_verifier_log_type(env, v->t, "Invalid elem"); in btf_array_resolve()
2939 btf_verifier_log_type(env, v->t, "Invalid array of int"); in btf_array_resolve()
2944 btf_verifier_log_type(env, v->t, in btf_array_resolve()
2955 const struct btf_type *t) in btf_array_log() argument
2957 const struct btf_array *array = btf_type_array(t); in btf_array_log()
2963 static void __btf_array_show(const struct btf *btf, const struct btf_type *t, in __btf_array_show() argument
2967 const struct btf_array *array = btf_type_array(t); in __btf_array_show()
2992 if (!btf_show_start_array_type(show, t, type_id, encoding, data)) in __btf_array_show()
3016 static void btf_array_show(const struct btf *btf, const struct btf_type *t, in btf_array_show() argument
3032 __btf_array_show(btf, t, type_id, data, bits_offset, show); in btf_array_show()
3046 __btf_array_show(btf, t, type_id, data, bits_offset, show); in btf_array_show()
3084 const struct btf_type *t, in btf_struct_check_meta() argument
3087 bool is_union = BTF_INFO_KIND(t->info) == BTF_KIND_UNION; in btf_struct_check_meta()
3091 u32 struct_size = t->size; in btf_struct_check_meta()
3095 meta_needed = btf_type_vlen(t) * sizeof(*member); in btf_struct_check_meta()
3097 btf_verifier_log_basic(env, t, in btf_struct_check_meta()
3104 if (t->name_off && in btf_struct_check_meta()
3105 !btf_name_valid_identifier(env->btf, t->name_off)) { in btf_struct_check_meta()
3106 btf_verifier_log_type(env, t, "Invalid name"); in btf_struct_check_meta()
3110 btf_verifier_log_type(env, t, NULL); in btf_struct_check_meta()
3113 for_each_member(i, t, member) { in btf_struct_check_meta()
3115 btf_verifier_log_member(env, t, member, in btf_struct_check_meta()
3124 btf_verifier_log_member(env, t, member, "Invalid name"); in btf_struct_check_meta()
3129 btf_verifier_log_member(env, t, member, in btf_struct_check_meta()
3134 offset = __btf_member_bit_offset(t, member); in btf_struct_check_meta()
3136 btf_verifier_log_member(env, t, member, in btf_struct_check_meta()
3146 btf_verifier_log_member(env, t, member, in btf_struct_check_meta()
3152 btf_verifier_log_member(env, t, member, in btf_struct_check_meta()
3157 btf_verifier_log_member(env, t, member, NULL); in btf_struct_check_meta()
3180 last_member = btf_type_member(v->t) + v->next_member - 1; in btf_struct_resolve()
3188 if (btf_type_kflag(v->t)) in btf_struct_resolve()
3189 err = btf_type_ops(last_member_type)->check_kflag_member(env, v->t, in btf_struct_resolve()
3193 err = btf_type_ops(last_member_type)->check_member(env, v->t, in btf_struct_resolve()
3200 for_each_member_from(i, v->next_member, v->t, member) { in btf_struct_resolve()
3207 btf_verifier_log_member(env, v->t, member, in btf_struct_resolve()
3218 if (btf_type_kflag(v->t)) in btf_struct_resolve()
3219 err = btf_type_ops(member_type)->check_kflag_member(env, v->t, in btf_struct_resolve()
3223 err = btf_type_ops(member_type)->check_member(env, v->t, in btf_struct_resolve()
3236 const struct btf_type *t) in btf_struct_log() argument
3238 btf_verifier_log(env, "size=%u vlen=%u", t->size, btf_type_vlen(t)); in btf_struct_log()
3260 static int btf_find_struct(const struct btf *btf, const struct btf_type *t, in btf_find_struct() argument
3264 if (!__btf_type_is_struct(t)) in btf_find_struct()
3266 if (t->size != sz) in btf_find_struct()
3273 static int btf_find_kptr(const struct btf *btf, const struct btf_type *t, in btf_find_kptr() argument
3280 if (btf_type_is_volatile(t)) in btf_find_kptr()
3281 t = btf_type_by_id(btf, t->type); in btf_find_kptr()
3283 if (!btf_type_is_ptr(t)) in btf_find_kptr()
3285 t = btf_type_by_id(btf, t->type); in btf_find_kptr()
3287 if (!btf_type_is_type_tag(t)) in btf_find_kptr()
3290 if (btf_type_is_type_tag(btf_type_by_id(btf, t->type))) in btf_find_kptr()
3292 if (!strcmp("kptr_untrusted", __btf_name_by_offset(btf, t->name_off))) in btf_find_kptr()
3294 else if (!strcmp("kptr", __btf_name_by_offset(btf, t->name_off))) in btf_find_kptr()
3300 t = btf_type_skip_modifiers(btf, t->type, &res_id); in btf_find_kptr()
3302 if (!__btf_type_is_struct(t)) in btf_find_kptr()
3318 const struct btf_type *t = btf_type_by_id(btf, i); in btf_find_decl_tag_value() local
3321 if (!btf_type_is_decl_tag(t)) in btf_find_decl_tag_value()
3323 if (pt != btf_type_by_id(btf, t->type) || in btf_find_decl_tag_value()
3324 btf_type_decl_tag(t)->component_idx != comp_idx) in btf_find_decl_tag_value()
3326 if (strncmp(__btf_name_by_offset(btf, t->name_off), tag_key, len)) in btf_find_decl_tag_value()
3328 return __btf_name_by_offset(btf, t->name_off) + len; in btf_find_decl_tag_value()
3335 const struct btf_type *t, int comp_idx, u32 off, in btf_find_graph_root() argument
3343 if (!__btf_type_is_struct(t)) in btf_find_graph_root()
3345 if (t->size != sz) in btf_find_graph_root()
3420 const struct btf_type *t, u32 field_mask, in btf_find_struct_field() argument
3428 for_each_member(i, t, member) { in btf_find_struct_field()
3439 off = __btf_member_bit_offset(t, member); in btf_find_struct_field()
3467 ret = btf_find_graph_root(btf, t, member_type, in btf_find_struct_field()
3487 static int btf_find_datasec_var(const struct btf *btf, const struct btf_type *t, in btf_find_datasec_var() argument
3496 for_each_vsi(i, t, vsi) { in btf_find_datasec_var()
3553 static int btf_find_field(const struct btf *btf, const struct btf_type *t, in btf_find_field() argument
3557 if (__btf_type_is_struct(t)) in btf_find_field()
3558 return btf_find_struct_field(btf, t, field_mask, info, info_cnt); in btf_find_field()
3559 else if (btf_type_is_datasec(t)) in btf_find_field()
3560 return btf_find_datasec_var(btf, t, field_mask, info, info_cnt); in btf_find_field()
3568 const struct btf_type *t; in btf_parse_kptr() local
3579 t = btf_type_by_id(btf, info->kptr.type_id); in btf_parse_kptr()
3580 id = bpf_find_btf_id(__btf_name_by_offset(btf, t->name_off), BTF_INFO_KIND(t->info), in btf_parse_kptr()
3661 const struct btf_type *t, *n = NULL; in btf_parse_graph_root() local
3666 t = btf_type_by_id(btf, info->graph_root.value_btf_id); in btf_parse_graph_root()
3671 for_each_member(i, t, member) { in btf_parse_graph_root()
3725 struct btf_record *btf_parse_fields(const struct btf *btf, const struct btf_type *t, in btf_parse_fields() argument
3733 ret = btf_find_field(btf, t, field_mask, info_arr, ARRAY_SIZE(info_arr)); in btf_parse_fields()
3908 static void __btf_struct_show(const struct btf *btf, const struct btf_type *t, in __btf_struct_show() argument
3916 safe_data = btf_show_start_struct_type(show, t, type_id, data); in __btf_struct_show()
3920 for_each_member(i, t, member) { in __btf_struct_show()
3930 member_offset = __btf_member_bit_offset(t, member); in __btf_struct_show()
3931 bitfield_size = __btf_member_bitfield_size(t, member); in __btf_struct_show()
3955 static void btf_struct_show(const struct btf *btf, const struct btf_type *t, in btf_struct_show() argument
3971 __btf_struct_show(btf, t, type_id, data, bits_offset, show); in btf_struct_show()
3986 __btf_struct_show(btf, t, type_id, data, bits_offset, show); in btf_struct_show()
4059 const struct btf_type *t, in btf_enum_check_meta() argument
4062 const struct btf_enum *enums = btf_type_enum(t); in btf_enum_check_meta()
4068 nr_enums = btf_type_vlen(t); in btf_enum_check_meta()
4072 btf_verifier_log_basic(env, t, in btf_enum_check_meta()
4078 if (t->size > 8 || !is_power_of_2(t->size)) { in btf_enum_check_meta()
4079 btf_verifier_log_type(env, t, "Unexpected size"); in btf_enum_check_meta()
4084 if (t->name_off && in btf_enum_check_meta()
4085 !btf_name_valid_identifier(env->btf, t->name_off)) { in btf_enum_check_meta()
4086 btf_verifier_log_type(env, t, "Invalid name"); in btf_enum_check_meta()
4090 btf_verifier_log_type(env, t, NULL); in btf_enum_check_meta()
4102 btf_verifier_log_type(env, t, "Invalid name"); in btf_enum_check_meta()
4108 fmt_str = btf_type_kflag(t) ? "\t%s val=%d\n" : "\t%s val=%u\n"; in btf_enum_check_meta()
4118 const struct btf_type *t) in btf_enum_log() argument
4120 btf_verifier_log(env, "size=%u vlen=%u", t->size, btf_type_vlen(t)); in btf_enum_log()
4123 static void btf_enum_show(const struct btf *btf, const struct btf_type *t, in btf_enum_show() argument
4127 const struct btf_enum *enums = btf_type_enum(t); in btf_enum_show()
4128 u32 i, nr_enums = btf_type_vlen(t); in btf_enum_show()
4132 safe_data = btf_show_start_type(show, t, type_id, data); in btf_enum_show()
4150 if (btf_type_kflag(t)) in btf_enum_show()
4167 const struct btf_type *t, in btf_enum64_check_meta() argument
4170 const struct btf_enum64 *enums = btf_type_enum64(t); in btf_enum64_check_meta()
4176 nr_enums = btf_type_vlen(t); in btf_enum64_check_meta()
4180 btf_verifier_log_basic(env, t, in btf_enum64_check_meta()
4186 if (t->size > 8 || !is_power_of_2(t->size)) { in btf_enum64_check_meta()
4187 btf_verifier_log_type(env, t, "Unexpected size"); in btf_enum64_check_meta()
4192 if (t->name_off && in btf_enum64_check_meta()
4193 !btf_name_valid_identifier(env->btf, t->name_off)) { in btf_enum64_check_meta()
4194 btf_verifier_log_type(env, t, "Invalid name"); in btf_enum64_check_meta()
4198 btf_verifier_log_type(env, t, NULL); in btf_enum64_check_meta()
4210 btf_verifier_log_type(env, t, "Invalid name"); in btf_enum64_check_meta()
4217 fmt_str = btf_type_kflag(t) ? "\t%s val=%lld\n" : "\t%s val=%llu\n"; in btf_enum64_check_meta()
4226 static void btf_enum64_show(const struct btf *btf, const struct btf_type *t, in btf_enum64_show() argument
4230 const struct btf_enum64 *enums = btf_type_enum64(t); in btf_enum64_show()
4231 u32 i, nr_enums = btf_type_vlen(t); in btf_enum64_show()
4235 safe_data = btf_show_start_type(show, t, type_id, data); in btf_enum64_show()
4253 if (btf_type_kflag(t)) in btf_enum64_show()
4270 const struct btf_type *t, in btf_func_proto_check_meta() argument
4273 u32 meta_needed = btf_type_vlen(t) * sizeof(struct btf_param); in btf_func_proto_check_meta()
4276 btf_verifier_log_basic(env, t, in btf_func_proto_check_meta()
4282 if (t->name_off) { in btf_func_proto_check_meta()
4283 btf_verifier_log_type(env, t, "Invalid name"); in btf_func_proto_check_meta()
4287 if (btf_type_kflag(t)) { in btf_func_proto_check_meta()
4288 btf_verifier_log_type(env, t, "Invalid btf_info kind_flag"); in btf_func_proto_check_meta()
4292 btf_verifier_log_type(env, t, NULL); in btf_func_proto_check_meta()
4298 const struct btf_type *t) in btf_func_proto_log() argument
4300 const struct btf_param *args = (const struct btf_param *)(t + 1); in btf_func_proto_log()
4301 u16 nr_args = btf_type_vlen(t), i; in btf_func_proto_log()
4303 btf_verifier_log(env, "return=%u args=(", t->type); in btf_func_proto_log()
4357 const struct btf_type *t, in btf_func_check_meta() argument
4360 if (!t->name_off || in btf_func_check_meta()
4361 !btf_name_valid_identifier(env->btf, t->name_off)) { in btf_func_check_meta()
4362 btf_verifier_log_type(env, t, "Invalid name"); in btf_func_check_meta()
4366 if (btf_type_vlen(t) > BTF_FUNC_GLOBAL) { in btf_func_check_meta()
4367 btf_verifier_log_type(env, t, "Invalid func linkage"); in btf_func_check_meta()
4371 if (btf_type_kflag(t)) { in btf_func_check_meta()
4372 btf_verifier_log_type(env, t, "Invalid btf_info kind_flag"); in btf_func_check_meta()
4376 btf_verifier_log_type(env, t, NULL); in btf_func_check_meta()
4384 const struct btf_type *t = v->t; in btf_func_resolve() local
4385 u32 next_type_id = t->type; in btf_func_resolve()
4388 err = btf_func_check(env, t); in btf_func_resolve()
4406 const struct btf_type *t, in btf_var_check_meta() argument
4413 btf_verifier_log_basic(env, t, in btf_var_check_meta()
4419 if (btf_type_vlen(t)) { in btf_var_check_meta()
4420 btf_verifier_log_type(env, t, "vlen != 0"); in btf_var_check_meta()
4424 if (btf_type_kflag(t)) { in btf_var_check_meta()
4425 btf_verifier_log_type(env, t, "Invalid btf_info kind_flag"); in btf_var_check_meta()
4429 if (!t->name_off || in btf_var_check_meta()
4430 !__btf_name_valid(env->btf, t->name_off)) { in btf_var_check_meta()
4431 btf_verifier_log_type(env, t, "Invalid name"); in btf_var_check_meta()
4436 if (!t->type || !BTF_TYPE_ID_VALID(t->type)) { in btf_var_check_meta()
4437 btf_verifier_log_type(env, t, "Invalid type_id"); in btf_var_check_meta()
4441 var = btf_type_var(t); in btf_var_check_meta()
4444 btf_verifier_log_type(env, t, "Linkage not supported"); in btf_var_check_meta()
4448 btf_verifier_log_type(env, t, NULL); in btf_var_check_meta()
4453 static void btf_var_log(struct btf_verifier_env *env, const struct btf_type *t) in btf_var_log() argument
4455 const struct btf_var *var = btf_type_var(t); in btf_var_log()
4457 btf_verifier_log(env, "type_id=%u linkage=%u", t->type, var->linkage); in btf_var_log()
4470 const struct btf_type *t, in btf_datasec_check_meta() argument
4477 meta_needed = btf_type_vlen(t) * sizeof(*vsi); in btf_datasec_check_meta()
4479 btf_verifier_log_basic(env, t, in btf_datasec_check_meta()
4485 if (!t->size) { in btf_datasec_check_meta()
4486 btf_verifier_log_type(env, t, "size == 0"); in btf_datasec_check_meta()
4490 if (btf_type_kflag(t)) { in btf_datasec_check_meta()
4491 btf_verifier_log_type(env, t, "Invalid btf_info kind_flag"); in btf_datasec_check_meta()
4495 if (!t->name_off || in btf_datasec_check_meta()
4496 !btf_name_valid_section(env->btf, t->name_off)) { in btf_datasec_check_meta()
4497 btf_verifier_log_type(env, t, "Invalid name"); in btf_datasec_check_meta()
4501 btf_verifier_log_type(env, t, NULL); in btf_datasec_check_meta()
4503 for_each_vsi(i, t, vsi) { in btf_datasec_check_meta()
4506 btf_verifier_log_vsi(env, t, vsi, in btf_datasec_check_meta()
4511 if (vsi->offset < last_vsi_end_off || vsi->offset >= t->size) { in btf_datasec_check_meta()
4512 btf_verifier_log_vsi(env, t, vsi, in btf_datasec_check_meta()
4517 if (!vsi->size || vsi->size > t->size) { in btf_datasec_check_meta()
4518 btf_verifier_log_vsi(env, t, vsi, in btf_datasec_check_meta()
4524 if (last_vsi_end_off > t->size) { in btf_datasec_check_meta()
4525 btf_verifier_log_vsi(env, t, vsi, in btf_datasec_check_meta()
4530 btf_verifier_log_vsi(env, t, vsi, NULL); in btf_datasec_check_meta()
4534 if (t->size < sum) { in btf_datasec_check_meta()
4535 btf_verifier_log_type(env, t, "Invalid btf_info size"); in btf_datasec_check_meta()
4550 for_each_vsi_from(i, v->next_member, v->t, vsi) { in btf_datasec_resolve()
4555 btf_verifier_log_vsi(env, v->t, vsi, in btf_datasec_resolve()
4568 btf_verifier_log_vsi(env, v->t, vsi, "Invalid type"); in btf_datasec_resolve()
4573 btf_verifier_log_vsi(env, v->t, vsi, "Invalid size"); in btf_datasec_resolve()
4583 const struct btf_type *t) in btf_datasec_log() argument
4585 btf_verifier_log(env, "size=%u vlen=%u", t->size, btf_type_vlen(t)); in btf_datasec_log()
4589 const struct btf_type *t, u32 type_id, in btf_datasec_show() argument
4597 if (!btf_show_start_type(show, t, type_id, data)) in btf_datasec_show()
4601 __btf_name_by_offset(btf, t->name_off)); in btf_datasec_show()
4602 for_each_vsi(i, t, vsi) { in btf_datasec_show()
4622 const struct btf_type *t, in btf_float_check_meta() argument
4625 if (btf_type_vlen(t)) { in btf_float_check_meta()
4626 btf_verifier_log_type(env, t, "vlen != 0"); in btf_float_check_meta()
4630 if (btf_type_kflag(t)) { in btf_float_check_meta()
4631 btf_verifier_log_type(env, t, "Invalid btf_info kind_flag"); in btf_float_check_meta()
4635 if (t->size != 2 && t->size != 4 && t->size != 8 && t->size != 12 && in btf_float_check_meta()
4636 t->size != 16) { in btf_float_check_meta()
4637 btf_verifier_log_type(env, t, "Invalid type_size"); in btf_float_check_meta()
4641 btf_verifier_log_type(env, t, NULL); in btf_float_check_meta()
4682 const struct btf_type *t) in btf_float_log() argument
4684 btf_verifier_log(env, "size=%u", t->size); in btf_float_log()
4697 const struct btf_type *t, in btf_decl_tag_check_meta() argument
4706 btf_verifier_log_basic(env, t, in btf_decl_tag_check_meta()
4712 value = btf_name_by_offset(env->btf, t->name_off); in btf_decl_tag_check_meta()
4714 btf_verifier_log_type(env, t, "Invalid value"); in btf_decl_tag_check_meta()
4718 if (btf_type_vlen(t)) { in btf_decl_tag_check_meta()
4719 btf_verifier_log_type(env, t, "vlen != 0"); in btf_decl_tag_check_meta()
4723 if (btf_type_kflag(t)) { in btf_decl_tag_check_meta()
4724 btf_verifier_log_type(env, t, "Invalid btf_info kind_flag"); in btf_decl_tag_check_meta()
4728 component_idx = btf_type_decl_tag(t)->component_idx; in btf_decl_tag_check_meta()
4730 btf_verifier_log_type(env, t, "Invalid component_idx"); in btf_decl_tag_check_meta()
4734 btf_verifier_log_type(env, t, NULL); in btf_decl_tag_check_meta()
4743 const struct btf_type *t = v->t; in btf_decl_tag_resolve() local
4744 u32 next_type_id = t->type; in btf_decl_tag_resolve()
4751 btf_verifier_log_type(env, v->t, "Invalid type_id"); in btf_decl_tag_resolve()
4759 component_idx = btf_type_decl_tag(t)->component_idx; in btf_decl_tag_resolve()
4762 btf_verifier_log_type(env, v->t, "Invalid component_idx"); in btf_decl_tag_resolve()
4775 btf_verifier_log_type(env, v->t, "Invalid component_idx"); in btf_decl_tag_resolve()
4785 static void btf_decl_tag_log(struct btf_verifier_env *env, const struct btf_type *t) in btf_decl_tag_log() argument
4787 btf_verifier_log(env, "type=%u component_idx=%d", t->type, in btf_decl_tag_log()
4788 btf_type_decl_tag(t)->component_idx); in btf_decl_tag_log()
4801 const struct btf_type *t) in btf_func_proto_check() argument
4810 args = (const struct btf_param *)(t + 1); in btf_func_proto_check()
4811 nr_args = btf_type_vlen(t); in btf_func_proto_check()
4814 if (t->type) { in btf_func_proto_check()
4815 u32 ret_type_id = t->type; in btf_func_proto_check()
4819 btf_verifier_log_type(env, t, "Invalid return type"); in btf_func_proto_check()
4824 btf_verifier_log_type(env, t, "Invalid return type"); in btf_func_proto_check()
4837 btf_verifier_log_type(env, t, "Invalid return type"); in btf_func_proto_check()
4848 btf_verifier_log_type(env, t, "Invalid arg#%u", in btf_func_proto_check()
4862 btf_verifier_log_type(env, t, "Invalid arg#%u", i + 1); in btf_func_proto_check()
4867 btf_verifier_log_type(env, t, "Invalid arg#%u", i + 1); in btf_func_proto_check()
4874 btf_verifier_log_type(env, t, in btf_func_proto_check()
4887 btf_verifier_log_type(env, t, "Invalid arg#%u", i + 1); in btf_func_proto_check()
4896 const struct btf_type *t) in btf_func_check() argument
4904 proto_type = btf_type_by_id(btf, t->type); in btf_func_check()
4907 btf_verifier_log_type(env, t, "Invalid type_id"); in btf_func_check()
4915 btf_verifier_log_type(env, t, "Invalid arg#%u", i + 1); in btf_func_check()
4946 const struct btf_type *t, in btf_check_meta() argument
4952 if (meta_left < sizeof(*t)) { in btf_check_meta()
4954 env->log_type_id, meta_left, sizeof(*t)); in btf_check_meta()
4957 meta_left -= sizeof(*t); in btf_check_meta()
4959 if (t->info & ~BTF_INFO_MASK) { in btf_check_meta()
4961 env->log_type_id, t->info); in btf_check_meta()
4965 if (BTF_INFO_KIND(t->info) > BTF_KIND_MAX || in btf_check_meta()
4966 BTF_INFO_KIND(t->info) == BTF_KIND_UNKN) { in btf_check_meta()
4968 env->log_type_id, BTF_INFO_KIND(t->info)); in btf_check_meta()
4972 if (!btf_name_offset_valid(env->btf, t->name_off)) { in btf_check_meta()
4974 env->log_type_id, t->name_off); in btf_check_meta()
4978 var_meta_size = btf_type_ops(t)->check_meta(env, t, meta_left); in btf_check_meta()
4999 struct btf_type *t = cur; in btf_check_all_metas() local
5002 meta_size = btf_check_meta(env, t, end - cur); in btf_check_all_metas()
5006 btf_add_type(env, t); in btf_check_all_metas()
5015 const struct btf_type *t, in btf_resolve_valid() argument
5023 if (btf_type_is_struct(t) || btf_type_is_datasec(t)) in btf_resolve_valid()
5027 if (btf_type_is_decl_tag(t) || btf_type_is_func(t)) in btf_resolve_valid()
5031 if (btf_type_is_modifier(t) || btf_type_is_ptr(t) || in btf_resolve_valid()
5032 btf_type_is_var(t)) { in btf_resolve_valid()
5033 t = btf_type_id_resolve(btf, &type_id); in btf_resolve_valid()
5034 return t && in btf_resolve_valid()
5035 !btf_type_is_modifier(t) && in btf_resolve_valid()
5036 !btf_type_is_var(t) && in btf_resolve_valid()
5037 !btf_type_is_datasec(t); in btf_resolve_valid()
5040 if (btf_type_is_array(t)) { in btf_resolve_valid()
5041 const struct btf_array *array = btf_type_array(t); in btf_resolve_valid()
5056 const struct btf_type *t, u32 type_id) in btf_resolve() argument
5063 env_stack_push(env, t, type_id); in btf_resolve()
5066 err = btf_type_ops(v->t)->resolve(env, v); in btf_resolve()
5071 btf_verifier_log_type(env, t, in btf_resolve()
5075 btf_verifier_log_type(env, t, "Loop detected"); in btf_resolve()
5079 if (!err && !btf_resolve_valid(env, t, type_id)) { in btf_resolve()
5080 btf_verifier_log_type(env, t, "Invalid resolve state"); in btf_resolve()
5091 const struct btf_type *t; in btf_check_all_types() local
5102 t = btf_type_by_id(btf, type_id); in btf_check_all_types()
5105 if (btf_type_needs_resolve(t) && in btf_check_all_types()
5107 err = btf_resolve(env, t, type_id); in btf_check_all_types()
5112 if (btf_type_is_func_proto(t)) { in btf_check_all_types()
5113 err = btf_func_proto_check(env, t); in btf_check_all_types()
5353 const struct btf_type *t; in btf_parse_struct_metas() local
5356 t = btf_type_by_id(btf, i); in btf_parse_struct_metas()
5357 if (!t) { in btf_parse_struct_metas()
5361 if (!__btf_type_is_struct(t)) in btf_parse_struct_metas()
5366 for_each_member(j, t, member) { in btf_parse_struct_metas()
5385 record = btf_parse_fields(btf, t, BPF_SPIN_LOCK | BPF_LIST_HEAD | BPF_LIST_NODE | in btf_parse_struct_metas()
5386 BPF_RB_ROOT | BPF_RB_NODE | BPF_REFCOUNT, t->size); in btf_parse_struct_metas()
5420 const struct btf_type *t; in btf_check_type_tags() local
5424 t = btf_type_by_id(btf, i); in btf_check_type_tags()
5425 if (!t) in btf_check_type_tags()
5427 if (!btf_type_is_modifier(t)) in btf_check_type_tags()
5432 in_tags = btf_type_is_type_tag(t); in btf_check_type_tags()
5433 while (btf_type_is_modifier(t)) { in btf_check_type_tags()
5438 if (btf_type_is_type_tag(t)) { in btf_check_type_tags()
5449 cur_id = t->type; in btf_check_type_tags()
5450 t = btf_type_by_id(btf, cur_id); in btf_check_type_tags()
5451 if (!t) in btf_check_type_tags()
5592 const struct btf_type *t; member
5613 const struct btf_type *t, enum bpf_prog_type prog_type, in btf_get_prog_ctx_type() argument
5621 conv_struct = bpf_ctx_convert.t; in btf_get_prog_ctx_type()
5626 t = btf_type_by_id(btf, t->type); in btf_get_prog_ctx_type()
5627 while (btf_type_is_modifier(t)) in btf_get_prog_ctx_type()
5628 t = btf_type_by_id(btf, t->type); in btf_get_prog_ctx_type()
5629 if (!btf_type_is_struct(t)) { in btf_get_prog_ctx_type()
5637 tname = btf_name_by_offset(btf, t->name_off); in btf_get_prog_ctx_type()
5684 const struct btf_type *t, in btf_translate_to_vmlinux() argument
5690 prog_ctx_type = btf_get_prog_ctx_type(log, btf, t, prog_type, arg); in btf_translate_to_vmlinux()
5704 conv_struct = bpf_ctx_convert.t; in get_kern_ctx_btf_id()
5765 bpf_ctx_convert.t = btf_type_by_id(btf, bpf_ctx_convert_btf_id[0]); in BTF_ID()
5874 static bool is_int_ptr(struct btf *btf, const struct btf_type *t) in is_int_ptr() argument
5877 t = btf_type_skip_modifiers(btf, t->type, NULL); in is_int_ptr()
5879 return btf_type_is_int(t); in is_int_ptr()
5886 const struct btf_type *t; in get_ctx_arg_idx() local
5896 t = btf_type_skip_modifiers(btf, args[i].type, NULL); in get_ctx_arg_idx()
5897 offset += btf_type_is_ptr(t) ? 8 : roundup(t->size, 8); in get_ctx_arg_idx()
5902 t = btf_type_skip_modifiers(btf, func_proto->type, NULL); in get_ctx_arg_idx()
5903 offset += btf_type_is_ptr(t) ? 8 : roundup(t->size, 8); in get_ctx_arg_idx()
5930 const struct btf_type *t = prog->aux->attach_func_proto; in btf_ctx_access() local
5945 arg = get_ctx_arg_idx(btf, t, off); in btf_ctx_access()
5946 args = (const struct btf_param *)(t + 1); in btf_ctx_access()
5950 nr_args = t ? btf_type_vlen(t) : MAX_BPF_FUNC_REG_ARGS; in btf_ctx_access()
5981 if (!t) in btf_ctx_access()
5983 t = btf_type_by_id(btf, t->type); in btf_ctx_access()
5989 if (!t) in btf_ctx_access()
5992 t = btf_type_skip_modifiers(btf, t->type, NULL); in btf_ctx_access()
5993 if (!btf_type_is_small_int(t)) { in btf_ctx_access()
5996 btf_type_str(t)); in btf_ctx_access()
6006 if (!t) in btf_ctx_access()
6009 t = btf_type_by_id(btf, args[arg].type); in btf_ctx_access()
6013 while (btf_type_is_modifier(t)) in btf_ctx_access()
6014 t = btf_type_by_id(btf, t->type); in btf_ctx_access()
6015 if (btf_type_is_small_int(t) || btf_is_any_enum(t) || __btf_type_is_struct(t)) in btf_ctx_access()
6018 if (!btf_type_is_ptr(t)) { in btf_ctx_access()
6022 __btf_name_by_offset(btf, t->name_off), in btf_ctx_access()
6023 btf_type_str(t)); in btf_ctx_access()
6041 if (t->type == 0) in btf_ctx_access()
6048 if (is_int_ptr(btf, t)) in btf_ctx_access()
6080 ret = btf_translate_to_vmlinux(log, btf, t, tgt_type, arg); in btf_ctx_access()
6091 info->btf_id = t->type; in btf_ctx_access()
6092 t = btf_type_by_id(btf, t->type); in btf_ctx_access()
6094 if (btf_type_is_type_tag(t)) { in btf_ctx_access()
6095 tag_value = __btf_name_by_offset(btf, t->name_off); in btf_ctx_access()
6103 while (btf_type_is_modifier(t)) { in btf_ctx_access()
6104 info->btf_id = t->type; in btf_ctx_access()
6105 t = btf_type_by_id(btf, t->type); in btf_ctx_access()
6107 if (!btf_type_is_struct(t)) { in btf_ctx_access()
6110 tname, arg, btf_type_str(t)); in btf_ctx_access()
6114 tname, arg, info->btf_id, btf_type_str(t), in btf_ctx_access()
6115 __btf_name_by_offset(btf, t->name_off)); in btf_ctx_access()
6127 const struct btf_type *t, int off, int size, in btf_struct_walk() argument
6138 if (btf_type_is_modifier(t)) in btf_struct_walk()
6139 t = btf_type_skip_modifiers(btf, t->type, NULL); in btf_struct_walk()
6140 tname = __btf_name_by_offset(btf, t->name_off); in btf_struct_walk()
6141 if (!btf_type_is_struct(t)) { in btf_struct_walk()
6146 vlen = btf_type_vlen(t); in btf_struct_walk()
6147 if (BTF_INFO_KIND(t->info) == BTF_KIND_UNION && vlen != 1 && !(*flag & PTR_UNTRUSTED)) in btf_struct_walk()
6155 if (off + size > t->size) { in btf_struct_walk()
6164 member = btf_type_member(t) + vlen - 1; in btf_struct_walk()
6174 moff = __btf_member_bit_offset(t, member) / 8; in btf_struct_walk()
6179 t = btf_type_skip_modifiers(btf, array_elem->type, in btf_struct_walk()
6182 if (btf_type_is_int(t)) in btf_struct_walk()
6185 if (!btf_type_is_struct(t)) in btf_struct_walk()
6188 off = (off - moff) % t->size; in btf_struct_walk()
6197 for_each_member(i, t, member) { in btf_struct_walk()
6199 moff = __btf_member_bit_offset(t, member) / 8; in btf_struct_walk()
6204 if (__btf_member_bitfield_size(t, member)) { in btf_struct_walk()
6205 u32 end_bit = __btf_member_bit_offset(t, member) + in btf_struct_walk()
6206 __btf_member_bitfield_size(t, member); in btf_struct_walk()
6316 t = mtype; in btf_struct_walk()
6330 const struct btf_type *stype, *t; in btf_struct_walk() local
6342 t = btf_type_by_id(btf, mtype->type); in btf_struct_walk()
6343 if (btf_type_is_type_tag(t)) { in btf_struct_walk()
6344 tag_value = __btf_name_by_offset(btf, t->name_off); in btf_struct_walk()
6393 const struct btf_type *t; in btf_struct_access() local
6419 t = btf_type_by_id(btf, id); in btf_struct_access()
6421 err = btf_struct_walk(log, btf, t, off, size, &id, &tmp_flag, field_name); in btf_struct_access()
6443 t = btf_type_by_id(btf, id); in btf_struct_access()
6454 } while (t); in btf_struct_access()
6516 const struct btf_type *t; in __get_type_size() local
6522 t = btf_type_by_id(btf, btf_id); in __get_type_size()
6523 while (t && btf_type_is_modifier(t)) in __get_type_size()
6524 t = btf_type_by_id(btf, t->type); in __get_type_size()
6525 if (!t) in __get_type_size()
6527 *ret_type = t; in __get_type_size()
6528 if (btf_type_is_ptr(t)) in __get_type_size()
6531 if (btf_type_is_int(t) || btf_is_any_enum(t) || __btf_type_is_struct(t)) in __get_type_size()
6532 return t->size; in __get_type_size()
6536 static u8 __get_type_fmodel_flags(const struct btf_type *t) in __get_type_fmodel_flags() argument
6540 if (__btf_type_is_struct(t)) in __get_type_fmodel_flags()
6542 if (btf_type_is_signed_int(t)) in __get_type_fmodel_flags()
6555 const struct btf_type *t; in btf_distill_func_proto() local
6580 ret = __get_type_size(btf, func->type, &t); in btf_distill_func_proto()
6581 if (ret < 0 || __btf_type_is_struct(t)) { in btf_distill_func_proto()
6584 tname, btf_type_str(t)); in btf_distill_func_proto()
6588 m->ret_flags = __get_type_fmodel_flags(t); in btf_distill_func_proto()
6597 ret = __get_type_size(btf, args[i].type, &t); in btf_distill_func_proto()
6603 tname, i, btf_type_str(t)); in btf_distill_func_proto()
6613 m->arg_flags[i] = __get_type_fmodel_flags(t); in btf_distill_func_proto()
6770 const struct btf_type *t, *ref_t; in btf_check_func_arg_match() local
6775 t = btf_type_by_id(btf, func_id); in btf_check_func_arg_match()
6776 if (!t || !btf_type_is_func(t)) { in btf_check_func_arg_match()
6784 func_name = btf_name_by_offset(btf, t->name_off); in btf_check_func_arg_match()
6786 t = btf_type_by_id(btf, t->type); in btf_check_func_arg_match()
6787 if (!t || !btf_type_is_func_proto(t)) { in btf_check_func_arg_match()
6791 args = (const struct btf_param *)(t + 1); in btf_check_func_arg_match()
6792 nargs = btf_type_vlen(t); in btf_check_func_arg_match()
6807 t = btf_type_skip_modifiers(btf, args[i].type, NULL); in btf_check_func_arg_match()
6808 if (btf_type_is_scalar(t)) { in btf_check_func_arg_match()
6815 if (!btf_type_is_ptr(t)) { in btf_check_func_arg_match()
6817 i, btf_type_str(t)); in btf_check_func_arg_match()
6821 ref_t = btf_type_skip_modifiers(btf, t->type, &ref_id); in btf_check_func_arg_match()
6828 if (btf_get_prog_ctx_type(log, btf, t, prog_type, i)) { in btf_check_func_arg_match()
6835 i, btf_type_str(t)); in btf_check_func_arg_match()
6959 const struct btf_type *t, *ref_t; in btf_prepare_func_args() local
6975 t = btf_type_by_id(btf, btf_id); in btf_prepare_func_args()
6976 if (!t || !btf_type_is_func(t)) { in btf_prepare_func_args()
6984 tname = btf_name_by_offset(btf, t->name_off); in btf_prepare_func_args()
6997 t = btf_type_by_id(btf, t->type); in btf_prepare_func_args()
6998 if (!t || !btf_type_is_func_proto(t)) { in btf_prepare_func_args()
7002 args = (const struct btf_param *)(t + 1); in btf_prepare_func_args()
7003 nargs = btf_type_vlen(t); in btf_prepare_func_args()
7010 t = btf_type_by_id(btf, t->type); in btf_prepare_func_args()
7011 while (btf_type_is_modifier(t)) in btf_prepare_func_args()
7012 t = btf_type_by_id(btf, t->type); in btf_prepare_func_args()
7013 if (!btf_type_is_int(t) && !btf_is_any_enum(t)) { in btf_prepare_func_args()
7025 t = btf_type_by_id(btf, args[i].type); in btf_prepare_func_args()
7026 while (btf_type_is_modifier(t)) in btf_prepare_func_args()
7027 t = btf_type_by_id(btf, t->type); in btf_prepare_func_args()
7028 if (btf_type_is_int(t) || btf_is_any_enum(t)) { in btf_prepare_func_args()
7032 if (btf_type_is_ptr(t)) { in btf_prepare_func_args()
7033 if (btf_get_prog_ctx_type(log, btf, t, prog_type, i)) { in btf_prepare_func_args()
7038 t = btf_type_skip_modifiers(btf, t->type, NULL); in btf_prepare_func_args()
7040 ref_t = btf_resolve_size(btf, t, ®->mem_size); in btf_prepare_func_args()
7044 i, btf_type_str(t), btf_name_by_offset(btf, t->name_off), in btf_prepare_func_args()
7055 i, btf_type_str(t), tname); in btf_prepare_func_args()
7064 const struct btf_type *t = btf_type_by_id(btf, type_id); in btf_type_show() local
7070 btf_type_ops(t)->show(btf, t, type_id, obj, 0, show); in btf_type_show()
7578 const struct btf_type *t; in BTF_ID_LIST_GLOBAL() local
7592 t = btf_type_skip_modifiers(btf, arg->type, NULL); in BTF_ID_LIST_GLOBAL()
7593 if (!t || !btf_type_is_ptr(t)) in BTF_ID_LIST_GLOBAL()
7595 t = btf_type_skip_modifiers(btf, t->type, NULL); in BTF_ID_LIST_GLOBAL()
7596 if (!t || !__btf_type_is_struct(t)) in BTF_ID_LIST_GLOBAL()
7599 name = btf_name_by_offset(btf, t->name_off); in BTF_ID_LIST_GLOBAL()
7606 if (t->size == 0 || (t->size % 8)) in BTF_ID_LIST_GLOBAL()
7630 t = btf_type_skip_modifiers(btf, func->type, NULL); in BTF_ID_LIST_GLOBAL()
7631 if (!t || !btf_type_is_ptr(t)) in BTF_ID_LIST_GLOBAL()
7637 t = btf_type_by_id(btf, func->type); in BTF_ID_LIST_GLOBAL()
7638 if (!t || !btf_type_is_void(t)) in BTF_ID_LIST_GLOBAL()
7954 const struct btf_type *dtor_func, *dtor_func_proto, *t; in btf_check_dtor_kfuncs() local
7971 t = btf_type_by_id(btf, dtor_func_proto->type); in btf_check_dtor_kfuncs()
7972 if (!t || !btf_type_is_void(t)) in btf_check_dtor_kfuncs()
7979 t = btf_type_by_id(btf, args[0].type); in btf_check_dtor_kfuncs()
7983 if (!t || !btf_type_is_ptr(t)) in btf_check_dtor_kfuncs()
8285 const struct btf_type *t; in bpf_core_add_cands() local
8292 t = btf_type_by_id(targ_btf, i); in bpf_core_add_cands()
8293 if (btf_kind(t) != cands->kind) in bpf_core_add_cands()
8296 targ_name = btf_name_by_offset(targ_btf, t->name_off); in bpf_core_add_cands()