From: Paul Chaignon <paul.chaignon@orange.com>
To: "Björn Töpel" <bjorn.topel@gmail.com>
Cc: Paul Burton <paulburton@kernel.org>,
Mahshid Khezri <khezri.mahshid@gmail.com>,
paul.chaignon@gmail.com, bpf <bpf@vger.kernel.org>,
Netdev <netdev@vger.kernel.org>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
Yonghong Song <yhs@fb.com>, Andrii Nakryiko <andriin@fb.com>,
linux-riscv@lists.infradead.org
Subject: Re: [PATCH bpf 1/2] bpf, riscv: limit to 33 tail calls
Date: Tue, 10 Dec 2019 10:36:06 +0100 [thread overview]
Message-ID: <20191210093605.GA31145@Nover> (raw)
In-Reply-To: <CAJ+HfNgFo8viKn3KzNfbmniPNUpjOv_QM4ua_V0RFLBpWCOBYw@mail.gmail.com>
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
> >
next prev parent reply other threads:[~2019-12-10 9:36 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-09 18:51 [PATCH bpf 0/2] Limit tail calls to 33 in all JIT compilers Paul Chaignon
2019-12-09 18:52 ` [PATCH bpf 1/2] bpf, riscv: limit to 33 tail calls Paul Chaignon
2019-12-09 19:57 ` Björn Töpel
2019-12-10 6:31 ` Björn Töpel
2019-12-10 9:36 ` Paul Chaignon [this message]
2019-12-09 18:52 ` [PATCH bpf 2/2] bpf, mips: " Paul Chaignon
2019-12-10 23:23 ` Paul Burton
2019-12-12 16:19 ` Daniel Borkmann
2019-12-18 9:32 ` Alexander Lobakin
2019-12-18 9:58 ` Paul Chaignon
2019-12-18 10:02 ` Alexander Lobakin
2019-12-10 18:19 ` [PATCH bpf 0/2] Limit tail calls to 33 in all JIT compilers Martin Lau
2019-12-11 13:00 ` Daniel Borkmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191210093605.GA31145@Nover \
--to=paul.chaignon@orange.com \
--cc=andriin@fb.com \
--cc=ast@kernel.org \
--cc=bjorn.topel@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kafai@fb.com \
--cc=khezri.mahshid@gmail.com \
--cc=linux-riscv@lists.infradead.org \
--cc=netdev@vger.kernel.org \
--cc=paul.chaignon@gmail.com \
--cc=paulburton@kernel.org \
--cc=songliubraving@fb.com \
--cc=yhs@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).