Projectname
large_stringclasses
15 values
Filepath
large_stringlengths
4
106
⌀
Function
large_stringlengths
11
3.45k
Label
list
Linux Kernel
tools/arch/x86/include/asm/atomic.h
static inline int atomic_read(const atomic_t *v) { return READ_ONCE((v)->counter); }
[ 0, 0 ]
Linux Kernel
tools/arch/x86/include/asm/atomic.h
static inline void atomic_set(atomic_t *v, int i) { v->counter = i; }
[ 0, 0 ]
Linux Kernel
tools/arch/x86/include/asm/inat.h
static inline int inat_is_vex_prefix(insn_attr_t attr) { attr &= INAT_PFX_MASK; return attr == INAT_PFX_VEX2 || attr == INAT_PFX_VEX3 || attr == INAT_PFX_EVEX; }
[ 0, 0 ]
Linux Kernel
tools/arch/x86/include/asm/inat.h
static inline int inat_is_evex_prefix(insn_attr_t attr) { return (attr & INAT_PFX_MASK) == INAT_PFX_EVEX; }
[ 0, 0 ]
Linux Kernel
tools/arch/x86/include/asm/inat.h
static inline int inat_group_id(insn_attr_t attr) { return (attr & INAT_GRP_MASK) >> INAT_GRP_OFFS; }
[ 0, 0 ]
Linux Kernel
tools/arch/x86/include/asm/inat.h
static inline int inat_group_common_attribute(insn_attr_t attr) { return attr & ~INAT_GRP_MASK; }
[ 0, 0 ]
Linux Kernel
tools/arch/x86/include/asm/inat.h
static inline int inat_must_evex(insn_attr_t attr) { return attr & INAT_EVEXONLY; } #endif
[ 0, 0 ]
Linux Kernel
tools/arch/x86/include/asm/insn.h
static inline int insn_is_evex(struct insn *insn) { if (!insn->prefixes.got) insn_get_prefixes(insn); return (insn->vex_prefix.nbytes == 4); }
[ 0, 0 ]
Linux Kernel
tools/arch/x86/include/asm/insn.h
static inline insn_byte_t insn_vex_m_bits(struct insn *insn) { if (insn->vex_prefix.nbytes == 2) return X86_VEX2_M; else if (insn->vex_prefix.nbytes == 3) /* 3 bytes VEX */ return X86_VEX3_M(insn->vex_prefix.bytes[1]); else /* EVEX */ return X86_EVEX_M(insn->vex_prefix.bytes[1]); }
[ 0, 0 ]
Linux Kernel
tools/arch/x86/include/asm/insn.h
static inline int insn_offset_rex_prefix(struct insn *insn) { return insn->prefixes.nbytes; }
[ 0, 0 ]
Linux Kernel
tools/arch/x86/include/asm/insn.h
static inline int insn_offset_opcode(struct insn *insn) { return insn_offset_vex_prefix(insn) + insn->vex_prefix.nbytes; }
[ 0, 0 ]
Linux Kernel
tools/arch/x86/include/asm/insn.h
static inline int insn_offset_modrm(struct insn *insn) { return insn_offset_opcode(insn) + insn->opcode.nbytes; }
[ 0, 0 ]
Linux Kernel
tools/arch/x86/include/asm/insn.h
static inline int insn_offset_sib(struct insn *insn) { return insn_offset_modrm(insn) + insn->modrm.nbytes; }
[ 0, 0 ]
Linux Kernel
tools/arch/x86/include/asm/pvclock.h
static __always_inline u64 __pvclock_read_cycles(const struct pvclock_vcpu_time_info *src, u64 tsc) { u64 delta = tsc - src->tsc_timestamp; u64 offset = pvclock_scale_delta(delta, src->tsc_to_system_mul, src->tsc_shift); return src->system_time + offset; }
[ 0, 0 ]
Linux Kernel
tools/arch/x86/intel_sdsi/intel_sdsi.c
static char *license_blob_type(uint32_t type) { switch (type) { case LBT_ONE_TIME_UPGRADE: return "One time upgrade"; case LBT_METERED_UPGRADE: return "Metered upgrade"; default: return "Unknown license blob type"; } }
[ 0, 0 ]
Linux Kernel
tools/arch/x86/kcpuid/kcpuid.c
struct cpuid_range *setup_cpuid_range(u32 input_eax) { u32 max_func, idx_func; int subleaf; struct cpuid_range *range; u32 eax, ebx, ecx, edx; u32 f = input_eax; int max_subleaf; bool allzero; eax = input_eax; ebx = ecx = edx = 0; cpuid(&eax, &ebx, &ecx, &edx); max_func = eax; idx_func = (max_...
[ 1, 0 ]
Linux Kernel
tools/arch/x86/kcpuid/kcpuid.c
static void parse_text(void) { FILE *file; char *filename, *line = NULL; size_t len = 0; int ret; if (show_raw) return; filename = user_csv ? user_csv : def_csv; file = fopen(filename, "r"); if (!file) { file = fopen("./cpuid.csv", "r"); } if (!file) { printf("Fail to open '%s'\n", f...
[ 1, 0 ]
Linux Kernel
tools/arch/x86/kcpuid/kcpuid.c
static void show_leaf(struct subleaf *leaf) { if (!leaf) return; if (show_raw) leaf_print_raw(leaf); decode_bits(leaf->eax, &leaf->info[R_EAX]); decode_bits(leaf->ebx, &leaf->info[R_EBX]); decode_bits(leaf->ecx, &leaf->info[R_ECX]); decode_bits(leaf->edx, &leaf->info[R_EDX]); }
[ 0, 0 ]
Linux Kernel
tools/arch/x86/kcpuid/kcpuid.c
static inline struct cpuid_func *index_to_func(u32 index) { struct cpuid_range *range; range = (index & 0x80000000) ? leafs_ext : leafs_basic; index &= 0x7FFFFFFF; if (((index & 0xFFFF) + 1) > (u32)range->nr) { printf("ERR: invalid input index (0x%x)\n", index); return NULL; } return &range->func...
[ 1, 0 ]
Linux Kernel
tools/arch/x86/lib/inat.c
insn_attr_t inat_get_opcode_attribute(insn_byte_t opcode) { return inat_primary_table[opcode]; }
[ 0, 0 ]
Linux Kernel
tools/arch/x86/lib/inat.c
int inat_get_last_prefix_id(insn_byte_t last_pfx) { insn_attr_t lpfx_attr; lpfx_attr = inat_get_opcode_attribute(last_pfx); return inat_last_prefix_id(lpfx_attr); }
[ 0, 0 ]
Linux Kernel
tools/arch/x86/lib/inat.c
insn_attr_t inat_get_group_attribute(insn_byte_t modrm, int lpfx_id, insn_attr_t grp_attr) { const insn_attr_t *table; int n; n = inat_group_id(grp_attr); table = inat_group_tables[n][0]; if (!table) return inat_group_common_attribute(grp_attr); if (inat_has_varia...
[ 0, 0 ]
Linux Kernel
tools/arch/x86/lib/inat.c
insn_attr_t inat_get_avx_attribute(insn_byte_t opcode, insn_byte_t vex_m, insn_byte_t vex_p) { const insn_attr_t *table; if (vex_m > X86_VEX_M_MAX || vex_p > INAT_LSTPFX_MAX) return 0; table = inat_avx_tables[vex_m][0]; if (!table) return 0; if (!inat_is_group(table...
[ 1, 0 ]
Linux Kernel
tools/arch/x86/lib/insn.c
static void insn_get_emulate_prefix(struct insn *insn) { if (__insn_get_emulate_prefix(insn, xen_prefix, sizeof(xen_prefix))) return; __insn_get_emulate_prefix(insn, kvm_prefix, sizeof(kvm_prefix)); }
[ 1, 0 ]
Linux Kernel
tools/arch/x86/lib/insn.c
int insn_get_opcode(struct insn *insn) { struct insn_field *opcode = &insn->opcode; int pfx_id, ret; insn_byte_t op; if (opcode->got) return 0; if (!insn->prefixes.got) { ret = insn_get_prefixes(insn); if (ret) return ret; } op = get_next(insn_byte_t, insn); insn_set_byte(opcode, 0,...
[ 1, 0 ]
Linux Kernel
tools/arch/x86/lib/insn.c
int insn_get_displacement(struct insn *insn) { insn_byte_t mod, rm, base; int ret; if (insn->displacement.got) return 0; if (!insn->sib.got) { ret = insn_get_sib(insn); if (ret) return ret; } if (insn->modrm.nbytes) { mod = X86_MODRM_MOD(insn->modrm.value); rm = X86_MODRM_RM(in...
[ 1, 0 ]
Linux Kernel
tools/arch/x86/lib/insn.c
int insn_get_immediate(struct insn *insn) { int ret; if (insn->immediate.got) return 0; if (!insn->displacement.got) { ret = insn_get_displacement(insn); if (ret) return ret; } if (inat_has_moffset(insn->attr)) { if (!__get_moffset(insn)) goto err_out; goto done; } if (...
[ 0, 0 ]
Linux Kernel
tools/arch/x86/lib/insn.c
int insn_decode(struct insn *insn, const void *kaddr, int buf_len, enum insn_mode m) { int ret; #define INSN_MODE_KERN (enum insn_mode) - 1 if (m == INSN_MODE_KERN) insn_init(insn, kaddr, buf_len, IS_ENABLED(CONFIG_X86_64)); else insn_init(insn, kaddr, buf_len, m == INSN_MODE_64); ret...
[ 0, 0 ]
Linux Kernel
tools/bootconfig/include/linux/bootconfig.h
static inline char *skip_spaces(const char *str) { while (isspace(*str)) ++str; return (char *)str; }
[ 0, 0 ]
Linux Kernel
tools/bootconfig/main.c
static int xbc_show_value(struct xbc_node *node, bool semicolon) { const char *val, *eol; char q; int i = 0; eol = semicolon ? ";\n" : "\n"; xbc_array_for_each_value(node, val) { if (strchr(val, '"')) q = '\''; else q = '"'; printf("%c%s%c%s", q, val, q, xbc_node_is_array(node) ? ", ...
[ 0, 0 ]
Linux Kernel
tools/bootconfig/main.c
static int load_xbc_file(const char *path, char **buf) { struct stat stat; int fd, ret; fd = open(path, O_RDONLY); if (fd < 0) return -errno; ret = fstat(fd, &stat); if (ret < 0) return -errno; ret = load_xbc_fd(fd, buf, stat.st_size); close(fd); return ret; }
[ 0, 0 ]
Linux Kernel
tools/bootconfig/main.c
static int init_xbc_with_error(char *buf, int len) { char *copy = strdup(buf); const char *msg; int ret, pos; if (!copy) return -ENOMEM; ret = xbc_init(buf, len, &msg, &pos); if (ret < 0) show_xbc_error(copy, msg, pos); free(copy); return ret; }
[ 1, 0 ]
Linux Kernel
tools/bootconfig/main.c
static int delete_xbc(const char *path) { struct stat stat; int ret = 0, fd, size; char *buf = NULL; fd = open(path, O_RDWR); if (fd < 0) { ret = -errno; pr_err("Failed to open initrd %s: %d\n", path, ret); return ret; } size = load_xbc_from_initrd(fd, &buf); if (size < 0) { ret = size...
[ 1, 0 ]
Linux Kernel
tools/bpf/bpftool/btf.c
static const char *btf_str(const struct btf *btf, __u32 off) { if (!off) return "(anon)"; return btf__name_by_offset(btf, off) ?: "(invalid)"; }
[ 0, 0 ]
Linux Kernel
tools/bpf/bpftool/btf.c
static bool btf_is_kernel_module(__u32 btf_id) { struct bpf_btf_info btf_info = {}; char btf_name[BTF_NAME_BUFF_LEN]; int btf_fd; __u32 len; int err; btf_fd = bpf_btf_get_fd_by_id(btf_id); if (btf_fd < 0) { p_err("can't get BTF object by id (%u): %s", btf_id, strerror(errno)); return false; } ...
[ 1, 0 ]
Linux Kernel
tools/bpf/bpftool/btf.c
static int btf_parse_fd(int *argc, char ***argv) { unsigned int id; char *endptr; int fd; if (!is_prefix(*argv[0], "id")) { p_err("expected 'id', got: '%s'?", **argv); return -1; } NEXT_ARGP(); id = strtoul(**argv, &endptr, 0); if (*endptr) { p_err("can't parse %s as ID", **argv); ret...
[ 0, 0 ]
Linux Kernel
tools/bpf/bpftool/btf.c
static void show_btf_plain(struct bpf_btf_info *info, int fd, struct hashmap *btf_prog_table, struct hashmap *btf_map_table) { struct hashmap_entry *entry; const char *name = u64_to_ptr(info->name); int n; printf("%u: ", info->id); if (info->kernel_btf) ...
[ 1, 0 ]
Linux Kernel
tools/bpf/bpftool/btf_dumper.c
static void btf_dumper_ptr(const struct btf_dumper *d, const struct btf_type *t, const void *data) { unsigned long value = *(unsigned long *)data; const struct btf_type *ptr_type; __s32 ptr_type_id; if (!d->prog_id_as_func_ptr || value > UINT32_MAX) goto print_ptr_value; ptr_...
[ 1, 0 ]
Linux Kernel
tools/bpf/bpftool/btf_dumper.c
static void btf_dumper_bitfield(__u32 nr_bits, __u8 bit_offset, const void *data, json_writer_t *jw, bool is_plain_text) { int left_shift_bits, right_shift_bits; __u64 print_num[2] = {}; int bytes_to_copy; int bits_to_copy; bits_to_copy = bit_o...
[ 1, 0 ]
Linux Kernel
tools/bpf/bpftool/btf_dumper.c
static void btf_dumper_int_bits(__u32 int_type, __u8 bit_offset, const void *data, json_writer_t *jw, bool is_plain_text) { int nr_bits = BTF_INT_BITS(int_type); int total_bits_offset; total_bits_offset = bit_offset + BTF_INT_OFFSET(int_type); dat...
[ 0, 0 ]
Linux Kernel
tools/bpf/bpftool/btf_dumper.c
static int btf_dumper_struct(const struct btf_dumper *d, __u32 type_id, const void *data) { const struct btf_type *t; struct btf_member *m; const void *data_off; int kind_flag; int ret = 0; int i, vlen; t = btf__type_by_id(d->btf, type_id); if (!t) return -EINVAL; k...
[ 0, 0 ]
Linux Kernel
tools/bpf/bpftool/btf_dumper.c
static int btf_dumper_var(const struct btf_dumper *d, __u32 type_id, __u8 bit_offset, const void *data) { const struct btf_type *t = btf__type_by_id(d->btf, type_id); int ret; jsonw_start_object(d->jw); jsonw_name(d->jw, btf__name_by_offset(d->btf, t->name_off)); ret = btf_dumper_d...
[ 0, 0 ]
Linux Kernel
tools/bpf/bpftool/btf_dumper.c
static int btf_dump_func(const struct btf *btf, char *func_sig, const struct btf_type *func_proto, const struct btf_type *func, int pos, int size) { int i, vlen; BTF_PRINT_TYPE(func_proto->type); if (func) BTF_PRINT_ARG("%s(", btf__name_by_offset(btf, func->n...
[ 1, 0 ]
Linux Kernel
tools/bpf/bpftool/btf_dumper.c
void btf_dump_linfo_plain(const struct btf *btf, const struct bpf_line_info *linfo, const char *prefix, bool linum) { const char *line = btf__name_by_offset(btf, linfo->line_off); if (!line) return; line = ltrim(line); if (!prefix) prefix = ""; if...
[ 0, 0 ]
Linux Kernel
tools/bpf/bpftool/btf_dumper.c
void btf_dump_linfo_json(const struct btf *btf, const struct bpf_line_info *linfo, bool linum) { const char *line = btf__name_by_offset(btf, linfo->line_off); if (line) jsonw_string_field(json_wtr, "src", ltrim(line)); if (linum) { const char *file = btf__name_by_offset(btf, li...
[ 0, 0 ]
Linux Kernel
tools/bpf/bpftool/cfg.c
static struct func_node *cfg_append_func(struct cfg *cfg, struct bpf_insn *insn) { struct func_node *new_func, *func; list_for_each_entry(func, &cfg->funcs, l) { if (func->start == insn) return func; else if (func->start > insn) break; } func = fun...
[ 1, 0 ]
Linux Kernel
tools/bpf/bpftool/cfg.c
static struct bb_node *func_append_bb(struct func_node *func, struct bpf_insn *insn) { struct bb_node *new_bb, *bb; list_for_each_entry(bb, &func->bbs, l) { if (bb->head == insn) return bb; else if (bb->head > insn) break; } bb = bb_prev(bb); new_bb...
[ 1, 0 ]
Linux Kernel
tools/bpf/bpftool/cfg.c
static struct bb_node *func_insert_dummy_bb(struct list_head *after) { struct bb_node *bb; bb = calloc(1, sizeof(*bb)); if (!bb) { p_err("OOM when allocating BB node"); return NULL; } INIT_LIST_HEAD(&bb->e_prevs); INIT_LIST_HEAD(&bb->e_succs); list_add(&bb->l, after); return bb; }
[ 1, 0 ]
Linux Kernel
tools/bpf/bpftool/cfg.c
static void draw_bb_succ_edges(struct func_node *func, struct bb_node *bb) { const char *style = "\"solid,bold\""; const char *color = "black"; int func_idx = func->idx; struct edge_node *e; int weight = 10; if (list_empty(&bb->e_succs)) return; list_for_each_entry(e, &bb->e_succs, l) { printf(...
[ 1, 0 ]
Linux Kernel
tools/bpf/bpftool/cfg.c
void dump_xlated_cfg(void *buf, unsigned int len) { struct bpf_insn *insn = buf; struct cfg cfg; memset(&cfg, 0, sizeof(cfg)); if (cfg_build(&cfg, insn, len)) return; cfg_dump(&cfg); cfg_destroy(&cfg); }
[ 1, 0 ]
Linux Kernel
tools/bpf/bpftool/cgroup.c
static void guess_vmlinux_btf_id(__u32 attach_btf_obj_id) { struct bpf_btf_info btf_info = {}; __u32 btf_len = sizeof(btf_info); char name[16] = {}; int err; int fd; btf_info.name = ptr_to_u64(name); btf_info.name_len = sizeof(name); fd = bpf_btf_get_fd_by_id(attach_btf_obj_id); if (fd < 0) ret...
[ 1, 0 ]
Linux Kernel
tools/bpf/bpftool/cgroup.c
static int count_attached_bpf_progs(int cgroup_fd, enum bpf_attach_type type) { __u32 prog_cnt = 0; int ret; ret = bpf_prog_query(cgroup_fd, type, query_flags, NULL, NULL, &prog_cnt); if (ret) return -1; return prog_cnt; }
[ 0, 0 ]
Linux Kernel
tools/bpf/bpftool/cgroup.c
static int show_bpf_progs(int cgroup_fd, enum bpf_attach_type type, int level) { return query_flags & BPF_F_QUERY_EFFECTIVE ? show_effective_bpf_progs(cgroup_fd, type, level) : show_attached_bpf_progs(cgroup_fd, type, level); }
[ 0, 0 ]
Linux Kernel
tools/bpf/bpftool/cgroup.c
static int do_show_tree_fn(const char *fpath, const struct stat *sb, int typeflag, struct FTW *ftw) { enum bpf_attach_type type; int has_attached_progs; int cgroup_fd; if (typeflag != FTW_D) return 0; cgroup_fd = open(fpath, O_RDONLY); if (cgroup_fd < 0) { p_err("can't o...
[ 0, 0 ]
Linux Kernel
tools/bpf/bpftool/cgroup.c
static int do_show_tree(int argc, char **argv) { char *cgroup_root, *cgroup_alloced = NULL; int ret; query_flags = 0; if (!argc) { cgroup_alloced = find_cgroup_root(); if (!cgroup_alloced) { p_err("cgroup v2 isn't mounted"); return -1; } cgroup_root = cgroup_alloced; } else { ...
[ 1, 0 ]
Linux Kernel
tools/bpf/bpftool/common.c
static bool is_bpffs(char *path) { struct statfs st_fs; if (statfs(path, &st_fs) < 0) return false; return (unsigned long)st_fs.f_type == BPF_FS_MAGIC; }
[ 0, 0 ]
Linux Kernel
tools/bpf/bpftool/common.c
static bool known_to_need_rlimit(void) { struct rlimit rlim_init, rlim_cur_zero = {}; struct bpf_insn insns[] = { BPF_MOV64_IMM(BPF_REG_0, 0), BPF_EXIT_INSN(), }; size_t insn_cnt = ARRAY_SIZE(insns); union bpf_attr attr; int prog_fd, err; memset(&attr, 0, sizeof(attr)); attr.prog_type = BPF...
[ 1, 0 ]
Linux Kernel
tools/bpf/bpftool/common.c
char *get_fdinfo(int fd, const char *key) { char path[PATH_MAX]; char *line = NULL; size_t line_n = 0; ssize_t n; FILE *fdi; snprintf(path, sizeof(path), "/proc/self/fdinfo/%d", fd); fdi = fopen(path, "r"); if (!fdi) return NULL; while ((n = getline(&line, &line_n, fdi)) > 0) { char *value...
[ 1, 0 ]
Linux Kernel
tools/bpf/bpftool/common.c
void print_data_json(uint8_t *data, size_t len) { unsigned int i; jsonw_start_array(json_wtr); for (i = 0; i < len; i++) jsonw_printf(json_wtr, "%d", data[i]); jsonw_end_array(json_wtr); }
[ 0, 0 ]
Linux Kernel
tools/bpf/bpftool/common.c
void print_hex_data_json(uint8_t *data, size_t len) { unsigned int i; jsonw_start_array(json_wtr); for (i = 0; i < len; i++) jsonw_printf(json_wtr, "\"0x%02hhx\"", data[i]); jsonw_end_array(json_wtr); }
[ 0, 0 ]
Linux Kernel
tools/bpf/bpftool/common.c
static int read_sysfs_hex_int(char *path) { char vendor_id_buf[8]; int len; int fd; fd = open(path, O_RDONLY); if (fd < 0) { p_err("Can't open %s: %s", path, strerror(errno)); return -1; } len = read(fd, vendor_id_buf, sizeof(vendor_id_buf)); close(fd); if (len < 0) { p_err("Can't read ...
[ 1, 0 ]
Linux Kernel
tools/bpf/bpftool/common.c
int prog_parse_fds(int *argc, char ***argv, int **fds) { if (is_prefix(**argv, "id")) { unsigned int id; char *endptr; NEXT_ARGP(); id = strtoul(**argv, &endptr, 0); if (*endptr) { p_err("can't parse %s as ID", **argv); return -1; } NEXT_ARGP(); (*fds)[0] = bpf_prog_get...
[ 0, 0 ]
Linux Kernel
tools/bpf/bpftool/common.c
int map_parse_fd_and_info(int *argc, char ***argv, void *info, __u32 *info_len) { int err; int fd; fd = map_parse_fd(argc, argv); if (fd < 0) return -1; err = bpf_obj_get_info_by_fd(fd, info, info_len); if (err) { p_err("can't get map info: %s", strerror(errno)); clo...
[ 0, 0 ]
Linux Kernel
tools/bpf/bpftool/feature.c
static bool grep(const char *buffer, const char *pattern) { return !!strstr(buffer, pattern); }
[ 0, 0 ]
Linux Kernel
tools/bpf/bpftool/feature.c
static bool check_procfs(void) { struct statfs st_fs; if (statfs("/proc", &st_fs) < 0) return false; if ((unsigned long)st_fs.f_type != PROC_SUPER_MAGIC) return false; return true; }
[ 1, 0 ]
Linux Kernel
tools/bpf/bpftool/feature.c
static void uppercase(char *str, size_t len) { size_t i; for (i = 0; i < len && str[i] != '\0'; i++) str[i] = toupper(str[i]); }
[ 1, 0 ]
Linux Kernel
tools/bpf/bpftool/feature.c
static void print_kernel_option(const char *name, const char *value, const char *define_prefix) { char *endptr; int res; if (json_output) { if (!value) { jsonw_null_field(json_wtr, name); return; } errno = 0; res = strtol(value, &endptr, 0); if (!er...
[ 1, 0 ]
Linux Kernel
tools/bpf/bpftool/feature.c
static void probe_jit_harden(void) { int res; res = read_procfs("/proc/sys/net/core/bpf_jit_harden"); if (json_output) { jsonw_int_field(json_wtr, "bpf_jit_harden", res); } else { switch (res) { case 0: printf("JIT compiler hardening is disabled\n"); break; case 1: printf("JIT...
[ 0, 0 ]
Linux Kernel
tools/bpf/bpftool/feature.c
static bool read_next_kernel_config_option(gzFile file, char *buf, size_t n, char **value) { char *sep; while (gzgets(file, buf, n)) { if (strncmp(buf, "CONFIG_", 7)) continue; sep = strchr(buf, '='); if (!sep) continue; buf[strlen(buf) - 1] ...
[ 0, 0 ]
Linux Kernel
tools/bpf/bpftool/feature.c
static bool probe_prog_load_ifindex(enum bpf_prog_type prog_type, const struct bpf_insn *insns, size_t insns_cnt, char *log_buf, size_t log_buf_sz, __u32 ifindex) { LIBBPF_OPTS(bpf_prog_load_opts, opts, .log_b...
[ 1, 0 ]
Linux Kernel
tools/bpf/bpftool/feature.c
static void probe_prog_type(enum bpf_prog_type prog_type, const char *prog_type_str, bool *supported_types, const char *define_prefix, __u32 ifindex) { char feat_name[128], plain_desc[128], define_name[128]; const char *plain_comment = "eBPF program_type "; ...
[ 1, 0 ]
Linux Kernel
tools/bpf/bpftool/feature.c
static void probe_map_type(enum bpf_map_type map_type, char const *map_type_str, const char *define_prefix, __u32 ifindex) { char feat_name[128], plain_desc[128], define_name[128]; const char *plain_comment = "eBPF map_type "; size_t maxlen; bool res; if (ifindex) { switch (map...
[ 1, 0 ]
Linux Kernel
tools/bpf/bpftool/feature.c
static bool probe_helper_for_progtype(enum bpf_prog_type prog_type, bool supported_type, const char *define_prefix, unsigned int id, const char *ptype_name, __u32 ifind...
[ 0, 0 ]
Linux Kernel
tools/bpf/bpftool/feature.c
static void probe_helpers_for_progtype(enum bpf_prog_type prog_type, const char *prog_type_str, bool supported_type, const char *define_prefix, __u32 ifindex) { c...
[ 1, 0 ]
Linux Kernel
tools/bpf/bpftool/feature.c
static void probe_bounded_loops(const char *define_prefix, __u32 ifindex) { struct bpf_insn insns[4] = { BPF_MOV64_IMM(BPF_REG_0, 10), BPF_ALU64_IMM(BPF_SUB, BPF_REG_0, 1), BPF_JMP_IMM(BPF_JNE, BPF_REG_0, 0, -2), BPF_EXIT_INSN()}; probe_misc_feature(insns, ARRAY_SIZE(insns), define_prefix, ifindex, ...
[ 0, 0 ]
Linux Kernel
tools/bpf/bpftool/feature.c
static void section_misc(const char *define_prefix, __u32 ifindex) { print_start_section("misc", "Scanning miscellaneous eBPF features...", "", define_prefix); probe_large_insn_limit(define_prefix, ifindex); probe_bounded_loops(define_prefix, ifindex); probe_v2_isa_extension(define_prefix,...
[ 0, 0 ]
Linux Kernel
tools/bpf/bpftool/feature.c
static int do_list_builtins(int argc, char **argv) { const char *(*get_name)(unsigned int id); unsigned int id = 0; if (argc < 1) usage(); if (is_prefix(*argv, "prog_types")) { get_name = (const char *(*)(unsigned int))libbpf_bpf_prog_type_str; } else if (is_prefix(*argv, "map_types")) { get_nam...
[ 1, 0 ]
Linux Kernel
tools/bpf/bpftool/gen.c
static bool str_has_prefix(const char *str, const char *prefix) { return strncmp(str, prefix, strlen(prefix)) == 0; }
[ 0, 0 ]
Linux Kernel
tools/bpf/bpftool/gen.c
static bool str_has_suffix(const char *str, const char *suffix) { size_t i, n1 = strlen(str), n2 = strlen(suffix); if (n1 < n2) return false; for (i = 0; i < n2; i++) { if (str[n1 - i - 1] != suffix[n2 - i - 1]) return false; } return true; }
[ 1, 0 ]
Linux Kernel
tools/bpf/bpftool/gen.c
static void get_obj_name(char *name, const char *file) { strncpy(name, basename(file), MAX_OBJ_NAME_LEN - 1); name[MAX_OBJ_NAME_LEN - 1] = '\0'; if (str_has_suffix(name, ".o")) name[strlen(name) - 2] = '\0'; sanitize_identifier(name); }
[ 1, 0 ]
Linux Kernel
tools/bpf/bpftool/gen.c
static void get_header_guard(char *guard, const char *obj_name, const char *suffix) { int i; sprintf(guard, "__%s_%s__", obj_name, suffix); for (i = 0; guard[i]; i++) guard[i] = toupper(guard[i]); }
[ 1, 0 ]
Linux Kernel
tools/bpf/bpftool/gen.c
static bool get_map_ident(const struct bpf_map *map, char *buf, size_t buf_sz) { static const char *sfxs[] = {".data", ".rodata", ".bss", ".kconfig"}; const char *name = bpf_map__name(map); int i, n; if (!bpf_map__is_internal(map)) { snprintf(buf, buf_sz, "%s", name); return true; } for (i = 0, n...
[ 0, 0 ]
Linux Kernel
tools/bpf/bpftool/gen.c
static bool is_internal_mmapable_map(const struct bpf_map *map, char *buf, size_t sz) { if (!bpf_map__is_internal(map) || !(bpf_map__map_flags(map) & BPF_F_MMAPABLE)) return false; if (!get_map_ident(map, buf, sz)) return false; return true; }
[ 0, 0 ]
Linux Kernel
tools/bpf/bpftool/gen.c
static int codegen_datasecs(struct bpf_object *obj, const char *obj_name) { struct btf *btf = bpf_object__btf(obj); struct btf_dump *d; struct bpf_map *map; const struct btf_type *sec; char map_ident[256]; int err = 0; d = btf_dump__new(btf, codegen_btf_dump_printf, NULL, NULL); if (!d) return -err...
[ 1, 0 ]
Linux Kernel
tools/bpf/bpftool/gen.c
static bool btf_is_ptr_to_func_proto(const struct btf *btf, const struct btf_type *v) { return btf_is_ptr(v) && btf_is_func_proto(btf__type_by_id(btf, v->type)); }
[ 0, 0 ]
Linux Kernel
tools/bpf/bpftool/gen.c
static void codegen(const char *template, ...) { const char *src, *end; int skip_tabs = 0, n; char *s, *dst; va_list args; char c; n = strlen(template); s = malloc(n + 1); if (!s) exit(-1); src = template; dst = s; while ((c = *src++)) { if (c == '\t') { skip_tabs++; } else if ...
[ 1, 0 ]
Linux Kernel
tools/bpf/bpftool/gen.c
static void codegen_progs_skeleton(struct bpf_object *obj, size_t prog_cnt, bool populate_links) { struct bpf_program *prog; int i; if (!prog_cnt) return; codegen("\ \n\ \n\ \n\ s->prog_cnt = %zu; \n\ s->prog_skel_sz = sizeof(*s->progs);...
[ 1, 0 ]
Linux Kernel
tools/bpf/bpftool/gen.c
static int do_object(int argc, char **argv) { struct bpf_linker *linker; const char *output_file, *file; int err = 0; if (!REQ_ARGS(2)) { usage(); return -1; } output_file = GET_ARG(); linker = bpf_linker__new(output_file, NULL); if (!linker) { p_err("failed to create BPF linker instance...
[ 0, 0 ]
Linux Kernel
tools/bpf/bpftool/gen.c
static size_t btfgen_hash_fn(long key, void *ctx) { return key; }
[ 0, 0 ]
Linux Kernel
tools/bpf/bpftool/gen.c
static void btfgen_mark_member(struct btfgen_info *info, int type_id, int idx) { const struct btf_type *t = btf__type_by_id(info->marked_btf, type_id); struct btf_member *m = btf_members(t) + idx; m->name_off = MARKED; }
[ 0, 0 ]
Linux Kernel
tools/bpf/bpftool/gen.c
static int btfgen_record_type_relo(struct btfgen_info *info, struct bpf_core_spec *targ_spec) { return btfgen_mark_type(info, targ_spec->root_type_id, true); }
[ 0, 0 ]
Linux Kernel
tools/bpf/bpftool/gen.c
static struct bpf_core_cand_list *btfgen_find_cands(const struct btf *local_btf, const struct btf *targ_btf, __u32 local_id) { const struct btf_type *local_type; struct bpf_core_cand_list *cands = NULL; struct...
[ 1, 0 ]
Linux Kernel
tools/bpf/bpftool/gen.c
static int minimize_btf(const char *src_btf, const char *dst_btf, const char *objspaths[]) { struct btfgen_info *info; struct btf *btf_new = NULL; int err, i; info = btfgen_new_info(src_btf); if (!info) { err = -errno; p_err("failed to allocate info structure: %s", strerror(er...
[ 0, 0 ]
Linux Kernel
tools/bpf/bpftool/jit_disasm.c
static const char * symbol_lookup_callback(__maybe_unused void *disasm_info, __maybe_unused uint64_t ref_value, uint64_t *ref_type, __maybe_unused uint64_t ref_PC, __maybe_unused const char **ref_name) { *ref_type = LLVMDisassembler_ReferenceType_In...
[ 0, 0 ]
Linux Kernel
tools/bpf/bpftool/jit_disasm.c
static int disassemble_insn(disasm_ctx_t *ctx, unsigned char *image, ssize_t len, int pc) { char buf[256]; int count; count = LLVMDisasmInstruction(*ctx, image + pc, len - pc, pc, buf, sizeof(buf)); if (json_output) printf_json(buf); else printf("%s", buf); retur...
[ 1, 0 ]
Linux Kernel
tools/bpf/bpftool/jit_disasm.c
int disasm_init(void) { LLVMInitializeAllTargetInfos(); LLVMInitializeAllTargetMCs(); LLVMInitializeAllDisassemblers(); return 0; } #endif #ifdef HAVE_LIBBFD_SUPPORT #define DISASM_SPACER "\t"
[ 0, 0 ]
Linux Kernel
tools/bpf/bpftool/json_writer.c
static void jsonw_indent(json_writer_t *self) { unsigned i; for (i = 0; i < self->depth; ++i) fputs(" ", self->out); }
[ 0, 0 ]
Linux Kernel
tools/bpf/bpftool/json_writer.c
void jsonw_pretty(json_writer_t *self, bool on) { self->pretty = on; }
[ 0, 0 ]
Linux Kernel
tools/bpf/bpftool/json_writer.c
void jsonw_name(json_writer_t *self, const char *name) { jsonw_eor(self); jsonw_eol(self); self->sep = '\0'; jsonw_puts(self, name); putc(':', self->out); if (self->pretty) putc(' ', self->out); }
[ 0, 0 ]
Linux Kernel
tools/bpf/bpftool/json_writer.c
void jsonw_start_object(json_writer_t *self) { jsonw_begin(self, '{'); }
[ 0, 0 ]