Lines Matching full:aux

94 	struct bpf_prog_aux *aux;  in bpf_prog_alloc_no_stats()  local
102 aux = kzalloc(sizeof(*aux), bpf_memcg_flags(GFP_KERNEL | gfp_extra_flags)); in bpf_prog_alloc_no_stats()
103 if (aux == NULL) { in bpf_prog_alloc_no_stats()
110 kfree(aux); in bpf_prog_alloc_no_stats()
115 fp->aux = aux; in bpf_prog_alloc_no_stats()
116 fp->aux->prog = fp; in bpf_prog_alloc_no_stats()
120 aux->cgroup_atype = CGROUP_BPF_ATTACH_TYPE_INVALID; in bpf_prog_alloc_no_stats()
123 INIT_LIST_HEAD_RCU(&fp->aux->ksym.lnode); in bpf_prog_alloc_no_stats()
124 mutex_init(&fp->aux->used_maps_mutex); in bpf_prog_alloc_no_stats()
125 mutex_init(&fp->aux->dst_mutex); in bpf_prog_alloc_no_stats()
143 kfree(prog->aux); in bpf_prog_alloc()
160 if (!prog->aux->nr_linfo || !prog->jit_requested) in bpf_prog_alloc_jited_linfo()
163 prog->aux->jited_linfo = kvcalloc(prog->aux->nr_linfo, in bpf_prog_alloc_jited_linfo()
164 sizeof(*prog->aux->jited_linfo), in bpf_prog_alloc_jited_linfo()
166 if (!prog->aux->jited_linfo) in bpf_prog_alloc_jited_linfo()
174 if (prog->aux->jited_linfo && in bpf_prog_jit_attempt_done()
175 (!prog->jited || !prog->aux->jited_linfo[0])) { in bpf_prog_jit_attempt_done()
176 kvfree(prog->aux->jited_linfo); in bpf_prog_jit_attempt_done()
177 prog->aux->jited_linfo = NULL; in bpf_prog_jit_attempt_done()
180 kfree(prog->aux->kfunc_tab); in bpf_prog_jit_attempt_done()
181 prog->aux->kfunc_tab = NULL; in bpf_prog_jit_attempt_done()
199 * The prog's idx to prog->aux->linfo and jited_linfo
215 if (!prog->aux->jited_linfo) in bpf_prog_fill_jited_linfo()
219 linfo_idx = prog->aux->linfo_idx; in bpf_prog_fill_jited_linfo()
220 linfo = &prog->aux->linfo[linfo_idx]; in bpf_prog_fill_jited_linfo()
224 jited_linfo = &prog->aux->jited_linfo[linfo_idx]; in bpf_prog_fill_jited_linfo()
227 nr_linfo = prog->aux->nr_linfo - linfo_idx; in bpf_prog_fill_jited_linfo()
253 fp->aux->prog = fp; in bpf_prog_realloc()
255 /* We keep fp->aux from fp_old around in the new in bpf_prog_realloc()
258 fp_old->aux = NULL; in bpf_prog_realloc()
269 if (fp->aux) { in __bpf_prog_free()
270 mutex_destroy(&fp->aux->used_maps_mutex); in __bpf_prog_free()
271 mutex_destroy(&fp->aux->dst_mutex); in __bpf_prog_free()
272 kfree(fp->aux->poke_tab); in __bpf_prog_free()
273 kfree(fp->aux); in __bpf_prog_free()
454 nr_linfo = prog->aux->nr_linfo; in bpf_adj_linfo()
458 linfo = prog->aux->linfo; in bpf_adj_linfo()
546 for (i = 0; i < fp->aux->func_cnt; i++) in bpf_prog_kallsyms_del_subprogs()
547 bpf_prog_kallsyms_del(fp->aux->func[i]); in bpf_prog_kallsyms_del_subprogs()
569 prog->aux->ksym.start = (unsigned long) prog->bpf_func; in bpf_prog_ksym_set_addr()
570 prog->aux->ksym.end = prog->aux->ksym.start + prog->jited_len; in bpf_prog_ksym_set_addr()
576 char *sym = prog->aux->ksym.name; in bpf_prog_ksym_set_name()
590 sizeof(prog->aux->name) > KSYM_NAME_LEN); in bpf_prog_ksym_set_name()
595 /* prog->aux->name will be ignored if full btf name is available */ in bpf_prog_ksym_set_name()
596 if (prog->aux->func_info_cnt) { in bpf_prog_ksym_set_name()
597 type = btf_type_by_id(prog->aux->btf, in bpf_prog_ksym_set_name()
598 prog->aux->func_info[prog->aux->func_idx].type_id); in bpf_prog_ksym_set_name()
599 func_name = btf_name_by_offset(prog->aux->btf, type->name_off); in bpf_prog_ksym_set_name()
604 if (prog->aux->name[0]) in bpf_prog_ksym_set_name()
605 snprintf(sym, (size_t)(end - sym), "_%s", prog->aux->name); in bpf_prog_ksym_set_name()
687 fp->aux->ksym.prog = true; in bpf_prog_kallsyms_add()
689 bpf_ksym_add(&fp->aux->ksym); in bpf_prog_kallsyms_add()
697 bpf_ksym_del(&fp->aux->ksym); in bpf_prog_kallsyms_del()
762 if (!prog->aux->num_exentries) in search_bpf_extables()
765 e = search_extable(prog->aux->extable, prog->aux->num_exentries, addr); in search_bpf_extables()
802 struct bpf_jit_poke_descriptor *tab = prog->aux->poke_tab; in bpf_jit_add_poke_descriptor()
804 u32 slot = prog->aux->size_poke_tab; in bpf_jit_add_poke_descriptor()
827 prog->aux->size_poke_tab = size; in bpf_jit_add_poke_descriptor()
828 prog->aux->poke_tab = tab; in bpf_jit_add_poke_descriptor()
1219 * can pick them up from prog->aux. in bpf_jit_get_func_addr()
1223 else if (prog->aux->func && in bpf_jit_get_func_addr()
1224 off >= 0 && off < prog->aux->func_cnt) in bpf_jit_get_func_addr()
1225 addr = (u8 *)prog->aux->func[off]->bpf_func; in bpf_jit_get_func_addr()
1247 const struct bpf_insn *aux, in bpf_jit_blind_insn() argument
1356 *to++ = BPF_ALU64_IMM(BPF_MOV, BPF_REG_AX, imm_rnd ^ aux[1].imm); in bpf_jit_blind_insn()
1359 *to++ = BPF_ALU64_REG(BPF_MOV, aux[0].dst_reg, BPF_REG_AX); in bpf_jit_blind_insn()
1362 *to++ = BPF_ALU32_IMM(BPF_MOV, BPF_REG_AX, imm_rnd ^ aux[0].imm); in bpf_jit_blind_insn()
1366 *to++ = BPF_ALU64_REG(BPF_OR, aux[0].dst_reg, BPF_REG_AX); in bpf_jit_blind_insn()
1390 /* aux->prog still points to the fp_other one, so in bpf_prog_clone_create()
1402 /* aux was stolen by the other clone, so we cannot free in bpf_prog_clone_free()
1409 fp->aux = NULL; in bpf_prog_clone_free()
1417 /* We have to repoint aux->prog to self, as we don't in bpf_jit_prog_release_other()
1420 fp->aux->prog = fp; in bpf_jit_prog_release_other()
1426 struct bpf_insn insn_buff[16], aux[2]; in bpf_jit_blind_constants() local
1459 memcpy(aux, insn, sizeof(aux)); in bpf_jit_blind_constants()
1461 rewritten = bpf_jit_blind_insn(insn, aux, insn_buff, in bpf_jit_blind_constants()
1462 clone->aux->verifier_zext); in bpf_jit_blind_constants()
1468 /* Patching may have repointed aux->prog during in bpf_jit_blind_constants()
2262 struct bpf_prog_aux *aux = fp->aux; in bpf_prog_map_compatible() local
2272 if (bpf_prog_is_dev_bound(aux)) in bpf_prog_map_compatible()
2282 map->owner.xdp_has_frags = aux->xdp_has_frags; in bpf_prog_map_compatible()
2283 map->owner.attach_func_proto = aux->attach_func_proto; in bpf_prog_map_compatible()
2288 map->owner.xdp_has_frags == aux->xdp_has_frags; in bpf_prog_map_compatible()
2290 map->owner.attach_func_proto != aux->attach_func_proto) { in bpf_prog_map_compatible()
2310 struct bpf_prog_aux *aux = fp->aux; in bpf_check_tail_call() local
2313 mutex_lock(&aux->used_maps_mutex); in bpf_check_tail_call()
2314 for (i = 0; i < aux->used_map_cnt; i++) { in bpf_check_tail_call()
2315 struct bpf_map *map = aux->used_maps[i]; in bpf_check_tail_call()
2327 mutex_unlock(&aux->used_maps_mutex); in bpf_check_tail_call()
2334 u32 stack_depth = max_t(u32, fp->aux->stack_depth, 1); in bpf_prog_select_func()
2375 if (!bpf_prog_is_offloaded(fp->aux)) { in bpf_prog_select_runtime()
2495 prog_ids[i] = item->prog->aux->id; in bpf_prog_array_copy_core()
2689 void __bpf_free_used_maps(struct bpf_prog_aux *aux, in __bpf_free_used_maps() argument
2696 sleepable = aux->sleepable; in __bpf_free_used_maps()
2700 map->ops->map_poke_untrack(map, aux); in __bpf_free_used_maps()
2707 static void bpf_free_used_maps(struct bpf_prog_aux *aux) in bpf_free_used_maps() argument
2709 __bpf_free_used_maps(aux, aux->used_maps, aux->used_map_cnt); in bpf_free_used_maps()
2710 kfree(aux->used_maps); in bpf_free_used_maps()
2713 void __bpf_free_used_btfs(struct bpf_prog_aux *aux, in __bpf_free_used_btfs() argument
2729 static void bpf_free_used_btfs(struct bpf_prog_aux *aux) in bpf_free_used_btfs() argument
2731 __bpf_free_used_btfs(aux, aux->used_btfs, aux->used_btf_cnt); in bpf_free_used_btfs()
2732 kfree(aux->used_btfs); in bpf_free_used_btfs()
2737 struct bpf_prog_aux *aux; in bpf_prog_free_deferred() local
2740 aux = container_of(work, struct bpf_prog_aux, work); in bpf_prog_free_deferred()
2742 bpf_free_kfunc_btf_tab(aux->kfunc_btf_tab); in bpf_prog_free_deferred()
2745 if (aux->cgroup_atype != CGROUP_BPF_ATTACH_TYPE_INVALID) in bpf_prog_free_deferred()
2746 bpf_cgroup_atype_put(aux->cgroup_atype); in bpf_prog_free_deferred()
2748 bpf_free_used_maps(aux); in bpf_prog_free_deferred()
2749 bpf_free_used_btfs(aux); in bpf_prog_free_deferred()
2750 if (bpf_prog_is_dev_bound(aux)) in bpf_prog_free_deferred()
2751 bpf_prog_dev_bound_destroy(aux->prog); in bpf_prog_free_deferred()
2753 if (aux->prog->has_callchain_buf) in bpf_prog_free_deferred()
2756 if (aux->dst_trampoline) in bpf_prog_free_deferred()
2757 bpf_trampoline_put(aux->dst_trampoline); in bpf_prog_free_deferred()
2758 for (i = 0; i < aux->func_cnt; i++) { in bpf_prog_free_deferred()
2763 aux->func[i]->aux->poke_tab = NULL; in bpf_prog_free_deferred()
2764 bpf_jit_free(aux->func[i]); in bpf_prog_free_deferred()
2766 if (aux->func_cnt) { in bpf_prog_free_deferred()
2767 kfree(aux->func); in bpf_prog_free_deferred()
2768 bpf_prog_unlock_free(aux->prog); in bpf_prog_free_deferred()
2770 bpf_jit_free(aux->prog); in bpf_prog_free_deferred()
2776 struct bpf_prog_aux *aux = fp->aux; in bpf_prog_free() local
2778 if (aux->dst_prog) in bpf_prog_free()
2779 bpf_prog_put(aux->dst_prog); in bpf_prog_free()
2780 INIT_WORK(&aux->work, bpf_prog_free_deferred); in bpf_prog_free()
2781 schedule_work(&aux->work); in bpf_prog_free()