[PATCH v7 bpf-next 04/16] bpf: verifier: insert zero extension according to analysis result

2019-05-22 Thread Jiong Wang
s hardware zero extension support. The peephole could be as simple as looking the next insn, if it is a special zero extension insn then it is safe to eliminate it if the current insn has hardware zero extension support. Reviewed-by: Jakub Kicinski Signed-off-by: Jiong Wang --- include/linux/bpf.h

[PATCH v7 bpf-next 03/16] bpf: introduce new mov32 variant for doing explicit zero extension

2019-05-22 Thread Jiong Wang
insn using this new mov32 variant. One helper function insn_is_zext is added for checking one insn is an zero extension on dst. This will be widely used by a few JIT back-ends in later patches in this set. Signed-off-by: Jiong Wang --- include/linux/filter.h | 14 ++ 1 file changed

[PATCH v7 bpf-next 00/16] bpf: eliminate zero extensions for sub-register writes

2019-05-22 Thread Jiong Wang
.*u8" | wc -l (READ_B) After this patch set enabled, more than half of those 4460 could be identified as doesn't needing zero extension on the destination, this could lead significant save on JITed image. Jiong Wang (16): bpf: verifier: mark verified-insn with sub-register zext f

[PATCH v7 bpf-next 01/16] bpf: verifier: mark verified-insn with sub-register zext flag

2019-05-22 Thread Jiong Wang
A new sub-register write overrides the old one. - When propagating read64 during path pruning, also mark any insn defining a sub-register that is read in the pruned path as full-register. Reviewed-by: Jakub Kicinski Signed-off-by: Jiong Wang --- include/linux/bpf_verifier.h | 14 +++- kerne

[PATCH v7 bpf-next 06/16] bpf: verifier: randomize high 32-bit when BPF_F_TEST_RND_HI32 is set

2019-05-22 Thread Jiong Wang
This patch randomizes high 32-bit of a definition when BPF_F_TEST_RND_HI32 is set. Suggested-by: Alexei Starovoitov Signed-off-by: Jiong Wang --- kernel/bpf/verifier.c | 68 ++- 1 file changed, 57 insertions(+), 11 deletions(-) diff --git a

[PATCH v7 bpf-next 14/16] x32: bpf: eliminate zero extension code-gen

2019-05-22 Thread Jiong Wang
Cc: Wang YanQing Tested-by: Wang YanQing Signed-off-by: Jiong Wang --- arch/x86/net/bpf_jit_comp32.c | 83 +-- 1 file changed, 56 insertions(+), 27 deletions(-) diff --git a/arch/x86/net/bpf_jit_comp32.c b/arch/x86/net/bpf_jit_comp32.c index b29e82f

[PATCH v7 bpf-next 16/16] nfp: bpf: eliminate zero extension code-gen

2019-05-22 Thread Jiong Wang
ed-by: Jakub Kicinski Signed-off-by: Jiong Wang --- drivers/net/ethernet/netronome/nfp/bpf/jit.c | 115 +- drivers/net/ethernet/netronome/nfp/bpf/main.h | 2 + drivers/net/ethernet/netronome/nfp/bpf/verifier.c | 12 +++ 3 files changed, 81 insertions(+), 48 dele

[PATCH v7 bpf-next 02/16] bpf: verifier: mark patched-insn with sub-register zext flag

2019-05-22 Thread Jiong Wang
Patched insns do not go through generic verification, therefore doesn't has zero extension information collected during insn walking. We don't bother analyze them at the moment, for any sub-register def comes from them, just conservatively mark it as needing zero extension. Signed-off

[PATCH v7 bpf-next 07/16] libbpf: add "prog_flags" to bpf_program/bpf_prog_load_attr/bpf_load_program_attr

2019-05-22 Thread Jiong Wang
stomizing program loading. Reviewed-by: Jakub Kicinski Signed-off-by: Jiong Wang --- tools/lib/bpf/bpf.c| 1 + tools/lib/bpf/bpf.h| 1 + tools/lib/bpf/libbpf.c | 3 +++ tools/lib/bpf/libbpf.h | 1 + 4 files changed, 6 insertions(+) diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c index

[PATCH v7 bpf-next 13/16] sparc: bpf: eliminate zero extension code-gen

2019-05-22 Thread Jiong Wang
Cc: David S. Miller Signed-off-by: Jiong Wang --- arch/sparc/net/bpf_jit_comp_64.c | 29 +++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/arch/sparc/net/bpf_jit_comp_64.c b/arch/sparc/net/bpf_jit_comp_64.c index 65428e7..3364e2a 100644 --- a/arch

[PATCH v7 bpf-next 12/16] s390: bpf: eliminate zero extension code-gen

2019-05-22 Thread Jiong Wang
Cc: Martin Schwidefsky Cc: Heiko Carstens Signed-off-by: Jiong Wang --- arch/s390/net/bpf_jit_comp.c | 41 ++--- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c index 5e7c630..e636728

[PATCH v7 bpf-next 05/16] bpf: introduce new bpf prog load flags "BPF_F_TEST_RND_HI32"

2019-05-22 Thread Jiong Wang
any later insn. Such randomization is only enabled under testing mode which is gated by the new bpf prog load flags "BPF_F_TEST_RND_HI32". Suggested-by: Alexei Starovoitov Signed-off-by: Jiong Wang --- include/uapi/linux/bpf.h | 18 ++ kernel/bpf/syscall.c

