bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paul Chaignon <paul.chaignon@orange.com>
To: Alexander Lobakin <alobakin@dlink.ru>
Cc: "Paul Burton" <paulburton@kernel.org>,
	"Björn Töpel" <bjorn.topel@gmail.com>,
	"Mahshid Khezri" <khezri.mahshid@gmail.com>,
	paul.chaignon@gmail.com, bpf@vger.kernel.org,
	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>
Subject: Re: [PATCH bpf 2/2] bpf, mips: limit to 33 tail calls
Date: Wed, 18 Dec 2019 10:58:25 +0100	[thread overview]
Message-ID: <20191218095825.GA15840@Omicron> (raw)
In-Reply-To: <8cf09e73329b3205a64eae4886b02fea@dlink.ru>

On Wed, Dec 18, 2019 at 12:32:53PM +0300, Alexander Lobakin wrote:
> Paul Burton wrote 11.12.2019 02:23:
> > Hi Paul,
> > 
> > On Mon, Dec 09, 2019 at 07:52:52PM +0100, Paul Chaignon 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 MIPS' JIT compiler to allow
> > > 33 tail calls.
> 
> Hi Paul,
> 
> You've restored MIPS cBPF in mips-fixes tree, doesn't it require any
> changes to limit tail calls to 33? This series includes only eBPF as
> there was no MIPS cBPF at the moment of writing.

cBPF doesn't support tail calls or even the call instruction for
helpers.

Paul C.

> 
> > > Fixes: b6bd53f9c4e8 ("MIPS: Add missing file for eBPF JIT.")
> > > Reported-by: Mahshid Khezri <khezri.mahshid@gmail.com>
> > > Signed-off-by: Paul Chaignon <paul.chaignon@orange.com>
> > 
> > I'd be happy to take this through mips-fixes, but equally happy for it
> > to go through the BPF/net trees in which case:
> > 
> >   Acked-by: Paul Burton <paulburton@kernel.org>
> > 
> > Thanks,
> >     Paul
> > 
> > > ---
> > >  arch/mips/net/ebpf_jit.c | 9 +++++----
> > >  1 file changed, 5 insertions(+), 4 deletions(-)
> > > 
> > > diff --git a/arch/mips/net/ebpf_jit.c b/arch/mips/net/ebpf_jit.c
> > > index 46b76751f3a5..3ec69d9cbe88 100644
> > > --- a/arch/mips/net/ebpf_jit.c
> > > +++ b/arch/mips/net/ebpf_jit.c
> > > @@ -604,6 +604,7 @@ static void emit_const_to_reg(struct jit_ctx
> > > *ctx, int dst, u64 value)
> > >  static int emit_bpf_tail_call(struct jit_ctx *ctx, int this_idx)
> > >  {
> > >  	int off, b_off;
> > > +	int tcc_reg;
> > > 
> > >  	ctx->flags |= EBPF_SEEN_TC;
> > >  	/*
> > > @@ -616,14 +617,14 @@ static int emit_bpf_tail_call(struct jit_ctx
> > > *ctx, int this_idx)
> > >  	b_off = b_imm(this_idx + 1, ctx);
> > >  	emit_instr(ctx, bne, MIPS_R_AT, MIPS_R_ZERO, b_off);
> > >  	/*
> > > -	 * if (--TCC < 0)
> > > +	 * if (TCC-- < 0)
> > >  	 *     goto out;
> > >  	 */
> > >  	/* Delay slot */
> > > -	emit_instr(ctx, daddiu, MIPS_R_T5,
> > > -		   (ctx->flags & EBPF_TCC_IN_V1) ? MIPS_R_V1 : MIPS_R_S4, -1);
> > > +	tcc_reg = (ctx->flags & EBPF_TCC_IN_V1) ? MIPS_R_V1 : MIPS_R_S4;
> > > +	emit_instr(ctx, daddiu, MIPS_R_T5, tcc_reg, -1);
> > >  	b_off = b_imm(this_idx + 1, ctx);
> > > -	emit_instr(ctx, bltz, MIPS_R_T5, b_off);
> > > +	emit_instr(ctx, bltz, tcc_reg, b_off);
> > >  	/*
> > >  	 * prog = array->ptrs[index];
> > >  	 * if (prog == NULL)
> > > --
> > > 2.17.1
> > > 
> 
> Regards,
> ᚷ ᛖ ᚢ ᚦ ᚠ ᚱ

  reply	other threads:[~2019-12-18  9:58 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
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 [this message]
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=20191218095825.GA15840@Omicron \
    --to=paul.chaignon@orange.com \
    --cc=alobakin@dlink.ru \
    --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=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).