Lines Matching refs:btf
199 struct btf { struct
248 struct btf *btf; member
344 const struct btf *btf; member
383 void (*show)(const struct btf *btf, const struct btf_type *t,
453 s32 btf_find_by_name_kind(const struct btf *btf, const char *name, u8 kind) in btf_find_by_name_kind() argument
459 for (i = 1; i <= btf->nr_types; i++) { in btf_find_by_name_kind()
460 t = btf->types[i]; in btf_find_by_name_kind()
464 tname = btf_name_by_offset(btf, t->name_off); in btf_find_by_name_kind()
472 const struct btf_type *btf_type_skip_modifiers(const struct btf *btf, in btf_type_skip_modifiers() argument
475 const struct btf_type *t = btf_type_by_id(btf, id); in btf_type_skip_modifiers()
479 t = btf_type_by_id(btf, t->type); in btf_type_skip_modifiers()
488 const struct btf_type *btf_type_resolve_ptr(const struct btf *btf, in btf_type_resolve_ptr() argument
493 t = btf_type_skip_modifiers(btf, id, NULL); in btf_type_resolve_ptr()
497 return btf_type_skip_modifiers(btf, t->type, res_id); in btf_type_resolve_ptr()
500 const struct btf_type *btf_type_resolve_func_ptr(const struct btf *btf, in btf_type_resolve_func_ptr() argument
505 ptype = btf_type_resolve_ptr(btf, id, res_id); in btf_type_resolve_func_ptr()
601 static bool btf_name_offset_valid(const struct btf *btf, u32 offset) in btf_name_offset_valid() argument
604 offset < btf->hdr.str_len; in btf_name_offset_valid()
618 static bool __btf_name_valid(const struct btf *btf, u32 offset, bool dot_ok) in __btf_name_valid() argument
621 const char *src = &btf->strings[offset]; in __btf_name_valid()
642 static bool btf_name_valid_identifier(const struct btf *btf, u32 offset) in btf_name_valid_identifier() argument
644 return __btf_name_valid(btf, offset, false); in btf_name_valid_identifier()
647 static bool btf_name_valid_section(const struct btf *btf, u32 offset) in btf_name_valid_section() argument
649 return __btf_name_valid(btf, offset, true); in btf_name_valid_section()
652 static const char *__btf_name_by_offset(const struct btf *btf, u32 offset) in __btf_name_by_offset() argument
656 else if (offset < btf->hdr.str_len) in __btf_name_by_offset()
657 return &btf->strings[offset]; in __btf_name_by_offset()
662 const char *btf_name_by_offset(const struct btf *btf, u32 offset) in btf_name_by_offset() argument
664 if (offset < btf->hdr.str_len) in btf_name_by_offset()
665 return &btf->strings[offset]; in btf_name_by_offset()
670 const struct btf_type *btf_type_by_id(const struct btf *btf, u32 type_id) in btf_type_by_id() argument
672 if (type_id > btf->nr_types) in btf_type_by_id()
675 return btf->types[type_id]; in btf_type_by_id()
705 bool btf_member_is_reg_int(const struct btf *btf, const struct btf_type *s, in btf_member_is_reg_int() argument
714 t = btf_type_id_size(btf, &id, NULL); in btf_member_is_reg_int()
743 static const struct btf_type *btf_type_skip_qualifiers(const struct btf *btf, in btf_type_skip_qualifiers() argument
746 const struct btf_type *t = btf_type_by_id(btf, id); in btf_type_skip_qualifiers()
751 t = btf_type_by_id(btf, t->type); in btf_type_skip_qualifiers()
797 member = btf_name_by_offset(show->btf, m->name_off); in btf_show_name()
809 t = btf_type_by_id(show->btf, id); in btf_show_name()
840 name = btf_name_by_offset(show->btf, in btf_show_name()
867 t = btf_type_skip_qualifiers(show->btf, id); in btf_show_name()
874 name = btf_name_by_offset(show->btf, t->name_off); in btf_show_name()
1062 rt = btf_resolve_size(show->btf, t, &size); in btf_show_obj_safe()
1255 struct btf *btf = env->btf; in __btf_verifier_log_type() local
1271 __btf_name_by_offset(btf, t->name_off), in __btf_verifier_log_type()
1299 struct btf *btf = env->btf; in btf_verifier_log_member() local
1319 __btf_name_by_offset(btf, member->name_off), in btf_verifier_log_member()
1325 __btf_name_by_offset(btf, member->name_off), in btf_verifier_log_member()
1370 const struct btf *btf = env->btf; in btf_verifier_log_hdr() local
1378 hdr = &btf->hdr; in btf_verifier_log_hdr()
1392 struct btf *btf = env->btf; in btf_add_type() local
1398 if (btf->types_size - btf->nr_types < 2) { in btf_add_type()
1404 if (btf->types_size == BTF_MAX_TYPE) { in btf_add_type()
1409 expand_by = max_t(u32, btf->types_size >> 2, 16); in btf_add_type()
1411 btf->types_size + expand_by); in btf_add_type()
1418 if (btf->nr_types == 0) in btf_add_type()
1421 memcpy(new_types, btf->types, in btf_add_type()
1422 sizeof(*btf->types) * (btf->nr_types + 1)); in btf_add_type()
1424 kvfree(btf->types); in btf_add_type()
1425 btf->types = new_types; in btf_add_type()
1426 btf->types_size = new_size; in btf_add_type()
1429 btf->types[++(btf->nr_types)] = t; in btf_add_type()
1434 static int btf_alloc_id(struct btf *btf) in btf_alloc_id() argument
1440 id = idr_alloc_cyclic(&btf_idr, btf, 1, INT_MAX, GFP_ATOMIC); in btf_alloc_id()
1442 btf->id = id; in btf_alloc_id()
1452 static void btf_free_id(struct btf *btf) in btf_free_id() argument
1466 idr_remove(&btf_idr, btf->id); in btf_free_id()
1470 static void btf_free(struct btf *btf) in btf_free() argument
1472 kvfree(btf->types); in btf_free()
1473 kvfree(btf->resolved_sizes); in btf_free()
1474 kvfree(btf->resolved_ids); in btf_free()
1475 kvfree(btf->data); in btf_free()
1476 kfree(btf); in btf_free()
1481 struct btf *btf = container_of(rcu, struct btf, rcu); in btf_free_rcu() local
1483 btf_free(btf); in btf_free_rcu()
1486 void btf_put(struct btf *btf) in btf_put() argument
1488 if (btf && refcount_dec_and_test(&btf->refcnt)) { in btf_put()
1489 btf_free_id(btf); in btf_put()
1490 call_rcu(&btf->rcu, btf_free_rcu); in btf_put()
1496 struct btf *btf = env->btf; in env_resolve_init() local
1497 u32 nr_types = btf->nr_types; in env_resolve_init()
1518 btf->resolved_sizes = resolved_sizes; in env_resolve_init()
1519 btf->resolved_ids = resolved_ids; in env_resolve_init()
1607 struct btf *btf = env->btf; in env_stack_pop_resolved() local
1609 btf->resolved_sizes[type_id] = resolved_size; in env_stack_pop_resolved()
1610 btf->resolved_ids[type_id] = resolved_type_id; in env_stack_pop_resolved()
1640 __btf_resolve_size(const struct btf *btf, const struct btf_type *type, in __btf_resolve_size() argument
1668 type = btf_type_by_id(btf, type->type); in __btf_resolve_size()
1678 type = btf_type_by_id(btf, array->type); in __btf_resolve_size()
1707 btf_resolve_size(const struct btf *btf, const struct btf_type *type, in btf_resolve_size() argument
1710 return __btf_resolve_size(btf, type, type_size, NULL, NULL, NULL, NULL); in btf_resolve_size()
1714 static const struct btf_type *btf_type_id_resolve(const struct btf *btf, in btf_type_id_resolve() argument
1717 *type_id = btf->resolved_ids[*type_id]; in btf_type_id_resolve()
1718 return btf_type_by_id(btf, *type_id); in btf_type_id_resolve()
1721 const struct btf_type *btf_type_id_size(const struct btf *btf, in btf_type_id_size() argument
1728 size_type = btf_type_by_id(btf, size_type_id); in btf_type_id_size()
1735 size = btf->resolved_sizes[size_type_id]; in btf_type_id_size()
1743 size_type_id = btf->resolved_ids[size_type_id]; in btf_type_id_size()
1744 size_type = btf_type_by_id(btf, size_type_id); in btf_type_id_size()
1750 size = btf->resolved_sizes[size_type_id]; in btf_type_id_size()
1813 static void btf_df_show(const struct btf *btf, const struct btf_type *t, in btf_df_show() argument
2081 static void btf_int_bits_show(const struct btf *btf, in btf_int_bits_show() argument
2100 static void btf_int_show(const struct btf *btf, const struct btf_type *t, in btf_int_show() argument
2116 btf_int_bits_show(btf, t, safe_data, bits_offset, show); in btf_int_show()
2163 btf_int_bits_show(btf, t, safe_data, bits_offset, show); in btf_int_show()
2187 struct btf *btf = env->btf; in btf_modifier_check_member() local
2189 resolved_type = btf_type_id_size(btf, &resolved_type_id, NULL); in btf_modifier_check_member()
2212 struct btf *btf = env->btf; in btf_modifier_check_kflag_member() local
2214 resolved_type = btf_type_id_size(btf, &resolved_type_id, NULL); in btf_modifier_check_kflag_member()
2279 !btf_name_valid_identifier(env->btf, t->name_off)) { in btf_ref_type_check_meta()
2301 struct btf *btf = env->btf; in btf_modifier_resolve() local
2303 next_type = btf_type_by_id(btf, next_type_id); in btf_modifier_resolve()
2319 if (!btf_type_id_size(btf, &next_type_id, NULL)) { in btf_modifier_resolve()
2321 next_type = btf_type_id_resolve(btf, &next_type_id); in btf_modifier_resolve()
2343 struct btf *btf = env->btf; in btf_var_resolve() local
2345 next_type = btf_type_by_id(btf, next_type_id); in btf_var_resolve()
2360 resolved_type = btf_type_id_resolve(btf, &resolved_type_id); in btf_var_resolve()
2373 if (!btf_type_id_size(btf, &next_type_id, NULL)) { in btf_var_resolve()
2389 struct btf *btf = env->btf; in btf_ptr_resolve() local
2391 next_type = btf_type_by_id(btf, next_type_id); in btf_ptr_resolve()
2414 resolved_type = btf_type_id_resolve(btf, &resolved_type_id); in btf_ptr_resolve()
2423 if (!btf_type_id_size(btf, &next_type_id, NULL)) { in btf_ptr_resolve()
2425 next_type = btf_type_id_resolve(btf, &next_type_id); in btf_ptr_resolve()
2440 static void btf_modifier_show(const struct btf *btf, in btf_modifier_show() argument
2445 if (btf->resolved_ids) in btf_modifier_show()
2446 t = btf_type_id_resolve(btf, &type_id); in btf_modifier_show()
2448 t = btf_type_skip_modifiers(btf, type_id, NULL); in btf_modifier_show()
2450 btf_type_ops(t)->show(btf, t, type_id, data, bits_offset, show); in btf_modifier_show()
2453 static void btf_var_show(const struct btf *btf, const struct btf_type *t, in btf_var_show() argument
2457 t = btf_type_id_resolve(btf, &type_id); in btf_var_show()
2459 btf_type_ops(t)->show(btf, t, type_id, data, bits_offset, show); in btf_var_show()
2462 static void btf_ptr_show(const struct btf *btf, const struct btf_type *t, in btf_ptr_show() argument
2520 !btf_name_valid_identifier(env->btf, t->name_off)) { in btf_fwd_check_meta()
2553 struct btf *btf = env->btf; in btf_array_check_member() local
2562 btf_type_id_size(btf, &array_type_id, &array_size); in btf_array_check_member()
2633 struct btf *btf = env->btf; in btf_array_resolve() local
2638 index_type = btf_type_by_id(btf, index_type_id); in btf_array_resolve()
2649 index_type = btf_type_id_size(btf, &index_type_id, NULL); in btf_array_resolve()
2658 elem_type = btf_type_by_id(btf, elem_type_id); in btf_array_resolve()
2670 elem_type = btf_type_id_size(btf, &elem_type_id, &elem_size); in btf_array_resolve()
2701 static void __btf_array_show(const struct btf *btf, const struct btf_type *t, in __btf_array_show() argument
2712 elem_type = btf_type_skip_modifiers(btf, elem_type_id, NULL); in __btf_array_show()
2741 elem_ops->show(btf, elem_type, elem_type_id, data, in __btf_array_show()
2754 static void btf_array_show(const struct btf *btf, const struct btf_type *t, in btf_array_show() argument
2770 __btf_array_show(btf, t, type_id, data, bits_offset, show); in btf_array_show()
2784 __btf_array_show(btf, t, type_id, data, bits_offset, show); in btf_array_show()
2828 struct btf *btf = env->btf; in btf_struct_check_meta() local
2843 !btf_name_valid_identifier(env->btf, t->name_off)) { in btf_struct_check_meta()
2852 if (!btf_name_offset_valid(btf, member->name_off)) { in btf_struct_check_meta()
2861 !btf_name_valid_identifier(btf, member->name_off)) { in btf_struct_check_meta()
2924 last_member_type = btf_type_by_id(env->btf, in btf_struct_resolve()
2940 const struct btf_type *member_type = btf_type_by_id(env->btf, in btf_struct_resolve()
2983 int btf_find_spin_lock(const struct btf *btf, const struct btf_type *t) in btf_find_spin_lock() argument
2992 const struct btf_type *member_type = btf_type_by_id(btf, in btf_find_spin_lock()
2998 if (strcmp(__btf_name_by_offset(btf, member_type->name_off), in btf_find_spin_lock()
3016 static void __btf_struct_show(const struct btf *btf, const struct btf_type *t, in __btf_struct_show() argument
3029 const struct btf_type *member_type = btf_type_by_id(btf, in __btf_struct_show()
3053 ops->show(btf, member_type, member->type, in __btf_struct_show()
3063 static void btf_struct_show(const struct btf *btf, const struct btf_type *t, in btf_struct_show() argument
3079 __btf_struct_show(btf, t, type_id, data, bits_offset, show); in btf_struct_show()
3094 __btf_struct_show(btf, t, type_id, data, bits_offset, show); in btf_struct_show()
3171 struct btf *btf = env->btf; in btf_enum_check_meta() local
3197 !btf_name_valid_identifier(env->btf, t->name_off)) { in btf_enum_check_meta()
3205 if (!btf_name_offset_valid(btf, enums[i].name_off)) { in btf_enum_check_meta()
3213 !btf_name_valid_identifier(btf, enums[i].name_off)) { in btf_enum_check_meta()
3221 __btf_name_by_offset(btf, enums[i].name_off), in btf_enum_check_meta()
3234 static void btf_enum_show(const struct btf *btf, const struct btf_type *t, in btf_enum_show() argument
3254 __btf_name_by_offset(btf, in btf_enum_show()
3321 __btf_name_by_offset(env->btf, in btf_func_proto_log()
3325 __btf_name_by_offset(env->btf, in btf_func_proto_log()
3333 __btf_name_by_offset(env->btf, in btf_func_proto_log()
3366 !btf_name_valid_identifier(env->btf, t->name_off)) { in btf_func_check_meta()
3420 !__btf_name_valid(env->btf, t->name_off, true)) { in btf_var_check_meta()
3491 !btf_name_valid_section(env->btf, t->name_off)) { in btf_datasec_check_meta()
3541 struct btf *btf = env->btf; in btf_datasec_resolve() local
3546 const struct btf_type *var_type = btf_type_by_id(env->btf, in btf_datasec_resolve()
3561 if (!btf_type_id_size(btf, &type_id, &type_size)) { in btf_datasec_resolve()
3582 static void btf_datasec_show(const struct btf *btf, in btf_datasec_show() argument
3595 __btf_name_by_offset(btf, t->name_off)); in btf_datasec_show()
3597 var = btf_type_by_id(btf, vsi->type); in btf_datasec_show()
3600 btf_type_ops(var)->show(btf, var, vsi->type, in btf_datasec_show()
3620 const struct btf *btf; in btf_func_proto_check() local
3624 btf = env->btf; in btf_func_proto_check()
3632 ret_type = btf_type_by_id(btf, ret_type_id); in btf_func_proto_check()
3646 if (!btf_type_id_size(btf, &ret_type_id, NULL)) { in btf_func_proto_check()
3671 arg_type = btf_type_by_id(btf, arg_type_id); in btf_func_proto_check()
3679 (!btf_name_offset_valid(btf, args[i].name_off) || in btf_func_proto_check()
3680 !btf_name_valid_identifier(btf, args[i].name_off))) { in btf_func_proto_check()
3694 if (!btf_type_id_size(btf, &arg_type_id, NULL)) { in btf_func_proto_check()
3709 const struct btf *btf; in btf_func_check() local
3712 btf = env->btf; in btf_func_check()
3713 proto_type = btf_type_by_id(btf, t->type); in btf_func_check()
3777 if (!btf_name_offset_valid(env->btf, t->name_off)) { in btf_check_meta()
3794 struct btf *btf = env->btf; in btf_check_all_metas() local
3798 hdr = &btf->hdr; in btf_check_all_metas()
3799 cur = btf->nohdr_data + hdr->type_off; in btf_check_all_metas()
3823 struct btf *btf = env->btf; in btf_resolve_valid() local
3829 return !btf->resolved_ids[type_id] && in btf_resolve_valid()
3830 !btf->resolved_sizes[type_id]; in btf_resolve_valid()
3834 t = btf_type_id_resolve(btf, &type_id); in btf_resolve_valid()
3847 elem_type = btf_type_id_size(btf, &elem_type_id, &elem_size); in btf_resolve_valid()
3850 btf->resolved_sizes[type_id]); in btf_resolve_valid()
3891 struct btf *btf = env->btf; in btf_check_all_types() local
3900 for (type_id = 1; type_id <= btf->nr_types; type_id++) { in btf_check_all_types()
3901 const struct btf_type *t = btf_type_by_id(btf, type_id); in btf_check_all_types()
3929 const struct btf_header *hdr = &env->btf->hdr; in btf_parse_type_sec()
3953 struct btf *btf = env->btf; in btf_parse_str_sec() local
3956 hdr = &btf->hdr; in btf_parse_str_sec()
3957 start = btf->nohdr_data + hdr->str_off; in btf_parse_str_sec()
3960 if (end != btf->data + btf->data_size) { in btf_parse_str_sec()
3971 btf->strings = start; in btf_parse_str_sec()
3995 const struct btf *btf; in btf_check_sec_info() local
3997 btf = env->btf; in btf_check_sec_info()
3998 hdr = &btf->hdr; in btf_check_sec_info()
4046 struct btf *btf; in btf_parse_hdr() local
4049 btf = env->btf; in btf_parse_hdr()
4050 btf_data_size = btf->data_size; in btf_parse_hdr()
4058 hdr = btf->data; in btf_parse_hdr()
4066 if (hdr_len > sizeof(btf->hdr)) { in btf_parse_hdr()
4067 u8 *expected_zero = btf->data + sizeof(btf->hdr); in btf_parse_hdr()
4068 u8 *end = btf->data + hdr_len; in btf_parse_hdr()
4078 hdr_copy = min_t(u32, hdr_len, sizeof(btf->hdr)); in btf_parse_hdr()
4079 memcpy(&btf->hdr, btf->data, hdr_copy); in btf_parse_hdr()
4081 hdr = &btf->hdr; in btf_parse_hdr()
4112 static struct btf *btf_parse(void __user *btf_data, u32 btf_data_size, in btf_parse()
4117 struct btf *btf = NULL; in btf_parse() local
4145 btf = kzalloc(sizeof(*btf), GFP_KERNEL | __GFP_NOWARN); in btf_parse()
4146 if (!btf) { in btf_parse()
4150 env->btf = btf; in btf_parse()
4158 btf->data = data; in btf_parse()
4159 btf->data_size = btf_data_size; in btf_parse()
4170 btf->nohdr_data = btf->data + btf->hdr.hdr_len; in btf_parse()
4186 refcount_set(&btf->refcnt, 1); in btf_parse()
4187 return btf; in btf_parse()
4191 if (btf) in btf_parse()
4192 btf_free(btf); in btf_parse()
4198 extern struct btf *btf_vmlinux;
4231 btf_get_prog_ctx_type(struct bpf_verifier_log *log, struct btf *btf, in btf_get_prog_ctx_type() argument
4245 t = btf_type_by_id(btf, t->type); in btf_get_prog_ctx_type()
4247 t = btf_type_by_id(btf, t->type); in btf_get_prog_ctx_type()
4258 tname = btf_name_by_offset(btf, t->name_off); in btf_get_prog_ctx_type()
4301 static int btf_vmlinux_map_ids_init(const struct btf *btf, in btf_vmlinux_map_ids_init() argument
4315 btf_id = btf_find_by_name_kind(btf, ops->map_btf_name, in btf_vmlinux_map_ids_init()
4326 struct btf *btf, in btf_translate_to_vmlinux() argument
4333 prog_ctx_type = btf_get_prog_ctx_type(log, btf, t, prog_type, arg); in btf_translate_to_vmlinux()
4343 struct btf *btf_parse_vmlinux(void) in BTF_ID()
4347 struct btf *btf = NULL; in BTF_ID() local
4357 btf = kzalloc(sizeof(*btf), GFP_KERNEL | __GFP_NOWARN); in BTF_ID()
4358 if (!btf) { in BTF_ID()
4362 env->btf = btf; in BTF_ID()
4364 btf->data = __start_BTF; in BTF_ID()
4365 btf->data_size = __stop_BTF - __start_BTF; in BTF_ID()
4371 btf->nohdr_data = btf->data + btf->hdr.hdr_len; in BTF_ID()
4382 bpf_ctx_convert.t = btf_type_by_id(btf, bpf_ctx_convert_btf_id[0]); in BTF_ID()
4385 err = btf_vmlinux_map_ids_init(btf, log); in BTF_ID()
4389 bpf_struct_ops_init(btf, log); in BTF_ID()
4392 refcount_set(&btf->refcnt, 1); in BTF_ID()
4393 return btf; in BTF_ID()
4397 if (btf) { in BTF_ID()
4398 kvfree(btf->types); in BTF_ID()
4399 kfree(btf); in BTF_ID()
4404 struct btf *bpf_prog_get_target_btf(const struct bpf_prog *prog) in bpf_prog_get_target_btf()
4409 return tgt_prog->aux->btf; in bpf_prog_get_target_btf()
4415 static bool is_string_ptr(struct btf *btf, const struct btf_type *t) in is_string_ptr() argument
4418 t = btf_type_by_id(btf, t->type); in is_string_ptr()
4422 t = btf_type_by_id(btf, t->type); in is_string_ptr()
4434 struct btf *btf = bpf_prog_get_target_btf(prog); in btf_ctx_access() local
4481 t = btf_type_by_id(btf, t->type); in btf_ctx_access()
4490 t = btf_type_skip_modifiers(btf, t->type, NULL); in btf_ctx_access()
4507 t = btf_type_by_id(btf, args[arg].type); in btf_ctx_access()
4512 t = btf_type_by_id(btf, t->type); in btf_ctx_access()
4520 __btf_name_by_offset(btf, t->name_off), in btf_ctx_access()
4544 if (is_string_ptr(btf, t)) in btf_ctx_access()
4567 ret = btf_translate_to_vmlinux(log, btf, t, tgt_type, arg); in btf_ctx_access()
4577 t = btf_type_by_id(btf, t->type); in btf_ctx_access()
4581 t = btf_type_by_id(btf, t->type); in btf_ctx_access()
4591 __btf_name_by_offset(btf, t->name_off)); in btf_ctx_access()
4900 static int __get_type_size(struct btf *btf, u32 btf_id, in __get_type_size() argument
4908 t = btf_type_by_id(btf, btf_id); in __get_type_size()
4910 t = btf_type_by_id(btf, t->type); in __get_type_size()
4912 *bad_type = btf->types[0]; in __get_type_size()
4925 struct btf *btf, in btf_distill_func_proto() argument
4953 ret = __get_type_size(btf, func->type, &t); in btf_distill_func_proto()
4963 ret = __get_type_size(btf, args[i].type, &t); in btf_distill_func_proto()
4985 struct btf *btf1, const struct btf_type *t1, in btf_check_func_type_match()
4986 struct btf *btf2, const struct btf_type *t2) in btf_check_func_type_match()
5096 struct btf *btf2, const struct btf_type *t2) in btf_check_type_match()
5098 struct btf *btf1 = prog->aux->btf; in btf_check_type_match()
5130 struct btf *btf = prog->aux->btf; in btf_check_func_arg_match() local
5146 t = btf_type_by_id(btf, btf_id); in btf_check_func_arg_match()
5155 tname = btf_name_by_offset(btf, t->name_off); in btf_check_func_arg_match()
5157 t = btf_type_by_id(btf, t->type); in btf_check_func_arg_match()
5172 t = btf_type_by_id(btf, args[i].type); in btf_check_func_arg_match()
5174 t = btf_type_by_id(btf, t->type); in btf_check_func_arg_match()
5189 if (btf_get_prog_ctx_type(log, btf, t, prog->type, i)) { in btf_check_func_arg_match()
5228 struct btf *btf = prog->aux->btf; in btf_prepare_func_args() local
5246 t = btf_type_by_id(btf, btf_id); in btf_prepare_func_args()
5255 tname = btf_name_by_offset(btf, t->name_off); in btf_prepare_func_args()
5268 t = btf_type_by_id(btf, t->type); in btf_prepare_func_args()
5281 t = btf_type_by_id(btf, t->type); in btf_prepare_func_args()
5283 t = btf_type_by_id(btf, t->type); in btf_prepare_func_args()
5294 t = btf_type_by_id(btf, args[i].type); in btf_prepare_func_args()
5296 t = btf_type_by_id(btf, t->type); in btf_prepare_func_args()
5302 btf_get_prog_ctx_type(log, btf, t, prog_type, i)) { in btf_prepare_func_args()
5313 static void btf_type_show(const struct btf *btf, u32 type_id, void *obj, in btf_type_show() argument
5316 const struct btf_type *t = btf_type_by_id(btf, type_id); in btf_type_show()
5318 show->btf = btf; in btf_type_show()
5322 btf_type_ops(t)->show(btf, t, type_id, obj, 0, show); in btf_type_show()
5331 int btf_type_seq_show_flags(const struct btf *btf, u32 type_id, in btf_type_seq_show_flags() argument
5340 btf_type_show(btf, type_id, obj, &sseq); in btf_type_seq_show_flags()
5345 void btf_type_seq_show(const struct btf *btf, u32 type_id, void *obj, in btf_type_seq_show() argument
5348 (void) btf_type_seq_show_flags(btf, type_id, obj, m, in btf_type_seq_show()
5381 int btf_type_snprintf_show(const struct btf *btf, u32 type_id, void *obj, in btf_type_snprintf_show() argument
5392 btf_type_show(btf, type_id, obj, (struct btf_show *)&ssnprintf); in btf_type_snprintf_show()
5405 const struct btf *btf = filp->private_data; in bpf_btf_show_fdinfo() local
5407 seq_printf(m, "btf_id:\t%u\n", btf->id); in bpf_btf_show_fdinfo()
5424 static int __btf_new_fd(struct btf *btf) in __btf_new_fd() argument
5426 return anon_inode_getfd("btf", &btf_fops, btf, O_RDONLY | O_CLOEXEC); in __btf_new_fd()
5431 struct btf *btf; in btf_new_fd() local
5434 btf = btf_parse(u64_to_user_ptr(attr->btf), in btf_new_fd()
5438 if (IS_ERR(btf)) in btf_new_fd()
5439 return PTR_ERR(btf); in btf_new_fd()
5441 ret = btf_alloc_id(btf); in btf_new_fd()
5443 btf_free(btf); in btf_new_fd()
5453 ret = __btf_new_fd(btf); in btf_new_fd()
5455 btf_put(btf); in btf_new_fd()
5460 struct btf *btf_get_by_fd(int fd) in btf_get_by_fd()
5462 struct btf *btf; in btf_get_by_fd() local
5475 btf = f.file->private_data; in btf_get_by_fd()
5476 refcount_inc(&btf->refcnt); in btf_get_by_fd()
5479 return btf; in btf_get_by_fd()
5482 int btf_get_info_by_fd(const struct btf *btf, in btf_get_info_by_fd() argument
5500 info.id = btf->id; in btf_get_info_by_fd()
5501 ubtf = u64_to_user_ptr(info.btf); in btf_get_info_by_fd()
5502 btf_copy = min_t(u32, btf->data_size, info.btf_size); in btf_get_info_by_fd()
5503 if (copy_to_user(ubtf, btf->data, btf_copy)) in btf_get_info_by_fd()
5505 info.btf_size = btf->data_size; in btf_get_info_by_fd()
5516 struct btf *btf; in btf_get_fd_by_id() local
5520 btf = idr_find(&btf_idr, id); in btf_get_fd_by_id()
5521 if (!btf || !refcount_inc_not_zero(&btf->refcnt)) in btf_get_fd_by_id()
5522 btf = ERR_PTR(-ENOENT); in btf_get_fd_by_id()
5525 if (IS_ERR(btf)) in btf_get_fd_by_id()
5526 return PTR_ERR(btf); in btf_get_fd_by_id()
5528 fd = __btf_new_fd(btf); in btf_get_fd_by_id()
5530 btf_put(btf); in btf_get_fd_by_id()
5535 u32 btf_id(const struct btf *btf) in btf_id() argument
5537 return btf->id; in btf_id()