2016-04-05 10:04:42

by Naveen N. Rao

[permalink] [raw]
Subject: [PATCH net 1/4] lib/test_bpf: Fix JMP_JSET tests

JMP_JSET tests incorrectly used BPF_JNE. Fix the same.

Cc: Alexei Starovoitov <[email protected]>
Cc: Daniel Borkmann <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: Ananth N Mavinakayanahalli <[email protected]>
Cc: Michael Ellerman <[email protected]>
Cc: Paul Mackerras <[email protected]>
Signed-off-by: Naveen N. Rao <[email protected]>
---
lib/test_bpf.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/test_bpf.c b/lib/test_bpf.c
index 27a7a26..e76fa4d 100644
--- a/lib/test_bpf.c
+++ b/lib/test_bpf.c
@@ -4303,7 +4303,7 @@ static struct bpf_test tests[] = {
.u.insns_int = {
BPF_ALU32_IMM(BPF_MOV, R0, 0),
BPF_LD_IMM64(R1, 3),
- BPF_JMP_IMM(BPF_JNE, R1, 2, 1),
+ BPF_JMP_IMM(BPF_JSET, R1, 2, 1),
BPF_EXIT_INSN(),
BPF_ALU32_IMM(BPF_MOV, R0, 1),
BPF_EXIT_INSN(),
@@ -4317,7 +4317,7 @@ static struct bpf_test tests[] = {
.u.insns_int = {
BPF_ALU32_IMM(BPF_MOV, R0, 0),
BPF_LD_IMM64(R1, 3),
- BPF_JMP_IMM(BPF_JNE, R1, 0xffffffff, 1),
+ BPF_JMP_IMM(BPF_JSET, R1, 0xffffffff, 1),
BPF_EXIT_INSN(),
BPF_ALU32_IMM(BPF_MOV, R0, 1),
BPF_EXIT_INSN(),
@@ -4474,7 +4474,7 @@ static struct bpf_test tests[] = {
BPF_ALU32_IMM(BPF_MOV, R0, 0),
BPF_LD_IMM64(R1, 3),
BPF_LD_IMM64(R2, 2),
- BPF_JMP_REG(BPF_JNE, R1, R2, 1),
+ BPF_JMP_REG(BPF_JSET, R1, R2, 1),
BPF_EXIT_INSN(),
BPF_ALU32_IMM(BPF_MOV, R0, 1),
BPF_EXIT_INSN(),
@@ -4489,7 +4489,7 @@ static struct bpf_test tests[] = {
BPF_ALU32_IMM(BPF_MOV, R0, 0),
BPF_LD_IMM64(R1, 3),
BPF_LD_IMM64(R2, 0xffffffff),
- BPF_JMP_REG(BPF_JNE, R1, R2, 1),
+ BPF_JMP_REG(BPF_JSET, R1, R2, 1),
BPF_EXIT_INSN(),
BPF_ALU32_IMM(BPF_MOV, R0, 1),
BPF_EXIT_INSN(),
--
2.7.4


2016-04-05 10:04:54

by Naveen N. Rao

[permalink] [raw]
Subject: [PATCH net 4/4] lib/test_bpf: Add additional BPF_ADD tests

Some of these tests proved useful with the powerpc eBPF JIT port due to
sign-extended 16-bit immediate loads. Though some of these aspects get
covered in other tests, it is better to have explicit tests so as to
quickly tag the precise problem.

Cc: Alexei Starovoitov <[email protected]>
Cc: Daniel Borkmann <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: Ananth N Mavinakayanahalli <[email protected]>
Cc: Michael Ellerman <[email protected]>
Cc: Paul Mackerras <[email protected]>
Signed-off-by: Naveen N. Rao <[email protected]>
---
lib/test_bpf.c | 128 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 128 insertions(+)

diff --git a/lib/test_bpf.c b/lib/test_bpf.c
index 2fb31aa..8f22fbe 100644
--- a/lib/test_bpf.c
+++ b/lib/test_bpf.c
@@ -2566,6 +2566,70 @@ static struct bpf_test tests[] = {
{ { 0, 0x1 } },
},
{
+ "ALU_ADD_K: 0 + 0xffff = 0xffff",
+ .u.insns_int = {
+ BPF_LD_IMM64(R2, 0x0),
+ BPF_LD_IMM64(R3, 0xffff),
+ BPF_ALU32_IMM(BPF_ADD, R2, 0xffff),
+ BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
+ BPF_MOV32_IMM(R0, 2),
+ BPF_EXIT_INSN(),
+ BPF_MOV32_IMM(R0, 1),
+ BPF_EXIT_INSN(),
+ },
+ INTERNAL,
+ { },
+ { { 0, 0x1 } },
+ },
+ {
+ "ALU_ADD_K: 0 + 0x7fffffff = 0x7fffffff",
+ .u.insns_int = {
+ BPF_LD_IMM64(R2, 0x0),
+ BPF_LD_IMM64(R3, 0x7fffffff),
+ BPF_ALU32_IMM(BPF_ADD, R2, 0x7fffffff),
+ BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
+ BPF_MOV32_IMM(R0, 2),
+ BPF_EXIT_INSN(),
+ BPF_MOV32_IMM(R0, 1),
+ BPF_EXIT_INSN(),
+ },
+ INTERNAL,
+ { },
+ { { 0, 0x1 } },
+ },
+ {
+ "ALU_ADD_K: 0 + 0x80000000 = 0x80000000",
+ .u.insns_int = {
+ BPF_LD_IMM64(R2, 0x0),
+ BPF_LD_IMM64(R3, 0x80000000),
+ BPF_ALU32_IMM(BPF_ADD, R2, 0x80000000),
+ BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
+ BPF_MOV32_IMM(R0, 2),
+ BPF_EXIT_INSN(),
+ BPF_MOV32_IMM(R0, 1),
+ BPF_EXIT_INSN(),
+ },
+ INTERNAL,
+ { },
+ { { 0, 0x1 } },
+ },
+ {
+ "ALU_ADD_K: 0 + 0x80008000 = 0x80008000",
+ .u.insns_int = {
+ BPF_LD_IMM64(R2, 0x0),
+ BPF_LD_IMM64(R3, 0x80008000),
+ BPF_ALU32_IMM(BPF_ADD, R2, 0x80008000),
+ BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
+ BPF_MOV32_IMM(R0, 2),
+ BPF_EXIT_INSN(),
+ BPF_MOV32_IMM(R0, 1),
+ BPF_EXIT_INSN(),
+ },
+ INTERNAL,
+ { },
+ { { 0, 0x1 } },
+ },
+ {
"ALU64_ADD_K: 1 + 2 = 3",
.u.insns_int = {
BPF_LD_IMM64(R0, 1),
@@ -2657,6 +2721,70 @@ static struct bpf_test tests[] = {
{ },
{ { 0, 0x1 } },
},
+ {
+ "ALU64_ADD_K: 0 + 0xffff = 0xffff",
+ .u.insns_int = {
+ BPF_LD_IMM64(R2, 0x0),
+ BPF_LD_IMM64(R3, 0xffff),
+ BPF_ALU64_IMM(BPF_ADD, R2, 0xffff),
+ BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
+ BPF_MOV32_IMM(R0, 2),
+ BPF_EXIT_INSN(),
+ BPF_MOV32_IMM(R0, 1),
+ BPF_EXIT_INSN(),
+ },
+ INTERNAL,
+ { },
+ { { 0, 0x1 } },
+ },
+ {
+ "ALU64_ADD_K: 0 + 0x7fffffff = 0x7fffffff",
+ .u.insns_int = {
+ BPF_LD_IMM64(R2, 0x0),
+ BPF_LD_IMM64(R3, 0x7fffffff),
+ BPF_ALU64_IMM(BPF_ADD, R2, 0x7fffffff),
+ BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
+ BPF_MOV32_IMM(R0, 2),
+ BPF_EXIT_INSN(),
+ BPF_MOV32_IMM(R0, 1),
+ BPF_EXIT_INSN(),
+ },
+ INTERNAL,
+ { },
+ { { 0, 0x1 } },
+ },
+ {
+ "ALU64_ADD_K: 0 + 0x80000000 = 0xffffffff80000000",
+ .u.insns_int = {
+ BPF_LD_IMM64(R2, 0x0),
+ BPF_LD_IMM64(R3, 0xffffffff80000000LL),
+ BPF_ALU64_IMM(BPF_ADD, R2, 0x80000000),
+ BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
+ BPF_MOV32_IMM(R0, 2),
+ BPF_EXIT_INSN(),
+ BPF_MOV32_IMM(R0, 1),
+ BPF_EXIT_INSN(),
+ },
+ INTERNAL,
+ { },
+ { { 0, 0x1 } },
+ },
+ {
+ "ALU_ADD_K: 0 + 0x80008000 = 0xffffffff80008000",
+ .u.insns_int = {
+ BPF_LD_IMM64(R2, 0x0),
+ BPF_LD_IMM64(R3, 0xffffffff80008000LL),
+ BPF_ALU64_IMM(BPF_ADD, R2, 0x80008000),
+ BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
+ BPF_MOV32_IMM(R0, 2),
+ BPF_EXIT_INSN(),
+ BPF_MOV32_IMM(R0, 1),
+ BPF_EXIT_INSN(),
+ },
+ INTERNAL,
+ { },
+ { { 0, 0x1 } },
+ },
/* BPF_ALU | BPF_SUB | BPF_X */
{
"ALU_SUB_X: 3 - 1 = 2",
--
2.7.4

2016-04-05 10:05:06

by Naveen N. Rao

[permalink] [raw]
Subject: [PATCH net 3/4] lib/test_bpf: Add test to check for result of 32-bit add that overflows

BPF_ALU32 and BPF_ALU64 tests for adding two 32-bit values that results in
32-bit overflow.

Cc: Alexei Starovoitov <[email protected]>
Cc: Daniel Borkmann <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: Ananth N Mavinakayanahalli <[email protected]>
Cc: Michael Ellerman <[email protected]>
Cc: Paul Mackerras <[email protected]>
Signed-off-by: Naveen N. Rao <[email protected]>
---
lib/test_bpf.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 64 insertions(+)

diff --git a/lib/test_bpf.c b/lib/test_bpf.c
index 7e6fb49..2fb31aa 100644
--- a/lib/test_bpf.c
+++ b/lib/test_bpf.c
@@ -2444,6 +2444,22 @@ static struct bpf_test tests[] = {
{ { 0, 4294967295U } },
},
{
+ "ALU_ADD_X: 2 + 4294967294 = 0",
+ .u.insns_int = {
+ BPF_LD_IMM64(R0, 2),
+ BPF_LD_IMM64(R1, 4294967294U),
+ BPF_ALU32_REG(BPF_ADD, R0, R1),
+ BPF_JMP_IMM(BPF_JEQ, R0, 0, 2),
+ BPF_ALU32_IMM(BPF_MOV, R0, 0),
+ BPF_EXIT_INSN(),
+ BPF_ALU32_IMM(BPF_MOV, R0, 1),
+ BPF_EXIT_INSN(),
+ },
+ INTERNAL,
+ { },
+ { { 0, 1 } },
+ },
+ {
"ALU64_ADD_X: 1 + 2 = 3",
.u.insns_int = {
BPF_LD_IMM64(R0, 1),
@@ -2467,6 +2483,23 @@ static struct bpf_test tests[] = {
{ },
{ { 0, 4294967295U } },
},
+ {
+ "ALU64_ADD_X: 2 + 4294967294 = 4294967296",
+ .u.insns_int = {
+ BPF_LD_IMM64(R0, 2),
+ BPF_LD_IMM64(R1, 4294967294U),
+ BPF_LD_IMM64(R2, 4294967296ULL),
+ BPF_ALU64_REG(BPF_ADD, R0, R1),
+ BPF_JMP_REG(BPF_JEQ, R0, R2, 2),
+ BPF_MOV32_IMM(R0, 0),
+ BPF_EXIT_INSN(),
+ BPF_MOV32_IMM(R0, 1),
+ BPF_EXIT_INSN(),
+ },
+ INTERNAL,
+ { },
+ { { 0, 1 } },
+ },
/* BPF_ALU | BPF_ADD | BPF_K */
{
"ALU_ADD_K: 1 + 2 = 3",
@@ -2502,6 +2535,21 @@ static struct bpf_test tests[] = {
{ { 0, 4294967295U } },
},
{
+ "ALU_ADD_K: 4294967294 + 2 = 0",
+ .u.insns_int = {
+ BPF_LD_IMM64(R0, 4294967294U),
+ BPF_ALU32_IMM(BPF_ADD, R0, 2),
+ BPF_JMP_IMM(BPF_JEQ, R0, 0, 2),
+ BPF_ALU32_IMM(BPF_MOV, R0, 0),
+ BPF_EXIT_INSN(),
+ BPF_ALU32_IMM(BPF_MOV, R0, 1),
+ BPF_EXIT_INSN(),
+ },
+ INTERNAL,
+ { },
+ { { 0, 1 } },
+ },
+ {
"ALU_ADD_K: 0 + (-1) = 0x00000000ffffffff",
.u.insns_int = {
BPF_LD_IMM64(R2, 0x0),
@@ -2551,6 +2599,22 @@ static struct bpf_test tests[] = {
{ { 0, 2147483647 } },
},
{
+ "ALU64_ADD_K: 4294967294 + 2 = 4294967296",
+ .u.insns_int = {
+ BPF_LD_IMM64(R0, 4294967294U),
+ BPF_LD_IMM64(R1, 4294967296ULL),
+ BPF_ALU64_IMM(BPF_ADD, R0, 2),
+ BPF_JMP_REG(BPF_JEQ, R0, R1, 2),
+ BPF_ALU32_IMM(BPF_MOV, R0, 0),
+ BPF_EXIT_INSN(),
+ BPF_ALU32_IMM(BPF_MOV, R0, 1),
+ BPF_EXIT_INSN(),
+ },
+ INTERNAL,
+ { },
+ { { 0, 1 } },
+ },
+ {
"ALU64_ADD_K: 2147483646 + -2147483647 = -1",
.u.insns_int = {
BPF_LD_IMM64(R0, 2147483646),
--
2.7.4

2016-04-05 10:04:53

by Naveen N. Rao

[permalink] [raw]
Subject: [PATCH net 2/4] lib/test_bpf: Add tests for unsigned BPF_JGT

Unsigned Jump-if-Greater-Than.

Cc: Alexei Starovoitov <[email protected]>
Cc: Daniel Borkmann <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: Ananth N Mavinakayanahalli <[email protected]>
Cc: Michael Ellerman <[email protected]>
Cc: Paul Mackerras <[email protected]>
Signed-off-by: Naveen N. Rao <[email protected]>
---
lib/test_bpf.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)

diff --git a/lib/test_bpf.c b/lib/test_bpf.c
index e76fa4d..7e6fb49 100644
--- a/lib/test_bpf.c
+++ b/lib/test_bpf.c
@@ -4222,6 +4222,20 @@ static struct bpf_test tests[] = {
{ },
{ { 0, 1 } },
},
+ {
+ "JMP_JGT_K: Unsigned jump: if (-1 > 1) return 1",
+ .u.insns_int = {
+ BPF_ALU32_IMM(BPF_MOV, R0, 0),
+ BPF_LD_IMM64(R1, -1),
+ BPF_JMP_IMM(BPF_JGT, R1, 1, 1),
+ BPF_EXIT_INSN(),
+ BPF_ALU32_IMM(BPF_MOV, R0, 1),
+ BPF_EXIT_INSN(),
+ },
+ INTERNAL,
+ { },
+ { { 0, 1 } },
+ },
/* BPF_JMP | BPF_JGE | BPF_K */
{
"JMP_JGE_K: if (3 >= 2) return 1",
@@ -4404,6 +4418,21 @@ static struct bpf_test tests[] = {
{ },
{ { 0, 1 } },
},
+ {
+ "JMP_JGT_X: Unsigned jump: if (-1 > 1) return 1",
+ .u.insns_int = {
+ BPF_ALU32_IMM(BPF_MOV, R0, 0),
+ BPF_LD_IMM64(R1, -1),
+ BPF_LD_IMM64(R2, 1),
+ BPF_JMP_REG(BPF_JGT, R1, R2, 1),
+ BPF_EXIT_INSN(),
+ BPF_ALU32_IMM(BPF_MOV, R0, 1),
+ BPF_EXIT_INSN(),
+ },
+ INTERNAL,
+ { },
+ { { 0, 1 } },
+ },
/* BPF_JMP | BPF_JGE | BPF_X */
{
"JMP_JGE_X: if (3 >= 2) return 1",
--
2.7.4

2016-04-05 15:58:27

by Alexei Starovoitov

[permalink] [raw]
Subject: Re: [PATCH net 1/4] lib/test_bpf: Fix JMP_JSET tests

On 4/5/16 3:02 AM, Naveen N. Rao wrote:
> JMP_JSET tests incorrectly used BPF_JNE. Fix the same.
>
> Cc: Alexei Starovoitov <[email protected]>
> Cc: Daniel Borkmann <[email protected]>
> Cc: "David S. Miller" <[email protected]>
> Cc: Ananth N Mavinakayanahalli <[email protected]>
> Cc: Michael Ellerman <[email protected]>
> Cc: Paul Mackerras <[email protected]>
> Signed-off-by: Naveen N. Rao <[email protected]>

Good catch.
Fixes: cffc642d93f9 ("test_bpf: add 173 new testcases for eBPF")
Acked-by: Alexei Starovoitov <[email protected]>

2016-04-05 16:21:07

by Alexei Starovoitov

[permalink] [raw]
Subject: Re: [PATCH net 2/4] lib/test_bpf: Add tests for unsigned BPF_JGT

On 4/5/16 3:02 AM, Naveen N. Rao wrote:
> Unsigned Jump-if-Greater-Than.
>
> Cc: Alexei Starovoitov <[email protected]>
> Cc: Daniel Borkmann <[email protected]>
> Cc: "David S. Miller" <[email protected]>
> Cc: Ananth N Mavinakayanahalli <[email protected]>
> Cc: Michael Ellerman <[email protected]>
> Cc: Paul Mackerras <[email protected]>
> Signed-off-by: Naveen N. Rao <[email protected]>

I think some of the tests already cover it, but extra tests are
always great.
Acked-by: Alexei Starovoitov <[email protected]>

I think the whole set belongs in net-next.
Next time you submit the patches please say [PATCH net-next] in subject.
[PATCH net] is for bugfixes only.
Thanks a bunch!

2016-04-05 16:22:30

by Alexei Starovoitov

[permalink] [raw]
Subject: Re: [PATCH net 3/4] lib/test_bpf: Add test to check for result of 32-bit add that overflows

On 4/5/16 3:02 AM, Naveen N. Rao wrote:
> BPF_ALU32 and BPF_ALU64 tests for adding two 32-bit values that results in
> 32-bit overflow.
>
> Cc: Alexei Starovoitov <[email protected]>
> Cc: Daniel Borkmann <[email protected]>
> Cc: "David S. Miller" <[email protected]>
> Cc: Ananth N Mavinakayanahalli <[email protected]>
> Cc: Michael Ellerman <[email protected]>
> Cc: Paul Mackerras <[email protected]>
> Signed-off-by: Naveen N. Rao <[email protected]>

Acked-by: Alexei Starovoitov <[email protected]>


2016-04-05 16:29:13

by Alexei Starovoitov

[permalink] [raw]
Subject: Re: [PATCH net 4/4] lib/test_bpf: Add additional BPF_ADD tests

On 4/5/16 3:02 AM, Naveen N. Rao wrote:
> Some of these tests proved useful with the powerpc eBPF JIT port due to
> sign-extended 16-bit immediate loads. Though some of these aspects get
> covered in other tests, it is better to have explicit tests so as to
> quickly tag the precise problem.
>
> Cc: Alexei Starovoitov <[email protected]>
> Cc: Daniel Borkmann <[email protected]>
> Cc: "David S. Miller" <[email protected]>
> Cc: Ananth N Mavinakayanahalli <[email protected]>
> Cc: Michael Ellerman <[email protected]>
> Cc: Paul Mackerras <[email protected]>
> Signed-off-by: Naveen N. Rao <[email protected]>

Makes sense. Looks like ppc jit will be using quite a bit of
available ppc instructions. Nice.

I'm assuming all these new tests passed with x64 jit?

Acked-by: Alexei Starovoitov <[email protected]>

2016-04-05 16:51:45

by Naveen N. Rao

[permalink] [raw]
Subject: Re: [PATCH net 2/4] lib/test_bpf: Add tests for unsigned BPF_JGT

On 2016/04/05 09:20AM, Alexei Starovoitov wrote:
> On 4/5/16 3:02 AM, Naveen N. Rao wrote:
> >Unsigned Jump-if-Greater-Than.
> >
> >Cc: Alexei Starovoitov <[email protected]>
> >Cc: Daniel Borkmann <[email protected]>
> >Cc: "David S. Miller" <[email protected]>
> >Cc: Ananth N Mavinakayanahalli <[email protected]>
> >Cc: Michael Ellerman <[email protected]>
> >Cc: Paul Mackerras <[email protected]>
> >Signed-off-by: Naveen N. Rao <[email protected]>
>
> I think some of the tests already cover it, but extra tests are
> always great.
> Acked-by: Alexei Starovoitov <[email protected]>
>
> I think the whole set belongs in net-next.
> Next time you submit the patches please say [PATCH net-next] in subject.
> [PATCH net] is for bugfixes only.

Ah, sure. Thanks for the review!

- Naveen

2016-04-05 16:53:37

by Naveen N. Rao

[permalink] [raw]
Subject: Re: [PATCH net 4/4] lib/test_bpf: Add additional BPF_ADD tests

On 2016/04/05 09:28AM, Alexei Starovoitov wrote:
> On 4/5/16 3:02 AM, Naveen N. Rao wrote:
> >Some of these tests proved useful with the powerpc eBPF JIT port due to
> >sign-extended 16-bit immediate loads. Though some of these aspects get
> >covered in other tests, it is better to have explicit tests so as to
> >quickly tag the precise problem.
> >
> >Cc: Alexei Starovoitov <[email protected]>
> >Cc: Daniel Borkmann <[email protected]>
> >Cc: "David S. Miller" <[email protected]>
> >Cc: Ananth N Mavinakayanahalli <[email protected]>
> >Cc: Michael Ellerman <[email protected]>
> >Cc: Paul Mackerras <[email protected]>
> >Signed-off-by: Naveen N. Rao <[email protected]>
>
> Makes sense. Looks like ppc jit will be using quite a bit of
> available ppc instructions. Nice.
>
> I'm assuming all these new tests passed with x64 jit?

Yes, all these tests pass on x86_64.

- Naveen

2016-04-05 19:32:13

by Daniel Borkmann

[permalink] [raw]
Subject: Re: [PATCH net 1/4] lib/test_bpf: Fix JMP_JSET tests

On 04/05/2016 12:02 PM, Naveen N. Rao wrote:
> JMP_JSET tests incorrectly used BPF_JNE. Fix the same.
>
> Cc: Alexei Starovoitov <[email protected]>
> Cc: Daniel Borkmann <[email protected]>
> Cc: "David S. Miller" <[email protected]>
> Cc: Ananth N Mavinakayanahalli <[email protected]>
> Cc: Michael Ellerman <[email protected]>
> Cc: Paul Mackerras <[email protected]>
> Signed-off-by: Naveen N. Rao <[email protected]>

Acked-by: Daniel Borkmann <[email protected]>

> ---
> lib/test_bpf.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/lib/test_bpf.c b/lib/test_bpf.c
> index 27a7a26..e76fa4d 100644
> --- a/lib/test_bpf.c
> +++ b/lib/test_bpf.c
> @@ -4303,7 +4303,7 @@ static struct bpf_test tests[] = {
> .u.insns_int = {
> BPF_ALU32_IMM(BPF_MOV, R0, 0),
> BPF_LD_IMM64(R1, 3),
> - BPF_JMP_IMM(BPF_JNE, R1, 2, 1),
> + BPF_JMP_IMM(BPF_JSET, R1, 2, 1),
> BPF_EXIT_INSN(),
> BPF_ALU32_IMM(BPF_MOV, R0, 1),
> BPF_EXIT_INSN(),
> @@ -4317,7 +4317,7 @@ static struct bpf_test tests[] = {
> .u.insns_int = {
> BPF_ALU32_IMM(BPF_MOV, R0, 0),
> BPF_LD_IMM64(R1, 3),
> - BPF_JMP_IMM(BPF_JNE, R1, 0xffffffff, 1),
> + BPF_JMP_IMM(BPF_JSET, R1, 0xffffffff, 1),
> BPF_EXIT_INSN(),
> BPF_ALU32_IMM(BPF_MOV, R0, 1),
> BPF_EXIT_INSN(),
> @@ -4474,7 +4474,7 @@ static struct bpf_test tests[] = {
> BPF_ALU32_IMM(BPF_MOV, R0, 0),
> BPF_LD_IMM64(R1, 3),
> BPF_LD_IMM64(R2, 2),
> - BPF_JMP_REG(BPF_JNE, R1, R2, 1),
> + BPF_JMP_REG(BPF_JSET, R1, R2, 1),
> BPF_EXIT_INSN(),
> BPF_ALU32_IMM(BPF_MOV, R0, 1),
> BPF_EXIT_INSN(),
> @@ -4489,7 +4489,7 @@ static struct bpf_test tests[] = {
> BPF_ALU32_IMM(BPF_MOV, R0, 0),
> BPF_LD_IMM64(R1, 3),
> BPF_LD_IMM64(R2, 0xffffffff),
> - BPF_JMP_REG(BPF_JNE, R1, R2, 1),
> + BPF_JMP_REG(BPF_JSET, R1, R2, 1),
> BPF_EXIT_INSN(),
> BPF_ALU32_IMM(BPF_MOV, R0, 1),
> BPF_EXIT_INSN(),
>

2016-04-05 19:34:07

by Daniel Borkmann

[permalink] [raw]
Subject: Re: [PATCH net 2/4] lib/test_bpf: Add tests for unsigned BPF_JGT

On 04/05/2016 12:02 PM, Naveen N. Rao wrote:
> Unsigned Jump-if-Greater-Than.
>
> Cc: Alexei Starovoitov <[email protected]>
> Cc: Daniel Borkmann <[email protected]>
> Cc: "David S. Miller" <[email protected]>
> Cc: Ananth N Mavinakayanahalli <[email protected]>
> Cc: Michael Ellerman <[email protected]>
> Cc: Paul Mackerras <[email protected]>
> Signed-off-by: Naveen N. Rao <[email protected]>

Acked-by: Daniel Borkmann <[email protected]>

2016-04-05 19:36:42

by Daniel Borkmann

[permalink] [raw]
Subject: Re: [PATCH net 3/4] lib/test_bpf: Add test to check for result of 32-bit add that overflows

On 04/05/2016 12:02 PM, Naveen N. Rao wrote:
> BPF_ALU32 and BPF_ALU64 tests for adding two 32-bit values that results in
> 32-bit overflow.
>
> Cc: Alexei Starovoitov <[email protected]>
> Cc: Daniel Borkmann <[email protected]>
> Cc: "David S. Miller" <[email protected]>
> Cc: Ananth N Mavinakayanahalli <[email protected]>
> Cc: Michael Ellerman <[email protected]>
> Cc: Paul Mackerras <[email protected]>
> Signed-off-by: Naveen N. Rao <[email protected]>

Acked-by: Daniel Borkmann <[email protected]>

2016-04-05 19:48:45

by Daniel Borkmann

[permalink] [raw]
Subject: Re: [PATCH net 4/4] lib/test_bpf: Add additional BPF_ADD tests

On 04/05/2016 12:02 PM, Naveen N. Rao wrote:
> Some of these tests proved useful with the powerpc eBPF JIT port due to
> sign-extended 16-bit immediate loads. Though some of these aspects get
> covered in other tests, it is better to have explicit tests so as to
> quickly tag the precise problem.
>
> Cc: Alexei Starovoitov <[email protected]>
> Cc: Daniel Borkmann <[email protected]>
> Cc: "David S. Miller" <[email protected]>
> Cc: Ananth N Mavinakayanahalli <[email protected]>
> Cc: Michael Ellerman <[email protected]>
> Cc: Paul Mackerras <[email protected]>
> Signed-off-by: Naveen N. Rao <[email protected]>

Thanks for adding these!

Acked-by: Daniel Borkmann <[email protected]>

2016-04-06 20:48:23

by David Miller

[permalink] [raw]
Subject: Re: [PATCH net 1/4] lib/test_bpf: Fix JMP_JSET tests

From: "Naveen N. Rao" <[email protected]>
Date: Tue, 5 Apr 2016 15:32:53 +0530

> JMP_JSET tests incorrectly used BPF_JNE. Fix the same.
>
> Cc: Alexei Starovoitov <[email protected]>
> Cc: Daniel Borkmann <[email protected]>
> Cc: "David S. Miller" <[email protected]>
> Cc: Ananth N Mavinakayanahalli <[email protected]>
> Cc: Michael Ellerman <[email protected]>
> Cc: Paul Mackerras <[email protected]>
> Signed-off-by: Naveen N. Rao <[email protected]>

Applied.

2016-04-06 20:48:27

by David Miller

[permalink] [raw]
Subject: Re: [PATCH net 3/4] lib/test_bpf: Add test to check for result of 32-bit add that overflows

From: "Naveen N. Rao" <[email protected]>
Date: Tue, 5 Apr 2016 15:32:55 +0530

> BPF_ALU32 and BPF_ALU64 tests for adding two 32-bit values that results in
> 32-bit overflow.
>
> Cc: Alexei Starovoitov <[email protected]>
> Cc: Daniel Borkmann <[email protected]>
> Cc: "David S. Miller" <[email protected]>
> Cc: Ananth N Mavinakayanahalli <[email protected]>
> Cc: Michael Ellerman <[email protected]>
> Cc: Paul Mackerras <[email protected]>
> Signed-off-by: Naveen N. Rao <[email protected]>

Applied.

2016-04-06 20:48:34

by David Miller

[permalink] [raw]
Subject: Re: [PATCH net 4/4] lib/test_bpf: Add additional BPF_ADD tests

From: "Naveen N. Rao" <[email protected]>
Date: Tue, 5 Apr 2016 15:32:56 +0530

> Some of these tests proved useful with the powerpc eBPF JIT port due to
> sign-extended 16-bit immediate loads. Though some of these aspects get
> covered in other tests, it is better to have explicit tests so as to
> quickly tag the precise problem.
>
> Cc: Alexei Starovoitov <[email protected]>
> Cc: Daniel Borkmann <[email protected]>
> Cc: "David S. Miller" <[email protected]>
> Cc: Ananth N Mavinakayanahalli <[email protected]>
> Cc: Michael Ellerman <[email protected]>
> Cc: Paul Mackerras <[email protected]>
> Signed-off-by: Naveen N. Rao <[email protected]>

Applied.

2016-04-06 20:48:21

by David Miller

[permalink] [raw]
Subject: Re: [PATCH net 2/4] lib/test_bpf: Add tests for unsigned BPF_JGT

From: "Naveen N. Rao" <[email protected]>
Date: Tue, 5 Apr 2016 15:32:54 +0530

> Unsigned Jump-if-Greater-Than.
>
> Cc: Alexei Starovoitov <[email protected]>
> Cc: Daniel Borkmann <[email protected]>
> Cc: "David S. Miller" <[email protected]>
> Cc: Ananth N Mavinakayanahalli <[email protected]>
> Cc: Michael Ellerman <[email protected]>
> Cc: Paul Mackerras <[email protected]>
> Signed-off-by: Naveen N. Rao <[email protected]>

Applied.