MCPcopy Create free account
hub / github.com/F-Stack/f-stack / eval_call

Function eval_call

dpdk/lib/bpf/bpf_validate.c:988–1030  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

986}
987
988static const char *
989eval_call(struct bpf_verifier *bvf, const struct ebpf_insn *ins)
990{
991 uint32_t i, idx;
992 struct bpf_reg_val *rv;
993 const struct rte_bpf_xsym *xsym;
994 const char *err;
995
996 idx = ins->imm;
997
998 if (idx >= bvf->prm->nb_xsym ||
999 bvf->prm->xsym[idx].type != RTE_BPF_XTYPE_FUNC)
1000 return "invalid external function index";
1001
1002 /* for now don't support function calls on 32 bit platform */
1003 if (sizeof(uint64_t) != sizeof(uintptr_t))
1004 return "function calls are supported only for 64 bit apps";
1005
1006 xsym = bvf->prm->xsym + idx;
1007
1008 /* evaluate function arguments */
1009 err = NULL;
1010 for (i = 0; i != xsym->func.nb_args && err == NULL; i++) {
1011 err = eval_func_arg(bvf, xsym->func.args + i,
1012 bvf->evst->rv + EBPF_REG_1 + i);
1013 }
1014
1015 /* R1-R5 argument/scratch registers */
1016 for (i = EBPF_REG_1; i != EBPF_REG_6; i++)
1017 bvf->evst->rv[i].v.type = RTE_BPF_ARG_UNDEF;
1018
1019 /* update return value */
1020
1021 rv = bvf->evst->rv + EBPF_REG_0;
1022 rv->v = xsym->func.ret;
1023 if (rv->v.type == RTE_BPF_ARG_RAW)
1024 eval_fill_max_bound(rv,
1025 RTE_LEN2MASK(rv->v.size * CHAR_BIT, uint64_t));
1026 else if (RTE_BPF_ARG_PTR_TYPE(rv->v.type) != 0)
1027 eval_fill_imm64(rv, UINTPTR_MAX, 0);
1028
1029 return err;
1030}
1031
1032static void
1033eval_jeq_jne(struct bpf_reg_val *trd, struct bpf_reg_val *trs)

Callers

nothing calls this directly

Calls 3

eval_func_argFunction · 0.85
eval_fill_max_boundFunction · 0.85
eval_fill_imm64Function · 0.85

Tested by

no test coverage detected