Lines Matching full:aux

87 	struct bpf_prog_aux *aux;  in bpf_prog_alloc_no_stats()  local
95 aux = kzalloc(sizeof(*aux), GFP_KERNEL_ACCOUNT | gfp_extra_flags); in bpf_prog_alloc_no_stats()
96 if (aux == NULL) { in bpf_prog_alloc_no_stats()
103 kfree(aux); in bpf_prog_alloc_no_stats()
108 fp->aux = aux; in bpf_prog_alloc_no_stats()
109 fp->aux->prog = fp; in bpf_prog_alloc_no_stats()
113 aux->cgroup_atype = CGROUP_BPF_ATTACH_TYPE_INVALID; in bpf_prog_alloc_no_stats()
116 INIT_LIST_HEAD_RCU(&fp->aux->ksym.lnode); in bpf_prog_alloc_no_stats()
117 mutex_init(&fp->aux->used_maps_mutex); in bpf_prog_alloc_no_stats()
118 mutex_init(&fp->aux->dst_mutex); in bpf_prog_alloc_no_stats()
136 kfree(prog->aux); in bpf_prog_alloc()
153 if (!prog->aux->nr_linfo || !prog->jit_requested) in bpf_prog_alloc_jited_linfo()
156 prog->aux->jited_linfo = kvcalloc(prog->aux->nr_linfo, in bpf_prog_alloc_jited_linfo()
157 sizeof(*prog->aux->jited_linfo), in bpf_prog_alloc_jited_linfo()
159 if (!prog->aux->jited_linfo) in bpf_prog_alloc_jited_linfo()
167 if (prog->aux->jited_linfo && in bpf_prog_jit_attempt_done()
168 (!prog->jited || !prog->aux->jited_linfo[0])) { in bpf_prog_jit_attempt_done()
169 kvfree(prog->aux->jited_linfo); in bpf_prog_jit_attempt_done()
170 prog->aux->jited_linfo = NULL; in bpf_prog_jit_attempt_done()
173 kfree(prog->aux->kfunc_tab); in bpf_prog_jit_attempt_done()
174 prog->aux->kfunc_tab = NULL; in bpf_prog_jit_attempt_done()
192 * The prog's idx to prog->aux->linfo and jited_linfo
208 if (!prog->aux->jited_linfo) in bpf_prog_fill_jited_linfo()
212 linfo_idx = prog->aux->linfo_idx; in bpf_prog_fill_jited_linfo()
213 linfo = &prog->aux->linfo[linfo_idx]; in bpf_prog_fill_jited_linfo()
217 jited_linfo = &prog->aux->jited_linfo[linfo_idx]; in bpf_prog_fill_jited_linfo()
220 nr_linfo = prog->aux->nr_linfo - linfo_idx; in bpf_prog_fill_jited_linfo()
246 fp->aux->prog = fp; in bpf_prog_realloc()
248 /* We keep fp->aux from fp_old around in the new in bpf_prog_realloc()
251 fp_old->aux = NULL; in bpf_prog_realloc()
262 if (fp->aux) { in __bpf_prog_free()
263 mutex_destroy(&fp->aux->used_maps_mutex); in __bpf_prog_free()
264 mutex_destroy(&fp->aux->dst_mutex); in __bpf_prog_free()
265 kfree(fp->aux->poke_tab); in __bpf_prog_free()
266 kfree(fp->aux); in __bpf_prog_free()
434 nr_linfo = prog->aux->nr_linfo; in bpf_adj_linfo()
438 linfo = prog->aux->linfo; in bpf_adj_linfo()
526 for (i = 0; i < fp->aux->func_cnt; i++) in bpf_prog_kallsyms_del_subprogs()
527 bpf_prog_kallsyms_del(fp->aux->func[i]); in bpf_prog_kallsyms_del_subprogs()
549 prog->aux->ksym.start = (unsigned long) prog->bpf_func; in bpf_prog_ksym_set_addr()
550 prog->aux->ksym.end = prog->aux->ksym.start + prog->jited_len; in bpf_prog_ksym_set_addr()
556 char *sym = prog->aux->ksym.name; in bpf_prog_ksym_set_name()
570 sizeof(prog->aux->name) > KSYM_NAME_LEN); in bpf_prog_ksym_set_name()
575 /* prog->aux->name will be ignored if full btf name is available */ in bpf_prog_ksym_set_name()
576 if (prog->aux->func_info_cnt) { in bpf_prog_ksym_set_name()
577 type = btf_type_by_id(prog->aux->btf, in bpf_prog_ksym_set_name()
578 prog->aux->func_info[prog->aux->func_idx].type_id); in bpf_prog_ksym_set_name()
579 func_name = btf_name_by_offset(prog->aux->btf, type->name_off); in bpf_prog_ksym_set_name()
584 if (prog->aux->name[0]) in bpf_prog_ksym_set_name()
585 snprintf(sym, (size_t)(end - sym), "_%s", prog->aux->name); in bpf_prog_ksym_set_name()
663 fp->aux->ksym.prog = true; in bpf_prog_kallsyms_add()
665 bpf_ksym_add(&fp->aux->ksym); in bpf_prog_kallsyms_add()
673 bpf_ksym_del(&fp->aux->ksym); in bpf_prog_kallsyms_del()
738 if (!prog->aux->num_exentries) in search_bpf_extables()
741 e = search_extable(prog->aux->extable, prog->aux->num_exentries, addr); in search_bpf_extables()
778 struct bpf_jit_poke_descriptor *tab = prog->aux->poke_tab; in bpf_jit_add_poke_descriptor()
780 u32 slot = prog->aux->size_poke_tab; in bpf_jit_add_poke_descriptor()
803 prog->aux->size_poke_tab = size; in bpf_jit_add_poke_descriptor()
804 prog->aux->poke_tab = tab; in bpf_jit_add_poke_descriptor()
1191 * can pick them up from prog->aux. in bpf_jit_get_func_addr()
1195 else if (prog->aux->func && in bpf_jit_get_func_addr()
1196 off >= 0 && off < prog->aux->func_cnt) in bpf_jit_get_func_addr()
1197 addr = (u8 *)prog->aux->func[off]->bpf_func; in bpf_jit_get_func_addr()
1214 const struct bpf_insn *aux, in bpf_jit_blind_insn() argument
1323 *to++ = BPF_ALU64_IMM(BPF_MOV, BPF_REG_AX, imm_rnd ^ aux[1].imm); in bpf_jit_blind_insn()
1326 *to++ = BPF_ALU64_REG(BPF_MOV, aux[0].dst_reg, BPF_REG_AX); in bpf_jit_blind_insn()
1329 *to++ = BPF_ALU32_IMM(BPF_MOV, BPF_REG_AX, imm_rnd ^ aux[0].imm); in bpf_jit_blind_insn()
1333 *to++ = BPF_ALU64_REG(BPF_OR, aux[0].dst_reg, BPF_REG_AX); in bpf_jit_blind_insn()
1357 /* aux->prog still points to the fp_other one, so in bpf_prog_clone_create()
1369 /* aux was stolen by the other clone, so we cannot free in bpf_prog_clone_free()
1376 fp->aux = NULL; in bpf_prog_clone_free()
1384 /* We have to repoint aux->prog to self, as we don't in bpf_jit_prog_release_other()
1387 fp->aux->prog = fp; in bpf_jit_prog_release_other()
1393 struct bpf_insn insn_buff[16], aux[2]; in bpf_jit_blind_constants() local
1426 memcpy(aux, insn, sizeof(aux)); in bpf_jit_blind_constants()
1428 rewritten = bpf_jit_blind_insn(insn, aux, insn_buff, in bpf_jit_blind_constants()
1429 clone->aux->verifier_zext); in bpf_jit_blind_constants()
1435 /* Patching may have repointed aux->prog during in bpf_jit_blind_constants()
2103 map->owner.xdp_has_frags = fp->aux->xdp_has_frags; in bpf_prog_map_compatible()
2108 map->owner.xdp_has_frags == fp->aux->xdp_has_frags; in bpf_prog_map_compatible()
2117 struct bpf_prog_aux *aux = fp->aux; in bpf_check_tail_call() local
2120 mutex_lock(&aux->used_maps_mutex); in bpf_check_tail_call()
2121 for (i = 0; i < aux->used_map_cnt; i++) { in bpf_check_tail_call()
2122 struct bpf_map *map = aux->used_maps[i]; in bpf_check_tail_call()
2134 mutex_unlock(&aux->used_maps_mutex); in bpf_check_tail_call()
2141 u32 stack_depth = max_t(u32, fp->aux->stack_depth, 1); in bpf_prog_select_func()
2182 if (!bpf_prog_is_dev_bound(fp->aux)) { in bpf_prog_select_runtime()
2296 prog_ids[i] = item->prog->aux->id; in bpf_prog_array_copy_core()
2490 void __bpf_free_used_maps(struct bpf_prog_aux *aux, in __bpf_free_used_maps() argument
2499 map->ops->map_poke_untrack(map, aux); in __bpf_free_used_maps()
2504 static void bpf_free_used_maps(struct bpf_prog_aux *aux) in bpf_free_used_maps() argument
2506 __bpf_free_used_maps(aux, aux->used_maps, aux->used_map_cnt); in bpf_free_used_maps()
2507 kfree(aux->used_maps); in bpf_free_used_maps()
2510 void __bpf_free_used_btfs(struct bpf_prog_aux *aux, in __bpf_free_used_btfs() argument
2526 static void bpf_free_used_btfs(struct bpf_prog_aux *aux) in bpf_free_used_btfs() argument
2528 __bpf_free_used_btfs(aux, aux->used_btfs, aux->used_btf_cnt); in bpf_free_used_btfs()
2529 kfree(aux->used_btfs); in bpf_free_used_btfs()
2534 struct bpf_prog_aux *aux; in bpf_prog_free_deferred() local
2537 aux = container_of(work, struct bpf_prog_aux, work); in bpf_prog_free_deferred()
2539 bpf_free_kfunc_btf_tab(aux->kfunc_btf_tab); in bpf_prog_free_deferred()
2542 if (aux->cgroup_atype != CGROUP_BPF_ATTACH_TYPE_INVALID) in bpf_prog_free_deferred()
2543 bpf_cgroup_atype_put(aux->cgroup_atype); in bpf_prog_free_deferred()
2545 bpf_free_used_maps(aux); in bpf_prog_free_deferred()
2546 bpf_free_used_btfs(aux); in bpf_prog_free_deferred()
2547 if (bpf_prog_is_dev_bound(aux)) in bpf_prog_free_deferred()
2548 bpf_prog_offload_destroy(aux->prog); in bpf_prog_free_deferred()
2550 if (aux->prog->has_callchain_buf) in bpf_prog_free_deferred()
2553 if (aux->dst_trampoline) in bpf_prog_free_deferred()
2554 bpf_trampoline_put(aux->dst_trampoline); in bpf_prog_free_deferred()
2555 for (i = 0; i < aux->func_cnt; i++) { in bpf_prog_free_deferred()
2560 aux->func[i]->aux->poke_tab = NULL; in bpf_prog_free_deferred()
2561 bpf_jit_free(aux->func[i]); in bpf_prog_free_deferred()
2563 if (aux->func_cnt) { in bpf_prog_free_deferred()
2564 kfree(aux->func); in bpf_prog_free_deferred()
2565 bpf_prog_unlock_free(aux->prog); in bpf_prog_free_deferred()
2567 bpf_jit_free(aux->prog); in bpf_prog_free_deferred()
2573 struct bpf_prog_aux *aux = fp->aux; in bpf_prog_free() local
2575 if (aux->dst_prog) in bpf_prog_free()
2576 bpf_prog_put(aux->dst_prog); in bpf_prog_free()
2577 INIT_WORK(&aux->work, bpf_prog_free_deferred); in bpf_prog_free()
2578 schedule_work(&aux->work); in bpf_prog_free()