[PATCH v7 bpf-next 08/16] selftests: bpf: adjust several test_verifier helpers for insn insertion

2019-05-22 Thread Jiong Wang
efficient that 1M call to it will hang computer. So , change to BPF_ALU64_IMM to avoid hi32 randomization. Signed-off-by: Jiong Wang --- tools/testing/selftests/bpf/test_verifier.c | 29 +++-- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/tools

[PATCH v7 bpf-next 09/16] selftests: bpf: enable hi32 randomization for all tests

2019-05-22 Thread Jiong Wang
used load APIs to the test version, hence enable high 32-bit randomization for these tests without changing source code. Besides all these, there are several testcases are using "bpf_prog_load_attr" directly, their call sites are updated to pass BPF_F_TEST_RND_HI32. Signed-off-by: Ji

[PATCH v7 bpf-next 11/16] powerpc: bpf: eliminate zero extension code-gen

2019-05-22 Thread Jiong Wang
Cc: Naveen N. Rao Cc: Sandipan Das Signed-off-by: Jiong Wang --- arch/powerpc/net/bpf_jit_comp64.c | 36 +--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/net/bpf_jit_comp64.c b/arch/powerpc/net/bpf_jit_comp64.c index 21a1dcd

[PATCH v7 bpf-next 10/16] arm: bpf: eliminate zero extension code-gen

2019-05-22 Thread Jiong Wang
Cc: Shubham Bansal Signed-off-by: Jiong Wang --- arch/arm/net/bpf_jit_32.c | 42 +++--- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/arch/arm/net/bpf_jit_32.c b/arch/arm/net/bpf_jit_32.c index c8bfbbf..97a6b4b 100644 --- a/arch/arm/net

[PATCH v7 bpf-next 15/16] riscv: bpf: eliminate zero extension code-gen

2019-05-22 Thread Jiong Wang
Cc: Björn Töpel Acked-by: Björn Töpel Tested-by: Björn Töpel Signed-off-by: Jiong Wang --- arch/riscv/net/bpf_jit_comp.c | 43 ++- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/arch/riscv/net/bpf_jit_comp.c b/arch/riscv/net

Re: [PATCH v7 bpf-next 01/16] bpf: verifier: mark verified-insn with sub-register zext flag

2019-05-23 Thread Jiong Wang
> On 23 May 2019, at 03:07, Alexei Starovoitov > wrote: > > On Wed, May 22, 2019 at 07:54:57PM +0100, Jiong Wang wrote: >> eBPF ISA specification requires high 32-bit cleared when low 32-bit >> sub-register is written. This applies to destination register of ALU32 et

Re: [PATCH bpf] selftests: bpf: add zero extend checks for ALU32 and/or/xor

2019-05-23 Thread Jiong Wang
> On 23 May 2019, at 15:02, Daniel Borkmann wrote: > > On 05/23/2019 08:38 AM, Y Song wrote: >> On Wed, May 22, 2019 at 1:46 PM Björn Töpel wrote: >>> On Wed, 22 May 2019 at 20:13, Y Song wrote: On Wed, May 22, 2019 at 2:25 AM Björn Töpel wrote: > > Add three tests to test_veri

Re: [PATCH v7 bpf-next 01/16] bpf: verifier: mark verified-insn with sub-register zext flag

2019-05-23 Thread Jiong Wang
Alexei Starovoitov writes: > well, it made me realize that we're probably doing it wrong, > since after calling check_reg_arg() we need to re-parse insn encoding. > How about we change check_reg_arg()'s enum reg_arg_type instead? This is exactly what I had implemented in my initial internal v

[PATCH v8 bpf-next 02/16] bpf: verifier: mark patched-insn with sub-register zext flag

2019-05-24 Thread Jiong Wang
Patched insns do not go through generic verification, therefore doesn't has zero extension information collected during insn walking. We don't bother analyze them at the moment, for any sub-register def comes from them, just conservatively mark it as needing zero extension. Signed-off

[PATCH v8 bpf-next 01/16] bpf: verifier: mark verified-insn with sub-register zext flag

2019-05-24 Thread Jiong Wang
A new sub-register write overrides the old one. - When propagating read64 during path pruning, also mark any insn defining a sub-register that is read in the pruned path as full-register. Reviewed-by: Jakub Kicinski Signed-off-by: Jiong Wang --- include/linux/bpf_verifier.h | 14 +++- kerne

[PATCH v8 bpf-next 03/16] bpf: introduce new mov32 variant for doing explicit zero extension

2019-05-24 Thread Jiong Wang
insn using this new mov32 variant. One helper function insn_is_zext is added for checking one insn is an zero extension on dst. This will be widely used by a few JIT back-ends in later patches in this set. Signed-off-by: Jiong Wang --- include/linux/filter.h | 14 ++ 1 file changed

[PATCH v8 bpf-next 00/16] bpf: eliminate zero extensions for sub-register writes

2019-05-24 Thread Jiong Wang
cat dump | grep -P "r.*=.*u32" | wc -l (READ_W) cat dump | grep -P "r.*=.*u16" | wc -l (READ_H) cat dump | grep -P "r.*=.*u8" | wc -l (READ_B) After this patch set enabled, > 25% of those 4460 could be identified as doesn't needing zero extension

[PATCH v8 bpf-next 15/16] riscv: bpf: eliminate zero extension code-gen

2019-05-24 Thread Jiong Wang
Cc: Björn Töpel Acked-by: Björn Töpel Tested-by: Björn Töpel Signed-off-by: Jiong Wang --- arch/riscv/net/bpf_jit_comp.c | 43 ++- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/arch/riscv/net/bpf_jit_comp.c b/arch/riscv/net

[PATCH v8 bpf-next 14/16] x32: bpf: eliminate zero extension code-gen

2019-05-24 Thread Jiong Wang
Cc: Wang YanQing Tested-by: Wang YanQing Signed-off-by: Jiong Wang --- arch/x86/net/bpf_jit_comp32.c | 83 +-- 1 file changed, 56 insertions(+), 27 deletions(-) diff --git a/arch/x86/net/bpf_jit_comp32.c b/arch/x86/net/bpf_jit_comp32.c index b29e82f

[PATCH v8 bpf-next 05/16] bpf: introduce new bpf prog load flags "BPF_F_TEST_RND_HI32"

2019-05-24 Thread Jiong Wang
any later insn. Such randomization is only enabled under testing mode which is gated by the new bpf prog load flags "BPF_F_TEST_RND_HI32". Suggested-by: Alexei Starovoitov Signed-off-by: Jiong Wang --- include/uapi/linux/bpf.h | 18 ++ kernel/bpf/syscall.c

[PATCH v8 bpf-next 04/16] bpf: verifier: insert zero extension according to analysis result

2019-05-24 Thread Jiong Wang
upport and want verifier insert zero extension explicitly. Offload targets do not use this native target hook, instead, they could get the optimization results using bpf_prog_offload_ops.finalize. Reviewed-by: Jakub Kicinski Signed-off-by: Jiong Wang --- include/linux/bpf.h| 1 + include/linu

[PATCH v8 bpf-next 11/16] powerpc: bpf: eliminate zero extension code-gen

2019-05-24 Thread Jiong Wang
Cc: Naveen N. Rao Cc: Sandipan Das Signed-off-by: Jiong Wang --- arch/powerpc/net/bpf_jit_comp64.c | 36 +--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/net/bpf_jit_comp64.c b/arch/powerpc/net/bpf_jit_comp64.c index 21a1dcd

[PATCH v8 bpf-next 12/16] s390: bpf: eliminate zero extension code-gen

2019-05-24 Thread Jiong Wang
Cc: Martin Schwidefsky Cc: Heiko Carstens Signed-off-by: Jiong Wang --- arch/s390/net/bpf_jit_comp.c | 41 ++--- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c index 5e7c630..e636728

[PATCH v8 bpf-next 08/16] selftests: bpf: adjust several test_verifier helpers for insn insertion

2019-05-24 Thread Jiong Wang
efficient that 1M call to it will hang computer. So , change to BPF_ALU64_IMM to avoid hi32 randomization. Signed-off-by: Jiong Wang --- tools/testing/selftests/bpf/test_verifier.c | 29 +++-- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/tools

[PATCH v8 bpf-next 06/16] bpf: verifier: randomize high 32-bit when BPF_F_TEST_RND_HI32 is set

2019-05-24 Thread Jiong Wang
This patch randomizes high 32-bit of a definition when BPF_F_TEST_RND_HI32 is set. Suggested-by: Alexei Starovoitov Signed-off-by: Jiong Wang --- kernel/bpf/verifier.c | 68 ++- 1 file changed, 57 insertions(+), 11 deletions(-) diff --git a

[PATCH v8 bpf-next 13/16] sparc: bpf: eliminate zero extension code-gen

2019-05-24 Thread Jiong Wang
Cc: David S. Miller Signed-off-by: Jiong Wang --- arch/sparc/net/bpf_jit_comp_64.c | 29 +++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/arch/sparc/net/bpf_jit_comp_64.c b/arch/sparc/net/bpf_jit_comp_64.c index 65428e7..3364e2a 100644 --- a/arch

[PATCH v8 bpf-next 07/16] libbpf: add "prog_flags" to bpf_program/bpf_prog_load_attr/bpf_load_program_attr

2019-05-24 Thread Jiong Wang
stomizing program loading. Reviewed-by: Jakub Kicinski Signed-off-by: Jiong Wang --- tools/lib/bpf/bpf.c| 1 + tools/lib/bpf/bpf.h| 1 + tools/lib/bpf/libbpf.c | 3 +++ tools/lib/bpf/libbpf.h | 1 + 4 files changed, 6 insertions(+) diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c index

[PATCH v8 bpf-next 09/16] selftests: bpf: enable hi32 randomization for all tests

2019-05-24 Thread Jiong Wang
used load APIs to the test version, hence enable high 32-bit randomization for these tests without changing source code. Besides all these, there are several testcases are using "bpf_prog_load_attr" directly, their call sites are updated to pass BPF_F_TEST_RND_HI32. Signed-off-by: Ji

[PATCH v8 bpf-next 16/16] nfp: bpf: eliminate zero extension code-gen

2019-05-24 Thread Jiong Wang
ed-by: Jakub Kicinski Signed-off-by: Jiong Wang --- drivers/net/ethernet/netronome/nfp/bpf/jit.c | 115 +- drivers/net/ethernet/netronome/nfp/bpf/main.h | 2 + drivers/net/ethernet/netronome/nfp/bpf/verifier.c | 12 +++ 3 files changed, 81 insertions(+), 48 dele

[PATCH v8 bpf-next 10/16] arm: bpf: eliminate zero extension code-gen

