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/bpf.h>
22 #include <linux/skbuff.h>
23 #include <linux/netdevice.h>
24 #include <linux/if_vlan.h>
25 #include <linux/random.h>
26 #include <linux/highmem.h>
28 /* General test specific settings */
29 #define MAX_SUBTESTS 3
30 #define MAX_TESTRUNS 10000
33 #define MAX_K 0xffffFFFF
35 /* Few constants used to init test 'skb' */
37 #define SKB_MARK 0x1234aaaa
38 #define SKB_HASH 0x1234aaab
39 #define SKB_QUEUE_MAP 123
40 #define SKB_VLAN_TCI 0xffff
41 #define SKB_DEV_IFINDEX 577
42 #define SKB_DEV_TYPE 588
44 /* Redefine REGs to make tests less verbose */
55 #define R10 BPF_REG_10
57 /* Flags that can be passed to test cases */
58 #define FLAG_NO_DATA BIT(0)
59 #define FLAG_EXPECTED_FAIL BIT(1)
60 #define FLAG_SKB_FRAG BIT(2)
63 CLASSIC
= BIT(6), /* Old BPF instructions only. */
64 INTERNAL
= BIT(7), /* Extended instruction set. */
67 #define TEST_TYPE_MASK (CLASSIC | INTERNAL)
72 struct sock_filter insns
[MAX_INSNS
];
73 struct bpf_insn insns_int
[MAX_INSNS
];
85 int (*fill_helper
)(struct bpf_test
*self
);
86 __u8 frag_data
[MAX_DATA
];
89 /* Large test cases need separate allocation and fill handler. */
91 static int bpf_fill_maxinsns1(struct bpf_test
*self
)
93 unsigned int len
= BPF_MAXINSNS
;
94 struct sock_filter
*insn
;
98 insn
= kmalloc_array(len
, sizeof(*insn
), GFP_KERNEL
);
102 for (i
= 0; i
< len
; i
++, k
--)
103 insn
[i
] = __BPF_STMT(BPF_RET
| BPF_K
, k
);
105 self
->u
.ptr
.insns
= insn
;
106 self
->u
.ptr
.len
= len
;
111 static int bpf_fill_maxinsns2(struct bpf_test
*self
)
113 unsigned int len
= BPF_MAXINSNS
;
114 struct sock_filter
*insn
;
117 insn
= kmalloc_array(len
, sizeof(*insn
), GFP_KERNEL
);
121 for (i
= 0; i
< len
; i
++)
122 insn
[i
] = __BPF_STMT(BPF_RET
| BPF_K
, 0xfefefefe);
124 self
->u
.ptr
.insns
= insn
;
125 self
->u
.ptr
.len
= len
;
130 static int bpf_fill_maxinsns3(struct bpf_test
*self
)
132 unsigned int len
= BPF_MAXINSNS
;
133 struct sock_filter
*insn
;
134 struct rnd_state rnd
;
137 insn
= kmalloc_array(len
, sizeof(*insn
), GFP_KERNEL
);
141 prandom_seed_state(&rnd
, 3141592653589793238ULL);
143 for (i
= 0; i
< len
- 1; i
++) {
144 __u32 k
= prandom_u32_state(&rnd
);
146 insn
[i
] = __BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, k
);
149 insn
[len
- 1] = __BPF_STMT(BPF_RET
| BPF_A
, 0);
151 self
->u
.ptr
.insns
= insn
;
152 self
->u
.ptr
.len
= len
;
157 static int bpf_fill_maxinsns4(struct bpf_test
*self
)
159 unsigned int len
= BPF_MAXINSNS
+ 1;
160 struct sock_filter
*insn
;
163 insn
= kmalloc_array(len
, sizeof(*insn
), GFP_KERNEL
);
167 for (i
= 0; i
< len
; i
++)
168 insn
[i
] = __BPF_STMT(BPF_RET
| BPF_K
, 0xfefefefe);
170 self
->u
.ptr
.insns
= insn
;
171 self
->u
.ptr
.len
= len
;
176 static int bpf_fill_maxinsns5(struct bpf_test
*self
)
178 unsigned int len
= BPF_MAXINSNS
;
179 struct sock_filter
*insn
;
182 insn
= kmalloc_array(len
, sizeof(*insn
), GFP_KERNEL
);
186 insn
[0] = __BPF_JUMP(BPF_JMP
| BPF_JA
, len
- 2, 0, 0);
188 for (i
= 1; i
< len
- 1; i
++)
189 insn
[i
] = __BPF_STMT(BPF_RET
| BPF_K
, 0xfefefefe);
191 insn
[len
- 1] = __BPF_STMT(BPF_RET
| BPF_K
, 0xabababab);
193 self
->u
.ptr
.insns
= insn
;
194 self
->u
.ptr
.len
= len
;
199 static int bpf_fill_maxinsns6(struct bpf_test
*self
)
201 unsigned int len
= BPF_MAXINSNS
;
202 struct sock_filter
*insn
;
205 insn
= kmalloc_array(len
, sizeof(*insn
), GFP_KERNEL
);
209 for (i
= 0; i
< len
- 1; i
++)
210 insn
[i
] = __BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
, SKF_AD_OFF
+
211 SKF_AD_VLAN_TAG_PRESENT
);
213 insn
[len
- 1] = __BPF_STMT(BPF_RET
| BPF_A
, 0);
215 self
->u
.ptr
.insns
= insn
;
216 self
->u
.ptr
.len
= len
;
221 static int bpf_fill_maxinsns7(struct bpf_test
*self
)
223 unsigned int len
= BPF_MAXINSNS
;
224 struct sock_filter
*insn
;
227 insn
= kmalloc_array(len
, sizeof(*insn
), GFP_KERNEL
);
231 for (i
= 0; i
< len
- 4; i
++)
232 insn
[i
] = __BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
, SKF_AD_OFF
+
235 insn
[len
- 4] = __BPF_STMT(BPF_MISC
| BPF_TAX
, 0);
236 insn
[len
- 3] = __BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
, SKF_AD_OFF
+
238 insn
[len
- 2] = __BPF_STMT(BPF_ALU
| BPF_SUB
| BPF_X
, 0);
239 insn
[len
- 1] = __BPF_STMT(BPF_RET
| BPF_A
, 0);
241 self
->u
.ptr
.insns
= insn
;
242 self
->u
.ptr
.len
= len
;
247 static int bpf_fill_maxinsns8(struct bpf_test
*self
)
249 unsigned int len
= BPF_MAXINSNS
;
250 struct sock_filter
*insn
;
251 int i
, jmp_off
= len
- 3;
253 insn
= kmalloc_array(len
, sizeof(*insn
), GFP_KERNEL
);
257 insn
[0] = __BPF_STMT(BPF_LD
| BPF_IMM
, 0xffffffff);
259 for (i
= 1; i
< len
- 1; i
++)
260 insn
[i
] = __BPF_JUMP(BPF_JMP
| BPF_JGT
, 0xffffffff, jmp_off
--, 0);
262 insn
[len
- 1] = __BPF_STMT(BPF_RET
| BPF_A
, 0);
264 self
->u
.ptr
.insns
= insn
;
265 self
->u
.ptr
.len
= len
;
270 static int bpf_fill_maxinsns9(struct bpf_test
*self
)
272 unsigned int len
= BPF_MAXINSNS
;
273 struct bpf_insn
*insn
;
276 insn
= kmalloc_array(len
, sizeof(*insn
), GFP_KERNEL
);
280 insn
[0] = BPF_JMP_IMM(BPF_JA
, 0, 0, len
- 2);
281 insn
[1] = BPF_ALU32_IMM(BPF_MOV
, R0
, 0xcbababab);
282 insn
[2] = BPF_EXIT_INSN();
284 for (i
= 3; i
< len
- 2; i
++)
285 insn
[i
] = BPF_ALU32_IMM(BPF_MOV
, R0
, 0xfefefefe);
287 insn
[len
- 2] = BPF_EXIT_INSN();
288 insn
[len
- 1] = BPF_JMP_IMM(BPF_JA
, 0, 0, -(len
- 1));
290 self
->u
.ptr
.insns
= insn
;
291 self
->u
.ptr
.len
= len
;
296 static int bpf_fill_maxinsns10(struct bpf_test
*self
)
298 unsigned int len
= BPF_MAXINSNS
, hlen
= len
- 2;
299 struct bpf_insn
*insn
;
302 insn
= kmalloc_array(len
, sizeof(*insn
), GFP_KERNEL
);
306 for (i
= 0; i
< hlen
/ 2; i
++)
307 insn
[i
] = BPF_JMP_IMM(BPF_JA
, 0, 0, hlen
- 2 - 2 * i
);
308 for (i
= hlen
- 1; i
> hlen
/ 2; i
--)
309 insn
[i
] = BPF_JMP_IMM(BPF_JA
, 0, 0, hlen
- 1 - 2 * i
);
311 insn
[hlen
/ 2] = BPF_JMP_IMM(BPF_JA
, 0, 0, hlen
/ 2 - 1);
312 insn
[hlen
] = BPF_ALU32_IMM(BPF_MOV
, R0
, 0xabababac);
313 insn
[hlen
+ 1] = BPF_EXIT_INSN();
315 self
->u
.ptr
.insns
= insn
;
316 self
->u
.ptr
.len
= len
;
321 static int __bpf_fill_ja(struct bpf_test
*self
, unsigned int len
,
324 struct sock_filter
*insn
;
328 insn
= kmalloc_array(len
, sizeof(*insn
), GFP_KERNEL
);
332 rlen
= (len
% plen
) - 1;
334 for (i
= 0; i
+ plen
< len
; i
+= plen
)
335 for (j
= 0; j
< plen
; j
++)
336 insn
[i
+ j
] = __BPF_JUMP(BPF_JMP
| BPF_JA
,
338 for (j
= 0; j
< rlen
; j
++)
339 insn
[i
+ j
] = __BPF_JUMP(BPF_JMP
| BPF_JA
, rlen
- 1 - j
,
342 insn
[len
- 1] = __BPF_STMT(BPF_RET
| BPF_K
, 0xababcbac);
344 self
->u
.ptr
.insns
= insn
;
345 self
->u
.ptr
.len
= len
;
350 static int bpf_fill_maxinsns11(struct bpf_test
*self
)
352 /* Hits 70 passes on x86_64, so cannot get JITed there. */
353 return __bpf_fill_ja(self
, BPF_MAXINSNS
, 68);
356 static int bpf_fill_ja(struct bpf_test
*self
)
358 /* Hits exactly 11 passes on x86_64 JIT. */
359 return __bpf_fill_ja(self
, 12, 9);
362 static int bpf_fill_ld_abs_get_processor_id(struct bpf_test
*self
)
364 unsigned int len
= BPF_MAXINSNS
;
365 struct sock_filter
*insn
;
368 insn
= kmalloc_array(len
, sizeof(*insn
), GFP_KERNEL
);
372 for (i
= 0; i
< len
- 1; i
+= 2) {
373 insn
[i
] = __BPF_STMT(BPF_LD
| BPF_B
| BPF_ABS
, 0);
374 insn
[i
+ 1] = __BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
375 SKF_AD_OFF
+ SKF_AD_CPU
);
378 insn
[len
- 1] = __BPF_STMT(BPF_RET
| BPF_K
, 0xbee);
380 self
->u
.ptr
.insns
= insn
;
381 self
->u
.ptr
.len
= len
;
387 /* test: {skb->data[0], vlan_push} x 68 + {skb->data[0], vlan_pop} x 68 */
388 static int bpf_fill_ld_abs_vlan_push_pop(struct bpf_test
*self
)
390 unsigned int len
= BPF_MAXINSNS
;
391 struct bpf_insn
*insn
;
394 insn
= kmalloc_array(len
, sizeof(*insn
), GFP_KERNEL
);
398 insn
[i
++] = BPF_MOV64_REG(R6
, R1
);
400 for (j
= 0; j
< PUSH_CNT
; j
++) {
401 insn
[i
++] = BPF_LD_ABS(BPF_B
, 0);
402 insn
[i
] = BPF_JMP_IMM(BPF_JNE
, R0
, 0x34, len
- i
- 2);
404 insn
[i
++] = BPF_MOV64_REG(R1
, R6
);
405 insn
[i
++] = BPF_MOV64_IMM(R2
, 1);
406 insn
[i
++] = BPF_MOV64_IMM(R3
, 2);
407 insn
[i
++] = BPF_RAW_INSN(BPF_JMP
| BPF_CALL
, 0, 0, 0,
408 bpf_skb_vlan_push_proto
.func
- __bpf_call_base
);
409 insn
[i
] = BPF_JMP_IMM(BPF_JNE
, R0
, 0, len
- i
- 2);
413 for (j
= 0; j
< PUSH_CNT
; j
++) {
414 insn
[i
++] = BPF_LD_ABS(BPF_B
, 0);
415 insn
[i
] = BPF_JMP_IMM(BPF_JNE
, R0
, 0x34, len
- i
- 2);
417 insn
[i
++] = BPF_MOV64_REG(R1
, R6
);
418 insn
[i
++] = BPF_RAW_INSN(BPF_JMP
| BPF_CALL
, 0, 0, 0,
419 bpf_skb_vlan_pop_proto
.func
- __bpf_call_base
);
420 insn
[i
] = BPF_JMP_IMM(BPF_JNE
, R0
, 0, len
- i
- 2);
426 for (; i
< len
- 1; i
++)
427 insn
[i
] = BPF_ALU32_IMM(BPF_MOV
, R0
, 0xbef);
429 insn
[len
- 1] = BPF_EXIT_INSN();
431 self
->u
.ptr
.insns
= insn
;
432 self
->u
.ptr
.len
= len
;
437 static struct bpf_test tests
[] = {
441 BPF_STMT(BPF_LD
| BPF_IMM
, 1),
442 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
443 BPF_STMT(BPF_LD
| BPF_IMM
, 2),
444 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
445 BPF_STMT(BPF_ALU
| BPF_NEG
, 0), /* A == -3 */
446 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
447 BPF_STMT(BPF_LD
| BPF_LEN
, 0),
448 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
449 BPF_STMT(BPF_MISC
| BPF_TAX
, 0), /* X == len - 3 */
450 BPF_STMT(BPF_LD
| BPF_B
| BPF_IND
, 1),
451 BPF_STMT(BPF_RET
| BPF_A
, 0)
454 { 10, 20, 30, 40, 50 },
455 { { 2, 10 }, { 3, 20 }, { 4, 30 } },
460 BPF_STMT(BPF_LDX
| BPF_LEN
, 0),
461 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
462 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
463 BPF_STMT(BPF_RET
| BPF_A
, 0) /* A == len * 2 */
466 { 10, 20, 30, 40, 50 },
467 { { 1, 2 }, { 3, 6 }, { 4, 8 } },
472 BPF_STMT(BPF_LD
| BPF_IMM
, 1),
473 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 2),
474 BPF_STMT(BPF_LDX
| BPF_IMM
, 3),
475 BPF_STMT(BPF_ALU
| BPF_SUB
| BPF_X
, 0),
476 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 0xffffffff),
477 BPF_STMT(BPF_ALU
| BPF_MUL
| BPF_K
, 3),
478 BPF_STMT(BPF_RET
| BPF_A
, 0)
480 CLASSIC
| FLAG_NO_DATA
,
482 { { 0, 0xfffffffd } }
487 BPF_STMT(BPF_LD
| BPF_IMM
, 8),
488 BPF_STMT(BPF_ALU
| BPF_DIV
| BPF_K
, 2),
489 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
490 BPF_STMT(BPF_LD
| BPF_IMM
, 0xffffffff),
491 BPF_STMT(BPF_ALU
| BPF_DIV
| BPF_X
, 0),
492 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
493 BPF_STMT(BPF_LD
| BPF_IMM
, 0xffffffff),
494 BPF_STMT(BPF_ALU
| BPF_DIV
| BPF_K
, 0x70000000),
495 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
496 BPF_STMT(BPF_LD
| BPF_IMM
, 0xffffffff),
497 BPF_STMT(BPF_ALU
| BPF_MOD
| BPF_X
, 0),
498 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
499 BPF_STMT(BPF_LD
| BPF_IMM
, 0xffffffff),
500 BPF_STMT(BPF_ALU
| BPF_MOD
| BPF_K
, 0x70000000),
501 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
502 BPF_STMT(BPF_RET
| BPF_A
, 0)
504 CLASSIC
| FLAG_NO_DATA
,
506 { { 0, 0x20000000 } }
511 BPF_STMT(BPF_LD
| BPF_IMM
, 0xff),
512 BPF_STMT(BPF_ALU
| BPF_AND
| BPF_K
, 0xf0),
513 BPF_STMT(BPF_ALU
| BPF_LSH
| BPF_K
, 27),
514 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
515 BPF_STMT(BPF_LD
| BPF_IMM
, 0xf),
516 BPF_STMT(BPF_ALU
| BPF_OR
| BPF_K
, 0xf0),
517 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
518 BPF_STMT(BPF_RET
| BPF_A
, 0)
520 CLASSIC
| FLAG_NO_DATA
,
522 { { 0, 0x800000ff }, { 1, 0x800000ff } },
527 BPF_STMT(BPF_LD
| BPF_IMM
, 0), /* ld #0 */
528 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 0, 1, 0),
529 BPF_STMT(BPF_RET
| BPF_K
, 0),
530 BPF_STMT(BPF_RET
| BPF_K
, 1),
539 BPF_STMT(BPF_LDX
| BPF_LEN
, 0),
540 BPF_STMT(BPF_LD
| BPF_H
| BPF_IND
, MAX_K
),
541 BPF_STMT(BPF_RET
| BPF_K
, 1)
545 { { 1, 0 }, { 10, 0 }, { 60, 0 } },
550 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
, 1000),
551 BPF_STMT(BPF_RET
| BPF_K
, 1)
555 { { 1, 0 }, { 10, 0 }, { 60, 0 } },
560 BPF_STMT(BPF_LD
| BPF_B
| BPF_ABS
, SKF_LL_OFF
),
561 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
562 BPF_STMT(BPF_LD
| BPF_B
| BPF_ABS
, SKF_LL_OFF
+ 1),
563 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
564 BPF_STMT(BPF_RET
| BPF_A
, 0)
568 { { 1, 0 }, { 2, 3 } },
573 BPF_STMT(BPF_LD
| BPF_IMM
, SKF_LL_OFF
- 1),
574 BPF_STMT(BPF_LDX
| BPF_LEN
, 0),
575 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
576 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
577 BPF_STMT(BPF_LD
| BPF_B
| BPF_IND
, 0),
578 BPF_STMT(BPF_RET
| BPF_A
, 0)
582 { { 1, 1 }, { 3, 3 }, { 4, 0xff } },
587 BPF_STMT(BPF_LD
| BPF_B
| BPF_ABS
, SKF_NET_OFF
),
588 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
589 BPF_STMT(BPF_LD
| BPF_B
| BPF_ABS
, SKF_NET_OFF
+ 1),
590 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
591 BPF_STMT(BPF_RET
| BPF_A
, 0)
594 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3 },
595 { { 15, 0 }, { 16, 3 } },
600 BPF_STMT(BPF_LD
| BPF_IMM
, SKF_NET_OFF
- 15),
601 BPF_STMT(BPF_LDX
| BPF_LEN
, 0),
602 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
603 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
604 BPF_STMT(BPF_LD
| BPF_B
| BPF_IND
, 0),
605 BPF_STMT(BPF_RET
| BPF_A
, 0)
608 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3 },
609 { { 14, 0 }, { 15, 1 }, { 17, 3 } },
614 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
615 SKF_AD_OFF
+ SKF_AD_PKTTYPE
),
616 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, SKB_TYPE
, 1, 0),
617 BPF_STMT(BPF_RET
| BPF_K
, 1),
618 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
619 SKF_AD_OFF
+ SKF_AD_PKTTYPE
),
620 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, SKB_TYPE
, 1, 0),
621 BPF_STMT(BPF_RET
| BPF_K
, 1),
622 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
623 SKF_AD_OFF
+ SKF_AD_PKTTYPE
),
624 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, SKB_TYPE
, 1, 0),
625 BPF_STMT(BPF_RET
| BPF_K
, 1),
626 BPF_STMT(BPF_RET
| BPF_A
, 0)
630 { { 1, 3 }, { 10, 3 } },
635 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
636 SKF_AD_OFF
+ SKF_AD_MARK
),
637 BPF_STMT(BPF_RET
| BPF_A
, 0)
641 { { 1, SKB_MARK
}, { 10, SKB_MARK
} },
646 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
647 SKF_AD_OFF
+ SKF_AD_RXHASH
),
648 BPF_STMT(BPF_RET
| BPF_A
, 0)
652 { { 1, SKB_HASH
}, { 10, SKB_HASH
} },
657 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
658 SKF_AD_OFF
+ SKF_AD_QUEUE
),
659 BPF_STMT(BPF_RET
| BPF_A
, 0)
663 { { 1, SKB_QUEUE_MAP
}, { 10, SKB_QUEUE_MAP
} },
668 BPF_STMT(BPF_LD
| BPF_B
| BPF_ABS
, 1),
669 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 20, 1, 0),
670 BPF_STMT(BPF_RET
| BPF_K
, 0),
671 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
672 SKF_AD_OFF
+ SKF_AD_PROTOCOL
),
673 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
674 BPF_STMT(BPF_LD
| BPF_B
| BPF_ABS
, 2),
675 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 30, 1, 0),
676 BPF_STMT(BPF_RET
| BPF_K
, 0),
677 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
678 BPF_STMT(BPF_RET
| BPF_A
, 0)
682 { { 10, ETH_P_IP
}, { 100, ETH_P_IP
} },
687 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
688 SKF_AD_OFF
+ SKF_AD_VLAN_TAG
),
689 BPF_STMT(BPF_RET
| BPF_A
, 0)
694 { 1, SKB_VLAN_TCI
& ~VLAN_TAG_PRESENT
},
695 { 10, SKB_VLAN_TCI
& ~VLAN_TAG_PRESENT
}
699 "LD_VLAN_TAG_PRESENT",
701 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
702 SKF_AD_OFF
+ SKF_AD_VLAN_TAG_PRESENT
),
703 BPF_STMT(BPF_RET
| BPF_A
, 0)
708 { 1, !!(SKB_VLAN_TCI
& VLAN_TAG_PRESENT
) },
709 { 10, !!(SKB_VLAN_TCI
& VLAN_TAG_PRESENT
) }
715 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
716 SKF_AD_OFF
+ SKF_AD_IFINDEX
),
717 BPF_STMT(BPF_RET
| BPF_A
, 0)
721 { { 1, SKB_DEV_IFINDEX
}, { 10, SKB_DEV_IFINDEX
} },
726 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
727 SKF_AD_OFF
+ SKF_AD_HATYPE
),
728 BPF_STMT(BPF_RET
| BPF_A
, 0)
732 { { 1, SKB_DEV_TYPE
}, { 10, SKB_DEV_TYPE
} },
737 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
738 SKF_AD_OFF
+ SKF_AD_CPU
),
739 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
740 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
741 SKF_AD_OFF
+ SKF_AD_CPU
),
742 BPF_STMT(BPF_ALU
| BPF_SUB
| BPF_X
, 0),
743 BPF_STMT(BPF_RET
| BPF_A
, 0)
747 { { 1, 0 }, { 10, 0 } },
752 BPF_STMT(BPF_LDX
| BPF_IMM
, 2),
753 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
754 BPF_STMT(BPF_LDX
| BPF_IMM
, 3),
755 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
756 SKF_AD_OFF
+ SKF_AD_NLATTR
),
757 BPF_STMT(BPF_RET
| BPF_A
, 0)
761 { 0xff, 0xff, 0, 4, 0, 2, 0, 4, 0, 3 },
763 { 0xff, 0xff, 4, 0, 2, 0, 4, 0, 3, 0 },
765 { { 4, 0 }, { 20, 6 } },
770 BPF_STMT(BPF_LD
| BPF_IMM
, 2),
771 BPF_STMT(BPF_LDX
| BPF_IMM
, 3),
772 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
773 SKF_AD_OFF
+ SKF_AD_NLATTR_NEST
),
774 BPF_STMT(BPF_LD
| BPF_IMM
, 2),
775 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
776 SKF_AD_OFF
+ SKF_AD_NLATTR_NEST
),
777 BPF_STMT(BPF_LD
| BPF_IMM
, 2),
778 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
779 SKF_AD_OFF
+ SKF_AD_NLATTR_NEST
),
780 BPF_STMT(BPF_LD
| BPF_IMM
, 2),
781 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
782 SKF_AD_OFF
+ SKF_AD_NLATTR_NEST
),
783 BPF_STMT(BPF_LD
| BPF_IMM
, 2),
784 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
785 SKF_AD_OFF
+ SKF_AD_NLATTR_NEST
),
786 BPF_STMT(BPF_LD
| BPF_IMM
, 2),
787 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
788 SKF_AD_OFF
+ SKF_AD_NLATTR_NEST
),
789 BPF_STMT(BPF_LD
| BPF_IMM
, 2),
790 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
791 SKF_AD_OFF
+ SKF_AD_NLATTR_NEST
),
792 BPF_STMT(BPF_LD
| BPF_IMM
, 2),
793 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
794 SKF_AD_OFF
+ SKF_AD_NLATTR_NEST
),
795 BPF_STMT(BPF_RET
| BPF_A
, 0)
799 { 0xff, 0xff, 0, 12, 0, 1, 0, 4, 0, 2, 0, 4, 0, 3 },
801 { 0xff, 0xff, 12, 0, 1, 0, 4, 0, 2, 0, 4, 0, 3, 0 },
803 { { 4, 0 }, { 20, 10 } },
808 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
809 SKF_AD_OFF
+ SKF_AD_PAY_OFFSET
),
810 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
811 SKF_AD_OFF
+ SKF_AD_PAY_OFFSET
),
812 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
813 SKF_AD_OFF
+ SKF_AD_PAY_OFFSET
),
814 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
815 SKF_AD_OFF
+ SKF_AD_PAY_OFFSET
),
816 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
817 SKF_AD_OFF
+ SKF_AD_PAY_OFFSET
),
818 BPF_STMT(BPF_RET
| BPF_A
, 0)
821 /* 00:00:00:00:00:00 > 00:00:00:00:00:00, ethtype IPv4 (0x0800),
822 * length 98: 127.0.0.1 > 127.0.0.1: ICMP echo request,
823 * id 9737, seq 1, length 64
825 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
826 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
828 0x45, 0x00, 0x00, 0x54, 0xac, 0x8b, 0x40, 0x00, 0x40,
829 0x01, 0x90, 0x1b, 0x7f, 0x00, 0x00, 0x01 },
830 { { 30, 0 }, { 100, 42 } },
835 BPF_STMT(BPF_LD
| BPF_IMM
, 10),
836 BPF_STMT(BPF_LDX
| BPF_IMM
, 300),
837 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
838 SKF_AD_OFF
+ SKF_AD_ALU_XOR_X
),
839 BPF_STMT(BPF_RET
| BPF_A
, 0)
843 { { 4, 10 ^ 300 }, { 20, 10 ^ 300 } },
848 BPF_STMT(BPF_LDX
| BPF_LEN
, 0),
849 BPF_STMT(BPF_LD
| BPF_IMM
, 2),
850 BPF_STMT(BPF_ALU
| BPF_RSH
, 1),
851 BPF_STMT(BPF_ALU
| BPF_XOR
| BPF_X
, 0),
852 BPF_STMT(BPF_ST
, 1), /* M1 = 1 ^ len */
853 BPF_STMT(BPF_ALU
| BPF_XOR
| BPF_K
, 0x80000000),
854 BPF_STMT(BPF_ST
, 2), /* M2 = 1 ^ len ^ 0x80000000 */
855 BPF_STMT(BPF_STX
, 15), /* M3 = len */
856 BPF_STMT(BPF_LDX
| BPF_MEM
, 1),
857 BPF_STMT(BPF_LD
| BPF_MEM
, 2),
858 BPF_STMT(BPF_ALU
| BPF_XOR
| BPF_X
, 0),
859 BPF_STMT(BPF_LDX
| BPF_MEM
, 15),
860 BPF_STMT(BPF_ALU
| BPF_XOR
| BPF_X
, 0),
861 BPF_STMT(BPF_RET
| BPF_A
, 0)
865 { { 1, 0x80000001 }, { 2, 0x80000002 }, { 60, 0x80000000 ^ 60 } }
870 BPF_STMT(BPF_LDX
| BPF_LEN
, 0),
871 BPF_STMT(BPF_LD
| BPF_B
| BPF_ABS
, 2),
872 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_X
, 0, 0, 1),
873 BPF_STMT(BPF_RET
| BPF_K
, 1),
874 BPF_STMT(BPF_RET
| BPF_K
, MAX_K
)
878 { { 1, 0 }, { 3, 1 }, { 4, MAX_K
} },
883 BPF_STMT(BPF_LDX
| BPF_LEN
, 0),
884 BPF_STMT(BPF_LD
| BPF_B
| BPF_ABS
, 2),
885 BPF_JUMP(BPF_JMP
| BPF_JGT
| BPF_X
, 0, 0, 1),
886 BPF_STMT(BPF_RET
| BPF_K
, 1),
887 BPF_STMT(BPF_RET
| BPF_K
, MAX_K
)
891 { { 2, 0 }, { 3, 1 }, { 4, MAX_K
} },
896 BPF_STMT(BPF_LDX
| BPF_LEN
, 0),
897 BPF_STMT(BPF_LD
| BPF_B
| BPF_IND
, MAX_K
),
898 BPF_JUMP(BPF_JMP
| BPF_JGE
| BPF_K
, 1, 1, 0),
899 BPF_STMT(BPF_RET
| BPF_K
, 10),
900 BPF_JUMP(BPF_JMP
| BPF_JGE
| BPF_K
, 2, 1, 0),
901 BPF_STMT(BPF_RET
| BPF_K
, 20),
902 BPF_JUMP(BPF_JMP
| BPF_JGE
| BPF_K
, 3, 1, 0),
903 BPF_STMT(BPF_RET
| BPF_K
, 30),
904 BPF_JUMP(BPF_JMP
| BPF_JGE
| BPF_K
, 4, 1, 0),
905 BPF_STMT(BPF_RET
| BPF_K
, 40),
906 BPF_STMT(BPF_RET
| BPF_K
, MAX_K
)
910 { { 1, 20 }, { 3, 40 }, { 5, MAX_K
} },
915 BPF_JUMP(BPF_JMP
| BPF_JA
, 0, 0, 0),
916 BPF_JUMP(BPF_JMP
| BPF_JA
, 1, 1, 1),
917 BPF_JUMP(BPF_JMP
| BPF_JA
, 0, 0, 0),
918 BPF_JUMP(BPF_JMP
| BPF_JA
, 0, 0, 0),
919 BPF_STMT(BPF_LDX
| BPF_LEN
, 0),
920 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
921 BPF_STMT(BPF_ALU
| BPF_SUB
| BPF_K
, 4),
922 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
923 BPF_STMT(BPF_LD
| BPF_W
| BPF_IND
, 0),
924 BPF_JUMP(BPF_JMP
| BPF_JSET
| BPF_K
, 1, 0, 1),
925 BPF_STMT(BPF_RET
| BPF_K
, 10),
926 BPF_JUMP(BPF_JMP
| BPF_JSET
| BPF_K
, 0x80000000, 0, 1),
927 BPF_STMT(BPF_RET
| BPF_K
, 20),
928 BPF_JUMP(BPF_JMP
| BPF_JSET
| BPF_K
, 0xffffff, 1, 0),
929 BPF_STMT(BPF_RET
| BPF_K
, 30),
930 BPF_JUMP(BPF_JMP
| BPF_JSET
| BPF_K
, 0xffffff, 1, 0),
931 BPF_STMT(BPF_RET
| BPF_K
, 30),
932 BPF_JUMP(BPF_JMP
| BPF_JSET
| BPF_K
, 0xffffff, 1, 0),
933 BPF_STMT(BPF_RET
| BPF_K
, 30),
934 BPF_JUMP(BPF_JMP
| BPF_JSET
| BPF_K
, 0xffffff, 1, 0),
935 BPF_STMT(BPF_RET
| BPF_K
, 30),
936 BPF_JUMP(BPF_JMP
| BPF_JSET
| BPF_K
, 0xffffff, 1, 0),
937 BPF_STMT(BPF_RET
| BPF_K
, 30),
938 BPF_STMT(BPF_RET
| BPF_K
, MAX_K
)
941 { 0, 0xAA, 0x55, 1 },
942 { { 4, 10 }, { 5, 20 }, { 6, MAX_K
} },
947 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 12),
948 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 0x86dd, 0, 8), /* IPv6 */
949 BPF_STMT(BPF_LD
| BPF_B
| BPF_ABS
, 20),
950 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 0x84, 2, 0),
951 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 0x6, 1, 0),
952 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 0x11, 0, 17),
953 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 54),
954 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 22, 14, 0),
955 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 56),
956 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 22, 12, 13),
957 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 0x0800, 0, 12), /* IPv4 */
958 BPF_STMT(BPF_LD
| BPF_B
| BPF_ABS
, 23),
959 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 0x84, 2, 0),
960 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 0x6, 1, 0),
961 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 0x11, 0, 8),
962 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 20),
963 BPF_JUMP(BPF_JMP
| BPF_JSET
| BPF_K
, 0x1fff, 6, 0),
964 BPF_STMT(BPF_LDX
| BPF_B
| BPF_MSH
, 14),
965 BPF_STMT(BPF_LD
| BPF_H
| BPF_IND
, 14),
966 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 22, 2, 0),
967 BPF_STMT(BPF_LD
| BPF_H
| BPF_IND
, 16),
968 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 22, 0, 1),
969 BPF_STMT(BPF_RET
| BPF_K
, 0xffff),
970 BPF_STMT(BPF_RET
| BPF_K
, 0),
973 /* 3c:07:54:43:e5:76 > 10:bf:48:d6:43:d6, ethertype IPv4(0x0800)
974 * length 114: 10.1.1.149.49700 > 10.1.2.10.22: Flags [P.],
975 * seq 1305692979:1305693027, ack 3650467037, win 65535,
976 * options [nop,nop,TS val 2502645400 ecr 3971138], length 48
978 { 0x10, 0xbf, 0x48, 0xd6, 0x43, 0xd6,
979 0x3c, 0x07, 0x54, 0x43, 0xe5, 0x76,
981 0x45, 0x10, 0x00, 0x64, 0x75, 0xb5,
982 0x40, 0x00, 0x40, 0x06, 0xad, 0x2e, /* IP header */
983 0x0a, 0x01, 0x01, 0x95, /* ip src */
984 0x0a, 0x01, 0x02, 0x0a, /* ip dst */
986 0x00, 0x16 /* dst port */ },
987 { { 10, 0 }, { 30, 0 }, { 100, 65535 } },
992 /* tcpdump -nei eth0 'tcp port 22 and (((ip[2:2] -
993 * ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0) and
994 * (len > 115 or len < 30000000000)' -d
996 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 12),
997 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 0x86dd, 30, 0),
998 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 0x800, 0, 29),
999 BPF_STMT(BPF_LD
| BPF_B
| BPF_ABS
, 23),
1000 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 0x6, 0, 27),
1001 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 20),
1002 BPF_JUMP(BPF_JMP
| BPF_JSET
| BPF_K
, 0x1fff, 25, 0),
1003 BPF_STMT(BPF_LDX
| BPF_B
| BPF_MSH
, 14),
1004 BPF_STMT(BPF_LD
| BPF_H
| BPF_IND
, 14),
1005 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 22, 2, 0),
1006 BPF_STMT(BPF_LD
| BPF_H
| BPF_IND
, 16),
1007 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 22, 0, 20),
1008 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 16),
1009 BPF_STMT(BPF_ST
, 1),
1010 BPF_STMT(BPF_LD
| BPF_B
| BPF_ABS
, 14),
1011 BPF_STMT(BPF_ALU
| BPF_AND
| BPF_K
, 0xf),
1012 BPF_STMT(BPF_ALU
| BPF_LSH
| BPF_K
, 2),
1013 BPF_STMT(BPF_MISC
| BPF_TAX
, 0x5), /* libpcap emits K on TAX */
1014 BPF_STMT(BPF_LD
| BPF_MEM
, 1),
1015 BPF_STMT(BPF_ALU
| BPF_SUB
| BPF_X
, 0),
1016 BPF_STMT(BPF_ST
, 5),
1017 BPF_STMT(BPF_LDX
| BPF_B
| BPF_MSH
, 14),
1018 BPF_STMT(BPF_LD
| BPF_B
| BPF_IND
, 26),
1019 BPF_STMT(BPF_ALU
| BPF_AND
| BPF_K
, 0xf0),
1020 BPF_STMT(BPF_ALU
| BPF_RSH
| BPF_K
, 2),
1021 BPF_STMT(BPF_MISC
| BPF_TAX
, 0x9), /* libpcap emits K on TAX */
1022 BPF_STMT(BPF_LD
| BPF_MEM
, 5),
1023 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_X
, 0, 4, 0),
1024 BPF_STMT(BPF_LD
| BPF_LEN
, 0),
1025 BPF_JUMP(BPF_JMP
| BPF_JGT
| BPF_K
, 0x73, 1, 0),
1026 BPF_JUMP(BPF_JMP
| BPF_JGE
| BPF_K
, 0xfc23ac00, 1, 0),
1027 BPF_STMT(BPF_RET
| BPF_K
, 0xffff),
1028 BPF_STMT(BPF_RET
| BPF_K
, 0),
1031 { 0x10, 0xbf, 0x48, 0xd6, 0x43, 0xd6,
1032 0x3c, 0x07, 0x54, 0x43, 0xe5, 0x76,
1034 0x45, 0x10, 0x00, 0x64, 0x75, 0xb5,
1035 0x40, 0x00, 0x40, 0x06, 0xad, 0x2e, /* IP header */
1036 0x0a, 0x01, 0x01, 0x95, /* ip src */
1037 0x0a, 0x01, 0x02, 0x0a, /* ip dst */
1039 0x00, 0x16 /* dst port */ },
1040 { { 10, 0 }, { 30, 0 }, { 100, 65535 } },
1045 /* check that unitialized X and A contain zeros */
1046 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
1047 BPF_STMT(BPF_RET
| BPF_A
, 0)
1056 BPF_ALU64_IMM(BPF_MOV
, R1
, 1),
1057 BPF_ALU64_IMM(BPF_ADD
, R1
, 2),
1058 BPF_ALU64_IMM(BPF_MOV
, R2
, 3),
1059 BPF_ALU64_REG(BPF_SUB
, R1
, R2
),
1060 BPF_ALU64_IMM(BPF_ADD
, R1
, -1),
1061 BPF_ALU64_IMM(BPF_MUL
, R1
, 3),
1062 BPF_ALU64_REG(BPF_MOV
, R0
, R1
),
1067 { { 0, 0xfffffffd } }
1072 BPF_ALU64_IMM(BPF_MOV
, R0
, -1),
1073 BPF_ALU64_IMM(BPF_MOV
, R1
, -1),
1074 BPF_ALU64_IMM(BPF_MOV
, R2
, 3),
1075 BPF_ALU64_REG(BPF_MUL
, R1
, R2
),
1076 BPF_JMP_IMM(BPF_JEQ
, R1
, 0xfffffffd, 1),
1078 BPF_ALU64_IMM(BPF_MOV
, R0
, 1),
1088 BPF_ALU32_IMM(BPF_MOV
, R0
, -1),
1089 BPF_ALU32_IMM(BPF_MOV
, R1
, -1),
1090 BPF_ALU32_IMM(BPF_MOV
, R2
, 3),
1091 BPF_ALU64_REG(BPF_MUL
, R1
, R2
),
1092 BPF_ALU64_IMM(BPF_RSH
, R1
, 8),
1093 BPF_JMP_IMM(BPF_JEQ
, R1
, 0x2ffffff, 1),
1095 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
1105 BPF_ALU32_IMM(BPF_MOV
, R0
, -1),
1106 BPF_ALU64_IMM(BPF_MOV
, R1
, -1),
1107 BPF_ALU32_IMM(BPF_MOV
, R2
, 3),
1108 BPF_ALU32_REG(BPF_MUL
, R1
, R2
),
1109 BPF_ALU64_IMM(BPF_RSH
, R1
, 8),
1110 BPF_JMP_IMM(BPF_JEQ
, R1
, 0xffffff, 1),
1112 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
1120 /* Have to test all register combinations, since
1121 * JITing of different registers will produce
1122 * different asm code.
1126 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
1127 BPF_ALU64_IMM(BPF_MOV
, R1
, 1),
1128 BPF_ALU64_IMM(BPF_MOV
, R2
, 2),
1129 BPF_ALU64_IMM(BPF_MOV
, R3
, 3),
1130 BPF_ALU64_IMM(BPF_MOV
, R4
, 4),
1131 BPF_ALU64_IMM(BPF_MOV
, R5
, 5),
1132 BPF_ALU64_IMM(BPF_MOV
, R6
, 6),
1133 BPF_ALU64_IMM(BPF_MOV
, R7
, 7),
1134 BPF_ALU64_IMM(BPF_MOV
, R8
, 8),
1135 BPF_ALU64_IMM(BPF_MOV
, R9
, 9),
1136 BPF_ALU64_IMM(BPF_ADD
, R0
, 20),
1137 BPF_ALU64_IMM(BPF_ADD
, R1
, 20),
1138 BPF_ALU64_IMM(BPF_ADD
, R2
, 20),
1139 BPF_ALU64_IMM(BPF_ADD
, R3
, 20),
1140 BPF_ALU64_IMM(BPF_ADD
, R4
, 20),
1141 BPF_ALU64_IMM(BPF_ADD
, R5
, 20),
1142 BPF_ALU64_IMM(BPF_ADD
, R6
, 20),
1143 BPF_ALU64_IMM(BPF_ADD
, R7
, 20),
1144 BPF_ALU64_IMM(BPF_ADD
, R8
, 20),
1145 BPF_ALU64_IMM(BPF_ADD
, R9
, 20),
1146 BPF_ALU64_IMM(BPF_SUB
, R0
, 10),
1147 BPF_ALU64_IMM(BPF_SUB
, R1
, 10),
1148 BPF_ALU64_IMM(BPF_SUB
, R2
, 10),
1149 BPF_ALU64_IMM(BPF_SUB
, R3
, 10),
1150 BPF_ALU64_IMM(BPF_SUB
, R4
, 10),
1151 BPF_ALU64_IMM(BPF_SUB
, R5
, 10),
1152 BPF_ALU64_IMM(BPF_SUB
, R6
, 10),
1153 BPF_ALU64_IMM(BPF_SUB
, R7
, 10),
1154 BPF_ALU64_IMM(BPF_SUB
, R8
, 10),
1155 BPF_ALU64_IMM(BPF_SUB
, R9
, 10),
1156 BPF_ALU64_REG(BPF_ADD
, R0
, R0
),
1157 BPF_ALU64_REG(BPF_ADD
, R0
, R1
),
1158 BPF_ALU64_REG(BPF_ADD
, R0
, R2
),
1159 BPF_ALU64_REG(BPF_ADD
, R0
, R3
),
1160 BPF_ALU64_REG(BPF_ADD
, R0
, R4
),
1161 BPF_ALU64_REG(BPF_ADD
, R0
, R5
),
1162 BPF_ALU64_REG(BPF_ADD
, R0
, R6
),
1163 BPF_ALU64_REG(BPF_ADD
, R0
, R7
),
1164 BPF_ALU64_REG(BPF_ADD
, R0
, R8
),
1165 BPF_ALU64_REG(BPF_ADD
, R0
, R9
), /* R0 == 155 */
1166 BPF_JMP_IMM(BPF_JEQ
, R0
, 155, 1),
1168 BPF_ALU64_REG(BPF_ADD
, R1
, R0
),
1169 BPF_ALU64_REG(BPF_ADD
, R1
, R1
),
1170 BPF_ALU64_REG(BPF_ADD
, R1
, R2
),
1171 BPF_ALU64_REG(BPF_ADD
, R1
, R3
),
1172 BPF_ALU64_REG(BPF_ADD
, R1
, R4
),
1173 BPF_ALU64_REG(BPF_ADD
, R1
, R5
),
1174 BPF_ALU64_REG(BPF_ADD
, R1
, R6
),
1175 BPF_ALU64_REG(BPF_ADD
, R1
, R7
),
1176 BPF_ALU64_REG(BPF_ADD
, R1
, R8
),
1177 BPF_ALU64_REG(BPF_ADD
, R1
, R9
), /* R1 == 456 */
1178 BPF_JMP_IMM(BPF_JEQ
, R1
, 456, 1),
1180 BPF_ALU64_REG(BPF_ADD
, R2
, R0
),
1181 BPF_ALU64_REG(BPF_ADD
, R2
, R1
),
1182 BPF_ALU64_REG(BPF_ADD
, R2
, R2
),
1183 BPF_ALU64_REG(BPF_ADD
, R2
, R3
),
1184 BPF_ALU64_REG(BPF_ADD
, R2
, R4
),
1185 BPF_ALU64_REG(BPF_ADD
, R2
, R5
),
1186 BPF_ALU64_REG(BPF_ADD
, R2
, R6
),
1187 BPF_ALU64_REG(BPF_ADD
, R2
, R7
),
1188 BPF_ALU64_REG(BPF_ADD
, R2
, R8
),
1189 BPF_ALU64_REG(BPF_ADD
, R2
, R9
), /* R2 == 1358 */
1190 BPF_JMP_IMM(BPF_JEQ
, R2
, 1358, 1),
1192 BPF_ALU64_REG(BPF_ADD
, R3
, R0
),
1193 BPF_ALU64_REG(BPF_ADD
, R3
, R1
),
1194 BPF_ALU64_REG(BPF_ADD
, R3
, R2
),
1195 BPF_ALU64_REG(BPF_ADD
, R3
, R3
),
1196 BPF_ALU64_REG(BPF_ADD
, R3
, R4
),
1197 BPF_ALU64_REG(BPF_ADD
, R3
, R5
),
1198 BPF_ALU64_REG(BPF_ADD
, R3
, R6
),
1199 BPF_ALU64_REG(BPF_ADD
, R3
, R7
),
1200 BPF_ALU64_REG(BPF_ADD
, R3
, R8
),
1201 BPF_ALU64_REG(BPF_ADD
, R3
, R9
), /* R3 == 4063 */
1202 BPF_JMP_IMM(BPF_JEQ
, R3
, 4063, 1),
1204 BPF_ALU64_REG(BPF_ADD
, R4
, R0
),
1205 BPF_ALU64_REG(BPF_ADD
, R4
, R1
),
1206 BPF_ALU64_REG(BPF_ADD
, R4
, R2
),
1207 BPF_ALU64_REG(BPF_ADD
, R4
, R3
),
1208 BPF_ALU64_REG(BPF_ADD
, R4
, R4
),
1209 BPF_ALU64_REG(BPF_ADD
, R4
, R5
),
1210 BPF_ALU64_REG(BPF_ADD
, R4
, R6
),
1211 BPF_ALU64_REG(BPF_ADD
, R4
, R7
),
1212 BPF_ALU64_REG(BPF_ADD
, R4
, R8
),
1213 BPF_ALU64_REG(BPF_ADD
, R4
, R9
), /* R4 == 12177 */
1214 BPF_JMP_IMM(BPF_JEQ
, R4
, 12177, 1),
1216 BPF_ALU64_REG(BPF_ADD
, R5
, R0
),
1217 BPF_ALU64_REG(BPF_ADD
, R5
, R1
),
1218 BPF_ALU64_REG(BPF_ADD
, R5
, R2
),
1219 BPF_ALU64_REG(BPF_ADD
, R5
, R3
),
1220 BPF_ALU64_REG(BPF_ADD
, R5
, R4
),
1221 BPF_ALU64_REG(BPF_ADD
, R5
, R5
),
1222 BPF_ALU64_REG(BPF_ADD
, R5
, R6
),
1223 BPF_ALU64_REG(BPF_ADD
, R5
, R7
),
1224 BPF_ALU64_REG(BPF_ADD
, R5
, R8
),
1225 BPF_ALU64_REG(BPF_ADD
, R5
, R9
), /* R5 == 36518 */
1226 BPF_JMP_IMM(BPF_JEQ
, R5
, 36518, 1),
1228 BPF_ALU64_REG(BPF_ADD
, R6
, R0
),
1229 BPF_ALU64_REG(BPF_ADD
, R6
, R1
),
1230 BPF_ALU64_REG(BPF_ADD
, R6
, R2
),
1231 BPF_ALU64_REG(BPF_ADD
, R6
, R3
),
1232 BPF_ALU64_REG(BPF_ADD
, R6
, R4
),
1233 BPF_ALU64_REG(BPF_ADD
, R6
, R5
),
1234 BPF_ALU64_REG(BPF_ADD
, R6
, R6
),
1235 BPF_ALU64_REG(BPF_ADD
, R6
, R7
),
1236 BPF_ALU64_REG(BPF_ADD
, R6
, R8
),
1237 BPF_ALU64_REG(BPF_ADD
, R6
, R9
), /* R6 == 109540 */
1238 BPF_JMP_IMM(BPF_JEQ
, R6
, 109540, 1),
1240 BPF_ALU64_REG(BPF_ADD
, R7
, R0
),
1241 BPF_ALU64_REG(BPF_ADD
, R7
, R1
),
1242 BPF_ALU64_REG(BPF_ADD
, R7
, R2
),
1243 BPF_ALU64_REG(BPF_ADD
, R7
, R3
),
1244 BPF_ALU64_REG(BPF_ADD
, R7
, R4
),
1245 BPF_ALU64_REG(BPF_ADD
, R7
, R5
),
1246 BPF_ALU64_REG(BPF_ADD
, R7
, R6
),
1247 BPF_ALU64_REG(BPF_ADD
, R7
, R7
),
1248 BPF_ALU64_REG(BPF_ADD
, R7
, R8
),
1249 BPF_ALU64_REG(BPF_ADD
, R7
, R9
), /* R7 == 328605 */
1250 BPF_JMP_IMM(BPF_JEQ
, R7
, 328605, 1),
1252 BPF_ALU64_REG(BPF_ADD
, R8
, R0
),
1253 BPF_ALU64_REG(BPF_ADD
, R8
, R1
),
1254 BPF_ALU64_REG(BPF_ADD
, R8
, R2
),
1255 BPF_ALU64_REG(BPF_ADD
, R8
, R3
),
1256 BPF_ALU64_REG(BPF_ADD
, R8
, R4
),
1257 BPF_ALU64_REG(BPF_ADD
, R8
, R5
),
1258 BPF_ALU64_REG(BPF_ADD
, R8
, R6
),
1259 BPF_ALU64_REG(BPF_ADD
, R8
, R7
),
1260 BPF_ALU64_REG(BPF_ADD
, R8
, R8
),
1261 BPF_ALU64_REG(BPF_ADD
, R8
, R9
), /* R8 == 985799 */
1262 BPF_JMP_IMM(BPF_JEQ
, R8
, 985799, 1),
1264 BPF_ALU64_REG(BPF_ADD
, R9
, R0
),
1265 BPF_ALU64_REG(BPF_ADD
, R9
, R1
),
1266 BPF_ALU64_REG(BPF_ADD
, R9
, R2
),
1267 BPF_ALU64_REG(BPF_ADD
, R9
, R3
),
1268 BPF_ALU64_REG(BPF_ADD
, R9
, R4
),
1269 BPF_ALU64_REG(BPF_ADD
, R9
, R5
),
1270 BPF_ALU64_REG(BPF_ADD
, R9
, R6
),
1271 BPF_ALU64_REG(BPF_ADD
, R9
, R7
),
1272 BPF_ALU64_REG(BPF_ADD
, R9
, R8
),
1273 BPF_ALU64_REG(BPF_ADD
, R9
, R9
), /* R9 == 2957380 */
1274 BPF_ALU64_REG(BPF_MOV
, R0
, R9
),
1284 BPF_ALU32_IMM(BPF_MOV
, R0
, 20),
1285 BPF_ALU32_IMM(BPF_MOV
, R1
, 1),
1286 BPF_ALU32_IMM(BPF_MOV
, R2
, 2),
1287 BPF_ALU32_IMM(BPF_MOV
, R3
, 3),
1288 BPF_ALU32_IMM(BPF_MOV
, R4
, 4),
1289 BPF_ALU32_IMM(BPF_MOV
, R5
, 5),
1290 BPF_ALU32_IMM(BPF_MOV
, R6
, 6),
1291 BPF_ALU32_IMM(BPF_MOV
, R7
, 7),
1292 BPF_ALU32_IMM(BPF_MOV
, R8
, 8),
1293 BPF_ALU32_IMM(BPF_MOV
, R9
, 9),
1294 BPF_ALU64_IMM(BPF_ADD
, R1
, 10),
1295 BPF_ALU64_IMM(BPF_ADD
, R2
, 10),
1296 BPF_ALU64_IMM(BPF_ADD
, R3
, 10),
1297 BPF_ALU64_IMM(BPF_ADD
, R4
, 10),
1298 BPF_ALU64_IMM(BPF_ADD
, R5
, 10),
1299 BPF_ALU64_IMM(BPF_ADD
, R6
, 10),
1300 BPF_ALU64_IMM(BPF_ADD
, R7
, 10),
1301 BPF_ALU64_IMM(BPF_ADD
, R8
, 10),
1302 BPF_ALU64_IMM(BPF_ADD
, R9
, 10),
1303 BPF_ALU32_REG(BPF_ADD
, R0
, R1
),
1304 BPF_ALU32_REG(BPF_ADD
, R0
, R2
),
1305 BPF_ALU32_REG(BPF_ADD
, R0
, R3
),
1306 BPF_ALU32_REG(BPF_ADD
, R0
, R4
),
1307 BPF_ALU32_REG(BPF_ADD
, R0
, R5
),
1308 BPF_ALU32_REG(BPF_ADD
, R0
, R6
),
1309 BPF_ALU32_REG(BPF_ADD
, R0
, R7
),
1310 BPF_ALU32_REG(BPF_ADD
, R0
, R8
),
1311 BPF_ALU32_REG(BPF_ADD
, R0
, R9
), /* R0 == 155 */
1312 BPF_JMP_IMM(BPF_JEQ
, R0
, 155, 1),
1314 BPF_ALU32_REG(BPF_ADD
, R1
, R0
),
1315 BPF_ALU32_REG(BPF_ADD
, R1
, R1
),
1316 BPF_ALU32_REG(BPF_ADD
, R1
, R2
),
1317 BPF_ALU32_REG(BPF_ADD
, R1
, R3
),
1318 BPF_ALU32_REG(BPF_ADD
, R1
, R4
),
1319 BPF_ALU32_REG(BPF_ADD
, R1
, R5
),
1320 BPF_ALU32_REG(BPF_ADD
, R1
, R6
),
1321 BPF_ALU32_REG(BPF_ADD
, R1
, R7
),
1322 BPF_ALU32_REG(BPF_ADD
, R1
, R8
),
1323 BPF_ALU32_REG(BPF_ADD
, R1
, R9
), /* R1 == 456 */
1324 BPF_JMP_IMM(BPF_JEQ
, R1
, 456, 1),
1326 BPF_ALU32_REG(BPF_ADD
, R2
, R0
),
1327 BPF_ALU32_REG(BPF_ADD
, R2
, R1
),
1328 BPF_ALU32_REG(BPF_ADD
, R2
, R2
),
1329 BPF_ALU32_REG(BPF_ADD
, R2
, R3
),
1330 BPF_ALU32_REG(BPF_ADD
, R2
, R4
),
1331 BPF_ALU32_REG(BPF_ADD
, R2
, R5
),
1332 BPF_ALU32_REG(BPF_ADD
, R2
, R6
),
1333 BPF_ALU32_REG(BPF_ADD
, R2
, R7
),
1334 BPF_ALU32_REG(BPF_ADD
, R2
, R8
),
1335 BPF_ALU32_REG(BPF_ADD
, R2
, R9
), /* R2 == 1358 */
1336 BPF_JMP_IMM(BPF_JEQ
, R2
, 1358, 1),
1338 BPF_ALU32_REG(BPF_ADD
, R3
, R0
),
1339 BPF_ALU32_REG(BPF_ADD
, R3
, R1
),
1340 BPF_ALU32_REG(BPF_ADD
, R3
, R2
),
1341 BPF_ALU32_REG(BPF_ADD
, R3
, R3
),
1342 BPF_ALU32_REG(BPF_ADD
, R3
, R4
),
1343 BPF_ALU32_REG(BPF_ADD
, R3
, R5
),
1344 BPF_ALU32_REG(BPF_ADD
, R3
, R6
),
1345 BPF_ALU32_REG(BPF_ADD
, R3
, R7
),
1346 BPF_ALU32_REG(BPF_ADD
, R3
, R8
),
1347 BPF_ALU32_REG(BPF_ADD
, R3
, R9
), /* R3 == 4063 */
1348 BPF_JMP_IMM(BPF_JEQ
, R3
, 4063, 1),
1350 BPF_ALU32_REG(BPF_ADD
, R4
, R0
),
1351 BPF_ALU32_REG(BPF_ADD
, R4
, R1
),
1352 BPF_ALU32_REG(BPF_ADD
, R4
, R2
),
1353 BPF_ALU32_REG(BPF_ADD
, R4
, R3
),
1354 BPF_ALU32_REG(BPF_ADD
, R4
, R4
),
1355 BPF_ALU32_REG(BPF_ADD
, R4
, R5
),
1356 BPF_ALU32_REG(BPF_ADD
, R4
, R6
),
1357 BPF_ALU32_REG(BPF_ADD
, R4
, R7
),
1358 BPF_ALU32_REG(BPF_ADD
, R4
, R8
),
1359 BPF_ALU32_REG(BPF_ADD
, R4
, R9
), /* R4 == 12177 */
1360 BPF_JMP_IMM(BPF_JEQ
, R4
, 12177, 1),
1362 BPF_ALU32_REG(BPF_ADD
, R5
, R0
),
1363 BPF_ALU32_REG(BPF_ADD
, R5
, R1
),
1364 BPF_ALU32_REG(BPF_ADD
, R5
, R2
),
1365 BPF_ALU32_REG(BPF_ADD
, R5
, R3
),
1366 BPF_ALU32_REG(BPF_ADD
, R5
, R4
),
1367 BPF_ALU32_REG(BPF_ADD
, R5
, R5
),
1368 BPF_ALU32_REG(BPF_ADD
, R5
, R6
),
1369 BPF_ALU32_REG(BPF_ADD
, R5
, R7
),
1370 BPF_ALU32_REG(BPF_ADD
, R5
, R8
),
1371 BPF_ALU32_REG(BPF_ADD
, R5
, R9
), /* R5 == 36518 */
1372 BPF_JMP_IMM(BPF_JEQ
, R5
, 36518, 1),
1374 BPF_ALU32_REG(BPF_ADD
, R6
, R0
),
1375 BPF_ALU32_REG(BPF_ADD
, R6
, R1
),
1376 BPF_ALU32_REG(BPF_ADD
, R6
, R2
),
1377 BPF_ALU32_REG(BPF_ADD
, R6
, R3
),
1378 BPF_ALU32_REG(BPF_ADD
, R6
, R4
),
1379 BPF_ALU32_REG(BPF_ADD
, R6
, R5
),
1380 BPF_ALU32_REG(BPF_ADD
, R6
, R6
),
1381 BPF_ALU32_REG(BPF_ADD
, R6
, R7
),
1382 BPF_ALU32_REG(BPF_ADD
, R6
, R8
),
1383 BPF_ALU32_REG(BPF_ADD
, R6
, R9
), /* R6 == 109540 */
1384 BPF_JMP_IMM(BPF_JEQ
, R6
, 109540, 1),
1386 BPF_ALU32_REG(BPF_ADD
, R7
, R0
),
1387 BPF_ALU32_REG(BPF_ADD
, R7
, R1
),
1388 BPF_ALU32_REG(BPF_ADD
, R7
, R2
),
1389 BPF_ALU32_REG(BPF_ADD
, R7
, R3
),
1390 BPF_ALU32_REG(BPF_ADD
, R7
, R4
),
1391 BPF_ALU32_REG(BPF_ADD
, R7
, R5
),
1392 BPF_ALU32_REG(BPF_ADD
, R7
, R6
),
1393 BPF_ALU32_REG(BPF_ADD
, R7
, R7
),
1394 BPF_ALU32_REG(BPF_ADD
, R7
, R8
),
1395 BPF_ALU32_REG(BPF_ADD
, R7
, R9
), /* R7 == 328605 */
1396 BPF_JMP_IMM(BPF_JEQ
, R7
, 328605, 1),
1398 BPF_ALU32_REG(BPF_ADD
, R8
, R0
),
1399 BPF_ALU32_REG(BPF_ADD
, R8
, R1
),
1400 BPF_ALU32_REG(BPF_ADD
, R8
, R2
),
1401 BPF_ALU32_REG(BPF_ADD
, R8
, R3
),
1402 BPF_ALU32_REG(BPF_ADD
, R8
, R4
),
1403 BPF_ALU32_REG(BPF_ADD
, R8
, R5
),
1404 BPF_ALU32_REG(BPF_ADD
, R8
, R6
),
1405 BPF_ALU32_REG(BPF_ADD
, R8
, R7
),
1406 BPF_ALU32_REG(BPF_ADD
, R8
, R8
),
1407 BPF_ALU32_REG(BPF_ADD
, R8
, R9
), /* R8 == 985799 */
1408 BPF_JMP_IMM(BPF_JEQ
, R8
, 985799, 1),
1410 BPF_ALU32_REG(BPF_ADD
, R9
, R0
),
1411 BPF_ALU32_REG(BPF_ADD
, R9
, R1
),
1412 BPF_ALU32_REG(BPF_ADD
, R9
, R2
),
1413 BPF_ALU32_REG(BPF_ADD
, R9
, R3
),
1414 BPF_ALU32_REG(BPF_ADD
, R9
, R4
),
1415 BPF_ALU32_REG(BPF_ADD
, R9
, R5
),
1416 BPF_ALU32_REG(BPF_ADD
, R9
, R6
),
1417 BPF_ALU32_REG(BPF_ADD
, R9
, R7
),
1418 BPF_ALU32_REG(BPF_ADD
, R9
, R8
),
1419 BPF_ALU32_REG(BPF_ADD
, R9
, R9
), /* R9 == 2957380 */
1420 BPF_ALU32_REG(BPF_MOV
, R0
, R9
),
1427 { /* Mainly checking JIT here. */
1430 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
1431 BPF_ALU64_IMM(BPF_MOV
, R1
, 1),
1432 BPF_ALU64_IMM(BPF_MOV
, R2
, 2),
1433 BPF_ALU64_IMM(BPF_MOV
, R3
, 3),
1434 BPF_ALU64_IMM(BPF_MOV
, R4
, 4),
1435 BPF_ALU64_IMM(BPF_MOV
, R5
, 5),
1436 BPF_ALU64_IMM(BPF_MOV
, R6
, 6),
1437 BPF_ALU64_IMM(BPF_MOV
, R7
, 7),
1438 BPF_ALU64_IMM(BPF_MOV
, R8
, 8),
1439 BPF_ALU64_IMM(BPF_MOV
, R9
, 9),
1440 BPF_ALU64_REG(BPF_SUB
, R0
, R0
),
1441 BPF_ALU64_REG(BPF_SUB
, R0
, R1
),
1442 BPF_ALU64_REG(BPF_SUB
, R0
, R2
),
1443 BPF_ALU64_REG(BPF_SUB
, R0
, R3
),
1444 BPF_ALU64_REG(BPF_SUB
, R0
, R4
),
1445 BPF_ALU64_REG(BPF_SUB
, R0
, R5
),
1446 BPF_ALU64_REG(BPF_SUB
, R0
, R6
),
1447 BPF_ALU64_REG(BPF_SUB
, R0
, R7
),
1448 BPF_ALU64_REG(BPF_SUB
, R0
, R8
),
1449 BPF_ALU64_REG(BPF_SUB
, R0
, R9
),
1450 BPF_ALU64_IMM(BPF_SUB
, R0
, 10),
1451 BPF_JMP_IMM(BPF_JEQ
, R0
, -55, 1),
1453 BPF_ALU64_REG(BPF_SUB
, R1
, R0
),
1454 BPF_ALU64_REG(BPF_SUB
, R1
, R2
),
1455 BPF_ALU64_REG(BPF_SUB
, R1
, R3
),
1456 BPF_ALU64_REG(BPF_SUB
, R1
, R4
),
1457 BPF_ALU64_REG(BPF_SUB
, R1
, R5
),
1458 BPF_ALU64_REG(BPF_SUB
, R1
, R6
),
1459 BPF_ALU64_REG(BPF_SUB
, R1
, R7
),
1460 BPF_ALU64_REG(BPF_SUB
, R1
, R8
),
1461 BPF_ALU64_REG(BPF_SUB
, R1
, R9
),
1462 BPF_ALU64_IMM(BPF_SUB
, R1
, 10),
1463 BPF_ALU64_REG(BPF_SUB
, R2
, R0
),
1464 BPF_ALU64_REG(BPF_SUB
, R2
, R1
),
1465 BPF_ALU64_REG(BPF_SUB
, R2
, R3
),
1466 BPF_ALU64_REG(BPF_SUB
, R2
, R4
),
1467 BPF_ALU64_REG(BPF_SUB
, R2
, R5
),
1468 BPF_ALU64_REG(BPF_SUB
, R2
, R6
),
1469 BPF_ALU64_REG(BPF_SUB
, R2
, R7
),
1470 BPF_ALU64_REG(BPF_SUB
, R2
, R8
),
1471 BPF_ALU64_REG(BPF_SUB
, R2
, R9
),
1472 BPF_ALU64_IMM(BPF_SUB
, R2
, 10),
1473 BPF_ALU64_REG(BPF_SUB
, R3
, R0
),
1474 BPF_ALU64_REG(BPF_SUB
, R3
, R1
),
1475 BPF_ALU64_REG(BPF_SUB
, R3
, R2
),
1476 BPF_ALU64_REG(BPF_SUB
, R3
, R4
),
1477 BPF_ALU64_REG(BPF_SUB
, R3
, R5
),
1478 BPF_ALU64_REG(BPF_SUB
, R3
, R6
),
1479 BPF_ALU64_REG(BPF_SUB
, R3
, R7
),
1480 BPF_ALU64_REG(BPF_SUB
, R3
, R8
),
1481 BPF_ALU64_REG(BPF_SUB
, R3
, R9
),
1482 BPF_ALU64_IMM(BPF_SUB
, R3
, 10),
1483 BPF_ALU64_REG(BPF_SUB
, R4
, R0
),
1484 BPF_ALU64_REG(BPF_SUB
, R4
, R1
),
1485 BPF_ALU64_REG(BPF_SUB
, R4
, R2
),
1486 BPF_ALU64_REG(BPF_SUB
, R4
, R3
),
1487 BPF_ALU64_REG(BPF_SUB
, R4
, R5
),
1488 BPF_ALU64_REG(BPF_SUB
, R4
, R6
),
1489 BPF_ALU64_REG(BPF_SUB
, R4
, R7
),
1490 BPF_ALU64_REG(BPF_SUB
, R4
, R8
),
1491 BPF_ALU64_REG(BPF_SUB
, R4
, R9
),
1492 BPF_ALU64_IMM(BPF_SUB
, R4
, 10),
1493 BPF_ALU64_REG(BPF_SUB
, R5
, R0
),
1494 BPF_ALU64_REG(BPF_SUB
, R5
, R1
),
1495 BPF_ALU64_REG(BPF_SUB
, R5
, R2
),
1496 BPF_ALU64_REG(BPF_SUB
, R5
, R3
),
1497 BPF_ALU64_REG(BPF_SUB
, R5
, R4
),
1498 BPF_ALU64_REG(BPF_SUB
, R5
, R6
),
1499 BPF_ALU64_REG(BPF_SUB
, R5
, R7
),
1500 BPF_ALU64_REG(BPF_SUB
, R5
, R8
),
1501 BPF_ALU64_REG(BPF_SUB
, R5
, R9
),
1502 BPF_ALU64_IMM(BPF_SUB
, R5
, 10),
1503 BPF_ALU64_REG(BPF_SUB
, R6
, R0
),
1504 BPF_ALU64_REG(BPF_SUB
, R6
, R1
),
1505 BPF_ALU64_REG(BPF_SUB
, R6
, R2
),
1506 BPF_ALU64_REG(BPF_SUB
, R6
, R3
),
1507 BPF_ALU64_REG(BPF_SUB
, R6
, R4
),
1508 BPF_ALU64_REG(BPF_SUB
, R6
, R5
),
1509 BPF_ALU64_REG(BPF_SUB
, R6
, R7
),
1510 BPF_ALU64_REG(BPF_SUB
, R6
, R8
),
1511 BPF_ALU64_REG(BPF_SUB
, R6
, R9
),
1512 BPF_ALU64_IMM(BPF_SUB
, R6
, 10),
1513 BPF_ALU64_REG(BPF_SUB
, R7
, R0
),
1514 BPF_ALU64_REG(BPF_SUB
, R7
, R1
),
1515 BPF_ALU64_REG(BPF_SUB
, R7
, R2
),
1516 BPF_ALU64_REG(BPF_SUB
, R7
, R3
),
1517 BPF_ALU64_REG(BPF_SUB
, R7
, R4
),
1518 BPF_ALU64_REG(BPF_SUB
, R7
, R5
),
1519 BPF_ALU64_REG(BPF_SUB
, R7
, R6
),
1520 BPF_ALU64_REG(BPF_SUB
, R7
, R8
),
1521 BPF_ALU64_REG(BPF_SUB
, R7
, R9
),
1522 BPF_ALU64_IMM(BPF_SUB
, R7
, 10),
1523 BPF_ALU64_REG(BPF_SUB
, R8
, R0
),
1524 BPF_ALU64_REG(BPF_SUB
, R8
, R1
),
1525 BPF_ALU64_REG(BPF_SUB
, R8
, R2
),
1526 BPF_ALU64_REG(BPF_SUB
, R8
, R3
),
1527 BPF_ALU64_REG(BPF_SUB
, R8
, R4
),
1528 BPF_ALU64_REG(BPF_SUB
, R8
, R5
),
1529 BPF_ALU64_REG(BPF_SUB
, R8
, R6
),
1530 BPF_ALU64_REG(BPF_SUB
, R8
, R7
),
1531 BPF_ALU64_REG(BPF_SUB
, R8
, R9
),
1532 BPF_ALU64_IMM(BPF_SUB
, R8
, 10),
1533 BPF_ALU64_REG(BPF_SUB
, R9
, R0
),
1534 BPF_ALU64_REG(BPF_SUB
, R9
, R1
),
1535 BPF_ALU64_REG(BPF_SUB
, R9
, R2
),
1536 BPF_ALU64_REG(BPF_SUB
, R9
, R3
),
1537 BPF_ALU64_REG(BPF_SUB
, R9
, R4
),
1538 BPF_ALU64_REG(BPF_SUB
, R9
, R5
),
1539 BPF_ALU64_REG(BPF_SUB
, R9
, R6
),
1540 BPF_ALU64_REG(BPF_SUB
, R9
, R7
),
1541 BPF_ALU64_REG(BPF_SUB
, R9
, R8
),
1542 BPF_ALU64_IMM(BPF_SUB
, R9
, 10),
1543 BPF_ALU64_IMM(BPF_SUB
, R0
, 10),
1544 BPF_ALU64_IMM(BPF_NEG
, R0
, 0),
1545 BPF_ALU64_REG(BPF_SUB
, R0
, R1
),
1546 BPF_ALU64_REG(BPF_SUB
, R0
, R2
),
1547 BPF_ALU64_REG(BPF_SUB
, R0
, R3
),
1548 BPF_ALU64_REG(BPF_SUB
, R0
, R4
),
1549 BPF_ALU64_REG(BPF_SUB
, R0
, R5
),
1550 BPF_ALU64_REG(BPF_SUB
, R0
, R6
),
1551 BPF_ALU64_REG(BPF_SUB
, R0
, R7
),
1552 BPF_ALU64_REG(BPF_SUB
, R0
, R8
),
1553 BPF_ALU64_REG(BPF_SUB
, R0
, R9
),
1560 { /* Mainly checking JIT here. */
1563 BPF_ALU64_REG(BPF_SUB
, R0
, R0
),
1564 BPF_ALU64_REG(BPF_XOR
, R1
, R1
),
1565 BPF_JMP_REG(BPF_JEQ
, R0
, R1
, 1),
1567 BPF_ALU64_IMM(BPF_MOV
, R0
, 10),
1568 BPF_ALU64_IMM(BPF_MOV
, R1
, -1),
1569 BPF_ALU64_REG(BPF_SUB
, R1
, R1
),
1570 BPF_ALU64_REG(BPF_XOR
, R2
, R2
),
1571 BPF_JMP_REG(BPF_JEQ
, R1
, R2
, 1),
1573 BPF_ALU64_REG(BPF_SUB
, R2
, R2
),
1574 BPF_ALU64_REG(BPF_XOR
, R3
, R3
),
1575 BPF_ALU64_IMM(BPF_MOV
, R0
, 10),
1576 BPF_ALU64_IMM(BPF_MOV
, R1
, -1),
1577 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 1),
1579 BPF_ALU64_REG(BPF_SUB
, R3
, R3
),
1580 BPF_ALU64_REG(BPF_XOR
, R4
, R4
),
1581 BPF_ALU64_IMM(BPF_MOV
, R2
, 1),
1582 BPF_ALU64_IMM(BPF_MOV
, R5
, -1),
1583 BPF_JMP_REG(BPF_JEQ
, R3
, R4
, 1),
1585 BPF_ALU64_REG(BPF_SUB
, R4
, R4
),
1586 BPF_ALU64_REG(BPF_XOR
, R5
, R5
),
1587 BPF_ALU64_IMM(BPF_MOV
, R3
, 1),
1588 BPF_ALU64_IMM(BPF_MOV
, R7
, -1),
1589 BPF_JMP_REG(BPF_JEQ
, R5
, R4
, 1),
1591 BPF_ALU64_IMM(BPF_MOV
, R5
, 1),
1592 BPF_ALU64_REG(BPF_SUB
, R5
, R5
),
1593 BPF_ALU64_REG(BPF_XOR
, R6
, R6
),
1594 BPF_ALU64_IMM(BPF_MOV
, R1
, 1),
1595 BPF_ALU64_IMM(BPF_MOV
, R8
, -1),
1596 BPF_JMP_REG(BPF_JEQ
, R5
, R6
, 1),
1598 BPF_ALU64_REG(BPF_SUB
, R6
, R6
),
1599 BPF_ALU64_REG(BPF_XOR
, R7
, R7
),
1600 BPF_JMP_REG(BPF_JEQ
, R7
, R6
, 1),
1602 BPF_ALU64_REG(BPF_SUB
, R7
, R7
),
1603 BPF_ALU64_REG(BPF_XOR
, R8
, R8
),
1604 BPF_JMP_REG(BPF_JEQ
, R7
, R8
, 1),
1606 BPF_ALU64_REG(BPF_SUB
, R8
, R8
),
1607 BPF_ALU64_REG(BPF_XOR
, R9
, R9
),
1608 BPF_JMP_REG(BPF_JEQ
, R9
, R8
, 1),
1610 BPF_ALU64_REG(BPF_SUB
, R9
, R9
),
1611 BPF_ALU64_REG(BPF_XOR
, R0
, R0
),
1612 BPF_JMP_REG(BPF_JEQ
, R9
, R0
, 1),
1614 BPF_ALU64_REG(BPF_SUB
, R1
, R1
),
1615 BPF_ALU64_REG(BPF_XOR
, R0
, R0
),
1616 BPF_JMP_REG(BPF_JEQ
, R9
, R0
, 2),
1617 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
1619 BPF_ALU64_IMM(BPF_MOV
, R0
, 1),
1626 { /* Mainly checking JIT here. */
1629 BPF_ALU64_IMM(BPF_MOV
, R0
, 11),
1630 BPF_ALU64_IMM(BPF_MOV
, R1
, 1),
1631 BPF_ALU64_IMM(BPF_MOV
, R2
, 2),
1632 BPF_ALU64_IMM(BPF_MOV
, R3
, 3),
1633 BPF_ALU64_IMM(BPF_MOV
, R4
, 4),
1634 BPF_ALU64_IMM(BPF_MOV
, R5
, 5),
1635 BPF_ALU64_IMM(BPF_MOV
, R6
, 6),
1636 BPF_ALU64_IMM(BPF_MOV
, R7
, 7),
1637 BPF_ALU64_IMM(BPF_MOV
, R8
, 8),
1638 BPF_ALU64_IMM(BPF_MOV
, R9
, 9),
1639 BPF_ALU64_REG(BPF_MUL
, R0
, R0
),
1640 BPF_ALU64_REG(BPF_MUL
, R0
, R1
),
1641 BPF_ALU64_REG(BPF_MUL
, R0
, R2
),
1642 BPF_ALU64_REG(BPF_MUL
, R0
, R3
),
1643 BPF_ALU64_REG(BPF_MUL
, R0
, R4
),
1644 BPF_ALU64_REG(BPF_MUL
, R0
, R5
),
1645 BPF_ALU64_REG(BPF_MUL
, R0
, R6
),
1646 BPF_ALU64_REG(BPF_MUL
, R0
, R7
),
1647 BPF_ALU64_REG(BPF_MUL
, R0
, R8
),
1648 BPF_ALU64_REG(BPF_MUL
, R0
, R9
),
1649 BPF_ALU64_IMM(BPF_MUL
, R0
, 10),
1650 BPF_JMP_IMM(BPF_JEQ
, R0
, 439084800, 1),
1652 BPF_ALU64_REG(BPF_MUL
, R1
, R0
),
1653 BPF_ALU64_REG(BPF_MUL
, R1
, R2
),
1654 BPF_ALU64_REG(BPF_MUL
, R1
, R3
),
1655 BPF_ALU64_REG(BPF_MUL
, R1
, R4
),
1656 BPF_ALU64_REG(BPF_MUL
, R1
, R5
),
1657 BPF_ALU64_REG(BPF_MUL
, R1
, R6
),
1658 BPF_ALU64_REG(BPF_MUL
, R1
, R7
),
1659 BPF_ALU64_REG(BPF_MUL
, R1
, R8
),
1660 BPF_ALU64_REG(BPF_MUL
, R1
, R9
),
1661 BPF_ALU64_IMM(BPF_MUL
, R1
, 10),
1662 BPF_ALU64_REG(BPF_MOV
, R2
, R1
),
1663 BPF_ALU64_IMM(BPF_RSH
, R2
, 32),
1664 BPF_JMP_IMM(BPF_JEQ
, R2
, 0x5a924, 1),
1666 BPF_ALU64_IMM(BPF_LSH
, R1
, 32),
1667 BPF_ALU64_IMM(BPF_ARSH
, R1
, 32),
1668 BPF_JMP_IMM(BPF_JEQ
, R1
, 0xebb90000, 1),
1670 BPF_ALU64_REG(BPF_MUL
, R2
, R0
),
1671 BPF_ALU64_REG(BPF_MUL
, R2
, R1
),
1672 BPF_ALU64_REG(BPF_MUL
, R2
, R3
),
1673 BPF_ALU64_REG(BPF_MUL
, R2
, R4
),
1674 BPF_ALU64_REG(BPF_MUL
, R2
, R5
),
1675 BPF_ALU64_REG(BPF_MUL
, R2
, R6
),
1676 BPF_ALU64_REG(BPF_MUL
, R2
, R7
),
1677 BPF_ALU64_REG(BPF_MUL
, R2
, R8
),
1678 BPF_ALU64_REG(BPF_MUL
, R2
, R9
),
1679 BPF_ALU64_IMM(BPF_MUL
, R2
, 10),
1680 BPF_ALU64_IMM(BPF_RSH
, R2
, 32),
1681 BPF_ALU64_REG(BPF_MOV
, R0
, R2
),
1686 { { 0, 0x35d97ef2 } }
1688 { /* Mainly checking JIT here. */
1691 BPF_LD_IMM64(R0
, 0xffffffffffffffffLL
),
1692 BPF_MOV64_REG(R1
, R0
),
1693 BPF_MOV64_REG(R2
, R1
),
1694 BPF_MOV64_REG(R3
, R2
),
1695 BPF_MOV64_REG(R4
, R3
),
1696 BPF_MOV64_REG(R5
, R4
),
1697 BPF_MOV64_REG(R6
, R5
),
1698 BPF_MOV64_REG(R7
, R6
),
1699 BPF_MOV64_REG(R8
, R7
),
1700 BPF_MOV64_REG(R9
, R8
),
1701 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
1702 BPF_ALU64_IMM(BPF_MOV
, R1
, 0),
1703 BPF_ALU64_IMM(BPF_MOV
, R2
, 0),
1704 BPF_ALU64_IMM(BPF_MOV
, R3
, 0),
1705 BPF_ALU64_IMM(BPF_MOV
, R4
, 0),
1706 BPF_ALU64_IMM(BPF_MOV
, R5
, 0),
1707 BPF_ALU64_IMM(BPF_MOV
, R6
, 0),
1708 BPF_ALU64_IMM(BPF_MOV
, R7
, 0),
1709 BPF_ALU64_IMM(BPF_MOV
, R8
, 0),
1710 BPF_ALU64_IMM(BPF_MOV
, R9
, 0),
1711 BPF_ALU64_REG(BPF_ADD
, R0
, R0
),
1712 BPF_ALU64_REG(BPF_ADD
, R0
, R1
),
1713 BPF_ALU64_REG(BPF_ADD
, R0
, R2
),
1714 BPF_ALU64_REG(BPF_ADD
, R0
, R3
),
1715 BPF_ALU64_REG(BPF_ADD
, R0
, R4
),
1716 BPF_ALU64_REG(BPF_ADD
, R0
, R5
),
1717 BPF_ALU64_REG(BPF_ADD
, R0
, R6
),
1718 BPF_ALU64_REG(BPF_ADD
, R0
, R7
),
1719 BPF_ALU64_REG(BPF_ADD
, R0
, R8
),
1720 BPF_ALU64_REG(BPF_ADD
, R0
, R9
),
1721 BPF_ALU64_IMM(BPF_ADD
, R0
, 0xfefe),
1728 { /* Mainly checking JIT here. */
1731 BPF_LD_IMM64(R0
, 0xffffffffffffffffLL
),
1732 BPF_MOV64_REG(R1
, R0
),
1733 BPF_MOV64_REG(R2
, R1
),
1734 BPF_MOV64_REG(R3
, R2
),
1735 BPF_MOV64_REG(R4
, R3
),
1736 BPF_MOV64_REG(R5
, R4
),
1737 BPF_MOV64_REG(R6
, R5
),
1738 BPF_MOV64_REG(R7
, R6
),
1739 BPF_MOV64_REG(R8
, R7
),
1740 BPF_MOV64_REG(R9
, R8
),
1741 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
1742 BPF_ALU32_IMM(BPF_MOV
, R1
, 0),
1743 BPF_ALU32_IMM(BPF_MOV
, R2
, 0),
1744 BPF_ALU32_IMM(BPF_MOV
, R3
, 0),
1745 BPF_ALU32_IMM(BPF_MOV
, R4
, 0),
1746 BPF_ALU32_IMM(BPF_MOV
, R5
, 0),
1747 BPF_ALU32_IMM(BPF_MOV
, R6
, 0),
1748 BPF_ALU32_IMM(BPF_MOV
, R7
, 0),
1749 BPF_ALU32_IMM(BPF_MOV
, R8
, 0),
1750 BPF_ALU32_IMM(BPF_MOV
, R9
, 0),
1751 BPF_ALU64_REG(BPF_ADD
, R0
, R0
),
1752 BPF_ALU64_REG(BPF_ADD
, R0
, R1
),
1753 BPF_ALU64_REG(BPF_ADD
, R0
, R2
),
1754 BPF_ALU64_REG(BPF_ADD
, R0
, R3
),
1755 BPF_ALU64_REG(BPF_ADD
, R0
, R4
),
1756 BPF_ALU64_REG(BPF_ADD
, R0
, R5
),
1757 BPF_ALU64_REG(BPF_ADD
, R0
, R6
),
1758 BPF_ALU64_REG(BPF_ADD
, R0
, R7
),
1759 BPF_ALU64_REG(BPF_ADD
, R0
, R8
),
1760 BPF_ALU64_REG(BPF_ADD
, R0
, R9
),
1761 BPF_ALU64_IMM(BPF_ADD
, R0
, 0xfefe),
1768 { /* Mainly checking JIT here. */
1771 BPF_LD_IMM64(R0
, 0xffffffffffffffffLL
),
1772 BPF_MOV64_REG(R1
, R0
),
1773 BPF_MOV64_REG(R2
, R1
),
1774 BPF_MOV64_REG(R3
, R2
),
1775 BPF_MOV64_REG(R4
, R3
),
1776 BPF_MOV64_REG(R5
, R4
),
1777 BPF_MOV64_REG(R6
, R5
),
1778 BPF_MOV64_REG(R7
, R6
),
1779 BPF_MOV64_REG(R8
, R7
),
1780 BPF_MOV64_REG(R9
, R8
),
1781 BPF_LD_IMM64(R0
, 0x0LL
),
1782 BPF_LD_IMM64(R1
, 0x0LL
),
1783 BPF_LD_IMM64(R2
, 0x0LL
),
1784 BPF_LD_IMM64(R3
, 0x0LL
),
1785 BPF_LD_IMM64(R4
, 0x0LL
),
1786 BPF_LD_IMM64(R5
, 0x0LL
),
1787 BPF_LD_IMM64(R6
, 0x0LL
),
1788 BPF_LD_IMM64(R7
, 0x0LL
),
1789 BPF_LD_IMM64(R8
, 0x0LL
),
1790 BPF_LD_IMM64(R9
, 0x0LL
),
1791 BPF_ALU64_REG(BPF_ADD
, R0
, R0
),
1792 BPF_ALU64_REG(BPF_ADD
, R0
, R1
),
1793 BPF_ALU64_REG(BPF_ADD
, R0
, R2
),
1794 BPF_ALU64_REG(BPF_ADD
, R0
, R3
),
1795 BPF_ALU64_REG(BPF_ADD
, R0
, R4
),
1796 BPF_ALU64_REG(BPF_ADD
, R0
, R5
),
1797 BPF_ALU64_REG(BPF_ADD
, R0
, R6
),
1798 BPF_ALU64_REG(BPF_ADD
, R0
, R7
),
1799 BPF_ALU64_REG(BPF_ADD
, R0
, R8
),
1800 BPF_ALU64_REG(BPF_ADD
, R0
, R9
),
1801 BPF_ALU64_IMM(BPF_ADD
, R0
, 0xfefe),
1811 BPF_ALU64_IMM(BPF_MOV
, R0
, 11),
1812 BPF_ALU64_IMM(BPF_ADD
, R0
, -1),
1813 BPF_ALU64_IMM(BPF_MOV
, R2
, 2),
1814 BPF_ALU64_IMM(BPF_XOR
, R2
, 3),
1815 BPF_ALU64_REG(BPF_DIV
, R0
, R2
),
1816 BPF_JMP_IMM(BPF_JEQ
, R0
, 10, 1),
1818 BPF_ALU64_IMM(BPF_MOD
, R0
, 3),
1819 BPF_JMP_IMM(BPF_JEQ
, R0
, 1, 1),
1821 BPF_ALU64_IMM(BPF_MOV
, R0
, -1),
1829 "INT: shifts by register",
1831 BPF_MOV64_IMM(R0
, -1234),
1832 BPF_MOV64_IMM(R1
, 1),
1833 BPF_ALU32_REG(BPF_RSH
, R0
, R1
),
1834 BPF_JMP_IMM(BPF_JEQ
, R0
, 0x7ffffd97, 1),
1836 BPF_MOV64_IMM(R2
, 1),
1837 BPF_ALU64_REG(BPF_LSH
, R0
, R2
),
1838 BPF_MOV32_IMM(R4
, -1234),
1839 BPF_JMP_REG(BPF_JEQ
, R0
, R4
, 1),
1841 BPF_ALU64_IMM(BPF_AND
, R4
, 63),
1842 BPF_ALU64_REG(BPF_LSH
, R0
, R4
), /* R0 <= 46 */
1843 BPF_MOV64_IMM(R3
, 47),
1844 BPF_ALU64_REG(BPF_ARSH
, R0
, R3
),
1845 BPF_JMP_IMM(BPF_JEQ
, R0
, -617, 1),
1847 BPF_MOV64_IMM(R2
, 1),
1848 BPF_ALU64_REG(BPF_LSH
, R4
, R2
), /* R4 = 46 << 1 */
1849 BPF_JMP_IMM(BPF_JEQ
, R4
, 92, 1),
1851 BPF_MOV64_IMM(R4
, 4),
1852 BPF_ALU64_REG(BPF_LSH
, R4
, R4
), /* R4 = 4 << 4 */
1853 BPF_JMP_IMM(BPF_JEQ
, R4
, 64, 1),
1855 BPF_MOV64_IMM(R4
, 5),
1856 BPF_ALU32_REG(BPF_LSH
, R4
, R4
), /* R4 = 5 << 5 */
1857 BPF_JMP_IMM(BPF_JEQ
, R4
, 160, 1),
1859 BPF_MOV64_IMM(R0
, -1),
1869 BPF_ALU64_REG(BPF_MOV
, R6
, R1
),
1870 BPF_LD_ABS(BPF_B
, 3),
1871 BPF_ALU64_IMM(BPF_MOV
, R2
, 2),
1872 BPF_ALU32_REG(BPF_DIV
, R0
, R2
),
1873 BPF_ALU64_REG(BPF_MOV
, R8
, R0
),
1874 BPF_LD_ABS(BPF_B
, 4),
1875 BPF_ALU64_REG(BPF_ADD
, R8
, R0
),
1876 BPF_LD_IND(BPF_B
, R8
, -70),
1880 { 10, 20, 30, 40, 50 },
1881 { { 4, 0 }, { 5, 10 } }
1886 BPF_ALU64_REG(BPF_MOV
, R6
, R1
),
1887 BPF_ALU64_IMM(BPF_MOV
, R7
, 0),
1888 BPF_LD_ABS(BPF_B
, 3),
1889 BPF_ALU32_REG(BPF_DIV
, R0
, R7
),
1893 { 10, 20, 30, 40, 50 },
1894 { { 3, 0 }, { 4, 0 } }
1897 "check: missing ret",
1899 BPF_STMT(BPF_LD
| BPF_IMM
, 1),
1901 CLASSIC
| FLAG_NO_DATA
| FLAG_EXPECTED_FAIL
,
1908 BPF_STMT(BPF_ALU
| BPF_DIV
| BPF_K
, 0),
1909 BPF_STMT(BPF_RET
| BPF_K
, 0)
1911 CLASSIC
| FLAG_NO_DATA
| FLAG_EXPECTED_FAIL
,
1916 "check: unknown insn",
1918 /* seccomp insn, rejected in socket filter */
1919 BPF_STMT(BPF_LDX
| BPF_W
| BPF_ABS
, 0),
1920 BPF_STMT(BPF_RET
| BPF_K
, 0)
1922 CLASSIC
| FLAG_EXPECTED_FAIL
,
1927 "check: out of range spill/fill",
1929 BPF_STMT(BPF_STX
, 16),
1930 BPF_STMT(BPF_RET
| BPF_K
, 0)
1932 CLASSIC
| FLAG_NO_DATA
| FLAG_EXPECTED_FAIL
,
1939 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1940 BPF_JUMP(BPF_JMP
| BPF_JGE
, 0, 13, 15),
1941 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1942 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1943 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1944 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1945 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1946 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1947 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1948 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1949 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1950 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1951 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1952 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1953 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1954 BPF_JUMP(BPF_JMP
| BPF_JEQ
, 0x90c2894d, 3, 4),
1955 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1956 BPF_JUMP(BPF_JMP
| BPF_JEQ
, 0x90c2894d, 1, 2),
1957 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1958 BPF_JUMP(BPF_JMP
| BPF_JGE
, 0, 14, 15),
1959 BPF_JUMP(BPF_JMP
| BPF_JGE
, 0, 13, 14),
1960 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1961 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1962 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1963 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1964 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1965 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1966 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1967 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1968 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1969 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1970 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1971 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1972 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1973 BPF_JUMP(BPF_JMP
| BPF_JEQ
, 0x2ac28349, 2, 3),
1974 BPF_JUMP(BPF_JMP
| BPF_JEQ
, 0x2ac28349, 1, 2),
1975 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1976 BPF_JUMP(BPF_JMP
| BPF_JGE
, 0, 14, 15),
1977 BPF_JUMP(BPF_JMP
| BPF_JGE
, 0, 13, 14),
1978 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1979 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1980 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1981 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1982 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1983 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1984 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1985 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1986 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1987 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1988 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1989 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1990 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1991 BPF_JUMP(BPF_JMP
| BPF_JEQ
, 0x90d2ff41, 2, 3),
1992 BPF_JUMP(BPF_JMP
| BPF_JEQ
, 0x90d2ff41, 1, 2),
1993 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
1994 BPF_STMT(BPF_RET
| BPF_A
, 0),
1995 BPF_STMT(BPF_RET
| BPF_A
, 0),
1998 { 0x00, 0x1b, 0x21, 0x3c, 0x9d, 0xf8,
1999 0x90, 0xe2, 0xba, 0x0a, 0x56, 0xb4,
2001 0x45, 0x00, 0x00, 0x28, 0x00, 0x00,
2002 0x20, 0x00, 0x40, 0x11, 0x00, 0x00, /* IP header */
2003 0xc0, 0xa8, 0x33, 0x01,
2004 0xc0, 0xa8, 0x33, 0x02,
2007 0x00, 0x14, 0x00, 0x00,
2008 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
2009 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
2010 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
2011 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
2012 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
2013 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
2014 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
2015 0xcc, 0xcc, 0xcc, 0xcc },
2021 BPF_STMT(BPF_RET
| BPF_X
, 0),
2023 CLASSIC
| FLAG_NO_DATA
| FLAG_EXPECTED_FAIL
,
2028 "check: LDX + RET X",
2030 BPF_STMT(BPF_LDX
| BPF_IMM
, 42),
2031 BPF_STMT(BPF_RET
| BPF_X
, 0),
2033 CLASSIC
| FLAG_NO_DATA
| FLAG_EXPECTED_FAIL
,
2037 { /* Mainly checking JIT here. */
2038 "M[]: alt STX + LDX",
2040 BPF_STMT(BPF_LDX
| BPF_IMM
, 100),
2041 BPF_STMT(BPF_STX
, 0),
2042 BPF_STMT(BPF_LDX
| BPF_MEM
, 0),
2043 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
2044 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 1),
2045 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
2046 BPF_STMT(BPF_STX
, 1),
2047 BPF_STMT(BPF_LDX
| BPF_MEM
, 1),
2048 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
2049 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 1),
2050 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
2051 BPF_STMT(BPF_STX
, 2),
2052 BPF_STMT(BPF_LDX
| BPF_MEM
, 2),
2053 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
2054 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 1),
2055 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
2056 BPF_STMT(BPF_STX
, 3),
2057 BPF_STMT(BPF_LDX
| BPF_MEM
, 3),
2058 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
2059 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 1),
2060 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
2061 BPF_STMT(BPF_STX
, 4),
2062 BPF_STMT(BPF_LDX
| BPF_MEM
, 4),
2063 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
2064 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 1),
2065 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
2066 BPF_STMT(BPF_STX
, 5),
2067 BPF_STMT(BPF_LDX
| BPF_MEM
, 5),
2068 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
2069 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 1),
2070 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
2071 BPF_STMT(BPF_STX
, 6),
2072 BPF_STMT(BPF_LDX
| BPF_MEM
, 6),
2073 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
2074 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 1),
2075 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
2076 BPF_STMT(BPF_STX
, 7),
2077 BPF_STMT(BPF_LDX
| BPF_MEM
, 7),
2078 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
2079 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 1),
2080 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
2081 BPF_STMT(BPF_STX
, 8),
2082 BPF_STMT(BPF_LDX
| BPF_MEM
, 8),
2083 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
2084 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 1),
2085 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
2086 BPF_STMT(BPF_STX
, 9),
2087 BPF_STMT(BPF_LDX
| BPF_MEM
, 9),
2088 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
2089 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 1),
2090 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
2091 BPF_STMT(BPF_STX
, 10),
2092 BPF_STMT(BPF_LDX
| BPF_MEM
, 10),
2093 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
2094 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 1),
2095 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
2096 BPF_STMT(BPF_STX
, 11),
2097 BPF_STMT(BPF_LDX
| BPF_MEM
, 11),
2098 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
2099 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 1),
2100 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
2101 BPF_STMT(BPF_STX
, 12),
2102 BPF_STMT(BPF_LDX
| BPF_MEM
, 12),
2103 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
2104 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 1),
2105 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
2106 BPF_STMT(BPF_STX
, 13),
2107 BPF_STMT(BPF_LDX
| BPF_MEM
, 13),
2108 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
2109 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 1),
2110 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
2111 BPF_STMT(BPF_STX
, 14),
2112 BPF_STMT(BPF_LDX
| BPF_MEM
, 14),
2113 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
2114 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 1),
2115 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
2116 BPF_STMT(BPF_STX
, 15),
2117 BPF_STMT(BPF_LDX
| BPF_MEM
, 15),
2118 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
2119 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 1),
2120 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
2121 BPF_STMT(BPF_RET
| BPF_A
, 0),
2123 CLASSIC
| FLAG_NO_DATA
,
2127 { /* Mainly checking JIT here. */
2128 "M[]: full STX + full LDX",
2130 BPF_STMT(BPF_LDX
| BPF_IMM
, 0xbadfeedb),
2131 BPF_STMT(BPF_STX
, 0),
2132 BPF_STMT(BPF_LDX
| BPF_IMM
, 0xecabedae),
2133 BPF_STMT(BPF_STX
, 1),
2134 BPF_STMT(BPF_LDX
| BPF_IMM
, 0xafccfeaf),
2135 BPF_STMT(BPF_STX
, 2),
2136 BPF_STMT(BPF_LDX
| BPF_IMM
, 0xbffdcedc),
2137 BPF_STMT(BPF_STX
, 3),
2138 BPF_STMT(BPF_LDX
| BPF_IMM
, 0xfbbbdccb),
2139 BPF_STMT(BPF_STX
, 4),
2140 BPF_STMT(BPF_LDX
| BPF_IMM
, 0xfbabcbda),
2141 BPF_STMT(BPF_STX
, 5),
2142 BPF_STMT(BPF_LDX
| BPF_IMM
, 0xaedecbdb),
2143 BPF_STMT(BPF_STX
, 6),
2144 BPF_STMT(BPF_LDX
| BPF_IMM
, 0xadebbade),
2145 BPF_STMT(BPF_STX
, 7),
2146 BPF_STMT(BPF_LDX
| BPF_IMM
, 0xfcfcfaec),
2147 BPF_STMT(BPF_STX
, 8),
2148 BPF_STMT(BPF_LDX
| BPF_IMM
, 0xbcdddbdc),
2149 BPF_STMT(BPF_STX
, 9),
2150 BPF_STMT(BPF_LDX
| BPF_IMM
, 0xfeefdfac),
2151 BPF_STMT(BPF_STX
, 10),
2152 BPF_STMT(BPF_LDX
| BPF_IMM
, 0xcddcdeea),
2153 BPF_STMT(BPF_STX
, 11),
2154 BPF_STMT(BPF_LDX
| BPF_IMM
, 0xaccfaebb),
2155 BPF_STMT(BPF_STX
, 12),
2156 BPF_STMT(BPF_LDX
| BPF_IMM
, 0xbdcccdcf),
2157 BPF_STMT(BPF_STX
, 13),
2158 BPF_STMT(BPF_LDX
| BPF_IMM
, 0xaaedecde),
2159 BPF_STMT(BPF_STX
, 14),
2160 BPF_STMT(BPF_LDX
| BPF_IMM
, 0xfaeacdad),
2161 BPF_STMT(BPF_STX
, 15),
2162 BPF_STMT(BPF_LDX
| BPF_MEM
, 0),
2163 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
2164 BPF_STMT(BPF_LDX
| BPF_MEM
, 1),
2165 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
2166 BPF_STMT(BPF_LDX
| BPF_MEM
, 2),
2167 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
2168 BPF_STMT(BPF_LDX
| BPF_MEM
, 3),
2169 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
2170 BPF_STMT(BPF_LDX
| BPF_MEM
, 4),
2171 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
2172 BPF_STMT(BPF_LDX
| BPF_MEM
, 5),
2173 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
2174 BPF_STMT(BPF_LDX
| BPF_MEM
, 6),
2175 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
2176 BPF_STMT(BPF_LDX
| BPF_MEM
, 7),
2177 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
2178 BPF_STMT(BPF_LDX
| BPF_MEM
, 8),
2179 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
2180 BPF_STMT(BPF_LDX
| BPF_MEM
, 9),
2181 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
2182 BPF_STMT(BPF_LDX
| BPF_MEM
, 10),
2183 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
2184 BPF_STMT(BPF_LDX
| BPF_MEM
, 11),
2185 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
2186 BPF_STMT(BPF_LDX
| BPF_MEM
, 12),
2187 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
2188 BPF_STMT(BPF_LDX
| BPF_MEM
, 13),
2189 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
2190 BPF_STMT(BPF_LDX
| BPF_MEM
, 14),
2191 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
2192 BPF_STMT(BPF_LDX
| BPF_MEM
, 15),
2193 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
2194 BPF_STMT(BPF_RET
| BPF_A
, 0),
2196 CLASSIC
| FLAG_NO_DATA
,
2198 { { 0, 0x2a5a5e5 } },
2201 "check: SKF_AD_MAX",
2203 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
2204 SKF_AD_OFF
+ SKF_AD_MAX
),
2205 BPF_STMT(BPF_RET
| BPF_A
, 0),
2207 CLASSIC
| FLAG_NO_DATA
| FLAG_EXPECTED_FAIL
,
2211 { /* Passes checker but fails during runtime. */
2212 "LD [SKF_AD_OFF-1]",
2214 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
2216 BPF_STMT(BPF_RET
| BPF_K
, 1),
2223 "load 64-bit immediate",
2225 BPF_LD_IMM64(R1
, 0x567800001234LL
),
2226 BPF_MOV64_REG(R2
, R1
),
2227 BPF_MOV64_REG(R3
, R2
),
2228 BPF_ALU64_IMM(BPF_RSH
, R2
, 32),
2229 BPF_ALU64_IMM(BPF_LSH
, R3
, 32),
2230 BPF_ALU64_IMM(BPF_RSH
, R3
, 32),
2231 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
2232 BPF_JMP_IMM(BPF_JEQ
, R2
, 0x5678, 1),
2234 BPF_JMP_IMM(BPF_JEQ
, R3
, 0x1234, 1),
2236 BPF_LD_IMM64(R0
, 0x1ffffffffLL
),
2237 BPF_ALU64_IMM(BPF_RSH
, R0
, 32), /* R0 = 1 */
2247 BPF_MOV64_REG(R6
, R1
),
2248 BPF_LD_ABS(BPF_H
, 12),
2249 BPF_JMP_IMM(BPF_JNE
, R0
, 0x806, 28),
2250 BPF_LD_ABS(BPF_H
, 12),
2251 BPF_JMP_IMM(BPF_JNE
, R0
, 0x806, 26),
2252 BPF_MOV32_IMM(R0
, 18),
2253 BPF_STX_MEM(BPF_W
, R10
, R0
, -64),
2254 BPF_LDX_MEM(BPF_W
, R7
, R10
, -64),
2255 BPF_LD_IND(BPF_W
, R7
, 14),
2256 BPF_STX_MEM(BPF_W
, R10
, R0
, -60),
2257 BPF_MOV32_IMM(R0
, 280971478),
2258 BPF_STX_MEM(BPF_W
, R10
, R0
, -56),
2259 BPF_LDX_MEM(BPF_W
, R7
, R10
, -56),
2260 BPF_LDX_MEM(BPF_W
, R0
, R10
, -60),
2261 BPF_ALU32_REG(BPF_SUB
, R0
, R7
),
2262 BPF_JMP_IMM(BPF_JNE
, R0
, 0, 15),
2263 BPF_LD_ABS(BPF_H
, 12),
2264 BPF_JMP_IMM(BPF_JNE
, R0
, 0x806, 13),
2265 BPF_MOV32_IMM(R0
, 22),
2266 BPF_STX_MEM(BPF_W
, R10
, R0
, -56),
2267 BPF_LDX_MEM(BPF_W
, R7
, R10
, -56),
2268 BPF_LD_IND(BPF_H
, R7
, 14),
2269 BPF_STX_MEM(BPF_W
, R10
, R0
, -52),
2270 BPF_MOV32_IMM(R0
, 17366),
2271 BPF_STX_MEM(BPF_W
, R10
, R0
, -48),
2272 BPF_LDX_MEM(BPF_W
, R7
, R10
, -48),
2273 BPF_LDX_MEM(BPF_W
, R0
, R10
, -52),
2274 BPF_ALU32_REG(BPF_SUB
, R0
, R7
),
2275 BPF_JMP_IMM(BPF_JNE
, R0
, 0, 2),
2276 BPF_MOV32_IMM(R0
, 256),
2278 BPF_MOV32_IMM(R0
, 0),
2282 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x08, 0x06, 0, 0,
2283 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2284 0x10, 0xbf, 0x48, 0xd6, 0x43, 0xd6},
2287 /* BPF_ALU | BPF_MOV | BPF_X */
2289 "ALU_MOV_X: dst = 2",
2291 BPF_ALU32_IMM(BPF_MOV
, R1
, 2),
2292 BPF_ALU32_REG(BPF_MOV
, R0
, R1
),
2300 "ALU_MOV_X: dst = 4294967295",
2302 BPF_ALU32_IMM(BPF_MOV
, R1
, 4294967295U),
2303 BPF_ALU32_REG(BPF_MOV
, R0
, R1
),
2308 { { 0, 4294967295U } },
2311 "ALU64_MOV_X: dst = 2",
2313 BPF_ALU32_IMM(BPF_MOV
, R1
, 2),
2314 BPF_ALU64_REG(BPF_MOV
, R0
, R1
),
2322 "ALU64_MOV_X: dst = 4294967295",
2324 BPF_ALU32_IMM(BPF_MOV
, R1
, 4294967295U),
2325 BPF_ALU64_REG(BPF_MOV
, R0
, R1
),
2330 { { 0, 4294967295U } },
2332 /* BPF_ALU | BPF_MOV | BPF_K */
2334 "ALU_MOV_K: dst = 2",
2336 BPF_ALU32_IMM(BPF_MOV
, R0
, 2),
2344 "ALU_MOV_K: dst = 4294967295",
2346 BPF_ALU32_IMM(BPF_MOV
, R0
, 4294967295U),
2351 { { 0, 4294967295U } },
2354 "ALU_MOV_K: 0x0000ffffffff0000 = 0x00000000ffffffff",
2356 BPF_LD_IMM64(R2
, 0x0000ffffffff0000LL
),
2357 BPF_LD_IMM64(R3
, 0x00000000ffffffffLL
),
2358 BPF_ALU32_IMM(BPF_MOV
, R2
, 0xffffffff),
2359 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
2360 BPF_MOV32_IMM(R0
, 2),
2362 BPF_MOV32_IMM(R0
, 1),
2370 "ALU64_MOV_K: dst = 2",
2372 BPF_ALU64_IMM(BPF_MOV
, R0
, 2),
2380 "ALU64_MOV_K: dst = 2147483647",
2382 BPF_ALU64_IMM(BPF_MOV
, R0
, 2147483647),
2387 { { 0, 2147483647 } },
2390 "ALU64_OR_K: dst = 0x0",
2392 BPF_LD_IMM64(R2
, 0x0000ffffffff0000LL
),
2393 BPF_LD_IMM64(R3
, 0x0),
2394 BPF_ALU64_IMM(BPF_MOV
, R2
, 0x0),
2395 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
2396 BPF_MOV32_IMM(R0
, 2),
2398 BPF_MOV32_IMM(R0
, 1),
2406 "ALU64_MOV_K: dst = -1",
2408 BPF_LD_IMM64(R2
, 0x0000ffffffff0000LL
),
2409 BPF_LD_IMM64(R3
, 0xffffffffffffffffLL
),
2410 BPF_ALU64_IMM(BPF_MOV
, R2
, 0xffffffff),
2411 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
2412 BPF_MOV32_IMM(R0
, 2),
2414 BPF_MOV32_IMM(R0
, 1),
2421 /* BPF_ALU | BPF_ADD | BPF_X */
2423 "ALU_ADD_X: 1 + 2 = 3",
2425 BPF_LD_IMM64(R0
, 1),
2426 BPF_ALU32_IMM(BPF_MOV
, R1
, 2),
2427 BPF_ALU32_REG(BPF_ADD
, R0
, R1
),
2435 "ALU_ADD_X: 1 + 4294967294 = 4294967295",
2437 BPF_LD_IMM64(R0
, 1),
2438 BPF_ALU32_IMM(BPF_MOV
, R1
, 4294967294U),
2439 BPF_ALU32_REG(BPF_ADD
, R0
, R1
),
2444 { { 0, 4294967295U } },
2447 "ALU_ADD_X: 2 + 4294967294 = 0",
2449 BPF_LD_IMM64(R0
, 2),
2450 BPF_LD_IMM64(R1
, 4294967294U),
2451 BPF_ALU32_REG(BPF_ADD
, R0
, R1
),
2452 BPF_JMP_IMM(BPF_JEQ
, R0
, 0, 2),
2453 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
2455 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
2463 "ALU64_ADD_X: 1 + 2 = 3",
2465 BPF_LD_IMM64(R0
, 1),
2466 BPF_ALU32_IMM(BPF_MOV
, R1
, 2),
2467 BPF_ALU64_REG(BPF_ADD
, R0
, R1
),
2475 "ALU64_ADD_X: 1 + 4294967294 = 4294967295",
2477 BPF_LD_IMM64(R0
, 1),
2478 BPF_ALU32_IMM(BPF_MOV
, R1
, 4294967294U),
2479 BPF_ALU64_REG(BPF_ADD
, R0
, R1
),
2484 { { 0, 4294967295U } },
2487 "ALU64_ADD_X: 2 + 4294967294 = 4294967296",
2489 BPF_LD_IMM64(R0
, 2),
2490 BPF_LD_IMM64(R1
, 4294967294U),
2491 BPF_LD_IMM64(R2
, 4294967296ULL),
2492 BPF_ALU64_REG(BPF_ADD
, R0
, R1
),
2493 BPF_JMP_REG(BPF_JEQ
, R0
, R2
, 2),
2494 BPF_MOV32_IMM(R0
, 0),
2496 BPF_MOV32_IMM(R0
, 1),
2503 /* BPF_ALU | BPF_ADD | BPF_K */
2505 "ALU_ADD_K: 1 + 2 = 3",
2507 BPF_LD_IMM64(R0
, 1),
2508 BPF_ALU32_IMM(BPF_ADD
, R0
, 2),
2516 "ALU_ADD_K: 3 + 0 = 3",
2518 BPF_LD_IMM64(R0
, 3),
2519 BPF_ALU32_IMM(BPF_ADD
, R0
, 0),
2527 "ALU_ADD_K: 1 + 4294967294 = 4294967295",
2529 BPF_LD_IMM64(R0
, 1),
2530 BPF_ALU32_IMM(BPF_ADD
, R0
, 4294967294U),
2535 { { 0, 4294967295U } },
2538 "ALU_ADD_K: 4294967294 + 2 = 0",
2540 BPF_LD_IMM64(R0
, 4294967294U),
2541 BPF_ALU32_IMM(BPF_ADD
, R0
, 2),
2542 BPF_JMP_IMM(BPF_JEQ
, R0
, 0, 2),
2543 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
2545 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
2553 "ALU_ADD_K: 0 + (-1) = 0x00000000ffffffff",
2555 BPF_LD_IMM64(R2
, 0x0),
2556 BPF_LD_IMM64(R3
, 0x00000000ffffffff),
2557 BPF_ALU32_IMM(BPF_ADD
, R2
, 0xffffffff),
2558 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
2559 BPF_MOV32_IMM(R0
, 2),
2561 BPF_MOV32_IMM(R0
, 1),
2569 "ALU_ADD_K: 0 + 0xffff = 0xffff",
2571 BPF_LD_IMM64(R2
, 0x0),
2572 BPF_LD_IMM64(R3
, 0xffff),
2573 BPF_ALU32_IMM(BPF_ADD
, R2
, 0xffff),
2574 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
2575 BPF_MOV32_IMM(R0
, 2),
2577 BPF_MOV32_IMM(R0
, 1),
2585 "ALU_ADD_K: 0 + 0x7fffffff = 0x7fffffff",
2587 BPF_LD_IMM64(R2
, 0x0),
2588 BPF_LD_IMM64(R3
, 0x7fffffff),
2589 BPF_ALU32_IMM(BPF_ADD
, R2
, 0x7fffffff),
2590 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
2591 BPF_MOV32_IMM(R0
, 2),
2593 BPF_MOV32_IMM(R0
, 1),
2601 "ALU_ADD_K: 0 + 0x80000000 = 0x80000000",
2603 BPF_LD_IMM64(R2
, 0x0),
2604 BPF_LD_IMM64(R3
, 0x80000000),
2605 BPF_ALU32_IMM(BPF_ADD
, R2
, 0x80000000),
2606 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
2607 BPF_MOV32_IMM(R0
, 2),
2609 BPF_MOV32_IMM(R0
, 1),
2617 "ALU_ADD_K: 0 + 0x80008000 = 0x80008000",
2619 BPF_LD_IMM64(R2
, 0x0),
2620 BPF_LD_IMM64(R3
, 0x80008000),
2621 BPF_ALU32_IMM(BPF_ADD
, R2
, 0x80008000),
2622 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
2623 BPF_MOV32_IMM(R0
, 2),
2625 BPF_MOV32_IMM(R0
, 1),
2633 "ALU64_ADD_K: 1 + 2 = 3",
2635 BPF_LD_IMM64(R0
, 1),
2636 BPF_ALU64_IMM(BPF_ADD
, R0
, 2),
2644 "ALU64_ADD_K: 3 + 0 = 3",
2646 BPF_LD_IMM64(R0
, 3),
2647 BPF_ALU64_IMM(BPF_ADD
, R0
, 0),
2655 "ALU64_ADD_K: 1 + 2147483646 = 2147483647",
2657 BPF_LD_IMM64(R0
, 1),
2658 BPF_ALU64_IMM(BPF_ADD
, R0
, 2147483646),
2663 { { 0, 2147483647 } },
2666 "ALU64_ADD_K: 4294967294 + 2 = 4294967296",
2668 BPF_LD_IMM64(R0
, 4294967294U),
2669 BPF_LD_IMM64(R1
, 4294967296ULL),
2670 BPF_ALU64_IMM(BPF_ADD
, R0
, 2),
2671 BPF_JMP_REG(BPF_JEQ
, R0
, R1
, 2),
2672 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
2674 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
2682 "ALU64_ADD_K: 2147483646 + -2147483647 = -1",
2684 BPF_LD_IMM64(R0
, 2147483646),
2685 BPF_ALU64_IMM(BPF_ADD
, R0
, -2147483647),
2693 "ALU64_ADD_K: 1 + 0 = 1",
2695 BPF_LD_IMM64(R2
, 0x1),
2696 BPF_LD_IMM64(R3
, 0x1),
2697 BPF_ALU64_IMM(BPF_ADD
, R2
, 0x0),
2698 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
2699 BPF_MOV32_IMM(R0
, 2),
2701 BPF_MOV32_IMM(R0
, 1),
2709 "ALU64_ADD_K: 0 + (-1) = 0xffffffffffffffff",
2711 BPF_LD_IMM64(R2
, 0x0),
2712 BPF_LD_IMM64(R3
, 0xffffffffffffffffLL
),
2713 BPF_ALU64_IMM(BPF_ADD
, R2
, 0xffffffff),
2714 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
2715 BPF_MOV32_IMM(R0
, 2),
2717 BPF_MOV32_IMM(R0
, 1),
2725 "ALU64_ADD_K: 0 + 0xffff = 0xffff",
2727 BPF_LD_IMM64(R2
, 0x0),
2728 BPF_LD_IMM64(R3
, 0xffff),
2729 BPF_ALU64_IMM(BPF_ADD
, R2
, 0xffff),
2730 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
2731 BPF_MOV32_IMM(R0
, 2),
2733 BPF_MOV32_IMM(R0
, 1),
2741 "ALU64_ADD_K: 0 + 0x7fffffff = 0x7fffffff",
2743 BPF_LD_IMM64(R2
, 0x0),
2744 BPF_LD_IMM64(R3
, 0x7fffffff),
2745 BPF_ALU64_IMM(BPF_ADD
, R2
, 0x7fffffff),
2746 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
2747 BPF_MOV32_IMM(R0
, 2),
2749 BPF_MOV32_IMM(R0
, 1),
2757 "ALU64_ADD_K: 0 + 0x80000000 = 0xffffffff80000000",
2759 BPF_LD_IMM64(R2
, 0x0),
2760 BPF_LD_IMM64(R3
, 0xffffffff80000000LL
),
2761 BPF_ALU64_IMM(BPF_ADD
, R2
, 0x80000000),
2762 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
2763 BPF_MOV32_IMM(R0
, 2),
2765 BPF_MOV32_IMM(R0
, 1),
2773 "ALU_ADD_K: 0 + 0x80008000 = 0xffffffff80008000",
2775 BPF_LD_IMM64(R2
, 0x0),
2776 BPF_LD_IMM64(R3
, 0xffffffff80008000LL
),
2777 BPF_ALU64_IMM(BPF_ADD
, R2
, 0x80008000),
2778 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
2779 BPF_MOV32_IMM(R0
, 2),
2781 BPF_MOV32_IMM(R0
, 1),
2788 /* BPF_ALU | BPF_SUB | BPF_X */
2790 "ALU_SUB_X: 3 - 1 = 2",
2792 BPF_LD_IMM64(R0
, 3),
2793 BPF_ALU32_IMM(BPF_MOV
, R1
, 1),
2794 BPF_ALU32_REG(BPF_SUB
, R0
, R1
),
2802 "ALU_SUB_X: 4294967295 - 4294967294 = 1",
2804 BPF_LD_IMM64(R0
, 4294967295U),
2805 BPF_ALU32_IMM(BPF_MOV
, R1
, 4294967294U),
2806 BPF_ALU32_REG(BPF_SUB
, R0
, R1
),
2814 "ALU64_SUB_X: 3 - 1 = 2",
2816 BPF_LD_IMM64(R0
, 3),
2817 BPF_ALU32_IMM(BPF_MOV
, R1
, 1),
2818 BPF_ALU64_REG(BPF_SUB
, R0
, R1
),
2826 "ALU64_SUB_X: 4294967295 - 4294967294 = 1",
2828 BPF_LD_IMM64(R0
, 4294967295U),
2829 BPF_ALU32_IMM(BPF_MOV
, R1
, 4294967294U),
2830 BPF_ALU64_REG(BPF_SUB
, R0
, R1
),
2837 /* BPF_ALU | BPF_SUB | BPF_K */
2839 "ALU_SUB_K: 3 - 1 = 2",
2841 BPF_LD_IMM64(R0
, 3),
2842 BPF_ALU32_IMM(BPF_SUB
, R0
, 1),
2850 "ALU_SUB_K: 3 - 0 = 3",
2852 BPF_LD_IMM64(R0
, 3),
2853 BPF_ALU32_IMM(BPF_SUB
, R0
, 0),
2861 "ALU_SUB_K: 4294967295 - 4294967294 = 1",
2863 BPF_LD_IMM64(R0
, 4294967295U),
2864 BPF_ALU32_IMM(BPF_SUB
, R0
, 4294967294U),
2872 "ALU64_SUB_K: 3 - 1 = 2",
2874 BPF_LD_IMM64(R0
, 3),
2875 BPF_ALU64_IMM(BPF_SUB
, R0
, 1),
2883 "ALU64_SUB_K: 3 - 0 = 3",
2885 BPF_LD_IMM64(R0
, 3),
2886 BPF_ALU64_IMM(BPF_SUB
, R0
, 0),
2894 "ALU64_SUB_K: 4294967294 - 4294967295 = -1",
2896 BPF_LD_IMM64(R0
, 4294967294U),
2897 BPF_ALU64_IMM(BPF_SUB
, R0
, 4294967295U),
2905 "ALU64_ADD_K: 2147483646 - 2147483647 = -1",
2907 BPF_LD_IMM64(R0
, 2147483646),
2908 BPF_ALU64_IMM(BPF_SUB
, R0
, 2147483647),
2915 /* BPF_ALU | BPF_MUL | BPF_X */
2917 "ALU_MUL_X: 2 * 3 = 6",
2919 BPF_LD_IMM64(R0
, 2),
2920 BPF_ALU32_IMM(BPF_MOV
, R1
, 3),
2921 BPF_ALU32_REG(BPF_MUL
, R0
, R1
),
2929 "ALU_MUL_X: 2 * 0x7FFFFFF8 = 0xFFFFFFF0",
2931 BPF_LD_IMM64(R0
, 2),
2932 BPF_ALU32_IMM(BPF_MOV
, R1
, 0x7FFFFFF8),
2933 BPF_ALU32_REG(BPF_MUL
, R0
, R1
),
2938 { { 0, 0xFFFFFFF0 } },
2941 "ALU_MUL_X: -1 * -1 = 1",
2943 BPF_LD_IMM64(R0
, -1),
2944 BPF_ALU32_IMM(BPF_MOV
, R1
, -1),
2945 BPF_ALU32_REG(BPF_MUL
, R0
, R1
),
2953 "ALU64_MUL_X: 2 * 3 = 6",
2955 BPF_LD_IMM64(R0
, 2),
2956 BPF_ALU32_IMM(BPF_MOV
, R1
, 3),
2957 BPF_ALU64_REG(BPF_MUL
, R0
, R1
),
2965 "ALU64_MUL_X: 1 * 2147483647 = 2147483647",
2967 BPF_LD_IMM64(R0
, 1),
2968 BPF_ALU32_IMM(BPF_MOV
, R1
, 2147483647),
2969 BPF_ALU64_REG(BPF_MUL
, R0
, R1
),
2974 { { 0, 2147483647 } },
2976 /* BPF_ALU | BPF_MUL | BPF_K */
2978 "ALU_MUL_K: 2 * 3 = 6",
2980 BPF_LD_IMM64(R0
, 2),
2981 BPF_ALU32_IMM(BPF_MUL
, R0
, 3),
2989 "ALU_MUL_K: 3 * 1 = 3",
2991 BPF_LD_IMM64(R0
, 3),
2992 BPF_ALU32_IMM(BPF_MUL
, R0
, 1),
3000 "ALU_MUL_K: 2 * 0x7FFFFFF8 = 0xFFFFFFF0",
3002 BPF_LD_IMM64(R0
, 2),
3003 BPF_ALU32_IMM(BPF_MUL
, R0
, 0x7FFFFFF8),
3008 { { 0, 0xFFFFFFF0 } },
3011 "ALU_MUL_K: 1 * (-1) = 0x00000000ffffffff",
3013 BPF_LD_IMM64(R2
, 0x1),
3014 BPF_LD_IMM64(R3
, 0x00000000ffffffff),
3015 BPF_ALU32_IMM(BPF_MUL
, R2
, 0xffffffff),
3016 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
3017 BPF_MOV32_IMM(R0
, 2),
3019 BPF_MOV32_IMM(R0
, 1),
3027 "ALU64_MUL_K: 2 * 3 = 6",
3029 BPF_LD_IMM64(R0
, 2),
3030 BPF_ALU64_IMM(BPF_MUL
, R0
, 3),
3038 "ALU64_MUL_K: 3 * 1 = 3",
3040 BPF_LD_IMM64(R0
, 3),
3041 BPF_ALU64_IMM(BPF_MUL
, R0
, 1),
3049 "ALU64_MUL_K: 1 * 2147483647 = 2147483647",
3051 BPF_LD_IMM64(R0
, 1),
3052 BPF_ALU64_IMM(BPF_MUL
, R0
, 2147483647),
3057 { { 0, 2147483647 } },
3060 "ALU64_MUL_K: 1 * -2147483647 = -2147483647",
3062 BPF_LD_IMM64(R0
, 1),
3063 BPF_ALU64_IMM(BPF_MUL
, R0
, -2147483647),
3068 { { 0, -2147483647 } },
3071 "ALU64_MUL_K: 1 * (-1) = 0xffffffffffffffff",
3073 BPF_LD_IMM64(R2
, 0x1),
3074 BPF_LD_IMM64(R3
, 0xffffffffffffffffLL
),
3075 BPF_ALU64_IMM(BPF_MUL
, R2
, 0xffffffff),
3076 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
3077 BPF_MOV32_IMM(R0
, 2),
3079 BPF_MOV32_IMM(R0
, 1),
3086 /* BPF_ALU | BPF_DIV | BPF_X */
3088 "ALU_DIV_X: 6 / 2 = 3",
3090 BPF_LD_IMM64(R0
, 6),
3091 BPF_ALU32_IMM(BPF_MOV
, R1
, 2),
3092 BPF_ALU32_REG(BPF_DIV
, R0
, R1
),
3100 "ALU_DIV_X: 4294967295 / 4294967295 = 1",
3102 BPF_LD_IMM64(R0
, 4294967295U),
3103 BPF_ALU32_IMM(BPF_MOV
, R1
, 4294967295U),
3104 BPF_ALU32_REG(BPF_DIV
, R0
, R1
),
3112 "ALU64_DIV_X: 6 / 2 = 3",
3114 BPF_LD_IMM64(R0
, 6),
3115 BPF_ALU32_IMM(BPF_MOV
, R1
, 2),
3116 BPF_ALU64_REG(BPF_DIV
, R0
, R1
),
3124 "ALU64_DIV_X: 2147483647 / 2147483647 = 1",
3126 BPF_LD_IMM64(R0
, 2147483647),
3127 BPF_ALU32_IMM(BPF_MOV
, R1
, 2147483647),
3128 BPF_ALU64_REG(BPF_DIV
, R0
, R1
),
3136 "ALU64_DIV_X: 0xffffffffffffffff / (-1) = 0x0000000000000001",
3138 BPF_LD_IMM64(R2
, 0xffffffffffffffffLL
),
3139 BPF_LD_IMM64(R4
, 0xffffffffffffffffLL
),
3140 BPF_LD_IMM64(R3
, 0x0000000000000001LL
),
3141 BPF_ALU64_REG(BPF_DIV
, R2
, R4
),
3142 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
3143 BPF_MOV32_IMM(R0
, 2),
3145 BPF_MOV32_IMM(R0
, 1),
3152 /* BPF_ALU | BPF_DIV | BPF_K */
3154 "ALU_DIV_K: 6 / 2 = 3",
3156 BPF_LD_IMM64(R0
, 6),
3157 BPF_ALU32_IMM(BPF_DIV
, R0
, 2),
3165 "ALU_DIV_K: 3 / 1 = 3",
3167 BPF_LD_IMM64(R0
, 3),
3168 BPF_ALU32_IMM(BPF_DIV
, R0
, 1),
3176 "ALU_DIV_K: 4294967295 / 4294967295 = 1",
3178 BPF_LD_IMM64(R0
, 4294967295U),
3179 BPF_ALU32_IMM(BPF_DIV
, R0
, 4294967295U),
3187 "ALU_DIV_K: 0xffffffffffffffff / (-1) = 0x1",
3189 BPF_LD_IMM64(R2
, 0xffffffffffffffffLL
),
3190 BPF_LD_IMM64(R3
, 0x1UL
),
3191 BPF_ALU32_IMM(BPF_DIV
, R2
, 0xffffffff),
3192 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
3193 BPF_MOV32_IMM(R0
, 2),
3195 BPF_MOV32_IMM(R0
, 1),
3203 "ALU64_DIV_K: 6 / 2 = 3",
3205 BPF_LD_IMM64(R0
, 6),
3206 BPF_ALU64_IMM(BPF_DIV
, R0
, 2),
3214 "ALU64_DIV_K: 3 / 1 = 3",
3216 BPF_LD_IMM64(R0
, 3),
3217 BPF_ALU64_IMM(BPF_DIV
, R0
, 1),
3225 "ALU64_DIV_K: 2147483647 / 2147483647 = 1",
3227 BPF_LD_IMM64(R0
, 2147483647),
3228 BPF_ALU64_IMM(BPF_DIV
, R0
, 2147483647),
3236 "ALU64_DIV_K: 0xffffffffffffffff / (-1) = 0x0000000000000001",
3238 BPF_LD_IMM64(R2
, 0xffffffffffffffffLL
),
3239 BPF_LD_IMM64(R3
, 0x0000000000000001LL
),
3240 BPF_ALU64_IMM(BPF_DIV
, R2
, 0xffffffff),
3241 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
3242 BPF_MOV32_IMM(R0
, 2),
3244 BPF_MOV32_IMM(R0
, 1),
3251 /* BPF_ALU | BPF_MOD | BPF_X */
3253 "ALU_MOD_X: 3 % 2 = 1",
3255 BPF_LD_IMM64(R0
, 3),
3256 BPF_ALU32_IMM(BPF_MOV
, R1
, 2),
3257 BPF_ALU32_REG(BPF_MOD
, R0
, R1
),
3265 "ALU_MOD_X: 4294967295 % 4294967293 = 2",
3267 BPF_LD_IMM64(R0
, 4294967295U),
3268 BPF_ALU32_IMM(BPF_MOV
, R1
, 4294967293U),
3269 BPF_ALU32_REG(BPF_MOD
, R0
, R1
),
3277 "ALU64_MOD_X: 3 % 2 = 1",
3279 BPF_LD_IMM64(R0
, 3),
3280 BPF_ALU32_IMM(BPF_MOV
, R1
, 2),
3281 BPF_ALU64_REG(BPF_MOD
, R0
, R1
),
3289 "ALU64_MOD_X: 2147483647 % 2147483645 = 2",
3291 BPF_LD_IMM64(R0
, 2147483647),
3292 BPF_ALU32_IMM(BPF_MOV
, R1
, 2147483645),
3293 BPF_ALU64_REG(BPF_MOD
, R0
, R1
),
3300 /* BPF_ALU | BPF_MOD | BPF_K */
3302 "ALU_MOD_K: 3 % 2 = 1",
3304 BPF_LD_IMM64(R0
, 3),
3305 BPF_ALU32_IMM(BPF_MOD
, R0
, 2),
3313 "ALU_MOD_K: 3 % 1 = 0",
3315 BPF_LD_IMM64(R0
, 3),
3316 BPF_ALU32_IMM(BPF_MOD
, R0
, 1),
3324 "ALU_MOD_K: 4294967295 % 4294967293 = 2",
3326 BPF_LD_IMM64(R0
, 4294967295U),
3327 BPF_ALU32_IMM(BPF_MOD
, R0
, 4294967293U),
3335 "ALU64_MOD_K: 3 % 2 = 1",
3337 BPF_LD_IMM64(R0
, 3),
3338 BPF_ALU64_IMM(BPF_MOD
, R0
, 2),
3346 "ALU64_MOD_K: 3 % 1 = 0",
3348 BPF_LD_IMM64(R0
, 3),
3349 BPF_ALU64_IMM(BPF_MOD
, R0
, 1),
3357 "ALU64_MOD_K: 2147483647 % 2147483645 = 2",
3359 BPF_LD_IMM64(R0
, 2147483647),
3360 BPF_ALU64_IMM(BPF_MOD
, R0
, 2147483645),
3367 /* BPF_ALU | BPF_AND | BPF_X */
3369 "ALU_AND_X: 3 & 2 = 2",
3371 BPF_LD_IMM64(R0
, 3),
3372 BPF_ALU32_IMM(BPF_MOV
, R1
, 2),
3373 BPF_ALU32_REG(BPF_AND
, R0
, R1
),
3381 "ALU_AND_X: 0xffffffff & 0xffffffff = 0xffffffff",
3383 BPF_LD_IMM64(R0
, 0xffffffff),
3384 BPF_ALU32_IMM(BPF_MOV
, R1
, 0xffffffff),
3385 BPF_ALU32_REG(BPF_AND
, R0
, R1
),
3390 { { 0, 0xffffffff } },
3393 "ALU64_AND_X: 3 & 2 = 2",
3395 BPF_LD_IMM64(R0
, 3),
3396 BPF_ALU32_IMM(BPF_MOV
, R1
, 2),
3397 BPF_ALU64_REG(BPF_AND
, R0
, R1
),
3405 "ALU64_AND_X: 0xffffffff & 0xffffffff = 0xffffffff",
3407 BPF_LD_IMM64(R0
, 0xffffffff),
3408 BPF_ALU32_IMM(BPF_MOV
, R1
, 0xffffffff),
3409 BPF_ALU64_REG(BPF_AND
, R0
, R1
),
3414 { { 0, 0xffffffff } },
3416 /* BPF_ALU | BPF_AND | BPF_K */
3418 "ALU_AND_K: 3 & 2 = 2",
3420 BPF_LD_IMM64(R0
, 3),
3421 BPF_ALU32_IMM(BPF_AND
, R0
, 2),
3429 "ALU_AND_K: 0xffffffff & 0xffffffff = 0xffffffff",
3431 BPF_LD_IMM64(R0
, 0xffffffff),
3432 BPF_ALU32_IMM(BPF_AND
, R0
, 0xffffffff),
3437 { { 0, 0xffffffff } },
3440 "ALU64_AND_K: 3 & 2 = 2",
3442 BPF_LD_IMM64(R0
, 3),
3443 BPF_ALU64_IMM(BPF_AND
, R0
, 2),
3451 "ALU64_AND_K: 0xffffffff & 0xffffffff = 0xffffffff",
3453 BPF_LD_IMM64(R0
, 0xffffffff),
3454 BPF_ALU64_IMM(BPF_AND
, R0
, 0xffffffff),
3459 { { 0, 0xffffffff } },
3462 "ALU64_AND_K: 0x0000ffffffff0000 & 0x0 = 0x0000ffff00000000",
3464 BPF_LD_IMM64(R2
, 0x0000ffffffff0000LL
),
3465 BPF_LD_IMM64(R3
, 0x0000000000000000LL
),
3466 BPF_ALU64_IMM(BPF_AND
, R2
, 0x0),
3467 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
3468 BPF_MOV32_IMM(R0
, 2),
3470 BPF_MOV32_IMM(R0
, 1),
3478 "ALU64_AND_K: 0x0000ffffffff0000 & -1 = 0x0000ffffffffffff",
3480 BPF_LD_IMM64(R2
, 0x0000ffffffff0000LL
),
3481 BPF_LD_IMM64(R3
, 0x0000ffffffff0000LL
),
3482 BPF_ALU64_IMM(BPF_AND
, R2
, 0xffffffff),
3483 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
3484 BPF_MOV32_IMM(R0
, 2),
3486 BPF_MOV32_IMM(R0
, 1),
3494 "ALU64_AND_K: 0xffffffffffffffff & -1 = 0xffffffffffffffff",
3496 BPF_LD_IMM64(R2
, 0xffffffffffffffffLL
),
3497 BPF_LD_IMM64(R3
, 0xffffffffffffffffLL
),
3498 BPF_ALU64_IMM(BPF_AND
, R2
, 0xffffffff),
3499 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
3500 BPF_MOV32_IMM(R0
, 2),
3502 BPF_MOV32_IMM(R0
, 1),
3509 /* BPF_ALU | BPF_OR | BPF_X */
3511 "ALU_OR_X: 1 | 2 = 3",
3513 BPF_LD_IMM64(R0
, 1),
3514 BPF_ALU32_IMM(BPF_MOV
, R1
, 2),
3515 BPF_ALU32_REG(BPF_OR
, R0
, R1
),
3523 "ALU_OR_X: 0x0 | 0xffffffff = 0xffffffff",
3525 BPF_LD_IMM64(R0
, 0),
3526 BPF_ALU32_IMM(BPF_MOV
, R1
, 0xffffffff),
3527 BPF_ALU32_REG(BPF_OR
, R0
, R1
),
3532 { { 0, 0xffffffff } },
3535 "ALU64_OR_X: 1 | 2 = 3",
3537 BPF_LD_IMM64(R0
, 1),
3538 BPF_ALU32_IMM(BPF_MOV
, R1
, 2),
3539 BPF_ALU64_REG(BPF_OR
, R0
, R1
),
3547 "ALU64_OR_X: 0 | 0xffffffff = 0xffffffff",
3549 BPF_LD_IMM64(R0
, 0),
3550 BPF_ALU32_IMM(BPF_MOV
, R1
, 0xffffffff),
3551 BPF_ALU64_REG(BPF_OR
, R0
, R1
),
3556 { { 0, 0xffffffff } },
3558 /* BPF_ALU | BPF_OR | BPF_K */
3560 "ALU_OR_K: 1 | 2 = 3",
3562 BPF_LD_IMM64(R0
, 1),
3563 BPF_ALU32_IMM(BPF_OR
, R0
, 2),
3571 "ALU_OR_K: 0 & 0xffffffff = 0xffffffff",
3573 BPF_LD_IMM64(R0
, 0),
3574 BPF_ALU32_IMM(BPF_OR
, R0
, 0xffffffff),
3579 { { 0, 0xffffffff } },
3582 "ALU64_OR_K: 1 | 2 = 3",
3584 BPF_LD_IMM64(R0
, 1),
3585 BPF_ALU64_IMM(BPF_OR
, R0
, 2),
3593 "ALU64_OR_K: 0 & 0xffffffff = 0xffffffff",
3595 BPF_LD_IMM64(R0
, 0),
3596 BPF_ALU64_IMM(BPF_OR
, R0
, 0xffffffff),
3601 { { 0, 0xffffffff } },
3604 "ALU64_OR_K: 0x0000ffffffff0000 | 0x0 = 0x0000ffff00000000",
3606 BPF_LD_IMM64(R2
, 0x0000ffffffff0000LL
),
3607 BPF_LD_IMM64(R3
, 0x0000ffffffff0000LL
),
3608 BPF_ALU64_IMM(BPF_OR
, R2
, 0x0),
3609 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
3610 BPF_MOV32_IMM(R0
, 2),
3612 BPF_MOV32_IMM(R0
, 1),
3620 "ALU64_OR_K: 0x0000ffffffff0000 | -1 = 0xffffffffffffffff",
3622 BPF_LD_IMM64(R2
, 0x0000ffffffff0000LL
),
3623 BPF_LD_IMM64(R3
, 0xffffffffffffffffLL
),
3624 BPF_ALU64_IMM(BPF_OR
, R2
, 0xffffffff),
3625 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
3626 BPF_MOV32_IMM(R0
, 2),
3628 BPF_MOV32_IMM(R0
, 1),
3636 "ALU64_OR_K: 0x000000000000000 | -1 = 0xffffffffffffffff",
3638 BPF_LD_IMM64(R2
, 0x0000000000000000LL
),
3639 BPF_LD_IMM64(R3
, 0xffffffffffffffffLL
),
3640 BPF_ALU64_IMM(BPF_OR
, R2
, 0xffffffff),
3641 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
3642 BPF_MOV32_IMM(R0
, 2),
3644 BPF_MOV32_IMM(R0
, 1),
3651 /* BPF_ALU | BPF_XOR | BPF_X */
3653 "ALU_XOR_X: 5 ^ 6 = 3",
3655 BPF_LD_IMM64(R0
, 5),
3656 BPF_ALU32_IMM(BPF_MOV
, R1
, 6),
3657 BPF_ALU32_REG(BPF_XOR
, R0
, R1
),
3665 "ALU_XOR_X: 0x1 ^ 0xffffffff = 0xfffffffe",
3667 BPF_LD_IMM64(R0
, 1),
3668 BPF_ALU32_IMM(BPF_MOV
, R1
, 0xffffffff),
3669 BPF_ALU32_REG(BPF_XOR
, R0
, R1
),
3674 { { 0, 0xfffffffe } },
3677 "ALU64_XOR_X: 5 ^ 6 = 3",
3679 BPF_LD_IMM64(R0
, 5),
3680 BPF_ALU32_IMM(BPF_MOV
, R1
, 6),
3681 BPF_ALU64_REG(BPF_XOR
, R0
, R1
),
3689 "ALU64_XOR_X: 1 ^ 0xffffffff = 0xfffffffe",
3691 BPF_LD_IMM64(R0
, 1),
3692 BPF_ALU32_IMM(BPF_MOV
, R1
, 0xffffffff),
3693 BPF_ALU64_REG(BPF_XOR
, R0
, R1
),
3698 { { 0, 0xfffffffe } },
3700 /* BPF_ALU | BPF_XOR | BPF_K */
3702 "ALU_XOR_K: 5 ^ 6 = 3",
3704 BPF_LD_IMM64(R0
, 5),
3705 BPF_ALU32_IMM(BPF_XOR
, R0
, 6),
3713 "ALU_XOR_K: 1 ^ 0xffffffff = 0xfffffffe",
3715 BPF_LD_IMM64(R0
, 1),
3716 BPF_ALU32_IMM(BPF_XOR
, R0
, 0xffffffff),
3721 { { 0, 0xfffffffe } },
3724 "ALU64_XOR_K: 5 ^ 6 = 3",
3726 BPF_LD_IMM64(R0
, 5),
3727 BPF_ALU64_IMM(BPF_XOR
, R0
, 6),
3735 "ALU64_XOR_K: 1 & 0xffffffff = 0xfffffffe",
3737 BPF_LD_IMM64(R0
, 1),
3738 BPF_ALU64_IMM(BPF_XOR
, R0
, 0xffffffff),
3743 { { 0, 0xfffffffe } },
3746 "ALU64_XOR_K: 0x0000ffffffff0000 ^ 0x0 = 0x0000ffffffff0000",
3748 BPF_LD_IMM64(R2
, 0x0000ffffffff0000LL
),
3749 BPF_LD_IMM64(R3
, 0x0000ffffffff0000LL
),
3750 BPF_ALU64_IMM(BPF_XOR
, R2
, 0x0),
3751 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
3752 BPF_MOV32_IMM(R0
, 2),
3754 BPF_MOV32_IMM(R0
, 1),
3762 "ALU64_XOR_K: 0x0000ffffffff0000 ^ -1 = 0xffff00000000ffff",
3764 BPF_LD_IMM64(R2
, 0x0000ffffffff0000LL
),
3765 BPF_LD_IMM64(R3
, 0xffff00000000ffffLL
),
3766 BPF_ALU64_IMM(BPF_XOR
, R2
, 0xffffffff),
3767 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
3768 BPF_MOV32_IMM(R0
, 2),
3770 BPF_MOV32_IMM(R0
, 1),
3778 "ALU64_XOR_K: 0x000000000000000 ^ -1 = 0xffffffffffffffff",
3780 BPF_LD_IMM64(R2
, 0x0000000000000000LL
),
3781 BPF_LD_IMM64(R3
, 0xffffffffffffffffLL
),
3782 BPF_ALU64_IMM(BPF_XOR
, R2
, 0xffffffff),
3783 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
3784 BPF_MOV32_IMM(R0
, 2),
3786 BPF_MOV32_IMM(R0
, 1),
3793 /* BPF_ALU | BPF_LSH | BPF_X */
3795 "ALU_LSH_X: 1 << 1 = 2",
3797 BPF_LD_IMM64(R0
, 1),
3798 BPF_ALU32_IMM(BPF_MOV
, R1
, 1),
3799 BPF_ALU32_REG(BPF_LSH
, R0
, R1
),
3807 "ALU_LSH_X: 1 << 31 = 0x80000000",
3809 BPF_LD_IMM64(R0
, 1),
3810 BPF_ALU32_IMM(BPF_MOV
, R1
, 31),
3811 BPF_ALU32_REG(BPF_LSH
, R0
, R1
),
3816 { { 0, 0x80000000 } },
3819 "ALU64_LSH_X: 1 << 1 = 2",
3821 BPF_LD_IMM64(R0
, 1),
3822 BPF_ALU32_IMM(BPF_MOV
, R1
, 1),
3823 BPF_ALU64_REG(BPF_LSH
, R0
, R1
),
3831 "ALU64_LSH_X: 1 << 31 = 0x80000000",
3833 BPF_LD_IMM64(R0
, 1),
3834 BPF_ALU32_IMM(BPF_MOV
, R1
, 31),
3835 BPF_ALU64_REG(BPF_LSH
, R0
, R1
),
3840 { { 0, 0x80000000 } },
3842 /* BPF_ALU | BPF_LSH | BPF_K */
3844 "ALU_LSH_K: 1 << 1 = 2",
3846 BPF_LD_IMM64(R0
, 1),
3847 BPF_ALU32_IMM(BPF_LSH
, R0
, 1),
3855 "ALU_LSH_K: 1 << 31 = 0x80000000",
3857 BPF_LD_IMM64(R0
, 1),
3858 BPF_ALU32_IMM(BPF_LSH
, R0
, 31),
3863 { { 0, 0x80000000 } },
3866 "ALU64_LSH_K: 1 << 1 = 2",
3868 BPF_LD_IMM64(R0
, 1),
3869 BPF_ALU64_IMM(BPF_LSH
, R0
, 1),
3877 "ALU64_LSH_K: 1 << 31 = 0x80000000",
3879 BPF_LD_IMM64(R0
, 1),
3880 BPF_ALU64_IMM(BPF_LSH
, R0
, 31),
3885 { { 0, 0x80000000 } },
3887 /* BPF_ALU | BPF_RSH | BPF_X */
3889 "ALU_RSH_X: 2 >> 1 = 1",
3891 BPF_LD_IMM64(R0
, 2),
3892 BPF_ALU32_IMM(BPF_MOV
, R1
, 1),
3893 BPF_ALU32_REG(BPF_RSH
, R0
, R1
),
3901 "ALU_RSH_X: 0x80000000 >> 31 = 1",
3903 BPF_LD_IMM64(R0
, 0x80000000),
3904 BPF_ALU32_IMM(BPF_MOV
, R1
, 31),
3905 BPF_ALU32_REG(BPF_RSH
, R0
, R1
),
3913 "ALU64_RSH_X: 2 >> 1 = 1",
3915 BPF_LD_IMM64(R0
, 2),
3916 BPF_ALU32_IMM(BPF_MOV
, R1
, 1),
3917 BPF_ALU64_REG(BPF_RSH
, R0
, R1
),
3925 "ALU64_RSH_X: 0x80000000 >> 31 = 1",
3927 BPF_LD_IMM64(R0
, 0x80000000),
3928 BPF_ALU32_IMM(BPF_MOV
, R1
, 31),
3929 BPF_ALU64_REG(BPF_RSH
, R0
, R1
),
3936 /* BPF_ALU | BPF_RSH | BPF_K */
3938 "ALU_RSH_K: 2 >> 1 = 1",
3940 BPF_LD_IMM64(R0
, 2),
3941 BPF_ALU32_IMM(BPF_RSH
, R0
, 1),
3949 "ALU_RSH_K: 0x80000000 >> 31 = 1",
3951 BPF_LD_IMM64(R0
, 0x80000000),
3952 BPF_ALU32_IMM(BPF_RSH
, R0
, 31),
3960 "ALU64_RSH_K: 2 >> 1 = 1",
3962 BPF_LD_IMM64(R0
, 2),
3963 BPF_ALU64_IMM(BPF_RSH
, R0
, 1),
3971 "ALU64_RSH_K: 0x80000000 >> 31 = 1",
3973 BPF_LD_IMM64(R0
, 0x80000000),
3974 BPF_ALU64_IMM(BPF_RSH
, R0
, 31),
3981 /* BPF_ALU | BPF_ARSH | BPF_X */
3983 "ALU_ARSH_X: 0xff00ff0000000000 >> 40 = 0xffffffffffff00ff",
3985 BPF_LD_IMM64(R0
, 0xff00ff0000000000LL
),
3986 BPF_ALU32_IMM(BPF_MOV
, R1
, 40),
3987 BPF_ALU64_REG(BPF_ARSH
, R0
, R1
),
3992 { { 0, 0xffff00ff } },
3994 /* BPF_ALU | BPF_ARSH | BPF_K */
3996 "ALU_ARSH_K: 0xff00ff0000000000 >> 40 = 0xffffffffffff00ff",
3998 BPF_LD_IMM64(R0
, 0xff00ff0000000000LL
),
3999 BPF_ALU64_IMM(BPF_ARSH
, R0
, 40),
4004 { { 0, 0xffff00ff } },
4006 /* BPF_ALU | BPF_NEG */
4008 "ALU_NEG: -(3) = -3",
4010 BPF_ALU32_IMM(BPF_MOV
, R0
, 3),
4011 BPF_ALU32_IMM(BPF_NEG
, R0
, 0),
4019 "ALU_NEG: -(-3) = 3",
4021 BPF_ALU32_IMM(BPF_MOV
, R0
, -3),
4022 BPF_ALU32_IMM(BPF_NEG
, R0
, 0),
4030 "ALU64_NEG: -(3) = -3",
4032 BPF_LD_IMM64(R0
, 3),
4033 BPF_ALU64_IMM(BPF_NEG
, R0
, 0),
4041 "ALU64_NEG: -(-3) = 3",
4043 BPF_LD_IMM64(R0
, -3),
4044 BPF_ALU64_IMM(BPF_NEG
, R0
, 0),
4051 /* BPF_ALU | BPF_END | BPF_FROM_BE */
4053 "ALU_END_FROM_BE 16: 0x0123456789abcdef -> 0xcdef",
4055 BPF_LD_IMM64(R0
, 0x0123456789abcdefLL
),
4056 BPF_ENDIAN(BPF_FROM_BE
, R0
, 16),
4061 { { 0, cpu_to_be16(0xcdef) } },
4064 "ALU_END_FROM_BE 32: 0x0123456789abcdef -> 0x89abcdef",
4066 BPF_LD_IMM64(R0
, 0x0123456789abcdefLL
),
4067 BPF_ENDIAN(BPF_FROM_BE
, R0
, 32),
4068 BPF_ALU64_REG(BPF_MOV
, R1
, R0
),
4069 BPF_ALU64_IMM(BPF_RSH
, R1
, 32),
4070 BPF_ALU32_REG(BPF_ADD
, R0
, R1
), /* R1 = 0 */
4075 { { 0, cpu_to_be32(0x89abcdef) } },
4078 "ALU_END_FROM_BE 64: 0x0123456789abcdef -> 0x89abcdef",
4080 BPF_LD_IMM64(R0
, 0x0123456789abcdefLL
),
4081 BPF_ENDIAN(BPF_FROM_BE
, R0
, 64),
4086 { { 0, (u32
) cpu_to_be64(0x0123456789abcdefLL
) } },
4088 /* BPF_ALU | BPF_END | BPF_FROM_LE */
4090 "ALU_END_FROM_LE 16: 0x0123456789abcdef -> 0xefcd",
4092 BPF_LD_IMM64(R0
, 0x0123456789abcdefLL
),
4093 BPF_ENDIAN(BPF_FROM_LE
, R0
, 16),
4098 { { 0, cpu_to_le16(0xcdef) } },
4101 "ALU_END_FROM_LE 32: 0x0123456789abcdef -> 0xefcdab89",
4103 BPF_LD_IMM64(R0
, 0x0123456789abcdefLL
),
4104 BPF_ENDIAN(BPF_FROM_LE
, R0
, 32),
4105 BPF_ALU64_REG(BPF_MOV
, R1
, R0
),
4106 BPF_ALU64_IMM(BPF_RSH
, R1
, 32),
4107 BPF_ALU32_REG(BPF_ADD
, R0
, R1
), /* R1 = 0 */
4112 { { 0, cpu_to_le32(0x89abcdef) } },
4115 "ALU_END_FROM_LE 64: 0x0123456789abcdef -> 0x67452301",
4117 BPF_LD_IMM64(R0
, 0x0123456789abcdefLL
),
4118 BPF_ENDIAN(BPF_FROM_LE
, R0
, 64),
4123 { { 0, (u32
) cpu_to_le64(0x0123456789abcdefLL
) } },
4125 /* BPF_ST(X) | BPF_MEM | BPF_B/H/W/DW */
4127 "ST_MEM_B: Store/Load byte: max negative",
4129 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4130 BPF_ST_MEM(BPF_B
, R10
, -40, 0xff),
4131 BPF_LDX_MEM(BPF_B
, R0
, R10
, -40),
4139 "ST_MEM_B: Store/Load byte: max positive",
4141 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4142 BPF_ST_MEM(BPF_H
, R10
, -40, 0x7f),
4143 BPF_LDX_MEM(BPF_H
, R0
, R10
, -40),
4151 "STX_MEM_B: Store/Load byte: max negative",
4153 BPF_LD_IMM64(R0
, 0),
4154 BPF_LD_IMM64(R1
, 0xffLL
),
4155 BPF_STX_MEM(BPF_B
, R10
, R1
, -40),
4156 BPF_LDX_MEM(BPF_B
, R0
, R10
, -40),
4164 "ST_MEM_H: Store/Load half word: max negative",
4166 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4167 BPF_ST_MEM(BPF_H
, R10
, -40, 0xffff),
4168 BPF_LDX_MEM(BPF_H
, R0
, R10
, -40),
4176 "ST_MEM_H: Store/Load half word: max positive",
4178 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4179 BPF_ST_MEM(BPF_H
, R10
, -40, 0x7fff),
4180 BPF_LDX_MEM(BPF_H
, R0
, R10
, -40),
4188 "STX_MEM_H: Store/Load half word: max negative",
4190 BPF_LD_IMM64(R0
, 0),
4191 BPF_LD_IMM64(R1
, 0xffffLL
),
4192 BPF_STX_MEM(BPF_H
, R10
, R1
, -40),
4193 BPF_LDX_MEM(BPF_H
, R0
, R10
, -40),
4201 "ST_MEM_W: Store/Load word: max negative",
4203 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4204 BPF_ST_MEM(BPF_W
, R10
, -40, 0xffffffff),
4205 BPF_LDX_MEM(BPF_W
, R0
, R10
, -40),
4210 { { 0, 0xffffffff } },
4213 "ST_MEM_W: Store/Load word: max positive",
4215 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4216 BPF_ST_MEM(BPF_W
, R10
, -40, 0x7fffffff),
4217 BPF_LDX_MEM(BPF_W
, R0
, R10
, -40),
4222 { { 0, 0x7fffffff } },
4225 "STX_MEM_W: Store/Load word: max negative",
4227 BPF_LD_IMM64(R0
, 0),
4228 BPF_LD_IMM64(R1
, 0xffffffffLL
),
4229 BPF_STX_MEM(BPF_W
, R10
, R1
, -40),
4230 BPF_LDX_MEM(BPF_W
, R0
, R10
, -40),
4235 { { 0, 0xffffffff } },
4238 "ST_MEM_DW: Store/Load double word: max negative",
4240 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4241 BPF_ST_MEM(BPF_DW
, R10
, -40, 0xffffffff),
4242 BPF_LDX_MEM(BPF_DW
, R0
, R10
, -40),
4247 { { 0, 0xffffffff } },
4250 "ST_MEM_DW: Store/Load double word: max negative 2",
4252 BPF_LD_IMM64(R2
, 0xffff00000000ffffLL
),
4253 BPF_LD_IMM64(R3
, 0xffffffffffffffffLL
),
4254 BPF_ST_MEM(BPF_DW
, R10
, -40, 0xffffffff),
4255 BPF_LDX_MEM(BPF_DW
, R2
, R10
, -40),
4256 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
4257 BPF_MOV32_IMM(R0
, 2),
4259 BPF_MOV32_IMM(R0
, 1),
4267 "ST_MEM_DW: Store/Load double word: max positive",
4269 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4270 BPF_ST_MEM(BPF_DW
, R10
, -40, 0x7fffffff),
4271 BPF_LDX_MEM(BPF_DW
, R0
, R10
, -40),
4276 { { 0, 0x7fffffff } },
4279 "STX_MEM_DW: Store/Load double word: max negative",
4281 BPF_LD_IMM64(R0
, 0),
4282 BPF_LD_IMM64(R1
, 0xffffffffffffffffLL
),
4283 BPF_STX_MEM(BPF_W
, R10
, R1
, -40),
4284 BPF_LDX_MEM(BPF_W
, R0
, R10
, -40),
4289 { { 0, 0xffffffff } },
4291 /* BPF_STX | BPF_XADD | BPF_W/DW */
4293 "STX_XADD_W: Test: 0x12 + 0x10 = 0x22",
4295 BPF_ALU32_IMM(BPF_MOV
, R0
, 0x12),
4296 BPF_ST_MEM(BPF_W
, R10
, -40, 0x10),
4297 BPF_STX_XADD(BPF_W
, R10
, R0
, -40),
4298 BPF_LDX_MEM(BPF_W
, R0
, R10
, -40),
4306 "STX_XADD_DW: Test: 0x12 + 0x10 = 0x22",
4308 BPF_ALU32_IMM(BPF_MOV
, R0
, 0x12),
4309 BPF_ST_MEM(BPF_DW
, R10
, -40, 0x10),
4310 BPF_STX_XADD(BPF_DW
, R10
, R0
, -40),
4311 BPF_LDX_MEM(BPF_DW
, R0
, R10
, -40),
4318 /* BPF_JMP | BPF_EXIT */
4322 BPF_ALU32_IMM(BPF_MOV
, R0
, 0x4711),
4324 BPF_ALU32_IMM(BPF_MOV
, R0
, 0x4712),
4330 /* BPF_JMP | BPF_JA */
4332 "JMP_JA: Unconditional jump: if (true) return 1",
4334 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
4335 BPF_JMP_IMM(BPF_JA
, 0, 0, 1),
4337 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4344 /* BPF_JMP | BPF_JSGT | BPF_K */
4346 "JMP_JSGT_K: Signed jump: if (-1 > -2) return 1",
4348 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
4349 BPF_LD_IMM64(R1
, 0xffffffffffffffffLL
),
4350 BPF_JMP_IMM(BPF_JSGT
, R1
, -2, 1),
4352 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4360 "JMP_JSGT_K: Signed jump: if (-1 > -1) return 0",
4362 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4363 BPF_LD_IMM64(R1
, 0xffffffffffffffffLL
),
4364 BPF_JMP_IMM(BPF_JSGT
, R1
, -1, 1),
4366 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
4373 /* BPF_JMP | BPF_JSGE | BPF_K */
4375 "JMP_JSGE_K: Signed jump: if (-1 >= -2) return 1",
4377 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
4378 BPF_LD_IMM64(R1
, 0xffffffffffffffffLL
),
4379 BPF_JMP_IMM(BPF_JSGE
, R1
, -2, 1),
4381 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4389 "JMP_JSGE_K: Signed jump: if (-1 >= -1) return 1",
4391 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
4392 BPF_LD_IMM64(R1
, 0xffffffffffffffffLL
),
4393 BPF_JMP_IMM(BPF_JSGE
, R1
, -1, 1),
4395 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4402 /* BPF_JMP | BPF_JGT | BPF_K */
4404 "JMP_JGT_K: if (3 > 2) return 1",
4406 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
4407 BPF_LD_IMM64(R1
, 3),
4408 BPF_JMP_IMM(BPF_JGT
, R1
, 2, 1),
4410 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4418 "JMP_JGT_K: Unsigned jump: if (-1 > 1) return 1",
4420 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
4421 BPF_LD_IMM64(R1
, -1),
4422 BPF_JMP_IMM(BPF_JGT
, R1
, 1, 1),
4424 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4431 /* BPF_JMP | BPF_JGE | BPF_K */
4433 "JMP_JGE_K: if (3 >= 2) return 1",
4435 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
4436 BPF_LD_IMM64(R1
, 3),
4437 BPF_JMP_IMM(BPF_JGE
, R1
, 2, 1),
4439 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4446 /* BPF_JMP | BPF_JGT | BPF_K jump backwards */
4448 "JMP_JGT_K: if (3 > 2) return 1 (jump backwards)",
4450 BPF_JMP_IMM(BPF_JA
, 0, 0, 2), /* goto start */
4451 BPF_ALU32_IMM(BPF_MOV
, R0
, 1), /* out: */
4453 BPF_ALU32_IMM(BPF_MOV
, R0
, 0), /* start: */
4454 BPF_LD_IMM64(R1
, 3), /* note: this takes 2 insns */
4455 BPF_JMP_IMM(BPF_JGT
, R1
, 2, -6), /* goto out */
4463 "JMP_JGE_K: if (3 >= 3) return 1",
4465 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
4466 BPF_LD_IMM64(R1
, 3),
4467 BPF_JMP_IMM(BPF_JGE
, R1
, 3, 1),
4469 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4476 /* BPF_JMP | BPF_JNE | BPF_K */
4478 "JMP_JNE_K: if (3 != 2) return 1",
4480 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
4481 BPF_LD_IMM64(R1
, 3),
4482 BPF_JMP_IMM(BPF_JNE
, R1
, 2, 1),
4484 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4491 /* BPF_JMP | BPF_JEQ | BPF_K */
4493 "JMP_JEQ_K: if (3 == 3) return 1",
4495 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
4496 BPF_LD_IMM64(R1
, 3),
4497 BPF_JMP_IMM(BPF_JEQ
, R1
, 3, 1),
4499 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4506 /* BPF_JMP | BPF_JSET | BPF_K */
4508 "JMP_JSET_K: if (0x3 & 0x2) return 1",
4510 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
4511 BPF_LD_IMM64(R1
, 3),
4512 BPF_JMP_IMM(BPF_JSET
, R1
, 2, 1),
4514 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4522 "JMP_JSET_K: if (0x3 & 0xffffffff) return 1",
4524 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
4525 BPF_LD_IMM64(R1
, 3),
4526 BPF_JMP_IMM(BPF_JSET
, R1
, 0xffffffff, 1),
4528 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4535 /* BPF_JMP | BPF_JSGT | BPF_X */
4537 "JMP_JSGT_X: Signed jump: if (-1 > -2) return 1",
4539 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
4540 BPF_LD_IMM64(R1
, -1),
4541 BPF_LD_IMM64(R2
, -2),
4542 BPF_JMP_REG(BPF_JSGT
, R1
, R2
, 1),
4544 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4552 "JMP_JSGT_X: Signed jump: if (-1 > -1) return 0",
4554 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4555 BPF_LD_IMM64(R1
, -1),
4556 BPF_LD_IMM64(R2
, -1),
4557 BPF_JMP_REG(BPF_JSGT
, R1
, R2
, 1),
4559 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
4566 /* BPF_JMP | BPF_JSGE | BPF_X */
4568 "JMP_JSGE_X: Signed jump: if (-1 >= -2) return 1",
4570 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
4571 BPF_LD_IMM64(R1
, -1),
4572 BPF_LD_IMM64(R2
, -2),
4573 BPF_JMP_REG(BPF_JSGE
, R1
, R2
, 1),
4575 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4583 "JMP_JSGE_X: Signed jump: if (-1 >= -1) return 1",
4585 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
4586 BPF_LD_IMM64(R1
, -1),
4587 BPF_LD_IMM64(R2
, -1),
4588 BPF_JMP_REG(BPF_JSGE
, R1
, R2
, 1),
4590 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4597 /* BPF_JMP | BPF_JGT | BPF_X */
4599 "JMP_JGT_X: if (3 > 2) return 1",
4601 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
4602 BPF_LD_IMM64(R1
, 3),
4603 BPF_LD_IMM64(R2
, 2),
4604 BPF_JMP_REG(BPF_JGT
, R1
, R2
, 1),
4606 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4614 "JMP_JGT_X: Unsigned jump: if (-1 > 1) return 1",
4616 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
4617 BPF_LD_IMM64(R1
, -1),
4618 BPF_LD_IMM64(R2
, 1),
4619 BPF_JMP_REG(BPF_JGT
, R1
, R2
, 1),
4621 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4628 /* BPF_JMP | BPF_JGE | BPF_X */
4630 "JMP_JGE_X: if (3 >= 2) return 1",
4632 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
4633 BPF_LD_IMM64(R1
, 3),
4634 BPF_LD_IMM64(R2
, 2),
4635 BPF_JMP_REG(BPF_JGE
, R1
, R2
, 1),
4637 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4645 "JMP_JGE_X: if (3 >= 3) return 1",
4647 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
4648 BPF_LD_IMM64(R1
, 3),
4649 BPF_LD_IMM64(R2
, 3),
4650 BPF_JMP_REG(BPF_JGE
, R1
, R2
, 1),
4652 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4659 /* BPF_JMP | BPF_JNE | BPF_X */
4661 "JMP_JNE_X: if (3 != 2) return 1",
4663 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
4664 BPF_LD_IMM64(R1
, 3),
4665 BPF_LD_IMM64(R2
, 2),
4666 BPF_JMP_REG(BPF_JNE
, R1
, R2
, 1),
4668 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4675 /* BPF_JMP | BPF_JEQ | BPF_X */
4677 "JMP_JEQ_X: if (3 == 3) return 1",
4679 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
4680 BPF_LD_IMM64(R1
, 3),
4681 BPF_LD_IMM64(R2
, 3),
4682 BPF_JMP_REG(BPF_JEQ
, R1
, R2
, 1),
4684 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4691 /* BPF_JMP | BPF_JSET | BPF_X */
4693 "JMP_JSET_X: if (0x3 & 0x2) return 1",
4695 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
4696 BPF_LD_IMM64(R1
, 3),
4697 BPF_LD_IMM64(R2
, 2),
4698 BPF_JMP_REG(BPF_JSET
, R1
, R2
, 1),
4700 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4708 "JMP_JSET_X: if (0x3 & 0xffffffff) return 1",
4710 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
4711 BPF_LD_IMM64(R1
, 3),
4712 BPF_LD_IMM64(R2
, 0xffffffff),
4713 BPF_JMP_REG(BPF_JSET
, R1
, R2
, 1),
4715 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4723 "JMP_JA: Jump, gap, jump, ...",
4725 CLASSIC
| FLAG_NO_DATA
,
4727 { { 0, 0xababcbac } },
4728 .fill_helper
= bpf_fill_ja
,
4730 { /* Mainly checking JIT here. */
4731 "BPF_MAXINSNS: Maximum possible literals",
4733 CLASSIC
| FLAG_NO_DATA
,
4735 { { 0, 0xffffffff } },
4736 .fill_helper
= bpf_fill_maxinsns1
,
4738 { /* Mainly checking JIT here. */
4739 "BPF_MAXINSNS: Single literal",
4741 CLASSIC
| FLAG_NO_DATA
,
4743 { { 0, 0xfefefefe } },
4744 .fill_helper
= bpf_fill_maxinsns2
,
4746 { /* Mainly checking JIT here. */
4747 "BPF_MAXINSNS: Run/add until end",
4749 CLASSIC
| FLAG_NO_DATA
,
4751 { { 0, 0x947bf368 } },
4752 .fill_helper
= bpf_fill_maxinsns3
,
4755 "BPF_MAXINSNS: Too many instructions",
4757 CLASSIC
| FLAG_NO_DATA
| FLAG_EXPECTED_FAIL
,
4760 .fill_helper
= bpf_fill_maxinsns4
,
4762 { /* Mainly checking JIT here. */
4763 "BPF_MAXINSNS: Very long jump",
4765 CLASSIC
| FLAG_NO_DATA
,
4767 { { 0, 0xabababab } },
4768 .fill_helper
= bpf_fill_maxinsns5
,
4770 { /* Mainly checking JIT here. */
4771 "BPF_MAXINSNS: Ctx heavy transformations",
4776 { 1, !!(SKB_VLAN_TCI
& VLAN_TAG_PRESENT
) },
4777 { 10, !!(SKB_VLAN_TCI
& VLAN_TAG_PRESENT
) }
4779 .fill_helper
= bpf_fill_maxinsns6
,
4781 { /* Mainly checking JIT here. */
4782 "BPF_MAXINSNS: Call heavy transformations",
4784 CLASSIC
| FLAG_NO_DATA
,
4786 { { 1, 0 }, { 10, 0 } },
4787 .fill_helper
= bpf_fill_maxinsns7
,
4789 { /* Mainly checking JIT here. */
4790 "BPF_MAXINSNS: Jump heavy test",
4792 CLASSIC
| FLAG_NO_DATA
,
4794 { { 0, 0xffffffff } },
4795 .fill_helper
= bpf_fill_maxinsns8
,
4797 { /* Mainly checking JIT here. */
4798 "BPF_MAXINSNS: Very long jump backwards",
4800 INTERNAL
| FLAG_NO_DATA
,
4802 { { 0, 0xcbababab } },
4803 .fill_helper
= bpf_fill_maxinsns9
,
4805 { /* Mainly checking JIT here. */
4806 "BPF_MAXINSNS: Edge hopping nuthouse",
4808 INTERNAL
| FLAG_NO_DATA
,
4810 { { 0, 0xabababac } },
4811 .fill_helper
= bpf_fill_maxinsns10
,
4814 "BPF_MAXINSNS: Jump, gap, jump, ...",
4816 CLASSIC
| FLAG_NO_DATA
,
4818 { { 0, 0xababcbac } },
4819 .fill_helper
= bpf_fill_maxinsns11
,
4822 "BPF_MAXINSNS: ld_abs+get_processor_id",
4827 .fill_helper
= bpf_fill_ld_abs_get_processor_id
,
4830 "BPF_MAXINSNS: ld_abs+vlan_push/pop",
4834 { { ETH_HLEN
, 0xbef } },
4835 .fill_helper
= bpf_fill_ld_abs_vlan_push_pop
,
4838 * LD_IND / LD_ABS on fragmented SKBs
4843 BPF_STMT(BPF_LDX
| BPF_IMM
, 0x40),
4844 BPF_STMT(BPF_LD
| BPF_IND
| BPF_B
, 0x0),
4845 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
4847 CLASSIC
| FLAG_SKB_FRAG
,
4851 0x42, 0x00, 0x00, 0x00,
4852 0x43, 0x44, 0x00, 0x00,
4853 0x21, 0x07, 0x19, 0x83,
4857 "LD_IND halfword frag",
4859 BPF_STMT(BPF_LDX
| BPF_IMM
, 0x40),
4860 BPF_STMT(BPF_LD
| BPF_IND
| BPF_H
, 0x4),
4861 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
4863 CLASSIC
| FLAG_SKB_FRAG
,
4867 0x42, 0x00, 0x00, 0x00,
4868 0x43, 0x44, 0x00, 0x00,
4869 0x21, 0x07, 0x19, 0x83,
4875 BPF_STMT(BPF_LDX
| BPF_IMM
, 0x40),
4876 BPF_STMT(BPF_LD
| BPF_IND
| BPF_W
, 0x8),
4877 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
4879 CLASSIC
| FLAG_SKB_FRAG
,
4881 { {0x40, 0x21071983} },
4883 0x42, 0x00, 0x00, 0x00,
4884 0x43, 0x44, 0x00, 0x00,
4885 0x21, 0x07, 0x19, 0x83,
4889 "LD_IND halfword mixed head/frag",
4891 BPF_STMT(BPF_LDX
| BPF_IMM
, 0x40),
4892 BPF_STMT(BPF_LD
| BPF_IND
| BPF_H
, -0x1),
4893 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
4895 CLASSIC
| FLAG_SKB_FRAG
,
4896 { [0x3e] = 0x25, [0x3f] = 0x05, },
4898 .frag_data
= { 0x19, 0x82 },
4901 "LD_IND word mixed head/frag",
4903 BPF_STMT(BPF_LDX
| BPF_IMM
, 0x40),
4904 BPF_STMT(BPF_LD
| BPF_IND
| BPF_W
, -0x2),
4905 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
4907 CLASSIC
| FLAG_SKB_FRAG
,
4908 { [0x3e] = 0x25, [0x3f] = 0x05, },
4909 { {0x40, 0x25051982} },
4910 .frag_data
= { 0x19, 0x82 },
4915 BPF_STMT(BPF_LD
| BPF_ABS
| BPF_B
, 0x40),
4916 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
4918 CLASSIC
| FLAG_SKB_FRAG
,
4922 0x42, 0x00, 0x00, 0x00,
4923 0x43, 0x44, 0x00, 0x00,
4924 0x21, 0x07, 0x19, 0x83,
4928 "LD_ABS halfword frag",
4930 BPF_STMT(BPF_LD
| BPF_ABS
| BPF_H
, 0x44),
4931 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
4933 CLASSIC
| FLAG_SKB_FRAG
,
4937 0x42, 0x00, 0x00, 0x00,
4938 0x43, 0x44, 0x00, 0x00,
4939 0x21, 0x07, 0x19, 0x83,
4945 BPF_STMT(BPF_LD
| BPF_ABS
| BPF_W
, 0x48),
4946 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
4948 CLASSIC
| FLAG_SKB_FRAG
,
4950 { {0x40, 0x21071983} },
4952 0x42, 0x00, 0x00, 0x00,
4953 0x43, 0x44, 0x00, 0x00,
4954 0x21, 0x07, 0x19, 0x83,
4958 "LD_ABS halfword mixed head/frag",
4960 BPF_STMT(BPF_LD
| BPF_ABS
| BPF_H
, 0x3f),
4961 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
4963 CLASSIC
| FLAG_SKB_FRAG
,
4964 { [0x3e] = 0x25, [0x3f] = 0x05, },
4966 .frag_data
= { 0x19, 0x82 },
4969 "LD_ABS word mixed head/frag",
4971 BPF_STMT(BPF_LD
| BPF_ABS
| BPF_W
, 0x3e),
4972 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
4974 CLASSIC
| FLAG_SKB_FRAG
,
4975 { [0x3e] = 0x25, [0x3f] = 0x05, },
4976 { {0x40, 0x25051982} },
4977 .frag_data
= { 0x19, 0x82 },
4980 * LD_IND / LD_ABS on non fragmented SKBs
4984 * this tests that the JIT/interpreter correctly resets X
4985 * before using it in an LD_IND instruction.
4987 "LD_IND byte default X",
4989 BPF_STMT(BPF_LD
| BPF_IND
| BPF_B
, 0x1),
4990 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
4997 "LD_IND byte positive offset",
4999 BPF_STMT(BPF_LDX
| BPF_IMM
, 0x3e),
5000 BPF_STMT(BPF_LD
| BPF_IND
| BPF_B
, 0x1),
5001 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
5004 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
5008 "LD_IND byte negative offset",
5010 BPF_STMT(BPF_LDX
| BPF_IMM
, 0x3e),
5011 BPF_STMT(BPF_LD
| BPF_IND
| BPF_B
, -0x1),
5012 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
5015 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
5019 "LD_IND halfword positive offset",
5021 BPF_STMT(BPF_LDX
| BPF_IMM
, 0x20),
5022 BPF_STMT(BPF_LD
| BPF_IND
| BPF_H
, 0x2),
5023 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
5027 [0x1c] = 0xaa, [0x1d] = 0x55,
5028 [0x1e] = 0xbb, [0x1f] = 0x66,
5029 [0x20] = 0xcc, [0x21] = 0x77,
5030 [0x22] = 0xdd, [0x23] = 0x88,
5032 { {0x40, 0xdd88 } },
5035 "LD_IND halfword negative offset",
5037 BPF_STMT(BPF_LDX
| BPF_IMM
, 0x20),
5038 BPF_STMT(BPF_LD
| BPF_IND
| BPF_H
, -0x2),
5039 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
5043 [0x1c] = 0xaa, [0x1d] = 0x55,
5044 [0x1e] = 0xbb, [0x1f] = 0x66,
5045 [0x20] = 0xcc, [0x21] = 0x77,
5046 [0x22] = 0xdd, [0x23] = 0x88,
5048 { {0x40, 0xbb66 } },
5051 "LD_IND halfword unaligned",
5053 BPF_STMT(BPF_LDX
| BPF_IMM
, 0x20),
5054 BPF_STMT(BPF_LD
| BPF_IND
| BPF_H
, -0x1),
5055 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
5059 [0x1c] = 0xaa, [0x1d] = 0x55,
5060 [0x1e] = 0xbb, [0x1f] = 0x66,
5061 [0x20] = 0xcc, [0x21] = 0x77,
5062 [0x22] = 0xdd, [0x23] = 0x88,
5064 { {0x40, 0x66cc } },
5067 "LD_IND word positive offset",
5069 BPF_STMT(BPF_LDX
| BPF_IMM
, 0x20),
5070 BPF_STMT(BPF_LD
| BPF_IND
| BPF_W
, 0x4),
5071 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
5075 [0x1c] = 0xaa, [0x1d] = 0x55,
5076 [0x1e] = 0xbb, [0x1f] = 0x66,
5077 [0x20] = 0xcc, [0x21] = 0x77,
5078 [0x22] = 0xdd, [0x23] = 0x88,
5079 [0x24] = 0xee, [0x25] = 0x99,
5080 [0x26] = 0xff, [0x27] = 0xaa,
5082 { {0x40, 0xee99ffaa } },
5085 "LD_IND word negative offset",
5087 BPF_STMT(BPF_LDX
| BPF_IMM
, 0x20),
5088 BPF_STMT(BPF_LD
| BPF_IND
| BPF_W
, -0x4),
5089 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
5093 [0x1c] = 0xaa, [0x1d] = 0x55,
5094 [0x1e] = 0xbb, [0x1f] = 0x66,
5095 [0x20] = 0xcc, [0x21] = 0x77,
5096 [0x22] = 0xdd, [0x23] = 0x88,
5097 [0x24] = 0xee, [0x25] = 0x99,
5098 [0x26] = 0xff, [0x27] = 0xaa,
5100 { {0x40, 0xaa55bb66 } },
5103 "LD_IND word unaligned (addr & 3 == 2)",
5105 BPF_STMT(BPF_LDX
| BPF_IMM
, 0x20),
5106 BPF_STMT(BPF_LD
| BPF_IND
| BPF_W
, -0x2),
5107 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
5111 [0x1c] = 0xaa, [0x1d] = 0x55,
5112 [0x1e] = 0xbb, [0x1f] = 0x66,
5113 [0x20] = 0xcc, [0x21] = 0x77,
5114 [0x22] = 0xdd, [0x23] = 0x88,
5115 [0x24] = 0xee, [0x25] = 0x99,
5116 [0x26] = 0xff, [0x27] = 0xaa,
5118 { {0x40, 0xbb66cc77 } },
5121 "LD_IND word unaligned (addr & 3 == 1)",
5123 BPF_STMT(BPF_LDX
| BPF_IMM
, 0x20),
5124 BPF_STMT(BPF_LD
| BPF_IND
| BPF_W
, -0x3),
5125 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
5129 [0x1c] = 0xaa, [0x1d] = 0x55,
5130 [0x1e] = 0xbb, [0x1f] = 0x66,
5131 [0x20] = 0xcc, [0x21] = 0x77,
5132 [0x22] = 0xdd, [0x23] = 0x88,
5133 [0x24] = 0xee, [0x25] = 0x99,
5134 [0x26] = 0xff, [0x27] = 0xaa,
5136 { {0x40, 0x55bb66cc } },
5139 "LD_IND word unaligned (addr & 3 == 3)",
5141 BPF_STMT(BPF_LDX
| BPF_IMM
, 0x20),
5142 BPF_STMT(BPF_LD
| BPF_IND
| BPF_W
, -0x1),
5143 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
5147 [0x1c] = 0xaa, [0x1d] = 0x55,
5148 [0x1e] = 0xbb, [0x1f] = 0x66,
5149 [0x20] = 0xcc, [0x21] = 0x77,
5150 [0x22] = 0xdd, [0x23] = 0x88,
5151 [0x24] = 0xee, [0x25] = 0x99,
5152 [0x26] = 0xff, [0x27] = 0xaa,
5154 { {0x40, 0x66cc77dd } },
5159 BPF_STMT(BPF_LD
| BPF_ABS
| BPF_B
, 0x20),
5160 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
5164 [0x1c] = 0xaa, [0x1d] = 0x55,
5165 [0x1e] = 0xbb, [0x1f] = 0x66,
5166 [0x20] = 0xcc, [0x21] = 0x77,
5167 [0x22] = 0xdd, [0x23] = 0x88,
5168 [0x24] = 0xee, [0x25] = 0x99,
5169 [0x26] = 0xff, [0x27] = 0xaa,
5176 BPF_STMT(BPF_LD
| BPF_ABS
| BPF_H
, 0x22),
5177 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
5181 [0x1c] = 0xaa, [0x1d] = 0x55,
5182 [0x1e] = 0xbb, [0x1f] = 0x66,
5183 [0x20] = 0xcc, [0x21] = 0x77,
5184 [0x22] = 0xdd, [0x23] = 0x88,
5185 [0x24] = 0xee, [0x25] = 0x99,
5186 [0x26] = 0xff, [0x27] = 0xaa,
5188 { {0x40, 0xdd88 } },
5191 "LD_ABS halfword unaligned",
5193 BPF_STMT(BPF_LD
| BPF_ABS
| BPF_H
, 0x25),
5194 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
5198 [0x1c] = 0xaa, [0x1d] = 0x55,
5199 [0x1e] = 0xbb, [0x1f] = 0x66,
5200 [0x20] = 0xcc, [0x21] = 0x77,
5201 [0x22] = 0xdd, [0x23] = 0x88,
5202 [0x24] = 0xee, [0x25] = 0x99,
5203 [0x26] = 0xff, [0x27] = 0xaa,
5205 { {0x40, 0x99ff } },
5210 BPF_STMT(BPF_LD
| BPF_ABS
| BPF_W
, 0x1c),
5211 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
5215 [0x1c] = 0xaa, [0x1d] = 0x55,
5216 [0x1e] = 0xbb, [0x1f] = 0x66,
5217 [0x20] = 0xcc, [0x21] = 0x77,
5218 [0x22] = 0xdd, [0x23] = 0x88,
5219 [0x24] = 0xee, [0x25] = 0x99,
5220 [0x26] = 0xff, [0x27] = 0xaa,
5222 { {0x40, 0xaa55bb66 } },
5225 "LD_ABS word unaligned (addr & 3 == 2)",
5227 BPF_STMT(BPF_LD
| BPF_ABS
| BPF_W
, 0x22),
5228 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
5232 [0x1c] = 0xaa, [0x1d] = 0x55,
5233 [0x1e] = 0xbb, [0x1f] = 0x66,
5234 [0x20] = 0xcc, [0x21] = 0x77,
5235 [0x22] = 0xdd, [0x23] = 0x88,
5236 [0x24] = 0xee, [0x25] = 0x99,
5237 [0x26] = 0xff, [0x27] = 0xaa,
5239 { {0x40, 0xdd88ee99 } },
5242 "LD_ABS word unaligned (addr & 3 == 1)",
5244 BPF_STMT(BPF_LD
| BPF_ABS
| BPF_W
, 0x21),
5245 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
5249 [0x1c] = 0xaa, [0x1d] = 0x55,
5250 [0x1e] = 0xbb, [0x1f] = 0x66,
5251 [0x20] = 0xcc, [0x21] = 0x77,
5252 [0x22] = 0xdd, [0x23] = 0x88,
5253 [0x24] = 0xee, [0x25] = 0x99,
5254 [0x26] = 0xff, [0x27] = 0xaa,
5256 { {0x40, 0x77dd88ee } },
5259 "LD_ABS word unaligned (addr & 3 == 3)",
5261 BPF_STMT(BPF_LD
| BPF_ABS
| BPF_W
, 0x23),
5262 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
5266 [0x1c] = 0xaa, [0x1d] = 0x55,
5267 [0x1e] = 0xbb, [0x1f] = 0x66,
5268 [0x20] = 0xcc, [0x21] = 0x77,
5269 [0x22] = 0xdd, [0x23] = 0x88,
5270 [0x24] = 0xee, [0x25] = 0x99,
5271 [0x26] = 0xff, [0x27] = 0xaa,
5273 { {0x40, 0x88ee99ff } },
5276 * verify that the interpreter or JIT correctly sets A and X
5287 BPF_STMT(BPF_LD
| BPF_IMM
, 0x42),
5288 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
5289 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
5291 CLASSIC
| FLAG_NO_DATA
,
5302 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 0x42),
5303 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
5305 CLASSIC
| FLAG_NO_DATA
,
5317 BPF_STMT(BPF_LD
| BPF_IMM
, 0x66),
5318 BPF_STMT(BPF_ALU
| BPF_SUB
| BPF_X
, 0),
5319 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
5321 CLASSIC
| FLAG_NO_DATA
,
5332 BPF_STMT(BPF_ALU
| BPF_SUB
| BPF_K
, -0x66),
5333 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
5335 CLASSIC
| FLAG_NO_DATA
,
5347 BPF_STMT(BPF_LD
| BPF_IMM
, 0x42),
5348 BPF_STMT(BPF_ALU
| BPF_MUL
| BPF_X
, 0),
5349 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
5351 CLASSIC
| FLAG_NO_DATA
,
5362 BPF_STMT(BPF_ALU
| BPF_MUL
| BPF_K
, 0x66),
5363 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
5365 CLASSIC
| FLAG_NO_DATA
,
5374 * A = A / X ; this halt the filter execution if X is 0
5377 BPF_STMT(BPF_LD
| BPF_IMM
, 0x42),
5378 BPF_STMT(BPF_ALU
| BPF_DIV
| BPF_X
, 0),
5379 BPF_STMT(BPF_RET
| BPF_K
, 0x42),
5381 CLASSIC
| FLAG_NO_DATA
,
5392 BPF_STMT(BPF_ALU
| BPF_DIV
| BPF_K
, 0x1),
5393 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
5395 CLASSIC
| FLAG_NO_DATA
,
5404 * A = A mod X ; this halt the filter execution if X is 0
5407 BPF_STMT(BPF_LD
| BPF_IMM
, 0x42),
5408 BPF_STMT(BPF_ALU
| BPF_MOD
| BPF_X
, 0),
5409 BPF_STMT(BPF_RET
| BPF_K
, 0x42),
5411 CLASSIC
| FLAG_NO_DATA
,
5422 BPF_STMT(BPF_ALU
| BPF_MOD
| BPF_K
, 0x1),
5423 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
5425 CLASSIC
| FLAG_NO_DATA
,
5437 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 0x0, 0, 1),
5438 BPF_STMT(BPF_RET
| BPF_K
, 0x42),
5439 BPF_STMT(BPF_RET
| BPF_K
, 0x66),
5441 CLASSIC
| FLAG_NO_DATA
,
5454 BPF_STMT(BPF_LD
| BPF_IMM
, 0x0),
5455 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_X
, 0x0, 0, 1),
5456 BPF_STMT(BPF_RET
| BPF_K
, 0x42),
5457 BPF_STMT(BPF_RET
| BPF_K
, 0x66),
5459 CLASSIC
| FLAG_NO_DATA
,
5465 static struct net_device dev
;
5467 static struct sk_buff
*populate_skb(char *buf
, int size
)
5469 struct sk_buff
*skb
;
5471 if (size
>= MAX_DATA
)
5474 skb
= alloc_skb(MAX_DATA
, GFP_KERNEL
);
5478 memcpy(__skb_put(skb
, size
), buf
, size
);
5480 /* Initialize a fake skb with test pattern. */
5481 skb_reset_mac_header(skb
);
5482 skb
->protocol
= htons(ETH_P_IP
);
5483 skb
->pkt_type
= SKB_TYPE
;
5484 skb
->mark
= SKB_MARK
;
5485 skb
->hash
= SKB_HASH
;
5486 skb
->queue_mapping
= SKB_QUEUE_MAP
;
5487 skb
->vlan_tci
= SKB_VLAN_TCI
;
5488 skb
->vlan_proto
= htons(ETH_P_IP
);
5490 skb
->dev
->ifindex
= SKB_DEV_IFINDEX
;
5491 skb
->dev
->type
= SKB_DEV_TYPE
;
5492 skb_set_network_header(skb
, min(size
, ETH_HLEN
));
5497 static void *generate_test_data(struct bpf_test
*test
, int sub
)
5499 struct sk_buff
*skb
;
5502 if (test
->aux
& FLAG_NO_DATA
)
5505 /* Test case expects an skb, so populate one. Various
5506 * subtests generate skbs of different sizes based on
5509 skb
= populate_skb(test
->data
, test
->test
[sub
].data_size
);
5513 if (test
->aux
& FLAG_SKB_FRAG
) {
5515 * when the test requires a fragmented skb, add a
5516 * single fragment to the skb, filled with
5521 page
= alloc_page(GFP_KERNEL
);
5529 memcpy(ptr
, test
->frag_data
, MAX_DATA
);
5531 skb_add_rx_frag(skb
, 0, page
, 0, MAX_DATA
, MAX_DATA
);
5543 static void release_test_data(const struct bpf_test
*test
, void *data
)
5545 if (test
->aux
& FLAG_NO_DATA
)
5551 static int filter_length(int which
)
5553 struct sock_filter
*fp
;
5556 if (tests
[which
].fill_helper
)
5557 return tests
[which
].u
.ptr
.len
;
5559 fp
= tests
[which
].u
.insns
;
5560 for (len
= MAX_INSNS
- 1; len
> 0; --len
)
5561 if (fp
[len
].code
!= 0 || fp
[len
].k
!= 0)
5567 static void *filter_pointer(int which
)
5569 if (tests
[which
].fill_helper
)
5570 return tests
[which
].u
.ptr
.insns
;
5572 return tests
[which
].u
.insns
;
5575 static struct bpf_prog
*generate_filter(int which
, int *err
)
5577 __u8 test_type
= tests
[which
].aux
& TEST_TYPE_MASK
;
5578 unsigned int flen
= filter_length(which
);
5579 void *fptr
= filter_pointer(which
);
5580 struct sock_fprog_kern fprog
;
5581 struct bpf_prog
*fp
;
5583 switch (test_type
) {
5585 fprog
.filter
= fptr
;
5588 *err
= bpf_prog_create(&fp
, &fprog
);
5589 if (tests
[which
].aux
& FLAG_EXPECTED_FAIL
) {
5590 if (*err
== -EINVAL
) {
5592 /* Verifier rejected filter as expected. */
5596 pr_cont("UNEXPECTED_PASS\n");
5597 /* Verifier didn't reject the test that's
5598 * bad enough, just return!
5604 /* We don't expect to fail. */
5606 pr_cont("FAIL to attach err=%d len=%d\n",
5613 fp
= bpf_prog_alloc(bpf_prog_size(flen
), 0);
5615 pr_cont("UNEXPECTED_FAIL no memory left\n");
5621 /* Type doesn't really matter here as long as it's not unspec. */
5622 fp
->type
= BPF_PROG_TYPE_SOCKET_FILTER
;
5623 memcpy(fp
->insnsi
, fptr
, fp
->len
* sizeof(struct bpf_insn
));
5625 /* We cannot error here as we don't need type compatibility
5628 fp
= bpf_prog_select_runtime(fp
, err
);
5636 static void release_filter(struct bpf_prog
*fp
, int which
)
5638 __u8 test_type
= tests
[which
].aux
& TEST_TYPE_MASK
;
5640 switch (test_type
) {
5642 bpf_prog_destroy(fp
);
5650 static int __run_one(const struct bpf_prog
*fp
, const void *data
,
5651 int runs
, u64
*duration
)
5656 start
= ktime_get_ns();
5658 for (i
= 0; i
< runs
; i
++)
5659 ret
= BPF_PROG_RUN(fp
, data
);
5661 finish
= ktime_get_ns();
5663 *duration
= finish
- start
;
5664 do_div(*duration
, runs
);
5669 static int run_one(const struct bpf_prog
*fp
, struct bpf_test
*test
)
5671 int err_cnt
= 0, i
, runs
= MAX_TESTRUNS
;
5673 for (i
= 0; i
< MAX_SUBTESTS
; i
++) {
5678 if (test
->test
[i
].data_size
== 0 &&
5679 test
->test
[i
].result
== 0)
5682 data
= generate_test_data(test
, i
);
5683 if (!data
&& !(test
->aux
& FLAG_NO_DATA
)) {
5684 pr_cont("data generation failed ");
5688 ret
= __run_one(fp
, data
, runs
, &duration
);
5689 release_test_data(test
, data
);
5691 if (ret
== test
->test
[i
].result
) {
5692 pr_cont("%lld ", duration
);
5694 pr_cont("ret %d != %d ", ret
,
5695 test
->test
[i
].result
);
5703 static char test_name
[64];
5704 module_param_string(test_name
, test_name
, sizeof(test_name
), 0);
5706 static int test_id
= -1;
5707 module_param(test_id
, int, 0);
5709 static int test_range
[2] = { 0, ARRAY_SIZE(tests
) - 1 };
5710 module_param_array(test_range
, int, NULL
, 0);
5712 static __init
int find_test_index(const char *test_name
)
5716 for (i
= 0; i
< ARRAY_SIZE(tests
); i
++) {
5717 if (!strcmp(tests
[i
].descr
, test_name
))
5723 static __init
int prepare_bpf_tests(void)
5729 * if a test_id was specified, use test_range to
5730 * cover only that test.
5732 if (test_id
>= ARRAY_SIZE(tests
)) {
5733 pr_err("test_bpf: invalid test_id specified.\n");
5737 test_range
[0] = test_id
;
5738 test_range
[1] = test_id
;
5739 } else if (*test_name
) {
5741 * if a test_name was specified, find it and setup
5742 * test_range to cover only that test.
5744 int idx
= find_test_index(test_name
);
5747 pr_err("test_bpf: no test named '%s' found.\n",
5751 test_range
[0] = idx
;
5752 test_range
[1] = idx
;
5755 * check that the supplied test_range is valid.
5757 if (test_range
[0] >= ARRAY_SIZE(tests
) ||
5758 test_range
[1] >= ARRAY_SIZE(tests
) ||
5759 test_range
[0] < 0 || test_range
[1] < 0) {
5760 pr_err("test_bpf: test_range is out of bound.\n");
5764 if (test_range
[1] < test_range
[0]) {
5765 pr_err("test_bpf: test_range is ending before it starts.\n");
5770 for (i
= 0; i
< ARRAY_SIZE(tests
); i
++) {
5771 if (tests
[i
].fill_helper
&&
5772 tests
[i
].fill_helper(&tests
[i
]) < 0)
5779 static __init
void destroy_bpf_tests(void)
5783 for (i
= 0; i
< ARRAY_SIZE(tests
); i
++) {
5784 if (tests
[i
].fill_helper
)
5785 kfree(tests
[i
].u
.ptr
.insns
);
5789 static bool exclude_test(int test_id
)
5791 return test_id
< test_range
[0] || test_id
> test_range
[1];
5794 static __init
int test_bpf(void)
5796 int i
, err_cnt
= 0, pass_cnt
= 0;
5797 int jit_cnt
= 0, run_cnt
= 0;
5799 for (i
= 0; i
< ARRAY_SIZE(tests
); i
++) {
5800 struct bpf_prog
*fp
;
5803 if (exclude_test(i
))
5806 pr_info("#%d %s ", i
, tests
[i
].descr
);
5808 fp
= generate_filter(i
, &err
);
5818 pr_cont("jited:%u ", fp
->jited
);
5824 err
= run_one(fp
, &tests
[i
]);
5825 release_filter(fp
, i
);
5828 pr_cont("FAIL (%d times)\n", err
);
5836 pr_info("Summary: %d PASSED, %d FAILED, [%d/%d JIT'ed]\n",
5837 pass_cnt
, err_cnt
, jit_cnt
, run_cnt
);
5839 return err_cnt
? -EINVAL
: 0;
5842 static int __init
test_bpf_init(void)
5846 ret
= prepare_bpf_tests();
5852 destroy_bpf_tests();
5856 static void __exit
test_bpf_exit(void)
5860 module_init(test_bpf_init
);
5861 module_exit(test_bpf_exit
);
5863 MODULE_LICENSE("GPL");