* [PATCH bpf 0/2] Limit tail calls to 33 in all JIT compilers
@ 2019-12-09 18:51 Paul Chaignon
2019-12-09 18:52 ` [PATCH bpf 1/2] bpf, riscv: limit to 33 tail calls Paul Chaignon
` (3 more replies)
0 siblings, 4 replies; 13+ messages in thread
From: Paul Chaignon @ 2019-12-09 18:51 UTC (permalink / raw)
To: Paul Burton, Björn Töpel
Cc: Mahshid Khezri, paul.chaignon, bpf, netdev, Alexei Starovoitov,
Daniel Borkmann, Martin KaFai Lau, Song Liu, Yonghong Song,
Andrii Nakryiko
The BPF interpreter and all JIT compilers, except RISC-V's and MIPS',
enforce a 33-tail calls limit at runtime. Because of this discrepancy, a
BPF program can have a different behavior and output depending on whether
it is interpreted or JIT compiled, or depending on the underlying
architecture.
This patchset changes the RISC-V and MIPS JIT compilers to limit tail
calls to 33 instead of 32. I have checked other BPF JIT compilers for the
same discrepancy.
Paul Chaignon (2):
bpf, riscv: limit to 33 tail calls
bpf, mips: limit to 33 tail calls
arch/mips/net/ebpf_jit.c | 9 +++++----
arch/riscv/net/bpf_jit_comp.c | 4 ++--
2 files changed, 7 insertions(+), 6 deletions(-)
--
2.17.1
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH bpf 1/2] bpf, riscv: limit to 33 tail calls
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 ` Paul Chaignon
2019-12-09 19:57 ` Björn Töpel
2019-12-09 18:52 ` [PATCH bpf 2/2] bpf, mips: " Paul Chaignon
` (2 subsequent siblings)
3 siblings, 1 reply; 13+ messages in thread
From: Paul Chaignon @ 2019-12-09 18:52 UTC (permalink / raw)
To: Paul Burton, Björn Töpel
Cc: Mahshid Khezri, paul.chaignon, bpf, netdev, Alexei Starovoitov,
Daniel Borkmann, Martin KaFai Lau, Song Liu, Yonghong Song,
Andrii Nakryiko
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.
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 related [flat|nested] 13+ messages in thread
* [PATCH bpf 2/2] bpf, mips: limit to 33 tail calls
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 18:52 ` Paul Chaignon
2019-12-10 23:23 ` Paul Burton
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
3 siblings, 1 reply; 13+ messages in thread
From: Paul Chaignon @ 2019-12-09 18:52 UTC (permalink / raw)
To: Paul Burton, Björn Töpel
Cc: Mahshid Khezri, paul.chaignon, bpf, netdev, Alexei Starovoitov,
Daniel Borkmann, Martin KaFai Lau, Song Liu, Yonghong Song,
Andrii Nakryiko
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.
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>
---
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
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH bpf 1/2] bpf, riscv: limit to 33 tail calls
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
0 siblings, 2 replies; 13+ messages in thread
From: Björn Töpel @ 2019-12-09 19:57 UTC (permalink / raw)
To: Paul Chaignon
Cc: Paul Burton, Mahshid Khezri, paul.chaignon, bpf, Netdev,
Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Song Liu,
Yonghong Song, Andrii Nakryiko, linux-riscv
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>
> 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] 13+ messages in thread
* Re: [PATCH bpf 1/2] bpf, riscv: limit to 33 tail calls
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
1 sibling, 0 replies; 13+ messages in thread
From: Björn Töpel @ 2019-12-10 6:31 UTC (permalink / raw)
To: Paul Chaignon
Cc: Paul Burton, Mahshid Khezri, paul.chaignon, bpf, Netdev,
Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Song Liu,
Yonghong Song, Andrii Nakryiko, linux-riscv
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] 13+ messages in thread
* Re: [PATCH bpf 1/2] bpf, riscv: limit to 33 tail calls
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
1 sibling, 0 replies; 13+ messages in thread
From: Paul Chaignon @ 2019-12-10 9:36 UTC (permalink / raw)
To: Björn Töpel
Cc: Paul Burton, Mahshid Khezri, paul.chaignon, bpf, Netdev,
Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Song Liu,
Yonghong Song, Andrii Nakryiko, linux-riscv
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] 13+ messages in thread
* Re: [PATCH bpf 0/2] Limit tail calls to 33 in all JIT compilers
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 18:52 ` [PATCH bpf 2/2] bpf, mips: " Paul Chaignon
@ 2019-12-10 18:19 ` Martin Lau
2019-12-11 13:00 ` Daniel Borkmann
3 siblings, 0 replies; 13+ messages in thread
From: Martin Lau @ 2019-12-10 18:19 UTC (permalink / raw)
To: Paul Chaignon
Cc: Paul Burton, Björn Töpel, Mahshid Khezri,
paul.chaignon, bpf, netdev, Alexei Starovoitov, Daniel Borkmann,
Song Liu, Yonghong Song, Andrii Nakryiko
On Mon, Dec 09, 2019 at 07:51:52PM +0100, Paul Chaignon wrote:
> The BPF interpreter and all JIT compilers, except RISC-V's and MIPS',
> enforce a 33-tail calls limit at runtime. Because of this discrepancy, a
> BPF program can have a different behavior and output depending on whether
> it is interpreted or JIT compiled, or depending on the underlying
> architecture.
>
> This patchset changes the RISC-V and MIPS JIT compilers to limit tail
> calls to 33 instead of 32. I have checked other BPF JIT compilers for the
> same discrepancy.
Acked-by: Martin KaFai Lau <kafai@fb.com>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH bpf 2/2] bpf, mips: limit to 33 tail calls
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
0 siblings, 2 replies; 13+ messages in thread
From: Paul Burton @ 2019-12-10 23:23 UTC (permalink / raw)
To: Paul Chaignon
Cc: Björn Töpel, Mahshid Khezri, paul.chaignon, bpf,
netdev, Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau,
Song Liu, Yonghong Song, Andrii Nakryiko
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.
>
> 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
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH bpf 0/2] Limit tail calls to 33 in all JIT compilers
2019-12-09 18:51 [PATCH bpf 0/2] Limit tail calls to 33 in all JIT compilers Paul Chaignon
` (2 preceding siblings ...)
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
3 siblings, 0 replies; 13+ messages in thread
From: Daniel Borkmann @ 2019-12-11 13:00 UTC (permalink / raw)
To: Paul Chaignon
Cc: Paul Burton, Björn Töpel, Mahshid Khezri,
paul.chaignon, bpf, netdev, Alexei Starovoitov, Martin KaFai Lau,
Song Liu, Yonghong Song, Andrii Nakryiko
On Mon, Dec 09, 2019 at 07:51:52PM +0100, Paul Chaignon wrote:
> The BPF interpreter and all JIT compilers, except RISC-V's and MIPS',
> enforce a 33-tail calls limit at runtime. Because of this discrepancy, a
> BPF program can have a different behavior and output depending on whether
> it is interpreted or JIT compiled, or depending on the underlying
> architecture.
>
> This patchset changes the RISC-V and MIPS JIT compilers to limit tail
> calls to 33 instead of 32. I have checked other BPF JIT compilers for the
> same discrepancy.
>
> Paul Chaignon (2):
> bpf, riscv: limit to 33 tail calls
> bpf, mips: limit to 33 tail calls
>
> arch/mips/net/ebpf_jit.c | 9 +++++----
> arch/riscv/net/bpf_jit_comp.c | 4 ++--
> 2 files changed, 7 insertions(+), 6 deletions(-)
Applied, thanks!
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH bpf 2/2] bpf, mips: limit to 33 tail calls
2019-12-10 23:23 ` Paul Burton
@ 2019-12-12 16:19 ` Daniel Borkmann
2019-12-18 9:32 ` Alexander Lobakin
1 sibling, 0 replies; 13+ messages in thread
From: Daniel Borkmann @ 2019-12-12 16:19 UTC (permalink / raw)
To: Paul Burton
Cc: Paul Chaignon, Björn Töpel, Mahshid Khezri,
paul.chaignon, bpf, netdev, Alexei Starovoitov, Martin KaFai Lau,
Song Liu, Yonghong Song, Andrii Nakryiko
On Tue, Dec 10, 2019 at 03:23:16PM -0800, Paul Burton wrote:
> 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.
> >
> > 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:
We took the series via bpf, thanks!
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH bpf 2/2] bpf, mips: limit to 33 tail calls
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
1 sibling, 1 reply; 13+ messages in thread
From: Alexander Lobakin @ 2019-12-18 9:32 UTC (permalink / raw)
To: Paul Burton
Cc: Paul Chaignon, Björn Töpel, Mahshid Khezri,
paul.chaignon, bpf, netdev, Alexei Starovoitov, Daniel Borkmann,
Martin KaFai Lau, Song Liu, Yonghong Song, Andrii Nakryiko
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.
>> 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,
ᚷ ᛖ ᚢ ᚦ ᚠ ᚱ
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH bpf 2/2] bpf, mips: limit to 33 tail calls
2019-12-18 9:32 ` Alexander Lobakin
@ 2019-12-18 9:58 ` Paul Chaignon
2019-12-18 10:02 ` Alexander Lobakin
0 siblings, 1 reply; 13+ messages in thread
From: Paul Chaignon @ 2019-12-18 9:58 UTC (permalink / raw)
To: Alexander Lobakin
Cc: Paul Burton, Björn Töpel, Mahshid Khezri,
paul.chaignon, bpf, netdev, Alexei Starovoitov, Daniel Borkmann,
Martin KaFai Lau, Song Liu, Yonghong Song, Andrii Nakryiko
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,
> ᚷ ᛖ ᚢ ᚦ ᚠ ᚱ
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH bpf 2/2] bpf, mips: limit to 33 tail calls
2019-12-18 9:58 ` Paul Chaignon
@ 2019-12-18 10:02 ` Alexander Lobakin
0 siblings, 0 replies; 13+ messages in thread
From: Alexander Lobakin @ 2019-12-18 10:02 UTC (permalink / raw)
To: Paul Chaignon
Cc: Paul Burton, Björn Töpel, Mahshid Khezri,
paul.chaignon, bpf, netdev, Alexei Starovoitov, Daniel Borkmann,
Martin KaFai Lau, Song Liu, Yonghong Song, Andrii Nakryiko
Paul Chaignon wrote 18.12.2019 12:58:
> 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.
Aww, didn't know that. Thanks!
> 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,
>> ᚷ ᛖ ᚢ ᚦ ᚠ ᚱ
Regards,
ᚷ ᛖ ᚢ ᚦ ᚠ ᚱ
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2019-12-18 10:02 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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
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).