Commit e8a4796e authored by Jakub Kicinski's avatar Jakub Kicinski Committed by Alexei Starovoitov

nfp: bpf: fix check of program max insn count

NFP program allocation length is in bytes and NFP program length
is in instructions, fix the comparison of the two.

Fixes: 9314c442 ("nfp: bpf: move translation prepare to offload.c")
Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: default avatarJiong Wang <jiong.wang@netronome.com>
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent 4b6eca9d
...@@ -74,7 +74,9 @@ nfp_meta_has_prev(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta) ...@@ -74,7 +74,9 @@ nfp_meta_has_prev(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta)
static void nfp_prog_push(struct nfp_prog *nfp_prog, u64 insn) static void nfp_prog_push(struct nfp_prog *nfp_prog, u64 insn)
{ {
if (nfp_prog->__prog_alloc_len == nfp_prog->prog_len) { if (nfp_prog->__prog_alloc_len / sizeof(u64) == nfp_prog->prog_len) {
pr_warn("instruction limit reached (%u NFP instructions)\n",
nfp_prog->prog_len);
nfp_prog->error = -ENOSPC; nfp_prog->error = -ENOSPC;
return; return;
} }
...@@ -2463,6 +2465,8 @@ static int nfp_translate(struct nfp_prog *nfp_prog) ...@@ -2463,6 +2465,8 @@ static int nfp_translate(struct nfp_prog *nfp_prog)
err = cb(nfp_prog, meta); err = cb(nfp_prog, meta);
if (err) if (err)
return err; return err;
if (nfp_prog->error)
return nfp_prog->error;
nfp_prog->n_translated++; nfp_prog->n_translated++;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment