* [PATCH] arm64: bpf: jit JMP_JSET_{X,K}
@ 2016-05-13 6:37 Zi Shen Lim
2016-05-13 9:57 ` Will Deacon
2016-05-13 16:23 ` Shi, Yang
0 siblings, 2 replies; 5+ messages in thread
From: Zi Shen Lim @ 2016-05-13 6:37 UTC (permalink / raw)
To: Alexei Starovoitov, David S. Miller, Will Deacon, Catalin Marinas
Cc: Zi Shen Lim, Daniel Borkmann, Yang Shi, netdev, linux-arm-kernel
Original implementation commit e54bcde3d69d ("arm64: eBPF JIT compiler")
had the relevant code paths, but due to an oversight always fail jiting.
As a result, we had been falling back to BPF interpreter whenever a BPF
program has JMP_JSET_{X,K} instructions.
With this fix, we confirm that the corresponding tests in lib/test_bpf
continue to pass, and also jited.
...
[ 2.784553] test_bpf: #30 JSET jited:1 188 192 197 PASS
[ 2.791373] test_bpf: #31 tcpdump port 22 jited:1 325 677 625 PASS
[ 2.808800] test_bpf: #32 tcpdump complex jited:1 323 731 991 PASS
...
[ 3.190759] test_bpf: #237 JMP_JSET_K: if (0x3 & 0x2) return 1 jited:1 110 PASS
[ 3.192524] test_bpf: #238 JMP_JSET_K: if (0x3 & 0xffffffff) return 1 jited:1 98 PASS
[ 3.211014] test_bpf: #249 JMP_JSET_X: if (0x3 & 0x2) return 1 jited:1 120 PASS
[ 3.212973] test_bpf: #250 JMP_JSET_X: if (0x3 & 0xffffffff) return 1 jited:1 89 PASS
...
Fixes: e54bcde3d69d ("arm64: eBPF JIT compiler")
Signed-off-by: Zi Shen Lim <zlim.lnx@gmail.com>
---
arch/arm64/net/bpf_jit_comp.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
index 031ed08..d0d5190 100644
--- a/arch/arm64/net/bpf_jit_comp.c
+++ b/arch/arm64/net/bpf_jit_comp.c
@@ -478,6 +478,7 @@ emit_cond_jmp:
case BPF_JGE:
jmp_cond = A64_COND_CS;
break;
+ case BPF_JSET:
case BPF_JNE:
jmp_cond = A64_COND_NE;
break;
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] arm64: bpf: jit JMP_JSET_{X,K}
2016-05-13 6:37 [PATCH] arm64: bpf: jit JMP_JSET_{X,K} Zi Shen Lim
@ 2016-05-13 9:57 ` Will Deacon
2016-05-13 10:03 ` Will Deacon
2016-05-13 16:23 ` Shi, Yang
1 sibling, 1 reply; 5+ messages in thread
From: Will Deacon @ 2016-05-13 9:57 UTC (permalink / raw)
To: Zi Shen Lim
Cc: Alexei Starovoitov, David S. Miller, Catalin Marinas,
Daniel Borkmann, Yang Shi, netdev, linux-arm-kernel
On Thu, May 12, 2016 at 11:37:58PM -0700, Zi Shen Lim wrote:
> Original implementation commit e54bcde3d69d ("arm64: eBPF JIT compiler")
> had the relevant code paths, but due to an oversight always fail jiting.
>
> As a result, we had been falling back to BPF interpreter whenever a BPF
> program has JMP_JSET_{X,K} instructions.
>
> With this fix, we confirm that the corresponding tests in lib/test_bpf
> continue to pass, and also jited.
>
> ...
> [ 2.784553] test_bpf: #30 JSET jited:1 188 192 197 PASS
> [ 2.791373] test_bpf: #31 tcpdump port 22 jited:1 325 677 625 PASS
> [ 2.808800] test_bpf: #32 tcpdump complex jited:1 323 731 991 PASS
> ...
> [ 3.190759] test_bpf: #237 JMP_JSET_K: if (0x3 & 0x2) return 1 jited:1 110 PASS
> [ 3.192524] test_bpf: #238 JMP_JSET_K: if (0x3 & 0xffffffff) return 1 jited:1 98 PASS
> [ 3.211014] test_bpf: #249 JMP_JSET_X: if (0x3 & 0x2) return 1 jited:1 120 PASS
> [ 3.212973] test_bpf: #250 JMP_JSET_X: if (0x3 & 0xffffffff) return 1 jited:1 89 PASS
> ...
>
> Fixes: e54bcde3d69d ("arm64: eBPF JIT compiler")
> Signed-off-by: Zi Shen Lim <zlim.lnx@gmail.com>
> ---
> arch/arm64/net/bpf_jit_comp.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
> index 031ed08..d0d5190 100644
> --- a/arch/arm64/net/bpf_jit_comp.c
> +++ b/arch/arm64/net/bpf_jit_comp.c
> @@ -478,6 +478,7 @@ emit_cond_jmp:
> case BPF_JGE:
> jmp_cond = A64_COND_CS;
> break;
> + case BPF_JSET:
> case BPF_JNE:
> jmp_cond = A64_COND_NE;
> break;
Are you sure about this? filter.txt says:
jne - Jump on K != A
...
jset - Jump on k & A
so it looks weird wiring them both to the same thing. I'm not sure you
can express this as a simple CMP + B.<cond>.
Will
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] arm64: bpf: jit JMP_JSET_{X,K}
2016-05-13 9:57 ` Will Deacon
@ 2016-05-13 10:03 ` Will Deacon
2016-05-14 20:12 ` David Miller
0 siblings, 1 reply; 5+ messages in thread
From: Will Deacon @ 2016-05-13 10:03 UTC (permalink / raw)
To: Zi Shen Lim
Cc: Alexei Starovoitov, David S. Miller, Catalin Marinas,
Daniel Borkmann, Yang Shi, netdev, linux-arm-kernel
On Fri, May 13, 2016 at 10:57:18AM +0100, Will Deacon wrote:
> On Thu, May 12, 2016 at 11:37:58PM -0700, Zi Shen Lim wrote:
> > Original implementation commit e54bcde3d69d ("arm64: eBPF JIT compiler")
> > had the relevant code paths, but due to an oversight always fail jiting.
> >
> > As a result, we had been falling back to BPF interpreter whenever a BPF
> > program has JMP_JSET_{X,K} instructions.
> >
> > With this fix, we confirm that the corresponding tests in lib/test_bpf
> > continue to pass, and also jited.
> >
> > ...
> > [ 2.784553] test_bpf: #30 JSET jited:1 188 192 197 PASS
> > [ 2.791373] test_bpf: #31 tcpdump port 22 jited:1 325 677 625 PASS
> > [ 2.808800] test_bpf: #32 tcpdump complex jited:1 323 731 991 PASS
> > ...
> > [ 3.190759] test_bpf: #237 JMP_JSET_K: if (0x3 & 0x2) return 1 jited:1 110 PASS
> > [ 3.192524] test_bpf: #238 JMP_JSET_K: if (0x3 & 0xffffffff) return 1 jited:1 98 PASS
> > [ 3.211014] test_bpf: #249 JMP_JSET_X: if (0x3 & 0x2) return 1 jited:1 120 PASS
> > [ 3.212973] test_bpf: #250 JMP_JSET_X: if (0x3 & 0xffffffff) return 1 jited:1 89 PASS
> > ...
> >
> > Fixes: e54bcde3d69d ("arm64: eBPF JIT compiler")
> > Signed-off-by: Zi Shen Lim <zlim.lnx@gmail.com>
> > ---
> > arch/arm64/net/bpf_jit_comp.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
> > index 031ed08..d0d5190 100644
> > --- a/arch/arm64/net/bpf_jit_comp.c
> > +++ b/arch/arm64/net/bpf_jit_comp.c
> > @@ -478,6 +478,7 @@ emit_cond_jmp:
> > case BPF_JGE:
> > jmp_cond = A64_COND_CS;
> > break;
> > + case BPF_JSET:
> > case BPF_JNE:
> > jmp_cond = A64_COND_NE;
> > break;
>
> Are you sure about this? filter.txt says:
>
> jne - Jump on K != A
> ...
> jset - Jump on k & A
>
> so it looks weird wiring them both to the same thing. I'm not sure you
> can express this as a simple CMP + B.<cond>.
Ah, sorry, I see how this works now. I overlooked the BPF_JMP | BPF_JSET |
BPF_X case emitting a TST instruction. In which case:
Acked-by: Will Deacon <will.deacon@arm.com>
I'm assuming David will queue this?
Will
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] arm64: bpf: jit JMP_JSET_{X,K}
2016-05-13 6:37 [PATCH] arm64: bpf: jit JMP_JSET_{X,K} Zi Shen Lim
2016-05-13 9:57 ` Will Deacon
@ 2016-05-13 16:23 ` Shi, Yang
1 sibling, 0 replies; 5+ messages in thread
From: Shi, Yang @ 2016-05-13 16:23 UTC (permalink / raw)
To: Zi Shen Lim, Alexei Starovoitov, David S. Miller, Will Deacon,
Catalin Marinas
Cc: Daniel Borkmann, netdev, linux-arm-kernel
On 5/12/2016 11:37 PM, Zi Shen Lim wrote:
> Original implementation commit e54bcde3d69d ("arm64: eBPF JIT compiler")
> had the relevant code paths, but due to an oversight always fail jiting.
>
> As a result, we had been falling back to BPF interpreter whenever a BPF
> program has JMP_JSET_{X,K} instructions.
>
> With this fix, we confirm that the corresponding tests in lib/test_bpf
> continue to pass, and also jited.
>
> ...
> [ 2.784553] test_bpf: #30 JSET jited:1 188 192 197 PASS
> [ 2.791373] test_bpf: #31 tcpdump port 22 jited:1 325 677 625 PASS
> [ 2.808800] test_bpf: #32 tcpdump complex jited:1 323 731 991 PASS
> ...
> [ 3.190759] test_bpf: #237 JMP_JSET_K: if (0x3 & 0x2) return 1 jited:1 110 PASS
> [ 3.192524] test_bpf: #238 JMP_JSET_K: if (0x3 & 0xffffffff) return 1 jited:1 98 PASS
> [ 3.211014] test_bpf: #249 JMP_JSET_X: if (0x3 & 0x2) return 1 jited:1 120 PASS
> [ 3.212973] test_bpf: #250 JMP_JSET_X: if (0x3 & 0xffffffff) return 1 jited:1 89 PASS
> ...
>
> Fixes: e54bcde3d69d ("arm64: eBPF JIT compiler")
> Signed-off-by: Zi Shen Lim <zlim.lnx@gmail.com>
Acked-by: Yang Shi <yang.shi@linaro.org>
Thanks,
Yang
> ---
> arch/arm64/net/bpf_jit_comp.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
> index 031ed08..d0d5190 100644
> --- a/arch/arm64/net/bpf_jit_comp.c
> +++ b/arch/arm64/net/bpf_jit_comp.c
> @@ -478,6 +478,7 @@ emit_cond_jmp:
> case BPF_JGE:
> jmp_cond = A64_COND_CS;
> break;
> + case BPF_JSET:
> case BPF_JNE:
> jmp_cond = A64_COND_NE;
> break;
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] arm64: bpf: jit JMP_JSET_{X,K}
2016-05-13 10:03 ` Will Deacon
@ 2016-05-14 20:12 ` David Miller
0 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2016-05-14 20:12 UTC (permalink / raw)
To: will.deacon
Cc: zlim.lnx, ast, catalin.marinas, daniel, yang.shi, netdev,
linux-arm-kernel
From: Will Deacon <will.deacon@arm.com>
Date: Fri, 13 May 2016 11:03:07 +0100
> On Fri, May 13, 2016 at 10:57:18AM +0100, Will Deacon wrote:
>> On Thu, May 12, 2016 at 11:37:58PM -0700, Zi Shen Lim wrote:
>> > Original implementation commit e54bcde3d69d ("arm64: eBPF JIT compiler")
>> > had the relevant code paths, but due to an oversight always fail jiting.
>> >
>> > As a result, we had been falling back to BPF interpreter whenever a BPF
>> > program has JMP_JSET_{X,K} instructions.
>> >
>> > With this fix, we confirm that the corresponding tests in lib/test_bpf
>> > continue to pass, and also jited.
>> >
>> > ...
>> > [ 2.784553] test_bpf: #30 JSET jited:1 188 192 197 PASS
>> > [ 2.791373] test_bpf: #31 tcpdump port 22 jited:1 325 677 625 PASS
>> > [ 2.808800] test_bpf: #32 tcpdump complex jited:1 323 731 991 PASS
>> > ...
>> > [ 3.190759] test_bpf: #237 JMP_JSET_K: if (0x3 & 0x2) return 1 jited:1 110 PASS
>> > [ 3.192524] test_bpf: #238 JMP_JSET_K: if (0x3 & 0xffffffff) return 1 jited:1 98 PASS
>> > [ 3.211014] test_bpf: #249 JMP_JSET_X: if (0x3 & 0x2) return 1 jited:1 120 PASS
>> > [ 3.212973] test_bpf: #250 JMP_JSET_X: if (0x3 & 0xffffffff) return 1 jited:1 89 PASS
>> > ...
>> >
>> > Fixes: e54bcde3d69d ("arm64: eBPF JIT compiler")
>> > Signed-off-by: Zi Shen Lim <zlim.lnx@gmail.com>
...
> Acked-by: Will Deacon <will.deacon@arm.com>
>
> I'm assuming David will queue this?
Yep I got this, applied, thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-05-14 20:12 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-13 6:37 [PATCH] arm64: bpf: jit JMP_JSET_{X,K} Zi Shen Lim
2016-05-13 9:57 ` Will Deacon
2016-05-13 10:03 ` Will Deacon
2016-05-14 20:12 ` David Miller
2016-05-13 16:23 ` Shi, Yang
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).