/linux/tools/testing/selftests/bpf/prog_tests/ |
H A D | linked_list.c | 252 struct btf *btf; in init_btf() local 269 return btf; in init_btf() 271 btf__free(btf); in init_btf() 278 struct btf *btf; in list_and_rb_node_same_struct() local 325 btf__free(btf); in list_and_rb_node_same_struct() 330 struct btf *btf = NULL; in test_btf() local 352 btf__free(btf); in test_btf() 378 btf__free(btf); in test_btf() 404 btf__free(btf); in test_btf() 424 btf__free(btf); in test_btf() [all …]
|
H A D | btf_write.c | 7 static void gen_btf(struct btf *btf) in gen_btf() argument 30 t = btf__type_by_id(btf, 1); in gen_btf() 55 id = btf__add_ptr(btf, 1); in gen_btf() 57 t = btf__type_by_id(btf, 2); in gen_btf() 65 t = btf__type_by_id(btf, 3); in gen_btf() 73 t = btf__type_by_id(btf, 4); in gen_btf() 357 struct btf *btf; in test_btf_add() local 359 btf = btf__new_empty(); in test_btf_add() 363 gen_btf(btf); in test_btf_add() 366 btf, in test_btf_add() [all …]
|
H A D | btf_dump.c | 26 static int btf_dump_all_types(const struct btf *btf, void *ctx) in btf_dump_all_types() argument 51 struct btf *btf = NULL; in test_btf_dump_case() local 60 btf = NULL; in test_btf_dump_case() 125 btf__free(btf); in test_btf_dump_case() 135 struct btf *btf = NULL; in test_btf_dump_incremental() local 255 btf__free(btf); in test_btf_dump_incremental() 269 static int btf_dump_data(struct btf *btf, struct btf_dump *d, in btf_dump_data() argument 840 struct btf *btf; in test_btf_dump_datasec_data() local 857 btf__free(btf); in test_btf_dump_datasec_data() 863 struct btf *btf; in test_btf_dump() local [all …]
|
H A D | btf_field_iter.c | 43 struct btf *btf = NULL; in test_btf_field_iter() local 46 btf = btf__new_empty(); in test_btf_field_iter() 47 if (!ASSERT_OK_PTR(btf, "empty_btf")) in test_btf_field_iter() 52 btf__add_ptr(btf, 1); /* [3] int * */ in test_btf_field_iter() 73 btf__add_func_param(btf, "p1", 1); in test_btf_field_iter() 74 btf__add_func_param(btf, "p2", 3); in test_btf_field_iter() 88 btf__add_datasec_var_info(btf, 15, 0, 4); in test_btf_field_iter() 89 btf__add_datasec_var_info(btf, 16, 4, 8); in test_btf_field_iter() 92 btf, in test_btf_field_iter() 128 for (id = 1; id < btf__type_cnt(btf); id++) { in test_btf_field_iter() [all …]
|
H A D | libbpf_str.c | 23 struct btf *btf; in test_libbpf_bpf_attach_type_str() local 36 t = btf__type_by_id(btf, id); in test_libbpf_bpf_attach_type_str() 59 btf__free(btf); in test_libbpf_bpf_attach_type_str() 68 struct btf *btf; in test_libbpf_bpf_link_type_str() local 81 t = btf__type_by_id(btf, id); in test_libbpf_bpf_link_type_str() 104 btf__free(btf); in test_libbpf_bpf_link_type_str() 113 struct btf *btf; in test_libbpf_bpf_map_type_str() local 126 t = btf__type_by_id(btf, id); in test_libbpf_bpf_map_type_str() 161 btf__free(btf); in test_libbpf_bpf_map_type_str() 170 struct btf *btf; in test_libbpf_bpf_prog_type_str() local [all …]
|
H A D | test_global_funcs.c | 26 static void check_ctx_arg_type(const struct btf *btf, const struct btf_param *p) in check_ctx_arg_type() argument 31 t = btf__type_by_id(btf, p->type); in check_ctx_arg_type() 35 s = btf_type_raw_dump(btf, t->type); in check_ctx_arg_type() 47 struct btf *btf = NULL; in subtest_ctx_arg_rewrite() local 50 struct btf *kern_btf = NULL; in subtest_ctx_arg_rewrite() 87 btf = btf__load_from_kernel_by_id(info.btf_id); in subtest_ctx_arg_rewrite() 88 if (!ASSERT_OK_PTR(btf, "obj_kern_btf")) in subtest_ctx_arg_rewrite() 99 fn_t = btf__type_by_id(btf, rec->type_id); in subtest_ctx_arg_rewrite() 104 proto_t = btf__type_by_id(btf, fn_t->type); in subtest_ctx_arg_rewrite() 108 name = btf__name_by_offset(btf, fn_t->name_off); in subtest_ctx_arg_rewrite() [all …]
|
H A D | libbpf_probes.c | 9 struct btf *btf; in test_libbpf_probe_prog_types() local 14 btf = btf__parse("/sys/kernel/btf/vmlinux", NULL); in test_libbpf_probe_prog_types() 15 if (!ASSERT_OK_PTR(btf, "btf_parse")) in test_libbpf_probe_prog_types() 19 id = btf__find_by_name_kind(btf, "bpf_prog_type", BTF_KIND_ENUM); in test_libbpf_probe_prog_types() 22 t = btf__type_by_id(btf, id); in test_libbpf_probe_prog_types() 44 btf__free(btf); in test_libbpf_probe_prog_types() 49 struct btf *btf; in test_libbpf_probe_map_types() local 54 btf = btf__parse("/sys/kernel/btf/vmlinux", NULL); in test_libbpf_probe_map_types() 55 if (!ASSERT_OK_PTR(btf, "btf_parse")) in test_libbpf_probe_map_types() 62 t = btf__type_by_id(btf, id); in test_libbpf_probe_map_types() [all …]
|
H A D | btf_endian.c | 18 struct btf *btf = NULL, *swap_btf = NULL; in test_btf_endian() local 26 btf = btf__parse_elf("btf_dump_test_case_syntax.bpf.o", NULL); in test_btf_endian() 27 if (!ASSERT_OK_PTR(btf, "parse_native_btf")) in test_btf_endian() 30 ASSERT_EQ(btf__endianness(btf), endian, "endian"); in test_btf_endian() 31 btf__set_endianness(btf, swap_endian); in test_btf_endian() 32 ASSERT_EQ(btf__endianness(btf), swap_endian, "endian"); in test_btf_endian() 35 raw_data = btf__raw_data(btf, &raw_sz); in test_btf_endian() 45 ASSERT_EQ(btf__type_cnt(swap_btf), btf__type_cnt(btf), "nr_types"); in test_btf_endian() 77 btf__set_endianness(btf, swap_endian); in test_btf_endian() 78 raw_data = btf__raw_data(btf, &raw_sz); in test_btf_endian() [all …]
|
H A D | core_autosize.c | 60 struct btf *btf = NULL; in test_core_autosize() local 66 btf = btf__new_empty(); in test_core_autosize() 67 if (!ASSERT_OK_PTR(btf, "empty_btf")) in test_core_autosize() 85 btf__set_pointer_size(btf, 4); in test_core_autosize() 87 char_id = btf__add_int(btf, "unsigned char", 1, 0); in test_core_autosize() 89 short_id = btf__add_int(btf, "unsigned short", 2, 0); in test_core_autosize() 92 int_id = btf__add_int(btf, "long unsigned int", 4, 0); in test_core_autosize() 96 void_ptr_id = btf__add_ptr(btf, 0); in test_core_autosize() 101 err = btf__add_field(btf, "ptr", void_ptr_id, 0, 0); in test_core_autosize() 115 raw_data = btf__raw_data(btf, &raw_sz); in test_core_autosize() [all …]
|
H A D | btf_dedup_split.c | 9 struct btf *btf1, *btf2; in test_split_simple() 127 struct btf *btf1, *btf2; in test_split_fwd_resolve() 225 struct btf *btf1, *btf2; in test_split_struct_duped() 332 static void btf_add_dup_struct_in_cu(struct btf *btf, int start_id) in btf_add_dup_struct_in_cu() argument 335 btf__set_pointer_size(btf, 8); /* enforce 64-bit arch */ in btf_add_dup_struct_in_cu() 337 btf__add_int(btf, "int", 4, BTF_INT_SIGNED); /* [1] int */ in btf_add_dup_struct_in_cu() 345 btf__add_field(btf, "f1", ID(1), 0, 0); /* int f1; */ in btf_add_dup_struct_in_cu() 346 btf__add_field(btf, "f2", ID(1), 32, 0); /* int f2; */ in btf_add_dup_struct_in_cu() 350 btf__add_field(btf, "f1", ID(1), 0, 0); /* int f1; */ in btf_add_dup_struct_in_cu() 351 btf__add_field(btf, "f2", ID(1), 32, 0); /* int f2; */ in btf_add_dup_struct_in_cu() [all …]
|
H A D | resolve_btfids.c | 66 __resolve_symbol(struct btf *btf, int type_id) in BTF_ID() 72 type = btf__type_by_id(btf, type_id); in BTF_ID() 85 str = btf__name_by_offset(btf, type->name_off); in BTF_ID() 100 struct btf *btf; in resolve_symbols() local 104 btf = btf__parse_elf("btf_data.bpf.o", NULL); in resolve_symbols() 105 if (CHECK(libbpf_get_error(btf), "resolve", in resolve_symbols() 109 nr = btf__type_cnt(btf); in resolve_symbols() 112 if (__resolve_symbol(btf, type_id)) in resolve_symbols() 116 btf__free(btf); in resolve_symbols()
|
/linux/tools/lib/bpf/ |
H A D | btf.h | 24 struct btf; 39 LIBBPF_API void btf__free(struct btf *btf); 145 LIBBPF_API int btf__load_into_kernel(struct btf *btf); 150 LIBBPF_API __u32 btf__type_cnt(const struct btf *btf); 151 LIBBPF_API const struct btf *btf__base_btf(const struct btf *btf); 161 LIBBPF_API int btf__fd(const struct btf *btf); 162 LIBBPF_API void btf__set_fd(struct btf *btf, int fd); 173 LIBBPF_API int btf__add_type(struct btf *btf, const struct btf *src_btf, 196 LIBBPF_API int btf__add_btf(struct btf *btf, const struct btf *src_btf); 201 LIBBPF_API int btf__add_array(struct btf *btf, [all …]
|
H A D | btf.c | 982 struct btf *btf; in btf_new_empty() local 1033 struct btf *btf; in btf_new() local 1064 btf->strs_data = btf->raw_data + btf->hdr->hdr_len + btf->hdr->str_off; in btf_new() 1065 btf->types_data = btf->raw_data + btf->hdr->hdr_len + btf->hdr->type_off; in btf_new() 1350 struct btf *btf; in btf_parse() local 1530 struct btf *btf = (struct btf *)btf_ro; in btf__raw_data() local 1570 struct btf *btf; in btf_get_from_fd() local 1621 struct btf *btf; in btf__load_from_kernel_by_id_split() local 3353 struct btf *btf; member 3471 d->btf = btf; in btf_dedup_new() [all …]
|
H A D | relo_core.h | 10 const struct btf *btf; member 30 const struct btf *btf; member 71 int __bpf_core_types_are_compat(const struct btf *local_btf, __u32 local_id, 72 const struct btf *targ_btf, __u32 targ_id, int level); 73 int bpf_core_types_are_compat(const struct btf *local_btf, __u32 local_id, 74 const struct btf *targ_btf, __u32 targ_id); 75 int __bpf_core_types_match(const struct btf *local_btf, __u32 local_id, const struct btf *targ_btf, 77 int bpf_core_types_match(const struct btf *local_btf, __u32 local_id, const struct btf *targ_btf, 84 const struct btf *local_btf, 93 int bpf_core_parse_spec(const char *prog_name, const struct btf *btf,
|
H A D | relo_core.c | 22 skip_mods_and_typedefs(const struct btf *btf, u32 id, u32 *res_id) in skip_mods_and_typedefs() argument 27 static const char *btf__name_by_offset(const struct btf *btf, u32 offset) in btf__name_by_offset() argument 32 static s64 btf__resolve_size(const struct btf *btf, u32 type_id) in btf__resolve_size() argument 37 t = btf_type_by_id(btf, type_id); in btf__resolve_size() 38 t = btf_resolve_size(btf, t, &size); in btf__resolve_size() 71 static bool is_flex_arr(const struct btf *btf, in is_flex_arr() argument 263 int bpf_core_parse_spec(const char *prog_name, const struct btf *btf, in bpf_core_parse_spec() argument 279 spec->btf = btf; in bpf_core_parse_spec() 329 sz = btf__resolve_size(btf, id); in bpf_core_parse_spec() 483 const struct btf *targ_btf, in bpf_core_match_member() [all …]
|
/linux/include/linux/ |
H A D | btf.h | 141 void btf_get(struct btf *btf); 142 void btf_put(struct btf *btf); 146 int btf_get_info_by_fd(const struct btf *btf, 213 u32 btf_obj_id(const struct btf *btf); 214 bool btf_is_kernel(const struct btf *btf); 215 bool btf_is_module(const struct btf *btf); 216 bool btf_is_vmlinux(const struct btf *btf); 218 u32 btf_nr_types(const struct btf *btf); 219 struct btf *btf_base_btf(const struct btf *btf); 555 void btf_set_base_btf(struct btf *btf, const struct btf *base_btf); [all …]
|
/linux/kernel/bpf/ |
H A D | btf.c | 1443 struct btf *btf = env->btf; in __btf_verifier_log_type() local 1493 struct btf *btf = env->btf; in btf_verifier_log_member() local 1593 struct btf *btf = env->btf; in btf_add_type() local 1791 struct btf *btf = env->btf; in env_resolve_init() local 1907 struct btf *btf = env->btf; in env_stack_pop_resolved() local 2507 struct btf *btf = env->btf; in btf_modifier_check_member() local 2532 struct btf *btf = env->btf; in btf_modifier_check_kflag_member() local 2629 struct btf *btf = env->btf; in btf_modifier_resolve() local 2671 struct btf *btf = env->btf; in btf_var_resolve() local 2717 struct btf *btf = env->btf; in btf_ptr_resolve() local [all …]
|
H A D | bpf_struct_ops.c | 42 struct btf *btf; member 88 static bool is_valid_value_type(struct btf *btf, s32 value_id, in is_valid_value_type() argument 158 find_stub_func_proto(const struct btf *btf, const char *st_op_name, in find_stub_func_proto() argument 202 static int prepare_arg_info(struct btf *btf, in prepare_arg_info() argument 277 info->btf = btf; in prepare_arg_info() 313 struct btf *btf, in bpf_struct_ops_desc_init() argument 906 struct btf *btf; in bpf_struct_ops_map_alloc() local 915 btf_put(btf); in bpf_struct_ops_map_alloc() 923 btf_put(btf); in bpf_struct_ops_map_alloc() 930 if (!btf) in bpf_struct_ops_map_alloc() [all …]
|
/linux/tools/testing/selftests/bpf/ |
H A D | btf_helpers.h | 9 int fprintf_btf_type_raw(FILE *out, const struct btf *btf, __u32 id); 10 const char *btf_type_raw_dump(const struct btf *btf, int type_id); 11 int btf_validate_raw(struct btf *btf, int nr_types, const char *exp_types[]); 13 #define VALIDATE_RAW_BTF(btf, raw_types...) \ argument 14 btf_validate_raw(btf, \ 18 const char *btf_type_c_dump(const struct btf *btf);
|
H A D | btf_helpers.c | 81 static const char *btf_str(const struct btf *btf, __u32 off) in btf_str() argument 88 int fprintf_btf_type_raw(FILE *out, const struct btf *btf, __u32 id) in fprintf_btf_type_raw() argument 94 t = btf__type_by_id(btf, id); in fprintf_btf_type_raw() 150 btf_str(btf, v->name_off), v->val); in fprintf_btf_type_raw() 164 btf_str(btf, v->name_off), in fprintf_btf_type_raw() 181 btf_str(btf, p->name_off), p->type); in fprintf_btf_type_raw() 216 const char *btf_type_raw_dump(const struct btf *btf, int type_id) in btf_type_raw_dump() argument 227 fprintf_btf_type_raw(buf_file, btf, type_id); in btf_type_raw_dump() 234 int btf_validate_raw(struct btf *btf, int nr_types, const char *exp_types[]) in btf_validate_raw() argument 257 const char *btf_type_c_dump(const struct btf *btf) in btf_type_c_dump() argument [all …]
|
/linux/tools/bpf/bpftool/ |
H A D | btf_dumper.c | 27 static int btf_dump_func(const struct btf *btf, char *func_sig, 40 struct btf *prog_btf = NULL; in dump_prog_id_as_func_ptr() 175 btf__name_by_offset(d->btf, in btf_dumper_enum() 211 static bool is_str_array(const struct btf *btf, const struct btf_array *arr, in is_str_array() argument 619 static int __btf_dumper_type_only(const struct btf *btf, __u32 type_id, in __btf_dumper_type_only() argument 710 static int btf_dump_func(const struct btf *btf, char *func_sig, in btf_dump_func() argument 747 void btf_dumper_type_only(const struct btf *btf, __u32 type_id, char *func_sig, in btf_dumper_type_only() argument 753 if (!btf) in btf_dumper_type_only() 769 void btf_dump_linfo_plain(const struct btf *btf, in btf_dump_linfo_plain() argument 801 void btf_dump_linfo_json(const struct btf *btf, in btf_dump_linfo_json() argument [all …]
|
H A D | gen.c | 148 struct btf *btf, in codegen_datasec_def() argument 277 struct btf *btf = bpf_object__btf(obj); in codegen_datasecs() local 326 struct btf *btf = bpf_object__btf(obj); in codegen_subskel_datasecs() local 499 struct btf *btf = bpf_object__btf(obj); in codegen_asserts() local 506 if (!btf) in codegen_asserts() 1112 if (!btf) in gen_st_ops_shadow() 1177 struct btf *btf; in do_skeleton() local 1582 struct btf *btf; in do_subskeleton() local 2107 struct btf *btf = info->src_btf; in btfgen_record_field_relo() local 2170 struct btf *btf = info->src_btf; in btfgen_mark_type_match() local [all …]
|
H A D | btf.c | 99 static const char *btf_str(const struct btf *btf, __u32 off) in btf_str() argument 111 static int dump_btf_type(const struct btf *btf, __u32 id, in dump_btf_type() argument 427 static int dump_btf_raw(const struct btf *btf, in dump_btf_raw() argument 602 static struct sort_datum *sort_btf_c(const struct btf *btf) in sort_btf_c() argument 627 static int dump_btf_c(const struct btf *btf, in dump_btf_c() argument 691 struct btf *base; in get_vmlinux_btf_from_sysfs() 733 struct btf *btf = NULL, *base = NULL; in do_dump() local 814 if (!btf) { in do_dump() 856 if (!btf) { in do_dump() 864 if (!btf) { in do_dump() [all …]
|
H A D | main.h | 85 extern struct btf *base_btf; 112 struct btf; 179 const struct btf *btf, 188 const struct btf *btf, in disasm_print_insn() argument 210 const struct btf *btf; member 225 void btf_dumper_type_only(const struct btf *btf, __u32 func_type_id, 228 void btf_dump_linfo_plain(const struct btf *btf, 231 void btf_dump_linfo_json(const struct btf *btf, 233 void btf_dump_linfo_dotlabel(const struct btf *btf,
|
/linux/kernel/bpf/preload/iterators/ |
H A D | iterators.bpf.c | 34 struct btf { struct 46 struct btf *btf; member 59 static const char *get_name(struct btf *btf, long btf_id, const char *fallback) in get_name() argument 65 if (!btf) in get_name() 67 str = btf->strings; in get_name() 68 types = btf->types; in get_name() 71 if (name_off >= btf->hdr.str_len) in get_name() 114 get_name(aux->btf, aux->func_info[0].type_id, aux->name), in dump_bpf_prog()
|