| /linux/tools/testing/selftests/bpf/prog_tests/ |
| H A D | linked_list.c | 252 static struct btf *init_btf(void) in init_btf() 255 struct btf *btf; in init_btf() local 257 btf = btf__new_empty(); in init_btf() 258 if (!ASSERT_OK_PTR(btf, "btf__new_empty")) in init_btf() 260 id = btf__add_int(btf, "int", 4, BTF_INT_SIGNED); in init_btf() 263 lid = btf__add_struct(btf, "bpf_spin_lock", 4); in init_btf() 266 hid = btf__add_struct(btf, "bpf_list_head", 16); in init_btf() 269 nid = btf__add_struct(btf, "bpf_list_node", 24); in init_btf() 272 return btf; in init_btf() 274 btf__free(btf); in init_btf() [all …]
|
| H A D | btf_write.c | 4 #include <bpf/btf.h> 7 static void gen_btf(struct btf *btf) in gen_btf() argument 17 str_off = btf__find_str(btf, "int"); in gen_btf() 20 str_off = btf__add_str(btf, "int"); in gen_btf() 23 str_off = btf__find_str(btf, "int"); in gen_btf() 27 id = btf__add_int(btf, "int", 4, BTF_INT_SIGNED); in gen_btf() 30 t = btf__type_by_id(btf, 1); in gen_btf() 33 ASSERT_STREQ(btf__str_by_offset(btf, t->name_off), "int", "int_name"); in gen_btf() 38 ASSERT_STREQ(btf_type_raw_dump(btf, in gen_btf() 357 struct btf *btf; test_btf_add() local [all...] |
| H A D | btf_dump.c | 3 #include <bpf/btf.h> 26 static int btf_dump_all_types(const struct btf *btf, void *ctx) in btf_dump_all_types() argument 28 size_t type_cnt = btf__type_cnt(btf); in btf_dump_all_types() 32 d = btf_dump__new(btf, btf_dump_printf, ctx, NULL); in btf_dump_all_types() 51 struct btf *btf = NULL; in test_btf_dump_case() local 57 btf = btf__parse_elf(test_file, NULL); in test_btf_dump_case() 58 if (!ASSERT_OK_PTR(btf, "btf_parse_elf")) { in test_btf_dump_case() 59 err = -PTR_ERR(btf); in test_btf_dump_case() 130 struct btf *btf; global() member 184 struct btf *btf; test_btf_dump_incremental() local 285 struct btf *btf; test_btf_dump_type_tags() local 339 btf_dump_data(struct btf * btf,struct btf_dump * d,char * name,char * prefix,__u64 flags,void * ptr,size_t ptr_sz,char * str,const char * expected_val) btf_dump_data() argument 420 test_btf_dump_int_data(struct btf * btf,struct btf_dump * d,char * str) test_btf_dump_int_data() argument 478 test_btf_dump_float_data(struct btf * btf,struct btf_dump * d,char * str) test_btf_dump_float_data() argument 523 test_btf_dump_char_data(struct btf * btf,struct btf_dump * d,char * str) test_btf_dump_char_data() argument 545 test_btf_dump_typedef_data(struct btf * btf,struct btf_dump * d,char * str) test_btf_dump_typedef_data() argument 600 test_btf_dump_enum_data(struct btf * btf,struct btf_dump * d,char * str) test_btf_dump_enum_data() argument 636 test_btf_dump_struct_data(struct btf * btf,struct btf_dump * d,char * str) test_btf_dump_struct_data() argument 871 test_btf_dump_var_data(struct btf * btf,struct btf_dump * d,char * str) test_btf_dump_var_data() argument 883 struct btf *btf; global() member 998 test_btf_datasec(struct btf * btf,struct btf_dump * d,char * str,const char * name,const char * expected_val,void * data,size_t data_sz) test_btf_datasec() argument 1026 struct btf *btf; test_btf_dump_datasec_data() local 1049 struct btf *btf; test_btf_dump() local [all...] |
| H A D | local_kptr_ownership.c | 14 static struct btf *init_btf(void) in init_btf() 16 struct btf *btf; in init_btf() local 19 btf = btf__new_empty(); in init_btf() 20 if (!ASSERT_OK_PTR(btf, "btf__new_empty")) in init_btf() 22 id = btf__add_int(btf, "int", 4, BTF_INT_SIGNED); in init_btf() 25 id = btf__add_struct(btf, "bpf_spin_lock", 4); in init_btf() 28 id = btf__add_struct(btf, "bpf_list_head", 16); in init_btf() 31 id = btf__add_struct(btf, "bpf_list_node", 24); in init_btf() 34 return btf; in init_btf() 37 btf__free(btf); in init_btf() [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() 50 btf__add_int(btf, "int", 4, BTF_INT_SIGNED); /* [1] int */ in test_btf_field_iter() 51 btf__add_int(btf, "int64", 8, BTF_INT_SIGNED); /* [2] int64 */ in test_btf_field_iter() 52 btf__add_ptr(btf, 1); /* [3] int * */ in test_btf_field_iter() 53 btf__add_array(btf, 1, 2, 3); /* [4] int64[3] */ in test_btf_field_iter() 54 btf__add_struct(btf, "s1", 12); /* [5] struct s1 { */ in test_btf_field_iter() 55 btf__add_field(btf, "f1", 3, 0, 0); /* int *f1; */ in test_btf_field_iter() 56 btf__add_field(btf, "f2", 1, 0, 0); /* int f2; */ in test_btf_field_iter() [all …]
|
| H A D | libbpf_str.c | 23 struct btf *btf; in test_libbpf_bpf_attach_type_str() local 28 btf = btf__parse("/sys/kernel/btf/vmlinux", NULL); in test_libbpf_bpf_attach_type_str() 29 if (!ASSERT_OK_PTR(btf, "btf_parse")) in test_libbpf_bpf_attach_type_str() 33 id = btf__find_by_name_kind(btf, "bpf_attach_type", BTF_KIND_ENUM); in test_libbpf_bpf_attach_type_str() 36 t = btf__type_by_id(btf, id); in test_libbpf_bpf_attach_type_str() 48 attach_type_name = btf__str_by_offset(btf, e->name_off); 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 73 btf = btf__parse("/sys/kernel/btf/vmlinux", NULL); in test_libbpf_bpf_link_type_str() 74 if (!ASSERT_OK_PTR(btf, "btf_parse")) in test_libbpf_bpf_link_type_str() [all …]
|
| H A D | resolve_btfids.c | 147 __resolve_symbol(struct btf *btf, int type_id) in BTF_ID() 153 type = btf__type_by_id(btf, type_id); in BTF_ID() 157 str = btf__name_by_offset(btf, type->name_off); in BTF_ID() 183 static int resolve_symbols(struct btf *btf) in resolve_symbols() argument 185 __u32 nr = btf__type_cnt(btf); in resolve_symbols() 189 if (__resolve_symbol(btf, type_id)) in resolve_symbols() 195 static bool btf_has_decl_tag(struct btf *btf, const char *tag_name, s32 target_id) in btf_has_decl_tag() argument 201 nr = btf__type_cnt(btf); in btf_has_decl_tag() 203 t = btf__type_by_id(btf, id); in btf_has_decl_tag() 210 name = btf__name_by_offset(btf, t->name_off); in btf_has_decl_tag() [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() 27 const char *prog_type_name = btf__str_by_offset(btf, e->name_off); 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() [all …]
|
| H A D | test_global_funcs.c | 27 static void check_ctx_arg_type(const struct btf *btf, const struct btf_param *p) in check_ctx_arg_type() 32 t = btf__type_by_id(btf, p->type); in check_ctx_arg_type() 36 s = btf_type_raw_dump(btf, t->type); in check_ctx_arg_type() 48 struct btf *btf = NULL; in subtest_ctx_arg_rewrite() 51 struct btf *kern_btf = NULL; in subtest_ctx_arg_rewrite() 88 btf = btf__load_from_kernel_by_id(info.btf_id); in subtest_ctx_arg_rewrite() 89 if (!ASSERT_OK_PTR(btf, "obj_kern_btf")) in subtest_ctx_arg_rewrite() 100 fn_t = btf__type_by_id(btf, re in subtest_ctx_arg_rewrite() 26 check_ctx_arg_type(const struct btf * btf,const struct btf_param * p) check_ctx_arg_type() argument 47 struct btf *btf = NULL; subtest_ctx_arg_rewrite() local [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() 71 var_id = btf__add_var(btf, "some_var", BTF_VAR_GLOBAL_ALLOCATED, 1); in test_btf_endian() 77 btf__set_endianness(btf, swap_endian); 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() 94 long_long_id = btf__add_int(btf, "unsigned long long", 8, 0); in test_core_autosize() 96 void_ptr_id = btf__add_ptr(btf, 0); in test_core_autosize() 99 id = btf__add_struct(btf, "test_struct", 20 /* bytes */); in test_core_autosize() [all …]
|
| H A D | btf_dedup_split.c | 4 #include <bpf/btf.h> 9 struct btf *btf1, *btf2; in test_split_simple() 143 struct btf *btf1, *btf2; in test_split_fwd_resolve() 241 struct btf *btf1, *btf2; in test_split_struct_duped() 348 static void btf_add_dup_struct_in_cu(struct btf *btf, int start_id) in btf_add_dup_struct_in_cu() 351 btf__set_pointer_size(btf, 8); /* enforce 64-bit arch */ in btf_add_dup_struct_in_cu() 353 btf__add_int(btf, "int", 4, BTF_INT_SIGNED); /* [1] int */ in btf_add_dup_struct_in_cu() 355 btf__add_struct(btf, "s", 8); /* [2] struct s { */ 356 btf__add_field(btf, " 332 btf_add_dup_struct_in_cu(struct btf * btf,int start_id) btf_add_dup_struct_in_cu() argument [all...] |
| /linux/tools/lib/bpf/ |
| H A D | btf.h | 24 struct btf; 39 LIBBPF_API void btf__free(struct btf *btf); 55 LIBBPF_API struct btf *btf__new(const void *data, __u32 size); 77 LIBBPF_API struct btf *btf__new_split(const void *data, __u32 size, struct btf *base_btf); 91 LIBBPF_API struct btf *btf__new_empty(void); 110 LIBBPF_API struct btf *btf__new_empty_split(struct btf *base_btf); 114 struct btf *base_btf; /* optional base BTF */ 130 LIBBPF_API struct btf *btf__new_empty_opts(struct btf_new_opts *opts); 154 LIBBPF_API int btf__distill_base(const struct btf *src_btf, struct btf **new_base_btf, 155 struct btf **new_split_btf); [all …]
|
| H A D | btf.c | 62 struct btf { struct 141 struct btf *base_btf; argument 253 static void *btf_add_type_offs_mem(struct btf *btf, size_t add_cnt) in btf_add_type_offs_mem() argument 255 return libbpf_add_mem((void **)&btf->type_offs, &btf->type_offs_cap, sizeof(__u32), in btf_add_type_offs_mem() 256 btf->nr_types, BTF_MAX_NR_TYPES, add_cnt); in btf_add_type_offs_mem() 259 static int btf_add_type_idx_entry(struct btf *btf, __u32 type_off) in btf_add_type_idx_entry() argument 263 p = btf_add_type_offs_mem(btf, 1); in btf_add_type_idx_entry() 286 static int btf_parse_hdr(struct btf *btf) in btf_parse_hdr() argument 288 struct btf_header *hdr = btf->raw_data; in btf_parse_hdr() 291 if (btf->raw_size < offsetofend(struct btf_header, str_len)) { in btf_parse_hdr() [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,
|
| /linux/include/linux/ |
| H A D | btf.h | 113 struct btf; 146 const char *btf_get_name(const struct btf *btf); 147 void btf_get(struct btf *btf); 148 void btf_put(struct btf *btf); 149 const struct btf_header *btf_header(const struct btf *btf); 152 struct btf *btf_get_by_fd(int fd); 153 int btf_get_info_by_fd(const struct btf *btf, 177 const struct btf_type *btf_type_id_size(const struct btf *btf, 198 void btf_type_seq_show(const struct btf *btf, u32 type_id, void *obj, 200 int btf_type_seq_show_flags(const struct btf *btf, u32 type_id, void *obj, [all …]
|
| /linux/kernel/bpf/ |
| H A D | btf.c | 254 struct btf { struct 276 struct btf *base_btf; argument 317 struct btf *btf; member 423 const struct btf *btf; member 462 void (*show)(const struct btf *btf, const struct btf_type *t, 500 static int btf_start_id(const struct btf *btf) in btf_start_id() argument 502 return btf->start_id + (btf->base_btf ? 0 : 1); in btf_start_id() 538 bool btf_is_vmlinux(const struct btf *btf) in btf_is_vmlinux() argument 540 return btf->kernel_btf && !btf->base_btf; in btf_is_vmlinux() 543 u32 btf_nr_types(const struct btf *btf) in btf_nr_types() argument [all …]
|
| H A D | check_btf.c | 40 const struct btf *btf; in prepare_btf_func() local 61 btf = prog->aux->btf; in prepare_btf_func() 108 type = btf_type_by_id(btf, krecord[i].type_id); in prepare_btf_func() 115 func_proto = btf_type_by_id(btf, type->type); in prepare_btf_func() 142 const struct btf *btf; in check_btf_func() local 161 btf = prog->aux->btf; in check_btf_func() 181 type = btf_type_by_id(btf, krecord[i].type_id); in check_btf_func() 184 func_proto = btf_type_by_id(btf, type->type); in check_btf_func() 186 ret_type = btf_type_skip_modifiers(btf, func_proto->type, NULL); in check_btf_func() 198 env->subprog_info[i].name = btf_name_by_offset(btf, type->name_off); in check_btf_func() [all …]
|
| H A D | bpf_struct_ops.c | 43 struct btf *btf; member 87 extern struct btf *btf_vmlinux; 89 static bool is_valid_value_type(struct btf *btf, s32 value_id, in is_valid_value_type() argument 97 vt = btf_type_by_id(btf, value_id); in is_valid_value_type() 104 mt = btf_type_by_id(btf, member->type); in is_valid_value_type() 113 mt = btf_type_by_id(btf, member->type); in is_valid_value_type() 116 value_name, btf_name_by_offset(btf, type->name_off)); in is_valid_value_type() 173 static int prepare_arg_info(struct btf *btf, in prepare_arg_info() argument 200 stub_func_id = btf_find_by_name_kind(btf, stub_fname, BTF_KIND_FUNC); in prepare_arg_info() 206 stub_func_proto = btf_type_by_id(btf, stub_func_id); in prepare_arg_info() [all …]
|
| /linux/tools/bpf/resolve_btfids/ |
| H A D | main.c | 143 struct btf *btf; member 144 struct btf *base_btf; 196 struct btf *btf; member 682 struct btf *base_btf = NULL, *btf = NULL; in load_btf() local 695 btf = btf__parse_split(obj->btf_path ?: obj->path, base_btf); in load_btf() 696 err = libbpf_get_error(btf); in load_btf() 704 obj->btf = btf; in load_btf() 710 btf__free(btf); in load_btf() 712 obj->btf = NULL; in load_btf() 722 struct btf *btf = obj->btf; in symbols_resolve() local [all …]
|
| /linux/tools/bpf/bpftool/ |
| H A D | btf.c | 108 static const char *btf_str(const struct btf *btf, __u32 off) in btf_str() argument 112 return btf__name_by_offset(btf, off) ? : "(invalid)"; in btf_str() 120 static int dump_btf_type(const struct btf *btf, __u32 id, in dump_btf_type() argument 130 jsonw_string_field(w, "name", btf_str(btf, t->name_off)); in dump_btf_type() 133 btf_str(btf, t->name_off)); in dump_btf_type() 193 const char *name = btf_str(btf, m->name_off); in dump_btf_type() 241 const char *name = btf_str(btf, v->name_off); in dump_btf_type() 278 const char *name = btf_str(btf, v->name_off); in dump_btf_type() 335 const char *name = btf_str(btf, p->name_off); in dump_btf_type() 388 if (v->type < btf__type_cnt(btf)) { in dump_btf_type() [all …]
|
| 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() 47 func_sig_len = btf_dump_func(d->btf, prog_str, func_proto, NULL, 0, in dump_prog_id_as_func_ptr() 118 ptr_type_id = btf__resolve_type(d->btf, t->type); in btf_dumper_ptr() 121 ptr_type = btf__type_by_id(d->btf, ptr_type_id); in btf_dumper_ptr() 140 actual_type_id = btf__resolve_type(d->btf, type_id); in btf_dumper_modifier() 175 btf__name_by_offset(d->btf, in btf_dumper_enum() 201 btf__name_by_offset(d->btf, in btf_dumper_enum64() 211 static bool is_str_array(const struct btf *btf, const struct btf_array *arr, in is_str_array() argument 220 elem_type = btf__type_by_id(btf, arr->type); in is_str_array() [all …]
|
| H A D | gen.c | 59 resolve_func_ptr(const struct btf *btf, __u32 id, __u32 *res_id) in resolve_func_ptr() argument 63 t = skip_mods_and_typedefs(btf, id, NULL); in resolve_func_ptr() 67 t = skip_mods_and_typedefs(btf, t->type, res_id); in resolve_func_ptr() 154 struct btf *btf, in codegen_datasec_def() argument 159 const char *sec_name = btf__name_by_offset(btf, sec->name_off); in codegen_datasec_def() 173 const struct btf_type *var = btf__type_by_id(btf, sec_var->type); in codegen_datasec_def() 174 const char *var_name = btf__name_by_offset(btf, var->name_off); in codegen_datasec_def() 193 align = btf__align_of(btf, var->type); in codegen_datasec_def() 241 static const struct btf_type *find_type_for_map(struct btf *btf, const char *map_ident) in find_type_for_map() argument 243 int n = btf__type_cnt(btf), i; in find_type_for_map() [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 85 return btf__str_by_offset(btf, off) ?: "(invalid)"; in btf_str() 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() 101 fprintf(out, "[%u] %s '%s'", id, btf_kind_str(kind), btf_str(btf, t->name_off)); in fprintf_btf_type_raw() 135 btf_str(btf, m->name_off), m->type, bit_off); 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 [all …]
|