• Home
  • Raw
  • Download

Lines Matching refs:ext

1524 static int set_kcfg_value_tri(struct extern_desc *ext, void *ext_val,  in set_kcfg_value_tri()  argument
1527 switch (ext->kcfg.type) { in set_kcfg_value_tri()
1531 ext->name, value); in set_kcfg_value_tri()
1552 ext->name, value); in set_kcfg_value_tri()
1555 ext->is_set = true; in set_kcfg_value_tri()
1559 static int set_kcfg_value_str(struct extern_desc *ext, char *ext_val, in set_kcfg_value_str() argument
1564 if (ext->kcfg.type != KCFG_CHAR_ARR) { in set_kcfg_value_str()
1565 pr_warn("extern (kcfg) %s=%s should be char array\n", ext->name, value); in set_kcfg_value_str()
1572 ext->name, value); in set_kcfg_value_str()
1578 if (len >= ext->kcfg.sz) { in set_kcfg_value_str()
1580 ext->name, value, len, ext->kcfg.sz - 1); in set_kcfg_value_str()
1581 len = ext->kcfg.sz - 1; in set_kcfg_value_str()
1585 ext->is_set = true; in set_kcfg_value_str()
1608 static bool is_kcfg_value_in_range(const struct extern_desc *ext, __u64 v) in is_kcfg_value_in_range() argument
1610 int bit_sz = ext->kcfg.sz * 8; in is_kcfg_value_in_range()
1612 if (ext->kcfg.sz == 8) in is_kcfg_value_in_range()
1627 if (ext->kcfg.is_signed) in is_kcfg_value_in_range()
1633 static int set_kcfg_value_num(struct extern_desc *ext, void *ext_val, in set_kcfg_value_num() argument
1636 if (ext->kcfg.type != KCFG_INT && ext->kcfg.type != KCFG_CHAR) { in set_kcfg_value_num()
1638 ext->name, (unsigned long long)value); in set_kcfg_value_num()
1641 if (!is_kcfg_value_in_range(ext, value)) { in set_kcfg_value_num()
1643 ext->name, (unsigned long long)value, ext->kcfg.sz); in set_kcfg_value_num()
1646 switch (ext->kcfg.sz) { in set_kcfg_value_num()
1654 ext->is_set = true; in set_kcfg_value_num()
1661 struct extern_desc *ext; in bpf_object__process_kconfig_line() local
1688 ext = find_extern_by_name(obj, buf); in bpf_object__process_kconfig_line()
1689 if (!ext || ext->is_set) in bpf_object__process_kconfig_line()
1692 ext_val = data + ext->kcfg.data_off; in bpf_object__process_kconfig_line()
1697 err = set_kcfg_value_tri(ext, ext_val, *value); in bpf_object__process_kconfig_line()
1700 err = set_kcfg_value_str(ext, ext_val, value); in bpf_object__process_kconfig_line()
1707 ext->name, value); in bpf_object__process_kconfig_line()
1710 err = set_kcfg_value_num(ext, ext_val, num); in bpf_object__process_kconfig_line()
1715 pr_debug("extern (kcfg) %s=%s\n", ext->name, value); in bpf_object__process_kconfig_line()
1786 struct extern_desc *last_ext = NULL, *ext; in bpf_object__init_kconfig_map() local
1791 ext = &obj->externs[i]; in bpf_object__init_kconfig_map()
1792 if (ext->type == EXT_KCFG) in bpf_object__init_kconfig_map()
1793 last_ext = ext; in bpf_object__init_kconfig_map()
2657 const struct extern_desc *ext; in obj_needs_vmlinux_btf() local
2659 ext = &obj->externs[i]; in obj_needs_vmlinux_btf()
2660 if (ext->type == EXT_KSYM && ext->ksym.type_id) in obj_needs_vmlinux_btf()
3315 struct extern_desc *ext; in bpf_object__collect_externs() local
3346 ext = obj->externs; in bpf_object__collect_externs()
3347 ext = libbpf_reallocarray(ext, obj->nr_extern + 1, sizeof(*ext)); in bpf_object__collect_externs()
3348 if (!ext) in bpf_object__collect_externs()
3350 obj->externs = ext; in bpf_object__collect_externs()
3351 ext = &ext[obj->nr_extern]; in bpf_object__collect_externs()
3352 memset(ext, 0, sizeof(*ext)); in bpf_object__collect_externs()
3355 ext->btf_id = find_extern_btf_id(obj->btf, ext_name); in bpf_object__collect_externs()
3356 if (ext->btf_id <= 0) { in bpf_object__collect_externs()
3358 ext_name, ext->btf_id); in bpf_object__collect_externs()
3359 return ext->btf_id; in bpf_object__collect_externs()
3361 t = btf__type_by_id(obj->btf, ext->btf_id); in bpf_object__collect_externs()
3362 ext->name = btf__name_by_offset(obj->btf, t->name_off); in bpf_object__collect_externs()
3363 ext->sym_idx = i; in bpf_object__collect_externs()
3364 ext->is_weak = GELF_ST_BIND(sym.st_info) == STB_WEAK; in bpf_object__collect_externs()
3366 ext->sec_btf_id = find_extern_sec_btf_id(obj->btf, ext->btf_id); in bpf_object__collect_externs()
3367 if (ext->sec_btf_id <= 0) { in bpf_object__collect_externs()
3369 ext_name, ext->btf_id, ext->sec_btf_id); in bpf_object__collect_externs()
3370 return ext->sec_btf_id; in bpf_object__collect_externs()
3372 sec = (void *)btf__type_by_id(obj->btf, ext->sec_btf_id); in bpf_object__collect_externs()
3378 ext->name, KCONFIG_SEC); in bpf_object__collect_externs()
3382 ext->type = EXT_KCFG; in bpf_object__collect_externs()
3383 ext->kcfg.sz = btf__resolve_size(obj->btf, t->type); in bpf_object__collect_externs()
3384 if (ext->kcfg.sz <= 0) { in bpf_object__collect_externs()
3386 ext_name, ext->kcfg.sz); in bpf_object__collect_externs()
3387 return ext->kcfg.sz; in bpf_object__collect_externs()
3389 ext->kcfg.align = btf__align_of(obj->btf, t->type); in bpf_object__collect_externs()
3390 if (ext->kcfg.align <= 0) { in bpf_object__collect_externs()
3392 ext_name, ext->kcfg.align); in bpf_object__collect_externs()
3395 ext->kcfg.type = find_kcfg_type(obj->btf, t->type, in bpf_object__collect_externs()
3396 &ext->kcfg.is_signed); in bpf_object__collect_externs()
3397 if (ext->kcfg.type == KCFG_UNKNOWN) { in bpf_object__collect_externs()
3402 if (btf_is_func(t) && ext->is_weak) { in bpf_object__collect_externs()
3404 ext->name); in bpf_object__collect_externs()
3408 ext->type = EXT_KSYM; in bpf_object__collect_externs()
3410 &ext->ksym.type_id); in bpf_object__collect_externs()
3422 qsort(obj->externs, obj->nr_extern, sizeof(*ext), cmp_externs); in bpf_object__collect_externs()
3442 ext = &obj->externs[i]; in bpf_object__collect_externs()
3443 if (ext->type != EXT_KSYM) in bpf_object__collect_externs()
3446 i, ext->sym_idx, ext->name); in bpf_object__collect_externs()
3457 ext = find_extern_by_name(obj, ext_name); in bpf_object__collect_externs()
3458 if (!ext) { in bpf_object__collect_externs()
3496 ext = &obj->externs[i]; in bpf_object__collect_externs()
3497 if (ext->type != EXT_KCFG) in bpf_object__collect_externs()
3500 ext->kcfg.data_off = roundup(off, ext->kcfg.align); in bpf_object__collect_externs()
3501 off = ext->kcfg.data_off + ext->kcfg.sz; in bpf_object__collect_externs()
3503 i, ext->sym_idx, ext->kcfg.data_off, ext->name); in bpf_object__collect_externs()
3512 ext = find_extern_by_name(obj, ext_name); in bpf_object__collect_externs()
3513 if (!ext) { in bpf_object__collect_externs()
3519 vs->offset = ext->kcfg.data_off; in bpf_object__collect_externs()
3623 struct extern_desc *ext; in bpf_program__record_reloc() local
3626 ext = &obj->externs[i]; in bpf_program__record_reloc()
3627 if (ext->sym_idx == sym_idx) in bpf_program__record_reloc()
3636 prog->name, i, ext->name, ext->sym_idx, insn_idx); in bpf_program__record_reloc()
5306 struct extern_desc *ext; in bpf_object__relocate_data() local
5329 ext = &obj->externs[relo->sym_off]; in bpf_object__relocate_data()
5330 if (ext->type == EXT_KCFG) { in bpf_object__relocate_data()
5338 insn[1].imm = ext->kcfg.data_off; in bpf_object__relocate_data()
5340 if (ext->ksym.type_id && ext->is_set) { /* typed ksyms */ in bpf_object__relocate_data()
5342 insn[0].imm = ext->ksym.kernel_btf_id; in bpf_object__relocate_data()
5343 insn[1].imm = ext->ksym.kernel_btf_obj_fd; in bpf_object__relocate_data()
5345 insn[0].imm = (__u32)ext->ksym.addr; in bpf_object__relocate_data()
5346 insn[1].imm = ext->ksym.addr >> 32; in bpf_object__relocate_data()
5351 ext = &obj->externs[relo->sym_off]; in bpf_object__relocate_data()
5353 insn[0].imm = ext->ksym.kernel_btf_id; in bpf_object__relocate_data()
6239 struct extern_desc *ext = &obj->externs[relo->sym_off]; in bpf_program__record_externs() local
6243 if (ext->type != EXT_KSYM) in bpf_program__record_externs()
6245 if (!ext->ksym.type_id) { in bpf_program__record_externs()
6247 ext->name); in bpf_program__record_externs()
6250 bpf_gen__record_extern(obj->gen_loader, ext->name, BTF_KIND_VAR, in bpf_program__record_externs()
6254 bpf_gen__record_extern(obj->gen_loader, ext->name, BTF_KIND_FUNC, in bpf_program__record_externs()
6598 struct extern_desc *ext; in bpf_object__read_kallsyms_file() local
6620 ext = find_extern_by_name(obj, sym_name); in bpf_object__read_kallsyms_file()
6621 if (!ext || ext->type != EXT_KSYM) in bpf_object__read_kallsyms_file()
6624 t = btf__type_by_id(obj->btf, ext->btf_id); in bpf_object__read_kallsyms_file()
6628 if (ext->is_set && ext->ksym.addr != sym_addr) { in bpf_object__read_kallsyms_file()
6630 sym_name, ext->ksym.addr, sym_addr); in bpf_object__read_kallsyms_file()
6634 if (!ext->is_set) { in bpf_object__read_kallsyms_file()
6635 ext->is_set = true; in bpf_object__read_kallsyms_file()
6636 ext->ksym.addr = sym_addr; in bpf_object__read_kallsyms_file()
6680 struct extern_desc *ext) in bpf_object__resolve_ksym_var_btf_id() argument
6688 id = find_ksym_btf_id(obj, ext->name, BTF_KIND_VAR, &btf, &btf_fd); in bpf_object__resolve_ksym_var_btf_id()
6689 if (id == -ESRCH && ext->is_weak) { in bpf_object__resolve_ksym_var_btf_id()
6693 ext->name); in bpf_object__resolve_ksym_var_btf_id()
6698 local_type_id = ext->ksym.type_id; in bpf_object__resolve_ksym_var_btf_id()
6716 ext->name, local_type_id, in bpf_object__resolve_ksym_var_btf_id()
6722 ext->is_set = true; in bpf_object__resolve_ksym_var_btf_id()
6723 ext->ksym.kernel_btf_obj_fd = btf_fd; in bpf_object__resolve_ksym_var_btf_id()
6724 ext->ksym.kernel_btf_id = id; in bpf_object__resolve_ksym_var_btf_id()
6726 ext->name, id, btf_kind_str(targ_var), targ_var_name); in bpf_object__resolve_ksym_var_btf_id()
6732 struct extern_desc *ext) in bpf_object__resolve_ksym_func_btf_id() argument
6739 local_func_proto_id = ext->ksym.type_id; in bpf_object__resolve_ksym_func_btf_id()
6741 kfunc_id = find_ksym_btf_id(obj, ext->name, BTF_KIND_FUNC, in bpf_object__resolve_ksym_func_btf_id()
6745 ext->name); in bpf_object__resolve_ksym_func_btf_id()
6751 ext->name); in bpf_object__resolve_ksym_func_btf_id()
6762 ext->name, local_func_proto_id, kfunc_proto_id); in bpf_object__resolve_ksym_func_btf_id()
6766 ext->is_set = true; in bpf_object__resolve_ksym_func_btf_id()
6767 ext->ksym.kernel_btf_obj_fd = kern_btf_fd; in bpf_object__resolve_ksym_func_btf_id()
6768 ext->ksym.kernel_btf_id = kfunc_id; in bpf_object__resolve_ksym_func_btf_id()
6770 ext->name, kfunc_id); in bpf_object__resolve_ksym_func_btf_id()
6778 struct extern_desc *ext; in bpf_object__resolve_ksyms_btf_id() local
6782 ext = &obj->externs[i]; in bpf_object__resolve_ksyms_btf_id()
6783 if (ext->type != EXT_KSYM || !ext->ksym.type_id) in bpf_object__resolve_ksyms_btf_id()
6787 ext->is_set = true; in bpf_object__resolve_ksyms_btf_id()
6788 ext->ksym.kernel_btf_obj_fd = 0; in bpf_object__resolve_ksyms_btf_id()
6789 ext->ksym.kernel_btf_id = 0; in bpf_object__resolve_ksyms_btf_id()
6792 t = btf__type_by_id(obj->btf, ext->btf_id); in bpf_object__resolve_ksyms_btf_id()
6794 err = bpf_object__resolve_ksym_var_btf_id(obj, ext); in bpf_object__resolve_ksyms_btf_id()
6796 err = bpf_object__resolve_ksym_func_btf_id(obj, ext); in bpf_object__resolve_ksyms_btf_id()
6808 struct extern_desc *ext; in bpf_object__resolve_externs() local
6819 ext = &obj->externs[i]; in bpf_object__resolve_externs()
6821 if (ext->type == EXT_KCFG && in bpf_object__resolve_externs()
6822 strcmp(ext->name, "LINUX_KERNEL_VERSION") == 0) { in bpf_object__resolve_externs()
6823 void *ext_val = kcfg_data + ext->kcfg.data_off; in bpf_object__resolve_externs()
6830 err = set_kcfg_value_num(ext, ext_val, kver); in bpf_object__resolve_externs()
6833 pr_debug("extern (kcfg) %s=0x%x\n", ext->name, kver); in bpf_object__resolve_externs()
6834 } else if (ext->type == EXT_KCFG && in bpf_object__resolve_externs()
6835 strncmp(ext->name, "CONFIG_", 7) == 0) { in bpf_object__resolve_externs()
6837 } else if (ext->type == EXT_KSYM) { in bpf_object__resolve_externs()
6838 if (ext->ksym.type_id) in bpf_object__resolve_externs()
6843 pr_warn("unrecognized extern '%s'\n", ext->name); in bpf_object__resolve_externs()
6853 ext = &obj->externs[i]; in bpf_object__resolve_externs()
6854 if (ext->type == EXT_KCFG && !ext->is_set) { in bpf_object__resolve_externs()
6876 ext = &obj->externs[i]; in bpf_object__resolve_externs()
6878 if (!ext->is_set && !ext->is_weak) { in bpf_object__resolve_externs()
6879 pr_warn("extern %s (strong) not resolved\n", ext->name); in bpf_object__resolve_externs()
6881 } else if (!ext->is_set) { in bpf_object__resolve_externs()
6883 ext->name); in bpf_object__resolve_externs()