| 986 | } |
| 987 | |
| 988 | static const char * |
| 989 | eval_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 | |
| 1032 | static void |
| 1033 | eval_jeq_jne(struct bpf_reg_val *trd, struct bpf_reg_val *trs) |
nothing calls this directly
no test coverage detected