2019-05-24 Thread Jiong Wang
Cc: Shubham Bansal Signed-off-by: Jiong Wang --- arch/arm/net/bpf_jit_32.c | 42 +++--- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/arch/arm/net/bpf_jit_32.c b/arch/arm/net/bpf_jit_32.c index c8bfbbf..97a6b4b 100644 --- a/arch/arm/net

Re: [PATCH v8 bpf-next 15/16] riscv: bpf: eliminate zero extension code-gen

2019-05-24 Thread Jiong Wang
Björn Töpel writes: > On Fri, 24 May 2019 at 13:36, Jiong Wang wrote: >> >> Cc: Björn Töpel >> Acked-by: Björn Töpel >> Tested-by: Björn Töpel >> Signed-off-by: Jiong Wang >> --- >> arch/riscv/net/bpf_jit_comp.c | 43 >> +++

Re: [PATCH v8 bpf-next 05/16] bpf: introduce new bpf prog load flags "BPF_F_TEST_RND_HI32"

2019-05-24 Thread Jiong Wang
On 24/05/2019 21:43, Alexei Starovoitov wrote: On Fri, May 24, 2019 at 12:35:15PM +0100, Jiong Wang wrote: x86_64 and AArch64 perhaps are two arches that running bpf testsuite frequently, however the zero extension insertion pass is not enabled for them because of their hardware support. It is

[PATCH v9 bpf-next 08/17] libbpf: add "prog_flags" to bpf_program/bpf_prog_load_attr/bpf_load_program_attr

2019-05-24 Thread Jiong Wang
stomizing program loading. Reviewed-by: Jakub Kicinski Signed-off-by: Jiong Wang --- tools/lib/bpf/bpf.c| 1 + tools/lib/bpf/bpf.h| 1 + tools/lib/bpf/libbpf.c | 3 +++ tools/lib/bpf/libbpf.h | 1 + 4 files changed, 6 insertions(+) diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c index

[PATCH v9 bpf-next 16/17] riscv: bpf: eliminate zero extension code-gen

2019-05-24 Thread Jiong Wang
Cc: Björn Töpel Acked-by: Björn Töpel Tested-by: Björn Töpel Signed-off-by: Jiong Wang --- arch/riscv/net/bpf_jit_comp.c | 43 ++- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/arch/riscv/net/bpf_jit_comp.c b/arch/riscv/net

[PATCH v9 bpf-next 11/17] arm: bpf: eliminate zero extension code-gen

2019-05-24 Thread Jiong Wang
Cc: Shubham Bansal Signed-off-by: Jiong Wang --- arch/arm/net/bpf_jit_32.c | 42 +++--- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/arch/arm/net/bpf_jit_32.c b/arch/arm/net/bpf_jit_32.c index c8bfbbf..97a6b4b 100644 --- a/arch/arm/net

[PATCH v9 bpf-next 15/17] x32: bpf: eliminate zero extension code-gen

2019-05-24 Thread Jiong Wang
Cc: Wang YanQing Tested-by: Wang YanQing Signed-off-by: Jiong Wang --- arch/x86/net/bpf_jit_comp32.c | 83 +-- 1 file changed, 56 insertions(+), 27 deletions(-) diff --git a/arch/x86/net/bpf_jit_comp32.c b/arch/x86/net/bpf_jit_comp32.c index b29e82f

[PATCH v9 bpf-next 14/17] sparc: bpf: eliminate zero extension code-gen

2019-05-24 Thread Jiong Wang
Cc: David S. Miller Signed-off-by: Jiong Wang --- arch/sparc/net/bpf_jit_comp_64.c | 29 +++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/arch/sparc/net/bpf_jit_comp_64.c b/arch/sparc/net/bpf_jit_comp_64.c index 65428e7..3364e2a 100644 --- a/arch

[PATCH v9 bpf-next 06/17] tools: bpf: sync uapi header bpf.h

2019-05-24 Thread Jiong Wang
Sync new bpf prog load flag "BPF_F_TEST_RND_HI32" to tools/. Signed-off-by: Jiong Wang --- tools/include/uapi/linux/bpf.h | 18 ++ 1 file changed, 18 insertions(+) diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h index 68d4470..7c6aef2 10

[PATCH v9 bpf-next 17/17] nfp: bpf: eliminate zero extension code-gen

2019-05-24 Thread Jiong Wang
ed-by: Jakub Kicinski Signed-off-by: Jiong Wang --- drivers/net/ethernet/netronome/nfp/bpf/jit.c | 115 +- drivers/net/ethernet/netronome/nfp/bpf/main.h | 2 + drivers/net/ethernet/netronome/nfp/bpf/verifier.c | 12 +++ 3 files changed, 81 insertions(+), 48 dele

[PATCH v9 bpf-next 00/17] bpf: eliminate zero extensions for sub-register writes

2019-05-24 Thread Jiong Wang
set enabled, > 25% of those 4460 could be identified as doesn't needing zero extension on the destination, and the percentage could go further up to more than 50% with some follow up optimizations based on the infrastructure offered by this set. This leads to significant save on JITed

[PATCH v9 bpf-next 05/17] bpf: introduce new bpf prog load flags "BPF_F_TEST_RND_HI32"

2019-05-24 Thread Jiong Wang
any later insn. Such randomization is only enabled under testing mode which is gated by the new bpf prog load flags "BPF_F_TEST_RND_HI32". Suggested-by: Alexei Starovoitov Signed-off-by: Jiong Wang --- include/uapi/linux/bpf.h | 18 ++ kernel/bpf/syscall.c | 4 +

