[PATCH] bpf: update the comment about the length of analysis

2017-03-01 Thread Gary Lin
ned-off-by: Gary Lin --- kernel/bpf/verifier.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index cdc43b899f28..0960f65c6da7 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -33,7 +33,7 @@ * - out of bounds or

[PATCH v3 3/3] selftests/bpf: Add verifier test for x64 jit jump padding

2021-01-14 Thread Gary Lin
m log, there was one more jit happened with only one pass and the same jit code was produced. Signed-off-by: Gary Lin --- tools/testing/selftests/bpf/test_verifier.c | 43 + tools/testing/selftests/bpf/verifier/jit.c | 16 2 files changed, 59 insertions(+) diff --git a/

[PATCH v3 2/3] test_bpf: remove EXPECTED_FAIL flag from bpf_fill_maxinsns11

2021-01-14 Thread Gary Lin
With NOPs padding, x64 jit now can handle the jump cases like bpf_fill_maxinsns11(). Signed-off-by: Gary Lin --- lib/test_bpf.c | 7 +-- 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/test_bpf.c b/lib/test_bpf.c index ca7d635bccd9..272a9fd143ab 100644 --- a/lib/test_bpf.c

[PATCH v3 1/3] bpf,x64: pad NOPs to make images converge more easily

2021-01-14 Thread Gary Lin
e without padding. v2: - Simplify the sample code in the description and provide the jit code - Check the expected padding bytes with WARN_ONCE - Move the 'padded' flag to 'struct x64_jit_data' Signed-off-by: Gary Lin --- arch/x86/net/bpf_jit_comp.c | 103 +

[PATCH v3 0/3] bpf,x64: implement jump padding in jit

2021-01-14 Thread Gary Lin
sample code in the commit description and provide the jit code - Check the expected padding bytes with WARN_ONCE - Move the 'padded' flag to 'struct x64_jit_data' - Remove the EXPECTED_FAIL flag from bpf_fill_maxinsns11() in test_bpf - Add 2 verifier tests Gary L

Re: [PATCH v3 1/3] bpf,x64: pad NOPs to make images converge more easily

