2 * Testsuite for BPF interpreter and BPF JIT compiler
4 * Copyright (c) 2011-2014 PLUMgrid, http://plumgrid.com
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of version 2 of the GNU General Public
8 * License as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
16 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
18 #include <linux/init.h>
19 #include <linux/module.h>
20 #include <linux/filter.h>
21 #include <linux/skbuff.h>
22 #include <linux/netdevice.h>
23 #include <linux/if_vlan.h>
24 #include <linux/random.h>
26 /* General test specific settings */
27 #define MAX_SUBTESTS 3
28 #define MAX_TESTRUNS 10000
31 #define MAX_K 0xffffFFFF
33 /* Few constants used to init test 'skb' */
35 #define SKB_MARK 0x1234aaaa
36 #define SKB_HASH 0x1234aaab
37 #define SKB_QUEUE_MAP 123
38 #define SKB_VLAN_TCI 0xffff
39 #define SKB_DEV_IFINDEX 577
40 #define SKB_DEV_TYPE 588
42 /* Redefine REGs to make tests less verbose */
53 #define R10 BPF_REG_10
55 /* Flags that can be passed to test cases */
56 #define FLAG_NO_DATA BIT(0)
57 #define FLAG_EXPECTED_FAIL BIT(1)
60 CLASSIC
= BIT(6), /* Old BPF instructions only. */
61 INTERNAL
= BIT(7), /* Extended instruction set. */
64 #define TEST_TYPE_MASK (CLASSIC | INTERNAL)
69 struct sock_filter insns
[MAX_INSNS
];
70 struct bpf_insn insns_int
[MAX_INSNS
];
82 int (*fill_helper
)(struct bpf_test
*self
);
85 /* Large test cases need separate allocation and fill handler. */
87 static int bpf_fill_maxinsns1(struct bpf_test
*self
)
89 unsigned int len
= BPF_MAXINSNS
;
90 struct sock_filter
*insn
;
94 insn
= kmalloc_array(len
, sizeof(*insn
), GFP_KERNEL
);
98 for (i
= 0; i
< len
; i
++, k
--)
99 insn
[i
] = __BPF_STMT(BPF_RET
| BPF_K
, k
);
101 self
->u
.ptr
.insns
= insn
;
102 self
->u
.ptr
.len
= len
;
107 static int bpf_fill_maxinsns2(struct bpf_test
*self
)
109 unsigned int len
= BPF_MAXINSNS
;
110 struct sock_filter
*insn
;
113 insn
= kmalloc_array(len
, sizeof(*insn
), GFP_KERNEL
);
117 for (i
= 0; i
< len
; i
++)
118 insn
[i
] = __BPF_STMT(BPF_RET
| BPF_K
, 0xfefefefe);
120 self
->u
.ptr
.insns
= insn
;
121 self
->u
.ptr
.len
= len
;
126 static int bpf_fill_maxinsns3(struct bpf_test
*self
)
128 unsigned int len
= BPF_MAXINSNS
;
129 struct sock_filter
*insn
;
130 struct rnd_state rnd
;
133 insn
= kmalloc_array(len
, sizeof(*insn
), GFP_KERNEL
);
137 prandom_seed_state(&rnd
, 3141592653589793238ULL);
139 for (i
= 0; i
< len
- 1; i
++) {
140 __u32 k
= prandom_u32_state(&rnd
);
142 insn
[i
] = __BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, k
);
145 insn
[len
- 1] = __BPF_STMT(BPF_RET
| BPF_A
, 0);
147 self
->u
.ptr
.insns
= insn
;
148 self
->u
.ptr
.len
= len
;
153 static int bpf_fill_maxinsns4(struct bpf_test
*self
)
155 unsigned int len
= BPF_MAXINSNS
+ 1;
156 struct sock_filter
*insn
;
159 insn
= kmalloc_array(len
, sizeof(*insn
), GFP_KERNEL
);
163 for (i
= 0; i
< len
; i
++)
164 insn
[i
] = __BPF_STMT(BPF_RET
| BPF_K
, 0xfefefefe);
166 self
->u
.ptr
.insns
= insn
;
167 self
->u
.ptr
.len
= len
;
172 static int bpf_fill_maxinsns5(struct bpf_test
*self
)
174 unsigned int len
= BPF_MAXINSNS
;
175 struct sock_filter
*insn
;
178 insn
= kmalloc_array(len
, sizeof(*insn
), GFP_KERNEL
);
182 insn
[0] = __BPF_JUMP(BPF_JMP
| BPF_JA
, len
- 2, 0, 0);
184 for (i
= 1; i
< len
- 1; i
++)
185 insn
[i
] = __BPF_STMT(BPF_RET
| BPF_K
, 0xfefefefe);
187 insn
[len
- 1] = __BPF_STMT(BPF_RET
| BPF_K
, 0xabababab);
189 self
->u
.ptr
.insns
= insn
;
190 self
->u
.ptr
.len
= len
;
195 static int bpf_fill_maxinsns6(struct bpf_test
*self
)
197 unsigned int len
= BPF_MAXINSNS
;
198 struct sock_filter
*insn
;
201 insn
= kmalloc_array(len
, sizeof(*insn
), GFP_KERNEL
);
205 for (i
= 0; i
< len
- 1; i
++)
206 insn
[i
] = __BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
, SKF_AD_OFF
+
207 SKF_AD_VLAN_TAG_PRESENT
);
209 insn
[len
- 1] = __BPF_STMT(BPF_RET
| BPF_A
, 0);
211 self
->u
.ptr
.insns
= insn
;
212 self
->u
.ptr
.len
= len
;
217 static int bpf_fill_maxinsns7(struct bpf_test
*self
)
219 unsigned int len
= BPF_MAXINSNS
;
220 struct sock_filter
*insn
;
223 insn
= kmalloc_array(len
, sizeof(*insn
), GFP_KERNEL
);
227 for (i
= 0; i
< len
- 4; i
++)
228 insn
[i
] = __BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
, SKF_AD_OFF
+
231 insn
[len
- 4] = __BPF_STMT(BPF_MISC
| BPF_TAX
, 0);
232 insn
[len
- 3] = __BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
, SKF_AD_OFF
+
234 insn
[len
- 2] = __BPF_STMT(BPF_ALU
| BPF_SUB
| BPF_X
, 0);
235 insn
[len
- 1] = __BPF_STMT(BPF_RET
| BPF_A
, 0);
237 self
->u
.ptr
.insns
= insn
;
238 self
->u
.ptr
.len
= len
;
243 static int bpf_fill_maxinsns8(struct bpf_test
*self
)
245 unsigned int len
= BPF_MAXINSNS
;
246 struct sock_filter
*insn
;
247 int i
, jmp_off
= len
- 3;
249 insn
= kmalloc_array(len
, sizeof(*insn
), GFP_KERNEL
);
253 insn
[0] = __BPF_STMT(BPF_LD
| BPF_IMM
, 0xffffffff);
255 for (i
= 1; i
< len
- 1; i
++)
256 insn
[i
] = __BPF_JUMP(BPF_JMP
| BPF_JGT
, 0xffffffff, jmp_off
--, 0);
258 insn
[len
- 1] = __BPF_STMT(BPF_RET
| BPF_A
, 0);
260 self
->u
.ptr
.insns
= insn
;
261 self
->u
.ptr
.len
= len
;
266 static int bpf_fill_maxinsns9(struct bpf_test
*self
)
268 unsigned int len
= BPF_MAXINSNS
;
269 struct bpf_insn
*insn
;
272 insn
= kmalloc_array(len
, sizeof(*insn
), GFP_KERNEL
);
276 insn
[0] = BPF_JMP_IMM(BPF_JA
, 0, 0, len
- 2);
277 insn
[1] = BPF_ALU32_IMM(BPF_MOV
, R0
, 0xcbababab);
278 insn
[2] = BPF_EXIT_INSN();
280 for (i
= 3; i
< len
- 2; i
++)
281 insn
[i
] = BPF_ALU32_IMM(BPF_MOV
, R0
, 0xfefefefe);
283 insn
[len
- 2] = BPF_EXIT_INSN();
284 insn
[len
- 1] = BPF_JMP_IMM(BPF_JA
, 0, 0, -(len
- 1));
286 self
->u
.ptr
.insns
= insn
;
287 self
->u
.ptr
.len
= len
;
292 static int bpf_fill_maxinsns10(struct bpf_test
*self
)
294 unsigned int len
= BPF_MAXINSNS
, hlen
= len
- 2;
295 struct bpf_insn
*insn
;
298 insn
= kmalloc_array(len
, sizeof(*insn
), GFP_KERNEL
);
302 for (i
= 0; i
< hlen
/ 2; i
++)
303 insn
[i
] = BPF_JMP_IMM(BPF_JA
, 0, 0, hlen
- 2 - 2 * i
);
304 for (i
= hlen
- 1; i
> hlen
/ 2; i
--)
305 insn
[i
] = BPF_JMP_IMM(BPF_JA
, 0, 0, hlen
- 1 - 2 * i
);
307 insn
[hlen
/ 2] = BPF_JMP_IMM(BPF_JA
, 0, 0, hlen
/ 2 - 1);
308 insn
[hlen
] = BPF_ALU32_IMM(BPF_MOV
, R0
, 0xabababac);
309 insn
[hlen
+ 1] = BPF_EXIT_INSN();
311 self
->u
.ptr
.insns
= insn
;
312 self
->u
.ptr
.len
= len
;
317 static int __bpf_fill_ja(struct bpf_test
*self
, unsigned int len
,
320 struct sock_filter
*insn
;
324 insn
= kmalloc_array(len
, sizeof(*insn
), GFP_KERNEL
);
328 rlen
= (len
% plen
) - 1;
330 for (i
= 0; i
+ plen
< len
; i
+= plen
)
331 for (j
= 0; j
< plen
; j
++)
332 insn
[i
+ j
] = __BPF_JUMP(BPF_JMP
| BPF_JA
,
334 for (j
= 0; j
< rlen
; j
++)
335 insn
[i
+ j
] = __BPF_JUMP(BPF_JMP
| BPF_JA
, rlen
- 1 - j
,
338 insn
[len
- 1] = __BPF_STMT(BPF_RET
| BPF_K
, 0xababcbac);
340 self
->u
.ptr
.insns
= insn
;
341 self
->u
.ptr
.len
= len
;
346 static int bpf_fill_maxinsns11(struct bpf_test
*self
)
348 /* Hits 70 passes on x86_64, so cannot get JITed there. */
349 return __bpf_fill_ja(self
, BPF_MAXINSNS
, 68);
352 static int bpf_fill_ja(struct bpf_test
*self
)
354 /* Hits exactly 11 passes on x86_64 JIT. */
355 return __bpf_fill_ja(self
, 12, 9);
358 static struct bpf_test tests
[] = {
362 BPF_STMT(BPF_LD
| BPF_IMM
, 1),
363 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
364 BPF_STMT(BPF_LD
| BPF_IMM
, 2),
365 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
366 BPF_STMT(BPF_ALU
| BPF_NEG
, 0), /* A == -3 */
367 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
368 BPF_STMT(BPF_LD
| BPF_LEN
, 0),
369 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
370 BPF_STMT(BPF_MISC
| BPF_TAX
, 0), /* X == len - 3 */
371 BPF_STMT(BPF_LD
| BPF_B
| BPF_IND
, 1),
372 BPF_STMT(BPF_RET
| BPF_A
, 0)
375 { 10, 20, 30, 40, 50 },
376 { { 2, 10 }, { 3, 20 }, { 4, 30 } },
381 BPF_STMT(BPF_LDX
| BPF_LEN
, 0),
382 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
383 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
384 BPF_STMT(BPF_RET
| BPF_A
, 0) /* A == len * 2 */
387 { 10, 20, 30, 40, 50 },
388 { { 1, 2 }, { 3, 6 }, { 4, 8 } },
393 BPF_STMT(BPF_LD
| BPF_IMM
, 1),
394 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 2),
395 BPF_STMT(BPF_LDX
| BPF_IMM
, 3),
396 BPF_STMT(BPF_ALU
| BPF_SUB
| BPF_X
, 0),
397 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 0xffffffff),
398 BPF_STMT(BPF_ALU
| BPF_MUL
| BPF_K
, 3),
399 BPF_STMT(BPF_RET
| BPF_A
, 0)
401 CLASSIC
| FLAG_NO_DATA
,
403 { { 0, 0xfffffffd } }
408 BPF_STMT(BPF_LD
| BPF_IMM
, 8),
409 BPF_STMT(BPF_ALU
| BPF_DIV
| BPF_K
, 2),
410 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
411 BPF_STMT(BPF_LD
| BPF_IMM
, 0xffffffff),
412 BPF_STMT(BPF_ALU
| BPF_DIV
| BPF_X
, 0),
413 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
414 BPF_STMT(BPF_LD
| BPF_IMM
, 0xffffffff),
415 BPF_STMT(BPF_ALU
| BPF_DIV
| BPF_K
, 0x70000000),
416 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
417 BPF_STMT(BPF_LD
| BPF_IMM
, 0xffffffff),
418 BPF_STMT(BPF_ALU
| BPF_MOD
| BPF_X
, 0),
419 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
420 BPF_STMT(BPF_LD
| BPF_IMM
, 0xffffffff),
421 BPF_STMT(BPF_ALU
| BPF_MOD
| BPF_K
, 0x70000000),
422 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
423 BPF_STMT(BPF_RET
| BPF_A
, 0)
425 CLASSIC
| FLAG_NO_DATA
,
427 { { 0, 0x20000000 } }
432 BPF_STMT(BPF_LD
| BPF_IMM
, 0xff),
433 BPF_STMT(BPF_ALU
| BPF_AND
| BPF_K
, 0xf0),
434 BPF_STMT(BPF_ALU
| BPF_LSH
| BPF_K
, 27),
435 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
436 BPF_STMT(BPF_LD
| BPF_IMM
, 0xf),
437 BPF_STMT(BPF_ALU
| BPF_OR
| BPF_K
, 0xf0),
438 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
439 BPF_STMT(BPF_RET
| BPF_A
, 0)
441 CLASSIC
| FLAG_NO_DATA
,
443 { { 0, 0x800000ff }, { 1, 0x800000ff } },
448 BPF_STMT(BPF_LD
| BPF_IMM
, 0), /* ld #0 */
449 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 0, 1, 0),
450 BPF_STMT(BPF_RET
| BPF_K
, 0),
451 BPF_STMT(BPF_RET
| BPF_K
, 1),
460 BPF_STMT(BPF_LDX
| BPF_LEN
, 0),
461 BPF_STMT(BPF_LD
| BPF_H
| BPF_IND
, MAX_K
),
462 BPF_STMT(BPF_RET
| BPF_K
, 1)
466 { { 1, 0 }, { 10, 0 }, { 60, 0 } },
471 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
, 1000),
472 BPF_STMT(BPF_RET
| BPF_K
, 1)
476 { { 1, 0 }, { 10, 0 }, { 60, 0 } },
481 BPF_STMT(BPF_LD
| BPF_B
| BPF_ABS
, SKF_LL_OFF
),
482 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
483 BPF_STMT(BPF_LD
| BPF_B
| BPF_ABS
, SKF_LL_OFF
+ 1),
484 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
485 BPF_STMT(BPF_RET
| BPF_A
, 0)
489 { { 1, 0 }, { 2, 3 } },
494 BPF_STMT(BPF_LD
| BPF_IMM
, SKF_LL_OFF
- 1),
495 BPF_STMT(BPF_LDX
| BPF_LEN
, 0),
496 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
497 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
498 BPF_STMT(BPF_LD
| BPF_B
| BPF_IND
, 0),
499 BPF_STMT(BPF_RET
| BPF_A
, 0)
503 { { 1, 1 }, { 3, 3 }, { 4, 0xff } },
508 BPF_STMT(BPF_LD
| BPF_B
| BPF_ABS
, SKF_NET_OFF
),
509 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
510 BPF_STMT(BPF_LD
| BPF_B
| BPF_ABS
, SKF_NET_OFF
+ 1),
511 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
512 BPF_STMT(BPF_RET
| BPF_A
, 0)
515 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3 },
516 { { 15, 0 }, { 16, 3 } },
521 BPF_STMT(BPF_LD
| BPF_IMM
, SKF_NET_OFF
- 15),
522 BPF_STMT(BPF_LDX
| BPF_LEN
, 0),
523 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
524 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
525 BPF_STMT(BPF_LD
| BPF_B
| BPF_IND
, 0),
526 BPF_STMT(BPF_RET
| BPF_A
, 0)
529 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3 },
530 { { 14, 0 }, { 15, 1 }, { 17, 3 } },
535 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
536 SKF_AD_OFF
+ SKF_AD_PKTTYPE
),
537 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, SKB_TYPE
, 1, 0),
538 BPF_STMT(BPF_RET
| BPF_K
, 1),
539 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
540 SKF_AD_OFF
+ SKF_AD_PKTTYPE
),
541 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, SKB_TYPE
, 1, 0),
542 BPF_STMT(BPF_RET
| BPF_K
, 1),
543 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
544 SKF_AD_OFF
+ SKF_AD_PKTTYPE
),
545 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, SKB_TYPE
, 1, 0),
546 BPF_STMT(BPF_RET
| BPF_K
, 1),
547 BPF_STMT(BPF_RET
| BPF_A
, 0)
551 { { 1, 3 }, { 10, 3 } },
556 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
557 SKF_AD_OFF
+ SKF_AD_MARK
),
558 BPF_STMT(BPF_RET
| BPF_A
, 0)
562 { { 1, SKB_MARK
}, { 10, SKB_MARK
} },
567 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
568 SKF_AD_OFF
+ SKF_AD_RXHASH
),
569 BPF_STMT(BPF_RET
| BPF_A
, 0)
573 { { 1, SKB_HASH
}, { 10, SKB_HASH
} },
578 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
579 SKF_AD_OFF
+ SKF_AD_QUEUE
),
580 BPF_STMT(BPF_RET
| BPF_A
, 0)
584 { { 1, SKB_QUEUE_MAP
}, { 10, SKB_QUEUE_MAP
} },
589 BPF_STMT(BPF_LD
| BPF_B
| BPF_ABS
, 1),
590 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 20, 1, 0),
591 BPF_STMT(BPF_RET
| BPF_K
, 0),
592 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
593 SKF_AD_OFF
+ SKF_AD_PROTOCOL
),
594 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
595 BPF_STMT(BPF_LD
| BPF_B
| BPF_ABS
, 2),
596 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 30, 1, 0),
597 BPF_STMT(BPF_RET
| BPF_K
, 0),
598 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
599 BPF_STMT(BPF_RET
| BPF_A
, 0)
603 { { 10, ETH_P_IP
}, { 100, ETH_P_IP
} },
608 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
609 SKF_AD_OFF
+ SKF_AD_VLAN_TAG
),
610 BPF_STMT(BPF_RET
| BPF_A
, 0)
615 { 1, SKB_VLAN_TCI
& ~VLAN_TAG_PRESENT
},
616 { 10, SKB_VLAN_TCI
& ~VLAN_TAG_PRESENT
}
620 "LD_VLAN_TAG_PRESENT",
622 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
623 SKF_AD_OFF
+ SKF_AD_VLAN_TAG_PRESENT
),
624 BPF_STMT(BPF_RET
| BPF_A
, 0)
629 { 1, !!(SKB_VLAN_TCI
& VLAN_TAG_PRESENT
) },
630 { 10, !!(SKB_VLAN_TCI
& VLAN_TAG_PRESENT
) }
636 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
637 SKF_AD_OFF
+ SKF_AD_IFINDEX
),
638 BPF_STMT(BPF_RET
| BPF_A
, 0)
642 { { 1, SKB_DEV_IFINDEX
}, { 10, SKB_DEV_IFINDEX
} },
647 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
648 SKF_AD_OFF
+ SKF_AD_HATYPE
),
649 BPF_STMT(BPF_RET
| BPF_A
, 0)
653 { { 1, SKB_DEV_TYPE
}, { 10, SKB_DEV_TYPE
} },
658 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
659 SKF_AD_OFF
+ SKF_AD_CPU
),
660 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
661 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
662 SKF_AD_OFF
+ SKF_AD_CPU
),
663 BPF_STMT(BPF_ALU
| BPF_SUB
| BPF_X
, 0),
664 BPF_STMT(BPF_RET
| BPF_A
, 0)
668 { { 1, 0 }, { 10, 0 } },
673 BPF_STMT(BPF_LDX
| BPF_IMM
, 2),
674 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
675 BPF_STMT(BPF_LDX
| BPF_IMM
, 3),
676 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
677 SKF_AD_OFF
+ SKF_AD_NLATTR
),
678 BPF_STMT(BPF_RET
| BPF_A
, 0)
682 { 0xff, 0xff, 0, 4, 0, 2, 0, 4, 0, 3 },
684 { 0xff, 0xff, 4, 0, 2, 0, 4, 0, 3, 0 },
686 { { 4, 0 }, { 20, 6 } },
691 BPF_STMT(BPF_LD
| BPF_IMM
, 2),
692 BPF_STMT(BPF_LDX
| BPF_IMM
, 3),
693 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
694 SKF_AD_OFF
+ SKF_AD_NLATTR_NEST
),
695 BPF_STMT(BPF_LD
| BPF_IMM
, 2),
696 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
697 SKF_AD_OFF
+ SKF_AD_NLATTR_NEST
),
698 BPF_STMT(BPF_LD
| BPF_IMM
, 2),
699 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
700 SKF_AD_OFF
+ SKF_AD_NLATTR_NEST
),
701 BPF_STMT(BPF_LD
| BPF_IMM
, 2),
702 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
703 SKF_AD_OFF
+ SKF_AD_NLATTR_NEST
),
704 BPF_STMT(BPF_LD
| BPF_IMM
, 2),
705 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
706 SKF_AD_OFF
+ SKF_AD_NLATTR_NEST
),
707 BPF_STMT(BPF_LD
| BPF_IMM
, 2),
708 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
709 SKF_AD_OFF
+ SKF_AD_NLATTR_NEST
),
710 BPF_STMT(BPF_LD
| BPF_IMM
, 2),
711 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
712 SKF_AD_OFF
+ SKF_AD_NLATTR_NEST
),
713 BPF_STMT(BPF_LD
| BPF_IMM
, 2),
714 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
715 SKF_AD_OFF
+ SKF_AD_NLATTR_NEST
),
716 BPF_STMT(BPF_RET
| BPF_A
, 0)
720 { 0xff, 0xff, 0, 12, 0, 1, 0, 4, 0, 2, 0, 4, 0, 3 },
722 { 0xff, 0xff, 12, 0, 1, 0, 4, 0, 2, 0, 4, 0, 3, 0 },
724 { { 4, 0 }, { 20, 10 } },
729 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
730 SKF_AD_OFF
+ SKF_AD_PAY_OFFSET
),
731 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
732 SKF_AD_OFF
+ SKF_AD_PAY_OFFSET
),
733 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
734 SKF_AD_OFF
+ SKF_AD_PAY_OFFSET
),
735 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
736 SKF_AD_OFF
+ SKF_AD_PAY_OFFSET
),
737 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
738 SKF_AD_OFF
+ SKF_AD_PAY_OFFSET
),
739 BPF_STMT(BPF_RET
| BPF_A
, 0)
742 /* 00:00:00:00:00:00 > 00:00:00:00:00:00, ethtype IPv4 (0x0800),
743 * length 98: 127.0.0.1 > 127.0.0.1: ICMP echo request,
744 * id 9737, seq 1, length 64
746 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
747 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
749 0x45, 0x00, 0x00, 0x54, 0xac, 0x8b, 0x40, 0x00, 0x40,
750 0x01, 0x90, 0x1b, 0x7f, 0x00, 0x00, 0x01 },
751 { { 30, 0 }, { 100, 42 } },
756 BPF_STMT(BPF_LD
| BPF_IMM
, 10),
757 BPF_STMT(BPF_LDX
| BPF_IMM
, 300),
758 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
759 SKF_AD_OFF
+ SKF_AD_ALU_XOR_X
),
760 BPF_STMT(BPF_RET
| BPF_A
, 0)
764 { { 4, 10 ^ 300 }, { 20, 10 ^ 300 } },
769 BPF_STMT(BPF_LDX
| BPF_LEN
, 0),
770 BPF_STMT(BPF_LD
| BPF_IMM
, 2),
771 BPF_STMT(BPF_ALU
| BPF_RSH
, 1),
772 BPF_STMT(BPF_ALU
| BPF_XOR
| BPF_X
, 0),
773 BPF_STMT(BPF_ST
, 1), /* M1 = 1 ^ len */
774 BPF_STMT(BPF_ALU
| BPF_XOR
| BPF_K
, 0x80000000),
775 BPF_STMT(BPF_ST
, 2), /* M2 = 1 ^ len ^ 0x80000000 */
776 BPF_STMT(BPF_STX
, 15), /* M3 = len */
777 BPF_STMT(BPF_LDX
| BPF_MEM
, 1),
778 BPF_STMT(BPF_LD
| BPF_MEM
, 2),
779 BPF_STMT(BPF_ALU
| BPF_XOR
| BPF_X
, 0),
780 BPF_STMT(BPF_LDX
| BPF_MEM
, 15),
781 BPF_STMT(BPF_ALU
| BPF_XOR
| BPF_X
, 0),
782 BPF_STMT(BPF_RET
| BPF_A
, 0)
786 { { 1, 0x80000001 }, { 2, 0x80000002 }, { 60, 0x80000000 ^ 60 } }
791 BPF_STMT(BPF_LDX
| BPF_LEN
, 0),
792 BPF_STMT(BPF_LD
| BPF_B
| BPF_ABS
, 2),
793 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_X
, 0, 0, 1),
794 BPF_STMT(BPF_RET
| BPF_K
, 1),
795 BPF_STMT(BPF_RET
| BPF_K
, MAX_K
)
799 { { 1, 0 }, { 3, 1 }, { 4, MAX_K
} },
804 BPF_STMT(BPF_LDX
| BPF_LEN
, 0),
805 BPF_STMT(BPF_LD
| BPF_B
| BPF_ABS
, 2),
806 BPF_JUMP(BPF_JMP
| BPF_JGT
| BPF_X
, 0, 0, 1),
807 BPF_STMT(BPF_RET
| BPF_K
, 1),
808 BPF_STMT(BPF_RET
| BPF_K
, MAX_K
)
812 { { 2, 0 }, { 3, 1 }, { 4, MAX_K
} },
817 BPF_STMT(BPF_LDX
| BPF_LEN
, 0),
818 BPF_STMT(BPF_LD
| BPF_B
| BPF_IND
, MAX_K
),
819 BPF_JUMP(BPF_JMP
| BPF_JGE
| BPF_K
, 1, 1, 0),
820 BPF_STMT(BPF_RET
| BPF_K
, 10),
821 BPF_JUMP(BPF_JMP
| BPF_JGE
| BPF_K
, 2, 1, 0),
822 BPF_STMT(BPF_RET
| BPF_K
, 20),
823 BPF_JUMP(BPF_JMP
| BPF_JGE
| BPF_K
, 3, 1, 0),
824 BPF_STMT(BPF_RET
| BPF_K
, 30),
825 BPF_JUMP(BPF_JMP
| BPF_JGE
| BPF_K
, 4, 1, 0),
826 BPF_STMT(BPF_RET
| BPF_K
, 40),
827 BPF_STMT(BPF_RET
| BPF_K
, MAX_K
)
831 { { 1, 20 }, { 3, 40 }, { 5, MAX_K
} },
836 BPF_JUMP(BPF_JMP
| BPF_JA
, 0, 0, 0),
837 BPF_JUMP(BPF_JMP
| BPF_JA
, 1, 1, 1),
838 BPF_JUMP(BPF_JMP
| BPF_JA
, 0, 0, 0),
839 BPF_JUMP(BPF_JMP
| BPF_JA
, 0, 0, 0),
840 BPF_STMT(BPF_LDX
| BPF_LEN
, 0),
841 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
842 BPF_STMT(BPF_ALU
| BPF_SUB
| BPF_K
, 4),
843 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
844 BPF_STMT(BPF_LD
| BPF_W
| BPF_IND
, 0),
845 BPF_JUMP(BPF_JMP
| BPF_JSET
| BPF_K
, 1, 0, 1),
846 BPF_STMT(BPF_RET
| BPF_K
, 10),
847 BPF_JUMP(BPF_JMP
| BPF_JSET
| BPF_K
, 0x80000000, 0, 1),
848 BPF_STMT(BPF_RET
| BPF_K
, 20),
849 BPF_JUMP(BPF_JMP
| BPF_JSET
| BPF_K
, 0xffffff, 1, 0),
850 BPF_STMT(BPF_RET
| BPF_K
, 30),
851 BPF_JUMP(BPF_JMP
| BPF_JSET
| BPF_K
, 0xffffff, 1, 0),
852 BPF_STMT(BPF_RET
| BPF_K
, 30),
853 BPF_JUMP(BPF_JMP
| BPF_JSET
| BPF_K
, 0xffffff, 1, 0),
854 BPF_STMT(BPF_RET
| BPF_K
, 30),
855 BPF_JUMP(BPF_JMP
| BPF_JSET
| BPF_K
, 0xffffff, 1, 0),
856 BPF_STMT(BPF_RET
| BPF_K
, 30),
857 BPF_JUMP(BPF_JMP
| BPF_JSET
| BPF_K
, 0xffffff, 1, 0),
858 BPF_STMT(BPF_RET
| BPF_K
, 30),
859 BPF_STMT(BPF_RET
| BPF_K
, MAX_K
)
862 { 0, 0xAA, 0x55, 1 },
863 { { 4, 10 }, { 5, 20 }, { 6, MAX_K
} },
868 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 12),
869 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 0x86dd, 0, 8), /* IPv6 */
870 BPF_STMT(BPF_LD
| BPF_B
| BPF_ABS
, 20),
871 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 0x84, 2, 0),
872 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 0x6, 1, 0),
873 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 0x11, 0, 17),
874 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 54),
875 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 22, 14, 0),
876 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 56),
877 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 22, 12, 13),
878 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 0x0800, 0, 12), /* IPv4 */
879 BPF_STMT(BPF_LD
| BPF_B
| BPF_ABS
, 23),
880 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 0x84, 2, 0),
881 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 0x6, 1, 0),
882 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 0x11, 0, 8),
883 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 20),
884 BPF_JUMP(BPF_JMP
| BPF_JSET
| BPF_K
, 0x1fff, 6, 0),
885 BPF_STMT(BPF_LDX
| BPF_B
| BPF_MSH
, 14),
886 BPF_STMT(BPF_LD
| BPF_H
| BPF_IND
, 14),
887 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 22, 2, 0),
888 BPF_STMT(BPF_LD
| BPF_H
| BPF_IND
, 16),
889 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 22, 0, 1),
890 BPF_STMT(BPF_RET
| BPF_K
, 0xffff),
891 BPF_STMT(BPF_RET
| BPF_K
, 0),
894 /* 3c:07:54:43:e5:76 > 10:bf:48:d6:43:d6, ethertype IPv4(0x0800)
895 * length 114: 10.1.1.149.49700 > 10.1.2.10.22: Flags [P.],
896 * seq 1305692979:1305693027, ack 3650467037, win 65535,
897 * options [nop,nop,TS val 2502645400 ecr 3971138], length 48
899 { 0x10, 0xbf, 0x48, 0xd6, 0x43, 0xd6,
900 0x3c, 0x07, 0x54, 0x43, 0xe5, 0x76,
902 0x45, 0x10, 0x00, 0x64, 0x75, 0xb5,
903 0x40, 0x00, 0x40, 0x06, 0xad, 0x2e, /* IP header */
904 0x0a, 0x01, 0x01, 0x95, /* ip src */
905 0x0a, 0x01, 0x02, 0x0a, /* ip dst */
907 0x00, 0x16 /* dst port */ },
908 { { 10, 0 }, { 30, 0 }, { 100, 65535 } },
913 /* tcpdump -nei eth0 'tcp port 22 and (((ip[2:2] -
914 * ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0) and
915 * (len > 115 or len < 30000000000)' -d
917 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 12),
918 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 0x86dd, 30, 0),
919 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 0x800, 0, 29),
920 BPF_STMT(BPF_LD
| BPF_B
| BPF_ABS
, 23),
921 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 0x6, 0, 27),
922 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 20),
923 BPF_JUMP(BPF_JMP
| BPF_JSET
| BPF_K
, 0x1fff, 25, 0),
924 BPF_STMT(BPF_LDX
| BPF_B
| BPF_MSH
, 14),
925 BPF_STMT(BPF_LD
| BPF_H
| BPF_IND
, 14),
926 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 22, 2, 0),
927 BPF_STMT(BPF_LD
| BPF_H
| BPF_IND
, 16),
928 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 22, 0, 20),
929 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 16),
931 BPF_STMT(BPF_LD
| BPF_B
| BPF_ABS
, 14),
932 BPF_STMT(BPF_ALU
| BPF_AND
| BPF_K
, 0xf),
933 BPF_STMT(BPF_ALU
| BPF_LSH
| BPF_K
, 2),
934 BPF_STMT(BPF_MISC
| BPF_TAX
, 0x5), /* libpcap emits K on TAX */
935 BPF_STMT(BPF_LD
| BPF_MEM
, 1),
936 BPF_STMT(BPF_ALU
| BPF_SUB
| BPF_X
, 0),
938 BPF_STMT(BPF_LDX
| BPF_B
| BPF_MSH
, 14),
939 BPF_STMT(BPF_LD
| BPF_B
| BPF_IND
, 26),
940 BPF_STMT(BPF_ALU
| BPF_AND
| BPF_K
, 0xf0),
941 BPF_STMT(BPF_ALU
| BPF_RSH
| BPF_K
, 2),
942 BPF_STMT(BPF_MISC
| BPF_TAX
, 0x9), /* libpcap emits K on TAX */
943 BPF_STMT(BPF_LD
| BPF_MEM
, 5),
944 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_X
, 0, 4, 0),
945 BPF_STMT(BPF_LD
| BPF_LEN
, 0),
946 BPF_JUMP(BPF_JMP
| BPF_JGT
| BPF_K
, 0x73, 1, 0),
947 BPF_JUMP(BPF_JMP
| BPF_JGE
| BPF_K
, 0xfc23ac00, 1, 0),
948 BPF_STMT(BPF_RET
| BPF_K
, 0xffff),
949 BPF_STMT(BPF_RET
| BPF_K
, 0),
952 { 0x10, 0xbf, 0x48, 0xd6, 0x43, 0xd6,
953 0x3c, 0x07, 0x54, 0x43, 0xe5, 0x76,
955 0x45, 0x10, 0x00, 0x64, 0x75, 0xb5,
956 0x40, 0x00, 0x40, 0x06, 0xad, 0x2e, /* IP header */
957 0x0a, 0x01, 0x01, 0x95, /* ip src */
958 0x0a, 0x01, 0x02, 0x0a, /* ip dst */
960 0x00, 0x16 /* dst port */ },
961 { { 10, 0 }, { 30, 0 }, { 100, 65535 } },
966 /* check that unitialized X and A contain zeros */
967 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
968 BPF_STMT(BPF_RET
| BPF_A
, 0)
977 BPF_ALU64_IMM(BPF_MOV
, R1
, 1),
978 BPF_ALU64_IMM(BPF_ADD
, R1
, 2),
979 BPF_ALU64_IMM(BPF_MOV
, R2
, 3),
980 BPF_ALU64_REG(BPF_SUB
, R1
, R2
),
981 BPF_ALU64_IMM(BPF_ADD
, R1
, -1),
982 BPF_ALU64_IMM(BPF_MUL
, R1
, 3),
983 BPF_ALU64_REG(BPF_MOV
, R0
, R1
),
988 { { 0, 0xfffffffd } }
993 BPF_ALU64_IMM(BPF_MOV
, R0
, -1),
994 BPF_ALU64_IMM(BPF_MOV
, R1
, -1),
995 BPF_ALU64_IMM(BPF_MOV
, R2
, 3),
996 BPF_ALU64_REG(BPF_MUL
, R1
, R2
),
997 BPF_JMP_IMM(BPF_JEQ
, R1
, 0xfffffffd, 1),
999 BPF_ALU64_IMM(BPF_MOV
, R0
, 1),
1009 BPF_ALU32_IMM(BPF_MOV
, R0
, -1),
1010 BPF_ALU32_IMM(BPF_MOV
, R1
, -1),
1011 BPF_ALU32_IMM(BPF_MOV
, R2
, 3),
1012 BPF_ALU64_REG(BPF_MUL
, R1
, R2
),
1013 BPF_ALU64_IMM(BPF_RSH
, R1
, 8),
1014 BPF_JMP_IMM(BPF_JEQ
, R1
, 0x2ffffff, 1),
1016 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
1026 BPF_ALU32_IMM(BPF_MOV
, R0
, -1),
1027 BPF_ALU64_IMM(BPF_MOV
, R1
, -1),
1028 BPF_ALU32_IMM(BPF_MOV
, R2
, 3),
1029 BPF_ALU32_REG(BPF_MUL
, R1
, R2
),
1030 BPF_ALU64_IMM(BPF_RSH
, R1
, 8),
1031 BPF_JMP_IMM(BPF_JEQ
, R1
, 0xffffff, 1),
1033 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
1041 /* Have to test all register combinations, since
1042 * JITing of different registers will produce
1043 * different asm code.
1047 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
1048 BPF_ALU64_IMM(BPF_MOV
, R1
, 1),
1049 BPF_ALU64_IMM(BPF_MOV
, R2
, 2),
1050 BPF_ALU64_IMM(BPF_MOV
, R3
, 3),
1051 BPF_ALU64_IMM(BPF_MOV
, R4
, 4),
1052 BPF_ALU64_IMM(BPF_MOV
, R5
, 5),
1053 BPF_ALU64_IMM(BPF_MOV
, R6
, 6),
1054 BPF_ALU64_IMM(BPF_MOV
, R7
, 7),
1055 BPF_ALU64_IMM(BPF_MOV
, R8
, 8),
1056 BPF_ALU64_IMM(BPF_MOV
, R9
, 9),
1057 BPF_ALU64_IMM(BPF_ADD
, R0
, 20),
1058 BPF_ALU64_IMM(BPF_ADD
, R1
, 20),
1059 BPF_ALU64_IMM(BPF_ADD
, R2
, 20),
1060 BPF_ALU64_IMM(BPF_ADD
, R3
, 20),
1061 BPF_ALU64_IMM(BPF_ADD
, R4
, 20),
1062 BPF_ALU64_IMM(BPF_ADD
, R5
, 20),
1063 BPF_ALU64_IMM(BPF_ADD
, R6
, 20),
1064 BPF_ALU64_IMM(BPF_ADD
, R7
, 20),
1065 BPF_ALU64_IMM(BPF_ADD
, R8
, 20),
1066 BPF_ALU64_IMM(BPF_ADD
, R9
, 20),
1067 BPF_ALU64_IMM(BPF_SUB
, R0
, 10),
1068 BPF_ALU64_IMM(BPF_SUB
, R1
, 10),
1069 BPF_ALU64_IMM(BPF_SUB
, R2
, 10),
1070 BPF_ALU64_IMM(BPF_SUB
, R3
, 10),
1071 BPF_ALU64_IMM(BPF_SUB
, R4
, 10),
1072 BPF_ALU64_IMM(BPF_SUB
, R5
, 10),
1073 BPF_ALU64_IMM(BPF_SUB
, R6
, 10),
1074 BPF_ALU64_IMM(BPF_SUB
, R7
, 10),
1075 BPF_ALU64_IMM(BPF_SUB
, R8
, 10),
1076 BPF_ALU64_IMM(BPF_SUB
, R9
, 10),
1077 BPF_ALU64_REG(BPF_ADD
, R0
, R0
),
1078 BPF_ALU64_REG(BPF_ADD
, R0
, R1
),
1079 BPF_ALU64_REG(BPF_ADD
, R0
, R2
),
1080 BPF_ALU64_REG(BPF_ADD
, R0
, R3
),
1081 BPF_ALU64_REG(BPF_ADD
, R0
, R4
),
1082 BPF_ALU64_REG(BPF_ADD
, R0
, R5
),
1083 BPF_ALU64_REG(BPF_ADD
, R0
, R6
),
1084 BPF_ALU64_REG(BPF_ADD
, R0
, R7
),
1085 BPF_ALU64_REG(BPF_ADD
, R0
, R8
),
1086 BPF_ALU64_REG(BPF_ADD
, R0
, R9
), /* R0 == 155 */
1087 BPF_JMP_IMM(BPF_JEQ
, R0
, 155, 1),
1089 BPF_ALU64_REG(BPF_ADD
, R1
, R0
),
1090 BPF_ALU64_REG(BPF_ADD
, R1
, R1
),
1091 BPF_ALU64_REG(BPF_ADD
, R1
, R2
),
1092 BPF_ALU64_REG(BPF_ADD
, R1
, R3
),
1093 BPF_ALU64_REG(BPF_ADD
, R1
, R4
),
1094 BPF_ALU64_REG(BPF_ADD
, R1
, R5
),
1095 BPF_ALU64_REG(BPF_ADD
, R1
, R6
),
1096 BPF_ALU64_REG(BPF_ADD
, R1
, R7
),
1097 BPF_ALU64_REG(BPF_ADD
, R1
, R8
),
1098 BPF_ALU64_REG(BPF_ADD
, R1
, R9
), /* R1 == 456 */
1099 BPF_JMP_IMM(BPF_JEQ
, R1
, 456, 1),
1101 BPF_ALU64_REG(BPF_ADD
, R2
, R0
),
1102 BPF_ALU64_REG(BPF_ADD
, R2
, R1
),
1103 BPF_ALU64_REG(BPF_ADD
, R2
, R2
),
1104 BPF_ALU64_REG(BPF_ADD
, R2
, R3
),
1105 BPF_ALU64_REG(BPF_ADD
, R2
, R4
),
1106 BPF_ALU64_REG(BPF_ADD
, R2
, R5
),
1107 BPF_ALU64_REG(BPF_ADD
, R2
, R6
),
1108 BPF_ALU64_REG(BPF_ADD
, R2
, R7
),
1109 BPF_ALU64_REG(BPF_ADD
, R2
, R8
),
1110 BPF_ALU64_REG(BPF_ADD
, R2
, R9
), /* R2 == 1358 */
1111 BPF_JMP_IMM(BPF_JEQ
, R2
, 1358, 1),
1113 BPF_ALU64_REG(BPF_ADD
, R3
, R0
),
1114 BPF_ALU64_REG(BPF_ADD
, R3
, R1
),
1115 BPF_ALU64_REG(BPF_ADD
, R3
, R2
),
1116 BPF_ALU64_REG(BPF_ADD
, R3
, R3
),
1117 BPF_ALU64_REG(BPF_ADD
, R3
, R4
),
1118 BPF_ALU64_REG(BPF_ADD
, R3
, R5
),
1119 BPF_ALU64_REG(BPF_ADD
, R3
, R6
),
1120 BPF_ALU64_REG(BPF_ADD
, R3
, R7
),
1121 BPF_ALU64_REG(BPF_ADD
, R3
, R8
),
1122 BPF_ALU64_REG(BPF_ADD
, R3
, R9
), /* R3 == 4063 */
1123 BPF_JMP_IMM(BPF_JEQ
, R3
, 4063, 1),
1125 BPF_ALU64_REG(BPF_ADD
, R4
, R0
),
1126 BPF_ALU64_REG(BPF_ADD
, R4
, R1
),
1127 BPF_ALU64_REG(BPF_ADD
, R4
, R2
),
1128 BPF_ALU64_REG(BPF_ADD
, R4
, R3
),
1129 BPF_ALU64_REG(BPF_ADD
, R4
, R4
),
1130 BPF_ALU64_REG(BPF_ADD
, R4
, R5
),
1131 BPF_ALU64_REG(BPF_ADD
, R4
, R6
),
1132 BPF_ALU64_REG(BPF_ADD
, R4
, R7
),
1133 BPF_ALU64_REG(BPF_ADD
, R4
, R8
),
1134 BPF_ALU64_REG(BPF_ADD
, R4
, R9
), /* R4 == 12177 */
1135 BPF_JMP_IMM(BPF_JEQ
, R4
, 12177, 1),
1137 BPF_ALU64_REG(BPF_ADD
, R5
, R0
),
1138 BPF_ALU64_REG(BPF_ADD
, R5
, R1
),
1139 BPF_ALU64_REG(BPF_ADD
, R5
, R2
),
1140 BPF_ALU64_REG(BPF_ADD
, R5
, R3
),
1141 BPF_ALU64_REG(BPF_ADD
, R5
, R4
),
1142 BPF_ALU64_REG(BPF_ADD
, R5
, R5
),
1143 BPF_ALU64_REG(BPF_ADD
, R5
, R6
),
1144 BPF_ALU64_REG(BPF_ADD
, R5
, R7
),
1145 BPF_ALU64_REG(BPF_ADD
, R5
, R8
),
1146 BPF_ALU64_REG(BPF_ADD
, R5
, R9
), /* R5 == 36518 */
1147 BPF_JMP_IMM(BPF_JEQ
, R5
, 36518, 1),
1149 BPF_ALU64_REG(BPF_ADD
, R6
, R0
),
1150 BPF_ALU64_REG(BPF_ADD
, R6
, R1
),
1151 BPF_ALU64_REG(BPF_ADD
, R6
, R2
),
1152 BPF_ALU64_REG(BPF_ADD
, R6
, R3
),
1153 BPF_ALU64_REG(BPF_ADD
, R6
, R4
),
1154 BPF_ALU64_REG(BPF_ADD
, R6
, R5
),
1155 BPF_ALU64_REG(BPF_ADD
, R6
, R6
),
1156 BPF_ALU64_REG(BPF_ADD
, R6
, R7
),
1157 BPF_ALU64_REG(BPF_ADD
, R6
, R8
),
1158 BPF_ALU64_REG(BPF_ADD
, R6
, R9
), /* R6 == 109540 */
1159 BPF_JMP_IMM(BPF_JEQ
, R6
, 109540, 1),
1161 BPF_ALU64_REG(BPF_ADD
, R7
, R0
),
1162 BPF_ALU64_REG(BPF_ADD
, R7
, R1
),
1163 BPF_ALU64_REG(BPF_ADD
, R7
, R2
),
1164 BPF_ALU64_REG(BPF_ADD
, R7
, R3
),
1165 BPF_ALU64_REG(BPF_ADD
, R7
, R4
),
1166 BPF_ALU64_REG(BPF_ADD
, R7
, R5
),
1167 BPF_ALU64_REG(BPF_ADD
, R7
, R6
),
1168 BPF_ALU64_REG(BPF_ADD
, R7
, R7
),
1169 BPF_ALU64_REG(BPF_ADD
, R7
, R8
),
1170 BPF_ALU64_REG(BPF_ADD
, R7
, R9
), /* R7 == 328605 */
1171 BPF_JMP_IMM(BPF_JEQ
, R7
, 328605, 1),
1173 BPF_ALU64_REG(BPF_ADD
, R8
, R0
),
1174 BPF_ALU64_REG(BPF_ADD
, R8
, R1
),
1175 BPF_ALU64_REG(BPF_ADD
, R8
, R2
),
1176 BPF_ALU64_REG(BPF_ADD
, R8
, R3
),
1177 BPF_ALU64_REG(BPF_ADD
, R8
, R4
),
1178 BPF_ALU64_REG(BPF_ADD
, R8
, R5
),
1179 BPF_ALU64_REG(BPF_ADD
, R8
, R6
),
1180 BPF_ALU64_REG(BPF_ADD
, R8
, R7
),
1181 BPF_ALU64_REG(BPF_ADD
, R8
, R8
),
1182 BPF_ALU64_REG(BPF_ADD
, R8
, R9
), /* R8 == 985799 */
1183 BPF_JMP_IMM(BPF_JEQ
, R8
, 985799, 1),
1185 BPF_ALU64_REG(BPF_ADD
, R9
, R0
),
1186 BPF_ALU64_REG(BPF_ADD
, R9
, R1
),
1187 BPF_ALU64_REG(BPF_ADD
, R9
, R2
),
1188 BPF_ALU64_REG(BPF_ADD
, R9
, R3
),
1189 BPF_ALU64_REG(BPF_ADD
, R9
, R4
),
1190 BPF_ALU64_REG(BPF_ADD
, R9
, R5
),
1191 BPF_ALU64_REG(BPF_ADD
, R9
, R6
),
1192 BPF_ALU64_REG(BPF_ADD
, R9
, R7
),
1193 BPF_ALU64_REG(BPF_ADD
, R9
, R8
),
1194 BPF_ALU64_REG(BPF_ADD
, R9
, R9
), /* R9 == 2957380 */
1195 BPF_ALU64_REG(BPF_MOV
, R0
, R9
),
1205 BPF_ALU32_IMM(BPF_MOV
, R0
, 20),
1206 BPF_ALU32_IMM(BPF_MOV
, R1
, 1),
1207 BPF_ALU32_IMM(BPF_MOV
, R2
, 2),
1208 BPF_ALU32_IMM(BPF_MOV
, R3
, 3),
1209 BPF_ALU32_IMM(BPF_MOV
, R4
, 4),
1210 BPF_ALU32_IMM(BPF_MOV
, R5
, 5),
1211 BPF_ALU32_IMM(BPF_MOV
, R6
, 6),
1212 BPF_ALU32_IMM(BPF_MOV
, R7
, 7),
1213 BPF_ALU32_IMM(BPF_MOV
, R8
, 8),
1214 BPF_ALU32_IMM(BPF_MOV
, R9
, 9),
1215 BPF_ALU64_IMM(BPF_ADD
, R1
, 10),
1216 BPF_ALU64_IMM(BPF_ADD
, R2
, 10),
1217 BPF_ALU64_IMM(BPF_ADD
, R3
, 10),
1218 BPF_ALU64_IMM(BPF_ADD
, R4
, 10),
1219 BPF_ALU64_IMM(BPF_ADD
, R5
, 10),
1220 BPF_ALU64_IMM(BPF_ADD
, R6
, 10),
1221 BPF_ALU64_IMM(BPF_ADD
, R7
, 10),
1222 BPF_ALU64_IMM(BPF_ADD
, R8
, 10),
1223 BPF_ALU64_IMM(BPF_ADD
, R9
, 10),
1224 BPF_ALU32_REG(BPF_ADD
, R0
, R1
),
1225 BPF_ALU32_REG(BPF_ADD
, R0
, R2
),
1226 BPF_ALU32_REG(BPF_ADD
, R0
, R3
),
1227 BPF_ALU32_REG(BPF_ADD
, R0
, R4
),
1228 BPF_ALU32_REG(BPF_ADD
, R0
, R5
),
1229 BPF_ALU32_REG(BPF_ADD
, R0
, R6
),
1230 BPF_ALU32_REG(BPF_ADD
, R0
, R7
),
1231 BPF_ALU32_REG(BPF_ADD
, R0
, R8
),
1232 BPF_ALU32_REG(BPF_ADD
, R0
, R9
), /* R0 == 155 */
1233 BPF_JMP_IMM(BPF_JEQ
, R0
, 155, 1),
1235 BPF_ALU32_REG(BPF_ADD
, R1
, R0
),
1236 BPF_ALU32_REG(BPF_ADD
, R1
, R1
),
1237 BPF_ALU32_REG(BPF_ADD
, R1
, R2
),
1238 BPF_ALU32_REG(BPF_ADD
, R1
, R3
),
1239 BPF_ALU32_REG(BPF_ADD
, R1
, R4
),
1240 BPF_ALU32_REG(BPF_ADD
, R1
, R5
),
1241 BPF_ALU32_REG(BPF_ADD
, R1
, R6
),
1242 BPF_ALU32_REG(BPF_ADD
, R1
, R7
),
1243 BPF_ALU32_REG(BPF_ADD
, R1
, R8
),
1244 BPF_ALU32_REG(BPF_ADD
, R1
, R9
), /* R1 == 456 */
1245 BPF_JMP_IMM(BPF_JEQ
, R1
, 456, 1),
1247 BPF_ALU32_REG(BPF_ADD
, R2
, R0
),
1248 BPF_ALU32_REG(BPF_ADD
, R2
, R1
),
1249 BPF_ALU32_REG(BPF_ADD
, R2
, R2
),
1250 BPF_ALU32_REG(BPF_ADD
, R2
, R3
),
1251 BPF_ALU32_REG(BPF_ADD
, R2
, R4
),
1252 BPF_ALU32_REG(BPF_ADD
, R2
, R5
),
1253 BPF_ALU32_REG(BPF_ADD
, R2
, R6
),
1254 BPF_ALU32_REG(BPF_ADD
, R2
, R7
),
1255 BPF_ALU32_REG(BPF_ADD
, R2
, R8
),
1256 BPF_ALU32_REG(BPF_ADD
, R2
, R9
), /* R2 == 1358 */
1257 BPF_JMP_IMM(BPF_JEQ
, R2
, 1358, 1),
1259 BPF_ALU32_REG(BPF_ADD
, R3
, R0
),
1260 BPF_ALU32_REG(BPF_ADD
, R3
, R1
),
1261 BPF_ALU32_REG(BPF_ADD
, R3
, R2
),
1262 BPF_ALU32_REG(BPF_ADD
, R3
, R3
),
1263 BPF_ALU32_REG(BPF_ADD
, R3
, R4
),
1264 BPF_ALU32_REG(BPF_ADD
, R3
, R5
),
1265 BPF_ALU32_REG(BPF_ADD
, R3
, R6
),
1266 BPF_ALU32_REG(BPF_ADD
, R3
, R7
),
1267 BPF_ALU32_REG(BPF_ADD
, R3
, R8
),
1268 BPF_ALU32_REG(BPF_ADD
, R3
, R9
), /* R3 == 4063 */
1269 BPF_JMP_IMM(BPF_JEQ
, R3
, 4063, 1),
1271 BPF_ALU32_REG(BPF_ADD
, R4
, R0
),
1272 BPF_ALU32_REG(BPF_ADD
, R4
, R1
),
1273 BPF_ALU32_REG(BPF_ADD
, R4
, R2
),
1274 BPF_ALU32_REG(BPF_ADD
, R4
, R3
),
1275 BPF_ALU32_REG(BPF_ADD
, R4
, R4
),
1276 BPF_ALU32_REG(BPF_ADD
, R4
, R5
),
1277 BPF_ALU32_REG(BPF_ADD
, R4
, R6
),
1278 BPF_ALU32_REG(BPF_ADD
, R4
, R7
),
1279 BPF_ALU32_REG(BPF_ADD
, R4
, R8
),
1280 BPF_ALU32_REG(BPF_ADD
, R4
, R9
), /* R4 == 12177 */
1281 BPF_JMP_IMM(BPF_JEQ
, R4
, 12177, 1),
1283 BPF_ALU32_REG(BPF_ADD
, R5
, R0
),
1284 BPF_ALU32_REG(BPF_ADD
, R5
, R1
),
1285 BPF_ALU32_REG(BPF_ADD
, R5
, R2
),
1286 BPF_ALU32_REG(BPF_ADD
, R5
, R3
),
1287 BPF_ALU32_REG(BPF_ADD
, R5
, R4
),
1288 BPF_ALU32_REG(BPF_ADD
, R5
, R5
),
1289 BPF_ALU32_REG(BPF_ADD
, R5
, R6
),
1290 BPF_ALU32_REG(BPF_ADD
, R5
, R7
),
1291 BPF_ALU32_REG(BPF_ADD
, R5
, R8
),
1292 BPF_ALU32_REG(BPF_ADD
, R5
, R9
), /* R5 == 36518 */
1293 BPF_JMP_IMM(BPF_JEQ
, R5
, 36518, 1),
1295 BPF_ALU32_REG(BPF_ADD
, R6
, R0
),
1296 BPF_ALU32_REG(BPF_ADD
, R6
, R1
),
1297 BPF_ALU32_REG(BPF_ADD
, R6
, R2
),
1298 BPF_ALU32_REG(BPF_ADD
, R6
, R3
),
1299 BPF_ALU32_REG(BPF_ADD
, R6
, R4
),
1300 BPF_ALU32_REG(BPF_ADD
, R6
, R5
),
1301 BPF_ALU32_REG(BPF_ADD
, R6
, R6
),
1302 BPF_ALU32_REG(BPF_ADD
, R6
, R7
),
1303 BPF_ALU32_REG(BPF_ADD
, R6
, R8
),
1304 BPF_ALU32_REG(BPF_ADD
, R6
, R9
), /* R6 == 109540 */
1305 BPF_JMP_IMM(BPF_JEQ
, R6
, 109540, 1),
1307 BPF_ALU32_REG(BPF_ADD
, R7
, R0
),
1308 BPF_ALU32_REG(BPF_ADD
, R7
, R1
),
1309 BPF_ALU32_REG(BPF_ADD
, R7
, R2
),
1310 BPF_ALU32_REG(BPF_ADD
, R7
, R3
),
1311 BPF_ALU32_REG(BPF_ADD
, R7
, R4
),
1312 BPF_ALU32_REG(BPF_ADD
, R7
, R5
),
1313 BPF_ALU32_REG(BPF_ADD
, R7
, R6
),
1314 BPF_ALU32_REG(BPF_ADD
, R7
, R7
),
1315 BPF_ALU32_REG(BPF_ADD
, R7
, R8
),
1316 BPF_ALU32_REG(BPF_ADD
, R7
, R9
), /* R7 == 328605 */
1317 BPF_JMP_IMM(BPF_JEQ
, R7
, 328605, 1),
1319 BPF_ALU32_REG(BPF_ADD
, R8
, R0
),
1320 BPF_ALU32_REG(BPF_ADD
, R8
, R1
),
1321 BPF_ALU32_REG(BPF_ADD
, R8
, R2
),
1322 BPF_ALU32_REG(BPF_ADD
, R8
, R3
),
1323 BPF_ALU32_REG(BPF_ADD
, R8
, R4
),
1324 BPF_ALU32_REG(BPF_ADD
, R8
, R5
),
1325 BPF_ALU32_REG(BPF_ADD
, R8
, R6
),
1326 BPF_ALU32_REG(BPF_ADD
, R8
, R7
),
1327 BPF_ALU32_REG(BPF_ADD
, R8
, R8
),
1328 BPF_ALU32_REG(BPF_ADD
, R8
, R9
), /* R8 == 985799 */
1329 BPF_JMP_IMM(BPF_JEQ
, R8
, 985799, 1),
1331 BPF_ALU32_REG(BPF_ADD
, R9
, R0
),
1332 BPF_ALU32_REG(BPF_ADD
, R9
, R1
),
1333 BPF_ALU32_REG(BPF_ADD
, R9
, R2
),
1334 BPF_ALU32_REG(BPF_ADD
, R9
, R3
),
1335 BPF_ALU32_REG(BPF_ADD
, R9
, R4
),
1336 BPF_ALU32_REG(BPF_ADD
, R9
, R5
),
1337 BPF_ALU32_REG(BPF_ADD
, R9
, R6
),
1338 BPF_ALU32_REG(BPF_ADD
, R9
, R7
),
1339 BPF_ALU32_REG(BPF_ADD
, R9
, R8
),
1340 BPF_ALU32_REG(BPF_ADD
, R9
, R9
), /* R9 == 2957380 */
1341 BPF_ALU32_REG(BPF_MOV
, R0
, R9
),
1348 { /* Mainly checking JIT here. */
1351 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
1352 BPF_ALU64_IMM(BPF_MOV
, R1
, 1),
1353 BPF_ALU64_IMM(BPF_MOV
, R2
, 2),
1354 BPF_ALU64_IMM(BPF_MOV
, R3
, 3),
1355 BPF_ALU64_IMM(BPF_MOV
, R4
, 4),
1356 BPF_ALU64_IMM(BPF_MOV
, R5
, 5),
1357 BPF_ALU64_IMM(BPF_MOV
, R6
, 6),
1358 BPF_ALU64_IMM(BPF_MOV
, R7
, 7),
1359 BPF_ALU64_IMM(BPF_MOV
, R8
, 8),
1360 BPF_ALU64_IMM(BPF_MOV
, R9
, 9),
1361 BPF_ALU64_REG(BPF_SUB
, R0
, R0
),
1362 BPF_ALU64_REG(BPF_SUB
, R0
, R1
),
1363 BPF_ALU64_REG(BPF_SUB
, R0
, R2
),
1364 BPF_ALU64_REG(BPF_SUB
, R0
, R3
),
1365 BPF_ALU64_REG(BPF_SUB
, R0
, R4
),
1366 BPF_ALU64_REG(BPF_SUB
, R0
, R5
),
1367 BPF_ALU64_REG(BPF_SUB
, R0
, R6
),
1368 BPF_ALU64_REG(BPF_SUB
, R0
, R7
),
1369 BPF_ALU64_REG(BPF_SUB
, R0
, R8
),
1370 BPF_ALU64_REG(BPF_SUB
, R0
, R9
),
1371 BPF_ALU64_IMM(BPF_SUB
, R0
, 10),
1372 BPF_JMP_IMM(BPF_JEQ
, R0
, -55, 1),
1374 BPF_ALU64_REG(BPF_SUB
, R1
, R0
),
1375 BPF_ALU64_REG(BPF_SUB
, R1
, R2
),
1376 BPF_ALU64_REG(BPF_SUB
, R1
, R3
),
1377 BPF_ALU64_REG(BPF_SUB
, R1
, R4
),
1378 BPF_ALU64_REG(BPF_SUB
, R1
, R5
),
1379 BPF_ALU64_REG(BPF_SUB
, R1
, R6
),
1380 BPF_ALU64_REG(BPF_SUB
, R1
, R7
),
1381 BPF_ALU64_REG(BPF_SUB
, R1
, R8
),
1382 BPF_ALU64_REG(BPF_SUB
, R1
, R9
),
1383 BPF_ALU64_IMM(BPF_SUB
, R1
, 10),
1384 BPF_ALU64_REG(BPF_SUB
, R2
, R0
),
1385 BPF_ALU64_REG(BPF_SUB
, R2
, R1
),
1386 BPF_ALU64_REG(BPF_SUB
, R2
, R3
),
1387 BPF_ALU64_REG(BPF_SUB
, R2
, R4
),
1388 BPF_ALU64_REG(BPF_SUB
, R2
, R5
),
1389 BPF_ALU64_REG(BPF_SUB
, R2
, R6
),
1390 BPF_ALU64_REG(BPF_SUB
, R2
, R7
),
1391 BPF_ALU64_REG(BPF_SUB
, R2
, R8
),
1392 BPF_ALU64_REG(BPF_SUB
, R2
, R9
),
1393 BPF_ALU64_IMM(BPF_SUB
, R2
, 10),
1394 BPF_ALU64_REG(BPF_SUB
, R3
, R0
),
1395 BPF_ALU64_REG(BPF_SUB
, R3
, R1
),
1396 BPF_ALU64_REG(BPF_SUB
, R3
, R2
),
1397 BPF_ALU64_REG(BPF_SUB
, R3
, R4
),
1398 BPF_ALU64_REG(BPF_SUB
, R3
, R5
),
1399 BPF_ALU64_REG(BPF_SUB
, R3
, R6
),
1400 BPF_ALU64_REG(BPF_SUB
, R3
, R7
),
1401 BPF_ALU64_REG(BPF_SUB
, R3
, R8
),
1402 BPF_ALU64_REG(BPF_SUB
, R3
, R9
),
1403 BPF_ALU64_IMM(BPF_SUB
, R3
, 10),
1404 BPF_ALU64_REG(BPF_SUB
, R4
, R0
),
1405 BPF_ALU64_REG(BPF_SUB
, R4
, R1
),
1406 BPF_ALU64_REG(BPF_SUB
, R4
, R2
),
1407 BPF_ALU64_REG(BPF_SUB
, R4
, R3
),
1408 BPF_ALU64_REG(BPF_SUB
, R4
, R5
),
1409 BPF_ALU64_REG(BPF_SUB
, R4
, R6
),
1410 BPF_ALU64_REG(BPF_SUB
, R4
, R7
),
1411 BPF_ALU64_REG(BPF_SUB
, R4
, R8
),
1412 BPF_ALU64_REG(BPF_SUB
, R4
, R9
),
1413 BPF_ALU64_IMM(BPF_SUB
, R4
, 10),
1414 BPF_ALU64_REG(BPF_SUB
, R5
, R0
),
1415 BPF_ALU64_REG(BPF_SUB
, R5
, R1
),
1416 BPF_ALU64_REG(BPF_SUB
, R5
, R2
),
1417 BPF_ALU64_REG(BPF_SUB
, R5
, R3
),
1418 BPF_ALU64_REG(BPF_SUB
, R5
, R4
),
1419 BPF_ALU64_REG(BPF_SUB
, R5
, R6
),
1420 BPF_ALU64_REG(BPF_SUB
, R5
, R7
),
1421 BPF_ALU64_REG(BPF_SUB
, R5
, R8
),
1422 BPF_ALU64_REG(BPF_SUB
, R5
, R9
),
1423 BPF_ALU64_IMM(BPF_SUB
, R5
, 10),
1424 BPF_ALU64_REG(BPF_SUB
, R6
, R0
),
1425 BPF_ALU64_REG(BPF_SUB
, R6
, R1
),
1426 BPF_ALU64_REG(BPF_SUB
, R6
, R2
),
1427 BPF_ALU64_REG(BPF_SUB
, R6
, R3
),
1428 BPF_ALU64_REG(BPF_SUB
, R6
, R4
),
1429 BPF_ALU64_REG(BPF_SUB
, R6
, R5
),
1430 BPF_ALU64_REG(BPF_SUB
, R6
, R7
),
1431 BPF_ALU64_REG(BPF_SUB
, R6
, R8
),
1432 BPF_ALU64_REG(BPF_SUB
, R6
, R9
),
1433 BPF_ALU64_IMM(BPF_SUB
, R6
, 10),
1434 BPF_ALU64_REG(BPF_SUB
, R7
, R0
),
1435 BPF_ALU64_REG(BPF_SUB
, R7
, R1
),
1436 BPF_ALU64_REG(BPF_SUB
, R7
, R2
),
1437 BPF_ALU64_REG(BPF_SUB
, R7
, R3
),
1438 BPF_ALU64_REG(BPF_SUB
, R7
, R4
),
1439 BPF_ALU64_REG(BPF_SUB
, R7
, R5
),
1440 BPF_ALU64_REG(BPF_SUB
, R7
, R6
),
1441 BPF_ALU64_REG(BPF_SUB
, R7
, R8
),
1442 BPF_ALU64_REG(BPF_SUB
, R7
, R9
),
1443 BPF_ALU64_IMM(BPF_SUB
, R7
, 10),
1444 BPF_ALU64_REG(BPF_SUB
, R8
, R0
),
1445 BPF_ALU64_REG(BPF_SUB
, R8
, R1
),
1446 BPF_ALU64_REG(BPF_SUB
, R8
, R2
),
1447 BPF_ALU64_REG(BPF_SUB
, R8
, R3
),
1448 BPF_ALU64_REG(BPF_SUB
, R8
, R4
),
1449 BPF_ALU64_REG(BPF_SUB
, R8
, R5
),
1450 BPF_ALU64_REG(BPF_SUB
, R8
, R6
),
1451 BPF_ALU64_REG(BPF_SUB
, R8
, R7
),
1452 BPF_ALU64_REG(BPF_SUB
, R8
, R9
),
1453 BPF_ALU64_IMM(BPF_SUB
, R8
, 10),
1454 BPF_ALU64_REG(BPF_SUB
, R9
, R0
),
1455 BPF_ALU64_REG(BPF_SUB
, R9
, R1
),
1456 BPF_ALU64_REG(BPF_SUB
, R9
, R2
),
1457 BPF_ALU64_REG(BPF_SUB
, R9
, R3
),
1458 BPF_ALU64_REG(BPF_SUB
, R9
, R4
),
1459 BPF_ALU64_REG(BPF_SUB
, R9
, R5
),
1460 BPF_ALU64_REG(BPF_SUB
, R9
, R6
),
1461 BPF_ALU64_REG(BPF_SUB
, R9
, R7
),
1462 BPF_ALU64_REG(BPF_SUB
, R9
, R8
),
1463 BPF_ALU64_IMM(BPF_SUB
, R9
, 10),
1464 BPF_ALU64_IMM(BPF_SUB
, R0
, 10),
1465 BPF_ALU64_IMM(BPF_NEG
, R0
, 0),
1466 BPF_ALU64_REG(BPF_SUB
, R0
, R1
),
1467 BPF_ALU64_REG(BPF_SUB
, R0
, R2
),
1468 BPF_ALU64_REG(BPF_SUB
, R0
, R3
),
1469 BPF_ALU64_REG(BPF_SUB
, R0
, R4
),
1470 BPF_ALU64_REG(BPF_SUB
, R0
, R5
),
1471 BPF_ALU64_REG(BPF_SUB
, R0
, R6
),
1472 BPF_ALU64_REG(BPF_SUB
, R0
, R7
),
1473 BPF_ALU64_REG(BPF_SUB
, R0
, R8
),
1474 BPF_ALU64_REG(BPF_SUB
, R0
, R9
),
1481 { /* Mainly checking JIT here. */
1484 BPF_ALU64_REG(BPF_SUB
, R0
, R0
),
1485 BPF_ALU64_REG(BPF_XOR
, R1
, R1
),
1486 BPF_JMP_REG(BPF_JEQ
, R0
, R1
, 1),
1488 BPF_ALU64_IMM(BPF_MOV
, R0
, 10),
1489 BPF_ALU64_IMM(BPF_MOV
, R1
, -1),
1490 BPF_ALU64_REG(BPF_SUB
, R1
, R1
),
1491 BPF_ALU64_REG(BPF_XOR
, R2
, R2
),
1492 BPF_JMP_REG(BPF_JEQ
, R1
, R2
, 1),
1494 BPF_ALU64_REG(BPF_SUB
, R2
, R2
),
1495 BPF_ALU64_REG(BPF_XOR
, R3
, R3
),
1496 BPF_ALU64_IMM(BPF_MOV
, R0
, 10),
1497 BPF_ALU64_IMM(BPF_MOV
, R1
, -1),
1498 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 1),
1500 BPF_ALU64_REG(BPF_SUB
, R3
, R3
),
1501 BPF_ALU64_REG(BPF_XOR
, R4
, R4
),
1502 BPF_ALU64_IMM(BPF_MOV
, R2
, 1),
1503 BPF_ALU64_IMM(BPF_MOV
, R5
, -1),
1504 BPF_JMP_REG(BPF_JEQ
, R3
, R4
, 1),
1506 BPF_ALU64_REG(BPF_SUB
, R4
, R4
),
1507 BPF_ALU64_REG(BPF_XOR
, R5
, R5
),
1508 BPF_ALU64_IMM(BPF_MOV
, R3
, 1),
1509 BPF_ALU64_IMM(BPF_MOV
, R7
, -1),
1510 BPF_JMP_REG(BPF_JEQ
, R5
, R4
, 1),
1512 BPF_ALU64_IMM(BPF_MOV
, R5
, 1),
1513 BPF_ALU64_REG(BPF_SUB
, R5
, R5
),
1514 BPF_ALU64_REG(BPF_XOR
, R6
, R6
),
1515 BPF_ALU64_IMM(BPF_MOV
, R1
, 1),
1516 BPF_ALU64_IMM(BPF_MOV
, R8
, -1),
1517 BPF_JMP_REG(BPF_JEQ
, R5
, R6
, 1),
1519 BPF_ALU64_REG(BPF_SUB
, R6
, R6
),
1520 BPF_ALU64_REG(BPF_XOR
, R7
, R7
),
1521 BPF_JMP_REG(BPF_JEQ
, R7
, R6
, 1),
1523 BPF_ALU64_REG(BPF_SUB
, R7
, R7
),
1524 BPF_ALU64_REG(BPF_XOR
, R8
, R8
),
1525 BPF_JMP_REG(BPF_JEQ
, R7
, R8
, 1),
1527 BPF_ALU64_REG(BPF_SUB
, R8
, R8
),
1528 BPF_ALU64_REG(BPF_XOR
, R9
, R9
),
1529 BPF_JMP_REG(BPF_JEQ
, R9
, R8
, 1),
1531 BPF_ALU64_REG(BPF_SUB
, R9
, R9
),
1532 BPF_ALU64_REG(BPF_XOR
, R0
, R0
),
1533 BPF_JMP_REG(BPF_JEQ
, R9
, R0
, 1),
1535 BPF_ALU64_REG(BPF_SUB
, R1
, R1
),
1536 BPF_ALU64_REG(BPF_XOR
, R0
, R0
),
1537 BPF_JMP_REG(BPF_JEQ
, R9
, R0
, 2),
1538 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
1540 BPF_ALU64_IMM(BPF_MOV
, R0
, 1),
1547 { /* Mainly checking JIT here. */
1550 BPF_ALU64_IMM(BPF_MOV
, R0
, 11),
1551 BPF_ALU64_IMM(BPF_MOV
, R1
, 1),
1552 BPF_ALU64_IMM(BPF_MOV
, R2
, 2),
1553 BPF_ALU64_IMM(BPF_MOV
, R3
, 3),
1554 BPF_ALU64_IMM(BPF_MOV
, R4
, 4),
1555 BPF_ALU64_IMM(BPF_MOV
, R5
, 5),
1556 BPF_ALU64_IMM(BPF_MOV
, R6
, 6),
1557 BPF_ALU64_IMM(BPF_MOV
, R7
, 7),
1558 BPF_ALU64_IMM(BPF_MOV
, R8
, 8),
1559 BPF_ALU64_IMM(BPF_MOV
, R9
, 9),
1560 BPF_ALU64_REG(BPF_MUL
, R0
, R0
),
1561 BPF_ALU64_REG(BPF_MUL
, R0
, R1
),
1562 BPF_ALU64_REG(BPF_MUL
, R0
, R2
),
1563 BPF_ALU64_REG(BPF_MUL
, R0
, R3
),
1564 BPF_ALU64_REG(BPF_MUL
, R0
, R4
),
1565 BPF_ALU64_REG(BPF_MUL
, R0
, R5
),
1566 BPF_ALU64_REG(BPF_MUL
, R0
, R6
),
1567 BPF_ALU64_REG(BPF_MUL
, R0
, R7
),
1568 BPF_ALU64_REG(BPF_MUL
, R0
, R8
),
1569 BPF_ALU64_REG(BPF_MUL
, R0
, R9
),
1570 BPF_ALU64_IMM(BPF_MUL
, R0
, 10),
1571 BPF_JMP_IMM(BPF_JEQ
, R0
, 439084800, 1),
1573 BPF_ALU64_REG(BPF_MUL
, R1
, R0
),
1574 BPF_ALU64_REG(BPF_MUL
, R1
, R2
),
1575 BPF_ALU64_REG(BPF_MUL
, R1
, R3
),
1576 BPF_ALU64_REG(BPF_MUL
, R1
, R4
),
1577 BPF_ALU64_REG(BPF_MUL
, R1
, R5
),
1578 BPF_ALU64_REG(BPF_MUL
, R1
, R6
),
1579 BPF_ALU64_REG(BPF_MUL
, R1
, R7
),
1580 BPF_ALU64_REG(BPF_MUL
, R1
, R8
),
1581 BPF_ALU64_REG(BPF_MUL
, R1
, R9
),
1582 BPF_ALU64_IMM(BPF_MUL
, R1
, 10),
1583 BPF_ALU64_REG(BPF_MOV
, R2
, R1
),
1584 BPF_ALU64_IMM(BPF_RSH
, R2
, 32),
1585 BPF_JMP_IMM(BPF_JEQ
, R2
, 0x5a924, 1),
1587 BPF_ALU64_IMM(BPF_LSH
, R1
, 32),
1588 BPF_ALU64_IMM(BPF_ARSH
, R1
, 32),
1589 BPF_JMP_IMM(BPF_JEQ
, R1
, 0xebb90000, 1),
1591 BPF_ALU64_REG(BPF_MUL
, R2
, R0
),
1592 BPF_ALU64_REG(BPF_MUL
, R2
, R1
),
1593 BPF_ALU64_REG(BPF_MUL
, R2
, R3
),
1594 BPF_ALU64_REG(BPF_MUL
, R2
, R4
),
1595 BPF_ALU64_REG(BPF_MUL
, R2
, R5
),
1596 BPF_ALU64_REG(BPF_MUL
, R2
, R6
),
1597 BPF_ALU64_REG(BPF_MUL
, R2
, R7
),
1598 BPF_ALU64_REG(BPF_MUL
, R2
, R8
),
1599 BPF_ALU64_REG(BPF_MUL
, R2
, R9
),
1600 BPF_ALU64_IMM(BPF_MUL
, R2
, 10),
1601 BPF_ALU64_IMM(BPF_RSH
, R2
, 32),
1602 BPF_ALU64_REG(BPF_MOV
, R0
, R2
),
1607 { { 0, 0x35d97ef2 } }
1612 BPF_ALU64_IMM(BPF_MOV
, R0
, 11),
1613 BPF_ALU64_IMM(BPF_ADD
, R0
, -1),
1614 BPF_ALU64_IMM(BPF_MOV
, R2
, 2),
1615 BPF_ALU64_IMM(BPF_XOR
, R2
, 3),
1616 BPF_ALU64_REG(BPF_DIV
, R0
, R2
),
1617 BPF_JMP_IMM(BPF_JEQ
, R0
, 10, 1),
1619 BPF_ALU64_IMM(BPF_MOD
, R0
, 3),
1620 BPF_JMP_IMM(BPF_JEQ
, R0
, 1, 1),
1622 BPF_ALU64_IMM(BPF_MOV
, R0
, -1),
1630 "INT: shifts by register",
1632 BPF_MOV64_IMM(R0
, -1234),
1633 BPF_MOV64_IMM(R1
, 1),
1634 BPF_ALU32_REG(BPF_RSH
, R0
, R1
),
1635 BPF_JMP_IMM(BPF_JEQ
, R0
, 0x7ffffd97, 1),
1637 BPF_MOV64_IMM(R2
, 1),
1638 BPF_ALU64_REG(BPF_LSH
, R0
, R2
),
1639 BPF_MOV32_IMM(R4
, -1234),
1640 BPF_JMP_REG(BPF_JEQ
, R0
, R4
, 1),
1642 BPF_ALU64_IMM(BPF_AND
, R4
, 63),
1643 BPF_ALU64_REG(BPF_LSH
, R0
, R4
), /* R0 <= 46 */
1644 BPF_MOV64_IMM(R3
, 47),
1645 BPF_ALU64_REG(BPF_ARSH
, R0
, R3
),
1646 BPF_JMP_IMM(BPF_JEQ
, R0
, -617, 1),
1648 BPF_MOV64_IMM(R2
, 1),
1649 BPF_ALU64_REG(BPF_LSH
, R4
, R2
), /* R4 = 46 << 1 */
1650 BPF_JMP_IMM(BPF_JEQ
, R4
, 92, 1),
1652 BPF_MOV64_IMM(R4
, 4),
1653 BPF_ALU64_REG(BPF_LSH
, R4
, R4
), /* R4 = 4 << 4 */
1654 BPF_JMP_IMM(BPF_JEQ
, R4
, 64, 1),
1656 BPF_MOV64_IMM(R4
, 5),
1657 BPF_ALU32_REG(BPF_LSH
, R4
, R4
), /* R4 = 5 << 5 */
1658 BPF_JMP_IMM(BPF_JEQ
, R4
, 160, 1),
1660 BPF_MOV64_IMM(R0
, -1),
1670 BPF_ALU64_REG(BPF_MOV
, R6
, R1
),
1671 BPF_LD_ABS(BPF_B
, 3),
1672 BPF_ALU64_IMM(BPF_MOV
, R2
, 2),
1673 BPF_ALU32_REG(BPF_DIV
, R0
, R2
),
1674 BPF_ALU64_REG(BPF_MOV
, R8
, R0
),
1675 BPF_LD_ABS(BPF_B
, 4),
1676 BPF_ALU64_REG(BPF_ADD
, R8
, R0
),
1677 BPF_LD_IND(BPF_B
, R8
, -70),
1681 { 10, 20, 30, 40, 50 },
1682 { { 4, 0 }, { 5, 10 } }
1687 BPF_ALU64_REG(BPF_MOV
, R6
, R1
),
1688 BPF_ALU64_IMM(BPF_MOV
, R7
, 0),
1689 BPF_LD_ABS(BPF_B
, 3),
1690 BPF_ALU32_REG(BPF_DIV
, R0
, R7
),
1694 { 10, 20, 30, 40, 50 },
1695 { { 3, 0 }, { 4, 0 } }
1698 "check: missing ret",
1700 BPF_STMT(BPF_LD
| BPF_IMM
, 1),
1702 CLASSIC
| FLAG_NO_DATA
| FLAG_EXPECTED_FAIL
,
1709 BPF_STMT(BPF_ALU
| BPF_DIV
| BPF_K
, 0),
1710 BPF_STMT(BPF_RET
| BPF_K
, 0)
1712 CLASSIC
| FLAG_NO_DATA
| FLAG_EXPECTED_FAIL
,
1717 "check: unknown insn",
1719 /* seccomp insn, rejected in socket filter */
1720 BPF_STMT(BPF_LDX
| BPF_W
| BPF_ABS
, 0),
1721 BPF_STMT(BPF_RET
| BPF_K
, 0)
1723 CLASSIC
| FLAG_EXPECTED_FAIL
,
1728 "check: out of range spill/fill",
1730 BPF_STMT(BPF_STX
, 16),
1731 BPF_STMT(BPF_RET
| BPF_K
, 0)
1733 CLASSIC
| FLAG_NO_DATA
| FLAG_EXPECTED_FAIL
,
1740 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1741 BPF_JUMP(BPF_JMP
| BPF_JGE
, 0, 13, 15),
1742 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1743 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1744 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1745 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1746 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1747 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1748 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1749 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1750 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1751 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1752 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1753 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1754 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1755 BPF_JUMP(BPF_JMP
| BPF_JEQ
, 0x90c2894d, 3, 4),
1756 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1757 BPF_JUMP(BPF_JMP
| BPF_JEQ
, 0x90c2894d, 1, 2),
1758 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1759 BPF_JUMP(BPF_JMP
| BPF_JGE
, 0, 14, 15),
1760 BPF_JUMP(BPF_JMP
| BPF_JGE
, 0, 13, 14),
1761 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1762 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1763 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1764 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1765 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1766 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1767 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1768 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1769 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1770 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1771 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1772 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1773 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1774 BPF_JUMP(BPF_JMP
| BPF_JEQ
, 0x2ac28349, 2, 3),
1775 BPF_JUMP(BPF_JMP
| BPF_JEQ
, 0x2ac28349, 1, 2),
1776 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1777 BPF_JUMP(BPF_JMP
| BPF_JGE
, 0, 14, 15),
1778 BPF_JUMP(BPF_JMP
| BPF_JGE
, 0, 13, 14),
1779 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1780 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1781 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1782 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1783 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1784 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1785 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1786 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1787 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1788 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1789 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1790 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1791 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1792 BPF_JUMP(BPF_JMP
| BPF_JEQ
, 0x90d2ff41, 2, 3),
1793 BPF_JUMP(BPF_JMP
| BPF_JEQ
, 0x90d2ff41, 1, 2),
1794 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1795 BPF_STMT(BPF_RET
| BPF_A
, 0),
1796 BPF_STMT(BPF_RET
| BPF_A
, 0),
1799 { 0x00, 0x1b, 0x21, 0x3c, 0x9d, 0xf8,
1800 0x90, 0xe2, 0xba, 0x0a, 0x56, 0xb4,
1802 0x45, 0x00, 0x00, 0x28, 0x00, 0x00,
1803 0x20, 0x00, 0x40, 0x11, 0x00, 0x00, /* IP header */
1804 0xc0, 0xa8, 0x33, 0x01,
1805 0xc0, 0xa8, 0x33, 0x02,
1808 0x00, 0x14, 0x00, 0x00,
1809 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
1810 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
1811 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
1812 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
1813 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
1814 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
1815 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
1816 0xcc, 0xcc, 0xcc, 0xcc },
1822 BPF_STMT(BPF_RET
| BPF_X
, 0),
1824 CLASSIC
| FLAG_NO_DATA
| FLAG_EXPECTED_FAIL
,
1829 "check: LDX + RET X",
1831 BPF_STMT(BPF_LDX
| BPF_IMM
, 42),
1832 BPF_STMT(BPF_RET
| BPF_X
, 0),
1834 CLASSIC
| FLAG_NO_DATA
| FLAG_EXPECTED_FAIL
,
1838 { /* Mainly checking JIT here. */
1839 "M[]: alt STX + LDX",
1841 BPF_STMT(BPF_LDX
| BPF_IMM
, 100),
1842 BPF_STMT(BPF_STX
, 0),
1843 BPF_STMT(BPF_LDX
| BPF_MEM
, 0),
1844 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
1845 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 1),
1846 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
1847 BPF_STMT(BPF_STX
, 1),
1848 BPF_STMT(BPF_LDX
| BPF_MEM
, 1),
1849 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
1850 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 1),
1851 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
1852 BPF_STMT(BPF_STX
, 2),
1853 BPF_STMT(BPF_LDX
| BPF_MEM
, 2),
1854 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
1855 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 1),
1856 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
1857 BPF_STMT(BPF_STX
, 3),
1858 BPF_STMT(BPF_LDX
| BPF_MEM
, 3),
1859 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
1860 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 1),
1861 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
1862 BPF_STMT(BPF_STX
, 4),
1863 BPF_STMT(BPF_LDX
| BPF_MEM
, 4),
1864 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
1865 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 1),
1866 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
1867 BPF_STMT(BPF_STX
, 5),
1868 BPF_STMT(BPF_LDX
| BPF_MEM
, 5),
1869 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
1870 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 1),
1871 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
1872 BPF_STMT(BPF_STX
, 6),
1873 BPF_STMT(BPF_LDX
| BPF_MEM
, 6),
1874 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
1875 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 1),
1876 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
1877 BPF_STMT(BPF_STX
, 7),
1878 BPF_STMT(BPF_LDX
| BPF_MEM
, 7),
1879 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
1880 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 1),
1881 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
1882 BPF_STMT(BPF_STX
, 8),
1883 BPF_STMT(BPF_LDX
| BPF_MEM
, 8),
1884 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
1885 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 1),
1886 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
1887 BPF_STMT(BPF_STX
, 9),
1888 BPF_STMT(BPF_LDX
| BPF_MEM
, 9),
1889 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
1890 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 1),
1891 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
1892 BPF_STMT(BPF_STX
, 10),
1893 BPF_STMT(BPF_LDX
| BPF_MEM
, 10),
1894 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
1895 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 1),
1896 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
1897 BPF_STMT(BPF_STX
, 11),
1898 BPF_STMT(BPF_LDX
| BPF_MEM
, 11),
1899 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
1900 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 1),
1901 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
1902 BPF_STMT(BPF_STX
, 12),
1903 BPF_STMT(BPF_LDX
| BPF_MEM
, 12),
1904 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
1905 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 1),
1906 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
1907 BPF_STMT(BPF_STX
, 13),
1908 BPF_STMT(BPF_LDX
| BPF_MEM
, 13),
1909 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
1910 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 1),
1911 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
1912 BPF_STMT(BPF_STX
, 14),
1913 BPF_STMT(BPF_LDX
| BPF_MEM
, 14),
1914 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
1915 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 1),
1916 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
1917 BPF_STMT(BPF_STX
, 15),
1918 BPF_STMT(BPF_LDX
| BPF_MEM
, 15),
1919 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
1920 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 1),
1921 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
1922 BPF_STMT(BPF_RET
| BPF_A
, 0),
1924 CLASSIC
| FLAG_NO_DATA
,
1928 { /* Mainly checking JIT here. */
1929 "M[]: full STX + full LDX",
1931 BPF_STMT(BPF_LDX
| BPF_IMM
, 0xbadfeedb),
1932 BPF_STMT(BPF_STX
, 0),
1933 BPF_STMT(BPF_LDX
| BPF_IMM
, 0xecabedae),
1934 BPF_STMT(BPF_STX
, 1),
1935 BPF_STMT(BPF_LDX
| BPF_IMM
, 0xafccfeaf),
1936 BPF_STMT(BPF_STX
, 2),
1937 BPF_STMT(BPF_LDX
| BPF_IMM
, 0xbffdcedc),
1938 BPF_STMT(BPF_STX
, 3),
1939 BPF_STMT(BPF_LDX
| BPF_IMM
, 0xfbbbdccb),
1940 BPF_STMT(BPF_STX
, 4),
1941 BPF_STMT(BPF_LDX
| BPF_IMM
, 0xfbabcbda),
1942 BPF_STMT(BPF_STX
, 5),
1943 BPF_STMT(BPF_LDX
| BPF_IMM
, 0xaedecbdb),
1944 BPF_STMT(BPF_STX
, 6),
1945 BPF_STMT(BPF_LDX
| BPF_IMM
, 0xadebbade),
1946 BPF_STMT(BPF_STX
, 7),
1947 BPF_STMT(BPF_LDX
| BPF_IMM
, 0xfcfcfaec),
1948 BPF_STMT(BPF_STX
, 8),
1949 BPF_STMT(BPF_LDX
| BPF_IMM
, 0xbcdddbdc),
1950 BPF_STMT(BPF_STX
, 9),
1951 BPF_STMT(BPF_LDX
| BPF_IMM
, 0xfeefdfac),
1952 BPF_STMT(BPF_STX
, 10),
1953 BPF_STMT(BPF_LDX
| BPF_IMM
, 0xcddcdeea),
1954 BPF_STMT(BPF_STX
, 11),
1955 BPF_STMT(BPF_LDX
| BPF_IMM
, 0xaccfaebb),
1956 BPF_STMT(BPF_STX
, 12),
1957 BPF_STMT(BPF_LDX
| BPF_IMM
, 0xbdcccdcf),
1958 BPF_STMT(BPF_STX
, 13),
1959 BPF_STMT(BPF_LDX
| BPF_IMM
, 0xaaedecde),
1960 BPF_STMT(BPF_STX
, 14),
1961 BPF_STMT(BPF_LDX
| BPF_IMM
, 0xfaeacdad),
1962 BPF_STMT(BPF_STX
, 15),
1963 BPF_STMT(BPF_LDX
| BPF_MEM
, 0),
1964 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
1965 BPF_STMT(BPF_LDX
| BPF_MEM
, 1),
1966 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
1967 BPF_STMT(BPF_LDX
| BPF_MEM
, 2),
1968 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
1969 BPF_STMT(BPF_LDX
| BPF_MEM
, 3),
1970 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
1971 BPF_STMT(BPF_LDX
| BPF_MEM
, 4),
1972 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
1973 BPF_STMT(BPF_LDX
| BPF_MEM
, 5),
1974 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
1975 BPF_STMT(BPF_LDX
| BPF_MEM
, 6),
1976 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
1977 BPF_STMT(BPF_LDX
| BPF_MEM
, 7),
1978 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
1979 BPF_STMT(BPF_LDX
| BPF_MEM
, 8),
1980 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
1981 BPF_STMT(BPF_LDX
| BPF_MEM
, 9),
1982 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
1983 BPF_STMT(BPF_LDX
| BPF_MEM
, 10),
1984 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
1985 BPF_STMT(BPF_LDX
| BPF_MEM
, 11),
1986 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
1987 BPF_STMT(BPF_LDX
| BPF_MEM
, 12),
1988 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
1989 BPF_STMT(BPF_LDX
| BPF_MEM
, 13),
1990 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
1991 BPF_STMT(BPF_LDX
| BPF_MEM
, 14),
1992 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
1993 BPF_STMT(BPF_LDX
| BPF_MEM
, 15),
1994 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
1995 BPF_STMT(BPF_RET
| BPF_A
, 0),
1997 CLASSIC
| FLAG_NO_DATA
,
1999 { { 0, 0x2a5a5e5 } },
2002 "check: SKF_AD_MAX",
2004 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
2005 SKF_AD_OFF
+ SKF_AD_MAX
),
2006 BPF_STMT(BPF_RET
| BPF_A
, 0),
2008 CLASSIC
| FLAG_NO_DATA
| FLAG_EXPECTED_FAIL
,
2012 { /* Passes checker but fails during runtime. */
2013 "LD [SKF_AD_OFF-1]",
2015 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
2017 BPF_STMT(BPF_RET
| BPF_K
, 1),
2024 "load 64-bit immediate",
2026 BPF_LD_IMM64(R1
, 0x567800001234LL
),
2027 BPF_MOV64_REG(R2
, R1
),
2028 BPF_MOV64_REG(R3
, R2
),
2029 BPF_ALU64_IMM(BPF_RSH
, R2
, 32),
2030 BPF_ALU64_IMM(BPF_LSH
, R3
, 32),
2031 BPF_ALU64_IMM(BPF_RSH
, R3
, 32),
2032 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
2033 BPF_JMP_IMM(BPF_JEQ
, R2
, 0x5678, 1),
2035 BPF_JMP_IMM(BPF_JEQ
, R3
, 0x1234, 1),
2037 BPF_LD_IMM64(R0
, 0x1ffffffffLL
),
2038 BPF_ALU64_IMM(BPF_RSH
, R0
, 32), /* R0 = 1 */
2048 BPF_MOV64_REG(R6
, R1
),
2049 BPF_LD_ABS(BPF_H
, 12),
2050 BPF_JMP_IMM(BPF_JNE
, R0
, 0x806, 28),
2051 BPF_LD_ABS(BPF_H
, 12),
2052 BPF_JMP_IMM(BPF_JNE
, R0
, 0x806, 26),
2053 BPF_MOV32_IMM(R0
, 18),
2054 BPF_STX_MEM(BPF_W
, R10
, R0
, -64),
2055 BPF_LDX_MEM(BPF_W
, R7
, R10
, -64),
2056 BPF_LD_IND(BPF_W
, R7
, 14),
2057 BPF_STX_MEM(BPF_W
, R10
, R0
, -60),
2058 BPF_MOV32_IMM(R0
, 280971478),
2059 BPF_STX_MEM(BPF_W
, R10
, R0
, -56),
2060 BPF_LDX_MEM(BPF_W
, R7
, R10
, -56),
2061 BPF_LDX_MEM(BPF_W
, R0
, R10
, -60),
2062 BPF_ALU32_REG(BPF_SUB
, R0
, R7
),
2063 BPF_JMP_IMM(BPF_JNE
, R0
, 0, 15),
2064 BPF_LD_ABS(BPF_H
, 12),
2065 BPF_JMP_IMM(BPF_JNE
, R0
, 0x806, 13),
2066 BPF_MOV32_IMM(R0
, 22),
2067 BPF_STX_MEM(BPF_W
, R10
, R0
, -56),
2068 BPF_LDX_MEM(BPF_W
, R7
, R10
, -56),
2069 BPF_LD_IND(BPF_H
, R7
, 14),
2070 BPF_STX_MEM(BPF_W
, R10
, R0
, -52),
2071 BPF_MOV32_IMM(R0
, 17366),
2072 BPF_STX_MEM(BPF_W
, R10
, R0
, -48),
2073 BPF_LDX_MEM(BPF_W
, R7
, R10
, -48),
2074 BPF_LDX_MEM(BPF_W
, R0
, R10
, -52),
2075 BPF_ALU32_REG(BPF_SUB
, R0
, R7
),
2076 BPF_JMP_IMM(BPF_JNE
, R0
, 0, 2),
2077 BPF_MOV32_IMM(R0
, 256),
2079 BPF_MOV32_IMM(R0
, 0),
2083 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x08, 0x06, 0, 0,
2084 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2085 0x10, 0xbf, 0x48, 0xd6, 0x43, 0xd6},
2088 /* BPF_ALU | BPF_MOV | BPF_X */
2090 "ALU_MOV_X: dst = 2",
2092 BPF_ALU32_IMM(BPF_MOV
, R1
, 2),
2093 BPF_ALU32_REG(BPF_MOV
, R0
, R1
),
2101 "ALU_MOV_X: dst = 4294967295",
2103 BPF_ALU32_IMM(BPF_MOV
, R1
, 4294967295U),
2104 BPF_ALU32_REG(BPF_MOV
, R0
, R1
),
2109 { { 0, 4294967295U } },
2112 "ALU64_MOV_X: dst = 2",
2114 BPF_ALU32_IMM(BPF_MOV
, R1
, 2),
2115 BPF_ALU64_REG(BPF_MOV
, R0
, R1
),
2123 "ALU64_MOV_X: dst = 4294967295",
2125 BPF_ALU32_IMM(BPF_MOV
, R1
, 4294967295U),
2126 BPF_ALU64_REG(BPF_MOV
, R0
, R1
),
2131 { { 0, 4294967295U } },
2133 /* BPF_ALU | BPF_MOV | BPF_K */
2135 "ALU_MOV_K: dst = 2",
2137 BPF_ALU32_IMM(BPF_MOV
, R0
, 2),
2145 "ALU_MOV_K: dst = 4294967295",
2147 BPF_ALU32_IMM(BPF_MOV
, R0
, 4294967295U),
2152 { { 0, 4294967295U } },
2155 "ALU_MOV_K: 0x0000ffffffff0000 = 0x00000000ffffffff",
2157 BPF_LD_IMM64(R2
, 0x0000ffffffff0000LL
),
2158 BPF_LD_IMM64(R3
, 0x00000000ffffffffLL
),
2159 BPF_ALU32_IMM(BPF_MOV
, R2
, 0xffffffff),
2160 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
2161 BPF_MOV32_IMM(R0
, 2),
2163 BPF_MOV32_IMM(R0
, 1),
2171 "ALU64_MOV_K: dst = 2",
2173 BPF_ALU64_IMM(BPF_MOV
, R0
, 2),
2181 "ALU64_MOV_K: dst = 2147483647",
2183 BPF_ALU64_IMM(BPF_MOV
, R0
, 2147483647),
2188 { { 0, 2147483647 } },
2191 "ALU64_OR_K: dst = 0x0",
2193 BPF_LD_IMM64(R2
, 0x0000ffffffff0000LL
),
2194 BPF_LD_IMM64(R3
, 0x0),
2195 BPF_ALU64_IMM(BPF_MOV
, R2
, 0x0),
2196 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
2197 BPF_MOV32_IMM(R0
, 2),
2199 BPF_MOV32_IMM(R0
, 1),
2207 "ALU64_MOV_K: dst = -1",
2209 BPF_LD_IMM64(R2
, 0x0000ffffffff0000LL
),
2210 BPF_LD_IMM64(R3
, 0xffffffffffffffffLL
),
2211 BPF_ALU64_IMM(BPF_MOV
, R2
, 0xffffffff),
2212 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
2213 BPF_MOV32_IMM(R0
, 2),
2215 BPF_MOV32_IMM(R0
, 1),
2222 /* BPF_ALU | BPF_ADD | BPF_X */
2224 "ALU_ADD_X: 1 + 2 = 3",
2226 BPF_LD_IMM64(R0
, 1),
2227 BPF_ALU32_IMM(BPF_MOV
, R1
, 2),
2228 BPF_ALU32_REG(BPF_ADD
, R0
, R1
),
2236 "ALU_ADD_X: 1 + 4294967294 = 4294967295",
2238 BPF_LD_IMM64(R0
, 1),
2239 BPF_ALU32_IMM(BPF_MOV
, R1
, 4294967294U),
2240 BPF_ALU32_REG(BPF_ADD
, R0
, R1
),
2245 { { 0, 4294967295U } },
2248 "ALU64_ADD_X: 1 + 2 = 3",
2250 BPF_LD_IMM64(R0
, 1),
2251 BPF_ALU32_IMM(BPF_MOV
, R1
, 2),
2252 BPF_ALU64_REG(BPF_ADD
, R0
, R1
),
2260 "ALU64_ADD_X: 1 + 4294967294 = 4294967295",
2262 BPF_LD_IMM64(R0
, 1),
2263 BPF_ALU32_IMM(BPF_MOV
, R1
, 4294967294U),
2264 BPF_ALU64_REG(BPF_ADD
, R0
, R1
),
2269 { { 0, 4294967295U } },
2271 /* BPF_ALU | BPF_ADD | BPF_K */
2273 "ALU_ADD_K: 1 + 2 = 3",
2275 BPF_LD_IMM64(R0
, 1),
2276 BPF_ALU32_IMM(BPF_ADD
, R0
, 2),
2284 "ALU_ADD_K: 3 + 0 = 3",
2286 BPF_LD_IMM64(R0
, 3),
2287 BPF_ALU32_IMM(BPF_ADD
, R0
, 0),
2295 "ALU_ADD_K: 1 + 4294967294 = 4294967295",
2297 BPF_LD_IMM64(R0
, 1),
2298 BPF_ALU32_IMM(BPF_ADD
, R0
, 4294967294U),
2303 { { 0, 4294967295U } },
2306 "ALU_ADD_K: 0 + (-1) = 0x00000000ffffffff",
2308 BPF_LD_IMM64(R2
, 0x0),
2309 BPF_LD_IMM64(R3
, 0x00000000ffffffff),
2310 BPF_ALU32_IMM(BPF_ADD
, R2
, 0xffffffff),
2311 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
2312 BPF_MOV32_IMM(R0
, 2),
2314 BPF_MOV32_IMM(R0
, 1),
2322 "ALU64_ADD_K: 1 + 2 = 3",
2324 BPF_LD_IMM64(R0
, 1),
2325 BPF_ALU64_IMM(BPF_ADD
, R0
, 2),
2333 "ALU64_ADD_K: 3 + 0 = 3",
2335 BPF_LD_IMM64(R0
, 3),
2336 BPF_ALU64_IMM(BPF_ADD
, R0
, 0),
2344 "ALU64_ADD_K: 1 + 2147483646 = 2147483647",
2346 BPF_LD_IMM64(R0
, 1),
2347 BPF_ALU64_IMM(BPF_ADD
, R0
, 2147483646),
2352 { { 0, 2147483647 } },
2355 "ALU64_ADD_K: 2147483646 + -2147483647 = -1",
2357 BPF_LD_IMM64(R0
, 2147483646),
2358 BPF_ALU64_IMM(BPF_ADD
, R0
, -2147483647),
2366 "ALU64_ADD_K: 1 + 0 = 1",
2368 BPF_LD_IMM64(R2
, 0x1),
2369 BPF_LD_IMM64(R3
, 0x1),
2370 BPF_ALU64_IMM(BPF_ADD
, R2
, 0x0),
2371 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
2372 BPF_MOV32_IMM(R0
, 2),
2374 BPF_MOV32_IMM(R0
, 1),
2382 "ALU64_ADD_K: 0 + (-1) = 0xffffffffffffffff",
2384 BPF_LD_IMM64(R2
, 0x0),
2385 BPF_LD_IMM64(R3
, 0xffffffffffffffffLL
),
2386 BPF_ALU64_IMM(BPF_ADD
, R2
, 0xffffffff),
2387 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
2388 BPF_MOV32_IMM(R0
, 2),
2390 BPF_MOV32_IMM(R0
, 1),
2397 /* BPF_ALU | BPF_SUB | BPF_X */
2399 "ALU_SUB_X: 3 - 1 = 2",
2401 BPF_LD_IMM64(R0
, 3),
2402 BPF_ALU32_IMM(BPF_MOV
, R1
, 1),
2403 BPF_ALU32_REG(BPF_SUB
, R0
, R1
),
2411 "ALU_SUB_X: 4294967295 - 4294967294 = 1",
2413 BPF_LD_IMM64(R0
, 4294967295U),
2414 BPF_ALU32_IMM(BPF_MOV
, R1
, 4294967294U),
2415 BPF_ALU32_REG(BPF_SUB
, R0
, R1
),
2423 "ALU64_SUB_X: 3 - 1 = 2",
2425 BPF_LD_IMM64(R0
, 3),
2426 BPF_ALU32_IMM(BPF_MOV
, R1
, 1),
2427 BPF_ALU64_REG(BPF_SUB
, R0
, R1
),
2435 "ALU64_SUB_X: 4294967295 - 4294967294 = 1",
2437 BPF_LD_IMM64(R0
, 4294967295U),
2438 BPF_ALU32_IMM(BPF_MOV
, R1
, 4294967294U),
2439 BPF_ALU64_REG(BPF_SUB
, R0
, R1
),
2446 /* BPF_ALU | BPF_SUB | BPF_K */
2448 "ALU_SUB_K: 3 - 1 = 2",
2450 BPF_LD_IMM64(R0
, 3),
2451 BPF_ALU32_IMM(BPF_SUB
, R0
, 1),
2459 "ALU_SUB_K: 3 - 0 = 3",
2461 BPF_LD_IMM64(R0
, 3),
2462 BPF_ALU32_IMM(BPF_SUB
, R0
, 0),
2470 "ALU_SUB_K: 4294967295 - 4294967294 = 1",
2472 BPF_LD_IMM64(R0
, 4294967295U),
2473 BPF_ALU32_IMM(BPF_SUB
, R0
, 4294967294U),
2481 "ALU64_SUB_K: 3 - 1 = 2",
2483 BPF_LD_IMM64(R0
, 3),
2484 BPF_ALU64_IMM(BPF_SUB
, R0
, 1),
2492 "ALU64_SUB_K: 3 - 0 = 3",
2494 BPF_LD_IMM64(R0
, 3),
2495 BPF_ALU64_IMM(BPF_SUB
, R0
, 0),
2503 "ALU64_SUB_K: 4294967294 - 4294967295 = -1",
2505 BPF_LD_IMM64(R0
, 4294967294U),
2506 BPF_ALU64_IMM(BPF_SUB
, R0
, 4294967295U),
2514 "ALU64_ADD_K: 2147483646 - 2147483647 = -1",
2516 BPF_LD_IMM64(R0
, 2147483646),
2517 BPF_ALU64_IMM(BPF_SUB
, R0
, 2147483647),
2524 /* BPF_ALU | BPF_MUL | BPF_X */
2526 "ALU_MUL_X: 2 * 3 = 6",
2528 BPF_LD_IMM64(R0
, 2),
2529 BPF_ALU32_IMM(BPF_MOV
, R1
, 3),
2530 BPF_ALU32_REG(BPF_MUL
, R0
, R1
),
2538 "ALU_MUL_X: 2 * 0x7FFFFFF8 = 0xFFFFFFF0",
2540 BPF_LD_IMM64(R0
, 2),
2541 BPF_ALU32_IMM(BPF_MOV
, R1
, 0x7FFFFFF8),
2542 BPF_ALU32_REG(BPF_MUL
, R0
, R1
),
2547 { { 0, 0xFFFFFFF0 } },
2550 "ALU_MUL_X: -1 * -1 = 1",
2552 BPF_LD_IMM64(R0
, -1),
2553 BPF_ALU32_IMM(BPF_MOV
, R1
, -1),
2554 BPF_ALU32_REG(BPF_MUL
, R0
, R1
),
2562 "ALU64_MUL_X: 2 * 3 = 6",
2564 BPF_LD_IMM64(R0
, 2),
2565 BPF_ALU32_IMM(BPF_MOV
, R1
, 3),
2566 BPF_ALU64_REG(BPF_MUL
, R0
, R1
),
2574 "ALU64_MUL_X: 1 * 2147483647 = 2147483647",
2576 BPF_LD_IMM64(R0
, 1),
2577 BPF_ALU32_IMM(BPF_MOV
, R1
, 2147483647),
2578 BPF_ALU64_REG(BPF_MUL
, R0
, R1
),
2583 { { 0, 2147483647 } },
2585 /* BPF_ALU | BPF_MUL | BPF_K */
2587 "ALU_MUL_K: 2 * 3 = 6",
2589 BPF_LD_IMM64(R0
, 2),
2590 BPF_ALU32_IMM(BPF_MUL
, R0
, 3),
2598 "ALU_MUL_K: 3 * 1 = 3",
2600 BPF_LD_IMM64(R0
, 3),
2601 BPF_ALU32_IMM(BPF_MUL
, R0
, 1),
2609 "ALU_MUL_K: 2 * 0x7FFFFFF8 = 0xFFFFFFF0",
2611 BPF_LD_IMM64(R0
, 2),
2612 BPF_ALU32_IMM(BPF_MUL
, R0
, 0x7FFFFFF8),
2617 { { 0, 0xFFFFFFF0 } },
2620 "ALU_MUL_K: 1 * (-1) = 0x00000000ffffffff",
2622 BPF_LD_IMM64(R2
, 0x1),
2623 BPF_LD_IMM64(R3
, 0x00000000ffffffff),
2624 BPF_ALU32_IMM(BPF_MUL
, R2
, 0xffffffff),
2625 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
2626 BPF_MOV32_IMM(R0
, 2),
2628 BPF_MOV32_IMM(R0
, 1),
2636 "ALU64_MUL_K: 2 * 3 = 6",
2638 BPF_LD_IMM64(R0
, 2),
2639 BPF_ALU64_IMM(BPF_MUL
, R0
, 3),
2647 "ALU64_MUL_K: 3 * 1 = 3",
2649 BPF_LD_IMM64(R0
, 3),
2650 BPF_ALU64_IMM(BPF_MUL
, R0
, 1),
2658 "ALU64_MUL_K: 1 * 2147483647 = 2147483647",
2660 BPF_LD_IMM64(R0
, 1),
2661 BPF_ALU64_IMM(BPF_MUL
, R0
, 2147483647),
2666 { { 0, 2147483647 } },
2669 "ALU64_MUL_K: 1 * -2147483647 = -2147483647",
2671 BPF_LD_IMM64(R0
, 1),
2672 BPF_ALU64_IMM(BPF_MUL
, R0
, -2147483647),
2677 { { 0, -2147483647 } },
2680 "ALU64_MUL_K: 1 * (-1) = 0xffffffffffffffff",
2682 BPF_LD_IMM64(R2
, 0x1),
2683 BPF_LD_IMM64(R3
, 0xffffffffffffffffLL
),
2684 BPF_ALU64_IMM(BPF_MUL
, R2
, 0xffffffff),
2685 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
2686 BPF_MOV32_IMM(R0
, 2),
2688 BPF_MOV32_IMM(R0
, 1),
2695 /* BPF_ALU | BPF_DIV | BPF_X */
2697 "ALU_DIV_X: 6 / 2 = 3",
2699 BPF_LD_IMM64(R0
, 6),
2700 BPF_ALU32_IMM(BPF_MOV
, R1
, 2),
2701 BPF_ALU32_REG(BPF_DIV
, R0
, R1
),
2709 "ALU_DIV_X: 4294967295 / 4294967295 = 1",
2711 BPF_LD_IMM64(R0
, 4294967295U),
2712 BPF_ALU32_IMM(BPF_MOV
, R1
, 4294967295U),
2713 BPF_ALU32_REG(BPF_DIV
, R0
, R1
),
2721 "ALU64_DIV_X: 6 / 2 = 3",
2723 BPF_LD_IMM64(R0
, 6),
2724 BPF_ALU32_IMM(BPF_MOV
, R1
, 2),
2725 BPF_ALU64_REG(BPF_DIV
, R0
, R1
),
2733 "ALU64_DIV_X: 2147483647 / 2147483647 = 1",
2735 BPF_LD_IMM64(R0
, 2147483647),
2736 BPF_ALU32_IMM(BPF_MOV
, R1
, 2147483647),
2737 BPF_ALU64_REG(BPF_DIV
, R0
, R1
),
2745 "ALU64_DIV_X: 0xffffffffffffffff / (-1) = 0x0000000000000001",
2747 BPF_LD_IMM64(R2
, 0xffffffffffffffffLL
),
2748 BPF_LD_IMM64(R4
, 0xffffffffffffffffLL
),
2749 BPF_LD_IMM64(R3
, 0x0000000000000001LL
),
2750 BPF_ALU64_REG(BPF_DIV
, R2
, R4
),
2751 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
2752 BPF_MOV32_IMM(R0
, 2),
2754 BPF_MOV32_IMM(R0
, 1),
2761 /* BPF_ALU | BPF_DIV | BPF_K */
2763 "ALU_DIV_K: 6 / 2 = 3",
2765 BPF_LD_IMM64(R0
, 6),
2766 BPF_ALU32_IMM(BPF_DIV
, R0
, 2),
2774 "ALU_DIV_K: 3 / 1 = 3",
2776 BPF_LD_IMM64(R0
, 3),
2777 BPF_ALU32_IMM(BPF_DIV
, R0
, 1),
2785 "ALU_DIV_K: 4294967295 / 4294967295 = 1",
2787 BPF_LD_IMM64(R0
, 4294967295U),
2788 BPF_ALU32_IMM(BPF_DIV
, R0
, 4294967295U),
2796 "ALU_DIV_K: 0xffffffffffffffff / (-1) = 0x1",
2798 BPF_LD_IMM64(R2
, 0xffffffffffffffffLL
),
2799 BPF_LD_IMM64(R3
, 0x1UL
),
2800 BPF_ALU32_IMM(BPF_DIV
, R2
, 0xffffffff),
2801 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
2802 BPF_MOV32_IMM(R0
, 2),
2804 BPF_MOV32_IMM(R0
, 1),
2812 "ALU64_DIV_K: 6 / 2 = 3",
2814 BPF_LD_IMM64(R0
, 6),
2815 BPF_ALU64_IMM(BPF_DIV
, R0
, 2),
2823 "ALU64_DIV_K: 3 / 1 = 3",
2825 BPF_LD_IMM64(R0
, 3),
2826 BPF_ALU64_IMM(BPF_DIV
, R0
, 1),
2834 "ALU64_DIV_K: 2147483647 / 2147483647 = 1",
2836 BPF_LD_IMM64(R0
, 2147483647),
2837 BPF_ALU64_IMM(BPF_DIV
, R0
, 2147483647),
2845 "ALU64_DIV_K: 0xffffffffffffffff / (-1) = 0x0000000000000001",
2847 BPF_LD_IMM64(R2
, 0xffffffffffffffffLL
),
2848 BPF_LD_IMM64(R3
, 0x0000000000000001LL
),
2849 BPF_ALU64_IMM(BPF_DIV
, R2
, 0xffffffff),
2850 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
2851 BPF_MOV32_IMM(R0
, 2),
2853 BPF_MOV32_IMM(R0
, 1),
2860 /* BPF_ALU | BPF_MOD | BPF_X */
2862 "ALU_MOD_X: 3 % 2 = 1",
2864 BPF_LD_IMM64(R0
, 3),
2865 BPF_ALU32_IMM(BPF_MOV
, R1
, 2),
2866 BPF_ALU32_REG(BPF_MOD
, R0
, R1
),
2874 "ALU_MOD_X: 4294967295 % 4294967293 = 2",
2876 BPF_LD_IMM64(R0
, 4294967295U),
2877 BPF_ALU32_IMM(BPF_MOV
, R1
, 4294967293U),
2878 BPF_ALU32_REG(BPF_MOD
, R0
, R1
),
2886 "ALU64_MOD_X: 3 % 2 = 1",
2888 BPF_LD_IMM64(R0
, 3),
2889 BPF_ALU32_IMM(BPF_MOV
, R1
, 2),
2890 BPF_ALU64_REG(BPF_MOD
, R0
, R1
),
2898 "ALU64_MOD_X: 2147483647 % 2147483645 = 2",
2900 BPF_LD_IMM64(R0
, 2147483647),
2901 BPF_ALU32_IMM(BPF_MOV
, R1
, 2147483645),
2902 BPF_ALU64_REG(BPF_MOD
, R0
, R1
),
2909 /* BPF_ALU | BPF_MOD | BPF_K */
2911 "ALU_MOD_K: 3 % 2 = 1",
2913 BPF_LD_IMM64(R0
, 3),
2914 BPF_ALU32_IMM(BPF_MOD
, R0
, 2),
2922 "ALU_MOD_K: 3 % 1 = 0",
2924 BPF_LD_IMM64(R0
, 3),
2925 BPF_ALU32_IMM(BPF_MOD
, R0
, 1),
2933 "ALU_MOD_K: 4294967295 % 4294967293 = 2",
2935 BPF_LD_IMM64(R0
, 4294967295U),
2936 BPF_ALU32_IMM(BPF_MOD
, R0
, 4294967293U),
2944 "ALU64_MOD_K: 3 % 2 = 1",
2946 BPF_LD_IMM64(R0
, 3),
2947 BPF_ALU64_IMM(BPF_MOD
, R0
, 2),
2955 "ALU64_MOD_K: 3 % 1 = 0",
2957 BPF_LD_IMM64(R0
, 3),
2958 BPF_ALU64_IMM(BPF_MOD
, R0
, 1),
2966 "ALU64_MOD_K: 2147483647 % 2147483645 = 2",
2968 BPF_LD_IMM64(R0
, 2147483647),
2969 BPF_ALU64_IMM(BPF_MOD
, R0
, 2147483645),
2976 /* BPF_ALU | BPF_AND | BPF_X */
2978 "ALU_AND_X: 3 & 2 = 2",
2980 BPF_LD_IMM64(R0
, 3),
2981 BPF_ALU32_IMM(BPF_MOV
, R1
, 2),
2982 BPF_ALU32_REG(BPF_AND
, R0
, R1
),
2990 "ALU_AND_X: 0xffffffff & 0xffffffff = 0xffffffff",
2992 BPF_LD_IMM64(R0
, 0xffffffff),
2993 BPF_ALU32_IMM(BPF_MOV
, R1
, 0xffffffff),
2994 BPF_ALU32_REG(BPF_AND
, R0
, R1
),
2999 { { 0, 0xffffffff } },
3002 "ALU64_AND_X: 3 & 2 = 2",
3004 BPF_LD_IMM64(R0
, 3),
3005 BPF_ALU32_IMM(BPF_MOV
, R1
, 2),
3006 BPF_ALU64_REG(BPF_AND
, R0
, R1
),
3014 "ALU64_AND_X: 0xffffffff & 0xffffffff = 0xffffffff",
3016 BPF_LD_IMM64(R0
, 0xffffffff),
3017 BPF_ALU32_IMM(BPF_MOV
, R1
, 0xffffffff),
3018 BPF_ALU64_REG(BPF_AND
, R0
, R1
),
3023 { { 0, 0xffffffff } },
3025 /* BPF_ALU | BPF_AND | BPF_K */
3027 "ALU_AND_K: 3 & 2 = 2",
3029 BPF_LD_IMM64(R0
, 3),
3030 BPF_ALU32_IMM(BPF_AND
, R0
, 2),
3038 "ALU_AND_K: 0xffffffff & 0xffffffff = 0xffffffff",
3040 BPF_LD_IMM64(R0
, 0xffffffff),
3041 BPF_ALU32_IMM(BPF_AND
, R0
, 0xffffffff),
3046 { { 0, 0xffffffff } },
3049 "ALU64_AND_K: 3 & 2 = 2",
3051 BPF_LD_IMM64(R0
, 3),
3052 BPF_ALU64_IMM(BPF_AND
, R0
, 2),
3060 "ALU64_AND_K: 0xffffffff & 0xffffffff = 0xffffffff",
3062 BPF_LD_IMM64(R0
, 0xffffffff),
3063 BPF_ALU64_IMM(BPF_AND
, R0
, 0xffffffff),
3068 { { 0, 0xffffffff } },
3071 "ALU64_AND_K: 0x0000ffffffff0000 & 0x0 = 0x0000ffff00000000",
3073 BPF_LD_IMM64(R2
, 0x0000ffffffff0000LL
),
3074 BPF_LD_IMM64(R3
, 0x0000000000000000LL
),
3075 BPF_ALU64_IMM(BPF_AND
, R2
, 0x0),
3076 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
3077 BPF_MOV32_IMM(R0
, 2),
3079 BPF_MOV32_IMM(R0
, 1),
3087 "ALU64_AND_K: 0x0000ffffffff0000 & -1 = 0x0000ffffffffffff",
3089 BPF_LD_IMM64(R2
, 0x0000ffffffff0000LL
),
3090 BPF_LD_IMM64(R3
, 0x0000ffffffff0000LL
),
3091 BPF_ALU64_IMM(BPF_AND
, R2
, 0xffffffff),
3092 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
3093 BPF_MOV32_IMM(R0
, 2),
3095 BPF_MOV32_IMM(R0
, 1),
3103 "ALU64_AND_K: 0xffffffffffffffff & -1 = 0xffffffffffffffff",
3105 BPF_LD_IMM64(R2
, 0xffffffffffffffffLL
),
3106 BPF_LD_IMM64(R3
, 0xffffffffffffffffLL
),
3107 BPF_ALU64_IMM(BPF_AND
, R2
, 0xffffffff),
3108 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
3109 BPF_MOV32_IMM(R0
, 2),
3111 BPF_MOV32_IMM(R0
, 1),
3118 /* BPF_ALU | BPF_OR | BPF_X */
3120 "ALU_OR_X: 1 | 2 = 3",
3122 BPF_LD_IMM64(R0
, 1),
3123 BPF_ALU32_IMM(BPF_MOV
, R1
, 2),
3124 BPF_ALU32_REG(BPF_OR
, R0
, R1
),
3132 "ALU_OR_X: 0x0 | 0xffffffff = 0xffffffff",
3134 BPF_LD_IMM64(R0
, 0),
3135 BPF_ALU32_IMM(BPF_MOV
, R1
, 0xffffffff),
3136 BPF_ALU32_REG(BPF_OR
, R0
, R1
),
3141 { { 0, 0xffffffff } },
3144 "ALU64_OR_X: 1 | 2 = 3",
3146 BPF_LD_IMM64(R0
, 1),
3147 BPF_ALU32_IMM(BPF_MOV
, R1
, 2),
3148 BPF_ALU64_REG(BPF_OR
, R0
, R1
),
3156 "ALU64_OR_X: 0 | 0xffffffff = 0xffffffff",
3158 BPF_LD_IMM64(R0
, 0),
3159 BPF_ALU32_IMM(BPF_MOV
, R1
, 0xffffffff),
3160 BPF_ALU64_REG(BPF_OR
, R0
, R1
),
3165 { { 0, 0xffffffff } },
3167 /* BPF_ALU | BPF_OR | BPF_K */
3169 "ALU_OR_K: 1 | 2 = 3",
3171 BPF_LD_IMM64(R0
, 1),
3172 BPF_ALU32_IMM(BPF_OR
, R0
, 2),
3180 "ALU_OR_K: 0 & 0xffffffff = 0xffffffff",
3182 BPF_LD_IMM64(R0
, 0),
3183 BPF_ALU32_IMM(BPF_OR
, R0
, 0xffffffff),
3188 { { 0, 0xffffffff } },
3191 "ALU64_OR_K: 1 | 2 = 3",
3193 BPF_LD_IMM64(R0
, 1),
3194 BPF_ALU64_IMM(BPF_OR
, R0
, 2),
3202 "ALU64_OR_K: 0 & 0xffffffff = 0xffffffff",
3204 BPF_LD_IMM64(R0
, 0),
3205 BPF_ALU64_IMM(BPF_OR
, R0
, 0xffffffff),
3210 { { 0, 0xffffffff } },
3213 "ALU64_OR_K: 0x0000ffffffff0000 | 0x0 = 0x0000ffff00000000",
3215 BPF_LD_IMM64(R2
, 0x0000ffffffff0000LL
),
3216 BPF_LD_IMM64(R3
, 0x0000ffffffff0000LL
),
3217 BPF_ALU64_IMM(BPF_OR
, R2
, 0x0),
3218 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
3219 BPF_MOV32_IMM(R0
, 2),
3221 BPF_MOV32_IMM(R0
, 1),
3229 "ALU64_OR_K: 0x0000ffffffff0000 | -1 = 0xffffffffffffffff",
3231 BPF_LD_IMM64(R2
, 0x0000ffffffff0000LL
),
3232 BPF_LD_IMM64(R3
, 0xffffffffffffffffLL
),
3233 BPF_ALU64_IMM(BPF_OR
, R2
, 0xffffffff),
3234 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
3235 BPF_MOV32_IMM(R0
, 2),
3237 BPF_MOV32_IMM(R0
, 1),
3245 "ALU64_OR_K: 0x000000000000000 | -1 = 0xffffffffffffffff",
3247 BPF_LD_IMM64(R2
, 0x0000000000000000LL
),
3248 BPF_LD_IMM64(R3
, 0xffffffffffffffffLL
),
3249 BPF_ALU64_IMM(BPF_OR
, R2
, 0xffffffff),
3250 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
3251 BPF_MOV32_IMM(R0
, 2),
3253 BPF_MOV32_IMM(R0
, 1),
3260 /* BPF_ALU | BPF_XOR | BPF_X */
3262 "ALU_XOR_X: 5 ^ 6 = 3",
3264 BPF_LD_IMM64(R0
, 5),
3265 BPF_ALU32_IMM(BPF_MOV
, R1
, 6),
3266 BPF_ALU32_REG(BPF_XOR
, R0
, R1
),
3274 "ALU_XOR_X: 0x1 ^ 0xffffffff = 0xfffffffe",
3276 BPF_LD_IMM64(R0
, 1),
3277 BPF_ALU32_IMM(BPF_MOV
, R1
, 0xffffffff),
3278 BPF_ALU32_REG(BPF_XOR
, R0
, R1
),
3283 { { 0, 0xfffffffe } },
3286 "ALU64_XOR_X: 5 ^ 6 = 3",
3288 BPF_LD_IMM64(R0
, 5),
3289 BPF_ALU32_IMM(BPF_MOV
, R1
, 6),
3290 BPF_ALU64_REG(BPF_XOR
, R0
, R1
),
3298 "ALU64_XOR_X: 1 ^ 0xffffffff = 0xfffffffe",
3300 BPF_LD_IMM64(R0
, 1),
3301 BPF_ALU32_IMM(BPF_MOV
, R1
, 0xffffffff),
3302 BPF_ALU64_REG(BPF_XOR
, R0
, R1
),
3307 { { 0, 0xfffffffe } },
3309 /* BPF_ALU | BPF_XOR | BPF_K */
3311 "ALU_XOR_K: 5 ^ 6 = 3",
3313 BPF_LD_IMM64(R0
, 5),
3314 BPF_ALU32_IMM(BPF_XOR
, R0
, 6),
3322 "ALU_XOR_K: 1 ^ 0xffffffff = 0xfffffffe",
3324 BPF_LD_IMM64(R0
, 1),
3325 BPF_ALU32_IMM(BPF_XOR
, R0
, 0xffffffff),
3330 { { 0, 0xfffffffe } },
3333 "ALU64_XOR_K: 5 ^ 6 = 3",
3335 BPF_LD_IMM64(R0
, 5),
3336 BPF_ALU64_IMM(BPF_XOR
, R0
, 6),
3344 "ALU64_XOR_K: 1 & 0xffffffff = 0xfffffffe",
3346 BPF_LD_IMM64(R0
, 1),
3347 BPF_ALU64_IMM(BPF_XOR
, R0
, 0xffffffff),
3352 { { 0, 0xfffffffe } },
3355 "ALU64_XOR_K: 0x0000ffffffff0000 ^ 0x0 = 0x0000ffffffff0000",
3357 BPF_LD_IMM64(R2
, 0x0000ffffffff0000LL
),
3358 BPF_LD_IMM64(R3
, 0x0000ffffffff0000LL
),
3359 BPF_ALU64_IMM(BPF_XOR
, R2
, 0x0),
3360 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
3361 BPF_MOV32_IMM(R0
, 2),
3363 BPF_MOV32_IMM(R0
, 1),
3371 "ALU64_XOR_K: 0x0000ffffffff0000 ^ -1 = 0xffff00000000ffff",
3373 BPF_LD_IMM64(R2
, 0x0000ffffffff0000LL
),
3374 BPF_LD_IMM64(R3
, 0xffff00000000ffffLL
),
3375 BPF_ALU64_IMM(BPF_XOR
, R2
, 0xffffffff),
3376 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
3377 BPF_MOV32_IMM(R0
, 2),
3379 BPF_MOV32_IMM(R0
, 1),
3387 "ALU64_XOR_K: 0x000000000000000 ^ -1 = 0xffffffffffffffff",
3389 BPF_LD_IMM64(R2
, 0x0000000000000000LL
),
3390 BPF_LD_IMM64(R3
, 0xffffffffffffffffLL
),
3391 BPF_ALU64_IMM(BPF_XOR
, R2
, 0xffffffff),
3392 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
3393 BPF_MOV32_IMM(R0
, 2),
3395 BPF_MOV32_IMM(R0
, 1),
3402 /* BPF_ALU | BPF_LSH | BPF_X */
3404 "ALU_LSH_X: 1 << 1 = 2",
3406 BPF_LD_IMM64(R0
, 1),
3407 BPF_ALU32_IMM(BPF_MOV
, R1
, 1),
3408 BPF_ALU32_REG(BPF_LSH
, R0
, R1
),
3416 "ALU_LSH_X: 1 << 31 = 0x80000000",
3418 BPF_LD_IMM64(R0
, 1),
3419 BPF_ALU32_IMM(BPF_MOV
, R1
, 31),
3420 BPF_ALU32_REG(BPF_LSH
, R0
, R1
),
3425 { { 0, 0x80000000 } },
3428 "ALU64_LSH_X: 1 << 1 = 2",
3430 BPF_LD_IMM64(R0
, 1),
3431 BPF_ALU32_IMM(BPF_MOV
, R1
, 1),
3432 BPF_ALU64_REG(BPF_LSH
, R0
, R1
),
3440 "ALU64_LSH_X: 1 << 31 = 0x80000000",
3442 BPF_LD_IMM64(R0
, 1),
3443 BPF_ALU32_IMM(BPF_MOV
, R1
, 31),
3444 BPF_ALU64_REG(BPF_LSH
, R0
, R1
),
3449 { { 0, 0x80000000 } },
3451 /* BPF_ALU | BPF_LSH | BPF_K */
3453 "ALU_LSH_K: 1 << 1 = 2",
3455 BPF_LD_IMM64(R0
, 1),
3456 BPF_ALU32_IMM(BPF_LSH
, R0
, 1),
3464 "ALU_LSH_K: 1 << 31 = 0x80000000",
3466 BPF_LD_IMM64(R0
, 1),
3467 BPF_ALU32_IMM(BPF_LSH
, R0
, 31),
3472 { { 0, 0x80000000 } },
3475 "ALU64_LSH_K: 1 << 1 = 2",
3477 BPF_LD_IMM64(R0
, 1),
3478 BPF_ALU64_IMM(BPF_LSH
, R0
, 1),
3486 "ALU64_LSH_K: 1 << 31 = 0x80000000",
3488 BPF_LD_IMM64(R0
, 1),
3489 BPF_ALU64_IMM(BPF_LSH
, R0
, 31),
3494 { { 0, 0x80000000 } },
3496 /* BPF_ALU | BPF_RSH | BPF_X */
3498 "ALU_RSH_X: 2 >> 1 = 1",
3500 BPF_LD_IMM64(R0
, 2),
3501 BPF_ALU32_IMM(BPF_MOV
, R1
, 1),
3502 BPF_ALU32_REG(BPF_RSH
, R0
, R1
),
3510 "ALU_RSH_X: 0x80000000 >> 31 = 1",
3512 BPF_LD_IMM64(R0
, 0x80000000),
3513 BPF_ALU32_IMM(BPF_MOV
, R1
, 31),
3514 BPF_ALU32_REG(BPF_RSH
, R0
, R1
),
3522 "ALU64_RSH_X: 2 >> 1 = 1",
3524 BPF_LD_IMM64(R0
, 2),
3525 BPF_ALU32_IMM(BPF_MOV
, R1
, 1),
3526 BPF_ALU64_REG(BPF_RSH
, R0
, R1
),
3534 "ALU64_RSH_X: 0x80000000 >> 31 = 1",
3536 BPF_LD_IMM64(R0
, 0x80000000),
3537 BPF_ALU32_IMM(BPF_MOV
, R1
, 31),
3538 BPF_ALU64_REG(BPF_RSH
, R0
, R1
),
3545 /* BPF_ALU | BPF_RSH | BPF_K */
3547 "ALU_RSH_K: 2 >> 1 = 1",
3549 BPF_LD_IMM64(R0
, 2),
3550 BPF_ALU32_IMM(BPF_RSH
, R0
, 1),
3558 "ALU_RSH_K: 0x80000000 >> 31 = 1",
3560 BPF_LD_IMM64(R0
, 0x80000000),
3561 BPF_ALU32_IMM(BPF_RSH
, R0
, 31),
3569 "ALU64_RSH_K: 2 >> 1 = 1",
3571 BPF_LD_IMM64(R0
, 2),
3572 BPF_ALU64_IMM(BPF_RSH
, R0
, 1),
3580 "ALU64_RSH_K: 0x80000000 >> 31 = 1",
3582 BPF_LD_IMM64(R0
, 0x80000000),
3583 BPF_ALU64_IMM(BPF_RSH
, R0
, 31),
3590 /* BPF_ALU | BPF_ARSH | BPF_X */
3592 "ALU_ARSH_X: 0xff00ff0000000000 >> 40 = 0xffffffffffff00ff",
3594 BPF_LD_IMM64(R0
, 0xff00ff0000000000LL
),
3595 BPF_ALU32_IMM(BPF_MOV
, R1
, 40),
3596 BPF_ALU64_REG(BPF_ARSH
, R0
, R1
),
3601 { { 0, 0xffff00ff } },
3603 /* BPF_ALU | BPF_ARSH | BPF_K */
3605 "ALU_ARSH_K: 0xff00ff0000000000 >> 40 = 0xffffffffffff00ff",
3607 BPF_LD_IMM64(R0
, 0xff00ff0000000000LL
),
3608 BPF_ALU64_IMM(BPF_ARSH
, R0
, 40),
3613 { { 0, 0xffff00ff } },
3615 /* BPF_ALU | BPF_NEG */
3617 "ALU_NEG: -(3) = -3",
3619 BPF_ALU32_IMM(BPF_MOV
, R0
, 3),
3620 BPF_ALU32_IMM(BPF_NEG
, R0
, 0),
3628 "ALU_NEG: -(-3) = 3",
3630 BPF_ALU32_IMM(BPF_MOV
, R0
, -3),
3631 BPF_ALU32_IMM(BPF_NEG
, R0
, 0),
3639 "ALU64_NEG: -(3) = -3",
3641 BPF_LD_IMM64(R0
, 3),
3642 BPF_ALU64_IMM(BPF_NEG
, R0
, 0),
3650 "ALU64_NEG: -(-3) = 3",
3652 BPF_LD_IMM64(R0
, -3),
3653 BPF_ALU64_IMM(BPF_NEG
, R0
, 0),
3660 /* BPF_ALU | BPF_END | BPF_FROM_BE */
3662 "ALU_END_FROM_BE 16: 0x0123456789abcdef -> 0xcdef",
3664 BPF_LD_IMM64(R0
, 0x0123456789abcdefLL
),
3665 BPF_ENDIAN(BPF_FROM_BE
, R0
, 16),
3670 { { 0, cpu_to_be16(0xcdef) } },
3673 "ALU_END_FROM_BE 32: 0x0123456789abcdef -> 0x89abcdef",
3675 BPF_LD_IMM64(R0
, 0x0123456789abcdefLL
),
3676 BPF_ENDIAN(BPF_FROM_BE
, R0
, 32),
3681 { { 0, cpu_to_be32(0x89abcdef) } },
3684 "ALU_END_FROM_BE 64: 0x0123456789abcdef -> 0x89abcdef",
3686 BPF_LD_IMM64(R0
, 0x0123456789abcdefLL
),
3687 BPF_ENDIAN(BPF_FROM_BE
, R0
, 64),
3692 { { 0, (u32
) cpu_to_be64(0x0123456789abcdefLL
) } },
3694 /* BPF_ALU | BPF_END | BPF_FROM_LE */
3696 "ALU_END_FROM_LE 16: 0x0123456789abcdef -> 0xefcd",
3698 BPF_LD_IMM64(R0
, 0x0123456789abcdefLL
),
3699 BPF_ENDIAN(BPF_FROM_LE
, R0
, 16),
3704 { { 0, cpu_to_le16(0xcdef) } },
3707 "ALU_END_FROM_LE 32: 0x0123456789abcdef -> 0xefcdab89",
3709 BPF_LD_IMM64(R0
, 0x0123456789abcdefLL
),
3710 BPF_ENDIAN(BPF_FROM_LE
, R0
, 32),
3715 { { 0, cpu_to_le32(0x89abcdef) } },
3718 "ALU_END_FROM_LE 64: 0x0123456789abcdef -> 0x67452301",
3720 BPF_LD_IMM64(R0
, 0x0123456789abcdefLL
),
3721 BPF_ENDIAN(BPF_FROM_LE
, R0
, 64),
3726 { { 0, (u32
) cpu_to_le64(0x0123456789abcdefLL
) } },
3728 /* BPF_ST(X) | BPF_MEM | BPF_B/H/W/DW */
3730 "ST_MEM_B: Store/Load byte: max negative",
3732 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
3733 BPF_ST_MEM(BPF_B
, R10
, -40, 0xff),
3734 BPF_LDX_MEM(BPF_B
, R0
, R10
, -40),
3742 "ST_MEM_B: Store/Load byte: max positive",
3744 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
3745 BPF_ST_MEM(BPF_H
, R10
, -40, 0x7f),
3746 BPF_LDX_MEM(BPF_H
, R0
, R10
, -40),
3754 "STX_MEM_B: Store/Load byte: max negative",
3756 BPF_LD_IMM64(R0
, 0),
3757 BPF_LD_IMM64(R1
, 0xffLL
),
3758 BPF_STX_MEM(BPF_B
, R10
, R1
, -40),
3759 BPF_LDX_MEM(BPF_B
, R0
, R10
, -40),
3767 "ST_MEM_H: Store/Load half word: max negative",
3769 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
3770 BPF_ST_MEM(BPF_H
, R10
, -40, 0xffff),
3771 BPF_LDX_MEM(BPF_H
, R0
, R10
, -40),
3779 "ST_MEM_H: Store/Load half word: max positive",
3781 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
3782 BPF_ST_MEM(BPF_H
, R10
, -40, 0x7fff),
3783 BPF_LDX_MEM(BPF_H
, R0
, R10
, -40),
3791 "STX_MEM_H: Store/Load half word: max negative",
3793 BPF_LD_IMM64(R0
, 0),
3794 BPF_LD_IMM64(R1
, 0xffffLL
),
3795 BPF_STX_MEM(BPF_H
, R10
, R1
, -40),
3796 BPF_LDX_MEM(BPF_H
, R0
, R10
, -40),
3804 "ST_MEM_W: Store/Load word: max negative",
3806 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
3807 BPF_ST_MEM(BPF_W
, R10
, -40, 0xffffffff),
3808 BPF_LDX_MEM(BPF_W
, R0
, R10
, -40),
3813 { { 0, 0xffffffff } },
3816 "ST_MEM_W: Store/Load word: max positive",
3818 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
3819 BPF_ST_MEM(BPF_W
, R10
, -40, 0x7fffffff),
3820 BPF_LDX_MEM(BPF_W
, R0
, R10
, -40),
3825 { { 0, 0x7fffffff } },
3828 "STX_MEM_W: Store/Load word: max negative",
3830 BPF_LD_IMM64(R0
, 0),
3831 BPF_LD_IMM64(R1
, 0xffffffffLL
),
3832 BPF_STX_MEM(BPF_W
, R10
, R1
, -40),
3833 BPF_LDX_MEM(BPF_W
, R0
, R10
, -40),
3838 { { 0, 0xffffffff } },
3841 "ST_MEM_DW: Store/Load double word: max negative",
3843 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
3844 BPF_ST_MEM(BPF_DW
, R10
, -40, 0xffffffff),
3845 BPF_LDX_MEM(BPF_DW
, R0
, R10
, -40),
3850 { { 0, 0xffffffff } },
3853 "ST_MEM_DW: Store/Load double word: max negative 2",
3855 BPF_LD_IMM64(R2
, 0xffff00000000ffffLL
),
3856 BPF_LD_IMM64(R3
, 0xffffffffffffffffLL
),
3857 BPF_ST_MEM(BPF_DW
, R10
, -40, 0xffffffff),
3858 BPF_LDX_MEM(BPF_DW
, R2
, R10
, -40),
3859 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
3860 BPF_MOV32_IMM(R0
, 2),
3862 BPF_MOV32_IMM(R0
, 1),
3870 "ST_MEM_DW: Store/Load double word: max positive",
3872 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
3873 BPF_ST_MEM(BPF_DW
, R10
, -40, 0x7fffffff),
3874 BPF_LDX_MEM(BPF_DW
, R0
, R10
, -40),
3879 { { 0, 0x7fffffff } },
3882 "STX_MEM_DW: Store/Load double word: max negative",
3884 BPF_LD_IMM64(R0
, 0),
3885 BPF_LD_IMM64(R1
, 0xffffffffffffffffLL
),
3886 BPF_STX_MEM(BPF_W
, R10
, R1
, -40),
3887 BPF_LDX_MEM(BPF_W
, R0
, R10
, -40),
3892 { { 0, 0xffffffff } },
3894 /* BPF_STX | BPF_XADD | BPF_W/DW */
3896 "STX_XADD_W: Test: 0x12 + 0x10 = 0x22",
3898 BPF_ALU32_IMM(BPF_MOV
, R0
, 0x12),
3899 BPF_ST_MEM(BPF_W
, R10
, -40, 0x10),
3900 BPF_STX_XADD(BPF_W
, R10
, R0
, -40),
3901 BPF_LDX_MEM(BPF_W
, R0
, R10
, -40),
3909 "STX_XADD_DW: Test: 0x12 + 0x10 = 0x22",
3911 BPF_ALU32_IMM(BPF_MOV
, R0
, 0x12),
3912 BPF_ST_MEM(BPF_DW
, R10
, -40, 0x10),
3913 BPF_STX_XADD(BPF_DW
, R10
, R0
, -40),
3914 BPF_LDX_MEM(BPF_DW
, R0
, R10
, -40),
3921 /* BPF_JMP | BPF_EXIT */
3925 BPF_ALU32_IMM(BPF_MOV
, R0
, 0x4711),
3927 BPF_ALU32_IMM(BPF_MOV
, R0
, 0x4712),
3933 /* BPF_JMP | BPF_JA */
3935 "JMP_JA: Unconditional jump: if (true) return 1",
3937 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
3938 BPF_JMP_IMM(BPF_JA
, 0, 0, 1),
3940 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
3947 /* BPF_JMP | BPF_JSGT | BPF_K */
3949 "JMP_JSGT_K: Signed jump: if (-1 > -2) return 1",
3951 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
3952 BPF_LD_IMM64(R1
, 0xffffffffffffffffLL
),
3953 BPF_JMP_IMM(BPF_JSGT
, R1
, -2, 1),
3955 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
3963 "JMP_JSGT_K: Signed jump: if (-1 > -1) return 0",
3965 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
3966 BPF_LD_IMM64(R1
, 0xffffffffffffffffLL
),
3967 BPF_JMP_IMM(BPF_JSGT
, R1
, -1, 1),
3969 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
3976 /* BPF_JMP | BPF_JSGE | BPF_K */
3978 "JMP_JSGE_K: Signed jump: if (-1 >= -2) return 1",
3980 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
3981 BPF_LD_IMM64(R1
, 0xffffffffffffffffLL
),
3982 BPF_JMP_IMM(BPF_JSGE
, R1
, -2, 1),
3984 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
3992 "JMP_JSGE_K: Signed jump: if (-1 >= -1) return 1",
3994 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
3995 BPF_LD_IMM64(R1
, 0xffffffffffffffffLL
),
3996 BPF_JMP_IMM(BPF_JSGE
, R1
, -1, 1),
3998 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4005 /* BPF_JMP | BPF_JGT | BPF_K */
4007 "JMP_JGT_K: if (3 > 2) return 1",
4009 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
4010 BPF_LD_IMM64(R1
, 3),
4011 BPF_JMP_IMM(BPF_JGT
, R1
, 2, 1),
4013 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4020 /* BPF_JMP | BPF_JGE | BPF_K */
4022 "JMP_JGE_K: if (3 >= 2) return 1",
4024 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
4025 BPF_LD_IMM64(R1
, 3),
4026 BPF_JMP_IMM(BPF_JGE
, R1
, 2, 1),
4028 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4035 /* BPF_JMP | BPF_JGT | BPF_K jump backwards */
4037 "JMP_JGT_K: if (3 > 2) return 1 (jump backwards)",
4039 BPF_JMP_IMM(BPF_JA
, 0, 0, 2), /* goto start */
4040 BPF_ALU32_IMM(BPF_MOV
, R0
, 1), /* out: */
4042 BPF_ALU32_IMM(BPF_MOV
, R0
, 0), /* start: */
4043 BPF_LD_IMM64(R1
, 3), /* note: this takes 2 insns */
4044 BPF_JMP_IMM(BPF_JGT
, R1
, 2, -6), /* goto out */
4052 "JMP_JGE_K: if (3 >= 3) return 1",
4054 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
4055 BPF_LD_IMM64(R1
, 3),
4056 BPF_JMP_IMM(BPF_JGE
, R1
, 3, 1),
4058 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4065 /* BPF_JMP | BPF_JNE | BPF_K */
4067 "JMP_JNE_K: if (3 != 2) return 1",
4069 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
4070 BPF_LD_IMM64(R1
, 3),
4071 BPF_JMP_IMM(BPF_JNE
, R1
, 2, 1),
4073 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4080 /* BPF_JMP | BPF_JEQ | BPF_K */
4082 "JMP_JEQ_K: if (3 == 3) return 1",
4084 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
4085 BPF_LD_IMM64(R1
, 3),
4086 BPF_JMP_IMM(BPF_JEQ
, R1
, 3, 1),
4088 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4095 /* BPF_JMP | BPF_JSET | BPF_K */
4097 "JMP_JSET_K: if (0x3 & 0x2) return 1",
4099 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
4100 BPF_LD_IMM64(R1
, 3),
4101 BPF_JMP_IMM(BPF_JNE
, R1
, 2, 1),
4103 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4111 "JMP_JSET_K: if (0x3 & 0xffffffff) return 1",
4113 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
4114 BPF_LD_IMM64(R1
, 3),
4115 BPF_JMP_IMM(BPF_JNE
, R1
, 0xffffffff, 1),
4117 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4124 /* BPF_JMP | BPF_JSGT | BPF_X */
4126 "JMP_JSGT_X: Signed jump: if (-1 > -2) return 1",
4128 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
4129 BPF_LD_IMM64(R1
, -1),
4130 BPF_LD_IMM64(R2
, -2),
4131 BPF_JMP_REG(BPF_JSGT
, R1
, R2
, 1),
4133 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4141 "JMP_JSGT_X: Signed jump: if (-1 > -1) return 0",
4143 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4144 BPF_LD_IMM64(R1
, -1),
4145 BPF_LD_IMM64(R2
, -1),
4146 BPF_JMP_REG(BPF_JSGT
, R1
, R2
, 1),
4148 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
4155 /* BPF_JMP | BPF_JSGE | BPF_X */
4157 "JMP_JSGE_X: Signed jump: if (-1 >= -2) return 1",
4159 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
4160 BPF_LD_IMM64(R1
, -1),
4161 BPF_LD_IMM64(R2
, -2),
4162 BPF_JMP_REG(BPF_JSGE
, R1
, R2
, 1),
4164 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4172 "JMP_JSGE_X: Signed jump: if (-1 >= -1) return 1",
4174 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
4175 BPF_LD_IMM64(R1
, -1),
4176 BPF_LD_IMM64(R2
, -1),
4177 BPF_JMP_REG(BPF_JSGE
, R1
, R2
, 1),
4179 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4186 /* BPF_JMP | BPF_JGT | BPF_X */
4188 "JMP_JGT_X: if (3 > 2) return 1",
4190 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
4191 BPF_LD_IMM64(R1
, 3),
4192 BPF_LD_IMM64(R2
, 2),
4193 BPF_JMP_REG(BPF_JGT
, R1
, R2
, 1),
4195 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4202 /* BPF_JMP | BPF_JGE | BPF_X */
4204 "JMP_JGE_X: if (3 >= 2) return 1",
4206 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
4207 BPF_LD_IMM64(R1
, 3),
4208 BPF_LD_IMM64(R2
, 2),
4209 BPF_JMP_REG(BPF_JGE
, R1
, R2
, 1),
4211 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4219 "JMP_JGE_X: if (3 >= 3) return 1",
4221 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
4222 BPF_LD_IMM64(R1
, 3),
4223 BPF_LD_IMM64(R2
, 3),
4224 BPF_JMP_REG(BPF_JGE
, R1
, R2
, 1),
4226 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4233 /* BPF_JMP | BPF_JNE | BPF_X */
4235 "JMP_JNE_X: if (3 != 2) return 1",
4237 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
4238 BPF_LD_IMM64(R1
, 3),
4239 BPF_LD_IMM64(R2
, 2),
4240 BPF_JMP_REG(BPF_JNE
, R1
, R2
, 1),
4242 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4249 /* BPF_JMP | BPF_JEQ | BPF_X */
4251 "JMP_JEQ_X: if (3 == 3) return 1",
4253 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
4254 BPF_LD_IMM64(R1
, 3),
4255 BPF_LD_IMM64(R2
, 3),
4256 BPF_JMP_REG(BPF_JEQ
, R1
, R2
, 1),
4258 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4265 /* BPF_JMP | BPF_JSET | BPF_X */
4267 "JMP_JSET_X: if (0x3 & 0x2) return 1",
4269 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
4270 BPF_LD_IMM64(R1
, 3),
4271 BPF_LD_IMM64(R2
, 2),
4272 BPF_JMP_REG(BPF_JNE
, R1
, R2
, 1),
4274 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4282 "JMP_JSET_X: if (0x3 & 0xffffffff) return 1",
4284 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
4285 BPF_LD_IMM64(R1
, 3),
4286 BPF_LD_IMM64(R2
, 0xffffffff),
4287 BPF_JMP_REG(BPF_JNE
, R1
, R2
, 1),
4289 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4297 "JMP_JA: Jump, gap, jump, ...",
4299 CLASSIC
| FLAG_NO_DATA
,
4301 { { 0, 0xababcbac } },
4302 .fill_helper
= bpf_fill_ja
,
4304 { /* Mainly checking JIT here. */
4305 "BPF_MAXINSNS: Maximum possible literals",
4307 CLASSIC
| FLAG_NO_DATA
,
4309 { { 0, 0xffffffff } },
4310 .fill_helper
= bpf_fill_maxinsns1
,
4312 { /* Mainly checking JIT here. */
4313 "BPF_MAXINSNS: Single literal",
4315 CLASSIC
| FLAG_NO_DATA
,
4317 { { 0, 0xfefefefe } },
4318 .fill_helper
= bpf_fill_maxinsns2
,
4320 { /* Mainly checking JIT here. */
4321 "BPF_MAXINSNS: Run/add until end",
4323 CLASSIC
| FLAG_NO_DATA
,
4325 { { 0, 0x947bf368 } },
4326 .fill_helper
= bpf_fill_maxinsns3
,
4329 "BPF_MAXINSNS: Too many instructions",
4331 CLASSIC
| FLAG_NO_DATA
| FLAG_EXPECTED_FAIL
,
4334 .fill_helper
= bpf_fill_maxinsns4
,
4336 { /* Mainly checking JIT here. */
4337 "BPF_MAXINSNS: Very long jump",
4339 CLASSIC
| FLAG_NO_DATA
,
4341 { { 0, 0xabababab } },
4342 .fill_helper
= bpf_fill_maxinsns5
,
4344 { /* Mainly checking JIT here. */
4345 "BPF_MAXINSNS: Ctx heavy transformations",
4350 { 1, !!(SKB_VLAN_TCI
& VLAN_TAG_PRESENT
) },
4351 { 10, !!(SKB_VLAN_TCI
& VLAN_TAG_PRESENT
) }
4353 .fill_helper
= bpf_fill_maxinsns6
,
4355 { /* Mainly checking JIT here. */
4356 "BPF_MAXINSNS: Call heavy transformations",
4358 CLASSIC
| FLAG_NO_DATA
,
4360 { { 1, 0 }, { 10, 0 } },
4361 .fill_helper
= bpf_fill_maxinsns7
,
4363 { /* Mainly checking JIT here. */
4364 "BPF_MAXINSNS: Jump heavy test",
4366 CLASSIC
| FLAG_NO_DATA
,
4368 { { 0, 0xffffffff } },
4369 .fill_helper
= bpf_fill_maxinsns8
,
4371 { /* Mainly checking JIT here. */
4372 "BPF_MAXINSNS: Very long jump backwards",
4374 INTERNAL
| FLAG_NO_DATA
,
4376 { { 0, 0xcbababab } },
4377 .fill_helper
= bpf_fill_maxinsns9
,
4379 { /* Mainly checking JIT here. */
4380 "BPF_MAXINSNS: Edge hopping nuthouse",
4382 INTERNAL
| FLAG_NO_DATA
,
4384 { { 0, 0xabababac } },
4385 .fill_helper
= bpf_fill_maxinsns10
,
4388 "BPF_MAXINSNS: Jump, gap, jump, ...",
4390 CLASSIC
| FLAG_NO_DATA
,
4392 { { 0, 0xababcbac } },
4393 .fill_helper
= bpf_fill_maxinsns11
,
4397 static struct net_device dev
;
4399 static struct sk_buff
*populate_skb(char *buf
, int size
)
4401 struct sk_buff
*skb
;
4403 if (size
>= MAX_DATA
)
4406 skb
= alloc_skb(MAX_DATA
, GFP_KERNEL
);
4410 memcpy(__skb_put(skb
, size
), buf
, size
);
4412 /* Initialize a fake skb with test pattern. */
4413 skb_reset_mac_header(skb
);
4414 skb
->protocol
= htons(ETH_P_IP
);
4415 skb
->pkt_type
= SKB_TYPE
;
4416 skb
->mark
= SKB_MARK
;
4417 skb
->hash
= SKB_HASH
;
4418 skb
->queue_mapping
= SKB_QUEUE_MAP
;
4419 skb
->vlan_tci
= SKB_VLAN_TCI
;
4421 skb
->dev
->ifindex
= SKB_DEV_IFINDEX
;
4422 skb
->dev
->type
= SKB_DEV_TYPE
;
4423 skb_set_network_header(skb
, min(size
, ETH_HLEN
));
4428 static void *generate_test_data(struct bpf_test
*test
, int sub
)
4430 if (test
->aux
& FLAG_NO_DATA
)
4433 /* Test case expects an skb, so populate one. Various
4434 * subtests generate skbs of different sizes based on
4437 return populate_skb(test
->data
, test
->test
[sub
].data_size
);
4440 static void release_test_data(const struct bpf_test
*test
, void *data
)
4442 if (test
->aux
& FLAG_NO_DATA
)
4448 static int filter_length(int which
)
4450 struct sock_filter
*fp
;
4453 if (tests
[which
].fill_helper
)
4454 return tests
[which
].u
.ptr
.len
;
4456 fp
= tests
[which
].u
.insns
;
4457 for (len
= MAX_INSNS
- 1; len
> 0; --len
)
4458 if (fp
[len
].code
!= 0 || fp
[len
].k
!= 0)
4464 static void *filter_pointer(int which
)
4466 if (tests
[which
].fill_helper
)
4467 return tests
[which
].u
.ptr
.insns
;
4469 return tests
[which
].u
.insns
;
4472 static struct bpf_prog
*generate_filter(int which
, int *err
)
4474 __u8 test_type
= tests
[which
].aux
& TEST_TYPE_MASK
;
4475 unsigned int flen
= filter_length(which
);
4476 void *fptr
= filter_pointer(which
);
4477 struct sock_fprog_kern fprog
;
4478 struct bpf_prog
*fp
;
4480 switch (test_type
) {
4482 fprog
.filter
= fptr
;
4485 *err
= bpf_prog_create(&fp
, &fprog
);
4486 if (tests
[which
].aux
& FLAG_EXPECTED_FAIL
) {
4487 if (*err
== -EINVAL
) {
4489 /* Verifier rejected filter as expected. */
4493 pr_cont("UNEXPECTED_PASS\n");
4494 /* Verifier didn't reject the test that's
4495 * bad enough, just return!
4501 /* We don't expect to fail. */
4503 pr_cont("FAIL to attach err=%d len=%d\n",
4510 fp
= bpf_prog_alloc(bpf_prog_size(flen
), 0);
4512 pr_cont("UNEXPECTED_FAIL no memory left\n");
4518 memcpy(fp
->insnsi
, fptr
, fp
->len
* sizeof(struct bpf_insn
));
4520 bpf_prog_select_runtime(fp
);
4528 static void release_filter(struct bpf_prog
*fp
, int which
)
4530 __u8 test_type
= tests
[which
].aux
& TEST_TYPE_MASK
;
4532 switch (test_type
) {
4534 bpf_prog_destroy(fp
);
4542 static int __run_one(const struct bpf_prog
*fp
, const void *data
,
4543 int runs
, u64
*duration
)
4548 start
= ktime_to_us(ktime_get());
4550 for (i
= 0; i
< runs
; i
++)
4551 ret
= BPF_PROG_RUN(fp
, data
);
4553 finish
= ktime_to_us(ktime_get());
4555 *duration
= (finish
- start
) * 1000ULL;
4556 do_div(*duration
, runs
);
4561 static int run_one(const struct bpf_prog
*fp
, struct bpf_test
*test
)
4563 int err_cnt
= 0, i
, runs
= MAX_TESTRUNS
;
4565 for (i
= 0; i
< MAX_SUBTESTS
; i
++) {
4570 if (test
->test
[i
].data_size
== 0 &&
4571 test
->test
[i
].result
== 0)
4574 data
= generate_test_data(test
, i
);
4575 ret
= __run_one(fp
, data
, runs
, &duration
);
4576 release_test_data(test
, data
);
4578 if (ret
== test
->test
[i
].result
) {
4579 pr_cont("%lld ", duration
);
4581 pr_cont("ret %d != %d ", ret
,
4582 test
->test
[i
].result
);
4590 static __init
int prepare_bpf_tests(void)
4594 for (i
= 0; i
< ARRAY_SIZE(tests
); i
++) {
4595 if (tests
[i
].fill_helper
&&
4596 tests
[i
].fill_helper(&tests
[i
]) < 0)
4603 static __init
void destroy_bpf_tests(void)
4607 for (i
= 0; i
< ARRAY_SIZE(tests
); i
++) {
4608 if (tests
[i
].fill_helper
)
4609 kfree(tests
[i
].u
.ptr
.insns
);
4613 static __init
int test_bpf(void)
4615 int i
, err_cnt
= 0, pass_cnt
= 0;
4616 int jit_cnt
= 0, run_cnt
= 0;
4618 for (i
= 0; i
< ARRAY_SIZE(tests
); i
++) {
4619 struct bpf_prog
*fp
;
4622 pr_info("#%d %s ", i
, tests
[i
].descr
);
4624 fp
= generate_filter(i
, &err
);
4634 pr_cont("jited:%u ", fp
->jited
);
4640 err
= run_one(fp
, &tests
[i
]);
4641 release_filter(fp
, i
);
4644 pr_cont("FAIL (%d times)\n", err
);
4652 pr_info("Summary: %d PASSED, %d FAILED, [%d/%d JIT'ed]\n",
4653 pass_cnt
, err_cnt
, jit_cnt
, run_cnt
);
4655 return err_cnt
? -EINVAL
: 0;
4658 static int __init
test_bpf_init(void)
4662 ret
= prepare_bpf_tests();
4668 destroy_bpf_tests();
4672 static void __exit
test_bpf_exit(void)
4676 module_init(test_bpf_init
);
4677 module_exit(test_bpf_exit
);
4679 MODULE_LICENSE("GPL");