[PATCH v9 bpf-next 03/17] bpf: introduce new mov32 variant for doing explicit zero extension

2019-05-24 Thread Jiong Wang
insn using this new mov32 variant. One helper function insn_is_zext is added for checking one insn is an zero extension on dst. This will be widely used by a few JIT back-ends in later patches in this set. Signed-off-by: Jiong Wang --- include/linux/filter.h | 14 ++ 1 file changed

[PATCH v9 bpf-next 04/17] bpf: verifier: insert zero extension according to analysis result

2019-05-24 Thread Jiong Wang
s hardware zero extension support. The peephole could be as simple as looking the next insn, if it is a special zero extension insn then it is safe to eliminate it if the current insn has hardware zero extension support. Reviewed-by: Jakub Kicinski Signed-off-by: Jiong Wang --- include/linux/bpf.h

[PATCH v9 bpf-next 10/17] selftests: bpf: enable hi32 randomization for all tests

2019-05-24 Thread Jiong Wang
used load APIs to the test version, hence enable high 32-bit randomization for these tests without changing source code. Besides all these, there are several testcases are using "bpf_prog_load_attr" directly, their call sites are updated to pass BPF_F_TEST_RND_HI32. Signed-off-by: Ji

[PATCH v9 bpf-next 12/17] powerpc: bpf: eliminate zero extension code-gen

2019-05-24 Thread Jiong Wang
Cc: Naveen N. Rao Cc: Sandipan Das Signed-off-by: Jiong Wang --- arch/powerpc/net/bpf_jit_comp64.c | 36 +--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/net/bpf_jit_comp64.c b/arch/powerpc/net/bpf_jit_comp64.c index 21a1dcd

[PATCH v9 bpf-next 07/17] bpf: verifier: randomize high 32-bit when BPF_F_TEST_RND_HI32 is set

2019-05-24 Thread Jiong Wang
This patch randomizes high 32-bit of a definition when BPF_F_TEST_RND_HI32 is set. Suggested-by: Alexei Starovoitov Signed-off-by: Jiong Wang --- kernel/bpf/verifier.c | 68 ++- 1 file changed, 57 insertions(+), 11 deletions(-) diff --git a

[PATCH v9 bpf-next 01/17] bpf: verifier: mark verified-insn with sub-register zext flag

2019-05-24 Thread Jiong Wang
A new sub-register write overrides the old one. - When propagating read64 during path pruning, also mark any insn defining a sub-register that is read in the pruned path as full-register. Reviewed-by: Jakub Kicinski Signed-off-by: Jiong Wang --- include/linux/bpf_verifier.h | 14 +++- kerne

[PATCH v9 bpf-next 09/17] selftests: bpf: adjust several test_verifier helpers for insn insertion

2019-05-24 Thread Jiong Wang
efficient that 1M call to it will hang computer. So , change to BPF_ALU64_IMM to avoid hi32 randomization. Signed-off-by: Jiong Wang --- tools/testing/selftests/bpf/test_verifier.c | 29 +++-- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/tools

[PATCH v9 bpf-next 13/17] s390: bpf: eliminate zero extension code-gen

2019-05-24 Thread Jiong Wang
Cc: Martin Schwidefsky Cc: Heiko Carstens Signed-off-by: Jiong Wang --- arch/s390/net/bpf_jit_comp.c | 41 ++--- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c index 5e7c630..e636728

[PATCH v9 bpf-next 02/17] bpf: verifier: mark patched-insn with sub-register zext flag

2019-05-24 Thread Jiong Wang
Patched insns do not go through generic verification, therefore doesn't has zero extension information collected during insn walking. We don't bother analyze them at the moment, for any sub-register def comes from them, just conservatively mark it as needing zero extension. Signed-off

Re: [PATCH v9 bpf-next 00/17] bpf: eliminate zero extensions for sub-register writes

2019-05-25 Thread Jiong Wang
Alexei Starovoitov writes: > On Fri, May 24, 2019 at 11:25:11PM +0100, Jiong Wang wrote: >> v9: >> - Split patch 5 in v8. >> make bpf uapi header file sync a separate patch. (Alexei) > > 9th time's a charm? ;) Yup :), it's all good things and he

[PATCH bpf 1/2] selftests: bpf: move sub-register zero extension checks into subreg.c

2019-05-29 Thread Jiong Wang
It is better to centralize all sub-register zero extension checks into an independent file. This patch takes the first step to move existing sub-register zero extension checks into subreg.c. Acked-by: Jakub Kicinski Reviewed-by: Quentin Monnet Signed-off-by: Jiong Wang --- tools/testing

[PATCH bpf 0/2] selftests: bpf: more sub-register zero extension unit tests