2021-01-15 Thread Gary Lin
On Thu, Jan 14, 2021 at 10:37:33PM -0800, Alexei Starovoitov wrote: > On Thu, Jan 14, 2021 at 1:54 AM Gary Lin wrote: > > * pass to emit the final image. > > */ > > - for (pass = 0; pass < 20 || image; pass++) { > > - progl

Re: [PATCH v3 1/3] bpf,x64: pad NOPs to make images converge more easily

2021-01-17 Thread Gary Lin
On Fri, Jan 15, 2021 at 08:04:06AM -0800, Alexei Starovoitov wrote: > On Fri, Jan 15, 2021 at 1:41 AM Gary Lin wrote: > > > > On Thu, Jan 14, 2021 at 10:37:33PM -0800, Alexei Starovoitov wrote: > > > On Thu, Jan 14, 2021 at 1:54 AM Gary Lin wrote: > > > >

[PATCH v4 0/3] bpf,x64: implement jump padding in jit

2021-01-19 Thread Gary Lin
ding bytes with WARN_ONCE - Move the 'padded' flag to 'struct x64_jit_data' - Remove the EXPECTED_FAIL flag from bpf_fill_maxinsns11() in test_bpf - Add 2 verifier tests Gary Lin (3): bpf,x64: pad NOPs to make images converge more easily test_bpf: remove EXPECTED

[PATCH v4 1/3] bpf,x64: pad NOPs to make images converge more easily

2021-01-19 Thread Gary Lin
g is always enabled since it won't hurt the images that converge without padding. v2: - Simplify the sample code in the description and provide the jit code - Check the expected padding bytes with WARN_ONCE - Move the 'padded' flag to 'struct x64_jit_

[PATCH v4 3/3] selftests/bpf: Add verifier tests for x64 jit jump padding

2021-01-19 Thread Gary Lin
the same jit code was produced. v4: - Add the second test case which triggers jmp_cond padding and imm32 nop jmp padding. - Add the new test case as another subprog Signed-off-by: Gary Lin --- tools/testing/selftests/bpf/test_verifier.c | 72 + tools/testing/selftests/

[PATCH v4 2/3] test_bpf: remove EXPECTED_FAIL flag from bpf_fill_maxinsns11

2021-01-19 Thread Gary Lin
With NOPs padding, x64 jit now can handle the jump cases like bpf_fill_maxinsns11(). Signed-off-by: Gary Lin --- lib/test_bpf.c | 7 +-- 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/test_bpf.c b/lib/test_bpf.c index 49ec9e8d8aed..4dc4dcbecd12 100644 --- a/lib/test_bpf.c

[PATCH] bpf,x64: pad NOPs to make images converge more easily

2020-12-11 Thread Gary Lin
oduced to 'struct bpf_prog' so that bpf_int_jit_compile() could know if the program is padded or not. Signed-off-by: Gary Lin --- arch/x86/net/bpf_jit_comp.c | 68 - include/linux/filter.h | 1 + 2 files changed, 45 insertions(+), 24 deletions(-) diff -

Re: [PATCH] bpf,x64: pad NOPs to make images converge more easily

2020-12-13 Thread Gary Lin
On Fri, Dec 11, 2020 at 12:58:17PM -0800, Andrii Nakryiko wrote: > On Fri, Dec 11, 2020 at 8:51 AM Gary Lin wrote: > > > > The x64 bpf jit expects bpf images converge within the given passes, but > > it could fail to do so with some corner cases. For example: > &g

Re: [PATCH] bpf,x64: pad NOPs to make images converge more easily

2020-12-13 Thread Gary Lin
On Fri, Dec 11, 2020 at 09:05:05PM +0100, Daniel Borkmann wrote: > On 12/11/20 9:19 AM, Gary Lin wrote: > > The x64 bpf jit expects bpf images converge within the given passes, but > > it could fail to do so with some corner cases. For example: > > > >l0

Re: [PATCH] bpf,x64: pad NOPs to make images converge more easily

2020-12-13 Thread Gary Lin
icky bits > of the prog structure. > It's only needed between the last pass and extra pass for bpf2bpf calls. > I think it would be cleaner to keep it in struct x64_jit_data *jit_data. > Okay, jit_data is surely a better place for the flag. > As others have said the selftests are must have. > Especially for bpf2bpf calls where one subprog is padded. > Will try to craft some test cases for this patch in v2. Gary Lin

Re: [PATCH] bpf,x64: pad NOPs to make images converge more easily

2020-12-14 Thread Gary Lin
On Mon, Dec 14, 2020 at 11:56:22AM +0800, Gary Lin wrote: > On Fri, Dec 11, 2020 at 09:05:05PM +0100, Daniel Borkmann wrote: > > On 12/11/20 9:19 AM, Gary Lin wrote: > > > The x64 bpf jit expects bpf images converge within the given passes, but > > > it could fail to d

Re: [PATCH] bpf,x64: pad NOPs to make images converge more easily

2020-12-14 Thread Gary Lin
On Mon, Dec 14, 2020 at 04:31:44PM +0100, Daniel Borkmann wrote: > On 12/14/20 9:15 AM, Gary Lin wrote: > > On Mon, Dec 14, 2020 at 11:56:22AM +0800, Gary Lin wrote: > > > On Fri, Dec 11, 2020 at 09:05:05PM +0100, Daniel Borkmann wrote: > > > > On 12/11/20 9:19 AM,

[PATCH v2 0/3] bpf,x64: implement jump padding in jit

2020-12-17 Thread Gary Lin
'padded' flag to 'struct x64_jit_data' - Remove the EXPECTED_FAIL flag from bpf_fill_maxinsns11() in test_bpf - Add 2 verifier tests Gary Lin (3): bpf,x64: pad NOPs to make images converge more easily test_bpf: remove EXPECTED_FAIL flag from bpf_fill_maxinsns11 selftes

[PATCH v2 2/3] test_bpf: remove EXPECTED_FAIL flag from bpf_fill_maxinsns11

2020-12-17 Thread Gary Lin
With NOPs padding, x64 jit now can handle the jump cases like bpf_fill_maxinsns11(). Signed-off-by: Gary Lin --- lib/test_bpf.c | 7 +-- 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/test_bpf.c b/lib/test_bpf.c index ca7d635bccd9..272a9fd143ab 100644 --- a/lib/test_bpf.c

[PATCH v2 3/3] selftests/bpf: Add verifier test for x64 jit jump padding

2020-12-17 Thread Gary Lin
m log, there was one more jit happened with only one pass and the same jit code was produced. Signed-off-by: Gary Lin --- tools/testing/selftests/bpf/test_verifier.c | 43 + tools/testing/selftests/bpf/verifier/jit.c | 16 2 files changed, 59 insertions(+) diff --git a/

[PATCH v2 1/3] bpf,x64: pad NOPs to make images converge more easily

2020-12-17 Thread Gary Lin
padding bytes with WARN_ONCE - Move the 'padded' flag to 'struct x64_jit_data' Signed-off-by: Gary Lin --- arch/x86/net/bpf_jit_comp.c | 86 ++--- 1 file changed, 62 insertions(+), 24 deletions(-) diff --git a/arch/x86/net/bpf_jit_comp.c

[PATCH] net: bpfilter: print umh messages to /dev/kmsg

2019-07-04 Thread Gary Lin
igned-off-by: Gary Lin --- net/bpfilter/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/bpfilter/main.c b/net/bpfilter/main.c index 61ce8454a88e..77396a098fbe 100644 --- a/net/bpfilter/main.c +++ b/net/bpfilter/main.c @@ -55,7 +55,7 @@ static void loop(void) int

[RFC PATCH] bpf, x64: add extra passes and relax size convergence check

2020-11-26 Thread Gary Lin
ed and a warning is issued to notify the user. Signed-off-by: Gary Lin --- arch/x86/net/bpf_jit_comp.c | 47 + 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c index 796506dcfc42..6fe933e9

Re: [RFC PATCH] bpf, x64: add extra passes and relax size convergence check

2020-11-26 Thread Gary Lin
On Thu, Nov 26, 2020 at 04:01:30PM +0800, Gary Lin wrote: > The x64 bpf jit expects bpf images converge within the given passes, but > it could fail to do so with some corner cases. For example: > > l0: ldh [4] > l1: jeq #0x537d, l2, l40 > l2:

[PATCH] bpf, x64: add extra passes without size optimizations

2020-11-26 Thread Gary Lin
ed to avoid the further jump offset changes. Due to the fact that the images are not optimized after the extra passes, a warning is issued to notify the user, but at least the images are allocated and ready to run. Signed-off-by: Gary Lin --- arch/x86/net/bpf_jit_comp.c | 35

[PATCH] bpf, x64: bump the number of passes to 64

2020-12-03 Thread Gary Lin
o be small. To avoid increasing the complexity of BPF JIT, this commit just bumps the number of passes to 64 as suggested by Daniel to make it less likely to fail on such cases. Signed-off-by: Gary Lin --- arch/x86/net/bpf_jit_comp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arc

Re: [PATCH] bpf, x64: bump the number of passes to 64

2020-12-03 Thread Gary Lin
On Thu, Dec 03, 2020 at 10:14:31AM -0800, Alexei Starovoitov wrote: > On Thu, Dec 03, 2020 at 12:20:38PM +0100, Eric Dumazet wrote: > > > > > > On 12/3/20 10:12 AM, Gary Lin wrote: > > > The x64 bpf jit expects bpf images converge within the given passes, but >

Re: [PATCH] bpf, x64: bump the number of passes to 64

2020-12-04 Thread Gary Lin
On Fri, Dec 04, 2020 at 11:42:13AM +0800, Gary Lin wrote: > On Thu, Dec 03, 2020 at 10:14:31AM -0800, Alexei Starovoitov wrote: > > On Thu, Dec 03, 2020 at 12:20:38PM +0100, Eric Dumazet wrote: > > > > > > > > > On 12/3/20 10:12 AM, Gary Lin wrote: > &

[PATCH RESEND v2 0/3] bpf,x64: implement jump padding in jit

2021-01-06 Thread Gary Lin
'padded' flag to 'struct x64_jit_data' - Remove the EXPECTED_FAIL flag from bpf_fill_maxinsns11() in test_bpf - Add 2 verifier tests Gary Lin (3): bpf,x64: pad NOPs to make images converge more easily test_bpf: remove EXPECTED_FAIL flag from bpf_fill_maxinsns11 selftes

[PATCH RESEND v2 1/3] bpf,x64: pad NOPs to make images converge more easily

2021-01-06 Thread Gary Lin
padding bytes with WARN_ONCE - Move the 'padded' flag to 'struct x64_jit_data' Signed-off-by: Gary Lin --- arch/x86/net/bpf_jit_comp.c | 86 ++--- 1 file changed, 62 insertions(+), 24 deletions(-) diff --git a/arch/x86/net/bpf_jit_comp.c

[PATCH RESEND v2 3/3] selftests/bpf: Add verifier test for x64 jit jump padding

2021-01-06 Thread Gary Lin
m log, there was one more jit happened with only one pass and the same jit code was produced. Signed-off-by: Gary Lin --- tools/testing/selftests/bpf/test_verifier.c | 43 + tools/testing/selftests/bpf/verifier/jit.c | 16 2 files changed, 59 insertions(+) diff --git a/

[PATCH RESEND v2 2/3] test_bpf: remove EXPECTED_FAIL flag from bpf_fill_maxinsns11

2021-01-06 Thread Gary Lin
With NOPs padding, x64 jit now can handle the jump cases like bpf_fill_maxinsns11(). Signed-off-by: Gary Lin --- lib/test_bpf.c | 7 +-- 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/test_bpf.c b/lib/test_bpf.c index ca7d635bccd9..272a9fd143ab 100644 --- a/lib/test_bpf.c

Re: [PATCH RESEND v2 1/3] bpf,x64: pad NOPs to make images converge more easily

2021-01-10 Thread Gary Lin
On Fri, Jan 08, 2021 at 11:21:13PM +0100, Daniel Borkmann wrote: > On 1/7/21 3:16 AM, Gary Lin wrote: > > The x64 bpf jit expects bpf images converge within the given passes, but > > it could fail to do so with some corner cases. For example: > > > >l0: ja

[PATCH RFC] bpf, x64: allow not-converged images when BPF_JIT_ALWAYS_ON is set

2020-11-13 Thread Gary Lin
eserves a document to collect the corner cases so that the user could know the limitations and how to work around them. Signed-off-by: Gary Lin --- arch/x86/net/bpf_jit_comp.c | 13 - 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x

Re: [PATCH RFC] bpf, x64: allow not-converged images when BPF_JIT_ALWAYS_ON is set

2020-11-15 Thread Gary Lin
On Fri, Nov 13, 2020 at 05:48:31PM -0800, Alexei Starovoitov wrote: > On Fri, Nov 13, 2020 at 12:40 AM Gary Lin wrote: > > > > The x64 bpf jit expects the bpf images converge within the given passes. > > However there is a corner case: > > > > l0: ldh [4] &