build: disable experimental API check internally
[dpdk.git] / lib / librte_bpf / bpf_validate.c
index 83983ef..6bd6f78 100644 (file)
@@ -15,6 +15,8 @@
 
 #include "bpf_impl.h"
 
+#define BPF_ARG_PTR_STACK RTE_BPF_ARG_RESERVED
+
 struct bpf_reg_val {
        struct rte_bpf_arg v;
        uint64_t mask;
@@ -710,7 +712,7 @@ eval_ptr(struct bpf_verifier *bvf, struct bpf_reg_val *rm, uint32_t opsz,
        if (rm->u.max % align !=  0)
                return "unaligned memory access";
 
-       if (rm->v.type == RTE_BPF_ARG_PTR_STACK) {
+       if (rm->v.type == BPF_ARG_PTR_STACK) {
 
                if (rm->u.max != rm->u.min || rm->s.max != rm->s.min ||
                                rm->u.max != (uint64_t)rm->s.max)
@@ -764,7 +766,7 @@ eval_load(struct bpf_verifier *bvf, const struct ebpf_insn *ins)
        if (err != NULL)
                return err;
 
-       if (rs.v.type == RTE_BPF_ARG_PTR_STACK) {
+       if (rs.v.type == BPF_ARG_PTR_STACK) {
 
                sv = st->sv + rs.u.max / sizeof(uint64_t);
                if (sv->v.type == RTE_BPF_ARG_UNDEF || sv->mask < msk)
@@ -859,7 +861,7 @@ eval_store(struct bpf_verifier *bvf, const struct ebpf_insn *ins)
        if (err != NULL)
                return err;
 
-       if (rd.v.type == RTE_BPF_ARG_PTR_STACK) {
+       if (rd.v.type == BPF_ARG_PTR_STACK) {
 
                sv = st->sv + rd.u.max / sizeof(uint64_t);
                if (BPF_CLASS(ins->code) == BPF_STX &&
@@ -908,7 +910,7 @@ eval_func_arg(struct bpf_verifier *bvf, const struct rte_bpf_arg *arg,
                 * pointer to the variable on the stack is passed
                 * as an argument, mark stack space it occupies as initialized.
                 */
-               if (err == NULL && rv->v.type == RTE_BPF_ARG_PTR_STACK) {
+               if (err == NULL && rv->v.type == BPF_ARG_PTR_STACK) {
 
                        i = rv->u.max / sizeof(uint64_t);
                        n = i + arg->size / sizeof(uint64_t);
@@ -925,7 +927,6 @@ eval_func_arg(struct bpf_verifier *bvf, const struct rte_bpf_arg *arg,
 static const char *
 eval_call(struct bpf_verifier *bvf, const struct ebpf_insn *ins)
 {
-       uint64_t msk;
        uint32_t i, idx;
        struct bpf_reg_val *rv;
        const struct rte_bpf_xsym *xsym;
@@ -958,10 +959,11 @@ eval_call(struct bpf_verifier *bvf, const struct ebpf_insn *ins)
 
        rv = bvf->evst->rv + EBPF_REG_0;
        rv->v = xsym->func.ret;
-       msk = (rv->v.type == RTE_BPF_ARG_RAW) ?
-               RTE_LEN2MASK(rv->v.size * CHAR_BIT, uint64_t) : UINTPTR_MAX;
-       eval_max_bound(rv, msk);
-       rv->mask = msk;
+       if (rv->v.type == RTE_BPF_ARG_RAW)
+               eval_fill_max_bound(rv,
+                       RTE_LEN2MASK(rv->v.size * CHAR_BIT, uint64_t));
+       else if (RTE_BPF_ARG_PTR_TYPE(rv->v.type) != 0)
+               eval_fill_imm64(rv, UINTPTR_MAX, 0);
 
        return err;
 }
@@ -1084,7 +1086,7 @@ eval_jcc(struct bpf_verifier *bvf, const struct ebpf_insn *ins)
 /*
  * validate parameters for each instruction type.
  */
-static const struct bpf_ins_check ins_chk[UINT8_MAX] = {
+static const struct bpf_ins_check ins_chk[UINT8_MAX + 1] = {
        /* ALU IMM 32-bit instructions */
        [(BPF_ALU | BPF_ADD | BPF_K)] = {
                .mask = {.dreg = WRT_REGS, .sreg = ZERO_REG},
@@ -2131,7 +2133,7 @@ evaluate(struct bpf_verifier *bvf)
        /* initial state of frame pointer */
        static const struct bpf_reg_val rvfp = {
                .v = {
-                       .type = RTE_BPF_ARG_PTR_STACK,
+                       .type = BPF_ARG_PTR_STACK,
                        .size = MAX_BPF_STACK_SIZE,
                },
                .mask = UINT64_MAX,