2019-05-29 Thread Jiong Wang
JIT back-ends need to guarantee high 32-bit cleared whenever one eBPF insn write low 32-bit sub-register only. It is possible that some JIT back-ends have failed doing this and are silently generating wrong image. This set completes the unit tests, so bug on this could be exposed. Jiong Wang (2

[PATCH bpf 2/2] selftests: bpf: complete sub-register zero extension checks

2019-05-29 Thread Jiong Wang
-ends failed to guarantee the mentioned semantics, these unit tests will fail. Acked-by: Jakub Kicinski Reviewed-by: Quentin Monnet Signed-off-by: Jiong Wang --- tools/testing/selftests/bpf/verifier/subreg.c | 516 +- 1 file changed, 505 insertions(+), 11 deletions

[PATCH bpf-next] bpf: doc: update answer for 32-bit subregister question

2019-05-30 Thread Jiong Wang
Reviewed-by: Jakub Kicinski Signed-off-by: Jiong Wang --- Documentation/bpf/bpf_design_QA.rst | 30 +- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/Documentation/bpf/bpf_design_QA.rst b/Documentation/bpf/bpf_design_QA.rst index cb402c5..5092a2a 100644

Re: [PATCH bpf-next] bpf: doc: update answer for 32-bit subregister question

2019-05-30 Thread Jiong Wang
Song Liu writes: > On Thu, May 30, 2019 at 12:46 AM Jiong Wang wrote: >> >> There has been quite a few progress around the two steps mentioned in the >> answer to the following question: >> >> Q: BPF 32-bit subregister requirements >> >> This patc

[PATCH v2 bpf-next] bpf: doc: update answer for 32-bit subregister question

2019-05-30 Thread Jiong Wang
) v1: - Integrated rephrase from Quentin and Jakub Reviewed-by: Quentin Monnet Reviewed-by: Jakub Kicinski Signed-off-by: Jiong Wang --- Documentation/bpf/bpf_design_QA.rst | 30 +- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/Documentation/bpf

Re: [RFC bpf-next 0/8] bpf: accelerate insn patching speed

2019-07-15 Thread Jiong Wang
Andrii Nakryiko writes: > On Thu, Jul 11, 2019 at 4:22 AM Jiong Wang wrote: >> >> >> Andrii Nakryiko writes: >> >> > On Thu, Jul 4, 2019 at 2:31 PM Jiong Wang wrote: >> >> >> >> This is an RFC based on latest bpf-next about accler

Re: [RFC bpf-next 1/8] bpf: introducing list based insn patching infra to core layer

2019-07-15 Thread Jiong Wang
Andrii Nakryiko writes: > On Thu, Jul 11, 2019 at 4:53 AM Jiong Wang wrote: >> >> >> Andrii Nakryiko writes: >> >> > On Thu, Jul 4, 2019 at 2:32 PM Jiong Wang wrote: >> >> >> >> This patch introduces list based bpf insn patching in

Re: [oss-drivers] Re: [RFC bpf-next 2/8] bpf: extend list based insn patching infra to verification layer

2019-07-15 Thread Jiong Wang
Andrii Nakryiko writes: > On Thu, Jul 11, 2019 at 5:20 AM Jiong Wang wrote: >> >> >> Jiong Wang writes: >> >> > Andrii Nakryiko writes: >> > >> >> On Thu, Jul 4, 2019 at 2:32 PM Jiong Wang >> >> wrote: >>

Re: [oss-drivers] Re: [RFC bpf-next 2/8] bpf: extend list based insn patching infra to verification layer

2019-07-16 Thread Jiong Wang
Andrii Nakryiko writes: > On Mon, Jul 15, 2019 at 3:02 AM Jiong Wang wrote: >> >> >> Andrii Nakryiko writes: >> >> > On Thu, Jul 11, 2019 at 5:20 AM Jiong Wang >> > wrote: >> >> >> >> >> >> Jiong Wang writes: &

Re: [RFC bpf-next 0/8] bpf: accelerate insn patching speed

2019-07-16 Thread Jiong Wang
Andrii Nakryiko writes: > On Mon, Jul 15, 2019 at 2:21 AM Jiong Wang wrote: >> >> >> Andrii Nakryiko writes: >> >> > On Thu, Jul 11, 2019 at 4:22 AM Jiong Wang >> > wrote: >> >> >> >> >> >> Andrii Nakryik

Re: [RFC bpf-next 0/8] bpf: accelerate insn patching speed

2019-07-16 Thread Jiong Wang
Alexei Starovoitov writes: > On Tue, Jul 16, 2019 at 09:50:25AM +0100, Jiong Wang wrote: >> >> Let me digest a little bit and do some coding, then I will come back. Some >> issues can only shown up during in-depth coding. I kind of feel handling >> aux reference in

Re: [PATCH] bpf: optimize constant blinding

2019-06-12 Thread Jiong Wang
Alexei Starovoitov writes: > On Wed, Jun 12, 2019 at 4:32 AM Naveen N. Rao > wrote: >> >> Currently, for constant blinding, we re-allocate the bpf program to >> account for its new size and adjust all branches to accommodate the >> same, for each BPF instruction that needs constant blinding. Th

Re: [PATCH] bpf: optimize constant blinding

2019-06-12 Thread Jiong Wang
Jiong Wang writes: > Alexei Starovoitov writes: > >> On Wed, Jun 12, 2019 at 4:32 AM Naveen N. Rao >> wrote: >>> >>> Currently, for constant blinding, we re-allocate the bpf program to >>> account for its new size and adjust all branches to accom

Re: [PATCH] bpf: optimize constant blinding

2019-06-14 Thread Jiong Wang
Alexei Starovoitov writes: > On Wed, Jun 12, 2019 at 8:25 AM Jiong Wang wrote: >> >> >> Jiong Wang writes: >> >> > Alexei Starovoitov writes: >> > >> >> On Wed, Jun 12, 2019 at 4:32 AM Naveen N. Rao >> >> wrote: >> >

Re: [PATCH] bpf: optimize constant blinding

2019-06-17 Thread Jiong Wang
Edward Cree writes: > On 14/06/2019 16:13, Jiong Wang wrote: >> Just an update and keep people posted. >> >> Working on linked list based approach, the implementation looks like the >> following, mostly a combine of discussions happened and Naveen's patch

