1 // SPDX-License-Identifier: GPL-2.0-only
3 * Testsuite for BPF interpreter and BPF JIT compiler
5 * Copyright (c) 2011-2014 PLUMgrid, http://plumgrid.com
8 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
10 #include <linux/init.h>
11 #include <linux/module.h>
12 #include <linux/filter.h>
13 #include <linux/bpf.h>
14 #include <linux/skbuff.h>
15 #include <linux/netdevice.h>
16 #include <linux/if_vlan.h>
17 #include <linux/random.h>
18 #include <linux/highmem.h>
19 #include <linux/sched.h>
21 /* General test specific settings */
22 #define MAX_SUBTESTS 3
23 #define MAX_TESTRUNS 1000
26 #define MAX_K 0xffffFFFF
28 /* Few constants used to init test 'skb' */
30 #define SKB_MARK 0x1234aaaa
31 #define SKB_HASH 0x1234aaab
32 #define SKB_QUEUE_MAP 123
33 #define SKB_VLAN_TCI 0xffff
34 #define SKB_VLAN_PRESENT 1
35 #define SKB_DEV_IFINDEX 577
36 #define SKB_DEV_TYPE 588
38 /* Redefine REGs to make tests less verbose */
49 #define R10 BPF_REG_10
51 /* Flags that can be passed to test cases */
52 #define FLAG_NO_DATA BIT(0)
53 #define FLAG_EXPECTED_FAIL BIT(1)
54 #define FLAG_SKB_FRAG BIT(2)
57 CLASSIC = BIT(6), /* Old BPF instructions only. */
58 INTERNAL = BIT(7), /* Extended instruction set. */
61 #define TEST_TYPE_MASK (CLASSIC | INTERNAL)
66 struct sock_filter insns[MAX_INSNS];
67 struct bpf_insn insns_int[MAX_INSNS];
79 int (*fill_helper)(struct bpf_test *self);
80 int expected_errcode; /* used when FLAG_EXPECTED_FAIL is set in the aux */
81 __u8 frag_data[MAX_DATA];
82 int stack_depth; /* for eBPF only, since tests don't call verifier */
85 /* Large test cases need separate allocation and fill handler. */
87 static int bpf_fill_maxinsns1(struct bpf_test *self)
89 unsigned int len = BPF_MAXINSNS;
90 struct sock_filter *insn;
94 insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL);
98 for (i = 0; i < len; i++, k--)
99 insn[i] = __BPF_STMT(BPF_RET | BPF_K, k);
101 self->u.ptr.insns = insn;
102 self->u.ptr.len = len;
107 static int bpf_fill_maxinsns2(struct bpf_test *self)
109 unsigned int len = BPF_MAXINSNS;
110 struct sock_filter *insn;
113 insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL);
117 for (i = 0; i < len; i++)
118 insn[i] = __BPF_STMT(BPF_RET | BPF_K, 0xfefefefe);
120 self->u.ptr.insns = insn;
121 self->u.ptr.len = len;
126 static int bpf_fill_maxinsns3(struct bpf_test *self)
128 unsigned int len = BPF_MAXINSNS;
129 struct sock_filter *insn;
130 struct rnd_state rnd;
133 insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL);
137 prandom_seed_state(&rnd, 3141592653589793238ULL);
139 for (i = 0; i < len - 1; i++) {
140 __u32 k = prandom_u32_state(&rnd);
142 insn[i] = __BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, k);
145 insn[len - 1] = __BPF_STMT(BPF_RET | BPF_A, 0);
147 self->u.ptr.insns = insn;
148 self->u.ptr.len = len;
153 static int bpf_fill_maxinsns4(struct bpf_test *self)
155 unsigned int len = BPF_MAXINSNS + 1;
156 struct sock_filter *insn;
159 insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL);
163 for (i = 0; i < len; i++)
164 insn[i] = __BPF_STMT(BPF_RET | BPF_K, 0xfefefefe);
166 self->u.ptr.insns = insn;
167 self->u.ptr.len = len;
172 static int bpf_fill_maxinsns5(struct bpf_test *self)
174 unsigned int len = BPF_MAXINSNS;
175 struct sock_filter *insn;
178 insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL);
182 insn[0] = __BPF_JUMP(BPF_JMP | BPF_JA, len - 2, 0, 0);
184 for (i = 1; i < len - 1; i++)
185 insn[i] = __BPF_STMT(BPF_RET | BPF_K, 0xfefefefe);
187 insn[len - 1] = __BPF_STMT(BPF_RET | BPF_K, 0xabababab);
189 self->u.ptr.insns = insn;
190 self->u.ptr.len = len;
195 static int bpf_fill_maxinsns6(struct bpf_test *self)
197 unsigned int len = BPF_MAXINSNS;
198 struct sock_filter *insn;
201 insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL);
205 for (i = 0; i < len - 1; i++)
206 insn[i] = __BPF_STMT(BPF_LD | BPF_W | BPF_ABS, SKF_AD_OFF +
207 SKF_AD_VLAN_TAG_PRESENT);
209 insn[len - 1] = __BPF_STMT(BPF_RET | BPF_A, 0);
211 self->u.ptr.insns = insn;
212 self->u.ptr.len = len;
217 static int bpf_fill_maxinsns7(struct bpf_test *self)
219 unsigned int len = BPF_MAXINSNS;
220 struct sock_filter *insn;
223 insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL);
227 for (i = 0; i < len - 4; i++)
228 insn[i] = __BPF_STMT(BPF_LD | BPF_W | BPF_ABS, SKF_AD_OFF +
231 insn[len - 4] = __BPF_STMT(BPF_MISC | BPF_TAX, 0);
232 insn[len - 3] = __BPF_STMT(BPF_LD | BPF_W | BPF_ABS, SKF_AD_OFF +
234 insn[len - 2] = __BPF_STMT(BPF_ALU | BPF_SUB | BPF_X, 0);
235 insn[len - 1] = __BPF_STMT(BPF_RET | BPF_A, 0);
237 self->u.ptr.insns = insn;
238 self->u.ptr.len = len;
243 static int bpf_fill_maxinsns8(struct bpf_test *self)
245 unsigned int len = BPF_MAXINSNS;
246 struct sock_filter *insn;
247 int i, jmp_off = len - 3;
249 insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL);
253 insn[0] = __BPF_STMT(BPF_LD | BPF_IMM, 0xffffffff);
255 for (i = 1; i < len - 1; i++)
256 insn[i] = __BPF_JUMP(BPF_JMP | BPF_JGT, 0xffffffff, jmp_off--, 0);
258 insn[len - 1] = __BPF_STMT(BPF_RET | BPF_A, 0);
260 self->u.ptr.insns = insn;
261 self->u.ptr.len = len;
266 static int bpf_fill_maxinsns9(struct bpf_test *self)
268 unsigned int len = BPF_MAXINSNS;
269 struct bpf_insn *insn;
272 insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL);
276 insn[0] = BPF_JMP_IMM(BPF_JA, 0, 0, len - 2);
277 insn[1] = BPF_ALU32_IMM(BPF_MOV, R0, 0xcbababab);
278 insn[2] = BPF_EXIT_INSN();
280 for (i = 3; i < len - 2; i++)
281 insn[i] = BPF_ALU32_IMM(BPF_MOV, R0, 0xfefefefe);
283 insn[len - 2] = BPF_EXIT_INSN();
284 insn[len - 1] = BPF_JMP_IMM(BPF_JA, 0, 0, -(len - 1));
286 self->u.ptr.insns = insn;
287 self->u.ptr.len = len;
292 static int bpf_fill_maxinsns10(struct bpf_test *self)
294 unsigned int len = BPF_MAXINSNS, hlen = len - 2;
295 struct bpf_insn *insn;
298 insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL);
302 for (i = 0; i < hlen / 2; i++)
303 insn[i] = BPF_JMP_IMM(BPF_JA, 0, 0, hlen - 2 - 2 * i);
304 for (i = hlen - 1; i > hlen / 2; i--)
305 insn[i] = BPF_JMP_IMM(BPF_JA, 0, 0, hlen - 1 - 2 * i);
307 insn[hlen / 2] = BPF_JMP_IMM(BPF_JA, 0, 0, hlen / 2 - 1);
308 insn[hlen] = BPF_ALU32_IMM(BPF_MOV, R0, 0xabababac);
309 insn[hlen + 1] = BPF_EXIT_INSN();
311 self->u.ptr.insns = insn;
312 self->u.ptr.len = len;
317 static int __bpf_fill_ja(struct bpf_test *self, unsigned int len,
320 struct sock_filter *insn;
324 insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL);
328 rlen = (len % plen) - 1;
330 for (i = 0; i + plen < len; i += plen)
331 for (j = 0; j < plen; j++)
332 insn[i + j] = __BPF_JUMP(BPF_JMP | BPF_JA,
334 for (j = 0; j < rlen; j++)
335 insn[i + j] = __BPF_JUMP(BPF_JMP | BPF_JA, rlen - 1 - j,
338 insn[len - 1] = __BPF_STMT(BPF_RET | BPF_K, 0xababcbac);
340 self->u.ptr.insns = insn;
341 self->u.ptr.len = len;
346 static int bpf_fill_maxinsns11(struct bpf_test *self)
348 /* Hits 70 passes on x86_64, so cannot get JITed there. */
349 return __bpf_fill_ja(self, BPF_MAXINSNS, 68);
352 static int bpf_fill_maxinsns12(struct bpf_test *self)
354 unsigned int len = BPF_MAXINSNS;
355 struct sock_filter *insn;
358 insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL);
362 insn[0] = __BPF_JUMP(BPF_JMP | BPF_JA, len - 2, 0, 0);
364 for (i = 1; i < len - 1; i++)
365 insn[i] = __BPF_STMT(BPF_LDX | BPF_B | BPF_MSH, 0);
367 insn[len - 1] = __BPF_STMT(BPF_RET | BPF_K, 0xabababab);
369 self->u.ptr.insns = insn;
370 self->u.ptr.len = len;
375 static int bpf_fill_maxinsns13(struct bpf_test *self)
377 unsigned int len = BPF_MAXINSNS;
378 struct sock_filter *insn;
381 insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL);
385 for (i = 0; i < len - 3; i++)
386 insn[i] = __BPF_STMT(BPF_LDX | BPF_B | BPF_MSH, 0);
388 insn[len - 3] = __BPF_STMT(BPF_LD | BPF_IMM, 0xabababab);
389 insn[len - 2] = __BPF_STMT(BPF_ALU | BPF_XOR | BPF_X, 0);
390 insn[len - 1] = __BPF_STMT(BPF_RET | BPF_A, 0);
392 self->u.ptr.insns = insn;
393 self->u.ptr.len = len;
398 static int bpf_fill_ja(struct bpf_test *self)
400 /* Hits exactly 11 passes on x86_64 JIT. */
401 return __bpf_fill_ja(self, 12, 9);
404 static int bpf_fill_ld_abs_get_processor_id(struct bpf_test *self)
406 unsigned int len = BPF_MAXINSNS;
407 struct sock_filter *insn;
410 insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL);
414 for (i = 0; i < len - 1; i += 2) {
415 insn[i] = __BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 0);
416 insn[i + 1] = __BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
417 SKF_AD_OFF + SKF_AD_CPU);
420 insn[len - 1] = __BPF_STMT(BPF_RET | BPF_K, 0xbee);
422 self->u.ptr.insns = insn;
423 self->u.ptr.len = len;
428 static int __bpf_fill_stxdw(struct bpf_test *self, int size)
430 unsigned int len = BPF_MAXINSNS;
431 struct bpf_insn *insn;
434 insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL);
438 insn[0] = BPF_ALU32_IMM(BPF_MOV, R0, 1);
439 insn[1] = BPF_ST_MEM(size, R10, -40, 42);
441 for (i = 2; i < len - 2; i++)
442 insn[i] = BPF_STX_XADD(size, R10, R0, -40);
444 insn[len - 2] = BPF_LDX_MEM(size, R0, R10, -40);
445 insn[len - 1] = BPF_EXIT_INSN();
447 self->u.ptr.insns = insn;
448 self->u.ptr.len = len;
449 self->stack_depth = 40;
454 static int bpf_fill_stxw(struct bpf_test *self)
456 return __bpf_fill_stxdw(self, BPF_W);
459 static int bpf_fill_stxdw(struct bpf_test *self)
461 return __bpf_fill_stxdw(self, BPF_DW);
464 static struct bpf_test tests[] = {
468 BPF_STMT(BPF_LD | BPF_IMM, 1),
469 BPF_STMT(BPF_MISC | BPF_TAX, 0),
470 BPF_STMT(BPF_LD | BPF_IMM, 2),
471 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
472 BPF_STMT(BPF_ALU | BPF_NEG, 0), /* A == -3 */
473 BPF_STMT(BPF_MISC | BPF_TAX, 0),
474 BPF_STMT(BPF_LD | BPF_LEN, 0),
475 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
476 BPF_STMT(BPF_MISC | BPF_TAX, 0), /* X == len - 3 */
477 BPF_STMT(BPF_LD | BPF_B | BPF_IND, 1),
478 BPF_STMT(BPF_RET | BPF_A, 0)
481 { 10, 20, 30, 40, 50 },
482 { { 2, 10 }, { 3, 20 }, { 4, 30 } },
487 BPF_STMT(BPF_LDX | BPF_LEN, 0),
488 BPF_STMT(BPF_MISC | BPF_TXA, 0),
489 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
490 BPF_STMT(BPF_RET | BPF_A, 0) /* A == len * 2 */
493 { 10, 20, 30, 40, 50 },
494 { { 1, 2 }, { 3, 6 }, { 4, 8 } },
499 BPF_STMT(BPF_LD | BPF_IMM, 1),
500 BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 2),
501 BPF_STMT(BPF_LDX | BPF_IMM, 3),
502 BPF_STMT(BPF_ALU | BPF_SUB | BPF_X, 0),
503 BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 0xffffffff),
504 BPF_STMT(BPF_ALU | BPF_MUL | BPF_K, 3),
505 BPF_STMT(BPF_RET | BPF_A, 0)
507 CLASSIC | FLAG_NO_DATA,
509 { { 0, 0xfffffffd } }
514 BPF_STMT(BPF_LD | BPF_IMM, 8),
515 BPF_STMT(BPF_ALU | BPF_DIV | BPF_K, 2),
516 BPF_STMT(BPF_MISC | BPF_TAX, 0),
517 BPF_STMT(BPF_LD | BPF_IMM, 0xffffffff),
518 BPF_STMT(BPF_ALU | BPF_DIV | BPF_X, 0),
519 BPF_STMT(BPF_MISC | BPF_TAX, 0),
520 BPF_STMT(BPF_LD | BPF_IMM, 0xffffffff),
521 BPF_STMT(BPF_ALU | BPF_DIV | BPF_K, 0x70000000),
522 BPF_STMT(BPF_MISC | BPF_TAX, 0),
523 BPF_STMT(BPF_LD | BPF_IMM, 0xffffffff),
524 BPF_STMT(BPF_ALU | BPF_MOD | BPF_X, 0),
525 BPF_STMT(BPF_MISC | BPF_TAX, 0),
526 BPF_STMT(BPF_LD | BPF_IMM, 0xffffffff),
527 BPF_STMT(BPF_ALU | BPF_MOD | BPF_K, 0x70000000),
528 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
529 BPF_STMT(BPF_RET | BPF_A, 0)
531 CLASSIC | FLAG_NO_DATA,
533 { { 0, 0x20000000 } }
538 BPF_STMT(BPF_LD | BPF_IMM, 0xff),
539 BPF_STMT(BPF_ALU | BPF_AND | BPF_K, 0xf0),
540 BPF_STMT(BPF_ALU | BPF_LSH | BPF_K, 27),
541 BPF_STMT(BPF_MISC | BPF_TAX, 0),
542 BPF_STMT(BPF_LD | BPF_IMM, 0xf),
543 BPF_STMT(BPF_ALU | BPF_OR | BPF_K, 0xf0),
544 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
545 BPF_STMT(BPF_RET | BPF_A, 0)
547 CLASSIC | FLAG_NO_DATA,
549 { { 0, 0x800000ff }, { 1, 0x800000ff } },
554 BPF_STMT(BPF_LD | BPF_IMM, 0), /* ld #0 */
555 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0, 1, 0),
556 BPF_STMT(BPF_RET | BPF_K, 0),
557 BPF_STMT(BPF_RET | BPF_K, 1),
566 BPF_STMT(BPF_LDX | BPF_LEN, 0),
567 BPF_STMT(BPF_LD | BPF_H | BPF_IND, MAX_K),
568 BPF_STMT(BPF_RET | BPF_K, 1)
572 { { 1, 0 }, { 10, 0 }, { 60, 0 } },
577 BPF_STMT(BPF_LD | BPF_W | BPF_ABS, 1000),
578 BPF_STMT(BPF_RET | BPF_K, 1)
582 { { 1, 0 }, { 10, 0 }, { 60, 0 } },
587 BPF_STMT(BPF_LD | BPF_B | BPF_ABS, SKF_LL_OFF),
588 BPF_STMT(BPF_MISC | BPF_TAX, 0),
589 BPF_STMT(BPF_LD | BPF_B | BPF_ABS, SKF_LL_OFF + 1),
590 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
591 BPF_STMT(BPF_RET | BPF_A, 0)
595 { { 1, 0 }, { 2, 3 } },
600 BPF_STMT(BPF_LD | BPF_IMM, SKF_LL_OFF - 1),
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)
609 { { 1, 1 }, { 3, 3 }, { 4, 0xff } },
614 BPF_STMT(BPF_LD | BPF_B | BPF_ABS, SKF_NET_OFF),
615 BPF_STMT(BPF_MISC | BPF_TAX, 0),
616 BPF_STMT(BPF_LD | BPF_B | BPF_ABS, SKF_NET_OFF + 1),
617 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
618 BPF_STMT(BPF_RET | BPF_A, 0)
621 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3 },
622 { { 15, 0 }, { 16, 3 } },
627 BPF_STMT(BPF_LD | BPF_IMM, SKF_NET_OFF - 15),
628 BPF_STMT(BPF_LDX | BPF_LEN, 0),
629 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
630 BPF_STMT(BPF_MISC | BPF_TAX, 0),
631 BPF_STMT(BPF_LD | BPF_B | BPF_IND, 0),
632 BPF_STMT(BPF_RET | BPF_A, 0)
635 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3 },
636 { { 14, 0 }, { 15, 1 }, { 17, 3 } },
641 BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
642 SKF_AD_OFF + SKF_AD_PKTTYPE),
643 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, SKB_TYPE, 1, 0),
644 BPF_STMT(BPF_RET | BPF_K, 1),
645 BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
646 SKF_AD_OFF + SKF_AD_PKTTYPE),
647 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, SKB_TYPE, 1, 0),
648 BPF_STMT(BPF_RET | BPF_K, 1),
649 BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
650 SKF_AD_OFF + SKF_AD_PKTTYPE),
651 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, SKB_TYPE, 1, 0),
652 BPF_STMT(BPF_RET | BPF_K, 1),
653 BPF_STMT(BPF_RET | BPF_A, 0)
657 { { 1, 3 }, { 10, 3 } },
662 BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
663 SKF_AD_OFF + SKF_AD_MARK),
664 BPF_STMT(BPF_RET | BPF_A, 0)
668 { { 1, SKB_MARK}, { 10, SKB_MARK} },
673 BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
674 SKF_AD_OFF + SKF_AD_RXHASH),
675 BPF_STMT(BPF_RET | BPF_A, 0)
679 { { 1, SKB_HASH}, { 10, SKB_HASH} },
684 BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
685 SKF_AD_OFF + SKF_AD_QUEUE),
686 BPF_STMT(BPF_RET | BPF_A, 0)
690 { { 1, SKB_QUEUE_MAP }, { 10, SKB_QUEUE_MAP } },
695 BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 1),
696 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 20, 1, 0),
697 BPF_STMT(BPF_RET | BPF_K, 0),
698 BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
699 SKF_AD_OFF + SKF_AD_PROTOCOL),
700 BPF_STMT(BPF_MISC | BPF_TAX, 0),
701 BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 2),
702 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 30, 1, 0),
703 BPF_STMT(BPF_RET | BPF_K, 0),
704 BPF_STMT(BPF_MISC | BPF_TXA, 0),
705 BPF_STMT(BPF_RET | BPF_A, 0)
709 { { 10, ETH_P_IP }, { 100, ETH_P_IP } },
714 BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
715 SKF_AD_OFF + SKF_AD_VLAN_TAG),
716 BPF_STMT(BPF_RET | BPF_A, 0)
726 "LD_VLAN_TAG_PRESENT",
728 BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
729 SKF_AD_OFF + SKF_AD_VLAN_TAG_PRESENT),
730 BPF_STMT(BPF_RET | BPF_A, 0)
735 { 1, SKB_VLAN_PRESENT },
736 { 10, SKB_VLAN_PRESENT }
742 BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
743 SKF_AD_OFF + SKF_AD_IFINDEX),
744 BPF_STMT(BPF_RET | BPF_A, 0)
748 { { 1, SKB_DEV_IFINDEX }, { 10, SKB_DEV_IFINDEX } },
753 BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
754 SKF_AD_OFF + SKF_AD_HATYPE),
755 BPF_STMT(BPF_RET | BPF_A, 0)
759 { { 1, SKB_DEV_TYPE }, { 10, SKB_DEV_TYPE } },
764 BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
765 SKF_AD_OFF + SKF_AD_CPU),
766 BPF_STMT(BPF_MISC | BPF_TAX, 0),
767 BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
768 SKF_AD_OFF + SKF_AD_CPU),
769 BPF_STMT(BPF_ALU | BPF_SUB | BPF_X, 0),
770 BPF_STMT(BPF_RET | BPF_A, 0)
774 { { 1, 0 }, { 10, 0 } },
779 BPF_STMT(BPF_LDX | BPF_IMM, 2),
780 BPF_STMT(BPF_MISC | BPF_TXA, 0),
781 BPF_STMT(BPF_LDX | BPF_IMM, 3),
782 BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
783 SKF_AD_OFF + SKF_AD_NLATTR),
784 BPF_STMT(BPF_RET | BPF_A, 0)
788 { 0xff, 0xff, 0, 4, 0, 2, 0, 4, 0, 3 },
790 { 0xff, 0xff, 4, 0, 2, 0, 4, 0, 3, 0 },
792 { { 4, 0 }, { 20, 6 } },
797 BPF_STMT(BPF_LD | BPF_IMM, 2),
798 BPF_STMT(BPF_LDX | BPF_IMM, 3),
799 BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
800 SKF_AD_OFF + SKF_AD_NLATTR_NEST),
801 BPF_STMT(BPF_LD | BPF_IMM, 2),
802 BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
803 SKF_AD_OFF + SKF_AD_NLATTR_NEST),
804 BPF_STMT(BPF_LD | BPF_IMM, 2),
805 BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
806 SKF_AD_OFF + SKF_AD_NLATTR_NEST),
807 BPF_STMT(BPF_LD | BPF_IMM, 2),
808 BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
809 SKF_AD_OFF + SKF_AD_NLATTR_NEST),
810 BPF_STMT(BPF_LD | BPF_IMM, 2),
811 BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
812 SKF_AD_OFF + SKF_AD_NLATTR_NEST),
813 BPF_STMT(BPF_LD | BPF_IMM, 2),
814 BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
815 SKF_AD_OFF + SKF_AD_NLATTR_NEST),
816 BPF_STMT(BPF_LD | BPF_IMM, 2),
817 BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
818 SKF_AD_OFF + SKF_AD_NLATTR_NEST),
819 BPF_STMT(BPF_LD | BPF_IMM, 2),
820 BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
821 SKF_AD_OFF + SKF_AD_NLATTR_NEST),
822 BPF_STMT(BPF_RET | BPF_A, 0)
826 { 0xff, 0xff, 0, 12, 0, 1, 0, 4, 0, 2, 0, 4, 0, 3 },
828 { 0xff, 0xff, 12, 0, 1, 0, 4, 0, 2, 0, 4, 0, 3, 0 },
830 { { 4, 0 }, { 20, 10 } },
835 BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
836 SKF_AD_OFF + SKF_AD_PAY_OFFSET),
837 BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
838 SKF_AD_OFF + SKF_AD_PAY_OFFSET),
839 BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
840 SKF_AD_OFF + SKF_AD_PAY_OFFSET),
841 BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
842 SKF_AD_OFF + SKF_AD_PAY_OFFSET),
843 BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
844 SKF_AD_OFF + SKF_AD_PAY_OFFSET),
845 BPF_STMT(BPF_RET | BPF_A, 0)
848 /* 00:00:00:00:00:00 > 00:00:00:00:00:00, ethtype IPv4 (0x0800),
849 * length 98: 127.0.0.1 > 127.0.0.1: ICMP echo request,
850 * id 9737, seq 1, length 64
852 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
853 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
855 0x45, 0x00, 0x00, 0x54, 0xac, 0x8b, 0x40, 0x00, 0x40,
856 0x01, 0x90, 0x1b, 0x7f, 0x00, 0x00, 0x01 },
857 { { 30, 0 }, { 100, 42 } },
862 BPF_STMT(BPF_LD | BPF_IMM, 10),
863 BPF_STMT(BPF_LDX | BPF_IMM, 300),
864 BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
865 SKF_AD_OFF + SKF_AD_ALU_XOR_X),
866 BPF_STMT(BPF_RET | BPF_A, 0)
870 { { 4, 0xA ^ 300 }, { 20, 0xA ^ 300 } },
875 BPF_STMT(BPF_LDX | BPF_LEN, 0),
876 BPF_STMT(BPF_LD | BPF_IMM, 2),
877 BPF_STMT(BPF_ALU | BPF_RSH, 1),
878 BPF_STMT(BPF_ALU | BPF_XOR | BPF_X, 0),
879 BPF_STMT(BPF_ST, 1), /* M1 = 1 ^ len */
880 BPF_STMT(BPF_ALU | BPF_XOR | BPF_K, 0x80000000),
881 BPF_STMT(BPF_ST, 2), /* M2 = 1 ^ len ^ 0x80000000 */
882 BPF_STMT(BPF_STX, 15), /* M3 = len */
883 BPF_STMT(BPF_LDX | BPF_MEM, 1),
884 BPF_STMT(BPF_LD | BPF_MEM, 2),
885 BPF_STMT(BPF_ALU | BPF_XOR | BPF_X, 0),
886 BPF_STMT(BPF_LDX | BPF_MEM, 15),
887 BPF_STMT(BPF_ALU | BPF_XOR | BPF_X, 0),
888 BPF_STMT(BPF_RET | BPF_A, 0)
892 { { 1, 0x80000001 }, { 2, 0x80000002 }, { 60, 0x80000000 ^ 60 } }
897 BPF_STMT(BPF_LDX | BPF_LEN, 0),
898 BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 2),
899 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_X, 0, 0, 1),
900 BPF_STMT(BPF_RET | BPF_K, 1),
901 BPF_STMT(BPF_RET | BPF_K, MAX_K)
905 { { 1, 0 }, { 3, 1 }, { 4, MAX_K } },
910 BPF_STMT(BPF_LDX | BPF_LEN, 0),
911 BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 2),
912 BPF_JUMP(BPF_JMP | BPF_JGT | BPF_X, 0, 0, 1),
913 BPF_STMT(BPF_RET | BPF_K, 1),
914 BPF_STMT(BPF_RET | BPF_K, MAX_K)
918 { { 2, 0 }, { 3, 1 }, { 4, MAX_K } },
921 "JGE (jt 0), test 1",
923 BPF_STMT(BPF_LDX | BPF_LEN, 0),
924 BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 2),
925 BPF_JUMP(BPF_JMP | BPF_JGE | BPF_X, 0, 0, 1),
926 BPF_STMT(BPF_RET | BPF_K, 1),
927 BPF_STMT(BPF_RET | BPF_K, MAX_K)
931 { { 2, 0 }, { 3, 1 }, { 4, 1 } },
934 "JGE (jt 0), test 2",
936 BPF_STMT(BPF_LDX | BPF_LEN, 0),
937 BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 2),
938 BPF_JUMP(BPF_JMP | BPF_JGE | BPF_X, 0, 0, 1),
939 BPF_STMT(BPF_RET | BPF_K, 1),
940 BPF_STMT(BPF_RET | BPF_K, MAX_K)
944 { { 4, 1 }, { 5, 1 }, { 6, MAX_K } },
949 BPF_STMT(BPF_LDX | BPF_LEN, 0),
950 BPF_STMT(BPF_LD | BPF_B | BPF_IND, MAX_K),
951 BPF_JUMP(BPF_JMP | BPF_JGE | BPF_K, 1, 1, 0),
952 BPF_STMT(BPF_RET | BPF_K, 10),
953 BPF_JUMP(BPF_JMP | BPF_JGE | BPF_K, 2, 1, 0),
954 BPF_STMT(BPF_RET | BPF_K, 20),
955 BPF_JUMP(BPF_JMP | BPF_JGE | BPF_K, 3, 1, 0),
956 BPF_STMT(BPF_RET | BPF_K, 30),
957 BPF_JUMP(BPF_JMP | BPF_JGE | BPF_K, 4, 1, 0),
958 BPF_STMT(BPF_RET | BPF_K, 40),
959 BPF_STMT(BPF_RET | BPF_K, MAX_K)
963 { { 1, 20 }, { 3, 40 }, { 5, MAX_K } },
968 BPF_JUMP(BPF_JMP | BPF_JA, 0, 0, 0),
969 BPF_JUMP(BPF_JMP | BPF_JA, 1, 1, 1),
970 BPF_JUMP(BPF_JMP | BPF_JA, 0, 0, 0),
971 BPF_JUMP(BPF_JMP | BPF_JA, 0, 0, 0),
972 BPF_STMT(BPF_LDX | BPF_LEN, 0),
973 BPF_STMT(BPF_MISC | BPF_TXA, 0),
974 BPF_STMT(BPF_ALU | BPF_SUB | BPF_K, 4),
975 BPF_STMT(BPF_MISC | BPF_TAX, 0),
976 BPF_STMT(BPF_LD | BPF_W | BPF_IND, 0),
977 BPF_JUMP(BPF_JMP | BPF_JSET | BPF_K, 1, 0, 1),
978 BPF_STMT(BPF_RET | BPF_K, 10),
979 BPF_JUMP(BPF_JMP | BPF_JSET | BPF_K, 0x80000000, 0, 1),
980 BPF_STMT(BPF_RET | BPF_K, 20),
981 BPF_JUMP(BPF_JMP | BPF_JSET | BPF_K, 0xffffff, 1, 0),
982 BPF_STMT(BPF_RET | BPF_K, 30),
983 BPF_JUMP(BPF_JMP | BPF_JSET | BPF_K, 0xffffff, 1, 0),
984 BPF_STMT(BPF_RET | BPF_K, 30),
985 BPF_JUMP(BPF_JMP | BPF_JSET | BPF_K, 0xffffff, 1, 0),
986 BPF_STMT(BPF_RET | BPF_K, 30),
987 BPF_JUMP(BPF_JMP | BPF_JSET | BPF_K, 0xffffff, 1, 0),
988 BPF_STMT(BPF_RET | BPF_K, 30),
989 BPF_JUMP(BPF_JMP | BPF_JSET | BPF_K, 0xffffff, 1, 0),
990 BPF_STMT(BPF_RET | BPF_K, 30),
991 BPF_STMT(BPF_RET | BPF_K, MAX_K)
994 { 0, 0xAA, 0x55, 1 },
995 { { 4, 10 }, { 5, 20 }, { 6, MAX_K } },
1000 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 12),
1001 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x86dd, 0, 8), /* IPv6 */
1002 BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 20),
1003 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x84, 2, 0),
1004 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x6, 1, 0),
1005 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x11, 0, 17),
1006 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 54),
1007 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 22, 14, 0),
1008 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 56),
1009 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 22, 12, 13),
1010 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x0800, 0, 12), /* IPv4 */
1011 BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 23),
1012 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x84, 2, 0),
1013 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x6, 1, 0),
1014 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x11, 0, 8),
1015 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 20),
1016 BPF_JUMP(BPF_JMP | BPF_JSET | BPF_K, 0x1fff, 6, 0),
1017 BPF_STMT(BPF_LDX | BPF_B | BPF_MSH, 14),
1018 BPF_STMT(BPF_LD | BPF_H | BPF_IND, 14),
1019 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 22, 2, 0),
1020 BPF_STMT(BPF_LD | BPF_H | BPF_IND, 16),
1021 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 22, 0, 1),
1022 BPF_STMT(BPF_RET | BPF_K, 0xffff),
1023 BPF_STMT(BPF_RET | BPF_K, 0),
1026 /* 3c:07:54:43:e5:76 > 10:bf:48:d6:43:d6, ethertype IPv4(0x0800)
1027 * length 114: 10.1.1.149.49700 > 10.1.2.10.22: Flags [P.],
1028 * seq 1305692979:1305693027, ack 3650467037, win 65535,
1029 * options [nop,nop,TS val 2502645400 ecr 3971138], length 48
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 /* tcpdump -nei eth0 'tcp port 22 and (((ip[2:2] -
1046 * ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0) and
1047 * (len > 115 or len < 30000000000)' -d
1049 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 12),
1050 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x86dd, 30, 0),
1051 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x800, 0, 29),
1052 BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 23),
1053 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x6, 0, 27),
1054 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 20),
1055 BPF_JUMP(BPF_JMP | BPF_JSET | BPF_K, 0x1fff, 25, 0),
1056 BPF_STMT(BPF_LDX | BPF_B | BPF_MSH, 14),
1057 BPF_STMT(BPF_LD | BPF_H | BPF_IND, 14),
1058 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 22, 2, 0),
1059 BPF_STMT(BPF_LD | BPF_H | BPF_IND, 16),
1060 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 22, 0, 20),
1061 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 16),
1062 BPF_STMT(BPF_ST, 1),
1063 BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 14),
1064 BPF_STMT(BPF_ALU | BPF_AND | BPF_K, 0xf),
1065 BPF_STMT(BPF_ALU | BPF_LSH | BPF_K, 2),
1066 BPF_STMT(BPF_MISC | BPF_TAX, 0x5), /* libpcap emits K on TAX */
1067 BPF_STMT(BPF_LD | BPF_MEM, 1),
1068 BPF_STMT(BPF_ALU | BPF_SUB | BPF_X, 0),
1069 BPF_STMT(BPF_ST, 5),
1070 BPF_STMT(BPF_LDX | BPF_B | BPF_MSH, 14),
1071 BPF_STMT(BPF_LD | BPF_B | BPF_IND, 26),
1072 BPF_STMT(BPF_ALU | BPF_AND | BPF_K, 0xf0),
1073 BPF_STMT(BPF_ALU | BPF_RSH | BPF_K, 2),
1074 BPF_STMT(BPF_MISC | BPF_TAX, 0x9), /* libpcap emits K on TAX */
1075 BPF_STMT(BPF_LD | BPF_MEM, 5),
1076 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_X, 0, 4, 0),
1077 BPF_STMT(BPF_LD | BPF_LEN, 0),
1078 BPF_JUMP(BPF_JMP | BPF_JGT | BPF_K, 0x73, 1, 0),
1079 BPF_JUMP(BPF_JMP | BPF_JGE | BPF_K, 0xfc23ac00, 1, 0),
1080 BPF_STMT(BPF_RET | BPF_K, 0xffff),
1081 BPF_STMT(BPF_RET | BPF_K, 0),
1084 { 0x10, 0xbf, 0x48, 0xd6, 0x43, 0xd6,
1085 0x3c, 0x07, 0x54, 0x43, 0xe5, 0x76,
1087 0x45, 0x10, 0x00, 0x64, 0x75, 0xb5,
1088 0x40, 0x00, 0x40, 0x06, 0xad, 0x2e, /* IP header */
1089 0x0a, 0x01, 0x01, 0x95, /* ip src */
1090 0x0a, 0x01, 0x02, 0x0a, /* ip dst */
1092 0x00, 0x16 /* dst port */ },
1093 { { 10, 0 }, { 30, 0 }, { 100, 65535 } },
1098 /* check that unitialized X and A contain zeros */
1099 BPF_STMT(BPF_MISC | BPF_TXA, 0),
1100 BPF_STMT(BPF_RET | BPF_A, 0)
1109 BPF_ALU64_IMM(BPF_MOV, R1, 1),
1110 BPF_ALU64_IMM(BPF_ADD, R1, 2),
1111 BPF_ALU64_IMM(BPF_MOV, R2, 3),
1112 BPF_ALU64_REG(BPF_SUB, R1, R2),
1113 BPF_ALU64_IMM(BPF_ADD, R1, -1),
1114 BPF_ALU64_IMM(BPF_MUL, R1, 3),
1115 BPF_ALU64_REG(BPF_MOV, R0, R1),
1120 { { 0, 0xfffffffd } }
1125 BPF_ALU64_IMM(BPF_MOV, R0, -1),
1126 BPF_ALU64_IMM(BPF_MOV, R1, -1),
1127 BPF_ALU64_IMM(BPF_MOV, R2, 3),
1128 BPF_ALU64_REG(BPF_MUL, R1, R2),
1129 BPF_JMP_IMM(BPF_JEQ, R1, 0xfffffffd, 1),
1131 BPF_ALU64_IMM(BPF_MOV, R0, 1),
1141 BPF_ALU32_IMM(BPF_MOV, R0, -1),
1142 BPF_ALU32_IMM(BPF_MOV, R1, -1),
1143 BPF_ALU32_IMM(BPF_MOV, R2, 3),
1144 BPF_ALU64_REG(BPF_MUL, R1, R2),
1145 BPF_ALU64_IMM(BPF_RSH, R1, 8),
1146 BPF_JMP_IMM(BPF_JEQ, R1, 0x2ffffff, 1),
1148 BPF_ALU32_IMM(BPF_MOV, R0, 1),
1158 BPF_ALU32_IMM(BPF_MOV, R0, -1),
1159 BPF_ALU64_IMM(BPF_MOV, R1, -1),
1160 BPF_ALU32_IMM(BPF_MOV, R2, 3),
1161 BPF_ALU32_REG(BPF_MUL, R1, R2),
1162 BPF_ALU64_IMM(BPF_RSH, R1, 8),
1163 BPF_JMP_IMM(BPF_JEQ, R1, 0xffffff, 1),
1165 BPF_ALU32_IMM(BPF_MOV, R0, 1),
1173 /* Have to test all register combinations, since
1174 * JITing of different registers will produce
1175 * different asm code.
1179 BPF_ALU64_IMM(BPF_MOV, R0, 0),
1180 BPF_ALU64_IMM(BPF_MOV, R1, 1),
1181 BPF_ALU64_IMM(BPF_MOV, R2, 2),
1182 BPF_ALU64_IMM(BPF_MOV, R3, 3),
1183 BPF_ALU64_IMM(BPF_MOV, R4, 4),
1184 BPF_ALU64_IMM(BPF_MOV, R5, 5),
1185 BPF_ALU64_IMM(BPF_MOV, R6, 6),
1186 BPF_ALU64_IMM(BPF_MOV, R7, 7),
1187 BPF_ALU64_IMM(BPF_MOV, R8, 8),
1188 BPF_ALU64_IMM(BPF_MOV, R9, 9),
1189 BPF_ALU64_IMM(BPF_ADD, R0, 20),
1190 BPF_ALU64_IMM(BPF_ADD, R1, 20),
1191 BPF_ALU64_IMM(BPF_ADD, R2, 20),
1192 BPF_ALU64_IMM(BPF_ADD, R3, 20),
1193 BPF_ALU64_IMM(BPF_ADD, R4, 20),
1194 BPF_ALU64_IMM(BPF_ADD, R5, 20),
1195 BPF_ALU64_IMM(BPF_ADD, R6, 20),
1196 BPF_ALU64_IMM(BPF_ADD, R7, 20),
1197 BPF_ALU64_IMM(BPF_ADD, R8, 20),
1198 BPF_ALU64_IMM(BPF_ADD, R9, 20),
1199 BPF_ALU64_IMM(BPF_SUB, R0, 10),
1200 BPF_ALU64_IMM(BPF_SUB, R1, 10),
1201 BPF_ALU64_IMM(BPF_SUB, R2, 10),
1202 BPF_ALU64_IMM(BPF_SUB, R3, 10),
1203 BPF_ALU64_IMM(BPF_SUB, R4, 10),
1204 BPF_ALU64_IMM(BPF_SUB, R5, 10),
1205 BPF_ALU64_IMM(BPF_SUB, R6, 10),
1206 BPF_ALU64_IMM(BPF_SUB, R7, 10),
1207 BPF_ALU64_IMM(BPF_SUB, R8, 10),
1208 BPF_ALU64_IMM(BPF_SUB, R9, 10),
1209 BPF_ALU64_REG(BPF_ADD, R0, R0),
1210 BPF_ALU64_REG(BPF_ADD, R0, R1),
1211 BPF_ALU64_REG(BPF_ADD, R0, R2),
1212 BPF_ALU64_REG(BPF_ADD, R0, R3),
1213 BPF_ALU64_REG(BPF_ADD, R0, R4),
1214 BPF_ALU64_REG(BPF_ADD, R0, R5),
1215 BPF_ALU64_REG(BPF_ADD, R0, R6),
1216 BPF_ALU64_REG(BPF_ADD, R0, R7),
1217 BPF_ALU64_REG(BPF_ADD, R0, R8),
1218 BPF_ALU64_REG(BPF_ADD, R0, R9), /* R0 == 155 */
1219 BPF_JMP_IMM(BPF_JEQ, R0, 155, 1),
1221 BPF_ALU64_REG(BPF_ADD, R1, R0),
1222 BPF_ALU64_REG(BPF_ADD, R1, R1),
1223 BPF_ALU64_REG(BPF_ADD, R1, R2),
1224 BPF_ALU64_REG(BPF_ADD, R1, R3),
1225 BPF_ALU64_REG(BPF_ADD, R1, R4),
1226 BPF_ALU64_REG(BPF_ADD, R1, R5),
1227 BPF_ALU64_REG(BPF_ADD, R1, R6),
1228 BPF_ALU64_REG(BPF_ADD, R1, R7),
1229 BPF_ALU64_REG(BPF_ADD, R1, R8),
1230 BPF_ALU64_REG(BPF_ADD, R1, R9), /* R1 == 456 */
1231 BPF_JMP_IMM(BPF_JEQ, R1, 456, 1),
1233 BPF_ALU64_REG(BPF_ADD, R2, R0),
1234 BPF_ALU64_REG(BPF_ADD, R2, R1),
1235 BPF_ALU64_REG(BPF_ADD, R2, R2),
1236 BPF_ALU64_REG(BPF_ADD, R2, R3),
1237 BPF_ALU64_REG(BPF_ADD, R2, R4),
1238 BPF_ALU64_REG(BPF_ADD, R2, R5),
1239 BPF_ALU64_REG(BPF_ADD, R2, R6),
1240 BPF_ALU64_REG(BPF_ADD, R2, R7),
1241 BPF_ALU64_REG(BPF_ADD, R2, R8),
1242 BPF_ALU64_REG(BPF_ADD, R2, R9), /* R2 == 1358 */
1243 BPF_JMP_IMM(BPF_JEQ, R2, 1358, 1),
1245 BPF_ALU64_REG(BPF_ADD, R3, R0),
1246 BPF_ALU64_REG(BPF_ADD, R3, R1),
1247 BPF_ALU64_REG(BPF_ADD, R3, R2),
1248 BPF_ALU64_REG(BPF_ADD, R3, R3),
1249 BPF_ALU64_REG(BPF_ADD, R3, R4),
1250 BPF_ALU64_REG(BPF_ADD, R3, R5),
1251 BPF_ALU64_REG(BPF_ADD, R3, R6),
1252 BPF_ALU64_REG(BPF_ADD, R3, R7),
1253 BPF_ALU64_REG(BPF_ADD, R3, R8),
1254 BPF_ALU64_REG(BPF_ADD, R3, R9), /* R3 == 4063 */
1255 BPF_JMP_IMM(BPF_JEQ, R3, 4063, 1),
1257 BPF_ALU64_REG(BPF_ADD, R4, R0),
1258 BPF_ALU64_REG(BPF_ADD, R4, R1),
1259 BPF_ALU64_REG(BPF_ADD, R4, R2),
1260 BPF_ALU64_REG(BPF_ADD, R4, R3),
1261 BPF_ALU64_REG(BPF_ADD, R4, R4),
1262 BPF_ALU64_REG(BPF_ADD, R4, R5),
1263 BPF_ALU64_REG(BPF_ADD, R4, R6),
1264 BPF_ALU64_REG(BPF_ADD, R4, R7),
1265 BPF_ALU64_REG(BPF_ADD, R4, R8),
1266 BPF_ALU64_REG(BPF_ADD, R4, R9), /* R4 == 12177 */
1267 BPF_JMP_IMM(BPF_JEQ, R4, 12177, 1),
1269 BPF_ALU64_REG(BPF_ADD, R5, R0),
1270 BPF_ALU64_REG(BPF_ADD, R5, R1),
1271 BPF_ALU64_REG(BPF_ADD, R5, R2),
1272 BPF_ALU64_REG(BPF_ADD, R5, R3),
1273 BPF_ALU64_REG(BPF_ADD, R5, R4),
1274 BPF_ALU64_REG(BPF_ADD, R5, R5),
1275 BPF_ALU64_REG(BPF_ADD, R5, R6),
1276 BPF_ALU64_REG(BPF_ADD, R5, R7),
1277 BPF_ALU64_REG(BPF_ADD, R5, R8),
1278 BPF_ALU64_REG(BPF_ADD, R5, R9), /* R5 == 36518 */
1279 BPF_JMP_IMM(BPF_JEQ, R5, 36518, 1),
1281 BPF_ALU64_REG(BPF_ADD, R6, R0),
1282 BPF_ALU64_REG(BPF_ADD, R6, R1),
1283 BPF_ALU64_REG(BPF_ADD, R6, R2),
1284 BPF_ALU64_REG(BPF_ADD, R6, R3),
1285 BPF_ALU64_REG(BPF_ADD, R6, R4),
1286 BPF_ALU64_REG(BPF_ADD, R6, R5),
1287 BPF_ALU64_REG(BPF_ADD, R6, R6),
1288 BPF_ALU64_REG(BPF_ADD, R6, R7),
1289 BPF_ALU64_REG(BPF_ADD, R6, R8),
1290 BPF_ALU64_REG(BPF_ADD, R6, R9), /* R6 == 109540 */
1291 BPF_JMP_IMM(BPF_JEQ, R6, 109540, 1),
1293 BPF_ALU64_REG(BPF_ADD, R7, R0),
1294 BPF_ALU64_REG(BPF_ADD, R7, R1),
1295 BPF_ALU64_REG(BPF_ADD, R7, R2),
1296 BPF_ALU64_REG(BPF_ADD, R7, R3),
1297 BPF_ALU64_REG(BPF_ADD, R7, R4),
1298 BPF_ALU64_REG(BPF_ADD, R7, R5),
1299 BPF_ALU64_REG(BPF_ADD, R7, R6),
1300 BPF_ALU64_REG(BPF_ADD, R7, R7),
1301 BPF_ALU64_REG(BPF_ADD, R7, R8),
1302 BPF_ALU64_REG(BPF_ADD, R7, R9), /* R7 == 328605 */
1303 BPF_JMP_IMM(BPF_JEQ, R7, 328605, 1),
1305 BPF_ALU64_REG(BPF_ADD, R8, R0),
1306 BPF_ALU64_REG(BPF_ADD, R8, R1),
1307 BPF_ALU64_REG(BPF_ADD, R8, R2),
1308 BPF_ALU64_REG(BPF_ADD, R8, R3),
1309 BPF_ALU64_REG(BPF_ADD, R8, R4),
1310 BPF_ALU64_REG(BPF_ADD, R8, R5),
1311 BPF_ALU64_REG(BPF_ADD, R8, R6),
1312 BPF_ALU64_REG(BPF_ADD, R8, R7),
1313 BPF_ALU64_REG(BPF_ADD, R8, R8),
1314 BPF_ALU64_REG(BPF_ADD, R8, R9), /* R8 == 985799 */
1315 BPF_JMP_IMM(BPF_JEQ, R8, 985799, 1),
1317 BPF_ALU64_REG(BPF_ADD, R9, R0),
1318 BPF_ALU64_REG(BPF_ADD, R9, R1),
1319 BPF_ALU64_REG(BPF_ADD, R9, R2),
1320 BPF_ALU64_REG(BPF_ADD, R9, R3),
1321 BPF_ALU64_REG(BPF_ADD, R9, R4),
1322 BPF_ALU64_REG(BPF_ADD, R9, R5),
1323 BPF_ALU64_REG(BPF_ADD, R9, R6),
1324 BPF_ALU64_REG(BPF_ADD, R9, R7),
1325 BPF_ALU64_REG(BPF_ADD, R9, R8),
1326 BPF_ALU64_REG(BPF_ADD, R9, R9), /* R9 == 2957380 */
1327 BPF_ALU64_REG(BPF_MOV, R0, R9),
1337 BPF_ALU32_IMM(BPF_MOV, R0, 20),
1338 BPF_ALU32_IMM(BPF_MOV, R1, 1),
1339 BPF_ALU32_IMM(BPF_MOV, R2, 2),
1340 BPF_ALU32_IMM(BPF_MOV, R3, 3),
1341 BPF_ALU32_IMM(BPF_MOV, R4, 4),
1342 BPF_ALU32_IMM(BPF_MOV, R5, 5),
1343 BPF_ALU32_IMM(BPF_MOV, R6, 6),
1344 BPF_ALU32_IMM(BPF_MOV, R7, 7),
1345 BPF_ALU32_IMM(BPF_MOV, R8, 8),
1346 BPF_ALU32_IMM(BPF_MOV, R9, 9),
1347 BPF_ALU64_IMM(BPF_ADD, R1, 10),
1348 BPF_ALU64_IMM(BPF_ADD, R2, 10),
1349 BPF_ALU64_IMM(BPF_ADD, R3, 10),
1350 BPF_ALU64_IMM(BPF_ADD, R4, 10),
1351 BPF_ALU64_IMM(BPF_ADD, R5, 10),
1352 BPF_ALU64_IMM(BPF_ADD, R6, 10),
1353 BPF_ALU64_IMM(BPF_ADD, R7, 10),
1354 BPF_ALU64_IMM(BPF_ADD, R8, 10),
1355 BPF_ALU64_IMM(BPF_ADD, R9, 10),
1356 BPF_ALU32_REG(BPF_ADD, R0, R1),
1357 BPF_ALU32_REG(BPF_ADD, R0, R2),
1358 BPF_ALU32_REG(BPF_ADD, R0, R3),
1359 BPF_ALU32_REG(BPF_ADD, R0, R4),
1360 BPF_ALU32_REG(BPF_ADD, R0, R5),
1361 BPF_ALU32_REG(BPF_ADD, R0, R6),
1362 BPF_ALU32_REG(BPF_ADD, R0, R7),
1363 BPF_ALU32_REG(BPF_ADD, R0, R8),
1364 BPF_ALU32_REG(BPF_ADD, R0, R9), /* R0 == 155 */
1365 BPF_JMP_IMM(BPF_JEQ, R0, 155, 1),
1367 BPF_ALU32_REG(BPF_ADD, R1, R0),
1368 BPF_ALU32_REG(BPF_ADD, R1, R1),
1369 BPF_ALU32_REG(BPF_ADD, R1, R2),
1370 BPF_ALU32_REG(BPF_ADD, R1, R3),
1371 BPF_ALU32_REG(BPF_ADD, R1, R4),
1372 BPF_ALU32_REG(BPF_ADD, R1, R5),
1373 BPF_ALU32_REG(BPF_ADD, R1, R6),
1374 BPF_ALU32_REG(BPF_ADD, R1, R7),
1375 BPF_ALU32_REG(BPF_ADD, R1, R8),
1376 BPF_ALU32_REG(BPF_ADD, R1, R9), /* R1 == 456 */
1377 BPF_JMP_IMM(BPF_JEQ, R1, 456, 1),
1379 BPF_ALU32_REG(BPF_ADD, R2, R0),
1380 BPF_ALU32_REG(BPF_ADD, R2, R1),
1381 BPF_ALU32_REG(BPF_ADD, R2, R2),
1382 BPF_ALU32_REG(BPF_ADD, R2, R3),
1383 BPF_ALU32_REG(BPF_ADD, R2, R4),
1384 BPF_ALU32_REG(BPF_ADD, R2, R5),
1385 BPF_ALU32_REG(BPF_ADD, R2, R6),
1386 BPF_ALU32_REG(BPF_ADD, R2, R7),
1387 BPF_ALU32_REG(BPF_ADD, R2, R8),
1388 BPF_ALU32_REG(BPF_ADD, R2, R9), /* R2 == 1358 */
1389 BPF_JMP_IMM(BPF_JEQ, R2, 1358, 1),
1391 BPF_ALU32_REG(BPF_ADD, R3, R0),
1392 BPF_ALU32_REG(BPF_ADD, R3, R1),
1393 BPF_ALU32_REG(BPF_ADD, R3, R2),
1394 BPF_ALU32_REG(BPF_ADD, R3, R3),
1395 BPF_ALU32_REG(BPF_ADD, R3, R4),
1396 BPF_ALU32_REG(BPF_ADD, R3, R5),
1397 BPF_ALU32_REG(BPF_ADD, R3, R6),
1398 BPF_ALU32_REG(BPF_ADD, R3, R7),
1399 BPF_ALU32_REG(BPF_ADD, R3, R8),
1400 BPF_ALU32_REG(BPF_ADD, R3, R9), /* R3 == 4063 */
1401 BPF_JMP_IMM(BPF_JEQ, R3, 4063, 1),
1403 BPF_ALU32_REG(BPF_ADD, R4, R0),
1404 BPF_ALU32_REG(BPF_ADD, R4, R1),
1405 BPF_ALU32_REG(BPF_ADD, R4, R2),
1406 BPF_ALU32_REG(BPF_ADD, R4, R3),
1407 BPF_ALU32_REG(BPF_ADD, R4, R4),
1408 BPF_ALU32_REG(BPF_ADD, R4, R5),
1409 BPF_ALU32_REG(BPF_ADD, R4, R6),
1410 BPF_ALU32_REG(BPF_ADD, R4, R7),
1411 BPF_ALU32_REG(BPF_ADD, R4, R8),
1412 BPF_ALU32_REG(BPF_ADD, R4, R9), /* R4 == 12177 */
1413 BPF_JMP_IMM(BPF_JEQ, R4, 12177, 1),
1415 BPF_ALU32_REG(BPF_ADD, R5, R0),
1416 BPF_ALU32_REG(BPF_ADD, R5, R1),
1417 BPF_ALU32_REG(BPF_ADD, R5, R2),
1418 BPF_ALU32_REG(BPF_ADD, R5, R3),
1419 BPF_ALU32_REG(BPF_ADD, R5, R4),
1420 BPF_ALU32_REG(BPF_ADD, R5, R5),
1421 BPF_ALU32_REG(BPF_ADD, R5, R6),
1422 BPF_ALU32_REG(BPF_ADD, R5, R7),
1423 BPF_ALU32_REG(BPF_ADD, R5, R8),
1424 BPF_ALU32_REG(BPF_ADD, R5, R9), /* R5 == 36518 */
1425 BPF_JMP_IMM(BPF_JEQ, R5, 36518, 1),
1427 BPF_ALU32_REG(BPF_ADD, R6, R0),
1428 BPF_ALU32_REG(BPF_ADD, R6, R1),
1429 BPF_ALU32_REG(BPF_ADD, R6, R2),
1430 BPF_ALU32_REG(BPF_ADD, R6, R3),
1431 BPF_ALU32_REG(BPF_ADD, R6, R4),
1432 BPF_ALU32_REG(BPF_ADD, R6, R5),
1433 BPF_ALU32_REG(BPF_ADD, R6, R6),
1434 BPF_ALU32_REG(BPF_ADD, R6, R7),
1435 BPF_ALU32_REG(BPF_ADD, R6, R8),
1436 BPF_ALU32_REG(BPF_ADD, R6, R9), /* R6 == 109540 */
1437 BPF_JMP_IMM(BPF_JEQ, R6, 109540, 1),
1439 BPF_ALU32_REG(BPF_ADD, R7, R0),
1440 BPF_ALU32_REG(BPF_ADD, R7, R1),
1441 BPF_ALU32_REG(BPF_ADD, R7, R2),
1442 BPF_ALU32_REG(BPF_ADD, R7, R3),
1443 BPF_ALU32_REG(BPF_ADD, R7, R4),
1444 BPF_ALU32_REG(BPF_ADD, R7, R5),
1445 BPF_ALU32_REG(BPF_ADD, R7, R6),
1446 BPF_ALU32_REG(BPF_ADD, R7, R7),
1447 BPF_ALU32_REG(BPF_ADD, R7, R8),
1448 BPF_ALU32_REG(BPF_ADD, R7, R9), /* R7 == 328605 */
1449 BPF_JMP_IMM(BPF_JEQ, R7, 328605, 1),
1451 BPF_ALU32_REG(BPF_ADD, R8, R0),
1452 BPF_ALU32_REG(BPF_ADD, R8, R1),
1453 BPF_ALU32_REG(BPF_ADD, R8, R2),
1454 BPF_ALU32_REG(BPF_ADD, R8, R3),
1455 BPF_ALU32_REG(BPF_ADD, R8, R4),
1456 BPF_ALU32_REG(BPF_ADD, R8, R5),
1457 BPF_ALU32_REG(BPF_ADD, R8, R6),
1458 BPF_ALU32_REG(BPF_ADD, R8, R7),
1459 BPF_ALU32_REG(BPF_ADD, R8, R8),
1460 BPF_ALU32_REG(BPF_ADD, R8, R9), /* R8 == 985799 */
1461 BPF_JMP_IMM(BPF_JEQ, R8, 985799, 1),
1463 BPF_ALU32_REG(BPF_ADD, R9, R0),
1464 BPF_ALU32_REG(BPF_ADD, R9, R1),
1465 BPF_ALU32_REG(BPF_ADD, R9, R2),
1466 BPF_ALU32_REG(BPF_ADD, R9, R3),
1467 BPF_ALU32_REG(BPF_ADD, R9, R4),
1468 BPF_ALU32_REG(BPF_ADD, R9, R5),
1469 BPF_ALU32_REG(BPF_ADD, R9, R6),
1470 BPF_ALU32_REG(BPF_ADD, R9, R7),
1471 BPF_ALU32_REG(BPF_ADD, R9, R8),
1472 BPF_ALU32_REG(BPF_ADD, R9, R9), /* R9 == 2957380 */
1473 BPF_ALU32_REG(BPF_MOV, R0, R9),
1480 { /* Mainly checking JIT here. */
1483 BPF_ALU64_IMM(BPF_MOV, R0, 0),
1484 BPF_ALU64_IMM(BPF_MOV, R1, 1),
1485 BPF_ALU64_IMM(BPF_MOV, R2, 2),
1486 BPF_ALU64_IMM(BPF_MOV, R3, 3),
1487 BPF_ALU64_IMM(BPF_MOV, R4, 4),
1488 BPF_ALU64_IMM(BPF_MOV, R5, 5),
1489 BPF_ALU64_IMM(BPF_MOV, R6, 6),
1490 BPF_ALU64_IMM(BPF_MOV, R7, 7),
1491 BPF_ALU64_IMM(BPF_MOV, R8, 8),
1492 BPF_ALU64_IMM(BPF_MOV, R9, 9),
1493 BPF_ALU64_REG(BPF_SUB, R0, R0),
1494 BPF_ALU64_REG(BPF_SUB, R0, R1),
1495 BPF_ALU64_REG(BPF_SUB, R0, R2),
1496 BPF_ALU64_REG(BPF_SUB, R0, R3),
1497 BPF_ALU64_REG(BPF_SUB, R0, R4),
1498 BPF_ALU64_REG(BPF_SUB, R0, R5),
1499 BPF_ALU64_REG(BPF_SUB, R0, R6),
1500 BPF_ALU64_REG(BPF_SUB, R0, R7),
1501 BPF_ALU64_REG(BPF_SUB, R0, R8),
1502 BPF_ALU64_REG(BPF_SUB, R0, R9),
1503 BPF_ALU64_IMM(BPF_SUB, R0, 10),
1504 BPF_JMP_IMM(BPF_JEQ, R0, -55, 1),
1506 BPF_ALU64_REG(BPF_SUB, R1, R0),
1507 BPF_ALU64_REG(BPF_SUB, R1, R2),
1508 BPF_ALU64_REG(BPF_SUB, R1, R3),
1509 BPF_ALU64_REG(BPF_SUB, R1, R4),
1510 BPF_ALU64_REG(BPF_SUB, R1, R5),
1511 BPF_ALU64_REG(BPF_SUB, R1, R6),
1512 BPF_ALU64_REG(BPF_SUB, R1, R7),
1513 BPF_ALU64_REG(BPF_SUB, R1, R8),
1514 BPF_ALU64_REG(BPF_SUB, R1, R9),
1515 BPF_ALU64_IMM(BPF_SUB, R1, 10),
1516 BPF_ALU64_REG(BPF_SUB, R2, R0),
1517 BPF_ALU64_REG(BPF_SUB, R2, R1),
1518 BPF_ALU64_REG(BPF_SUB, R2, R3),
1519 BPF_ALU64_REG(BPF_SUB, R2, R4),
1520 BPF_ALU64_REG(BPF_SUB, R2, R5),
1521 BPF_ALU64_REG(BPF_SUB, R2, R6),
1522 BPF_ALU64_REG(BPF_SUB, R2, R7),
1523 BPF_ALU64_REG(BPF_SUB, R2, R8),
1524 BPF_ALU64_REG(BPF_SUB, R2, R9),
1525 BPF_ALU64_IMM(BPF_SUB, R2, 10),
1526 BPF_ALU64_REG(BPF_SUB, R3, R0),
1527 BPF_ALU64_REG(BPF_SUB, R3, R1),
1528 BPF_ALU64_REG(BPF_SUB, R3, R2),
1529 BPF_ALU64_REG(BPF_SUB, R3, R4),
1530 BPF_ALU64_REG(BPF_SUB, R3, R5),
1531 BPF_ALU64_REG(BPF_SUB, R3, R6),
1532 BPF_ALU64_REG(BPF_SUB, R3, R7),
1533 BPF_ALU64_REG(BPF_SUB, R3, R8),
1534 BPF_ALU64_REG(BPF_SUB, R3, R9),
1535 BPF_ALU64_IMM(BPF_SUB, R3, 10),
1536 BPF_ALU64_REG(BPF_SUB, R4, R0),
1537 BPF_ALU64_REG(BPF_SUB, R4, R1),
1538 BPF_ALU64_REG(BPF_SUB, R4, R2),
1539 BPF_ALU64_REG(BPF_SUB, R4, R3),
1540 BPF_ALU64_REG(BPF_SUB, R4, R5),
1541 BPF_ALU64_REG(BPF_SUB, R4, R6),
1542 BPF_ALU64_REG(BPF_SUB, R4, R7),
1543 BPF_ALU64_REG(BPF_SUB, R4, R8),
1544 BPF_ALU64_REG(BPF_SUB, R4, R9),
1545 BPF_ALU64_IMM(BPF_SUB, R4, 10),
1546 BPF_ALU64_REG(BPF_SUB, R5, R0),
1547 BPF_ALU64_REG(BPF_SUB, R5, R1),
1548 BPF_ALU64_REG(BPF_SUB, R5, R2),
1549 BPF_ALU64_REG(BPF_SUB, R5, R3),
1550 BPF_ALU64_REG(BPF_SUB, R5, R4),
1551 BPF_ALU64_REG(BPF_SUB, R5, R6),
1552 BPF_ALU64_REG(BPF_SUB, R5, R7),
1553 BPF_ALU64_REG(BPF_SUB, R5, R8),
1554 BPF_ALU64_REG(BPF_SUB, R5, R9),
1555 BPF_ALU64_IMM(BPF_SUB, R5, 10),
1556 BPF_ALU64_REG(BPF_SUB, R6, R0),
1557 BPF_ALU64_REG(BPF_SUB, R6, R1),
1558 BPF_ALU64_REG(BPF_SUB, R6, R2),
1559 BPF_ALU64_REG(BPF_SUB, R6, R3),
1560 BPF_ALU64_REG(BPF_SUB, R6, R4),
1561 BPF_ALU64_REG(BPF_SUB, R6, R5),
1562 BPF_ALU64_REG(BPF_SUB, R6, R7),
1563 BPF_ALU64_REG(BPF_SUB, R6, R8),
1564 BPF_ALU64_REG(BPF_SUB, R6, R9),
1565 BPF_ALU64_IMM(BPF_SUB, R6, 10),
1566 BPF_ALU64_REG(BPF_SUB, R7, R0),
1567 BPF_ALU64_REG(BPF_SUB, R7, R1),
1568 BPF_ALU64_REG(BPF_SUB, R7, R2),
1569 BPF_ALU64_REG(BPF_SUB, R7, R3),
1570 BPF_ALU64_REG(BPF_SUB, R7, R4),
1571 BPF_ALU64_REG(BPF_SUB, R7, R5),
1572 BPF_ALU64_REG(BPF_SUB, R7, R6),
1573 BPF_ALU64_REG(BPF_SUB, R7, R8),
1574 BPF_ALU64_REG(BPF_SUB, R7, R9),
1575 BPF_ALU64_IMM(BPF_SUB, R7, 10),
1576 BPF_ALU64_REG(BPF_SUB, R8, R0),
1577 BPF_ALU64_REG(BPF_SUB, R8, R1),
1578 BPF_ALU64_REG(BPF_SUB, R8, R2),
1579 BPF_ALU64_REG(BPF_SUB, R8, R3),
1580 BPF_ALU64_REG(BPF_SUB, R8, R4),
1581 BPF_ALU64_REG(BPF_SUB, R8, R5),
1582 BPF_ALU64_REG(BPF_SUB, R8, R6),
1583 BPF_ALU64_REG(BPF_SUB, R8, R7),
1584 BPF_ALU64_REG(BPF_SUB, R8, R9),
1585 BPF_ALU64_IMM(BPF_SUB, R8, 10),
1586 BPF_ALU64_REG(BPF_SUB, R9, R0),
1587 BPF_ALU64_REG(BPF_SUB, R9, R1),
1588 BPF_ALU64_REG(BPF_SUB, R9, R2),
1589 BPF_ALU64_REG(BPF_SUB, R9, R3),
1590 BPF_ALU64_REG(BPF_SUB, R9, R4),
1591 BPF_ALU64_REG(BPF_SUB, R9, R5),
1592 BPF_ALU64_REG(BPF_SUB, R9, R6),
1593 BPF_ALU64_REG(BPF_SUB, R9, R7),
1594 BPF_ALU64_REG(BPF_SUB, R9, R8),
1595 BPF_ALU64_IMM(BPF_SUB, R9, 10),
1596 BPF_ALU64_IMM(BPF_SUB, R0, 10),
1597 BPF_ALU64_IMM(BPF_NEG, R0, 0),
1598 BPF_ALU64_REG(BPF_SUB, R0, R1),
1599 BPF_ALU64_REG(BPF_SUB, R0, R2),
1600 BPF_ALU64_REG(BPF_SUB, R0, R3),
1601 BPF_ALU64_REG(BPF_SUB, R0, R4),
1602 BPF_ALU64_REG(BPF_SUB, R0, R5),
1603 BPF_ALU64_REG(BPF_SUB, R0, R6),
1604 BPF_ALU64_REG(BPF_SUB, R0, R7),
1605 BPF_ALU64_REG(BPF_SUB, R0, R8),
1606 BPF_ALU64_REG(BPF_SUB, R0, R9),
1613 { /* Mainly checking JIT here. */
1616 BPF_ALU64_REG(BPF_SUB, R0, R0),
1617 BPF_ALU64_REG(BPF_XOR, R1, R1),
1618 BPF_JMP_REG(BPF_JEQ, R0, R1, 1),
1620 BPF_ALU64_IMM(BPF_MOV, R0, 10),
1621 BPF_ALU64_IMM(BPF_MOV, R1, -1),
1622 BPF_ALU64_REG(BPF_SUB, R1, R1),
1623 BPF_ALU64_REG(BPF_XOR, R2, R2),
1624 BPF_JMP_REG(BPF_JEQ, R1, R2, 1),
1626 BPF_ALU64_REG(BPF_SUB, R2, R2),
1627 BPF_ALU64_REG(BPF_XOR, R3, R3),
1628 BPF_ALU64_IMM(BPF_MOV, R0, 10),
1629 BPF_ALU64_IMM(BPF_MOV, R1, -1),
1630 BPF_JMP_REG(BPF_JEQ, R2, R3, 1),
1632 BPF_ALU64_REG(BPF_SUB, R3, R3),
1633 BPF_ALU64_REG(BPF_XOR, R4, R4),
1634 BPF_ALU64_IMM(BPF_MOV, R2, 1),
1635 BPF_ALU64_IMM(BPF_MOV, R5, -1),
1636 BPF_JMP_REG(BPF_JEQ, R3, R4, 1),
1638 BPF_ALU64_REG(BPF_SUB, R4, R4),
1639 BPF_ALU64_REG(BPF_XOR, R5, R5),
1640 BPF_ALU64_IMM(BPF_MOV, R3, 1),
1641 BPF_ALU64_IMM(BPF_MOV, R7, -1),
1642 BPF_JMP_REG(BPF_JEQ, R5, R4, 1),
1644 BPF_ALU64_IMM(BPF_MOV, R5, 1),
1645 BPF_ALU64_REG(BPF_SUB, R5, R5),
1646 BPF_ALU64_REG(BPF_XOR, R6, R6),
1647 BPF_ALU64_IMM(BPF_MOV, R1, 1),
1648 BPF_ALU64_IMM(BPF_MOV, R8, -1),
1649 BPF_JMP_REG(BPF_JEQ, R5, R6, 1),
1651 BPF_ALU64_REG(BPF_SUB, R6, R6),
1652 BPF_ALU64_REG(BPF_XOR, R7, R7),
1653 BPF_JMP_REG(BPF_JEQ, R7, R6, 1),
1655 BPF_ALU64_REG(BPF_SUB, R7, R7),
1656 BPF_ALU64_REG(BPF_XOR, R8, R8),
1657 BPF_JMP_REG(BPF_JEQ, R7, R8, 1),
1659 BPF_ALU64_REG(BPF_SUB, R8, R8),
1660 BPF_ALU64_REG(BPF_XOR, R9, R9),
1661 BPF_JMP_REG(BPF_JEQ, R9, R8, 1),
1663 BPF_ALU64_REG(BPF_SUB, R9, R9),
1664 BPF_ALU64_REG(BPF_XOR, R0, R0),
1665 BPF_JMP_REG(BPF_JEQ, R9, R0, 1),
1667 BPF_ALU64_REG(BPF_SUB, R1, R1),
1668 BPF_ALU64_REG(BPF_XOR, R0, R0),
1669 BPF_JMP_REG(BPF_JEQ, R9, R0, 2),
1670 BPF_ALU64_IMM(BPF_MOV, R0, 0),
1672 BPF_ALU64_IMM(BPF_MOV, R0, 1),
1679 { /* Mainly checking JIT here. */
1682 BPF_ALU64_IMM(BPF_MOV, R0, 11),
1683 BPF_ALU64_IMM(BPF_MOV, R1, 1),
1684 BPF_ALU64_IMM(BPF_MOV, R2, 2),
1685 BPF_ALU64_IMM(BPF_MOV, R3, 3),
1686 BPF_ALU64_IMM(BPF_MOV, R4, 4),
1687 BPF_ALU64_IMM(BPF_MOV, R5, 5),
1688 BPF_ALU64_IMM(BPF_MOV, R6, 6),
1689 BPF_ALU64_IMM(BPF_MOV, R7, 7),
1690 BPF_ALU64_IMM(BPF_MOV, R8, 8),
1691 BPF_ALU64_IMM(BPF_MOV, R9, 9),
1692 BPF_ALU64_REG(BPF_MUL, R0, R0),
1693 BPF_ALU64_REG(BPF_MUL, R0, R1),
1694 BPF_ALU64_REG(BPF_MUL, R0, R2),
1695 BPF_ALU64_REG(BPF_MUL, R0, R3),
1696 BPF_ALU64_REG(BPF_MUL, R0, R4),
1697 BPF_ALU64_REG(BPF_MUL, R0, R5),
1698 BPF_ALU64_REG(BPF_MUL, R0, R6),
1699 BPF_ALU64_REG(BPF_MUL, R0, R7),
1700 BPF_ALU64_REG(BPF_MUL, R0, R8),
1701 BPF_ALU64_REG(BPF_MUL, R0, R9),
1702 BPF_ALU64_IMM(BPF_MUL, R0, 10),
1703 BPF_JMP_IMM(BPF_JEQ, R0, 439084800, 1),
1705 BPF_ALU64_REG(BPF_MUL, R1, R0),
1706 BPF_ALU64_REG(BPF_MUL, R1, R2),
1707 BPF_ALU64_REG(BPF_MUL, R1, R3),
1708 BPF_ALU64_REG(BPF_MUL, R1, R4),
1709 BPF_ALU64_REG(BPF_MUL, R1, R5),
1710 BPF_ALU64_REG(BPF_MUL, R1, R6),
1711 BPF_ALU64_REG(BPF_MUL, R1, R7),
1712 BPF_ALU64_REG(BPF_MUL, R1, R8),
1713 BPF_ALU64_REG(BPF_MUL, R1, R9),
1714 BPF_ALU64_IMM(BPF_MUL, R1, 10),
1715 BPF_ALU64_REG(BPF_MOV, R2, R1),
1716 BPF_ALU64_IMM(BPF_RSH, R2, 32),
1717 BPF_JMP_IMM(BPF_JEQ, R2, 0x5a924, 1),
1719 BPF_ALU64_IMM(BPF_LSH, R1, 32),
1720 BPF_ALU64_IMM(BPF_ARSH, R1, 32),
1721 BPF_JMP_IMM(BPF_JEQ, R1, 0xebb90000, 1),
1723 BPF_ALU64_REG(BPF_MUL, R2, R0),
1724 BPF_ALU64_REG(BPF_MUL, R2, R1),
1725 BPF_ALU64_REG(BPF_MUL, R2, R3),
1726 BPF_ALU64_REG(BPF_MUL, R2, R4),
1727 BPF_ALU64_REG(BPF_MUL, R2, R5),
1728 BPF_ALU64_REG(BPF_MUL, R2, R6),
1729 BPF_ALU64_REG(BPF_MUL, R2, R7),
1730 BPF_ALU64_REG(BPF_MUL, R2, R8),
1731 BPF_ALU64_REG(BPF_MUL, R2, R9),
1732 BPF_ALU64_IMM(BPF_MUL, R2, 10),
1733 BPF_ALU64_IMM(BPF_RSH, R2, 32),
1734 BPF_ALU64_REG(BPF_MOV, R0, R2),
1739 { { 0, 0x35d97ef2 } }
1741 { /* Mainly checking JIT here. */
1744 BPF_LD_IMM64(R0, 0xffffffffffffffffLL),
1745 BPF_MOV64_REG(R1, R0),
1746 BPF_MOV64_REG(R2, R1),
1747 BPF_MOV64_REG(R3, R2),
1748 BPF_MOV64_REG(R4, R3),
1749 BPF_MOV64_REG(R5, R4),
1750 BPF_MOV64_REG(R6, R5),
1751 BPF_MOV64_REG(R7, R6),
1752 BPF_MOV64_REG(R8, R7),
1753 BPF_MOV64_REG(R9, R8),
1754 BPF_ALU64_IMM(BPF_MOV, R0, 0),
1755 BPF_ALU64_IMM(BPF_MOV, R1, 0),
1756 BPF_ALU64_IMM(BPF_MOV, R2, 0),
1757 BPF_ALU64_IMM(BPF_MOV, R3, 0),
1758 BPF_ALU64_IMM(BPF_MOV, R4, 0),
1759 BPF_ALU64_IMM(BPF_MOV, R5, 0),
1760 BPF_ALU64_IMM(BPF_MOV, R6, 0),
1761 BPF_ALU64_IMM(BPF_MOV, R7, 0),
1762 BPF_ALU64_IMM(BPF_MOV, R8, 0),
1763 BPF_ALU64_IMM(BPF_MOV, R9, 0),
1764 BPF_ALU64_REG(BPF_ADD, R0, R0),
1765 BPF_ALU64_REG(BPF_ADD, R0, R1),
1766 BPF_ALU64_REG(BPF_ADD, R0, R2),
1767 BPF_ALU64_REG(BPF_ADD, R0, R3),
1768 BPF_ALU64_REG(BPF_ADD, R0, R4),
1769 BPF_ALU64_REG(BPF_ADD, R0, R5),
1770 BPF_ALU64_REG(BPF_ADD, R0, R6),
1771 BPF_ALU64_REG(BPF_ADD, R0, R7),
1772 BPF_ALU64_REG(BPF_ADD, R0, R8),
1773 BPF_ALU64_REG(BPF_ADD, R0, R9),
1774 BPF_ALU64_IMM(BPF_ADD, R0, 0xfefe),
1781 { /* Mainly checking JIT here. */
1784 BPF_LD_IMM64(R0, 0xffffffffffffffffLL),
1785 BPF_MOV64_REG(R1, R0),
1786 BPF_MOV64_REG(R2, R1),
1787 BPF_MOV64_REG(R3, R2),
1788 BPF_MOV64_REG(R4, R3),
1789 BPF_MOV64_REG(R5, R4),
1790 BPF_MOV64_REG(R6, R5),
1791 BPF_MOV64_REG(R7, R6),
1792 BPF_MOV64_REG(R8, R7),
1793 BPF_MOV64_REG(R9, R8),
1794 BPF_ALU32_IMM(BPF_MOV, R0, 0),
1795 BPF_ALU32_IMM(BPF_MOV, R1, 0),
1796 BPF_ALU32_IMM(BPF_MOV, R2, 0),
1797 BPF_ALU32_IMM(BPF_MOV, R3, 0),
1798 BPF_ALU32_IMM(BPF_MOV, R4, 0),
1799 BPF_ALU32_IMM(BPF_MOV, R5, 0),
1800 BPF_ALU32_IMM(BPF_MOV, R6, 0),
1801 BPF_ALU32_IMM(BPF_MOV, R7, 0),
1802 BPF_ALU32_IMM(BPF_MOV, R8, 0),
1803 BPF_ALU32_IMM(BPF_MOV, R9, 0),
1804 BPF_ALU64_REG(BPF_ADD, R0, R0),
1805 BPF_ALU64_REG(BPF_ADD, R0, R1),
1806 BPF_ALU64_REG(BPF_ADD, R0, R2),
1807 BPF_ALU64_REG(BPF_ADD, R0, R3),
1808 BPF_ALU64_REG(BPF_ADD, R0, R4),
1809 BPF_ALU64_REG(BPF_ADD, R0, R5),
1810 BPF_ALU64_REG(BPF_ADD, R0, R6),
1811 BPF_ALU64_REG(BPF_ADD, R0, R7),
1812 BPF_ALU64_REG(BPF_ADD, R0, R8),
1813 BPF_ALU64_REG(BPF_ADD, R0, R9),
1814 BPF_ALU64_IMM(BPF_ADD, R0, 0xfefe),
1821 { /* Mainly checking JIT here. */
1824 BPF_LD_IMM64(R0, 0xffffffffffffffffLL),
1825 BPF_MOV64_REG(R1, R0),
1826 BPF_MOV64_REG(R2, R1),
1827 BPF_MOV64_REG(R3, R2),
1828 BPF_MOV64_REG(R4, R3),
1829 BPF_MOV64_REG(R5, R4),
1830 BPF_MOV64_REG(R6, R5),
1831 BPF_MOV64_REG(R7, R6),
1832 BPF_MOV64_REG(R8, R7),
1833 BPF_MOV64_REG(R9, R8),
1834 BPF_LD_IMM64(R0, 0x0LL),
1835 BPF_LD_IMM64(R1, 0x0LL),
1836 BPF_LD_IMM64(R2, 0x0LL),
1837 BPF_LD_IMM64(R3, 0x0LL),
1838 BPF_LD_IMM64(R4, 0x0LL),
1839 BPF_LD_IMM64(R5, 0x0LL),
1840 BPF_LD_IMM64(R6, 0x0LL),
1841 BPF_LD_IMM64(R7, 0x0LL),
1842 BPF_LD_IMM64(R8, 0x0LL),
1843 BPF_LD_IMM64(R9, 0x0LL),
1844 BPF_ALU64_REG(BPF_ADD, R0, R0),
1845 BPF_ALU64_REG(BPF_ADD, R0, R1),
1846 BPF_ALU64_REG(BPF_ADD, R0, R2),
1847 BPF_ALU64_REG(BPF_ADD, R0, R3),
1848 BPF_ALU64_REG(BPF_ADD, R0, R4),
1849 BPF_ALU64_REG(BPF_ADD, R0, R5),
1850 BPF_ALU64_REG(BPF_ADD, R0, R6),
1851 BPF_ALU64_REG(BPF_ADD, R0, R7),
1852 BPF_ALU64_REG(BPF_ADD, R0, R8),
1853 BPF_ALU64_REG(BPF_ADD, R0, R9),
1854 BPF_ALU64_IMM(BPF_ADD, R0, 0xfefe),
1864 BPF_ALU64_IMM(BPF_MOV, R0, 11),
1865 BPF_ALU64_IMM(BPF_ADD, R0, -1),
1866 BPF_ALU64_IMM(BPF_MOV, R2, 2),
1867 BPF_ALU64_IMM(BPF_XOR, R2, 3),
1868 BPF_ALU64_REG(BPF_DIV, R0, R2),
1869 BPF_JMP_IMM(BPF_JEQ, R0, 10, 1),
1871 BPF_ALU64_IMM(BPF_MOD, R0, 3),
1872 BPF_JMP_IMM(BPF_JEQ, R0, 1, 1),
1874 BPF_ALU64_IMM(BPF_MOV, R0, -1),
1882 "INT: shifts by register",
1884 BPF_MOV64_IMM(R0, -1234),
1885 BPF_MOV64_IMM(R1, 1),
1886 BPF_ALU32_REG(BPF_RSH, R0, R1),
1887 BPF_JMP_IMM(BPF_JEQ, R0, 0x7ffffd97, 1),
1889 BPF_MOV64_IMM(R2, 1),
1890 BPF_ALU64_REG(BPF_LSH, R0, R2),
1891 BPF_MOV32_IMM(R4, -1234),
1892 BPF_JMP_REG(BPF_JEQ, R0, R4, 1),
1894 BPF_ALU64_IMM(BPF_AND, R4, 63),
1895 BPF_ALU64_REG(BPF_LSH, R0, R4), /* R0 <= 46 */
1896 BPF_MOV64_IMM(R3, 47),
1897 BPF_ALU64_REG(BPF_ARSH, R0, R3),
1898 BPF_JMP_IMM(BPF_JEQ, R0, -617, 1),
1900 BPF_MOV64_IMM(R2, 1),
1901 BPF_ALU64_REG(BPF_LSH, R4, R2), /* R4 = 46 << 1 */
1902 BPF_JMP_IMM(BPF_JEQ, R4, 92, 1),
1904 BPF_MOV64_IMM(R4, 4),
1905 BPF_ALU64_REG(BPF_LSH, R4, R4), /* R4 = 4 << 4 */
1906 BPF_JMP_IMM(BPF_JEQ, R4, 64, 1),
1908 BPF_MOV64_IMM(R4, 5),
1909 BPF_ALU32_REG(BPF_LSH, R4, R4), /* R4 = 5 << 5 */
1910 BPF_JMP_IMM(BPF_JEQ, R4, 160, 1),
1912 BPF_MOV64_IMM(R0, -1),
1920 "check: missing ret",
1922 BPF_STMT(BPF_LD | BPF_IMM, 1),
1924 CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL,
1927 .fill_helper = NULL,
1928 .expected_errcode = -EINVAL,
1933 BPF_STMT(BPF_ALU | BPF_DIV | BPF_K, 0),
1934 BPF_STMT(BPF_RET | BPF_K, 0)
1936 CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL,
1939 .fill_helper = NULL,
1940 .expected_errcode = -EINVAL,
1943 "check: unknown insn",
1945 /* seccomp insn, rejected in socket filter */
1946 BPF_STMT(BPF_LDX | BPF_W | BPF_ABS, 0),
1947 BPF_STMT(BPF_RET | BPF_K, 0)
1949 CLASSIC | FLAG_EXPECTED_FAIL,
1952 .fill_helper = NULL,
1953 .expected_errcode = -EINVAL,
1956 "check: out of range spill/fill",
1958 BPF_STMT(BPF_STX, 16),
1959 BPF_STMT(BPF_RET | BPF_K, 0)
1961 CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL,
1964 .fill_helper = NULL,
1965 .expected_errcode = -EINVAL,
1970 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
1971 BPF_JUMP(BPF_JMP | BPF_JGE, 0, 13, 15),
1972 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
1973 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
1974 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
1975 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
1976 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
1977 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
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_JUMP(BPF_JMP | BPF_JEQ, 0x90c2894d, 3, 4),
1986 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
1987 BPF_JUMP(BPF_JMP | BPF_JEQ, 0x90c2894d, 1, 2),
1988 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
1989 BPF_JUMP(BPF_JMP | BPF_JGE, 0, 14, 15),
1990 BPF_JUMP(BPF_JMP | BPF_JGE, 0, 13, 14),
1991 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
1992 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
1993 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
1994 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
1995 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
1996 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
1997 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
1998 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
1999 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2000 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2001 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2002 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2003 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2004 BPF_JUMP(BPF_JMP | BPF_JEQ, 0x2ac28349, 2, 3),
2005 BPF_JUMP(BPF_JMP | BPF_JEQ, 0x2ac28349, 1, 2),
2006 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2007 BPF_JUMP(BPF_JMP | BPF_JGE, 0, 14, 15),
2008 BPF_JUMP(BPF_JMP | BPF_JGE, 0, 13, 14),
2009 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2010 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2011 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2012 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2013 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2014 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2015 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2016 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2017 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2018 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2019 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2020 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2021 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2022 BPF_JUMP(BPF_JMP | BPF_JEQ, 0x90d2ff41, 2, 3),
2023 BPF_JUMP(BPF_JMP | BPF_JEQ, 0x90d2ff41, 1, 2),
2024 BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2025 BPF_STMT(BPF_RET | BPF_A, 0),
2026 BPF_STMT(BPF_RET | BPF_A, 0),
2029 { 0x00, 0x1b, 0x21, 0x3c, 0x9d, 0xf8,
2030 0x90, 0xe2, 0xba, 0x0a, 0x56, 0xb4,
2032 0x45, 0x00, 0x00, 0x28, 0x00, 0x00,
2033 0x20, 0x00, 0x40, 0x11, 0x00, 0x00, /* IP header */
2034 0xc0, 0xa8, 0x33, 0x01,
2035 0xc0, 0xa8, 0x33, 0x02,
2038 0x00, 0x14, 0x00, 0x00,
2039 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
2040 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
2041 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
2042 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
2043 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
2044 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
2045 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
2046 0xcc, 0xcc, 0xcc, 0xcc },
2052 BPF_STMT(BPF_RET | BPF_X, 0),
2054 CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL,
2057 .fill_helper = NULL,
2058 .expected_errcode = -EINVAL,
2061 "check: LDX + RET X",
2063 BPF_STMT(BPF_LDX | BPF_IMM, 42),
2064 BPF_STMT(BPF_RET | BPF_X, 0),
2066 CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL,
2069 .fill_helper = NULL,
2070 .expected_errcode = -EINVAL,
2072 { /* Mainly checking JIT here. */
2073 "M[]: alt STX + LDX",
2075 BPF_STMT(BPF_LDX | BPF_IMM, 100),
2076 BPF_STMT(BPF_STX, 0),
2077 BPF_STMT(BPF_LDX | BPF_MEM, 0),
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, 1),
2082 BPF_STMT(BPF_LDX | BPF_MEM, 1),
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, 2),
2087 BPF_STMT(BPF_LDX | BPF_MEM, 2),
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, 3),
2092 BPF_STMT(BPF_LDX | BPF_MEM, 3),
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, 4),
2097 BPF_STMT(BPF_LDX | BPF_MEM, 4),
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, 5),
2102 BPF_STMT(BPF_LDX | BPF_MEM, 5),
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, 6),
2107 BPF_STMT(BPF_LDX | BPF_MEM, 6),
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, 7),
2112 BPF_STMT(BPF_LDX | BPF_MEM, 7),
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, 8),
2117 BPF_STMT(BPF_LDX | BPF_MEM, 8),
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_STX, 9),
2122 BPF_STMT(BPF_LDX | BPF_MEM, 9),
2123 BPF_STMT(BPF_MISC | BPF_TXA, 0),
2124 BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1),
2125 BPF_STMT(BPF_MISC | BPF_TAX, 0),
2126 BPF_STMT(BPF_STX, 10),
2127 BPF_STMT(BPF_LDX | BPF_MEM, 10),
2128 BPF_STMT(BPF_MISC | BPF_TXA, 0),
2129 BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1),
2130 BPF_STMT(BPF_MISC | BPF_TAX, 0),
2131 BPF_STMT(BPF_STX, 11),
2132 BPF_STMT(BPF_LDX | BPF_MEM, 11),
2133 BPF_STMT(BPF_MISC | BPF_TXA, 0),
2134 BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1),
2135 BPF_STMT(BPF_MISC | BPF_TAX, 0),
2136 BPF_STMT(BPF_STX, 12),
2137 BPF_STMT(BPF_LDX | BPF_MEM, 12),
2138 BPF_STMT(BPF_MISC | BPF_TXA, 0),
2139 BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1),
2140 BPF_STMT(BPF_MISC | BPF_TAX, 0),
2141 BPF_STMT(BPF_STX, 13),
2142 BPF_STMT(BPF_LDX | BPF_MEM, 13),
2143 BPF_STMT(BPF_MISC | BPF_TXA, 0),
2144 BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1),
2145 BPF_STMT(BPF_MISC | BPF_TAX, 0),
2146 BPF_STMT(BPF_STX, 14),
2147 BPF_STMT(BPF_LDX | BPF_MEM, 14),
2148 BPF_STMT(BPF_MISC | BPF_TXA, 0),
2149 BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1),
2150 BPF_STMT(BPF_MISC | BPF_TAX, 0),
2151 BPF_STMT(BPF_STX, 15),
2152 BPF_STMT(BPF_LDX | BPF_MEM, 15),
2153 BPF_STMT(BPF_MISC | BPF_TXA, 0),
2154 BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1),
2155 BPF_STMT(BPF_MISC | BPF_TAX, 0),
2156 BPF_STMT(BPF_RET | BPF_A, 0),
2158 CLASSIC | FLAG_NO_DATA,
2162 { /* Mainly checking JIT here. */
2163 "M[]: full STX + full LDX",
2165 BPF_STMT(BPF_LDX | BPF_IMM, 0xbadfeedb),
2166 BPF_STMT(BPF_STX, 0),
2167 BPF_STMT(BPF_LDX | BPF_IMM, 0xecabedae),
2168 BPF_STMT(BPF_STX, 1),
2169 BPF_STMT(BPF_LDX | BPF_IMM, 0xafccfeaf),
2170 BPF_STMT(BPF_STX, 2),
2171 BPF_STMT(BPF_LDX | BPF_IMM, 0xbffdcedc),
2172 BPF_STMT(BPF_STX, 3),
2173 BPF_STMT(BPF_LDX | BPF_IMM, 0xfbbbdccb),
2174 BPF_STMT(BPF_STX, 4),
2175 BPF_STMT(BPF_LDX | BPF_IMM, 0xfbabcbda),
2176 BPF_STMT(BPF_STX, 5),
2177 BPF_STMT(BPF_LDX | BPF_IMM, 0xaedecbdb),
2178 BPF_STMT(BPF_STX, 6),
2179 BPF_STMT(BPF_LDX | BPF_IMM, 0xadebbade),
2180 BPF_STMT(BPF_STX, 7),
2181 BPF_STMT(BPF_LDX | BPF_IMM, 0xfcfcfaec),
2182 BPF_STMT(BPF_STX, 8),
2183 BPF_STMT(BPF_LDX | BPF_IMM, 0xbcdddbdc),
2184 BPF_STMT(BPF_STX, 9),
2185 BPF_STMT(BPF_LDX | BPF_IMM, 0xfeefdfac),
2186 BPF_STMT(BPF_STX, 10),
2187 BPF_STMT(BPF_LDX | BPF_IMM, 0xcddcdeea),
2188 BPF_STMT(BPF_STX, 11),
2189 BPF_STMT(BPF_LDX | BPF_IMM, 0xaccfaebb),
2190 BPF_STMT(BPF_STX, 12),
2191 BPF_STMT(BPF_LDX | BPF_IMM, 0xbdcccdcf),
2192 BPF_STMT(BPF_STX, 13),
2193 BPF_STMT(BPF_LDX | BPF_IMM, 0xaaedecde),
2194 BPF_STMT(BPF_STX, 14),
2195 BPF_STMT(BPF_LDX | BPF_IMM, 0xfaeacdad),
2196 BPF_STMT(BPF_STX, 15),
2197 BPF_STMT(BPF_LDX | BPF_MEM, 0),
2198 BPF_STMT(BPF_MISC | BPF_TXA, 0),
2199 BPF_STMT(BPF_LDX | BPF_MEM, 1),
2200 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
2201 BPF_STMT(BPF_LDX | BPF_MEM, 2),
2202 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
2203 BPF_STMT(BPF_LDX | BPF_MEM, 3),
2204 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
2205 BPF_STMT(BPF_LDX | BPF_MEM, 4),
2206 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
2207 BPF_STMT(BPF_LDX | BPF_MEM, 5),
2208 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
2209 BPF_STMT(BPF_LDX | BPF_MEM, 6),
2210 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
2211 BPF_STMT(BPF_LDX | BPF_MEM, 7),
2212 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
2213 BPF_STMT(BPF_LDX | BPF_MEM, 8),
2214 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
2215 BPF_STMT(BPF_LDX | BPF_MEM, 9),
2216 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
2217 BPF_STMT(BPF_LDX | BPF_MEM, 10),
2218 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
2219 BPF_STMT(BPF_LDX | BPF_MEM, 11),
2220 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
2221 BPF_STMT(BPF_LDX | BPF_MEM, 12),
2222 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
2223 BPF_STMT(BPF_LDX | BPF_MEM, 13),
2224 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
2225 BPF_STMT(BPF_LDX | BPF_MEM, 14),
2226 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
2227 BPF_STMT(BPF_LDX | BPF_MEM, 15),
2228 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
2229 BPF_STMT(BPF_RET | BPF_A, 0),
2231 CLASSIC | FLAG_NO_DATA,
2233 { { 0, 0x2a5a5e5 } },
2236 "check: SKF_AD_MAX",
2238 BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
2239 SKF_AD_OFF + SKF_AD_MAX),
2240 BPF_STMT(BPF_RET | BPF_A, 0),
2242 CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL,
2245 .fill_helper = NULL,
2246 .expected_errcode = -EINVAL,
2248 { /* Passes checker but fails during runtime. */
2249 "LD [SKF_AD_OFF-1]",
2251 BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
2253 BPF_STMT(BPF_RET | BPF_K, 1),
2260 "load 64-bit immediate",
2262 BPF_LD_IMM64(R1, 0x567800001234LL),
2263 BPF_MOV64_REG(R2, R1),
2264 BPF_MOV64_REG(R3, R2),
2265 BPF_ALU64_IMM(BPF_RSH, R2, 32),
2266 BPF_ALU64_IMM(BPF_LSH, R3, 32),
2267 BPF_ALU64_IMM(BPF_RSH, R3, 32),
2268 BPF_ALU64_IMM(BPF_MOV, R0, 0),
2269 BPF_JMP_IMM(BPF_JEQ, R2, 0x5678, 1),
2271 BPF_JMP_IMM(BPF_JEQ, R3, 0x1234, 1),
2273 BPF_LD_IMM64(R0, 0x1ffffffffLL),
2274 BPF_ALU64_IMM(BPF_RSH, R0, 32), /* R0 = 1 */
2281 /* BPF_ALU | BPF_MOV | BPF_X */
2283 "ALU_MOV_X: dst = 2",
2285 BPF_ALU32_IMM(BPF_MOV, R1, 2),
2286 BPF_ALU32_REG(BPF_MOV, R0, R1),
2294 "ALU_MOV_X: dst = 4294967295",
2296 BPF_ALU32_IMM(BPF_MOV, R1, 4294967295U),
2297 BPF_ALU32_REG(BPF_MOV, R0, R1),
2302 { { 0, 4294967295U } },
2305 "ALU64_MOV_X: dst = 2",
2307 BPF_ALU32_IMM(BPF_MOV, R1, 2),
2308 BPF_ALU64_REG(BPF_MOV, R0, R1),
2316 "ALU64_MOV_X: dst = 4294967295",
2318 BPF_ALU32_IMM(BPF_MOV, R1, 4294967295U),
2319 BPF_ALU64_REG(BPF_MOV, R0, R1),
2324 { { 0, 4294967295U } },
2326 /* BPF_ALU | BPF_MOV | BPF_K */
2328 "ALU_MOV_K: dst = 2",
2330 BPF_ALU32_IMM(BPF_MOV, R0, 2),
2338 "ALU_MOV_K: dst = 4294967295",
2340 BPF_ALU32_IMM(BPF_MOV, R0, 4294967295U),
2345 { { 0, 4294967295U } },
2348 "ALU_MOV_K: 0x0000ffffffff0000 = 0x00000000ffffffff",
2350 BPF_LD_IMM64(R2, 0x0000ffffffff0000LL),
2351 BPF_LD_IMM64(R3, 0x00000000ffffffffLL),
2352 BPF_ALU32_IMM(BPF_MOV, R2, 0xffffffff),
2353 BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
2354 BPF_MOV32_IMM(R0, 2),
2356 BPF_MOV32_IMM(R0, 1),
2364 "ALU64_MOV_K: dst = 2",
2366 BPF_ALU64_IMM(BPF_MOV, R0, 2),
2374 "ALU64_MOV_K: dst = 2147483647",
2376 BPF_ALU64_IMM(BPF_MOV, R0, 2147483647),
2381 { { 0, 2147483647 } },
2384 "ALU64_OR_K: dst = 0x0",
2386 BPF_LD_IMM64(R2, 0x0000ffffffff0000LL),
2387 BPF_LD_IMM64(R3, 0x0),
2388 BPF_ALU64_IMM(BPF_MOV, R2, 0x0),
2389 BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
2390 BPF_MOV32_IMM(R0, 2),
2392 BPF_MOV32_IMM(R0, 1),
2400 "ALU64_MOV_K: dst = -1",
2402 BPF_LD_IMM64(R2, 0x0000ffffffff0000LL),
2403 BPF_LD_IMM64(R3, 0xffffffffffffffffLL),
2404 BPF_ALU64_IMM(BPF_MOV, R2, 0xffffffff),
2405 BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
2406 BPF_MOV32_IMM(R0, 2),
2408 BPF_MOV32_IMM(R0, 1),
2415 /* BPF_ALU | BPF_ADD | BPF_X */
2417 "ALU_ADD_X: 1 + 2 = 3",
2419 BPF_LD_IMM64(R0, 1),
2420 BPF_ALU32_IMM(BPF_MOV, R1, 2),
2421 BPF_ALU32_REG(BPF_ADD, R0, R1),
2429 "ALU_ADD_X: 1 + 4294967294 = 4294967295",
2431 BPF_LD_IMM64(R0, 1),
2432 BPF_ALU32_IMM(BPF_MOV, R1, 4294967294U),
2433 BPF_ALU32_REG(BPF_ADD, R0, R1),
2438 { { 0, 4294967295U } },
2441 "ALU_ADD_X: 2 + 4294967294 = 0",
2443 BPF_LD_IMM64(R0, 2),
2444 BPF_LD_IMM64(R1, 4294967294U),
2445 BPF_ALU32_REG(BPF_ADD, R0, R1),
2446 BPF_JMP_IMM(BPF_JEQ, R0, 0, 2),
2447 BPF_ALU32_IMM(BPF_MOV, R0, 0),
2449 BPF_ALU32_IMM(BPF_MOV, R0, 1),
2457 "ALU64_ADD_X: 1 + 2 = 3",
2459 BPF_LD_IMM64(R0, 1),
2460 BPF_ALU32_IMM(BPF_MOV, R1, 2),
2461 BPF_ALU64_REG(BPF_ADD, R0, R1),
2469 "ALU64_ADD_X: 1 + 4294967294 = 4294967295",
2471 BPF_LD_IMM64(R0, 1),
2472 BPF_ALU32_IMM(BPF_MOV, R1, 4294967294U),
2473 BPF_ALU64_REG(BPF_ADD, R0, R1),
2478 { { 0, 4294967295U } },
2481 "ALU64_ADD_X: 2 + 4294967294 = 4294967296",
2483 BPF_LD_IMM64(R0, 2),
2484 BPF_LD_IMM64(R1, 4294967294U),
2485 BPF_LD_IMM64(R2, 4294967296ULL),
2486 BPF_ALU64_REG(BPF_ADD, R0, R1),
2487 BPF_JMP_REG(BPF_JEQ, R0, R2, 2),
2488 BPF_MOV32_IMM(R0, 0),
2490 BPF_MOV32_IMM(R0, 1),
2497 /* BPF_ALU | BPF_ADD | BPF_K */
2499 "ALU_ADD_K: 1 + 2 = 3",
2501 BPF_LD_IMM64(R0, 1),
2502 BPF_ALU32_IMM(BPF_ADD, R0, 2),
2510 "ALU_ADD_K: 3 + 0 = 3",
2512 BPF_LD_IMM64(R0, 3),
2513 BPF_ALU32_IMM(BPF_ADD, R0, 0),
2521 "ALU_ADD_K: 1 + 4294967294 = 4294967295",
2523 BPF_LD_IMM64(R0, 1),
2524 BPF_ALU32_IMM(BPF_ADD, R0, 4294967294U),
2529 { { 0, 4294967295U } },
2532 "ALU_ADD_K: 4294967294 + 2 = 0",
2534 BPF_LD_IMM64(R0, 4294967294U),
2535 BPF_ALU32_IMM(BPF_ADD, R0, 2),
2536 BPF_JMP_IMM(BPF_JEQ, R0, 0, 2),
2537 BPF_ALU32_IMM(BPF_MOV, R0, 0),
2539 BPF_ALU32_IMM(BPF_MOV, R0, 1),
2547 "ALU_ADD_K: 0 + (-1) = 0x00000000ffffffff",
2549 BPF_LD_IMM64(R2, 0x0),
2550 BPF_LD_IMM64(R3, 0x00000000ffffffff),
2551 BPF_ALU32_IMM(BPF_ADD, R2, 0xffffffff),
2552 BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
2553 BPF_MOV32_IMM(R0, 2),
2555 BPF_MOV32_IMM(R0, 1),
2563 "ALU_ADD_K: 0 + 0xffff = 0xffff",
2565 BPF_LD_IMM64(R2, 0x0),
2566 BPF_LD_IMM64(R3, 0xffff),
2567 BPF_ALU32_IMM(BPF_ADD, R2, 0xffff),
2568 BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
2569 BPF_MOV32_IMM(R0, 2),
2571 BPF_MOV32_IMM(R0, 1),
2579 "ALU_ADD_K: 0 + 0x7fffffff = 0x7fffffff",
2581 BPF_LD_IMM64(R2, 0x0),
2582 BPF_LD_IMM64(R3, 0x7fffffff),
2583 BPF_ALU32_IMM(BPF_ADD, R2, 0x7fffffff),
2584 BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
2585 BPF_MOV32_IMM(R0, 2),
2587 BPF_MOV32_IMM(R0, 1),
2595 "ALU_ADD_K: 0 + 0x80000000 = 0x80000000",
2597 BPF_LD_IMM64(R2, 0x0),
2598 BPF_LD_IMM64(R3, 0x80000000),
2599 BPF_ALU32_IMM(BPF_ADD, R2, 0x80000000),
2600 BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
2601 BPF_MOV32_IMM(R0, 2),
2603 BPF_MOV32_IMM(R0, 1),
2611 "ALU_ADD_K: 0 + 0x80008000 = 0x80008000",
2613 BPF_LD_IMM64(R2, 0x0),
2614 BPF_LD_IMM64(R3, 0x80008000),
2615 BPF_ALU32_IMM(BPF_ADD, R2, 0x80008000),
2616 BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
2617 BPF_MOV32_IMM(R0, 2),
2619 BPF_MOV32_IMM(R0, 1),
2627 "ALU64_ADD_K: 1 + 2 = 3",
2629 BPF_LD_IMM64(R0, 1),
2630 BPF_ALU64_IMM(BPF_ADD, R0, 2),
2638 "ALU64_ADD_K: 3 + 0 = 3",
2640 BPF_LD_IMM64(R0, 3),
2641 BPF_ALU64_IMM(BPF_ADD, R0, 0),
2649 "ALU64_ADD_K: 1 + 2147483646 = 2147483647",
2651 BPF_LD_IMM64(R0, 1),
2652 BPF_ALU64_IMM(BPF_ADD, R0, 2147483646),
2657 { { 0, 2147483647 } },
2660 "ALU64_ADD_K: 4294967294 + 2 = 4294967296",
2662 BPF_LD_IMM64(R0, 4294967294U),
2663 BPF_LD_IMM64(R1, 4294967296ULL),
2664 BPF_ALU64_IMM(BPF_ADD, R0, 2),
2665 BPF_JMP_REG(BPF_JEQ, R0, R1, 2),
2666 BPF_ALU32_IMM(BPF_MOV, R0, 0),
2668 BPF_ALU32_IMM(BPF_MOV, R0, 1),
2676 "ALU64_ADD_K: 2147483646 + -2147483647 = -1",
2678 BPF_LD_IMM64(R0, 2147483646),
2679 BPF_ALU64_IMM(BPF_ADD, R0, -2147483647),
2687 "ALU64_ADD_K: 1 + 0 = 1",
2689 BPF_LD_IMM64(R2, 0x1),
2690 BPF_LD_IMM64(R3, 0x1),
2691 BPF_ALU64_IMM(BPF_ADD, R2, 0x0),
2692 BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
2693 BPF_MOV32_IMM(R0, 2),
2695 BPF_MOV32_IMM(R0, 1),
2703 "ALU64_ADD_K: 0 + (-1) = 0xffffffffffffffff",
2705 BPF_LD_IMM64(R2, 0x0),
2706 BPF_LD_IMM64(R3, 0xffffffffffffffffLL),
2707 BPF_ALU64_IMM(BPF_ADD, R2, 0xffffffff),
2708 BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
2709 BPF_MOV32_IMM(R0, 2),
2711 BPF_MOV32_IMM(R0, 1),
2719 "ALU64_ADD_K: 0 + 0xffff = 0xffff",
2721 BPF_LD_IMM64(R2, 0x0),
2722 BPF_LD_IMM64(R3, 0xffff),
2723 BPF_ALU64_IMM(BPF_ADD, R2, 0xffff),
2724 BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
2725 BPF_MOV32_IMM(R0, 2),
2727 BPF_MOV32_IMM(R0, 1),
2735 "ALU64_ADD_K: 0 + 0x7fffffff = 0x7fffffff",
2737 BPF_LD_IMM64(R2, 0x0),
2738 BPF_LD_IMM64(R3, 0x7fffffff),
2739 BPF_ALU64_IMM(BPF_ADD, R2, 0x7fffffff),
2740 BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
2741 BPF_MOV32_IMM(R0, 2),
2743 BPF_MOV32_IMM(R0, 1),
2751 "ALU64_ADD_K: 0 + 0x80000000 = 0xffffffff80000000",
2753 BPF_LD_IMM64(R2, 0x0),
2754 BPF_LD_IMM64(R3, 0xffffffff80000000LL),
2755 BPF_ALU64_IMM(BPF_ADD, R2, 0x80000000),
2756 BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
2757 BPF_MOV32_IMM(R0, 2),
2759 BPF_MOV32_IMM(R0, 1),
2767 "ALU_ADD_K: 0 + 0x80008000 = 0xffffffff80008000",
2769 BPF_LD_IMM64(R2, 0x0),
2770 BPF_LD_IMM64(R3, 0xffffffff80008000LL),
2771 BPF_ALU64_IMM(BPF_ADD, R2, 0x80008000),
2772 BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
2773 BPF_MOV32_IMM(R0, 2),
2775 BPF_MOV32_IMM(R0, 1),
2782 /* BPF_ALU | BPF_SUB | BPF_X */
2784 "ALU_SUB_X: 3 - 1 = 2",
2786 BPF_LD_IMM64(R0, 3),
2787 BPF_ALU32_IMM(BPF_MOV, R1, 1),
2788 BPF_ALU32_REG(BPF_SUB, R0, R1),
2796 "ALU_SUB_X: 4294967295 - 4294967294 = 1",
2798 BPF_LD_IMM64(R0, 4294967295U),
2799 BPF_ALU32_IMM(BPF_MOV, R1, 4294967294U),
2800 BPF_ALU32_REG(BPF_SUB, R0, R1),
2808 "ALU64_SUB_X: 3 - 1 = 2",
2810 BPF_LD_IMM64(R0, 3),
2811 BPF_ALU32_IMM(BPF_MOV, R1, 1),
2812 BPF_ALU64_REG(BPF_SUB, R0, R1),
2820 "ALU64_SUB_X: 4294967295 - 4294967294 = 1",
2822 BPF_LD_IMM64(R0, 4294967295U),
2823 BPF_ALU32_IMM(BPF_MOV, R1, 4294967294U),
2824 BPF_ALU64_REG(BPF_SUB, R0, R1),
2831 /* BPF_ALU | BPF_SUB | BPF_K */
2833 "ALU_SUB_K: 3 - 1 = 2",
2835 BPF_LD_IMM64(R0, 3),
2836 BPF_ALU32_IMM(BPF_SUB, R0, 1),
2844 "ALU_SUB_K: 3 - 0 = 3",
2846 BPF_LD_IMM64(R0, 3),
2847 BPF_ALU32_IMM(BPF_SUB, R0, 0),
2855 "ALU_SUB_K: 4294967295 - 4294967294 = 1",
2857 BPF_LD_IMM64(R0, 4294967295U),
2858 BPF_ALU32_IMM(BPF_SUB, R0, 4294967294U),
2866 "ALU64_SUB_K: 3 - 1 = 2",
2868 BPF_LD_IMM64(R0, 3),
2869 BPF_ALU64_IMM(BPF_SUB, R0, 1),
2877 "ALU64_SUB_K: 3 - 0 = 3",
2879 BPF_LD_IMM64(R0, 3),
2880 BPF_ALU64_IMM(BPF_SUB, R0, 0),
2888 "ALU64_SUB_K: 4294967294 - 4294967295 = -1",
2890 BPF_LD_IMM64(R0, 4294967294U),
2891 BPF_ALU64_IMM(BPF_SUB, R0, 4294967295U),
2899 "ALU64_ADD_K: 2147483646 - 2147483647 = -1",
2901 BPF_LD_IMM64(R0, 2147483646),
2902 BPF_ALU64_IMM(BPF_SUB, R0, 2147483647),
2909 /* BPF_ALU | BPF_MUL | BPF_X */
2911 "ALU_MUL_X: 2 * 3 = 6",
2913 BPF_LD_IMM64(R0, 2),
2914 BPF_ALU32_IMM(BPF_MOV, R1, 3),
2915 BPF_ALU32_REG(BPF_MUL, R0, R1),
2923 "ALU_MUL_X: 2 * 0x7FFFFFF8 = 0xFFFFFFF0",
2925 BPF_LD_IMM64(R0, 2),
2926 BPF_ALU32_IMM(BPF_MOV, R1, 0x7FFFFFF8),
2927 BPF_ALU32_REG(BPF_MUL, R0, R1),
2932 { { 0, 0xFFFFFFF0 } },
2935 "ALU_MUL_X: -1 * -1 = 1",
2937 BPF_LD_IMM64(R0, -1),
2938 BPF_ALU32_IMM(BPF_MOV, R1, -1),
2939 BPF_ALU32_REG(BPF_MUL, R0, R1),
2947 "ALU64_MUL_X: 2 * 3 = 6",
2949 BPF_LD_IMM64(R0, 2),
2950 BPF_ALU32_IMM(BPF_MOV, R1, 3),
2951 BPF_ALU64_REG(BPF_MUL, R0, R1),
2959 "ALU64_MUL_X: 1 * 2147483647 = 2147483647",
2961 BPF_LD_IMM64(R0, 1),
2962 BPF_ALU32_IMM(BPF_MOV, R1, 2147483647),
2963 BPF_ALU64_REG(BPF_MUL, R0, R1),
2968 { { 0, 2147483647 } },
2970 /* BPF_ALU | BPF_MUL | BPF_K */
2972 "ALU_MUL_K: 2 * 3 = 6",
2974 BPF_LD_IMM64(R0, 2),
2975 BPF_ALU32_IMM(BPF_MUL, R0, 3),
2983 "ALU_MUL_K: 3 * 1 = 3",
2985 BPF_LD_IMM64(R0, 3),
2986 BPF_ALU32_IMM(BPF_MUL, R0, 1),
2994 "ALU_MUL_K: 2 * 0x7FFFFFF8 = 0xFFFFFFF0",
2996 BPF_LD_IMM64(R0, 2),
2997 BPF_ALU32_IMM(BPF_MUL, R0, 0x7FFFFFF8),
3002 { { 0, 0xFFFFFFF0 } },
3005 "ALU_MUL_K: 1 * (-1) = 0x00000000ffffffff",
3007 BPF_LD_IMM64(R2, 0x1),
3008 BPF_LD_IMM64(R3, 0x00000000ffffffff),
3009 BPF_ALU32_IMM(BPF_MUL, R2, 0xffffffff),
3010 BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
3011 BPF_MOV32_IMM(R0, 2),
3013 BPF_MOV32_IMM(R0, 1),
3021 "ALU64_MUL_K: 2 * 3 = 6",
3023 BPF_LD_IMM64(R0, 2),
3024 BPF_ALU64_IMM(BPF_MUL, R0, 3),
3032 "ALU64_MUL_K: 3 * 1 = 3",
3034 BPF_LD_IMM64(R0, 3),
3035 BPF_ALU64_IMM(BPF_MUL, R0, 1),
3043 "ALU64_MUL_K: 1 * 2147483647 = 2147483647",
3045 BPF_LD_IMM64(R0, 1),
3046 BPF_ALU64_IMM(BPF_MUL, R0, 2147483647),
3051 { { 0, 2147483647 } },
3054 "ALU64_MUL_K: 1 * -2147483647 = -2147483647",
3056 BPF_LD_IMM64(R0, 1),
3057 BPF_ALU64_IMM(BPF_MUL, R0, -2147483647),
3062 { { 0, -2147483647 } },
3065 "ALU64_MUL_K: 1 * (-1) = 0xffffffffffffffff",
3067 BPF_LD_IMM64(R2, 0x1),
3068 BPF_LD_IMM64(R3, 0xffffffffffffffffLL),
3069 BPF_ALU64_IMM(BPF_MUL, R2, 0xffffffff),
3070 BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
3071 BPF_MOV32_IMM(R0, 2),
3073 BPF_MOV32_IMM(R0, 1),
3080 /* BPF_ALU | BPF_DIV | BPF_X */
3082 "ALU_DIV_X: 6 / 2 = 3",
3084 BPF_LD_IMM64(R0, 6),
3085 BPF_ALU32_IMM(BPF_MOV, R1, 2),
3086 BPF_ALU32_REG(BPF_DIV, R0, R1),
3094 "ALU_DIV_X: 4294967295 / 4294967295 = 1",
3096 BPF_LD_IMM64(R0, 4294967295U),
3097 BPF_ALU32_IMM(BPF_MOV, R1, 4294967295U),
3098 BPF_ALU32_REG(BPF_DIV, R0, R1),
3106 "ALU64_DIV_X: 6 / 2 = 3",
3108 BPF_LD_IMM64(R0, 6),
3109 BPF_ALU32_IMM(BPF_MOV, R1, 2),
3110 BPF_ALU64_REG(BPF_DIV, R0, R1),
3118 "ALU64_DIV_X: 2147483647 / 2147483647 = 1",
3120 BPF_LD_IMM64(R0, 2147483647),
3121 BPF_ALU32_IMM(BPF_MOV, R1, 2147483647),
3122 BPF_ALU64_REG(BPF_DIV, R0, R1),
3130 "ALU64_DIV_X: 0xffffffffffffffff / (-1) = 0x0000000000000001",
3132 BPF_LD_IMM64(R2, 0xffffffffffffffffLL),
3133 BPF_LD_IMM64(R4, 0xffffffffffffffffLL),
3134 BPF_LD_IMM64(R3, 0x0000000000000001LL),
3135 BPF_ALU64_REG(BPF_DIV, R2, R4),
3136 BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
3137 BPF_MOV32_IMM(R0, 2),
3139 BPF_MOV32_IMM(R0, 1),
3146 /* BPF_ALU | BPF_DIV | BPF_K */
3148 "ALU_DIV_K: 6 / 2 = 3",
3150 BPF_LD_IMM64(R0, 6),
3151 BPF_ALU32_IMM(BPF_DIV, R0, 2),
3159 "ALU_DIV_K: 3 / 1 = 3",
3161 BPF_LD_IMM64(R0, 3),
3162 BPF_ALU32_IMM(BPF_DIV, R0, 1),
3170 "ALU_DIV_K: 4294967295 / 4294967295 = 1",
3172 BPF_LD_IMM64(R0, 4294967295U),
3173 BPF_ALU32_IMM(BPF_DIV, R0, 4294967295U),
3181 "ALU_DIV_K: 0xffffffffffffffff / (-1) = 0x1",
3183 BPF_LD_IMM64(R2, 0xffffffffffffffffLL),
3184 BPF_LD_IMM64(R3, 0x1UL),
3185 BPF_ALU32_IMM(BPF_DIV, R2, 0xffffffff),
3186 BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
3187 BPF_MOV32_IMM(R0, 2),
3189 BPF_MOV32_IMM(R0, 1),
3197 "ALU64_DIV_K: 6 / 2 = 3",
3199 BPF_LD_IMM64(R0, 6),
3200 BPF_ALU64_IMM(BPF_DIV, R0, 2),
3208 "ALU64_DIV_K: 3 / 1 = 3",
3210 BPF_LD_IMM64(R0, 3),
3211 BPF_ALU64_IMM(BPF_DIV, R0, 1),
3219 "ALU64_DIV_K: 2147483647 / 2147483647 = 1",
3221 BPF_LD_IMM64(R0, 2147483647),
3222 BPF_ALU64_IMM(BPF_DIV, R0, 2147483647),
3230 "ALU64_DIV_K: 0xffffffffffffffff / (-1) = 0x0000000000000001",
3232 BPF_LD_IMM64(R2, 0xffffffffffffffffLL),
3233 BPF_LD_IMM64(R3, 0x0000000000000001LL),
3234 BPF_ALU64_IMM(BPF_DIV, R2, 0xffffffff),
3235 BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
3236 BPF_MOV32_IMM(R0, 2),
3238 BPF_MOV32_IMM(R0, 1),
3245 /* BPF_ALU | BPF_MOD | BPF_X */
3247 "ALU_MOD_X: 3 % 2 = 1",
3249 BPF_LD_IMM64(R0, 3),
3250 BPF_ALU32_IMM(BPF_MOV, R1, 2),
3251 BPF_ALU32_REG(BPF_MOD, R0, R1),
3259 "ALU_MOD_X: 4294967295 % 4294967293 = 2",
3261 BPF_LD_IMM64(R0, 4294967295U),
3262 BPF_ALU32_IMM(BPF_MOV, R1, 4294967293U),
3263 BPF_ALU32_REG(BPF_MOD, R0, R1),
3271 "ALU64_MOD_X: 3 % 2 = 1",
3273 BPF_LD_IMM64(R0, 3),
3274 BPF_ALU32_IMM(BPF_MOV, R1, 2),
3275 BPF_ALU64_REG(BPF_MOD, R0, R1),
3283 "ALU64_MOD_X: 2147483647 % 2147483645 = 2",
3285 BPF_LD_IMM64(R0, 2147483647),
3286 BPF_ALU32_IMM(BPF_MOV, R1, 2147483645),
3287 BPF_ALU64_REG(BPF_MOD, R0, R1),
3294 /* BPF_ALU | BPF_MOD | BPF_K */
3296 "ALU_MOD_K: 3 % 2 = 1",
3298 BPF_LD_IMM64(R0, 3),
3299 BPF_ALU32_IMM(BPF_MOD, R0, 2),
3307 "ALU_MOD_K: 3 % 1 = 0",
3309 BPF_LD_IMM64(R0, 3),
3310 BPF_ALU32_IMM(BPF_MOD, R0, 1),
3318 "ALU_MOD_K: 4294967295 % 4294967293 = 2",
3320 BPF_LD_IMM64(R0, 4294967295U),
3321 BPF_ALU32_IMM(BPF_MOD, R0, 4294967293U),
3329 "ALU64_MOD_K: 3 % 2 = 1",
3331 BPF_LD_IMM64(R0, 3),
3332 BPF_ALU64_IMM(BPF_MOD, R0, 2),
3340 "ALU64_MOD_K: 3 % 1 = 0",
3342 BPF_LD_IMM64(R0, 3),
3343 BPF_ALU64_IMM(BPF_MOD, R0, 1),
3351 "ALU64_MOD_K: 2147483647 % 2147483645 = 2",
3353 BPF_LD_IMM64(R0, 2147483647),
3354 BPF_ALU64_IMM(BPF_MOD, R0, 2147483645),
3361 /* BPF_ALU | BPF_AND | BPF_X */
3363 "ALU_AND_X: 3 & 2 = 2",
3365 BPF_LD_IMM64(R0, 3),
3366 BPF_ALU32_IMM(BPF_MOV, R1, 2),
3367 BPF_ALU32_REG(BPF_AND, R0, R1),
3375 "ALU_AND_X: 0xffffffff & 0xffffffff = 0xffffffff",
3377 BPF_LD_IMM64(R0, 0xffffffff),
3378 BPF_ALU32_IMM(BPF_MOV, R1, 0xffffffff),
3379 BPF_ALU32_REG(BPF_AND, R0, R1),
3384 { { 0, 0xffffffff } },
3387 "ALU64_AND_X: 3 & 2 = 2",
3389 BPF_LD_IMM64(R0, 3),
3390 BPF_ALU32_IMM(BPF_MOV, R1, 2),
3391 BPF_ALU64_REG(BPF_AND, R0, R1),
3399 "ALU64_AND_X: 0xffffffff & 0xffffffff = 0xffffffff",
3401 BPF_LD_IMM64(R0, 0xffffffff),
3402 BPF_ALU32_IMM(BPF_MOV, R1, 0xffffffff),
3403 BPF_ALU64_REG(BPF_AND, R0, R1),
3408 { { 0, 0xffffffff } },
3410 /* BPF_ALU | BPF_AND | BPF_K */
3412 "ALU_AND_K: 3 & 2 = 2",
3414 BPF_LD_IMM64(R0, 3),
3415 BPF_ALU32_IMM(BPF_AND, R0, 2),
3423 "ALU_AND_K: 0xffffffff & 0xffffffff = 0xffffffff",
3425 BPF_LD_IMM64(R0, 0xffffffff),
3426 BPF_ALU32_IMM(BPF_AND, R0, 0xffffffff),
3431 { { 0, 0xffffffff } },
3434 "ALU64_AND_K: 3 & 2 = 2",
3436 BPF_LD_IMM64(R0, 3),
3437 BPF_ALU64_IMM(BPF_AND, R0, 2),
3445 "ALU64_AND_K: 0xffffffff & 0xffffffff = 0xffffffff",
3447 BPF_LD_IMM64(R0, 0xffffffff),
3448 BPF_ALU64_IMM(BPF_AND, R0, 0xffffffff),
3453 { { 0, 0xffffffff } },
3456 "ALU64_AND_K: 0x0000ffffffff0000 & 0x0 = 0x0000ffff00000000",
3458 BPF_LD_IMM64(R2, 0x0000ffffffff0000LL),
3459 BPF_LD_IMM64(R3, 0x0000000000000000LL),
3460 BPF_ALU64_IMM(BPF_AND, R2, 0x0),
3461 BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
3462 BPF_MOV32_IMM(R0, 2),
3464 BPF_MOV32_IMM(R0, 1),
3472 "ALU64_AND_K: 0x0000ffffffff0000 & -1 = 0x0000ffffffffffff",
3474 BPF_LD_IMM64(R2, 0x0000ffffffff0000LL),
3475 BPF_LD_IMM64(R3, 0x0000ffffffff0000LL),
3476 BPF_ALU64_IMM(BPF_AND, R2, 0xffffffff),
3477 BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
3478 BPF_MOV32_IMM(R0, 2),
3480 BPF_MOV32_IMM(R0, 1),
3488 "ALU64_AND_K: 0xffffffffffffffff & -1 = 0xffffffffffffffff",
3490 BPF_LD_IMM64(R2, 0xffffffffffffffffLL),
3491 BPF_LD_IMM64(R3, 0xffffffffffffffffLL),
3492 BPF_ALU64_IMM(BPF_AND, R2, 0xffffffff),
3493 BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
3494 BPF_MOV32_IMM(R0, 2),
3496 BPF_MOV32_IMM(R0, 1),
3503 /* BPF_ALU | BPF_OR | BPF_X */
3505 "ALU_OR_X: 1 | 2 = 3",
3507 BPF_LD_IMM64(R0, 1),
3508 BPF_ALU32_IMM(BPF_MOV, R1, 2),
3509 BPF_ALU32_REG(BPF_OR, R0, R1),
3517 "ALU_OR_X: 0x0 | 0xffffffff = 0xffffffff",
3519 BPF_LD_IMM64(R0, 0),
3520 BPF_ALU32_IMM(BPF_MOV, R1, 0xffffffff),
3521 BPF_ALU32_REG(BPF_OR, R0, R1),
3526 { { 0, 0xffffffff } },
3529 "ALU64_OR_X: 1 | 2 = 3",
3531 BPF_LD_IMM64(R0, 1),
3532 BPF_ALU32_IMM(BPF_MOV, R1, 2),
3533 BPF_ALU64_REG(BPF_OR, R0, R1),
3541 "ALU64_OR_X: 0 | 0xffffffff = 0xffffffff",
3543 BPF_LD_IMM64(R0, 0),
3544 BPF_ALU32_IMM(BPF_MOV, R1, 0xffffffff),
3545 BPF_ALU64_REG(BPF_OR, R0, R1),
3550 { { 0, 0xffffffff } },
3552 /* BPF_ALU | BPF_OR | BPF_K */
3554 "ALU_OR_K: 1 | 2 = 3",
3556 BPF_LD_IMM64(R0, 1),
3557 BPF_ALU32_IMM(BPF_OR, R0, 2),
3565 "ALU_OR_K: 0 & 0xffffffff = 0xffffffff",
3567 BPF_LD_IMM64(R0, 0),
3568 BPF_ALU32_IMM(BPF_OR, R0, 0xffffffff),
3573 { { 0, 0xffffffff } },
3576 "ALU64_OR_K: 1 | 2 = 3",
3578 BPF_LD_IMM64(R0, 1),
3579 BPF_ALU64_IMM(BPF_OR, R0, 2),
3587 "ALU64_OR_K: 0 & 0xffffffff = 0xffffffff",
3589 BPF_LD_IMM64(R0, 0),
3590 BPF_ALU64_IMM(BPF_OR, R0, 0xffffffff),
3595 { { 0, 0xffffffff } },
3598 "ALU64_OR_K: 0x0000ffffffff0000 | 0x0 = 0x0000ffff00000000",
3600 BPF_LD_IMM64(R2, 0x0000ffffffff0000LL),
3601 BPF_LD_IMM64(R3, 0x0000ffffffff0000LL),
3602 BPF_ALU64_IMM(BPF_OR, R2, 0x0),
3603 BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
3604 BPF_MOV32_IMM(R0, 2),
3606 BPF_MOV32_IMM(R0, 1),
3614 "ALU64_OR_K: 0x0000ffffffff0000 | -1 = 0xffffffffffffffff",
3616 BPF_LD_IMM64(R2, 0x0000ffffffff0000LL),
3617 BPF_LD_IMM64(R3, 0xffffffffffffffffLL),
3618 BPF_ALU64_IMM(BPF_OR, R2, 0xffffffff),
3619 BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
3620 BPF_MOV32_IMM(R0, 2),
3622 BPF_MOV32_IMM(R0, 1),
3630 "ALU64_OR_K: 0x000000000000000 | -1 = 0xffffffffffffffff",
3632 BPF_LD_IMM64(R2, 0x0000000000000000LL),
3633 BPF_LD_IMM64(R3, 0xffffffffffffffffLL),
3634 BPF_ALU64_IMM(BPF_OR, R2, 0xffffffff),
3635 BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
3636 BPF_MOV32_IMM(R0, 2),
3638 BPF_MOV32_IMM(R0, 1),
3645 /* BPF_ALU | BPF_XOR | BPF_X */
3647 "ALU_XOR_X: 5 ^ 6 = 3",
3649 BPF_LD_IMM64(R0, 5),
3650 BPF_ALU32_IMM(BPF_MOV, R1, 6),
3651 BPF_ALU32_REG(BPF_XOR, R0, R1),
3659 "ALU_XOR_X: 0x1 ^ 0xffffffff = 0xfffffffe",
3661 BPF_LD_IMM64(R0, 1),
3662 BPF_ALU32_IMM(BPF_MOV, R1, 0xffffffff),
3663 BPF_ALU32_REG(BPF_XOR, R0, R1),
3668 { { 0, 0xfffffffe } },
3671 "ALU64_XOR_X: 5 ^ 6 = 3",
3673 BPF_LD_IMM64(R0, 5),
3674 BPF_ALU32_IMM(BPF_MOV, R1, 6),
3675 BPF_ALU64_REG(BPF_XOR, R0, R1),
3683 "ALU64_XOR_X: 1 ^ 0xffffffff = 0xfffffffe",
3685 BPF_LD_IMM64(R0, 1),
3686 BPF_ALU32_IMM(BPF_MOV, R1, 0xffffffff),
3687 BPF_ALU64_REG(BPF_XOR, R0, R1),
3692 { { 0, 0xfffffffe } },
3694 /* BPF_ALU | BPF_XOR | BPF_K */
3696 "ALU_XOR_K: 5 ^ 6 = 3",
3698 BPF_LD_IMM64(R0, 5),
3699 BPF_ALU32_IMM(BPF_XOR, R0, 6),
3707 "ALU_XOR_K: 1 ^ 0xffffffff = 0xfffffffe",
3709 BPF_LD_IMM64(R0, 1),
3710 BPF_ALU32_IMM(BPF_XOR, R0, 0xffffffff),
3715 { { 0, 0xfffffffe } },
3718 "ALU64_XOR_K: 5 ^ 6 = 3",
3720 BPF_LD_IMM64(R0, 5),
3721 BPF_ALU64_IMM(BPF_XOR, R0, 6),
3729 "ALU64_XOR_K: 1 & 0xffffffff = 0xfffffffe",
3731 BPF_LD_IMM64(R0, 1),
3732 BPF_ALU64_IMM(BPF_XOR, R0, 0xffffffff),
3737 { { 0, 0xfffffffe } },
3740 "ALU64_XOR_K: 0x0000ffffffff0000 ^ 0x0 = 0x0000ffffffff0000",
3742 BPF_LD_IMM64(R2, 0x0000ffffffff0000LL),
3743 BPF_LD_IMM64(R3, 0x0000ffffffff0000LL),
3744 BPF_ALU64_IMM(BPF_XOR, R2, 0x0),
3745 BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
3746 BPF_MOV32_IMM(R0, 2),
3748 BPF_MOV32_IMM(R0, 1),
3756 "ALU64_XOR_K: 0x0000ffffffff0000 ^ -1 = 0xffff00000000ffff",
3758 BPF_LD_IMM64(R2, 0x0000ffffffff0000LL),
3759 BPF_LD_IMM64(R3, 0xffff00000000ffffLL),
3760 BPF_ALU64_IMM(BPF_XOR, R2, 0xffffffff),
3761 BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
3762 BPF_MOV32_IMM(R0, 2),
3764 BPF_MOV32_IMM(R0, 1),
3772 "ALU64_XOR_K: 0x000000000000000 ^ -1 = 0xffffffffffffffff",
3774 BPF_LD_IMM64(R2, 0x0000000000000000LL),
3775 BPF_LD_IMM64(R3, 0xffffffffffffffffLL),
3776 BPF_ALU64_IMM(BPF_XOR, R2, 0xffffffff),
3777 BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
3778 BPF_MOV32_IMM(R0, 2),
3780 BPF_MOV32_IMM(R0, 1),
3787 /* BPF_ALU | BPF_LSH | BPF_X */
3789 "ALU_LSH_X: 1 << 1 = 2",
3791 BPF_LD_IMM64(R0, 1),
3792 BPF_ALU32_IMM(BPF_MOV, R1, 1),
3793 BPF_ALU32_REG(BPF_LSH, R0, R1),
3801 "ALU_LSH_X: 1 << 31 = 0x80000000",
3803 BPF_LD_IMM64(R0, 1),
3804 BPF_ALU32_IMM(BPF_MOV, R1, 31),
3805 BPF_ALU32_REG(BPF_LSH, R0, R1),
3810 { { 0, 0x80000000 } },
3813 "ALU64_LSH_X: 1 << 1 = 2",
3815 BPF_LD_IMM64(R0, 1),
3816 BPF_ALU32_IMM(BPF_MOV, R1, 1),
3817 BPF_ALU64_REG(BPF_LSH, R0, R1),
3825 "ALU64_LSH_X: 1 << 31 = 0x80000000",
3827 BPF_LD_IMM64(R0, 1),
3828 BPF_ALU32_IMM(BPF_MOV, R1, 31),
3829 BPF_ALU64_REG(BPF_LSH, R0, R1),
3834 { { 0, 0x80000000 } },
3836 /* BPF_ALU | BPF_LSH | BPF_K */
3838 "ALU_LSH_K: 1 << 1 = 2",
3840 BPF_LD_IMM64(R0, 1),
3841 BPF_ALU32_IMM(BPF_LSH, R0, 1),
3849 "ALU_LSH_K: 1 << 31 = 0x80000000",
3851 BPF_LD_IMM64(R0, 1),
3852 BPF_ALU32_IMM(BPF_LSH, R0, 31),
3857 { { 0, 0x80000000 } },
3860 "ALU64_LSH_K: 1 << 1 = 2",
3862 BPF_LD_IMM64(R0, 1),
3863 BPF_ALU64_IMM(BPF_LSH, R0, 1),
3871 "ALU64_LSH_K: 1 << 31 = 0x80000000",
3873 BPF_LD_IMM64(R0, 1),
3874 BPF_ALU64_IMM(BPF_LSH, R0, 31),
3879 { { 0, 0x80000000 } },
3881 /* BPF_ALU | BPF_RSH | BPF_X */
3883 "ALU_RSH_X: 2 >> 1 = 1",
3885 BPF_LD_IMM64(R0, 2),
3886 BPF_ALU32_IMM(BPF_MOV, R1, 1),
3887 BPF_ALU32_REG(BPF_RSH, R0, R1),
3895 "ALU_RSH_X: 0x80000000 >> 31 = 1",
3897 BPF_LD_IMM64(R0, 0x80000000),
3898 BPF_ALU32_IMM(BPF_MOV, R1, 31),
3899 BPF_ALU32_REG(BPF_RSH, R0, R1),
3907 "ALU64_RSH_X: 2 >> 1 = 1",
3909 BPF_LD_IMM64(R0, 2),
3910 BPF_ALU32_IMM(BPF_MOV, R1, 1),
3911 BPF_ALU64_REG(BPF_RSH, R0, R1),
3919 "ALU64_RSH_X: 0x80000000 >> 31 = 1",
3921 BPF_LD_IMM64(R0, 0x80000000),
3922 BPF_ALU32_IMM(BPF_MOV, R1, 31),
3923 BPF_ALU64_REG(BPF_RSH, R0, R1),
3930 /* BPF_ALU | BPF_RSH | BPF_K */
3932 "ALU_RSH_K: 2 >> 1 = 1",
3934 BPF_LD_IMM64(R0, 2),
3935 BPF_ALU32_IMM(BPF_RSH, R0, 1),
3943 "ALU_RSH_K: 0x80000000 >> 31 = 1",
3945 BPF_LD_IMM64(R0, 0x80000000),
3946 BPF_ALU32_IMM(BPF_RSH, R0, 31),
3954 "ALU64_RSH_K: 2 >> 1 = 1",
3956 BPF_LD_IMM64(R0, 2),
3957 BPF_ALU64_IMM(BPF_RSH, R0, 1),
3965 "ALU64_RSH_K: 0x80000000 >> 31 = 1",
3967 BPF_LD_IMM64(R0, 0x80000000),
3968 BPF_ALU64_IMM(BPF_RSH, R0, 31),
3975 /* BPF_ALU | BPF_ARSH | BPF_X */
3977 "ALU_ARSH_X: 0xff00ff0000000000 >> 40 = 0xffffffffffff00ff",
3979 BPF_LD_IMM64(R0, 0xff00ff0000000000LL),
3980 BPF_ALU32_IMM(BPF_MOV, R1, 40),
3981 BPF_ALU64_REG(BPF_ARSH, R0, R1),
3986 { { 0, 0xffff00ff } },
3988 /* BPF_ALU | BPF_ARSH | BPF_K */
3990 "ALU_ARSH_K: 0xff00ff0000000000 >> 40 = 0xffffffffffff00ff",
3992 BPF_LD_IMM64(R0, 0xff00ff0000000000LL),
3993 BPF_ALU64_IMM(BPF_ARSH, R0, 40),
3998 { { 0, 0xffff00ff } },
4000 /* BPF_ALU | BPF_NEG */
4002 "ALU_NEG: -(3) = -3",
4004 BPF_ALU32_IMM(BPF_MOV, R0, 3),
4005 BPF_ALU32_IMM(BPF_NEG, R0, 0),
4013 "ALU_NEG: -(-3) = 3",
4015 BPF_ALU32_IMM(BPF_MOV, R0, -3),
4016 BPF_ALU32_IMM(BPF_NEG, R0, 0),
4024 "ALU64_NEG: -(3) = -3",
4026 BPF_LD_IMM64(R0, 3),
4027 BPF_ALU64_IMM(BPF_NEG, R0, 0),
4035 "ALU64_NEG: -(-3) = 3",
4037 BPF_LD_IMM64(R0, -3),
4038 BPF_ALU64_IMM(BPF_NEG, R0, 0),
4045 /* BPF_ALU | BPF_END | BPF_FROM_BE */
4047 "ALU_END_FROM_BE 16: 0x0123456789abcdef -> 0xcdef",
4049 BPF_LD_IMM64(R0, 0x0123456789abcdefLL),
4050 BPF_ENDIAN(BPF_FROM_BE, R0, 16),
4055 { { 0, cpu_to_be16(0xcdef) } },
4058 "ALU_END_FROM_BE 32: 0x0123456789abcdef -> 0x89abcdef",
4060 BPF_LD_IMM64(R0, 0x0123456789abcdefLL),
4061 BPF_ENDIAN(BPF_FROM_BE, R0, 32),
4062 BPF_ALU64_REG(BPF_MOV, R1, R0),
4063 BPF_ALU64_IMM(BPF_RSH, R1, 32),
4064 BPF_ALU32_REG(BPF_ADD, R0, R1), /* R1 = 0 */
4069 { { 0, cpu_to_be32(0x89abcdef) } },
4072 "ALU_END_FROM_BE 64: 0x0123456789abcdef -> 0x89abcdef",
4074 BPF_LD_IMM64(R0, 0x0123456789abcdefLL),
4075 BPF_ENDIAN(BPF_FROM_BE, R0, 64),
4080 { { 0, (u32) cpu_to_be64(0x0123456789abcdefLL) } },
4082 /* BPF_ALU | BPF_END | BPF_FROM_LE */
4084 "ALU_END_FROM_LE 16: 0x0123456789abcdef -> 0xefcd",
4086 BPF_LD_IMM64(R0, 0x0123456789abcdefLL),
4087 BPF_ENDIAN(BPF_FROM_LE, R0, 16),
4092 { { 0, cpu_to_le16(0xcdef) } },
4095 "ALU_END_FROM_LE 32: 0x0123456789abcdef -> 0xefcdab89",
4097 BPF_LD_IMM64(R0, 0x0123456789abcdefLL),
4098 BPF_ENDIAN(BPF_FROM_LE, R0, 32),
4099 BPF_ALU64_REG(BPF_MOV, R1, R0),
4100 BPF_ALU64_IMM(BPF_RSH, R1, 32),
4101 BPF_ALU32_REG(BPF_ADD, R0, R1), /* R1 = 0 */
4106 { { 0, cpu_to_le32(0x89abcdef) } },
4109 "ALU_END_FROM_LE 64: 0x0123456789abcdef -> 0x67452301",
4111 BPF_LD_IMM64(R0, 0x0123456789abcdefLL),
4112 BPF_ENDIAN(BPF_FROM_LE, R0, 64),
4117 { { 0, (u32) cpu_to_le64(0x0123456789abcdefLL) } },
4119 /* BPF_ST(X) | BPF_MEM | BPF_B/H/W/DW */
4121 "ST_MEM_B: Store/Load byte: max negative",
4123 BPF_ALU32_IMM(BPF_MOV, R0, 1),
4124 BPF_ST_MEM(BPF_B, R10, -40, 0xff),
4125 BPF_LDX_MEM(BPF_B, R0, R10, -40),
4134 "ST_MEM_B: Store/Load byte: max positive",
4136 BPF_ALU32_IMM(BPF_MOV, R0, 1),
4137 BPF_ST_MEM(BPF_H, R10, -40, 0x7f),
4138 BPF_LDX_MEM(BPF_H, R0, R10, -40),
4147 "STX_MEM_B: Store/Load byte: max negative",
4149 BPF_LD_IMM64(R0, 0),
4150 BPF_LD_IMM64(R1, 0xffLL),
4151 BPF_STX_MEM(BPF_B, R10, R1, -40),
4152 BPF_LDX_MEM(BPF_B, R0, R10, -40),
4161 "ST_MEM_H: Store/Load half word: max negative",
4163 BPF_ALU32_IMM(BPF_MOV, R0, 1),
4164 BPF_ST_MEM(BPF_H, R10, -40, 0xffff),
4165 BPF_LDX_MEM(BPF_H, R0, R10, -40),
4174 "ST_MEM_H: Store/Load half word: max positive",
4176 BPF_ALU32_IMM(BPF_MOV, R0, 1),
4177 BPF_ST_MEM(BPF_H, R10, -40, 0x7fff),
4178 BPF_LDX_MEM(BPF_H, R0, R10, -40),
4187 "STX_MEM_H: Store/Load half word: max negative",
4189 BPF_LD_IMM64(R0, 0),
4190 BPF_LD_IMM64(R1, 0xffffLL),
4191 BPF_STX_MEM(BPF_H, R10, R1, -40),
4192 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 } },
4214 "ST_MEM_W: Store/Load word: max positive",
4216 BPF_ALU32_IMM(BPF_MOV, R0, 1),
4217 BPF_ST_MEM(BPF_W, R10, -40, 0x7fffffff),
4218 BPF_LDX_MEM(BPF_W, R0, R10, -40),
4223 { { 0, 0x7fffffff } },
4227 "STX_MEM_W: Store/Load word: max negative",
4229 BPF_LD_IMM64(R0, 0),
4230 BPF_LD_IMM64(R1, 0xffffffffLL),
4231 BPF_STX_MEM(BPF_W, R10, R1, -40),
4232 BPF_LDX_MEM(BPF_W, R0, R10, -40),
4237 { { 0, 0xffffffff } },
4241 "ST_MEM_DW: Store/Load double word: max negative",
4243 BPF_ALU32_IMM(BPF_MOV, R0, 1),
4244 BPF_ST_MEM(BPF_DW, R10, -40, 0xffffffff),
4245 BPF_LDX_MEM(BPF_DW, R0, R10, -40),
4250 { { 0, 0xffffffff } },
4254 "ST_MEM_DW: Store/Load double word: max negative 2",
4256 BPF_LD_IMM64(R2, 0xffff00000000ffffLL),
4257 BPF_LD_IMM64(R3, 0xffffffffffffffffLL),
4258 BPF_ST_MEM(BPF_DW, R10, -40, 0xffffffff),
4259 BPF_LDX_MEM(BPF_DW, R2, R10, -40),
4260 BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
4261 BPF_MOV32_IMM(R0, 2),
4263 BPF_MOV32_IMM(R0, 1),
4272 "ST_MEM_DW: Store/Load double word: max positive",
4274 BPF_ALU32_IMM(BPF_MOV, R0, 1),
4275 BPF_ST_MEM(BPF_DW, R10, -40, 0x7fffffff),
4276 BPF_LDX_MEM(BPF_DW, R0, R10, -40),
4281 { { 0, 0x7fffffff } },
4285 "STX_MEM_DW: Store/Load double word: max negative",
4287 BPF_LD_IMM64(R0, 0),
4288 BPF_LD_IMM64(R1, 0xffffffffffffffffLL),
4289 BPF_STX_MEM(BPF_W, R10, R1, -40),
4290 BPF_LDX_MEM(BPF_W, R0, R10, -40),
4295 { { 0, 0xffffffff } },
4298 /* BPF_STX | BPF_XADD | BPF_W/DW */
4300 "STX_XADD_W: Test: 0x12 + 0x10 = 0x22",
4302 BPF_ALU32_IMM(BPF_MOV, R0, 0x12),
4303 BPF_ST_MEM(BPF_W, R10, -40, 0x10),
4304 BPF_STX_XADD(BPF_W, R10, R0, -40),
4305 BPF_LDX_MEM(BPF_W, R0, R10, -40),
4314 "STX_XADD_W: Test side-effects, r10: 0x12 + 0x10 = 0x22",
4316 BPF_ALU64_REG(BPF_MOV, R1, R10),
4317 BPF_ALU32_IMM(BPF_MOV, R0, 0x12),
4318 BPF_ST_MEM(BPF_W, R10, -40, 0x10),
4319 BPF_STX_XADD(BPF_W, R10, R0, -40),
4320 BPF_ALU64_REG(BPF_MOV, R0, R10),
4321 BPF_ALU64_REG(BPF_SUB, R0, R1),
4330 "STX_XADD_W: Test side-effects, r0: 0x12 + 0x10 = 0x22",
4332 BPF_ALU32_IMM(BPF_MOV, R0, 0x12),
4333 BPF_ST_MEM(BPF_W, R10, -40, 0x10),
4334 BPF_STX_XADD(BPF_W, R10, R0, -40),
4343 "STX_XADD_W: X + 1 + 1 + 1 + ...",
4348 .fill_helper = bpf_fill_stxw,
4351 "STX_XADD_DW: Test: 0x12 + 0x10 = 0x22",
4353 BPF_ALU32_IMM(BPF_MOV, R0, 0x12),
4354 BPF_ST_MEM(BPF_DW, R10, -40, 0x10),
4355 BPF_STX_XADD(BPF_DW, R10, R0, -40),
4356 BPF_LDX_MEM(BPF_DW, R0, R10, -40),
4365 "STX_XADD_DW: Test side-effects, r10: 0x12 + 0x10 = 0x22",
4367 BPF_ALU64_REG(BPF_MOV, R1, R10),
4368 BPF_ALU32_IMM(BPF_MOV, R0, 0x12),
4369 BPF_ST_MEM(BPF_DW, R10, -40, 0x10),
4370 BPF_STX_XADD(BPF_DW, R10, R0, -40),
4371 BPF_ALU64_REG(BPF_MOV, R0, R10),
4372 BPF_ALU64_REG(BPF_SUB, R0, R1),
4381 "STX_XADD_DW: Test side-effects, r0: 0x12 + 0x10 = 0x22",
4383 BPF_ALU32_IMM(BPF_MOV, R0, 0x12),
4384 BPF_ST_MEM(BPF_DW, R10, -40, 0x10),
4385 BPF_STX_XADD(BPF_DW, R10, R0, -40),
4394 "STX_XADD_DW: X + 1 + 1 + 1 + ...",
4399 .fill_helper = bpf_fill_stxdw,
4401 /* BPF_JMP | BPF_EXIT */
4405 BPF_ALU32_IMM(BPF_MOV, R0, 0x4711),
4407 BPF_ALU32_IMM(BPF_MOV, R0, 0x4712),
4413 /* BPF_JMP | BPF_JA */
4415 "JMP_JA: Unconditional jump: if (true) return 1",
4417 BPF_ALU32_IMM(BPF_MOV, R0, 0),
4418 BPF_JMP_IMM(BPF_JA, 0, 0, 1),
4420 BPF_ALU32_IMM(BPF_MOV, R0, 1),
4427 /* BPF_JMP | BPF_JSLT | BPF_K */
4429 "JMP_JSLT_K: Signed jump: if (-2 < -1) return 1",
4431 BPF_ALU32_IMM(BPF_MOV, R0, 0),
4432 BPF_LD_IMM64(R1, 0xfffffffffffffffeLL),
4433 BPF_JMP_IMM(BPF_JSLT, R1, -1, 1),
4435 BPF_ALU32_IMM(BPF_MOV, R0, 1),
4443 "JMP_JSLT_K: Signed jump: if (-1 < -1) return 0",
4445 BPF_ALU32_IMM(BPF_MOV, R0, 1),
4446 BPF_LD_IMM64(R1, 0xffffffffffffffffLL),
4447 BPF_JMP_IMM(BPF_JSLT, R1, -1, 1),
4449 BPF_ALU32_IMM(BPF_MOV, R0, 0),
4456 /* BPF_JMP | BPF_JSGT | BPF_K */
4458 "JMP_JSGT_K: Signed jump: if (-1 > -2) return 1",
4460 BPF_ALU32_IMM(BPF_MOV, R0, 0),
4461 BPF_LD_IMM64(R1, 0xffffffffffffffffLL),
4462 BPF_JMP_IMM(BPF_JSGT, R1, -2, 1),
4464 BPF_ALU32_IMM(BPF_MOV, R0, 1),
4472 "JMP_JSGT_K: Signed jump: if (-1 > -1) return 0",
4474 BPF_ALU32_IMM(BPF_MOV, R0, 1),
4475 BPF_LD_IMM64(R1, 0xffffffffffffffffLL),
4476 BPF_JMP_IMM(BPF_JSGT, R1, -1, 1),
4478 BPF_ALU32_IMM(BPF_MOV, R0, 0),
4485 /* BPF_JMP | BPF_JSLE | BPF_K */
4487 "JMP_JSLE_K: Signed jump: if (-2 <= -1) return 1",
4489 BPF_ALU32_IMM(BPF_MOV, R0, 0),
4490 BPF_LD_IMM64(R1, 0xfffffffffffffffeLL),
4491 BPF_JMP_IMM(BPF_JSLE, R1, -1, 1),
4493 BPF_ALU32_IMM(BPF_MOV, R0, 1),
4501 "JMP_JSLE_K: Signed jump: if (-1 <= -1) return 1",
4503 BPF_ALU32_IMM(BPF_MOV, R0, 0),
4504 BPF_LD_IMM64(R1, 0xffffffffffffffffLL),
4505 BPF_JMP_IMM(BPF_JSLE, R1, -1, 1),
4507 BPF_ALU32_IMM(BPF_MOV, R0, 1),
4515 "JMP_JSLE_K: Signed jump: value walk 1",
4517 BPF_ALU32_IMM(BPF_MOV, R0, 0),
4518 BPF_LD_IMM64(R1, 3),
4519 BPF_JMP_IMM(BPF_JSLE, R1, 0, 6),
4520 BPF_ALU64_IMM(BPF_SUB, R1, 1),
4521 BPF_JMP_IMM(BPF_JSLE, R1, 0, 4),
4522 BPF_ALU64_IMM(BPF_SUB, R1, 1),
4523 BPF_JMP_IMM(BPF_JSLE, R1, 0, 2),
4524 BPF_ALU64_IMM(BPF_SUB, R1, 1),
4525 BPF_JMP_IMM(BPF_JSLE, R1, 0, 1),
4526 BPF_EXIT_INSN(), /* bad exit */
4527 BPF_ALU32_IMM(BPF_MOV, R0, 1), /* good exit */
4535 "JMP_JSLE_K: Signed jump: value walk 2",
4537 BPF_ALU32_IMM(BPF_MOV, R0, 0),
4538 BPF_LD_IMM64(R1, 3),
4539 BPF_JMP_IMM(BPF_JSLE, R1, 0, 4),
4540 BPF_ALU64_IMM(BPF_SUB, R1, 2),
4541 BPF_JMP_IMM(BPF_JSLE, R1, 0, 2),
4542 BPF_ALU64_IMM(BPF_SUB, R1, 2),
4543 BPF_JMP_IMM(BPF_JSLE, R1, 0, 1),
4544 BPF_EXIT_INSN(), /* bad exit */
4545 BPF_ALU32_IMM(BPF_MOV, R0, 1), /* good exit */
4552 /* BPF_JMP | BPF_JSGE | BPF_K */
4554 "JMP_JSGE_K: Signed jump: if (-1 >= -2) return 1",
4556 BPF_ALU32_IMM(BPF_MOV, R0, 0),
4557 BPF_LD_IMM64(R1, 0xffffffffffffffffLL),
4558 BPF_JMP_IMM(BPF_JSGE, R1, -2, 1),
4560 BPF_ALU32_IMM(BPF_MOV, R0, 1),
4568 "JMP_JSGE_K: Signed jump: if (-1 >= -1) return 1",
4570 BPF_ALU32_IMM(BPF_MOV, R0, 0),
4571 BPF_LD_IMM64(R1, 0xffffffffffffffffLL),
4572 BPF_JMP_IMM(BPF_JSGE, R1, -1, 1),
4574 BPF_ALU32_IMM(BPF_MOV, R0, 1),
4582 "JMP_JSGE_K: Signed jump: value walk 1",
4584 BPF_ALU32_IMM(BPF_MOV, R0, 0),
4585 BPF_LD_IMM64(R1, -3),
4586 BPF_JMP_IMM(BPF_JSGE, R1, 0, 6),
4587 BPF_ALU64_IMM(BPF_ADD, R1, 1),
4588 BPF_JMP_IMM(BPF_JSGE, R1, 0, 4),
4589 BPF_ALU64_IMM(BPF_ADD, R1, 1),
4590 BPF_JMP_IMM(BPF_JSGE, R1, 0, 2),
4591 BPF_ALU64_IMM(BPF_ADD, R1, 1),
4592 BPF_JMP_IMM(BPF_JSGE, R1, 0, 1),
4593 BPF_EXIT_INSN(), /* bad exit */
4594 BPF_ALU32_IMM(BPF_MOV, R0, 1), /* good exit */
4602 "JMP_JSGE_K: Signed jump: value walk 2",
4604 BPF_ALU32_IMM(BPF_MOV, R0, 0),
4605 BPF_LD_IMM64(R1, -3),
4606 BPF_JMP_IMM(BPF_JSGE, R1, 0, 4),
4607 BPF_ALU64_IMM(BPF_ADD, R1, 2),
4608 BPF_JMP_IMM(BPF_JSGE, R1, 0, 2),
4609 BPF_ALU64_IMM(BPF_ADD, R1, 2),
4610 BPF_JMP_IMM(BPF_JSGE, R1, 0, 1),
4611 BPF_EXIT_INSN(), /* bad exit */
4612 BPF_ALU32_IMM(BPF_MOV, R0, 1), /* good exit */
4619 /* BPF_JMP | BPF_JGT | BPF_K */
4621 "JMP_JGT_K: if (3 > 2) return 1",
4623 BPF_ALU32_IMM(BPF_MOV, R0, 0),
4624 BPF_LD_IMM64(R1, 3),
4625 BPF_JMP_IMM(BPF_JGT, R1, 2, 1),
4627 BPF_ALU32_IMM(BPF_MOV, R0, 1),
4635 "JMP_JGT_K: Unsigned jump: if (-1 > 1) return 1",
4637 BPF_ALU32_IMM(BPF_MOV, R0, 0),
4638 BPF_LD_IMM64(R1, -1),
4639 BPF_JMP_IMM(BPF_JGT, R1, 1, 1),
4641 BPF_ALU32_IMM(BPF_MOV, R0, 1),
4648 /* BPF_JMP | BPF_JLT | BPF_K */
4650 "JMP_JLT_K: if (2 < 3) return 1",
4652 BPF_ALU32_IMM(BPF_MOV, R0, 0),
4653 BPF_LD_IMM64(R1, 2),
4654 BPF_JMP_IMM(BPF_JLT, R1, 3, 1),
4656 BPF_ALU32_IMM(BPF_MOV, R0, 1),
4664 "JMP_JGT_K: Unsigned jump: if (1 < -1) return 1",
4666 BPF_ALU32_IMM(BPF_MOV, R0, 0),
4667 BPF_LD_IMM64(R1, 1),
4668 BPF_JMP_IMM(BPF_JLT, R1, -1, 1),
4670 BPF_ALU32_IMM(BPF_MOV, R0, 1),
4677 /* BPF_JMP | BPF_JGE | BPF_K */
4679 "JMP_JGE_K: if (3 >= 2) return 1",
4681 BPF_ALU32_IMM(BPF_MOV, R0, 0),
4682 BPF_LD_IMM64(R1, 3),
4683 BPF_JMP_IMM(BPF_JGE, R1, 2, 1),
4685 BPF_ALU32_IMM(BPF_MOV, R0, 1),
4692 /* BPF_JMP | BPF_JLE | BPF_K */
4694 "JMP_JLE_K: if (2 <= 3) return 1",
4696 BPF_ALU32_IMM(BPF_MOV, R0, 0),
4697 BPF_LD_IMM64(R1, 2),
4698 BPF_JMP_IMM(BPF_JLE, R1, 3, 1),
4700 BPF_ALU32_IMM(BPF_MOV, R0, 1),
4707 /* BPF_JMP | BPF_JGT | BPF_K jump backwards */
4709 "JMP_JGT_K: if (3 > 2) return 1 (jump backwards)",
4711 BPF_JMP_IMM(BPF_JA, 0, 0, 2), /* goto start */
4712 BPF_ALU32_IMM(BPF_MOV, R0, 1), /* out: */
4714 BPF_ALU32_IMM(BPF_MOV, R0, 0), /* start: */
4715 BPF_LD_IMM64(R1, 3), /* note: this takes 2 insns */
4716 BPF_JMP_IMM(BPF_JGT, R1, 2, -6), /* goto out */
4724 "JMP_JGE_K: if (3 >= 3) return 1",
4726 BPF_ALU32_IMM(BPF_MOV, R0, 0),
4727 BPF_LD_IMM64(R1, 3),
4728 BPF_JMP_IMM(BPF_JGE, R1, 3, 1),
4730 BPF_ALU32_IMM(BPF_MOV, R0, 1),
4737 /* BPF_JMP | BPF_JLT | BPF_K jump backwards */
4739 "JMP_JGT_K: if (2 < 3) return 1 (jump backwards)",
4741 BPF_JMP_IMM(BPF_JA, 0, 0, 2), /* goto start */
4742 BPF_ALU32_IMM(BPF_MOV, R0, 1), /* out: */
4744 BPF_ALU32_IMM(BPF_MOV, R0, 0), /* start: */
4745 BPF_LD_IMM64(R1, 2), /* note: this takes 2 insns */
4746 BPF_JMP_IMM(BPF_JLT, R1, 3, -6), /* goto out */
4754 "JMP_JLE_K: if (3 <= 3) return 1",
4756 BPF_ALU32_IMM(BPF_MOV, R0, 0),
4757 BPF_LD_IMM64(R1, 3),
4758 BPF_JMP_IMM(BPF_JLE, R1, 3, 1),
4760 BPF_ALU32_IMM(BPF_MOV, R0, 1),
4767 /* BPF_JMP | BPF_JNE | BPF_K */
4769 "JMP_JNE_K: if (3 != 2) return 1",
4771 BPF_ALU32_IMM(BPF_MOV, R0, 0),
4772 BPF_LD_IMM64(R1, 3),
4773 BPF_JMP_IMM(BPF_JNE, R1, 2, 1),
4775 BPF_ALU32_IMM(BPF_MOV, R0, 1),
4782 /* BPF_JMP | BPF_JEQ | BPF_K */
4784 "JMP_JEQ_K: if (3 == 3) return 1",
4786 BPF_ALU32_IMM(BPF_MOV, R0, 0),
4787 BPF_LD_IMM64(R1, 3),
4788 BPF_JMP_IMM(BPF_JEQ, R1, 3, 1),
4790 BPF_ALU32_IMM(BPF_MOV, R0, 1),
4797 /* BPF_JMP | BPF_JSET | BPF_K */
4799 "JMP_JSET_K: if (0x3 & 0x2) return 1",
4801 BPF_ALU32_IMM(BPF_MOV, R0, 0),
4802 BPF_LD_IMM64(R1, 3),
4803 BPF_JMP_IMM(BPF_JSET, R1, 2, 1),
4805 BPF_ALU32_IMM(BPF_MOV, R0, 1),
4813 "JMP_JSET_K: if (0x3 & 0xffffffff) return 1",
4815 BPF_ALU32_IMM(BPF_MOV, R0, 0),
4816 BPF_LD_IMM64(R1, 3),
4817 BPF_JMP_IMM(BPF_JSET, R1, 0xffffffff, 1),
4819 BPF_ALU32_IMM(BPF_MOV, R0, 1),
4826 /* BPF_JMP | BPF_JSGT | BPF_X */
4828 "JMP_JSGT_X: Signed jump: if (-1 > -2) return 1",
4830 BPF_ALU32_IMM(BPF_MOV, R0, 0),
4831 BPF_LD_IMM64(R1, -1),
4832 BPF_LD_IMM64(R2, -2),
4833 BPF_JMP_REG(BPF_JSGT, R1, R2, 1),
4835 BPF_ALU32_IMM(BPF_MOV, R0, 1),
4843 "JMP_JSGT_X: Signed jump: if (-1 > -1) return 0",
4845 BPF_ALU32_IMM(BPF_MOV, R0, 1),
4846 BPF_LD_IMM64(R1, -1),
4847 BPF_LD_IMM64(R2, -1),
4848 BPF_JMP_REG(BPF_JSGT, R1, R2, 1),
4850 BPF_ALU32_IMM(BPF_MOV, R0, 0),
4857 /* BPF_JMP | BPF_JSLT | BPF_X */
4859 "JMP_JSLT_X: Signed jump: if (-2 < -1) return 1",
4861 BPF_ALU32_IMM(BPF_MOV, R0, 0),
4862 BPF_LD_IMM64(R1, -1),
4863 BPF_LD_IMM64(R2, -2),
4864 BPF_JMP_REG(BPF_JSLT, R2, R1, 1),
4866 BPF_ALU32_IMM(BPF_MOV, R0, 1),
4874 "JMP_JSLT_X: Signed jump: if (-1 < -1) return 0",
4876 BPF_ALU32_IMM(BPF_MOV, R0, 1),
4877 BPF_LD_IMM64(R1, -1),
4878 BPF_LD_IMM64(R2, -1),
4879 BPF_JMP_REG(BPF_JSLT, R1, R2, 1),
4881 BPF_ALU32_IMM(BPF_MOV, R0, 0),
4888 /* BPF_JMP | BPF_JSGE | BPF_X */
4890 "JMP_JSGE_X: Signed jump: if (-1 >= -2) return 1",
4892 BPF_ALU32_IMM(BPF_MOV, R0, 0),
4893 BPF_LD_IMM64(R1, -1),
4894 BPF_LD_IMM64(R2, -2),
4895 BPF_JMP_REG(BPF_JSGE, R1, R2, 1),
4897 BPF_ALU32_IMM(BPF_MOV, R0, 1),
4905 "JMP_JSGE_X: Signed jump: if (-1 >= -1) return 1",
4907 BPF_ALU32_IMM(BPF_MOV, R0, 0),
4908 BPF_LD_IMM64(R1, -1),
4909 BPF_LD_IMM64(R2, -1),
4910 BPF_JMP_REG(BPF_JSGE, R1, R2, 1),
4912 BPF_ALU32_IMM(BPF_MOV, R0, 1),
4919 /* BPF_JMP | BPF_JSLE | BPF_X */
4921 "JMP_JSLE_X: Signed jump: if (-2 <= -1) return 1",
4923 BPF_ALU32_IMM(BPF_MOV, R0, 0),
4924 BPF_LD_IMM64(R1, -1),
4925 BPF_LD_IMM64(R2, -2),
4926 BPF_JMP_REG(BPF_JSLE, R2, R1, 1),
4928 BPF_ALU32_IMM(BPF_MOV, R0, 1),
4936 "JMP_JSLE_X: Signed jump: if (-1 <= -1) return 1",
4938 BPF_ALU32_IMM(BPF_MOV, R0, 0),
4939 BPF_LD_IMM64(R1, -1),
4940 BPF_LD_IMM64(R2, -1),
4941 BPF_JMP_REG(BPF_JSLE, R1, R2, 1),
4943 BPF_ALU32_IMM(BPF_MOV, R0, 1),
4950 /* BPF_JMP | BPF_JGT | BPF_X */
4952 "JMP_JGT_X: if (3 > 2) return 1",
4954 BPF_ALU32_IMM(BPF_MOV, R0, 0),
4955 BPF_LD_IMM64(R1, 3),
4956 BPF_LD_IMM64(R2, 2),
4957 BPF_JMP_REG(BPF_JGT, R1, R2, 1),
4959 BPF_ALU32_IMM(BPF_MOV, R0, 1),
4967 "JMP_JGT_X: Unsigned jump: if (-1 > 1) return 1",
4969 BPF_ALU32_IMM(BPF_MOV, R0, 0),
4970 BPF_LD_IMM64(R1, -1),
4971 BPF_LD_IMM64(R2, 1),
4972 BPF_JMP_REG(BPF_JGT, R1, R2, 1),
4974 BPF_ALU32_IMM(BPF_MOV, R0, 1),
4981 /* BPF_JMP | BPF_JLT | BPF_X */
4983 "JMP_JLT_X: if (2 < 3) return 1",
4985 BPF_ALU32_IMM(BPF_MOV, R0, 0),
4986 BPF_LD_IMM64(R1, 3),
4987 BPF_LD_IMM64(R2, 2),
4988 BPF_JMP_REG(BPF_JLT, R2, R1, 1),
4990 BPF_ALU32_IMM(BPF_MOV, R0, 1),
4998 "JMP_JLT_X: Unsigned jump: if (1 < -1) return 1",
5000 BPF_ALU32_IMM(BPF_MOV, R0, 0),
5001 BPF_LD_IMM64(R1, -1),
5002 BPF_LD_IMM64(R2, 1),
5003 BPF_JMP_REG(BPF_JLT, R2, R1, 1),
5005 BPF_ALU32_IMM(BPF_MOV, R0, 1),
5012 /* BPF_JMP | BPF_JGE | BPF_X */
5014 "JMP_JGE_X: if (3 >= 2) return 1",
5016 BPF_ALU32_IMM(BPF_MOV, R0, 0),
5017 BPF_LD_IMM64(R1, 3),
5018 BPF_LD_IMM64(R2, 2),
5019 BPF_JMP_REG(BPF_JGE, R1, R2, 1),
5021 BPF_ALU32_IMM(BPF_MOV, R0, 1),
5029 "JMP_JGE_X: if (3 >= 3) return 1",
5031 BPF_ALU32_IMM(BPF_MOV, R0, 0),
5032 BPF_LD_IMM64(R1, 3),
5033 BPF_LD_IMM64(R2, 3),
5034 BPF_JMP_REG(BPF_JGE, R1, R2, 1),
5036 BPF_ALU32_IMM(BPF_MOV, R0, 1),
5043 /* BPF_JMP | BPF_JLE | BPF_X */
5045 "JMP_JLE_X: if (2 <= 3) return 1",
5047 BPF_ALU32_IMM(BPF_MOV, R0, 0),
5048 BPF_LD_IMM64(R1, 3),
5049 BPF_LD_IMM64(R2, 2),
5050 BPF_JMP_REG(BPF_JLE, R2, R1, 1),
5052 BPF_ALU32_IMM(BPF_MOV, R0, 1),
5060 "JMP_JLE_X: if (3 <= 3) return 1",
5062 BPF_ALU32_IMM(BPF_MOV, R0, 0),
5063 BPF_LD_IMM64(R1, 3),
5064 BPF_LD_IMM64(R2, 3),
5065 BPF_JMP_REG(BPF_JLE, R1, R2, 1),
5067 BPF_ALU32_IMM(BPF_MOV, R0, 1),
5075 /* Mainly testing JIT + imm64 here. */
5076 "JMP_JGE_X: ldimm64 test 1",
5078 BPF_ALU32_IMM(BPF_MOV, R0, 0),
5079 BPF_LD_IMM64(R1, 3),
5080 BPF_LD_IMM64(R2, 2),
5081 BPF_JMP_REG(BPF_JGE, R1, R2, 2),
5082 BPF_LD_IMM64(R0, 0xffffffffffffffffULL),
5083 BPF_LD_IMM64(R0, 0xeeeeeeeeeeeeeeeeULL),
5088 { { 0, 0xeeeeeeeeU } },
5091 "JMP_JGE_X: ldimm64 test 2",
5093 BPF_ALU32_IMM(BPF_MOV, R0, 0),
5094 BPF_LD_IMM64(R1, 3),
5095 BPF_LD_IMM64(R2, 2),
5096 BPF_JMP_REG(BPF_JGE, R1, R2, 0),
5097 BPF_LD_IMM64(R0, 0xffffffffffffffffULL),
5102 { { 0, 0xffffffffU } },
5105 "JMP_JGE_X: ldimm64 test 3",
5107 BPF_ALU32_IMM(BPF_MOV, R0, 1),
5108 BPF_LD_IMM64(R1, 3),
5109 BPF_LD_IMM64(R2, 2),
5110 BPF_JMP_REG(BPF_JGE, R1, R2, 4),
5111 BPF_LD_IMM64(R0, 0xffffffffffffffffULL),
5112 BPF_LD_IMM64(R0, 0xeeeeeeeeeeeeeeeeULL),
5120 "JMP_JLE_X: ldimm64 test 1",
5122 BPF_ALU32_IMM(BPF_MOV, R0, 0),
5123 BPF_LD_IMM64(R1, 3),
5124 BPF_LD_IMM64(R2, 2),
5125 BPF_JMP_REG(BPF_JLE, R2, R1, 2),
5126 BPF_LD_IMM64(R0, 0xffffffffffffffffULL),
5127 BPF_LD_IMM64(R0, 0xeeeeeeeeeeeeeeeeULL),
5132 { { 0, 0xeeeeeeeeU } },
5135 "JMP_JLE_X: ldimm64 test 2",
5137 BPF_ALU32_IMM(BPF_MOV, R0, 0),
5138 BPF_LD_IMM64(R1, 3),
5139 BPF_LD_IMM64(R2, 2),
5140 BPF_JMP_REG(BPF_JLE, R2, R1, 0),
5141 BPF_LD_IMM64(R0, 0xffffffffffffffffULL),
5146 { { 0, 0xffffffffU } },
5149 "JMP_JLE_X: ldimm64 test 3",
5151 BPF_ALU32_IMM(BPF_MOV, R0, 1),
5152 BPF_LD_IMM64(R1, 3),
5153 BPF_LD_IMM64(R2, 2),
5154 BPF_JMP_REG(BPF_JLE, R2, R1, 4),
5155 BPF_LD_IMM64(R0, 0xffffffffffffffffULL),
5156 BPF_LD_IMM64(R0, 0xeeeeeeeeeeeeeeeeULL),
5163 /* BPF_JMP | BPF_JNE | BPF_X */
5165 "JMP_JNE_X: if (3 != 2) return 1",
5167 BPF_ALU32_IMM(BPF_MOV, R0, 0),
5168 BPF_LD_IMM64(R1, 3),
5169 BPF_LD_IMM64(R2, 2),
5170 BPF_JMP_REG(BPF_JNE, R1, R2, 1),
5172 BPF_ALU32_IMM(BPF_MOV, R0, 1),
5179 /* BPF_JMP | BPF_JEQ | BPF_X */
5181 "JMP_JEQ_X: if (3 == 3) return 1",
5183 BPF_ALU32_IMM(BPF_MOV, R0, 0),
5184 BPF_LD_IMM64(R1, 3),
5185 BPF_LD_IMM64(R2, 3),
5186 BPF_JMP_REG(BPF_JEQ, R1, R2, 1),
5188 BPF_ALU32_IMM(BPF_MOV, R0, 1),
5195 /* BPF_JMP | BPF_JSET | BPF_X */
5197 "JMP_JSET_X: if (0x3 & 0x2) return 1",
5199 BPF_ALU32_IMM(BPF_MOV, R0, 0),
5200 BPF_LD_IMM64(R1, 3),
5201 BPF_LD_IMM64(R2, 2),
5202 BPF_JMP_REG(BPF_JSET, R1, R2, 1),
5204 BPF_ALU32_IMM(BPF_MOV, R0, 1),
5212 "JMP_JSET_X: if (0x3 & 0xffffffff) return 1",
5214 BPF_ALU32_IMM(BPF_MOV, R0, 0),
5215 BPF_LD_IMM64(R1, 3),
5216 BPF_LD_IMM64(R2, 0xffffffff),
5217 BPF_JMP_REG(BPF_JSET, R1, R2, 1),
5219 BPF_ALU32_IMM(BPF_MOV, R0, 1),
5227 "JMP_JA: Jump, gap, jump, ...",
5229 CLASSIC | FLAG_NO_DATA,
5231 { { 0, 0xababcbac } },
5232 .fill_helper = bpf_fill_ja,
5234 { /* Mainly checking JIT here. */
5235 "BPF_MAXINSNS: Maximum possible literals",
5237 CLASSIC | FLAG_NO_DATA,
5239 { { 0, 0xffffffff } },
5240 .fill_helper = bpf_fill_maxinsns1,
5242 { /* Mainly checking JIT here. */
5243 "BPF_MAXINSNS: Single literal",
5245 CLASSIC | FLAG_NO_DATA,
5247 { { 0, 0xfefefefe } },
5248 .fill_helper = bpf_fill_maxinsns2,
5250 { /* Mainly checking JIT here. */
5251 "BPF_MAXINSNS: Run/add until end",
5253 CLASSIC | FLAG_NO_DATA,
5255 { { 0, 0x947bf368 } },
5256 .fill_helper = bpf_fill_maxinsns3,
5259 "BPF_MAXINSNS: Too many instructions",
5261 CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL,
5264 .fill_helper = bpf_fill_maxinsns4,
5265 .expected_errcode = -EINVAL,
5267 { /* Mainly checking JIT here. */
5268 "BPF_MAXINSNS: Very long jump",
5270 CLASSIC | FLAG_NO_DATA,
5272 { { 0, 0xabababab } },
5273 .fill_helper = bpf_fill_maxinsns5,
5275 { /* Mainly checking JIT here. */
5276 "BPF_MAXINSNS: Ctx heavy transformations",
5281 { 1, SKB_VLAN_PRESENT },
5282 { 10, SKB_VLAN_PRESENT }
5284 .fill_helper = bpf_fill_maxinsns6,
5286 { /* Mainly checking JIT here. */
5287 "BPF_MAXINSNS: Call heavy transformations",
5289 CLASSIC | FLAG_NO_DATA,
5291 { { 1, 0 }, { 10, 0 } },
5292 .fill_helper = bpf_fill_maxinsns7,
5294 { /* Mainly checking JIT here. */
5295 "BPF_MAXINSNS: Jump heavy test",
5297 CLASSIC | FLAG_NO_DATA,
5299 { { 0, 0xffffffff } },
5300 .fill_helper = bpf_fill_maxinsns8,
5302 { /* Mainly checking JIT here. */
5303 "BPF_MAXINSNS: Very long jump backwards",
5305 INTERNAL | FLAG_NO_DATA,
5307 { { 0, 0xcbababab } },
5308 .fill_helper = bpf_fill_maxinsns9,
5310 { /* Mainly checking JIT here. */
5311 "BPF_MAXINSNS: Edge hopping nuthouse",
5313 INTERNAL | FLAG_NO_DATA,
5315 { { 0, 0xabababac } },
5316 .fill_helper = bpf_fill_maxinsns10,
5319 "BPF_MAXINSNS: Jump, gap, jump, ...",
5321 #if defined(CONFIG_BPF_JIT_ALWAYS_ON) && defined(CONFIG_X86)
5322 CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL,
5324 CLASSIC | FLAG_NO_DATA,
5327 { { 0, 0xababcbac } },
5328 .fill_helper = bpf_fill_maxinsns11,
5329 .expected_errcode = -ENOTSUPP,
5332 "BPF_MAXINSNS: jump over MSH",
5334 CLASSIC | FLAG_EXPECTED_FAIL,
5335 { 0xfa, 0xfb, 0xfc, 0xfd, },
5336 { { 4, 0xabababab } },
5337 .fill_helper = bpf_fill_maxinsns12,
5338 .expected_errcode = -EINVAL,
5341 "BPF_MAXINSNS: exec all MSH",
5344 { 0xfa, 0xfb, 0xfc, 0xfd, },
5345 { { 4, 0xababab83 } },
5346 .fill_helper = bpf_fill_maxinsns13,
5349 "BPF_MAXINSNS: ld_abs+get_processor_id",
5354 .fill_helper = bpf_fill_ld_abs_get_processor_id,
5357 * LD_IND / LD_ABS on fragmented SKBs
5362 BPF_STMT(BPF_LDX | BPF_IMM, 0x40),
5363 BPF_STMT(BPF_LD | BPF_IND | BPF_B, 0x0),
5364 BPF_STMT(BPF_RET | BPF_A, 0x0),
5366 CLASSIC | FLAG_SKB_FRAG,
5370 0x42, 0x00, 0x00, 0x00,
5371 0x43, 0x44, 0x00, 0x00,
5372 0x21, 0x07, 0x19, 0x83,
5376 "LD_IND halfword frag",
5378 BPF_STMT(BPF_LDX | BPF_IMM, 0x40),
5379 BPF_STMT(BPF_LD | BPF_IND | BPF_H, 0x4),
5380 BPF_STMT(BPF_RET | BPF_A, 0x0),
5382 CLASSIC | FLAG_SKB_FRAG,
5386 0x42, 0x00, 0x00, 0x00,
5387 0x43, 0x44, 0x00, 0x00,
5388 0x21, 0x07, 0x19, 0x83,
5394 BPF_STMT(BPF_LDX | BPF_IMM, 0x40),
5395 BPF_STMT(BPF_LD | BPF_IND | BPF_W, 0x8),
5396 BPF_STMT(BPF_RET | BPF_A, 0x0),
5398 CLASSIC | FLAG_SKB_FRAG,
5400 { {0x40, 0x21071983} },
5402 0x42, 0x00, 0x00, 0x00,
5403 0x43, 0x44, 0x00, 0x00,
5404 0x21, 0x07, 0x19, 0x83,
5408 "LD_IND halfword mixed head/frag",
5410 BPF_STMT(BPF_LDX | BPF_IMM, 0x40),
5411 BPF_STMT(BPF_LD | BPF_IND | BPF_H, -0x1),
5412 BPF_STMT(BPF_RET | BPF_A, 0x0),
5414 CLASSIC | FLAG_SKB_FRAG,
5415 { [0x3e] = 0x25, [0x3f] = 0x05, },
5417 .frag_data = { 0x19, 0x82 },
5420 "LD_IND word mixed head/frag",
5422 BPF_STMT(BPF_LDX | BPF_IMM, 0x40),
5423 BPF_STMT(BPF_LD | BPF_IND | BPF_W, -0x2),
5424 BPF_STMT(BPF_RET | BPF_A, 0x0),
5426 CLASSIC | FLAG_SKB_FRAG,
5427 { [0x3e] = 0x25, [0x3f] = 0x05, },
5428 { {0x40, 0x25051982} },
5429 .frag_data = { 0x19, 0x82 },
5434 BPF_STMT(BPF_LD | BPF_ABS | BPF_B, 0x40),
5435 BPF_STMT(BPF_RET | BPF_A, 0x0),
5437 CLASSIC | FLAG_SKB_FRAG,
5441 0x42, 0x00, 0x00, 0x00,
5442 0x43, 0x44, 0x00, 0x00,
5443 0x21, 0x07, 0x19, 0x83,
5447 "LD_ABS halfword frag",
5449 BPF_STMT(BPF_LD | BPF_ABS | BPF_H, 0x44),
5450 BPF_STMT(BPF_RET | BPF_A, 0x0),
5452 CLASSIC | FLAG_SKB_FRAG,
5456 0x42, 0x00, 0x00, 0x00,
5457 0x43, 0x44, 0x00, 0x00,
5458 0x21, 0x07, 0x19, 0x83,
5464 BPF_STMT(BPF_LD | BPF_ABS | BPF_W, 0x48),
5465 BPF_STMT(BPF_RET | BPF_A, 0x0),
5467 CLASSIC | FLAG_SKB_FRAG,
5469 { {0x40, 0x21071983} },
5471 0x42, 0x00, 0x00, 0x00,
5472 0x43, 0x44, 0x00, 0x00,
5473 0x21, 0x07, 0x19, 0x83,
5477 "LD_ABS halfword mixed head/frag",
5479 BPF_STMT(BPF_LD | BPF_ABS | BPF_H, 0x3f),
5480 BPF_STMT(BPF_RET | BPF_A, 0x0),
5482 CLASSIC | FLAG_SKB_FRAG,
5483 { [0x3e] = 0x25, [0x3f] = 0x05, },
5485 .frag_data = { 0x19, 0x82 },
5488 "LD_ABS word mixed head/frag",
5490 BPF_STMT(BPF_LD | BPF_ABS | BPF_W, 0x3e),
5491 BPF_STMT(BPF_RET | BPF_A, 0x0),
5493 CLASSIC | FLAG_SKB_FRAG,
5494 { [0x3e] = 0x25, [0x3f] = 0x05, },
5495 { {0x40, 0x25051982} },
5496 .frag_data = { 0x19, 0x82 },
5499 * LD_IND / LD_ABS on non fragmented SKBs
5503 * this tests that the JIT/interpreter correctly resets X
5504 * before using it in an LD_IND instruction.
5506 "LD_IND byte default X",
5508 BPF_STMT(BPF_LD | BPF_IND | BPF_B, 0x1),
5509 BPF_STMT(BPF_RET | BPF_A, 0x0),
5516 "LD_IND byte positive offset",
5518 BPF_STMT(BPF_LDX | BPF_IMM, 0x3e),
5519 BPF_STMT(BPF_LD | BPF_IND | BPF_B, 0x1),
5520 BPF_STMT(BPF_RET | BPF_A, 0x0),
5523 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
5527 "LD_IND byte negative offset",
5529 BPF_STMT(BPF_LDX | BPF_IMM, 0x3e),
5530 BPF_STMT(BPF_LD | BPF_IND | BPF_B, -0x1),
5531 BPF_STMT(BPF_RET | BPF_A, 0x0),
5534 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
5538 "LD_IND byte positive offset, all ff",
5540 BPF_STMT(BPF_LDX | BPF_IMM, 0x3e),
5541 BPF_STMT(BPF_LD | BPF_IND | BPF_B, 0x1),
5542 BPF_STMT(BPF_RET | BPF_A, 0x0),
5545 { [0x3c] = 0xff, [0x3d] = 0xff, [0x3e] = 0xff, [0x3f] = 0xff },
5549 "LD_IND byte positive offset, out of bounds",
5551 BPF_STMT(BPF_LDX | BPF_IMM, 0x3e),
5552 BPF_STMT(BPF_LD | BPF_IND | BPF_B, 0x1),
5553 BPF_STMT(BPF_RET | BPF_A, 0x0),
5556 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
5560 "LD_IND byte negative offset, out of bounds",
5562 BPF_STMT(BPF_LDX | BPF_IMM, 0x3e),
5563 BPF_STMT(BPF_LD | BPF_IND | BPF_B, -0x3f),
5564 BPF_STMT(BPF_RET | BPF_A, 0x0),
5567 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
5571 "LD_IND byte negative offset, multiple calls",
5573 BPF_STMT(BPF_LDX | BPF_IMM, 0x3b),
5574 BPF_STMT(BPF_LD | BPF_IND | BPF_B, SKF_LL_OFF + 1),
5575 BPF_STMT(BPF_LD | BPF_IND | BPF_B, SKF_LL_OFF + 2),
5576 BPF_STMT(BPF_LD | BPF_IND | BPF_B, SKF_LL_OFF + 3),
5577 BPF_STMT(BPF_LD | BPF_IND | BPF_B, SKF_LL_OFF + 4),
5578 BPF_STMT(BPF_RET | BPF_A, 0x0),
5581 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
5585 "LD_IND halfword positive offset",
5587 BPF_STMT(BPF_LDX | BPF_IMM, 0x20),
5588 BPF_STMT(BPF_LD | BPF_IND | BPF_H, 0x2),
5589 BPF_STMT(BPF_RET | BPF_A, 0x0),
5593 [0x1c] = 0xaa, [0x1d] = 0x55,
5594 [0x1e] = 0xbb, [0x1f] = 0x66,
5595 [0x20] = 0xcc, [0x21] = 0x77,
5596 [0x22] = 0xdd, [0x23] = 0x88,
5598 { {0x40, 0xdd88 } },
5601 "LD_IND halfword negative offset",
5603 BPF_STMT(BPF_LDX | BPF_IMM, 0x20),
5604 BPF_STMT(BPF_LD | BPF_IND | BPF_H, -0x2),
5605 BPF_STMT(BPF_RET | BPF_A, 0x0),
5609 [0x1c] = 0xaa, [0x1d] = 0x55,
5610 [0x1e] = 0xbb, [0x1f] = 0x66,
5611 [0x20] = 0xcc, [0x21] = 0x77,
5612 [0x22] = 0xdd, [0x23] = 0x88,
5614 { {0x40, 0xbb66 } },
5617 "LD_IND halfword unaligned",
5619 BPF_STMT(BPF_LDX | BPF_IMM, 0x20),
5620 BPF_STMT(BPF_LD | BPF_IND | BPF_H, -0x1),
5621 BPF_STMT(BPF_RET | BPF_A, 0x0),
5625 [0x1c] = 0xaa, [0x1d] = 0x55,
5626 [0x1e] = 0xbb, [0x1f] = 0x66,
5627 [0x20] = 0xcc, [0x21] = 0x77,
5628 [0x22] = 0xdd, [0x23] = 0x88,
5630 { {0x40, 0x66cc } },
5633 "LD_IND halfword positive offset, all ff",
5635 BPF_STMT(BPF_LDX | BPF_IMM, 0x3d),
5636 BPF_STMT(BPF_LD | BPF_IND | BPF_H, 0x1),
5637 BPF_STMT(BPF_RET | BPF_A, 0x0),
5640 { [0x3c] = 0xff, [0x3d] = 0xff, [0x3e] = 0xff, [0x3f] = 0xff },
5641 { {0x40, 0xffff } },
5644 "LD_IND halfword positive offset, out of bounds",
5646 BPF_STMT(BPF_LDX | BPF_IMM, 0x3e),
5647 BPF_STMT(BPF_LD | BPF_IND | BPF_H, 0x1),
5648 BPF_STMT(BPF_RET | BPF_A, 0x0),
5651 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
5655 "LD_IND halfword negative offset, out of bounds",
5657 BPF_STMT(BPF_LDX | BPF_IMM, 0x3e),
5658 BPF_STMT(BPF_LD | BPF_IND | BPF_H, -0x3f),
5659 BPF_STMT(BPF_RET | BPF_A, 0x0),
5662 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
5666 "LD_IND word positive offset",
5668 BPF_STMT(BPF_LDX | BPF_IMM, 0x20),
5669 BPF_STMT(BPF_LD | BPF_IND | BPF_W, 0x4),
5670 BPF_STMT(BPF_RET | BPF_A, 0x0),
5674 [0x1c] = 0xaa, [0x1d] = 0x55,
5675 [0x1e] = 0xbb, [0x1f] = 0x66,
5676 [0x20] = 0xcc, [0x21] = 0x77,
5677 [0x22] = 0xdd, [0x23] = 0x88,
5678 [0x24] = 0xee, [0x25] = 0x99,
5679 [0x26] = 0xff, [0x27] = 0xaa,
5681 { {0x40, 0xee99ffaa } },
5684 "LD_IND word negative offset",
5686 BPF_STMT(BPF_LDX | BPF_IMM, 0x20),
5687 BPF_STMT(BPF_LD | BPF_IND | BPF_W, -0x4),
5688 BPF_STMT(BPF_RET | BPF_A, 0x0),
5692 [0x1c] = 0xaa, [0x1d] = 0x55,
5693 [0x1e] = 0xbb, [0x1f] = 0x66,
5694 [0x20] = 0xcc, [0x21] = 0x77,
5695 [0x22] = 0xdd, [0x23] = 0x88,
5696 [0x24] = 0xee, [0x25] = 0x99,
5697 [0x26] = 0xff, [0x27] = 0xaa,
5699 { {0x40, 0xaa55bb66 } },
5702 "LD_IND word unaligned (addr & 3 == 2)",
5704 BPF_STMT(BPF_LDX | BPF_IMM, 0x20),
5705 BPF_STMT(BPF_LD | BPF_IND | BPF_W, -0x2),
5706 BPF_STMT(BPF_RET | BPF_A, 0x0),
5710 [0x1c] = 0xaa, [0x1d] = 0x55,
5711 [0x1e] = 0xbb, [0x1f] = 0x66,
5712 [0x20] = 0xcc, [0x21] = 0x77,
5713 [0x22] = 0xdd, [0x23] = 0x88,
5714 [0x24] = 0xee, [0x25] = 0x99,
5715 [0x26] = 0xff, [0x27] = 0xaa,
5717 { {0x40, 0xbb66cc77 } },
5720 "LD_IND word unaligned (addr & 3 == 1)",
5722 BPF_STMT(BPF_LDX | BPF_IMM, 0x20),
5723 BPF_STMT(BPF_LD | BPF_IND | BPF_W, -0x3),
5724 BPF_STMT(BPF_RET | BPF_A, 0x0),
5728 [0x1c] = 0xaa, [0x1d] = 0x55,
5729 [0x1e] = 0xbb, [0x1f] = 0x66,
5730 [0x20] = 0xcc, [0x21] = 0x77,
5731 [0x22] = 0xdd, [0x23] = 0x88,
5732 [0x24] = 0xee, [0x25] = 0x99,
5733 [0x26] = 0xff, [0x27] = 0xaa,
5735 { {0x40, 0x55bb66cc } },
5738 "LD_IND word unaligned (addr & 3 == 3)",
5740 BPF_STMT(BPF_LDX | BPF_IMM, 0x20),
5741 BPF_STMT(BPF_LD | BPF_IND | BPF_W, -0x1),
5742 BPF_STMT(BPF_RET | BPF_A, 0x0),
5746 [0x1c] = 0xaa, [0x1d] = 0x55,
5747 [0x1e] = 0xbb, [0x1f] = 0x66,
5748 [0x20] = 0xcc, [0x21] = 0x77,
5749 [0x22] = 0xdd, [0x23] = 0x88,
5750 [0x24] = 0xee, [0x25] = 0x99,
5751 [0x26] = 0xff, [0x27] = 0xaa,
5753 { {0x40, 0x66cc77dd } },
5756 "LD_IND word positive offset, all ff",
5758 BPF_STMT(BPF_LDX | BPF_IMM, 0x3b),
5759 BPF_STMT(BPF_LD | BPF_IND | BPF_W, 0x1),
5760 BPF_STMT(BPF_RET | BPF_A, 0x0),
5763 { [0x3c] = 0xff, [0x3d] = 0xff, [0x3e] = 0xff, [0x3f] = 0xff },
5764 { {0x40, 0xffffffff } },
5767 "LD_IND word positive offset, out of bounds",
5769 BPF_STMT(BPF_LDX | BPF_IMM, 0x3e),
5770 BPF_STMT(BPF_LD | BPF_IND | BPF_W, 0x1),
5771 BPF_STMT(BPF_RET | BPF_A, 0x0),
5774 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
5778 "LD_IND word negative offset, out of bounds",
5780 BPF_STMT(BPF_LDX | BPF_IMM, 0x3e),
5781 BPF_STMT(BPF_LD | BPF_IND | BPF_W, -0x3f),
5782 BPF_STMT(BPF_RET | BPF_A, 0x0),
5785 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
5791 BPF_STMT(BPF_LD | BPF_ABS | BPF_B, 0x20),
5792 BPF_STMT(BPF_RET | BPF_A, 0x0),
5796 [0x1c] = 0xaa, [0x1d] = 0x55,
5797 [0x1e] = 0xbb, [0x1f] = 0x66,
5798 [0x20] = 0xcc, [0x21] = 0x77,
5799 [0x22] = 0xdd, [0x23] = 0x88,
5800 [0x24] = 0xee, [0x25] = 0x99,
5801 [0x26] = 0xff, [0x27] = 0xaa,
5806 "LD_ABS byte positive offset, all ff",
5808 BPF_STMT(BPF_LD | BPF_ABS | BPF_B, 0x3f),
5809 BPF_STMT(BPF_RET | BPF_A, 0x0),
5812 { [0x3c] = 0xff, [0x3d] = 0xff, [0x3e] = 0xff, [0x3f] = 0xff },
5816 "LD_ABS byte positive offset, out of bounds",
5818 BPF_STMT(BPF_LD | BPF_ABS | BPF_B, 0x3f),
5819 BPF_STMT(BPF_RET | BPF_A, 0x0),
5822 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
5826 "LD_ABS byte negative offset, out of bounds load",
5828 BPF_STMT(BPF_LD | BPF_ABS | BPF_B, -1),
5829 BPF_STMT(BPF_RET | BPF_A, 0x0),
5831 CLASSIC | FLAG_EXPECTED_FAIL,
5832 .expected_errcode = -EINVAL,
5835 "LD_ABS byte negative offset, in bounds",
5837 BPF_STMT(BPF_LD | BPF_ABS | BPF_B, SKF_LL_OFF + 0x3f),
5838 BPF_STMT(BPF_RET | BPF_A, 0x0),
5841 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
5845 "LD_ABS byte negative offset, out of bounds",
5847 BPF_STMT(BPF_LD | BPF_ABS | BPF_B, SKF_LL_OFF + 0x3f),
5848 BPF_STMT(BPF_RET | BPF_A, 0x0),
5851 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
5855 "LD_ABS byte negative offset, multiple calls",
5857 BPF_STMT(BPF_LD | BPF_ABS | BPF_B, SKF_LL_OFF + 0x3c),
5858 BPF_STMT(BPF_LD | BPF_ABS | BPF_B, SKF_LL_OFF + 0x3d),
5859 BPF_STMT(BPF_LD | BPF_ABS | BPF_B, SKF_LL_OFF + 0x3e),
5860 BPF_STMT(BPF_LD | BPF_ABS | BPF_B, SKF_LL_OFF + 0x3f),
5861 BPF_STMT(BPF_RET | BPF_A, 0x0),
5864 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
5870 BPF_STMT(BPF_LD | BPF_ABS | BPF_H, 0x22),
5871 BPF_STMT(BPF_RET | BPF_A, 0x0),
5875 [0x1c] = 0xaa, [0x1d] = 0x55,
5876 [0x1e] = 0xbb, [0x1f] = 0x66,
5877 [0x20] = 0xcc, [0x21] = 0x77,
5878 [0x22] = 0xdd, [0x23] = 0x88,
5879 [0x24] = 0xee, [0x25] = 0x99,
5880 [0x26] = 0xff, [0x27] = 0xaa,
5882 { {0x40, 0xdd88 } },
5885 "LD_ABS halfword unaligned",
5887 BPF_STMT(BPF_LD | BPF_ABS | BPF_H, 0x25),
5888 BPF_STMT(BPF_RET | BPF_A, 0x0),
5892 [0x1c] = 0xaa, [0x1d] = 0x55,
5893 [0x1e] = 0xbb, [0x1f] = 0x66,
5894 [0x20] = 0xcc, [0x21] = 0x77,
5895 [0x22] = 0xdd, [0x23] = 0x88,
5896 [0x24] = 0xee, [0x25] = 0x99,
5897 [0x26] = 0xff, [0x27] = 0xaa,
5899 { {0x40, 0x99ff } },
5902 "LD_ABS halfword positive offset, all ff",
5904 BPF_STMT(BPF_LD | BPF_ABS | BPF_H, 0x3e),
5905 BPF_STMT(BPF_RET | BPF_A, 0x0),
5908 { [0x3c] = 0xff, [0x3d] = 0xff, [0x3e] = 0xff, [0x3f] = 0xff },
5909 { {0x40, 0xffff } },
5912 "LD_ABS halfword positive offset, out of bounds",
5914 BPF_STMT(BPF_LD | BPF_ABS | BPF_H, 0x3f),
5915 BPF_STMT(BPF_RET | BPF_A, 0x0),
5918 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
5922 "LD_ABS halfword negative offset, out of bounds load",
5924 BPF_STMT(BPF_LD | BPF_ABS | BPF_H, -1),
5925 BPF_STMT(BPF_RET | BPF_A, 0x0),
5927 CLASSIC | FLAG_EXPECTED_FAIL,
5928 .expected_errcode = -EINVAL,
5931 "LD_ABS halfword negative offset, in bounds",
5933 BPF_STMT(BPF_LD | BPF_ABS | BPF_H, SKF_LL_OFF + 0x3e),
5934 BPF_STMT(BPF_RET | BPF_A, 0x0),
5937 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
5938 { {0x40, 0x1982 }, },
5941 "LD_ABS halfword negative offset, out of bounds",
5943 BPF_STMT(BPF_LD | BPF_ABS | BPF_H, SKF_LL_OFF + 0x3e),
5944 BPF_STMT(BPF_RET | BPF_A, 0x0),
5947 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
5953 BPF_STMT(BPF_LD | BPF_ABS | BPF_W, 0x1c),
5954 BPF_STMT(BPF_RET | BPF_A, 0x0),
5958 [0x1c] = 0xaa, [0x1d] = 0x55,
5959 [0x1e] = 0xbb, [0x1f] = 0x66,
5960 [0x20] = 0xcc, [0x21] = 0x77,
5961 [0x22] = 0xdd, [0x23] = 0x88,
5962 [0x24] = 0xee, [0x25] = 0x99,
5963 [0x26] = 0xff, [0x27] = 0xaa,
5965 { {0x40, 0xaa55bb66 } },
5968 "LD_ABS word unaligned (addr & 3 == 2)",
5970 BPF_STMT(BPF_LD | BPF_ABS | BPF_W, 0x22),
5971 BPF_STMT(BPF_RET | BPF_A, 0x0),
5975 [0x1c] = 0xaa, [0x1d] = 0x55,
5976 [0x1e] = 0xbb, [0x1f] = 0x66,
5977 [0x20] = 0xcc, [0x21] = 0x77,
5978 [0x22] = 0xdd, [0x23] = 0x88,
5979 [0x24] = 0xee, [0x25] = 0x99,
5980 [0x26] = 0xff, [0x27] = 0xaa,
5982 { {0x40, 0xdd88ee99 } },
5985 "LD_ABS word unaligned (addr & 3 == 1)",
5987 BPF_STMT(BPF_LD | BPF_ABS | BPF_W, 0x21),
5988 BPF_STMT(BPF_RET | BPF_A, 0x0),
5992 [0x1c] = 0xaa, [0x1d] = 0x55,
5993 [0x1e] = 0xbb, [0x1f] = 0x66,
5994 [0x20] = 0xcc, [0x21] = 0x77,
5995 [0x22] = 0xdd, [0x23] = 0x88,
5996 [0x24] = 0xee, [0x25] = 0x99,
5997 [0x26] = 0xff, [0x27] = 0xaa,
5999 { {0x40, 0x77dd88ee } },
6002 "LD_ABS word unaligned (addr & 3 == 3)",
6004 BPF_STMT(BPF_LD | BPF_ABS | BPF_W, 0x23),
6005 BPF_STMT(BPF_RET | BPF_A, 0x0),
6009 [0x1c] = 0xaa, [0x1d] = 0x55,
6010 [0x1e] = 0xbb, [0x1f] = 0x66,
6011 [0x20] = 0xcc, [0x21] = 0x77,
6012 [0x22] = 0xdd, [0x23] = 0x88,
6013 [0x24] = 0xee, [0x25] = 0x99,
6014 [0x26] = 0xff, [0x27] = 0xaa,
6016 { {0x40, 0x88ee99ff } },
6019 "LD_ABS word positive offset, all ff",
6021 BPF_STMT(BPF_LD | BPF_ABS | BPF_W, 0x3c),
6022 BPF_STMT(BPF_RET | BPF_A, 0x0),
6025 { [0x3c] = 0xff, [0x3d] = 0xff, [0x3e] = 0xff, [0x3f] = 0xff },
6026 { {0x40, 0xffffffff } },
6029 "LD_ABS word positive offset, out of bounds",
6031 BPF_STMT(BPF_LD | BPF_ABS | BPF_W, 0x3f),
6032 BPF_STMT(BPF_RET | BPF_A, 0x0),
6035 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
6039 "LD_ABS word negative offset, out of bounds load",
6041 BPF_STMT(BPF_LD | BPF_ABS | BPF_W, -1),
6042 BPF_STMT(BPF_RET | BPF_A, 0x0),
6044 CLASSIC | FLAG_EXPECTED_FAIL,
6045 .expected_errcode = -EINVAL,
6048 "LD_ABS word negative offset, in bounds",
6050 BPF_STMT(BPF_LD | BPF_ABS | BPF_W, SKF_LL_OFF + 0x3c),
6051 BPF_STMT(BPF_RET | BPF_A, 0x0),
6054 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
6055 { {0x40, 0x25051982 }, },
6058 "LD_ABS word negative offset, out of bounds",
6060 BPF_STMT(BPF_LD | BPF_ABS | BPF_W, SKF_LL_OFF + 0x3c),
6061 BPF_STMT(BPF_RET | BPF_A, 0x0),
6064 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
6068 "LDX_MSH standalone, preserved A",
6070 BPF_STMT(BPF_LD | BPF_IMM, 0xffeebbaa),
6071 BPF_STMT(BPF_LDX | BPF_B | BPF_MSH, 0x3c),
6072 BPF_STMT(BPF_RET | BPF_A, 0x0),
6075 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
6076 { {0x40, 0xffeebbaa }, },
6079 "LDX_MSH standalone, preserved A 2",
6081 BPF_STMT(BPF_LD | BPF_IMM, 0x175e9d63),
6082 BPF_STMT(BPF_LDX | BPF_B | BPF_MSH, 0x3c),
6083 BPF_STMT(BPF_LDX | BPF_B | BPF_MSH, 0x3d),
6084 BPF_STMT(BPF_LDX | BPF_B | BPF_MSH, 0x3e),
6085 BPF_STMT(BPF_LDX | BPF_B | BPF_MSH, 0x3f),
6086 BPF_STMT(BPF_RET | BPF_A, 0x0),
6089 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
6090 { {0x40, 0x175e9d63 }, },
6093 "LDX_MSH standalone, test result 1",
6095 BPF_STMT(BPF_LD | BPF_IMM, 0xffeebbaa),
6096 BPF_STMT(BPF_LDX | BPF_B | BPF_MSH, 0x3c),
6097 BPF_STMT(BPF_MISC | BPF_TXA, 0),
6098 BPF_STMT(BPF_RET | BPF_A, 0x0),
6101 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
6105 "LDX_MSH standalone, test result 2",
6107 BPF_STMT(BPF_LD | BPF_IMM, 0xffeebbaa),
6108 BPF_STMT(BPF_LDX | BPF_B | BPF_MSH, 0x3e),
6109 BPF_STMT(BPF_MISC | BPF_TXA, 0),
6110 BPF_STMT(BPF_RET | BPF_A, 0x0),
6113 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
6117 "LDX_MSH standalone, negative offset",
6119 BPF_STMT(BPF_LD | BPF_IMM, 0xffeebbaa),
6120 BPF_STMT(BPF_LDX | BPF_B | BPF_MSH, -1),
6121 BPF_STMT(BPF_MISC | BPF_TXA, 0),
6122 BPF_STMT(BPF_RET | BPF_A, 0x0),
6125 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
6129 "LDX_MSH standalone, negative offset 2",
6131 BPF_STMT(BPF_LD | BPF_IMM, 0xffeebbaa),
6132 BPF_STMT(BPF_LDX | BPF_B | BPF_MSH, SKF_LL_OFF + 0x3e),
6133 BPF_STMT(BPF_MISC | BPF_TXA, 0),
6134 BPF_STMT(BPF_RET | BPF_A, 0x0),
6137 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
6141 "LDX_MSH standalone, out of bounds",
6143 BPF_STMT(BPF_LD | BPF_IMM, 0xffeebbaa),
6144 BPF_STMT(BPF_LDX | BPF_B | BPF_MSH, 0x40),
6145 BPF_STMT(BPF_MISC | BPF_TXA, 0),
6146 BPF_STMT(BPF_RET | BPF_A, 0x0),
6149 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
6153 * verify that the interpreter or JIT correctly sets A and X
6164 BPF_STMT(BPF_LD | BPF_IMM, 0x42),
6165 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
6166 BPF_STMT(BPF_RET | BPF_A, 0x0),
6168 CLASSIC | FLAG_NO_DATA,
6179 BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 0x42),
6180 BPF_STMT(BPF_RET | BPF_A, 0x0),
6182 CLASSIC | FLAG_NO_DATA,
6194 BPF_STMT(BPF_LD | BPF_IMM, 0x66),
6195 BPF_STMT(BPF_ALU | BPF_SUB | BPF_X, 0),
6196 BPF_STMT(BPF_RET | BPF_A, 0x0),
6198 CLASSIC | FLAG_NO_DATA,
6209 BPF_STMT(BPF_ALU | BPF_SUB | BPF_K, -0x66),
6210 BPF_STMT(BPF_RET | BPF_A, 0x0),
6212 CLASSIC | FLAG_NO_DATA,
6224 BPF_STMT(BPF_LD | BPF_IMM, 0x42),
6225 BPF_STMT(BPF_ALU | BPF_MUL | BPF_X, 0),
6226 BPF_STMT(BPF_RET | BPF_A, 0x0),
6228 CLASSIC | FLAG_NO_DATA,
6239 BPF_STMT(BPF_ALU | BPF_MUL | BPF_K, 0x66),
6240 BPF_STMT(BPF_RET | BPF_A, 0x0),
6242 CLASSIC | FLAG_NO_DATA,
6251 * A = A / X ; this halt the filter execution if X is 0
6254 BPF_STMT(BPF_LD | BPF_IMM, 0x42),
6255 BPF_STMT(BPF_ALU | BPF_DIV | BPF_X, 0),
6256 BPF_STMT(BPF_RET | BPF_K, 0x42),
6258 CLASSIC | FLAG_NO_DATA,
6269 BPF_STMT(BPF_ALU | BPF_DIV | BPF_K, 0x1),
6270 BPF_STMT(BPF_RET | BPF_A, 0x0),
6272 CLASSIC | FLAG_NO_DATA,
6281 * A = A mod X ; this halt the filter execution if X is 0
6284 BPF_STMT(BPF_LD | BPF_IMM, 0x42),
6285 BPF_STMT(BPF_ALU | BPF_MOD | BPF_X, 0),
6286 BPF_STMT(BPF_RET | BPF_K, 0x42),
6288 CLASSIC | FLAG_NO_DATA,
6299 BPF_STMT(BPF_ALU | BPF_MOD | BPF_K, 0x1),
6300 BPF_STMT(BPF_RET | BPF_A, 0x0),
6302 CLASSIC | FLAG_NO_DATA,
6314 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x0, 0, 1),
6315 BPF_STMT(BPF_RET | BPF_K, 0x42),
6316 BPF_STMT(BPF_RET | BPF_K, 0x66),
6318 CLASSIC | FLAG_NO_DATA,
6331 BPF_STMT(BPF_LD | BPF_IMM, 0x0),
6332 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_X, 0x0, 0, 1),
6333 BPF_STMT(BPF_RET | BPF_K, 0x42),
6334 BPF_STMT(BPF_RET | BPF_K, 0x66),
6336 CLASSIC | FLAG_NO_DATA,
6340 /* Checking interpreter vs JIT wrt signed extended imms. */
6342 "JNE signed compare, test 1",
6344 BPF_ALU32_IMM(BPF_MOV, R1, 0xfefbbc12),
6345 BPF_ALU32_IMM(BPF_MOV, R3, 0xffff0000),
6346 BPF_MOV64_REG(R2, R1),
6347 BPF_ALU64_REG(BPF_AND, R2, R3),
6348 BPF_ALU32_IMM(BPF_MOV, R0, 1),
6349 BPF_JMP_IMM(BPF_JNE, R2, -17104896, 1),
6350 BPF_ALU32_IMM(BPF_MOV, R0, 2),
6358 "JNE signed compare, test 2",
6360 BPF_ALU32_IMM(BPF_MOV, R1, 0xfefbbc12),
6361 BPF_ALU32_IMM(BPF_MOV, R3, 0xffff0000),
6362 BPF_MOV64_REG(R2, R1),
6363 BPF_ALU64_REG(BPF_AND, R2, R3),
6364 BPF_ALU32_IMM(BPF_MOV, R0, 1),
6365 BPF_JMP_IMM(BPF_JNE, R2, 0xfefb0000, 1),
6366 BPF_ALU32_IMM(BPF_MOV, R0, 2),
6374 "JNE signed compare, test 3",
6376 BPF_ALU32_IMM(BPF_MOV, R1, 0xfefbbc12),
6377 BPF_ALU32_IMM(BPF_MOV, R3, 0xffff0000),
6378 BPF_ALU32_IMM(BPF_MOV, R4, 0xfefb0000),
6379 BPF_MOV64_REG(R2, R1),
6380 BPF_ALU64_REG(BPF_AND, R2, R3),
6381 BPF_ALU32_IMM(BPF_MOV, R0, 1),
6382 BPF_JMP_REG(BPF_JNE, R2, R4, 1),
6383 BPF_ALU32_IMM(BPF_MOV, R0, 2),
6391 "JNE signed compare, test 4",
6393 BPF_LD_IMM64(R1, -17104896),
6394 BPF_ALU32_IMM(BPF_MOV, R0, 1),
6395 BPF_JMP_IMM(BPF_JNE, R1, -17104896, 1),
6396 BPF_ALU32_IMM(BPF_MOV, R0, 2),
6404 "JNE signed compare, test 5",
6406 BPF_LD_IMM64(R1, 0xfefb0000),
6407 BPF_ALU32_IMM(BPF_MOV, R0, 1),
6408 BPF_JMP_IMM(BPF_JNE, R1, 0xfefb0000, 1),
6409 BPF_ALU32_IMM(BPF_MOV, R0, 2),
6417 "JNE signed compare, test 6",
6419 BPF_LD_IMM64(R1, 0x7efb0000),
6420 BPF_ALU32_IMM(BPF_MOV, R0, 1),
6421 BPF_JMP_IMM(BPF_JNE, R1, 0x7efb0000, 1),
6422 BPF_ALU32_IMM(BPF_MOV, R0, 2),
6430 "JNE signed compare, test 7",
6432 BPF_STMT(BPF_LD | BPF_IMM, 0xffff0000),
6433 BPF_STMT(BPF_MISC | BPF_TAX, 0),
6434 BPF_STMT(BPF_LD | BPF_IMM, 0xfefbbc12),
6435 BPF_STMT(BPF_ALU | BPF_AND | BPF_X, 0),
6436 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0xfefb0000, 1, 0),
6437 BPF_STMT(BPF_RET | BPF_K, 1),
6438 BPF_STMT(BPF_RET | BPF_K, 2),
6440 CLASSIC | FLAG_NO_DATA,
6446 static struct net_device dev;
6448 static struct sk_buff *populate_skb(char *buf, int size)
6450 struct sk_buff *skb;
6452 if (size >= MAX_DATA)
6455 skb = alloc_skb(MAX_DATA, GFP_KERNEL);
6459 __skb_put_data(skb, buf, size);
6461 /* Initialize a fake skb with test pattern. */
6462 skb_reset_mac_header(skb);
6463 skb->protocol = htons(ETH_P_IP);
6464 skb->pkt_type = SKB_TYPE;
6465 skb->mark = SKB_MARK;
6466 skb->hash = SKB_HASH;
6467 skb->queue_mapping = SKB_QUEUE_MAP;
6468 skb->vlan_tci = SKB_VLAN_TCI;
6469 skb->vlan_present = SKB_VLAN_PRESENT;
6470 skb->vlan_proto = htons(ETH_P_IP);
6471 dev_net_set(&dev, &init_net);
6473 skb->dev->ifindex = SKB_DEV_IFINDEX;
6474 skb->dev->type = SKB_DEV_TYPE;
6475 skb_set_network_header(skb, min(size, ETH_HLEN));
6480 static void *generate_test_data(struct bpf_test *test, int sub)
6482 struct sk_buff *skb;
6485 if (test->aux & FLAG_NO_DATA)
6488 /* Test case expects an skb, so populate one. Various
6489 * subtests generate skbs of different sizes based on
6492 skb = populate_skb(test->data, test->test[sub].data_size);
6496 if (test->aux & FLAG_SKB_FRAG) {
6498 * when the test requires a fragmented skb, add a
6499 * single fragment to the skb, filled with
6504 page = alloc_page(GFP_KERNEL);
6512 memcpy(ptr, test->frag_data, MAX_DATA);
6514 skb_add_rx_frag(skb, 0, page, 0, MAX_DATA, MAX_DATA);
6526 static void release_test_data(const struct bpf_test *test, void *data)
6528 if (test->aux & FLAG_NO_DATA)
6534 static int filter_length(int which)
6536 struct sock_filter *fp;
6539 if (tests[which].fill_helper)
6540 return tests[which].u.ptr.len;
6542 fp = tests[which].u.insns;
6543 for (len = MAX_INSNS - 1; len > 0; --len)
6544 if (fp[len].code != 0 || fp[len].k != 0)
6550 static void *filter_pointer(int which)
6552 if (tests[which].fill_helper)
6553 return tests[which].u.ptr.insns;
6555 return tests[which].u.insns;
6558 static struct bpf_prog *generate_filter(int which, int *err)
6560 __u8 test_type = tests[which].aux & TEST_TYPE_MASK;
6561 unsigned int flen = filter_length(which);
6562 void *fptr = filter_pointer(which);
6563 struct sock_fprog_kern fprog;
6564 struct bpf_prog *fp;
6566 switch (test_type) {
6568 fprog.filter = fptr;
6571 *err = bpf_prog_create(&fp, &fprog);
6572 if (tests[which].aux & FLAG_EXPECTED_FAIL) {
6573 if (*err == tests[which].expected_errcode) {
6575 /* Verifier rejected filter as expected. */
6579 pr_cont("UNEXPECTED_PASS\n");
6580 /* Verifier didn't reject the test that's
6581 * bad enough, just return!
6588 pr_cont("FAIL to prog_create err=%d len=%d\n",
6595 fp = bpf_prog_alloc(bpf_prog_size(flen), 0);
6597 pr_cont("UNEXPECTED_FAIL no memory left\n");
6603 /* Type doesn't really matter here as long as it's not unspec. */
6604 fp->type = BPF_PROG_TYPE_SOCKET_FILTER;
6605 memcpy(fp->insnsi, fptr, fp->len * sizeof(struct bpf_insn));
6606 fp->aux->stack_depth = tests[which].stack_depth;
6608 /* We cannot error here as we don't need type compatibility
6611 fp = bpf_prog_select_runtime(fp, err);
6613 pr_cont("FAIL to select_runtime err=%d\n", *err);
6623 static void release_filter(struct bpf_prog *fp, int which)
6625 __u8 test_type = tests[which].aux & TEST_TYPE_MASK;
6627 switch (test_type) {
6629 bpf_prog_destroy(fp);
6637 static int __run_one(const struct bpf_prog *fp, const void *data,
6638 int runs, u64 *duration)
6644 start = ktime_get_ns();
6646 for (i = 0; i < runs; i++)
6647 ret = BPF_PROG_RUN(fp, data);
6649 finish = ktime_get_ns();
6652 *duration = finish - start;
6653 do_div(*duration, runs);
6658 static int run_one(const struct bpf_prog *fp, struct bpf_test *test)
6660 int err_cnt = 0, i, runs = MAX_TESTRUNS;
6662 for (i = 0; i < MAX_SUBTESTS; i++) {
6667 if (test->test[i].data_size == 0 &&
6668 test->test[i].result == 0)
6671 data = generate_test_data(test, i);
6672 if (!data && !(test->aux & FLAG_NO_DATA)) {
6673 pr_cont("data generation failed ");
6677 ret = __run_one(fp, data, runs, &duration);
6678 release_test_data(test, data);
6680 if (ret == test->test[i].result) {
6681 pr_cont("%lld ", duration);
6683 pr_cont("ret %d != %d ", ret,
6684 test->test[i].result);
6692 static char test_name[64];
6693 module_param_string(test_name, test_name, sizeof(test_name), 0);
6695 static int test_id = -1;
6696 module_param(test_id, int, 0);
6698 static int test_range[2] = { 0, ARRAY_SIZE(tests) - 1 };
6699 module_param_array(test_range, int, NULL, 0);
6701 static __init int find_test_index(const char *test_name)
6705 for (i = 0; i < ARRAY_SIZE(tests); i++) {
6706 if (!strcmp(tests[i].descr, test_name))
6712 static __init int prepare_bpf_tests(void)
6718 * if a test_id was specified, use test_range to
6719 * cover only that test.
6721 if (test_id >= ARRAY_SIZE(tests)) {
6722 pr_err("test_bpf: invalid test_id specified.\n");
6726 test_range[0] = test_id;
6727 test_range[1] = test_id;
6728 } else if (*test_name) {
6730 * if a test_name was specified, find it and setup
6731 * test_range to cover only that test.
6733 int idx = find_test_index(test_name);
6736 pr_err("test_bpf: no test named '%s' found.\n",
6740 test_range[0] = idx;
6741 test_range[1] = idx;
6744 * check that the supplied test_range is valid.
6746 if (test_range[0] >= ARRAY_SIZE(tests) ||
6747 test_range[1] >= ARRAY_SIZE(tests) ||
6748 test_range[0] < 0 || test_range[1] < 0) {
6749 pr_err("test_bpf: test_range is out of bound.\n");
6753 if (test_range[1] < test_range[0]) {
6754 pr_err("test_bpf: test_range is ending before it starts.\n");
6759 for (i = 0; i < ARRAY_SIZE(tests); i++) {
6760 if (tests[i].fill_helper &&
6761 tests[i].fill_helper(&tests[i]) < 0)
6768 static __init void destroy_bpf_tests(void)
6772 for (i = 0; i < ARRAY_SIZE(tests); i++) {
6773 if (tests[i].fill_helper)
6774 kfree(tests[i].u.ptr.insns);
6778 static bool exclude_test(int test_id)
6780 return test_id < test_range[0] || test_id > test_range[1];
6783 static __init struct sk_buff *build_test_skb(void)
6785 u32 headroom = NET_SKB_PAD + NET_IP_ALIGN + ETH_HLEN;
6786 struct sk_buff *skb[2];
6787 struct page *page[2];
6788 int i, data_size = 8;
6790 for (i = 0; i < 2; i++) {
6791 page[i] = alloc_page(GFP_KERNEL);
6799 /* this will set skb[i]->head_frag */
6800 skb[i] = dev_alloc_skb(headroom + data_size);
6808 skb_reserve(skb[i], headroom);
6809 skb_put(skb[i], data_size);
6810 skb[i]->protocol = htons(ETH_P_IP);
6811 skb_reset_network_header(skb[i]);
6812 skb_set_mac_header(skb[i], -ETH_HLEN);
6814 skb_add_rx_frag(skb[i], 0, page[i], 0, 64, 64);
6815 // skb_headlen(skb[i]): 8, skb[i]->head_frag = 1
6819 skb_shinfo(skb[0])->gso_size = 1448;
6820 skb_shinfo(skb[0])->gso_type = SKB_GSO_TCPV4;
6821 skb_shinfo(skb[0])->gso_type |= SKB_GSO_DODGY;
6822 skb_shinfo(skb[0])->gso_segs = 0;
6823 skb_shinfo(skb[0])->frag_list = skb[1];
6825 /* adjust skb[0]'s len */
6826 skb[0]->len += skb[1]->len;
6827 skb[0]->data_len += skb[1]->data_len;
6828 skb[0]->truesize += skb[1]->truesize;
6833 __free_page(page[1]);
6837 __free_page(page[0]);
6842 static __init struct sk_buff *build_test_skb_linear_no_head_frag(void)
6844 unsigned int alloc_size = 2000;
6845 unsigned int headroom = 102, doffset = 72, data_size = 1308;
6846 struct sk_buff *skb[2];
6849 /* skbs linked in a frag_list, both with linear data, with head_frag=0
6850 * (data allocated by kmalloc), both have tcp data of 1308 bytes
6851 * (total payload is 2616 bytes).
6852 * Data offset is 72 bytes (40 ipv6 hdr, 32 tcp hdr). Some headroom.
6854 for (i = 0; i < 2; i++) {
6855 skb[i] = alloc_skb(alloc_size, GFP_KERNEL);
6863 skb[i]->protocol = htons(ETH_P_IPV6);
6864 skb_reserve(skb[i], headroom);
6865 skb_put(skb[i], doffset + data_size);
6866 skb_reset_network_header(skb[i]);
6868 skb_reset_mac_header(skb[i]);
6870 skb_set_mac_header(skb[i], -ETH_HLEN);
6871 __skb_pull(skb[i], doffset);
6875 * mimic bpf_skb_proto_4_to_6, which resets gso_segs and assigns a
6878 skb_shinfo(skb[0])->gso_size = 1288;
6879 skb_shinfo(skb[0])->gso_type = SKB_GSO_TCPV6 | SKB_GSO_DODGY;
6880 skb_shinfo(skb[0])->gso_segs = 0;
6881 skb_shinfo(skb[0])->frag_list = skb[1];
6883 /* adjust skb[0]'s len */
6884 skb[0]->len += skb[1]->len;
6885 skb[0]->data_len += skb[1]->len;
6886 skb[0]->truesize += skb[1]->truesize;
6896 struct skb_segment_test {
6898 struct sk_buff *(*build_skb)(void);
6899 netdev_features_t features;
6902 static struct skb_segment_test skb_segment_tests[] __initconst = {
6904 .descr = "gso_with_rx_frags",
6905 .build_skb = build_test_skb,
6906 .features = NETIF_F_SG | NETIF_F_GSO_PARTIAL | NETIF_F_IP_CSUM |
6907 NETIF_F_IPV6_CSUM | NETIF_F_RXCSUM
6910 .descr = "gso_linear_no_head_frag",
6911 .build_skb = build_test_skb_linear_no_head_frag,
6912 .features = NETIF_F_SG | NETIF_F_FRAGLIST |
6913 NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_GSO |
6914 NETIF_F_LLTX_BIT | NETIF_F_GRO |
6915 NETIF_F_IPV6_CSUM | NETIF_F_RXCSUM |
6916 NETIF_F_HW_VLAN_STAG_TX_BIT
6920 static __init int test_skb_segment_single(const struct skb_segment_test *test)
6922 struct sk_buff *skb, *segs;
6925 skb = test->build_skb();
6927 pr_info("%s: failed to build_test_skb", __func__);
6931 segs = skb_segment(skb, test->features);
6932 if (!IS_ERR(segs)) {
6933 kfree_skb_list(segs);
6941 static __init int test_skb_segment(void)
6943 int i, err_cnt = 0, pass_cnt = 0;
6945 for (i = 0; i < ARRAY_SIZE(skb_segment_tests); i++) {
6946 const struct skb_segment_test *test = &skb_segment_tests[i];
6948 pr_info("#%d %s ", i, test->descr);
6950 if (test_skb_segment_single(test)) {
6959 pr_info("%s: Summary: %d PASSED, %d FAILED\n", __func__,
6961 return err_cnt ? -EINVAL : 0;
6964 static __init int test_bpf(void)
6966 int i, err_cnt = 0, pass_cnt = 0;
6967 int jit_cnt = 0, run_cnt = 0;
6969 for (i = 0; i < ARRAY_SIZE(tests); i++) {
6970 struct bpf_prog *fp;
6974 if (exclude_test(i))
6977 pr_info("#%d %s ", i, tests[i].descr);
6979 fp = generate_filter(i, &err);
6989 pr_cont("jited:%u ", fp->jited);
6995 err = run_one(fp, &tests[i]);
6996 release_filter(fp, i);
6999 pr_cont("FAIL (%d times)\n", err);
7007 pr_info("Summary: %d PASSED, %d FAILED, [%d/%d JIT'ed]\n",
7008 pass_cnt, err_cnt, jit_cnt, run_cnt);
7010 return err_cnt ? -EINVAL : 0;
7013 static int __init test_bpf_init(void)
7017 ret = prepare_bpf_tests();
7022 destroy_bpf_tests();
7026 return test_skb_segment();
7029 static void __exit test_bpf_exit(void)
7033 module_init(test_bpf_init);
7034 module_exit(test_bpf_exit);
7036 MODULE_LICENSE("GPL");