• Home
  • Raw
  • Download

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()
617 static bool __btf_name_valid(const struct btf *btf, u32 offset) in __btf_name_valid() argument
620 const char *src = &btf->strings[offset]; in __btf_name_valid()
638 static bool btf_name_valid_identifier(const struct btf *btf, u32 offset) in btf_name_valid_identifier() argument
640 return __btf_name_valid(btf, offset); in btf_name_valid_identifier()
643 static bool btf_name_valid_section(const struct btf *btf, u32 offset) in btf_name_valid_section() argument
645 return __btf_name_valid(btf, offset); in btf_name_valid_section()
648 static const char *__btf_name_by_offset(const struct btf *btf, u32 offset) in __btf_name_by_offset() argument
652 else if (offset < btf->hdr.str_len) in __btf_name_by_offset()
653 return &btf->strings[offset]; in __btf_name_by_offset()
658 const char *btf_name_by_offset(const struct btf *btf, u32 offset) in btf_name_by_offset() argument
660 if (offset < btf->hdr.str_len) in btf_name_by_offset()
661 return &btf->strings[offset]; in btf_name_by_offset()
666 const struct btf_type *btf_type_by_id(const struct btf *btf, u32 type_id) in btf_type_by_id() argument
668 if (type_id > btf->nr_types) in btf_type_by_id()
671 return btf->types[type_id]; in btf_type_by_id()
701 bool btf_member_is_reg_int(const struct btf *btf, const struct btf_type *s, in btf_member_is_reg_int() argument
710 t = btf_type_id_size(btf, &id, NULL); in btf_member_is_reg_int()
739 static const struct btf_type *btf_type_skip_qualifiers(const struct btf *btf, in btf_type_skip_qualifiers() argument
742 const struct btf_type *t = btf_type_by_id(btf, id); in btf_type_skip_qualifiers()
747 t = btf_type_by_id(btf, t->type); in btf_type_skip_qualifiers()
793 member = btf_name_by_offset(show->btf, m->name_off); in btf_show_name()
805 t = btf_type_by_id(show->btf, id); in btf_show_name()
836 name = btf_name_by_offset(show->btf, in btf_show_name()
863 t = btf_type_skip_qualifiers(show->btf, id); in btf_show_name()
870 name = btf_name_by_offset(show->btf, t->name_off); in btf_show_name()
1058 rt = btf_resolve_size(show->btf, t, &size); in btf_show_obj_safe()
1251 struct btf *btf = env->btf; in __btf_verifier_log_type() local
1267 __btf_name_by_offset(btf, t->name_off), in __btf_verifier_log_type()
1295 struct btf *btf = env->btf; in btf_verifier_log_member() local
1315 __btf_name_by_offset(btf, member->name_off), in btf_verifier_log_member()
1321 __btf_name_by_offset(btf, member->name_off), in btf_verifier_log_member()
1366 const struct btf *btf = env->btf; in btf_verifier_log_hdr() local
1374 hdr = &btf->hdr; in btf_verifier_log_hdr()
1388 struct btf *btf = env->btf; in btf_add_type() local
1394 if (btf->types_size - btf->nr_types < 2) { in btf_add_type()
1400 if (btf->types_size == BTF_MAX_TYPE) { in btf_add_type()
1405 expand_by = max_t(u32, btf->types_size >> 2, 16); in btf_add_type()
1407 btf->types_size + expand_by); in btf_add_type()
1414 if (btf->nr_types == 0) in btf_add_type()
1417 memcpy(new_types, btf->types, in btf_add_type()
1418 sizeof(*btf->types) * (btf->nr_types + 1)); in btf_add_type()
1420 kvfree(btf->types); in btf_add_type()
1421 btf->types = new_types; in btf_add_type()
1422 btf->types_size = new_size; in btf_add_type()
1425 btf->types[++(btf->nr_types)] = t; in btf_add_type()
1430 static int btf_alloc_id(struct btf *btf) in btf_alloc_id() argument
1436 id = idr_alloc_cyclic(&btf_idr, btf, 1, INT_MAX, GFP_ATOMIC); in btf_alloc_id()
1438 btf->id = id; in btf_alloc_id()
1448 static void btf_free_id(struct btf *btf) in btf_free_id() argument
1462 idr_remove(&btf_idr, btf->id); in btf_free_id()
1466 static void btf_free(struct btf *btf) in btf_free() argument
1468 kvfree(btf->types); in btf_free()
1469 kvfree(btf->resolved_sizes); in btf_free()
1470 kvfree(btf->resolved_ids); in btf_free()
1471 kvfree(btf->data); in btf_free()
1472 kfree(btf); in btf_free()
1477 struct btf *btf = container_of(rcu, struct btf, rcu); in btf_free_rcu() local
1479 btf_free(btf); in btf_free_rcu()
1482 void btf_put(struct btf *btf) in btf_put() argument
1484 if (btf && refcount_dec_and_test(&btf->refcnt)) { in btf_put()
1485 btf_free_id(btf); in btf_put()
1486 call_rcu(&btf->rcu, btf_free_rcu); in btf_put()
1492 struct btf *btf = env->btf; in env_resolve_init() local
1493 u32 nr_types = btf->nr_types; in env_resolve_init()
1514 btf->resolved_sizes = resolved_sizes; in env_resolve_init()
1515 btf->resolved_ids = resolved_ids; in env_resolve_init()
1603 struct btf *btf = env->btf; in env_stack_pop_resolved() local
1605 btf->resolved_sizes[type_id] = resolved_size; in env_stack_pop_resolved()
1606 btf->resolved_ids[type_id] = resolved_type_id; in env_stack_pop_resolved()
1636 __btf_resolve_size(const struct btf *btf, const struct btf_type *type, in __btf_resolve_size() argument
1664 type = btf_type_by_id(btf, type->type); in __btf_resolve_size()
1674 type = btf_type_by_id(btf, array->type); in __btf_resolve_size()
1703 btf_resolve_size(const struct btf *btf, const struct btf_type *type, in btf_resolve_size() argument
1706 return __btf_resolve_size(btf, type, type_size, NULL, NULL, NULL, NULL); in btf_resolve_size()
1710 static const struct btf_type *btf_type_id_resolve(const struct btf *btf, in btf_type_id_resolve() argument
1713 *type_id = btf->resolved_ids[*type_id]; in btf_type_id_resolve()
1714 return btf_type_by_id(btf, *type_id); in btf_type_id_resolve()
1717 const struct btf_type *btf_type_id_size(const struct btf *btf, in btf_type_id_size() argument
1724 size_type = btf_type_by_id(btf, size_type_id); in btf_type_id_size()
1731 size = btf->resolved_sizes[size_type_id]; in btf_type_id_size()
1739 size_type_id = btf->resolved_ids[size_type_id]; in btf_type_id_size()
1740 size_type = btf_type_by_id(btf, size_type_id); in btf_type_id_size()
1746 size = btf->resolved_sizes[size_type_id]; in btf_type_id_size()
1809 static void btf_df_show(const struct btf *btf, const struct btf_type *t, in btf_df_show() argument
2077 static void btf_int_bits_show(const struct btf *btf, in btf_int_bits_show() argument
2096 static void btf_int_show(const struct btf *btf, const struct btf_type *t, in btf_int_show() argument
2112 btf_int_bits_show(btf, t, safe_data, bits_offset, show); in btf_int_show()
2159 btf_int_bits_show(btf, t, safe_data, bits_offset, show); in btf_int_show()
2183 struct btf *btf = env->btf; in btf_modifier_check_member() local
2185 resolved_type = btf_type_id_size(btf, &resolved_type_id, NULL); in btf_modifier_check_member()
2208 struct btf *btf = env->btf; in btf_modifier_check_kflag_member() local
2210 resolved_type = btf_type_id_size(btf, &resolved_type_id, NULL); in btf_modifier_check_kflag_member()
2275 !btf_name_valid_identifier(env->btf, t->name_off)) { in btf_ref_type_check_meta()
2297 struct btf *btf = env->btf; in btf_modifier_resolve() local
2299 next_type = btf_type_by_id(btf, next_type_id); in btf_modifier_resolve()
2315 if (!btf_type_id_size(btf, &next_type_id, NULL)) { in btf_modifier_resolve()
2317 next_type = btf_type_id_resolve(btf, &next_type_id); in btf_modifier_resolve()
2339 struct btf *btf = env->btf; in btf_var_resolve() local
2341 next_type = btf_type_by_id(btf, next_type_id); in btf_var_resolve()
2356 resolved_type = btf_type_id_resolve(btf, &resolved_type_id); in btf_var_resolve()
2369 if (!btf_type_id_size(btf, &next_type_id, NULL)) { in btf_var_resolve()
2385 struct btf *btf = env->btf; in btf_ptr_resolve() local
2387 next_type = btf_type_by_id(btf, next_type_id); in btf_ptr_resolve()
2410 resolved_type = btf_type_id_resolve(btf, &resolved_type_id); in btf_ptr_resolve()
2419 if (!btf_type_id_size(btf, &next_type_id, NULL)) { in btf_ptr_resolve()
2421 next_type = btf_type_id_resolve(btf, &next_type_id); in btf_ptr_resolve()
2436 static void btf_modifier_show(const struct btf *btf, in btf_modifier_show() argument
2441 if (btf->resolved_ids) in btf_modifier_show()
2442 t = btf_type_id_resolve(btf, &type_id); in btf_modifier_show()
2444 t = btf_type_skip_modifiers(btf, type_id, NULL); in btf_modifier_show()
2446 btf_type_ops(t)->show(btf, t, type_id, data, bits_offset, show); in btf_modifier_show()
2449 static void btf_var_show(const struct btf *btf, const struct btf_type *t, in btf_var_show() argument
2453 t = btf_type_id_resolve(btf, &type_id); in btf_var_show()
2455 btf_type_ops(t)->show(btf, t, type_id, data, bits_offset, show); in btf_var_show()
2458 static void btf_ptr_show(const struct btf *btf, const struct btf_type *t, in btf_ptr_show() argument
2516 !btf_name_valid_identifier(env->btf, t->name_off)) { in btf_fwd_check_meta()
2549 struct btf *btf = env->btf; in btf_array_check_member() local
2558 btf_type_id_size(btf, &array_type_id, &array_size); in btf_array_check_member()
2629 struct btf *btf = env->btf; in btf_array_resolve() local
2634 index_type = btf_type_by_id(btf, index_type_id); in btf_array_resolve()
2645 index_type = btf_type_id_size(btf, &index_type_id, NULL); in btf_array_resolve()
2654 elem_type = btf_type_by_id(btf, elem_type_id); in btf_array_resolve()
2666 elem_type = btf_type_id_size(btf, &elem_type_id, &elem_size); in btf_array_resolve()
2697 static void __btf_array_show(const struct btf *btf, const struct btf_type *t, in __btf_array_show() argument
2708 elem_type = btf_type_skip_modifiers(btf, elem_type_id, NULL); in __btf_array_show()
2737 elem_ops->show(btf, elem_type, elem_type_id, data, in __btf_array_show()
2750 static void btf_array_show(const struct btf *btf, const struct btf_type *t, in btf_array_show() argument
2766 __btf_array_show(btf, t, type_id, data, bits_offset, show); in btf_array_show()
2780 __btf_array_show(btf, t, type_id, data, bits_offset, show); in btf_array_show()
2824 struct btf *btf = env->btf; in btf_struct_check_meta() local
2839 !btf_name_valid_identifier(env->btf, t->name_off)) { in btf_struct_check_meta()
2848 if (!btf_name_offset_valid(btf, member->name_off)) { in btf_struct_check_meta()
2857 !btf_name_valid_identifier(btf, member->name_off)) { in btf_struct_check_meta()
2920 last_member_type = btf_type_by_id(env->btf, in btf_struct_resolve()
2936 const struct btf_type *member_type = btf_type_by_id(env->btf, in btf_struct_resolve()
2979 int btf_find_spin_lock(const struct btf *btf, const struct btf_type *t) in btf_find_spin_lock() argument
2988 const struct btf_type *member_type = btf_type_by_id(btf, in btf_find_spin_lock()
2994 if (strcmp(__btf_name_by_offset(btf, member_type->name_off), in btf_find_spin_lock()
3012 static void __btf_struct_show(const struct btf *btf, const struct btf_type *t, in __btf_struct_show() argument
3025 const struct btf_type *member_type = btf_type_by_id(btf, in __btf_struct_show()
3049 ops->show(btf, member_type, member->type, in __btf_struct_show()
3059 static void btf_struct_show(const struct btf *btf, const struct btf_type *t, in btf_struct_show() argument
3075 __btf_struct_show(btf, t, type_id, data, bits_offset, show); in btf_struct_show()
3090 __btf_struct_show(btf, t, type_id, data, bits_offset, show); in btf_struct_show()
3167 struct btf *btf = env->btf; in btf_enum_check_meta() local
3193 !btf_name_valid_identifier(env->btf, t->name_off)) { in btf_enum_check_meta()
3201 if (!btf_name_offset_valid(btf, enums[i].name_off)) { in btf_enum_check_meta()
3209 !btf_name_valid_identifier(btf, enums[i].name_off)) { in btf_enum_check_meta()
3217 __btf_name_by_offset(btf, enums[i].name_off), in btf_enum_check_meta()
3230 static void btf_enum_show(const struct btf *btf, const struct btf_type *t, in btf_enum_show() argument
3250 __btf_name_by_offset(btf, in btf_enum_show()
3317 __btf_name_by_offset(env->btf, in btf_func_proto_log()
3321 __btf_name_by_offset(env->btf, in btf_func_proto_log()
3329 __btf_name_by_offset(env->btf, in btf_func_proto_log()
3362 !btf_name_valid_identifier(env->btf, t->name_off)) { in btf_func_check_meta()
3416 !__btf_name_valid(env->btf, t->name_off)) { in btf_var_check_meta()
3487 !btf_name_valid_section(env->btf, t->name_off)) { in btf_datasec_check_meta()
3537 struct btf *btf = env->btf; in btf_datasec_resolve() local
3543 const struct btf_type *var_type = btf_type_by_id(env->btf, in btf_datasec_resolve()
3558 if (!btf_type_id_size(btf, &type_id, &type_size)) { in btf_datasec_resolve()
3579 static void btf_datasec_show(const struct btf *btf, in btf_datasec_show() argument
3592 __btf_name_by_offset(btf, t->name_off)); in btf_datasec_show()
3594 var = btf_type_by_id(btf, vsi->type); in btf_datasec_show()
3597 btf_type_ops(var)->show(btf, var, vsi->type, in btf_datasec_show()
3617 const struct btf *btf; in btf_func_proto_check() local
3621 btf = env->btf; in btf_func_proto_check()
3629 ret_type = btf_type_by_id(btf, ret_type_id); in btf_func_proto_check()
3643 if (!btf_type_id_size(btf, &ret_type_id, NULL)) { in btf_func_proto_check()
3668 arg_type = btf_type_by_id(btf, arg_type_id); in btf_func_proto_check()
3681 (!btf_name_offset_valid(btf, args[i].name_off) || in btf_func_proto_check()
3682 !btf_name_valid_identifier(btf, args[i].name_off))) { in btf_func_proto_check()
3696 if (!btf_type_id_size(btf, &arg_type_id, NULL)) { in btf_func_proto_check()
3711 const struct btf *btf; in btf_func_check() local
3714 btf = env->btf; in btf_func_check()
3715 proto_type = btf_type_by_id(btf, t->type); in btf_func_check()
3779 if (!btf_name_offset_valid(env->btf, t->name_off)) { in btf_check_meta()
3796 struct btf *btf = env->btf; in btf_check_all_metas() local
3800 hdr = &btf->hdr; in btf_check_all_metas()
3801 cur = btf->nohdr_data + hdr->type_off; in btf_check_all_metas()
3825 struct btf *btf = env->btf; in btf_resolve_valid() local
3831 return !btf->resolved_ids[type_id] && in btf_resolve_valid()
3832 !btf->resolved_sizes[type_id]; in btf_resolve_valid()
3836 t = btf_type_id_resolve(btf, &type_id); in btf_resolve_valid()
3849 elem_type = btf_type_id_size(btf, &elem_type_id, &elem_size); in btf_resolve_valid()
3852 btf->resolved_sizes[type_id]); in btf_resolve_valid()
3893 struct btf *btf = env->btf; in btf_check_all_types() local
3902 for (type_id = 1; type_id <= btf->nr_types; type_id++) { in btf_check_all_types()
3903 const struct btf_type *t = btf_type_by_id(btf, type_id); in btf_check_all_types()
3931 const struct btf_header *hdr = &env->btf->hdr; in btf_parse_type_sec()
3955 struct btf *btf = env->btf; in btf_parse_str_sec() local
3958 hdr = &btf->hdr; in btf_parse_str_sec()
3959 start = btf->nohdr_data + hdr->str_off; in btf_parse_str_sec()
3962 if (end != btf->data + btf->data_size) { in btf_parse_str_sec()
3973 btf->strings = start; in btf_parse_str_sec()
3997 const struct btf *btf; in btf_check_sec_info() local
3999 btf = env->btf; in btf_check_sec_info()
4000 hdr = &btf->hdr; in btf_check_sec_info()
4048 struct btf *btf; in btf_parse_hdr() local
4051 btf = env->btf; in btf_parse_hdr()
4052 btf_data_size = btf->data_size; in btf_parse_hdr()
4060 hdr = btf->data; in btf_parse_hdr()
4068 if (hdr_len > sizeof(btf->hdr)) { in btf_parse_hdr()
4069 u8 *expected_zero = btf->data + sizeof(btf->hdr); in btf_parse_hdr()
4070 u8 *end = btf->data + hdr_len; in btf_parse_hdr()
4080 hdr_copy = min_t(u32, hdr_len, sizeof(btf->hdr)); in btf_parse_hdr()
4081 memcpy(&btf->hdr, btf->data, hdr_copy); in btf_parse_hdr()
4083 hdr = &btf->hdr; in btf_parse_hdr()
4114 static struct btf *btf_parse(void __user *btf_data, u32 btf_data_size, in btf_parse()
4119 struct btf *btf = NULL; in btf_parse() local
4146 btf = kzalloc(sizeof(*btf), GFP_KERNEL | __GFP_NOWARN); in btf_parse()
4147 if (!btf) { in btf_parse()
4151 env->btf = btf; in btf_parse()
4159 btf->data = data; in btf_parse()
4160 btf->data_size = btf_data_size; in btf_parse()
4171 btf->nohdr_data = btf->data + btf->hdr.hdr_len; in btf_parse()
4187 refcount_set(&btf->refcnt, 1); in btf_parse()
4188 return btf; in btf_parse()
4192 if (btf) in btf_parse()
4193 btf_free(btf); in btf_parse()
4199 extern struct btf *btf_vmlinux;
4232 btf_get_prog_ctx_type(struct bpf_verifier_log *log, struct btf *btf, in btf_get_prog_ctx_type() argument
4246 t = btf_type_by_id(btf, t->type); in btf_get_prog_ctx_type()
4248 t = btf_type_by_id(btf, t->type); in btf_get_prog_ctx_type()
4259 tname = btf_name_by_offset(btf, t->name_off); in btf_get_prog_ctx_type()
4311 static int btf_vmlinux_map_ids_init(const struct btf *btf, in btf_vmlinux_map_ids_init() argument
4325 btf_id = btf_find_by_name_kind(btf, ops->map_btf_name, in btf_vmlinux_map_ids_init()
4336 struct btf *btf, in btf_translate_to_vmlinux() argument
4343 prog_ctx_type = btf_get_prog_ctx_type(log, btf, t, prog_type, arg); in btf_translate_to_vmlinux()
4353 struct btf *btf_parse_vmlinux(void) in BTF_ID()
4357 struct btf *btf = NULL; in BTF_ID() local
4367 btf = kzalloc(sizeof(*btf), GFP_KERNEL | __GFP_NOWARN); in BTF_ID()
4368 if (!btf) { in BTF_ID()
4372 env->btf = btf; in BTF_ID()
4374 btf->data = __start_BTF; in BTF_ID()
4375 btf->data_size = __stop_BTF - __start_BTF; in BTF_ID()
4381 btf->nohdr_data = btf->data + btf->hdr.hdr_len; in BTF_ID()
4392 bpf_ctx_convert.t = btf_type_by_id(btf, bpf_ctx_convert_btf_id[0]); in BTF_ID()
4395 err = btf_vmlinux_map_ids_init(btf, log); in BTF_ID()
4399 bpf_struct_ops_init(btf, log); in BTF_ID()
4402 refcount_set(&btf->refcnt, 1); in BTF_ID()
4403 return btf; in BTF_ID()
4407 if (btf) { in BTF_ID()
4408 kvfree(btf->types); in BTF_ID()
4409 kfree(btf); in BTF_ID()
4414 struct btf *bpf_prog_get_target_btf(const struct bpf_prog *prog) in bpf_prog_get_target_btf()
4419 return tgt_prog->aux->btf; in bpf_prog_get_target_btf()
4425 static bool is_string_ptr(struct btf *btf, const struct btf_type *t) in is_string_ptr() argument
4428 t = btf_type_by_id(btf, t->type); in is_string_ptr()
4432 t = btf_type_by_id(btf, t->type); in is_string_ptr()
4444 struct btf *btf = bpf_prog_get_target_btf(prog); in btf_ctx_access() local
4491 t = btf_type_by_id(btf, t->type); in btf_ctx_access()
4500 t = btf_type_skip_modifiers(btf, t->type, NULL); in btf_ctx_access()
4517 t = btf_type_by_id(btf, args[arg].type); in btf_ctx_access()
4522 t = btf_type_by_id(btf, t->type); in btf_ctx_access()
4530 __btf_name_by_offset(btf, t->name_off), in btf_ctx_access()
4554 if (is_string_ptr(btf, t)) in btf_ctx_access()
4577 ret = btf_translate_to_vmlinux(log, btf, t, tgt_type, arg); in btf_ctx_access()
4587 t = btf_type_by_id(btf, t->type); in btf_ctx_access()
4591 t = btf_type_by_id(btf, t->type); in btf_ctx_access()
4601 __btf_name_by_offset(btf, t->name_off)); in btf_ctx_access()
4910 static int __get_type_size(struct btf *btf, u32 btf_id, in __get_type_size() argument
4918 t = btf_type_by_id(btf, btf_id); in __get_type_size()
4920 t = btf_type_by_id(btf, t->type); in __get_type_size()
4922 *bad_type = btf->types[0]; in __get_type_size()
4935 struct btf *btf, in btf_distill_func_proto() argument
4963 ret = __get_type_size(btf, func->type, &t); in btf_distill_func_proto()
4979 ret = __get_type_size(btf, args[i].type, &t); in btf_distill_func_proto()
5007 struct btf *btf1, const struct btf_type *t1, in btf_check_func_type_match()
5008 struct btf *btf2, const struct btf_type *t2) in btf_check_func_type_match()
5118 struct btf *btf2, const struct btf_type *t2) in btf_check_type_match()
5120 struct btf *btf1 = prog->aux->btf; in btf_check_type_match()
5152 struct btf *btf = prog->aux->btf; in btf_check_func_arg_match() local
5168 t = btf_type_by_id(btf, btf_id); in btf_check_func_arg_match()
5177 tname = btf_name_by_offset(btf, t->name_off); in btf_check_func_arg_match()
5179 t = btf_type_by_id(btf, t->type); in btf_check_func_arg_match()
5194 t = btf_type_by_id(btf, args[i].type); in btf_check_func_arg_match()
5196 t = btf_type_by_id(btf, t->type); in btf_check_func_arg_match()
5211 if (btf_get_prog_ctx_type(log, btf, t, prog->type, i)) { in btf_check_func_arg_match()
5250 struct btf *btf = prog->aux->btf; in btf_prepare_func_args() local
5268 t = btf_type_by_id(btf, btf_id); in btf_prepare_func_args()
5277 tname = btf_name_by_offset(btf, t->name_off); in btf_prepare_func_args()
5290 t = btf_type_by_id(btf, t->type); in btf_prepare_func_args()
5303 t = btf_type_by_id(btf, t->type); in btf_prepare_func_args()
5305 t = btf_type_by_id(btf, t->type); in btf_prepare_func_args()
5316 t = btf_type_by_id(btf, args[i].type); in btf_prepare_func_args()
5318 t = btf_type_by_id(btf, t->type); in btf_prepare_func_args()
5324 btf_get_prog_ctx_type(log, btf, t, prog_type, i)) { in btf_prepare_func_args()
5335 static void btf_type_show(const struct btf *btf, u32 type_id, void *obj, in btf_type_show() argument
5338 const struct btf_type *t = btf_type_by_id(btf, type_id); in btf_type_show()
5340 show->btf = btf; in btf_type_show()
5344 btf_type_ops(t)->show(btf, t, type_id, obj, 0, show); in btf_type_show()
5353 int btf_type_seq_show_flags(const struct btf *btf, u32 type_id, in btf_type_seq_show_flags() argument
5362 btf_type_show(btf, type_id, obj, &sseq); in btf_type_seq_show_flags()
5367 void btf_type_seq_show(const struct btf *btf, u32 type_id, void *obj, in btf_type_seq_show() argument
5370 (void) btf_type_seq_show_flags(btf, type_id, obj, m, in btf_type_seq_show()
5403 int btf_type_snprintf_show(const struct btf *btf, u32 type_id, void *obj, in btf_type_snprintf_show() argument
5414 btf_type_show(btf, type_id, obj, (struct btf_show *)&ssnprintf); in btf_type_snprintf_show()
5427 const struct btf *btf = filp->private_data; in bpf_btf_show_fdinfo() local
5429 seq_printf(m, "btf_id:\t%u\n", btf->id); in bpf_btf_show_fdinfo()
5446 static int __btf_new_fd(struct btf *btf) in __btf_new_fd() argument
5448 return anon_inode_getfd("btf", &btf_fops, btf, O_RDONLY | O_CLOEXEC); in __btf_new_fd()
5453 struct btf *btf; in btf_new_fd() local
5456 btf = btf_parse(u64_to_user_ptr(attr->btf), in btf_new_fd()
5460 if (IS_ERR(btf)) in btf_new_fd()
5461 return PTR_ERR(btf); in btf_new_fd()
5463 ret = btf_alloc_id(btf); in btf_new_fd()
5465 btf_free(btf); in btf_new_fd()
5475 ret = __btf_new_fd(btf); in btf_new_fd()
5477 btf_put(btf); in btf_new_fd()
5482 struct btf *btf_get_by_fd(int fd) in btf_get_by_fd()
5484 struct btf *btf; in btf_get_by_fd() local
5497 btf = f.file->private_data; in btf_get_by_fd()
5498 refcount_inc(&btf->refcnt); in btf_get_by_fd()
5501 return btf; in btf_get_by_fd()
5504 int btf_get_info_by_fd(const struct btf *btf, in btf_get_info_by_fd() argument
5522 info.id = btf->id; in btf_get_info_by_fd()
5523 ubtf = u64_to_user_ptr(info.btf); in btf_get_info_by_fd()
5524 btf_copy = min_t(u32, btf->data_size, info.btf_size); in btf_get_info_by_fd()
5525 if (copy_to_user(ubtf, btf->data, btf_copy)) in btf_get_info_by_fd()
5527 info.btf_size = btf->data_size; in btf_get_info_by_fd()
5538 struct btf *btf; in btf_get_fd_by_id() local
5542 btf = idr_find(&btf_idr, id); in btf_get_fd_by_id()
5543 if (!btf || !refcount_inc_not_zero(&btf->refcnt)) in btf_get_fd_by_id()
5544 btf = ERR_PTR(-ENOENT); in btf_get_fd_by_id()
5547 if (IS_ERR(btf)) in btf_get_fd_by_id()
5548 return PTR_ERR(btf); in btf_get_fd_by_id()
5550 fd = __btf_new_fd(btf); in btf_get_fd_by_id()
5552 btf_put(btf); in btf_get_fd_by_id()
5557 u32 btf_id(const struct btf *btf) in btf_id() argument
5559 return btf->id; in btf_id()