Re: [PATCH] bpf: optimize constant blinding

2019-06-17 Thread Jiong Wang
Edward Cree writes: > On 17/06/2019 20:59, Jiong Wang wrote: >> Edward Cree writes: >> >>> On 14/06/2019 16:13, Jiong Wang wrote: >>>> Just an update and keep people posted. >>>> >>>> Working on linked list based approach, the imple

Re: [PATCH] bpf: optimize constant blinding

2019-06-17 Thread Jiong Wang
Alexei Starovoitov writes: > On Mon, Jun 17, 2019 at 1:40 PM Jiong Wang wrote: >> >> After digest Alexei and Andrii's reply, I still don't see the need to turn >> branch target into list, and I am not sure whether pool based list sound >> good? it sa

Re: [PATCH] bpf: optimize constant blinding

2019-06-19 Thread Jiong Wang
Edward Cree writes: > On 17/06/2019 21:40, Jiong Wang wrote: >> Now if we don't split patch when patch an insn inside patch, instead, if we >> replace the patched insn using what you suggested, then the logic looks to >> me becomes even more complex, something like

[PATCH bpf] bpf: fix BPF_ALU32 | BPF_ARSH on BE arches

2019-06-25 Thread Jiong Wang
serve the low 32-bit as signed integer, this is all we want. Fixes: 2dc6b100f928 ("bpf: interpreter support BPF_ALU | BPF_ARSH") Reported-by: Yauheni Kaliuta Reviewed-by: Jakub Kicinski Reviewed-by: Quentin Monnet Signed-off-by: Jiong Wang --- kernel/bpf/core.c | 4 ++-- 1 file change

[PATCH bpf-next 1/3] bpf: unify main prog and subprog

2018-04-30 Thread Jiong Wang
to unify them, and register all progs detected into env->subprog_starts. This could also help simplifying some code logic. Signed-off-by: Jiong Wang --- include/linux/bpf_verifier.h | 2 +- kernel/bpf/verifier.c| 57 2 files changed, 32 inse

[PATCH bpf-next 0/3] bpf: cleanups on managing subprog information

