* [PATCH] test_bpf: Add a couple of tests for BPF_JSGE.
@ 2017-05-24 23:35 David Daney
2017-05-24 23:52 ` Daniel Borkmann
2017-05-25 18:39 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: David Daney @ 2017-05-24 23:35 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, netdev, linux-kernel; +Cc: David Daney
Some JITs can optimize comparisons with zero. Add a couple of
BPF_JSGE tests against immediate zero.
Signed-off-by: David Daney <david.daney@cavium.com>
---
lib/test_bpf.c | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/lib/test_bpf.c b/lib/test_bpf.c
index 889bc31..be88cba 100644
--- a/lib/test_bpf.c
+++ b/lib/test_bpf.c
@@ -4504,6 +4504,44 @@ static struct bpf_test tests[] = {
{ },
{ { 0, 1 } },
},
+ {
+ "JMP_JSGE_K: Signed jump: value walk 1",
+ .u.insns_int = {
+ BPF_ALU32_IMM(BPF_MOV, R0, 0),
+ BPF_LD_IMM64(R1, -3),
+ BPF_JMP_IMM(BPF_JSGE, R1, 0, 6),
+ BPF_ALU64_IMM(BPF_ADD, R1, 1),
+ BPF_JMP_IMM(BPF_JSGE, R1, 0, 4),
+ BPF_ALU64_IMM(BPF_ADD, R1, 1),
+ BPF_JMP_IMM(BPF_JSGE, R1, 0, 2),
+ BPF_ALU64_IMM(BPF_ADD, R1, 1),
+ BPF_JMP_IMM(BPF_JSGE, R1, 0, 1),
+ BPF_EXIT_INSN(), /* bad exit */
+ BPF_ALU32_IMM(BPF_MOV, R0, 1), /* good exit */
+ BPF_EXIT_INSN(),
+ },
+ INTERNAL,
+ { },
+ { { 0, 1 } },
+ },
+ {
+ "JMP_JSGE_K: Signed jump: value walk 2",
+ .u.insns_int = {
+ BPF_ALU32_IMM(BPF_MOV, R0, 0),
+ BPF_LD_IMM64(R1, -3),
+ BPF_JMP_IMM(BPF_JSGE, R1, 0, 4),
+ BPF_ALU64_IMM(BPF_ADD, R1, 2),
+ BPF_JMP_IMM(BPF_JSGE, R1, 0, 2),
+ BPF_ALU64_IMM(BPF_ADD, R1, 2),
+ BPF_JMP_IMM(BPF_JSGE, R1, 0, 1),
+ BPF_EXIT_INSN(), /* bad exit */
+ BPF_ALU32_IMM(BPF_MOV, R0, 1), /* good exit */
+ BPF_EXIT_INSN(),
+ },
+ INTERNAL,
+ { },
+ { { 0, 1 } },
+ },
/* BPF_JMP | BPF_JGT | BPF_K */
{
"JMP_JGT_K: if (3 > 2) return 1",
--
2.9.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] test_bpf: Add a couple of tests for BPF_JSGE.
2017-05-24 23:35 [PATCH] test_bpf: Add a couple of tests for BPF_JSGE David Daney
@ 2017-05-24 23:52 ` Daniel Borkmann
2017-05-25 18:39 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Daniel Borkmann @ 2017-05-24 23:52 UTC (permalink / raw)
To: David Daney, Alexei Starovoitov, netdev, linux-kernel
On 05/25/2017 01:35 AM, David Daney wrote:
> Some JITs can optimize comparisons with zero. Add a couple of
> BPF_JSGE tests against immediate zero.
>
> Signed-off-by: David Daney <david.daney@cavium.com>
Thanks for the tests!
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] test_bpf: Add a couple of tests for BPF_JSGE.
2017-05-24 23:35 [PATCH] test_bpf: Add a couple of tests for BPF_JSGE David Daney
2017-05-24 23:52 ` Daniel Borkmann
@ 2017-05-25 18:39 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2017-05-25 18:39 UTC (permalink / raw)
To: david.daney; +Cc: ast, daniel, netdev, linux-kernel
From: David Daney <david.daney@cavium.com>
Date: Wed, 24 May 2017 16:35:49 -0700
> Some JITs can optimize comparisons with zero. Add a couple of
> BPF_JSGE tests against immediate zero.
>
> Signed-off-by: David Daney <david.daney@cavium.com>
Applied, thank you.
This reminds me that I should add support for "branch on register"
to the sparc64 eBPF JIT. At least now, when I do so, there will
be tests for it :-)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-05-25 18:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-24 23:35 [PATCH] test_bpf: Add a couple of tests for BPF_JSGE David Daney
2017-05-24 23:52 ` Daniel Borkmann
2017-05-25 18:39 ` David Miller
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).