Lines Matching full:env
16 #define pr_vlog(env, fmt, ...) \ argument
17 bpf_verifier_log_write(env, "[nfp] " fmt, ##__VA_ARGS__)
83 static bool nfp_bpf_map_update_value_ok(struct bpf_verifier_env *env) in nfp_bpf_map_update_value_ok() argument
85 const struct bpf_reg_state *reg1 = cur_regs(env) + BPF_REG_1; in nfp_bpf_map_update_value_ok()
86 const struct bpf_reg_state *reg3 = cur_regs(env) + BPF_REG_3; in nfp_bpf_map_update_value_ok()
92 state = env->cur_state->frame[reg3->frameno]; in nfp_bpf_map_update_value_ok()
113 …pr_vlog(env, "value at offset %d/%d may be non-zero, bpf_map_update_elem() is required to initiali… in nfp_bpf_map_update_value_ok()
124 nfp_bpf_stack_arg_ok(const char *fname, struct bpf_verifier_env *env, in nfp_bpf_stack_arg_ok() argument
131 pr_vlog(env, "%s: unsupported ptr type %d\n", in nfp_bpf_stack_arg_ok()
136 pr_vlog(env, "%s: variable pointer\n", fname); in nfp_bpf_stack_arg_ok()
142 pr_vlog(env, "%s: unaligned stack pointer %lld\n", fname, -off); in nfp_bpf_stack_arg_ok()
157 nfp_bpf_map_call_ok(const char *fname, struct bpf_verifier_env *env, in nfp_bpf_map_call_ok() argument
162 pr_vlog(env, "%s: not supported by FW\n", fname); in nfp_bpf_map_call_ok()
171 struct bpf_verifier_env *env, in nfp_bpf_check_helper_call() argument
174 const struct bpf_reg_state *reg1 = cur_regs(env) + BPF_REG_1; in nfp_bpf_check_helper_call()
175 const struct bpf_reg_state *reg2 = cur_regs(env) + BPF_REG_2; in nfp_bpf_check_helper_call()
176 const struct bpf_reg_state *reg3 = cur_regs(env) + BPF_REG_3; in nfp_bpf_check_helper_call()
183 pr_vlog(env, "adjust_head not supported by FW\n"); in nfp_bpf_check_helper_call()
187 pr_vlog(env, "adjust_head: FW requires shifting metadata, not supported by the driver\n"); in nfp_bpf_check_helper_call()
196 pr_vlog(env, "adjust_tail not supported by FW\n"); in nfp_bpf_check_helper_call()
202 if (!nfp_bpf_map_call_ok("map_lookup", env, meta, in nfp_bpf_check_helper_call()
204 !nfp_bpf_stack_arg_ok("map_lookup", env, reg2, in nfp_bpf_check_helper_call()
210 if (!nfp_bpf_map_call_ok("map_update", env, meta, in nfp_bpf_check_helper_call()
212 !nfp_bpf_stack_arg_ok("map_update", env, reg2, in nfp_bpf_check_helper_call()
214 !nfp_bpf_stack_arg_ok("map_update", env, reg3, NULL) || in nfp_bpf_check_helper_call()
215 !nfp_bpf_map_update_value_ok(env)) in nfp_bpf_check_helper_call()
220 if (!nfp_bpf_map_call_ok("map_delete", env, meta, in nfp_bpf_check_helper_call()
222 !nfp_bpf_stack_arg_ok("map_delete", env, reg2, in nfp_bpf_check_helper_call()
230 pr_vlog(env, "bpf_get_prandom_u32(): FW doesn't support random number generation\n"); in nfp_bpf_check_helper_call()
240 pr_vlog(env, "event_output: not supported by FW\n"); in nfp_bpf_check_helper_call()
253 pr_vlog(env, "event_output: must use BPF_F_CURRENT_CPU, var_off: %s\n", in nfp_bpf_check_helper_call()
261 reg1 = cur_regs(env) + BPF_REG_4; in nfp_bpf_check_helper_call()
267 pr_vlog(env, "event_output: unsupported ptr type: %d\n", in nfp_bpf_check_helper_call()
273 !nfp_bpf_stack_arg_ok("event_output", env, reg1, NULL)) in nfp_bpf_check_helper_call()
286 pr_vlog(env, "warning: return codes and behavior of event_output helper differ for offload!\n"); in nfp_bpf_check_helper_call()
292 pr_vlog(env, "event_output: ptr type changed: %d %d\n", in nfp_bpf_check_helper_call()
299 pr_vlog(env, "unsupported function id: %d\n", func_id); in nfp_bpf_check_helper_call()
312 struct bpf_verifier_env *env) in nfp_bpf_check_exit() argument
314 const struct bpf_reg_state *reg0 = cur_regs(env) + BPF_REG_0; in nfp_bpf_check_exit()
324 pr_vlog(env, "unsupported exit state: %d, var_off: %s\n", in nfp_bpf_check_exit()
334 pr_vlog(env, "unsupported exit state: %d, imm: %llx\n", in nfp_bpf_check_exit()
346 struct bpf_verifier_env *env) in nfp_bpf_check_stack_access() argument
350 if (reg->frameno != env->cur_state->curframe) in nfp_bpf_check_stack_access()
354 pr_vlog(env, "variable ptr stack access\n"); in nfp_bpf_check_stack_access()
372 pr_vlog(env, "stack access changed location was:%d is:%d\n", in nfp_bpf_check_stack_access()
392 nfp_bpf_map_mark_used_one(struct bpf_verifier_env *env, in nfp_bpf_map_mark_used_one() argument
398 pr_vlog(env, "map value use type conflict %s vs %s off: %u\n", in nfp_bpf_map_mark_used_one()
406 pr_vlog(env, "atomic counter in map value may already be initialized to non-zero value off: %u\n", in nfp_bpf_map_mark_used_one()
417 nfp_bpf_map_mark_used(struct bpf_verifier_env *env, struct nfp_insn_meta *meta, in nfp_bpf_map_mark_used() argument
427 pr_vlog(env, "map value offset is variable\n"); in nfp_bpf_map_mark_used()
437 pr_vlog(env, "map value access out-of-bounds\n"); in nfp_bpf_map_mark_used()
442 err = nfp_bpf_map_mark_used_one(env, nfp_map, off + i, use); in nfp_bpf_map_mark_used()
452 struct bpf_verifier_env *env, u8 reg_no) in nfp_bpf_check_ptr() argument
454 const struct bpf_reg_state *reg = cur_regs(env) + reg_no; in nfp_bpf_check_ptr()
461 pr_vlog(env, "unsupported ptr type: %d\n", reg->type); in nfp_bpf_check_ptr()
466 err = nfp_bpf_check_stack_access(nfp_prog, meta, reg, env); in nfp_bpf_check_ptr()
473 err = nfp_bpf_map_mark_used(env, meta, reg, in nfp_bpf_check_ptr()
479 pr_vlog(env, "map writes not supported\n"); in nfp_bpf_check_ptr()
483 err = nfp_bpf_map_mark_used(env, meta, reg, in nfp_bpf_check_ptr()
491 pr_vlog(env, "ptr type changed for instruction %d -> %d\n", in nfp_bpf_check_ptr()
503 struct bpf_verifier_env *env) in nfp_bpf_check_store() argument
505 const struct bpf_reg_state *reg = cur_regs(env) + meta->insn.dst_reg; in nfp_bpf_check_store()
514 pr_vlog(env, "queue selection not supported by FW\n"); in nfp_bpf_check_store()
518 pr_vlog(env, "unsupported store to context field\n"); in nfp_bpf_check_store()
522 return nfp_bpf_check_ptr(nfp_prog, meta, env, meta->insn.dst_reg); in nfp_bpf_check_store()
527 struct bpf_verifier_env *env) in nfp_bpf_check_atomic() argument
529 const struct bpf_reg_state *sreg = cur_regs(env) + meta->insn.src_reg; in nfp_bpf_check_atomic()
530 const struct bpf_reg_state *dreg = cur_regs(env) + meta->insn.dst_reg; in nfp_bpf_check_atomic()
533 pr_vlog(env, "atomic op not implemented: %d\n", meta->insn.imm); in nfp_bpf_check_atomic()
538 pr_vlog(env, "atomic add not to a map value pointer: %d\n", in nfp_bpf_check_atomic()
543 pr_vlog(env, "atomic add not of a scalar: %d\n", sreg->type); in nfp_bpf_check_atomic()
552 return nfp_bpf_check_ptr(nfp_prog, meta, env, meta->insn.dst_reg); in nfp_bpf_check_atomic()
557 struct bpf_verifier_env *env) in nfp_bpf_check_alu() argument
560 cur_regs(env) + meta->insn.src_reg; in nfp_bpf_check_alu()
562 cur_regs(env) + meta->insn.dst_reg; in nfp_bpf_check_alu()
583 pr_vlog(env, "multiplier is not within u32 value range\n"); in nfp_bpf_check_alu()
587 pr_vlog(env, "multiplicand is not within u32 value range\n"); in nfp_bpf_check_alu()
592 pr_vlog(env, "sign extended multiplicand won't be within u32 value range\n"); in nfp_bpf_check_alu()
609 pr_vlog(env, "dividend is not within u32 value range\n"); in nfp_bpf_check_alu()
614 pr_vlog(env, "divisor is not constant\n"); in nfp_bpf_check_alu()
618 pr_vlog(env, "divisor is not within u32 value range\n"); in nfp_bpf_check_alu()
623 pr_vlog(env, "divide by negative constant is not supported\n"); in nfp_bpf_check_alu()
631 int nfp_verify_insn(struct bpf_verifier_env *env, int insn_idx, in nfp_verify_insn() argument
634 struct nfp_prog *nfp_prog = env->prog->aux->offload->dev_priv; in nfp_verify_insn()
641 pr_vlog(env, "instruction %#02x not supported\n", in nfp_verify_insn()
648 pr_vlog(env, "program uses extended registers - jit hardening?\n"); in nfp_verify_insn()
653 return nfp_bpf_check_helper_call(nfp_prog, env, meta); in nfp_verify_insn()
655 return nfp_bpf_check_exit(nfp_prog, env); in nfp_verify_insn()
658 return nfp_bpf_check_ptr(nfp_prog, meta, env, in nfp_verify_insn()
661 return nfp_bpf_check_store(nfp_prog, meta, env); in nfp_verify_insn()
664 return nfp_bpf_check_atomic(nfp_prog, meta, env); in nfp_verify_insn()
667 return nfp_bpf_check_alu(nfp_prog, meta, env); in nfp_verify_insn()
673 nfp_assign_subprog_idx_and_regs(struct bpf_verifier_env *env, in nfp_assign_subprog_idx_and_regs() argument
690 …pr_vlog(env, "BUG: number of processed BPF functions is not consistent (processed %d, expected %d)… in nfp_assign_subprog_idx_and_regs()
763 int nfp_bpf_finalize(struct bpf_verifier_env *env) in nfp_bpf_finalize() argument
771 nfp_prog = env->prog->aux->offload->dev_priv; in nfp_bpf_finalize()
772 nfp_prog->subprog_cnt = env->subprog_cnt; in nfp_bpf_finalize()
778 nfp_assign_subprog_idx_and_regs(env, nfp_prog); in nfp_bpf_finalize()
780 info = env->subprog_info; in nfp_bpf_finalize()
794 nn = netdev_priv(env->prog->aux->offload->netdev); in nfp_bpf_finalize()
798 pr_vlog(env, "stack too large: program %dB > FW stack %dB\n", in nfp_bpf_finalize()
803 nfp_bpf_insn_flag_zext(nfp_prog, env->insn_aux_data); in nfp_bpf_finalize()
807 int nfp_bpf_opt_replace_insn(struct bpf_verifier_env *env, u32 off, in nfp_bpf_opt_replace_insn() argument
810 struct nfp_prog *nfp_prog = env->prog->aux->offload->dev_priv; in nfp_bpf_opt_replace_insn()
811 struct bpf_insn_aux_data *aux_data = env->insn_aux_data; in nfp_bpf_opt_replace_insn()
828 pr_vlog(env, "branch hard wire at %d changes target %d -> %d\n", in nfp_bpf_opt_replace_insn()
836 pr_vlog(env, "unsupported instruction replacement %hhx -> %hhx\n", in nfp_bpf_opt_replace_insn()
841 int nfp_bpf_opt_remove_insns(struct bpf_verifier_env *env, u32 off, u32 cnt) in nfp_bpf_opt_remove_insns() argument
843 struct nfp_prog *nfp_prog = env->prog->aux->offload->dev_priv; in nfp_bpf_opt_remove_insns()
844 struct bpf_insn_aux_data *aux_data = env->insn_aux_data; in nfp_bpf_opt_remove_insns()