2018-04-30 Thread Jiong Wang
rog_end = insn_cnt; else subprog_end = env->subprog_info[cur_subprog + 1].start; into: subprog_end = env->subprog_info[cur_subprog + 1].start; There is no functional change by this patch set. No bpf selftest regression found after this patch set. Jiong Wang (3

[PATCH bpf-next 3/3] bpf: add faked "ending" subprog

2018-04-30 Thread Jiong Wang
marker in subprog_info array to tell the end of it. We could resolve this issue by introducing a faked "ending" subprog. The special "ending" subprog is with "insn_cnt" as start offset, so it is serving as the end mark whenever we iterate over all subprogs. Signed

[PATCH bpf-next 2/3] bpf: centre subprog information fields

2018-04-30 Thread Jiong Wang
It is better to centre all subprog information fields into one structure. This structure could later serve as function node in call graph. Signed-off-by: Jiong Wang --- include/linux/bpf_verifier.h | 9 --- kernel/bpf/verifier.c| 62 +++- 2

Re: [PATCH bpf-next 0/3] bpf: cleanups on managing subprog information

2018-05-02 Thread Jiong Wang
On 01/05/2018 23:22, Alexei Starovoitov wrote: ... [ 27.784931] ? bpf_int_jit_compile+0x7ac/0xab0 [ 27.785475] bpf_int_jit_compile+0x2b6/0xab0 [ 27.786001] ? do_jit+0x6020/0x6020 [ 27.786428] ? kasan_kmalloc+0xa0/0xd0 [ 27.786885] bpf_check+0x2c05/0x4c40 [ 27.787346] ? fixup_bpf

Re: [PATCH bpf-next 0/3] bpf: cleanups on managing subprog information

2018-05-02 Thread Jiong Wang
On 02/05/2018 18:24, John Fastabend wrote: On 05/02/2018 09:59 AM, Jiong Wang wrote: On 01/05/2018 23:22, Alexei Starovoitov wrote: ... [   27.784931]  ? bpf_int_jit_compile+0x7ac/0xab0 [   27.785475]  bpf_int_jit_compile+0x2b6/0xab0 [   27.786001]  ? do_jit+0x6020/0x6020 [   27.786428

[PATCH v2 bpf-next 1/3] bpf: unify main prog and subprog

2018-05-02 Thread Jiong Wang
to unify them, and register all progs detected into env->subprog_starts. This could also help simplifying some code logic. Signed-off-by: Jiong Wang --- include/linux/bpf_verifier.h | 2 +- kernel/bpf/verifier.c| 57 2 files changed, 32 inse

[PATCH v2 bpf-next 3/3] bpf: add faked "ending" subprog

2018-05-02 Thread Jiong Wang
marker in subprog_info array to tell the end of it. We could resolve this issue by introducing a faked "ending" subprog. The special "ending" subprog is with "insn_cnt" as start offset, so it is serving as the end mark whenever we iterate over all subprogs. Signed

[PATCH v2 bpf-next 0/3] bpf: cleanups on managing subprog information

2018-05-02 Thread Jiong Wang
2: - fixed adjust_subprog_starts to also update fake "exit" subprog start. - for John's suggestion on renaming subprog to prog, I could work on a follow-up patch if it is recognized as worth the change. Jiong Wang (3): bpf: unify main prog and subprog bpf: centre subprog

[PATCH v2 bpf-next 2/3] bpf: centre subprog information fields

2018-05-02 Thread Jiong Wang
It is better to centre all subprog information fields into one structure. This structure could later serve as function node in call graph. Signed-off-by: Jiong Wang --- include/linux/bpf_verifier.h | 9 --- kernel/bpf/verifier.c| 62 +++- 2

[RFC bpf-next 00/10] initial control flow support for eBPF verifier

2018-05-07 Thread Jiong Wang
lay the ground for further static analysis inside eBPF verifier, for example bounded loop detection, path-sensitive data-flow analysis etc. Jiong Wang (10): bpf: cfg: partition basic blocks for each subprog bpf: cfg: add edges between basic blocks to form CFG bpf: cfg: build domination tree

[RFC bpf-next 01/10] bpf: cfg: partition basic blocks for each subprog

2018-05-07 Thread Jiong Wang
mmediately follows branch insn start a BB. Insn immediately follows exit and within subprog start a BB. BBs for each subprog are organized as a list in ascending head. Two special BBs, entry and exit are added as well. Signed-off-by: Jiong Wang --- include/linux/bpf_verifier.h | 1 + kernel/bp

[RFC bpf-next 06/10] bpf: cfg: move find_subprog/add_subprog to cfg.c

2018-05-07 Thread Jiong Wang
This patch centre find_subprog and add_subprog to cfg.c. Signed-off-by: Jiong Wang --- kernel/bpf/cfg.c | 41 + kernel/bpf/cfg.h | 2 ++ kernel/bpf/verifier.c | 42 -- 3 files changed, 43 insertions

[RFC bpf-next 07/10] bpf: cfg: build call graph and detect unreachable/recursive call

2018-05-07 Thread Jiong Wang
This patch build call graph during insn scan inside check_subprogs. Then do recursive and unreachable subprog detection using call graph. Signed-off-by: Jiong Wang --- include/linux/bpf_verifier.h | 1 + kernel/bpf/cfg.c | 133 +++ kernel

[RFC bpf-next 08/10] bpf: cfg: remove push_insn and check_cfg

2018-05-07 Thread Jiong Wang
As we have detected loop and unreachable insns based on domination information and call graph, there is no need of check_cfg. This patch removes check_cfg and it's associated push_insn. state prune heuristic marking as moved to check_subprog. Signed-off-by: Jiong Wang --- kerne

[RFC bpf-next 03/10] bpf: cfg: build domination tree using Tarjan algorithm

2018-05-07 Thread Jiong Wang
is built but not tested. Signed-off-by: Jiong Wang --- include/linux/bpf_verifier.h | 3 + kernel/bpf/cfg.c | 386 ++- kernel/bpf/cfg.h | 3 +- kernel/bpf/verifier.c| 5 +- 4 files changed, 393 insertions(+), 4

[RFC bpf-next 02/10] bpf: cfg: add edges between basic blocks to form CFG

2018-05-07 Thread Jiong Wang
This patch add edges between basic blocks. Both edges for predecessors and successors are added. Signed-off-by: Jiong Wang --- kernel/bpf/cfg.c | 129 +- kernel/bpf/cfg.h | 1 + kernel/bpf/verifier.c | 3 ++ 3 files changed, 131

[RFC bpf-next 10/10] bpf: cfg: reduce memory usage by using singly list + compat pointer

2018-05-07 Thread Jiong Wang
t;From benchmarks like test_xdp_noinline, this patch reduce peek memory usage of new cfg infrastructure by more than 50%. Signed-off-by: Jiong Wang --- include/linux/bpf_verifier.h | 7 +- kernel/bpf/cfg.c | 503 --- kernel/bpf/cfg.h

[RFC bpf-next 05/10] bpf: cfg: detect unreachable basic blocks

2018-05-07 Thread Jiong Wang
Do unreachable basic blocks detection as a side-product of the dfs walk when building domination information. Signed-off-by: Jiong Wang --- kernel/bpf/cfg.c | 31 ++- kernel/bpf/cfg.h | 3 ++- kernel/bpf/verifier.c | 3 ++- 3 files changed, 30 insertions

[RFC bpf-next 04/10] bpf: cfg: detect loop use domination information

2018-05-07 Thread Jiong Wang
If one bb is dominating its predecessor, then there is loop. Signed-off-by: Jiong Wang --- kernel/bpf/cfg.c | 22 ++ kernel/bpf/cfg.h | 1 + kernel/bpf/verifier.c | 8 3 files changed, 31 insertions(+) diff --git a/kernel/bpf/cfg.c b/kernel/bpf/cfg.c

[RFC bpf-next 09/10] bpf: cfg: reduce k*alloc/free call by using memory pool for allocating nodes

2018-05-07 Thread Jiong Wang
ation of estimated size (aligned to 2K). The pool will grow later if space are not enough. - There is no support on returning memory back to the pool. Signed-off-by: Jiong Wang --- kernel/bpf/cfg.c | 164 +- kernel/bpf/cfg.h

Re: [RFC bpf-next 00/10] initial control flow support for eBPF verifier

2018-05-07 Thread Jiong Wang
On 07/05/2018 11:22, Jiong Wang wrote: execution time === test_l4lb_noinline: existing check_subprog/check_cfg: ~55000 ns new infrastructure: ~135000 ns test_xdp_noinline: existing check_subprog/check_cfg: ~52000 ns new infrastructure: ~12 ns Intel(R) Xeon(R) CPU E5-2630 v4

  1   2   3   4   5   >