* Re: [PATCH bpf 1/2] bpf, riscv: limit to 33 tail calls
2019-12-09 19:57 ` [PATCH bpf 1/2] bpf, riscv: limit to 33 tail calls Björn Töpel
@ 2019-12-10 6:31 ` Björn Töpel
2019-12-10 9:36 ` Paul Chaignon
1 sibling, 0 replies; 3+ messages in thread
From: Björn Töpel @ 2019-12-10 6:31 UTC (permalink / raw)
To: Paul Chaignon
Cc: Song Liu, Daniel Borkmann, Paul Burton, paul.chaignon, Netdev,
Alexei Starovoitov, linux-riscv, Martin KaFai Lau, Yonghong Song,
Mahshid Khezri, Andrii Nakryiko, bpf
On Mon, 9 Dec 2019 at 20:57, Björn Töpel <bjorn.topel@gmail.com> wrote:
>
> On Mon, 9 Dec 2019 at 19:52, Paul Chaignon <paul.chaignon@orange.com> wrote:
> >
> > All BPF JIT compilers except RISC-V's and MIPS' enforce a 33-tail calls
> > limit at runtime. In addition, a test was recently added, in tailcalls2,
> > to check this limit.
> >
> > This patch updates the tail call limit in RISC-V's JIT compiler to allow
> > 33 tail calls. I tested it using the above selftest on an emulated
> > RISCV64.
> >
>
> 33! ICK! ;-) Thanks for finding this!
>
> Acked-by: Björn Töpel <bjorn.topel@gmail.com>
>
...and somewhat related; One of the tailcall tests fail due to missing
far-branch support in the emitter. I'll address this in the v2 of the
"far branch" series.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH bpf 1/2] bpf, riscv: limit to 33 tail calls
2019-12-09 19:57 ` [PATCH bpf 1/2] bpf, riscv: limit to 33 tail calls Björn Töpel
2019-12-10 6:31 ` Björn Töpel
@ 2019-12-10 9:36 ` Paul Chaignon
1 sibling, 0 replies; 3+ messages in thread
From: Paul Chaignon @ 2019-12-10 9:36 UTC (permalink / raw)
To: Björn Töpel
Cc: Song Liu, Daniel Borkmann, Paul Burton, paul.chaignon, Netdev,
Alexei Starovoitov, linux-riscv, Martin KaFai Lau, Yonghong Song,
Mahshid Khezri, Andrii Nakryiko, bpf
On Mon, Dec 09, 2019 at 08:57:27PM +0100, Björn Töpel wrote:
> On Mon, 9 Dec 2019 at 19:52, Paul Chaignon <paul.chaignon@orange.com> wrote:
> >
> > All BPF JIT compilers except RISC-V's and MIPS' enforce a 33-tail calls
> > limit at runtime. In addition, a test was recently added, in tailcalls2,
> > to check this limit.
> >
> > This patch updates the tail call limit in RISC-V's JIT compiler to allow
> > 33 tail calls. I tested it using the above selftest on an emulated
> > RISCV64.
> >
>
> 33! ICK! ;-) Thanks for finding this!
Actually, Mahshid found it during her internship because she wanted to
check that the number of tail calls was limited. And now I feel so
naive for trusting the doc...
>
> Acked-by: Björn Töpel <bjorn.topel@gmail.com>
>
> > Fixes: 2353ecc6f91f ("bpf, riscv: add BPF JIT for RV64G")
> > Reported-by: Mahshid Khezri <khezri.mahshid@gmail.com>
> > Signed-off-by: Paul Chaignon <paul.chaignon@orange.com>
> > ---
> > arch/riscv/net/bpf_jit_comp.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/arch/riscv/net/bpf_jit_comp.c b/arch/riscv/net/bpf_jit_comp.c
> > index 5451ef3845f2..7fbf56aab661 100644
> > --- a/arch/riscv/net/bpf_jit_comp.c
> > +++ b/arch/riscv/net/bpf_jit_comp.c
> > @@ -631,14 +631,14 @@ static int emit_bpf_tail_call(int insn, struct rv_jit_context *ctx)
> > return -1;
> > emit(rv_bgeu(RV_REG_A2, RV_REG_T1, off >> 1), ctx);
> >
> > - /* if (--TCC < 0)
> > + /* if (TCC-- < 0)
> > * goto out;
> > */
> > emit(rv_addi(RV_REG_T1, tcc, -1), ctx);
> > off = (tc_ninsn - (ctx->ninsns - start_insn)) << 2;
> > if (is_13b_check(off, insn))
> > return -1;
> > - emit(rv_blt(RV_REG_T1, RV_REG_ZERO, off >> 1), ctx);
> > + emit(rv_blt(tcc, RV_REG_ZERO, off >> 1), ctx);
> >
> > /* prog = array->ptrs[index];
> > * if (!prog)
> > --
> > 2.17.1
> >
^ permalink raw reply [flat|nested] 3+ messages in thread