errseq: Always report a writeback error once
[platform/kernel/linux-exynos.git] / lib / test_bpf.c
1 /*
2  * Testsuite for BPF interpreter and BPF JIT compiler
3  *
4  * Copyright (c) 2011-2014 PLUMgrid, http://plumgrid.com
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of version 2 of the GNU General Public
8  * License as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * General Public License for more details.
14  */
15
16 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
17
18 #include <linux/init.h>
19 #include <linux/module.h>
20 #include <linux/filter.h>
21 #include <linux/bpf.h>
22 #include <linux/skbuff.h>
23 #include <linux/netdevice.h>
24 #include <linux/if_vlan.h>
25 #include <linux/random.h>
26 #include <linux/highmem.h>
27
28 /* General test specific settings */
29 #define MAX_SUBTESTS    3
30 #define MAX_TESTRUNS    10000
31 #define MAX_DATA        128
32 #define MAX_INSNS       512
33 #define MAX_K           0xffffFFFF
34
35 /* Few constants used to init test 'skb' */
36 #define SKB_TYPE        3
37 #define SKB_MARK        0x1234aaaa
38 #define SKB_HASH        0x1234aaab
39 #define SKB_QUEUE_MAP   123
40 #define SKB_VLAN_TCI    0xffff
41 #define SKB_DEV_IFINDEX 577
42 #define SKB_DEV_TYPE    588
43
44 /* Redefine REGs to make tests less verbose */
45 #define R0              BPF_REG_0
46 #define R1              BPF_REG_1
47 #define R2              BPF_REG_2
48 #define R3              BPF_REG_3
49 #define R4              BPF_REG_4
50 #define R5              BPF_REG_5
51 #define R6              BPF_REG_6
52 #define R7              BPF_REG_7
53 #define R8              BPF_REG_8
54 #define R9              BPF_REG_9
55 #define R10             BPF_REG_10
56
57 /* Flags that can be passed to test cases */
58 #define FLAG_NO_DATA            BIT(0)
59 #define FLAG_EXPECTED_FAIL      BIT(1)
60 #define FLAG_SKB_FRAG           BIT(2)
61
62 enum {
63         CLASSIC  = BIT(6),      /* Old BPF instructions only. */
64         INTERNAL = BIT(7),      /* Extended instruction set.  */
65 };
66
67 #define TEST_TYPE_MASK          (CLASSIC | INTERNAL)
68
69 struct bpf_test {
70         const char *descr;
71         union {
72                 struct sock_filter insns[MAX_INSNS];
73                 struct bpf_insn insns_int[MAX_INSNS];
74                 struct {
75                         void *insns;
76                         unsigned int len;
77                 } ptr;
78         } u;
79         __u8 aux;
80         __u8 data[MAX_DATA];
81         struct {
82                 int data_size;
83                 __u32 result;
84         } test[MAX_SUBTESTS];
85         int (*fill_helper)(struct bpf_test *self);
86         int expected_errcode; /* used when FLAG_EXPECTED_FAIL is set in the aux */
87         __u8 frag_data[MAX_DATA];
88         int stack_depth; /* for eBPF only, since tests don't call verifier */
89 };
90
91 /* Large test cases need separate allocation and fill handler. */
92
93 static int bpf_fill_maxinsns1(struct bpf_test *self)
94 {
95         unsigned int len = BPF_MAXINSNS;
96         struct sock_filter *insn;
97         __u32 k = ~0;
98         int i;
99
100         insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL);
101         if (!insn)
102                 return -ENOMEM;
103
104         for (i = 0; i < len; i++, k--)
105                 insn[i] = __BPF_STMT(BPF_RET | BPF_K, k);
106
107         self->u.ptr.insns = insn;
108         self->u.ptr.len = len;
109
110         return 0;
111 }
112
113 static int bpf_fill_maxinsns2(struct bpf_test *self)
114 {
115         unsigned int len = BPF_MAXINSNS;
116         struct sock_filter *insn;
117         int i;
118
119         insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL);
120         if (!insn)
121                 return -ENOMEM;
122
123         for (i = 0; i < len; i++)
124                 insn[i] = __BPF_STMT(BPF_RET | BPF_K, 0xfefefefe);
125
126         self->u.ptr.insns = insn;
127         self->u.ptr.len = len;
128
129         return 0;
130 }
131
132 static int bpf_fill_maxinsns3(struct bpf_test *self)
133 {
134         unsigned int len = BPF_MAXINSNS;
135         struct sock_filter *insn;
136         struct rnd_state rnd;
137         int i;
138
139         insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL);
140         if (!insn)
141                 return -ENOMEM;
142
143         prandom_seed_state(&rnd, 3141592653589793238ULL);
144
145         for (i = 0; i < len - 1; i++) {
146                 __u32 k = prandom_u32_state(&rnd);
147
148                 insn[i] = __BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, k);
149         }
150
151         insn[len - 1] = __BPF_STMT(BPF_RET | BPF_A, 0);
152
153         self->u.ptr.insns = insn;
154         self->u.ptr.len = len;
155
156         return 0;
157 }
158
159 static int bpf_fill_maxinsns4(struct bpf_test *self)
160 {
161         unsigned int len = BPF_MAXINSNS + 1;
162         struct sock_filter *insn;
163         int i;
164
165         insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL);
166         if (!insn)
167                 return -ENOMEM;
168
169         for (i = 0; i < len; i++)
170                 insn[i] = __BPF_STMT(BPF_RET | BPF_K, 0xfefefefe);
171
172         self->u.ptr.insns = insn;
173         self->u.ptr.len = len;
174
175         return 0;
176 }
177
178 static int bpf_fill_maxinsns5(struct bpf_test *self)
179 {
180         unsigned int len = BPF_MAXINSNS;
181         struct sock_filter *insn;
182         int i;
183
184         insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL);
185         if (!insn)
186                 return -ENOMEM;
187
188         insn[0] = __BPF_JUMP(BPF_JMP | BPF_JA, len - 2, 0, 0);
189
190         for (i = 1; i < len - 1; i++)
191                 insn[i] = __BPF_STMT(BPF_RET | BPF_K, 0xfefefefe);
192
193         insn[len - 1] = __BPF_STMT(BPF_RET | BPF_K, 0xabababab);
194
195         self->u.ptr.insns = insn;
196         self->u.ptr.len = len;
197
198         return 0;
199 }
200
201 static int bpf_fill_maxinsns6(struct bpf_test *self)
202 {
203         unsigned int len = BPF_MAXINSNS;
204         struct sock_filter *insn;
205         int i;
206
207         insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL);
208         if (!insn)
209                 return -ENOMEM;
210
211         for (i = 0; i < len - 1; i++)
212                 insn[i] = __BPF_STMT(BPF_LD | BPF_W | BPF_ABS, SKF_AD_OFF +
213                                      SKF_AD_VLAN_TAG_PRESENT);
214
215         insn[len - 1] = __BPF_STMT(BPF_RET | BPF_A, 0);
216
217         self->u.ptr.insns = insn;
218         self->u.ptr.len = len;
219
220         return 0;
221 }
222
223 static int bpf_fill_maxinsns7(struct bpf_test *self)
224 {
225         unsigned int len = BPF_MAXINSNS;
226         struct sock_filter *insn;
227         int i;
228
229         insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL);
230         if (!insn)
231                 return -ENOMEM;
232
233         for (i = 0; i < len - 4; i++)
234                 insn[i] = __BPF_STMT(BPF_LD | BPF_W | BPF_ABS, SKF_AD_OFF +
235                                      SKF_AD_CPU);
236
237         insn[len - 4] = __BPF_STMT(BPF_MISC | BPF_TAX, 0);
238         insn[len - 3] = __BPF_STMT(BPF_LD | BPF_W | BPF_ABS, SKF_AD_OFF +
239                                    SKF_AD_CPU);
240         insn[len - 2] = __BPF_STMT(BPF_ALU | BPF_SUB | BPF_X, 0);
241         insn[len - 1] = __BPF_STMT(BPF_RET | BPF_A, 0);
242
243         self->u.ptr.insns = insn;
244         self->u.ptr.len = len;
245
246         return 0;
247 }
248
249 static int bpf_fill_maxinsns8(struct bpf_test *self)
250 {
251         unsigned int len = BPF_MAXINSNS;
252         struct sock_filter *insn;
253         int i, jmp_off = len - 3;
254
255         insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL);
256         if (!insn)
257                 return -ENOMEM;
258
259         insn[0] = __BPF_STMT(BPF_LD | BPF_IMM, 0xffffffff);
260
261         for (i = 1; i < len - 1; i++)
262                 insn[i] = __BPF_JUMP(BPF_JMP | BPF_JGT, 0xffffffff, jmp_off--, 0);
263
264         insn[len - 1] = __BPF_STMT(BPF_RET | BPF_A, 0);
265
266         self->u.ptr.insns = insn;
267         self->u.ptr.len = len;
268
269         return 0;
270 }
271
272 static int bpf_fill_maxinsns9(struct bpf_test *self)
273 {
274         unsigned int len = BPF_MAXINSNS;
275         struct bpf_insn *insn;
276         int i;
277
278         insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL);
279         if (!insn)
280                 return -ENOMEM;
281
282         insn[0] = BPF_JMP_IMM(BPF_JA, 0, 0, len - 2);
283         insn[1] = BPF_ALU32_IMM(BPF_MOV, R0, 0xcbababab);
284         insn[2] = BPF_EXIT_INSN();
285
286         for (i = 3; i < len - 2; i++)
287                 insn[i] = BPF_ALU32_IMM(BPF_MOV, R0, 0xfefefefe);
288
289         insn[len - 2] = BPF_EXIT_INSN();
290         insn[len - 1] = BPF_JMP_IMM(BPF_JA, 0, 0, -(len - 1));
291
292         self->u.ptr.insns = insn;
293         self->u.ptr.len = len;
294
295         return 0;
296 }
297
298 static int bpf_fill_maxinsns10(struct bpf_test *self)
299 {
300         unsigned int len = BPF_MAXINSNS, hlen = len - 2;
301         struct bpf_insn *insn;
302         int i;
303
304         insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL);
305         if (!insn)
306                 return -ENOMEM;
307
308         for (i = 0; i < hlen / 2; i++)
309                 insn[i] = BPF_JMP_IMM(BPF_JA, 0, 0, hlen - 2 - 2 * i);
310         for (i = hlen - 1; i > hlen / 2; i--)
311                 insn[i] = BPF_JMP_IMM(BPF_JA, 0, 0, hlen - 1 - 2 * i);
312
313         insn[hlen / 2] = BPF_JMP_IMM(BPF_JA, 0, 0, hlen / 2 - 1);
314         insn[hlen]     = BPF_ALU32_IMM(BPF_MOV, R0, 0xabababac);
315         insn[hlen + 1] = BPF_EXIT_INSN();
316
317         self->u.ptr.insns = insn;
318         self->u.ptr.len = len;
319
320         return 0;
321 }
322
323 static int __bpf_fill_ja(struct bpf_test *self, unsigned int len,
324                          unsigned int plen)
325 {
326         struct sock_filter *insn;
327         unsigned int rlen;
328         int i, j;
329
330         insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL);
331         if (!insn)
332                 return -ENOMEM;
333
334         rlen = (len % plen) - 1;
335
336         for (i = 0; i + plen < len; i += plen)
337                 for (j = 0; j < plen; j++)
338                         insn[i + j] = __BPF_JUMP(BPF_JMP | BPF_JA,
339                                                  plen - 1 - j, 0, 0);
340         for (j = 0; j < rlen; j++)
341                 insn[i + j] = __BPF_JUMP(BPF_JMP | BPF_JA, rlen - 1 - j,
342                                          0, 0);
343
344         insn[len - 1] = __BPF_STMT(BPF_RET | BPF_K, 0xababcbac);
345
346         self->u.ptr.insns = insn;
347         self->u.ptr.len = len;
348
349         return 0;
350 }
351
352 static int bpf_fill_maxinsns11(struct bpf_test *self)
353 {
354         /* Hits 70 passes on x86_64, so cannot get JITed there. */
355         return __bpf_fill_ja(self, BPF_MAXINSNS, 68);
356 }
357
358 static int bpf_fill_ja(struct bpf_test *self)
359 {
360         /* Hits exactly 11 passes on x86_64 JIT. */
361         return __bpf_fill_ja(self, 12, 9);
362 }
363
364 static int bpf_fill_ld_abs_get_processor_id(struct bpf_test *self)
365 {
366         unsigned int len = BPF_MAXINSNS;
367         struct sock_filter *insn;
368         int i;
369
370         insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL);
371         if (!insn)
372                 return -ENOMEM;
373
374         for (i = 0; i < len - 1; i += 2) {
375                 insn[i] = __BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 0);
376                 insn[i + 1] = __BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
377                                          SKF_AD_OFF + SKF_AD_CPU);
378         }
379
380         insn[len - 1] = __BPF_STMT(BPF_RET | BPF_K, 0xbee);
381
382         self->u.ptr.insns = insn;
383         self->u.ptr.len = len;
384
385         return 0;
386 }
387
388 #define PUSH_CNT 68
389 /* test: {skb->data[0], vlan_push} x 68 + {skb->data[0], vlan_pop} x 68 */
390 static int bpf_fill_ld_abs_vlan_push_pop(struct bpf_test *self)
391 {
392         unsigned int len = BPF_MAXINSNS;
393         struct bpf_insn *insn;
394         int i = 0, j, k = 0;
395
396         insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL);
397         if (!insn)
398                 return -ENOMEM;
399
400         insn[i++] = BPF_MOV64_REG(R6, R1);
401 loop:
402         for (j = 0; j < PUSH_CNT; j++) {
403                 insn[i++] = BPF_LD_ABS(BPF_B, 0);
404                 insn[i] = BPF_JMP_IMM(BPF_JNE, R0, 0x34, len - i - 2);
405                 i++;
406                 insn[i++] = BPF_MOV64_REG(R1, R6);
407                 insn[i++] = BPF_MOV64_IMM(R2, 1);
408                 insn[i++] = BPF_MOV64_IMM(R3, 2);
409                 insn[i++] = BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
410                                          bpf_skb_vlan_push_proto.func - __bpf_call_base);
411                 insn[i] = BPF_JMP_IMM(BPF_JNE, R0, 0, len - i - 2);
412                 i++;
413         }
414
415         for (j = 0; j < PUSH_CNT; j++) {
416                 insn[i++] = BPF_LD_ABS(BPF_B, 0);
417                 insn[i] = BPF_JMP_IMM(BPF_JNE, R0, 0x34, len - i - 2);
418                 i++;
419                 insn[i++] = BPF_MOV64_REG(R1, R6);
420                 insn[i++] = BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
421                                          bpf_skb_vlan_pop_proto.func - __bpf_call_base);
422                 insn[i] = BPF_JMP_IMM(BPF_JNE, R0, 0, len - i - 2);
423                 i++;
424         }
425         if (++k < 5)
426                 goto loop;
427
428         for (; i < len - 1; i++)
429                 insn[i] = BPF_ALU32_IMM(BPF_MOV, R0, 0xbef);
430
431         insn[len - 1] = BPF_EXIT_INSN();
432
433         self->u.ptr.insns = insn;
434         self->u.ptr.len = len;
435
436         return 0;
437 }
438
439 static int bpf_fill_jump_around_ld_abs(struct bpf_test *self)
440 {
441         unsigned int len = BPF_MAXINSNS;
442         struct bpf_insn *insn;
443         int i = 0;
444
445         insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL);
446         if (!insn)
447                 return -ENOMEM;
448
449         insn[i++] = BPF_MOV64_REG(R6, R1);
450         insn[i++] = BPF_LD_ABS(BPF_B, 0);
451         insn[i] = BPF_JMP_IMM(BPF_JEQ, R0, 10, len - i - 2);
452         i++;
453         while (i < len - 1)
454                 insn[i++] = BPF_LD_ABS(BPF_B, 1);
455         insn[i] = BPF_EXIT_INSN();
456
457         self->u.ptr.insns = insn;
458         self->u.ptr.len = len;
459
460         return 0;
461 }
462
463 static int __bpf_fill_stxdw(struct bpf_test *self, int size)
464 {
465         unsigned int len = BPF_MAXINSNS;
466         struct bpf_insn *insn;
467         int i;
468
469         insn = kmalloc_array(len, sizeof(*insn), GFP_KERNEL);
470         if (!insn)
471                 return -ENOMEM;
472
473         insn[0] = BPF_ALU32_IMM(BPF_MOV, R0, 1);
474         insn[1] = BPF_ST_MEM(size, R10, -40, 42);
475
476         for (i = 2; i < len - 2; i++)
477                 insn[i] = BPF_STX_XADD(size, R10, R0, -40);
478
479         insn[len - 2] = BPF_LDX_MEM(size, R0, R10, -40);
480         insn[len - 1] = BPF_EXIT_INSN();
481
482         self->u.ptr.insns = insn;
483         self->u.ptr.len = len;
484         self->stack_depth = 40;
485
486         return 0;
487 }
488
489 static int bpf_fill_stxw(struct bpf_test *self)
490 {
491         return __bpf_fill_stxdw(self, BPF_W);
492 }
493
494 static int bpf_fill_stxdw(struct bpf_test *self)
495 {
496         return __bpf_fill_stxdw(self, BPF_DW);
497 }
498
499 static struct bpf_test tests[] = {
500         {
501                 "TAX",
502                 .u.insns = {
503                         BPF_STMT(BPF_LD | BPF_IMM, 1),
504                         BPF_STMT(BPF_MISC | BPF_TAX, 0),
505                         BPF_STMT(BPF_LD | BPF_IMM, 2),
506                         BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
507                         BPF_STMT(BPF_ALU | BPF_NEG, 0), /* A == -3 */
508                         BPF_STMT(BPF_MISC | BPF_TAX, 0),
509                         BPF_STMT(BPF_LD | BPF_LEN, 0),
510                         BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
511                         BPF_STMT(BPF_MISC | BPF_TAX, 0), /* X == len - 3 */
512                         BPF_STMT(BPF_LD | BPF_B | BPF_IND, 1),
513                         BPF_STMT(BPF_RET | BPF_A, 0)
514                 },
515                 CLASSIC,
516                 { 10, 20, 30, 40, 50 },
517                 { { 2, 10 }, { 3, 20 }, { 4, 30 } },
518         },
519         {
520                 "TXA",
521                 .u.insns = {
522                         BPF_STMT(BPF_LDX | BPF_LEN, 0),
523                         BPF_STMT(BPF_MISC | BPF_TXA, 0),
524                         BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
525                         BPF_STMT(BPF_RET | BPF_A, 0) /* A == len * 2 */
526                 },
527                 CLASSIC,
528                 { 10, 20, 30, 40, 50 },
529                 { { 1, 2 }, { 3, 6 }, { 4, 8 } },
530         },
531         {
532                 "ADD_SUB_MUL_K",
533                 .u.insns = {
534                         BPF_STMT(BPF_LD | BPF_IMM, 1),
535                         BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 2),
536                         BPF_STMT(BPF_LDX | BPF_IMM, 3),
537                         BPF_STMT(BPF_ALU | BPF_SUB | BPF_X, 0),
538                         BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 0xffffffff),
539                         BPF_STMT(BPF_ALU | BPF_MUL | BPF_K, 3),
540                         BPF_STMT(BPF_RET | BPF_A, 0)
541                 },
542                 CLASSIC | FLAG_NO_DATA,
543                 { },
544                 { { 0, 0xfffffffd } }
545         },
546         {
547                 "DIV_MOD_KX",
548                 .u.insns = {
549                         BPF_STMT(BPF_LD | BPF_IMM, 8),
550                         BPF_STMT(BPF_ALU | BPF_DIV | BPF_K, 2),
551                         BPF_STMT(BPF_MISC | BPF_TAX, 0),
552                         BPF_STMT(BPF_LD | BPF_IMM, 0xffffffff),
553                         BPF_STMT(BPF_ALU | BPF_DIV | BPF_X, 0),
554                         BPF_STMT(BPF_MISC | BPF_TAX, 0),
555                         BPF_STMT(BPF_LD | BPF_IMM, 0xffffffff),
556                         BPF_STMT(BPF_ALU | BPF_DIV | BPF_K, 0x70000000),
557                         BPF_STMT(BPF_MISC | BPF_TAX, 0),
558                         BPF_STMT(BPF_LD | BPF_IMM, 0xffffffff),
559                         BPF_STMT(BPF_ALU | BPF_MOD | BPF_X, 0),
560                         BPF_STMT(BPF_MISC | BPF_TAX, 0),
561                         BPF_STMT(BPF_LD | BPF_IMM, 0xffffffff),
562                         BPF_STMT(BPF_ALU | BPF_MOD | BPF_K, 0x70000000),
563                         BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
564                         BPF_STMT(BPF_RET | BPF_A, 0)
565                 },
566                 CLASSIC | FLAG_NO_DATA,
567                 { },
568                 { { 0, 0x20000000 } }
569         },
570         {
571                 "AND_OR_LSH_K",
572                 .u.insns = {
573                         BPF_STMT(BPF_LD | BPF_IMM, 0xff),
574                         BPF_STMT(BPF_ALU | BPF_AND | BPF_K, 0xf0),
575                         BPF_STMT(BPF_ALU | BPF_LSH | BPF_K, 27),
576                         BPF_STMT(BPF_MISC | BPF_TAX, 0),
577                         BPF_STMT(BPF_LD | BPF_IMM, 0xf),
578                         BPF_STMT(BPF_ALU | BPF_OR | BPF_K, 0xf0),
579                         BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
580                         BPF_STMT(BPF_RET | BPF_A, 0)
581                 },
582                 CLASSIC | FLAG_NO_DATA,
583                 { },
584                 { { 0, 0x800000ff }, { 1, 0x800000ff } },
585         },
586         {
587                 "LD_IMM_0",
588                 .u.insns = {
589                         BPF_STMT(BPF_LD | BPF_IMM, 0), /* ld #0 */
590                         BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0, 1, 0),
591                         BPF_STMT(BPF_RET | BPF_K, 0),
592                         BPF_STMT(BPF_RET | BPF_K, 1),
593                 },
594                 CLASSIC,
595                 { },
596                 { { 1, 1 } },
597         },
598         {
599                 "LD_IND",
600                 .u.insns = {
601                         BPF_STMT(BPF_LDX | BPF_LEN, 0),
602                         BPF_STMT(BPF_LD | BPF_H | BPF_IND, MAX_K),
603                         BPF_STMT(BPF_RET | BPF_K, 1)
604                 },
605                 CLASSIC,
606                 { },
607                 { { 1, 0 }, { 10, 0 }, { 60, 0 } },
608         },
609         {
610                 "LD_ABS",
611                 .u.insns = {
612                         BPF_STMT(BPF_LD | BPF_W | BPF_ABS, 1000),
613                         BPF_STMT(BPF_RET | BPF_K, 1)
614                 },
615                 CLASSIC,
616                 { },
617                 { { 1, 0 }, { 10, 0 }, { 60, 0 } },
618         },
619         {
620                 "LD_ABS_LL",
621                 .u.insns = {
622                         BPF_STMT(BPF_LD | BPF_B | BPF_ABS, SKF_LL_OFF),
623                         BPF_STMT(BPF_MISC | BPF_TAX, 0),
624                         BPF_STMT(BPF_LD | BPF_B | BPF_ABS, SKF_LL_OFF + 1),
625                         BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
626                         BPF_STMT(BPF_RET | BPF_A, 0)
627                 },
628                 CLASSIC,
629                 { 1, 2, 3 },
630                 { { 1, 0 }, { 2, 3 } },
631         },
632         {
633                 "LD_IND_LL",
634                 .u.insns = {
635                         BPF_STMT(BPF_LD | BPF_IMM, SKF_LL_OFF - 1),
636                         BPF_STMT(BPF_LDX | BPF_LEN, 0),
637                         BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
638                         BPF_STMT(BPF_MISC | BPF_TAX, 0),
639                         BPF_STMT(BPF_LD | BPF_B | BPF_IND, 0),
640                         BPF_STMT(BPF_RET | BPF_A, 0)
641                 },
642                 CLASSIC,
643                 { 1, 2, 3, 0xff },
644                 { { 1, 1 }, { 3, 3 }, { 4, 0xff } },
645         },
646         {
647                 "LD_ABS_NET",
648                 .u.insns = {
649                         BPF_STMT(BPF_LD | BPF_B | BPF_ABS, SKF_NET_OFF),
650                         BPF_STMT(BPF_MISC | BPF_TAX, 0),
651                         BPF_STMT(BPF_LD | BPF_B | BPF_ABS, SKF_NET_OFF + 1),
652                         BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
653                         BPF_STMT(BPF_RET | BPF_A, 0)
654                 },
655                 CLASSIC,
656                 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3 },
657                 { { 15, 0 }, { 16, 3 } },
658         },
659         {
660                 "LD_IND_NET",
661                 .u.insns = {
662                         BPF_STMT(BPF_LD | BPF_IMM, SKF_NET_OFF - 15),
663                         BPF_STMT(BPF_LDX | BPF_LEN, 0),
664                         BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
665                         BPF_STMT(BPF_MISC | BPF_TAX, 0),
666                         BPF_STMT(BPF_LD | BPF_B | BPF_IND, 0),
667                         BPF_STMT(BPF_RET | BPF_A, 0)
668                 },
669                 CLASSIC,
670                 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3 },
671                 { { 14, 0 }, { 15, 1 }, { 17, 3 } },
672         },
673         {
674                 "LD_PKTTYPE",
675                 .u.insns = {
676                         BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
677                                  SKF_AD_OFF + SKF_AD_PKTTYPE),
678                         BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, SKB_TYPE, 1, 0),
679                         BPF_STMT(BPF_RET | BPF_K, 1),
680                         BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
681                                  SKF_AD_OFF + SKF_AD_PKTTYPE),
682                         BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, SKB_TYPE, 1, 0),
683                         BPF_STMT(BPF_RET | BPF_K, 1),
684                         BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
685                                  SKF_AD_OFF + SKF_AD_PKTTYPE),
686                         BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, SKB_TYPE, 1, 0),
687                         BPF_STMT(BPF_RET | BPF_K, 1),
688                         BPF_STMT(BPF_RET | BPF_A, 0)
689                 },
690                 CLASSIC,
691                 { },
692                 { { 1, 3 }, { 10, 3 } },
693         },
694         {
695                 "LD_MARK",
696                 .u.insns = {
697                         BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
698                                  SKF_AD_OFF + SKF_AD_MARK),
699                         BPF_STMT(BPF_RET | BPF_A, 0)
700                 },
701                 CLASSIC,
702                 { },
703                 { { 1, SKB_MARK}, { 10, SKB_MARK} },
704         },
705         {
706                 "LD_RXHASH",
707                 .u.insns = {
708                         BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
709                                  SKF_AD_OFF + SKF_AD_RXHASH),
710                         BPF_STMT(BPF_RET | BPF_A, 0)
711                 },
712                 CLASSIC,
713                 { },
714                 { { 1, SKB_HASH}, { 10, SKB_HASH} },
715         },
716         {
717                 "LD_QUEUE",
718                 .u.insns = {
719                         BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
720                                  SKF_AD_OFF + SKF_AD_QUEUE),
721                         BPF_STMT(BPF_RET | BPF_A, 0)
722                 },
723                 CLASSIC,
724                 { },
725                 { { 1, SKB_QUEUE_MAP }, { 10, SKB_QUEUE_MAP } },
726         },
727         {
728                 "LD_PROTOCOL",
729                 .u.insns = {
730                         BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 1),
731                         BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 20, 1, 0),
732                         BPF_STMT(BPF_RET | BPF_K, 0),
733                         BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
734                                  SKF_AD_OFF + SKF_AD_PROTOCOL),
735                         BPF_STMT(BPF_MISC | BPF_TAX, 0),
736                         BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 2),
737                         BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 30, 1, 0),
738                         BPF_STMT(BPF_RET | BPF_K, 0),
739                         BPF_STMT(BPF_MISC | BPF_TXA, 0),
740                         BPF_STMT(BPF_RET | BPF_A, 0)
741                 },
742                 CLASSIC,
743                 { 10, 20, 30 },
744                 { { 10, ETH_P_IP }, { 100, ETH_P_IP } },
745         },
746         {
747                 "LD_VLAN_TAG",
748                 .u.insns = {
749                         BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
750                                  SKF_AD_OFF + SKF_AD_VLAN_TAG),
751                         BPF_STMT(BPF_RET | BPF_A, 0)
752                 },
753                 CLASSIC,
754                 { },
755                 {
756                         { 1, SKB_VLAN_TCI & ~VLAN_TAG_PRESENT },
757                         { 10, SKB_VLAN_TCI & ~VLAN_TAG_PRESENT }
758                 },
759         },
760         {
761                 "LD_VLAN_TAG_PRESENT",
762                 .u.insns = {
763                         BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
764                                  SKF_AD_OFF + SKF_AD_VLAN_TAG_PRESENT),
765                         BPF_STMT(BPF_RET | BPF_A, 0)
766                 },
767                 CLASSIC,
768                 { },
769                 {
770                         { 1, !!(SKB_VLAN_TCI & VLAN_TAG_PRESENT) },
771                         { 10, !!(SKB_VLAN_TCI & VLAN_TAG_PRESENT) }
772                 },
773         },
774         {
775                 "LD_IFINDEX",
776                 .u.insns = {
777                         BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
778                                  SKF_AD_OFF + SKF_AD_IFINDEX),
779                         BPF_STMT(BPF_RET | BPF_A, 0)
780                 },
781                 CLASSIC,
782                 { },
783                 { { 1, SKB_DEV_IFINDEX }, { 10, SKB_DEV_IFINDEX } },
784         },
785         {
786                 "LD_HATYPE",
787                 .u.insns = {
788                         BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
789                                  SKF_AD_OFF + SKF_AD_HATYPE),
790                         BPF_STMT(BPF_RET | BPF_A, 0)
791                 },
792                 CLASSIC,
793                 { },
794                 { { 1, SKB_DEV_TYPE }, { 10, SKB_DEV_TYPE } },
795         },
796         {
797                 "LD_CPU",
798                 .u.insns = {
799                         BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
800                                  SKF_AD_OFF + SKF_AD_CPU),
801                         BPF_STMT(BPF_MISC | BPF_TAX, 0),
802                         BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
803                                  SKF_AD_OFF + SKF_AD_CPU),
804                         BPF_STMT(BPF_ALU | BPF_SUB | BPF_X, 0),
805                         BPF_STMT(BPF_RET | BPF_A, 0)
806                 },
807                 CLASSIC,
808                 { },
809                 { { 1, 0 }, { 10, 0 } },
810         },
811         {
812                 "LD_NLATTR",
813                 .u.insns = {
814                         BPF_STMT(BPF_LDX | BPF_IMM, 2),
815                         BPF_STMT(BPF_MISC | BPF_TXA, 0),
816                         BPF_STMT(BPF_LDX | BPF_IMM, 3),
817                         BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
818                                  SKF_AD_OFF + SKF_AD_NLATTR),
819                         BPF_STMT(BPF_RET | BPF_A, 0)
820                 },
821                 CLASSIC,
822 #ifdef __BIG_ENDIAN
823                 { 0xff, 0xff, 0, 4, 0, 2, 0, 4, 0, 3 },
824 #else
825                 { 0xff, 0xff, 4, 0, 2, 0, 4, 0, 3, 0 },
826 #endif
827                 { { 4, 0 }, { 20, 6 } },
828         },
829         {
830                 "LD_NLATTR_NEST",
831                 .u.insns = {
832                         BPF_STMT(BPF_LD | BPF_IMM, 2),
833                         BPF_STMT(BPF_LDX | BPF_IMM, 3),
834                         BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
835                                  SKF_AD_OFF + SKF_AD_NLATTR_NEST),
836                         BPF_STMT(BPF_LD | BPF_IMM, 2),
837                         BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
838                                  SKF_AD_OFF + SKF_AD_NLATTR_NEST),
839                         BPF_STMT(BPF_LD | BPF_IMM, 2),
840                         BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
841                                  SKF_AD_OFF + SKF_AD_NLATTR_NEST),
842                         BPF_STMT(BPF_LD | BPF_IMM, 2),
843                         BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
844                                  SKF_AD_OFF + SKF_AD_NLATTR_NEST),
845                         BPF_STMT(BPF_LD | BPF_IMM, 2),
846                         BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
847                                  SKF_AD_OFF + SKF_AD_NLATTR_NEST),
848                         BPF_STMT(BPF_LD | BPF_IMM, 2),
849                         BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
850                                  SKF_AD_OFF + SKF_AD_NLATTR_NEST),
851                         BPF_STMT(BPF_LD | BPF_IMM, 2),
852                         BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
853                                  SKF_AD_OFF + SKF_AD_NLATTR_NEST),
854                         BPF_STMT(BPF_LD | BPF_IMM, 2),
855                         BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
856                                  SKF_AD_OFF + SKF_AD_NLATTR_NEST),
857                         BPF_STMT(BPF_RET | BPF_A, 0)
858                 },
859                 CLASSIC,
860 #ifdef __BIG_ENDIAN
861                 { 0xff, 0xff, 0, 12, 0, 1, 0, 4, 0, 2, 0, 4, 0, 3 },
862 #else
863                 { 0xff, 0xff, 12, 0, 1, 0, 4, 0, 2, 0, 4, 0, 3, 0 },
864 #endif
865                 { { 4, 0 }, { 20, 10 } },
866         },
867         {
868                 "LD_PAYLOAD_OFF",
869                 .u.insns = {
870                         BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
871                                  SKF_AD_OFF + SKF_AD_PAY_OFFSET),
872                         BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
873                                  SKF_AD_OFF + SKF_AD_PAY_OFFSET),
874                         BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
875                                  SKF_AD_OFF + SKF_AD_PAY_OFFSET),
876                         BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
877                                  SKF_AD_OFF + SKF_AD_PAY_OFFSET),
878                         BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
879                                  SKF_AD_OFF + SKF_AD_PAY_OFFSET),
880                         BPF_STMT(BPF_RET | BPF_A, 0)
881                 },
882                 CLASSIC,
883                 /* 00:00:00:00:00:00 > 00:00:00:00:00:00, ethtype IPv4 (0x0800),
884                  * length 98: 127.0.0.1 > 127.0.0.1: ICMP echo request,
885                  * id 9737, seq 1, length 64
886                  */
887                 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
888                   0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
889                   0x08, 0x00,
890                   0x45, 0x00, 0x00, 0x54, 0xac, 0x8b, 0x40, 0x00, 0x40,
891                   0x01, 0x90, 0x1b, 0x7f, 0x00, 0x00, 0x01 },
892                 { { 30, 0 }, { 100, 42 } },
893         },
894         {
895                 "LD_ANC_XOR",
896                 .u.insns = {
897                         BPF_STMT(BPF_LD | BPF_IMM, 10),
898                         BPF_STMT(BPF_LDX | BPF_IMM, 300),
899                         BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
900                                  SKF_AD_OFF + SKF_AD_ALU_XOR_X),
901                         BPF_STMT(BPF_RET | BPF_A, 0)
902                 },
903                 CLASSIC,
904                 { },
905                 { { 4, 10 ^ 300 }, { 20, 10 ^ 300 } },
906         },
907         {
908                 "SPILL_FILL",
909                 .u.insns = {
910                         BPF_STMT(BPF_LDX | BPF_LEN, 0),
911                         BPF_STMT(BPF_LD | BPF_IMM, 2),
912                         BPF_STMT(BPF_ALU | BPF_RSH, 1),
913                         BPF_STMT(BPF_ALU | BPF_XOR | BPF_X, 0),
914                         BPF_STMT(BPF_ST, 1), /* M1 = 1 ^ len */
915                         BPF_STMT(BPF_ALU | BPF_XOR | BPF_K, 0x80000000),
916                         BPF_STMT(BPF_ST, 2), /* M2 = 1 ^ len ^ 0x80000000 */
917                         BPF_STMT(BPF_STX, 15), /* M3 = len */
918                         BPF_STMT(BPF_LDX | BPF_MEM, 1),
919                         BPF_STMT(BPF_LD | BPF_MEM, 2),
920                         BPF_STMT(BPF_ALU | BPF_XOR | BPF_X, 0),
921                         BPF_STMT(BPF_LDX | BPF_MEM, 15),
922                         BPF_STMT(BPF_ALU | BPF_XOR | BPF_X, 0),
923                         BPF_STMT(BPF_RET | BPF_A, 0)
924                 },
925                 CLASSIC,
926                 { },
927                 { { 1, 0x80000001 }, { 2, 0x80000002 }, { 60, 0x80000000 ^ 60 } }
928         },
929         {
930                 "JEQ",
931                 .u.insns = {
932                         BPF_STMT(BPF_LDX | BPF_LEN, 0),
933                         BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 2),
934                         BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_X, 0, 0, 1),
935                         BPF_STMT(BPF_RET | BPF_K, 1),
936                         BPF_STMT(BPF_RET | BPF_K, MAX_K)
937                 },
938                 CLASSIC,
939                 { 3, 3, 3, 3, 3 },
940                 { { 1, 0 }, { 3, 1 }, { 4, MAX_K } },
941         },
942         {
943                 "JGT",
944                 .u.insns = {
945                         BPF_STMT(BPF_LDX | BPF_LEN, 0),
946                         BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 2),
947                         BPF_JUMP(BPF_JMP | BPF_JGT | BPF_X, 0, 0, 1),
948                         BPF_STMT(BPF_RET | BPF_K, 1),
949                         BPF_STMT(BPF_RET | BPF_K, MAX_K)
950                 },
951                 CLASSIC,
952                 { 4, 4, 4, 3, 3 },
953                 { { 2, 0 }, { 3, 1 }, { 4, MAX_K } },
954         },
955         {
956                 "JGE (jt 0), test 1",
957                 .u.insns = {
958                         BPF_STMT(BPF_LDX | BPF_LEN, 0),
959                         BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 2),
960                         BPF_JUMP(BPF_JMP | BPF_JGE | BPF_X, 0, 0, 1),
961                         BPF_STMT(BPF_RET | BPF_K, 1),
962                         BPF_STMT(BPF_RET | BPF_K, MAX_K)
963                 },
964                 CLASSIC,
965                 { 4, 4, 4, 3, 3 },
966                 { { 2, 0 }, { 3, 1 }, { 4, 1 } },
967         },
968         {
969                 "JGE (jt 0), test 2",
970                 .u.insns = {
971                         BPF_STMT(BPF_LDX | BPF_LEN, 0),
972                         BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 2),
973                         BPF_JUMP(BPF_JMP | BPF_JGE | BPF_X, 0, 0, 1),
974                         BPF_STMT(BPF_RET | BPF_K, 1),
975                         BPF_STMT(BPF_RET | BPF_K, MAX_K)
976                 },
977                 CLASSIC,
978                 { 4, 4, 5, 3, 3 },
979                 { { 4, 1 }, { 5, 1 }, { 6, MAX_K } },
980         },
981         {
982                 "JGE",
983                 .u.insns = {
984                         BPF_STMT(BPF_LDX | BPF_LEN, 0),
985                         BPF_STMT(BPF_LD | BPF_B | BPF_IND, MAX_K),
986                         BPF_JUMP(BPF_JMP | BPF_JGE | BPF_K, 1, 1, 0),
987                         BPF_STMT(BPF_RET | BPF_K, 10),
988                         BPF_JUMP(BPF_JMP | BPF_JGE | BPF_K, 2, 1, 0),
989                         BPF_STMT(BPF_RET | BPF_K, 20),
990                         BPF_JUMP(BPF_JMP | BPF_JGE | BPF_K, 3, 1, 0),
991                         BPF_STMT(BPF_RET | BPF_K, 30),
992                         BPF_JUMP(BPF_JMP | BPF_JGE | BPF_K, 4, 1, 0),
993                         BPF_STMT(BPF_RET | BPF_K, 40),
994                         BPF_STMT(BPF_RET | BPF_K, MAX_K)
995                 },
996                 CLASSIC,
997                 { 1, 2, 3, 4, 5 },
998                 { { 1, 20 }, { 3, 40 }, { 5, MAX_K } },
999         },
1000         {
1001                 "JSET",
1002                 .u.insns = {
1003                         BPF_JUMP(BPF_JMP | BPF_JA, 0, 0, 0),
1004                         BPF_JUMP(BPF_JMP | BPF_JA, 1, 1, 1),
1005                         BPF_JUMP(BPF_JMP | BPF_JA, 0, 0, 0),
1006                         BPF_JUMP(BPF_JMP | BPF_JA, 0, 0, 0),
1007                         BPF_STMT(BPF_LDX | BPF_LEN, 0),
1008                         BPF_STMT(BPF_MISC | BPF_TXA, 0),
1009                         BPF_STMT(BPF_ALU | BPF_SUB | BPF_K, 4),
1010                         BPF_STMT(BPF_MISC | BPF_TAX, 0),
1011                         BPF_STMT(BPF_LD | BPF_W | BPF_IND, 0),
1012                         BPF_JUMP(BPF_JMP | BPF_JSET | BPF_K, 1, 0, 1),
1013                         BPF_STMT(BPF_RET | BPF_K, 10),
1014                         BPF_JUMP(BPF_JMP | BPF_JSET | BPF_K, 0x80000000, 0, 1),
1015                         BPF_STMT(BPF_RET | BPF_K, 20),
1016                         BPF_JUMP(BPF_JMP | BPF_JSET | BPF_K, 0xffffff, 1, 0),
1017                         BPF_STMT(BPF_RET | BPF_K, 30),
1018                         BPF_JUMP(BPF_JMP | BPF_JSET | BPF_K, 0xffffff, 1, 0),
1019                         BPF_STMT(BPF_RET | BPF_K, 30),
1020                         BPF_JUMP(BPF_JMP | BPF_JSET | BPF_K, 0xffffff, 1, 0),
1021                         BPF_STMT(BPF_RET | BPF_K, 30),
1022                         BPF_JUMP(BPF_JMP | BPF_JSET | BPF_K, 0xffffff, 1, 0),
1023                         BPF_STMT(BPF_RET | BPF_K, 30),
1024                         BPF_JUMP(BPF_JMP | BPF_JSET | BPF_K, 0xffffff, 1, 0),
1025                         BPF_STMT(BPF_RET | BPF_K, 30),
1026                         BPF_STMT(BPF_RET | BPF_K, MAX_K)
1027                 },
1028                 CLASSIC,
1029                 { 0, 0xAA, 0x55, 1 },
1030                 { { 4, 10 }, { 5, 20 }, { 6, MAX_K } },
1031         },
1032         {
1033                 "tcpdump port 22",
1034                 .u.insns = {
1035                         BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 12),
1036                         BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x86dd, 0, 8), /* IPv6 */
1037                         BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 20),
1038                         BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x84, 2, 0),
1039                         BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x6, 1, 0),
1040                         BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x11, 0, 17),
1041                         BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 54),
1042                         BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 22, 14, 0),
1043                         BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 56),
1044                         BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 22, 12, 13),
1045                         BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x0800, 0, 12), /* IPv4 */
1046                         BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 23),
1047                         BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x84, 2, 0),
1048                         BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x6, 1, 0),
1049                         BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x11, 0, 8),
1050                         BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 20),
1051                         BPF_JUMP(BPF_JMP | BPF_JSET | BPF_K, 0x1fff, 6, 0),
1052                         BPF_STMT(BPF_LDX | BPF_B | BPF_MSH, 14),
1053                         BPF_STMT(BPF_LD | BPF_H | BPF_IND, 14),
1054                         BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 22, 2, 0),
1055                         BPF_STMT(BPF_LD | BPF_H | BPF_IND, 16),
1056                         BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 22, 0, 1),
1057                         BPF_STMT(BPF_RET | BPF_K, 0xffff),
1058                         BPF_STMT(BPF_RET | BPF_K, 0),
1059                 },
1060                 CLASSIC,
1061                 /* 3c:07:54:43:e5:76 > 10:bf:48:d6:43:d6, ethertype IPv4(0x0800)
1062                  * length 114: 10.1.1.149.49700 > 10.1.2.10.22: Flags [P.],
1063                  * seq 1305692979:1305693027, ack 3650467037, win 65535,
1064                  * options [nop,nop,TS val 2502645400 ecr 3971138], length 48
1065                  */
1066                 { 0x10, 0xbf, 0x48, 0xd6, 0x43, 0xd6,
1067                   0x3c, 0x07, 0x54, 0x43, 0xe5, 0x76,
1068                   0x08, 0x00,
1069                   0x45, 0x10, 0x00, 0x64, 0x75, 0xb5,
1070                   0x40, 0x00, 0x40, 0x06, 0xad, 0x2e, /* IP header */
1071                   0x0a, 0x01, 0x01, 0x95, /* ip src */
1072                   0x0a, 0x01, 0x02, 0x0a, /* ip dst */
1073                   0xc2, 0x24,
1074                   0x00, 0x16 /* dst port */ },
1075                 { { 10, 0 }, { 30, 0 }, { 100, 65535 } },
1076         },
1077         {
1078                 "tcpdump complex",
1079                 .u.insns = {
1080                         /* tcpdump -nei eth0 'tcp port 22 and (((ip[2:2] -
1081                          * ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0) and
1082                          * (len > 115 or len < 30000000000)' -d
1083                          */
1084                         BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 12),
1085                         BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x86dd, 30, 0),
1086                         BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x800, 0, 29),
1087                         BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 23),
1088                         BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x6, 0, 27),
1089                         BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 20),
1090                         BPF_JUMP(BPF_JMP | BPF_JSET | BPF_K, 0x1fff, 25, 0),
1091                         BPF_STMT(BPF_LDX | BPF_B | BPF_MSH, 14),
1092                         BPF_STMT(BPF_LD | BPF_H | BPF_IND, 14),
1093                         BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 22, 2, 0),
1094                         BPF_STMT(BPF_LD | BPF_H | BPF_IND, 16),
1095                         BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 22, 0, 20),
1096                         BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 16),
1097                         BPF_STMT(BPF_ST, 1),
1098                         BPF_STMT(BPF_LD | BPF_B | BPF_ABS, 14),
1099                         BPF_STMT(BPF_ALU | BPF_AND | BPF_K, 0xf),
1100                         BPF_STMT(BPF_ALU | BPF_LSH | BPF_K, 2),
1101                         BPF_STMT(BPF_MISC | BPF_TAX, 0x5), /* libpcap emits K on TAX */
1102                         BPF_STMT(BPF_LD | BPF_MEM, 1),
1103                         BPF_STMT(BPF_ALU | BPF_SUB | BPF_X, 0),
1104                         BPF_STMT(BPF_ST, 5),
1105                         BPF_STMT(BPF_LDX | BPF_B | BPF_MSH, 14),
1106                         BPF_STMT(BPF_LD | BPF_B | BPF_IND, 26),
1107                         BPF_STMT(BPF_ALU | BPF_AND | BPF_K, 0xf0),
1108                         BPF_STMT(BPF_ALU | BPF_RSH | BPF_K, 2),
1109                         BPF_STMT(BPF_MISC | BPF_TAX, 0x9), /* libpcap emits K on TAX */
1110                         BPF_STMT(BPF_LD | BPF_MEM, 5),
1111                         BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_X, 0, 4, 0),
1112                         BPF_STMT(BPF_LD | BPF_LEN, 0),
1113                         BPF_JUMP(BPF_JMP | BPF_JGT | BPF_K, 0x73, 1, 0),
1114                         BPF_JUMP(BPF_JMP | BPF_JGE | BPF_K, 0xfc23ac00, 1, 0),
1115                         BPF_STMT(BPF_RET | BPF_K, 0xffff),
1116                         BPF_STMT(BPF_RET | BPF_K, 0),
1117                 },
1118                 CLASSIC,
1119                 { 0x10, 0xbf, 0x48, 0xd6, 0x43, 0xd6,
1120                   0x3c, 0x07, 0x54, 0x43, 0xe5, 0x76,
1121                   0x08, 0x00,
1122                   0x45, 0x10, 0x00, 0x64, 0x75, 0xb5,
1123                   0x40, 0x00, 0x40, 0x06, 0xad, 0x2e, /* IP header */
1124                   0x0a, 0x01, 0x01, 0x95, /* ip src */
1125                   0x0a, 0x01, 0x02, 0x0a, /* ip dst */
1126                   0xc2, 0x24,
1127                   0x00, 0x16 /* dst port */ },
1128                 { { 10, 0 }, { 30, 0 }, { 100, 65535 } },
1129         },
1130         {
1131                 "RET_A",
1132                 .u.insns = {
1133                         /* check that unitialized X and A contain zeros */
1134                         BPF_STMT(BPF_MISC | BPF_TXA, 0),
1135                         BPF_STMT(BPF_RET | BPF_A, 0)
1136                 },
1137                 CLASSIC,
1138                 { },
1139                 { {1, 0}, {2, 0} },
1140         },
1141         {
1142                 "INT: ADD trivial",
1143                 .u.insns_int = {
1144                         BPF_ALU64_IMM(BPF_MOV, R1, 1),
1145                         BPF_ALU64_IMM(BPF_ADD, R1, 2),
1146                         BPF_ALU64_IMM(BPF_MOV, R2, 3),
1147                         BPF_ALU64_REG(BPF_SUB, R1, R2),
1148                         BPF_ALU64_IMM(BPF_ADD, R1, -1),
1149                         BPF_ALU64_IMM(BPF_MUL, R1, 3),
1150                         BPF_ALU64_REG(BPF_MOV, R0, R1),
1151                         BPF_EXIT_INSN(),
1152                 },
1153                 INTERNAL,
1154                 { },
1155                 { { 0, 0xfffffffd } }
1156         },
1157         {
1158                 "INT: MUL_X",
1159                 .u.insns_int = {
1160                         BPF_ALU64_IMM(BPF_MOV, R0, -1),
1161                         BPF_ALU64_IMM(BPF_MOV, R1, -1),
1162                         BPF_ALU64_IMM(BPF_MOV, R2, 3),
1163                         BPF_ALU64_REG(BPF_MUL, R1, R2),
1164                         BPF_JMP_IMM(BPF_JEQ, R1, 0xfffffffd, 1),
1165                         BPF_EXIT_INSN(),
1166                         BPF_ALU64_IMM(BPF_MOV, R0, 1),
1167                         BPF_EXIT_INSN(),
1168                 },
1169                 INTERNAL,
1170                 { },
1171                 { { 0, 1 } }
1172         },
1173         {
1174                 "INT: MUL_X2",
1175                 .u.insns_int = {
1176                         BPF_ALU32_IMM(BPF_MOV, R0, -1),
1177                         BPF_ALU32_IMM(BPF_MOV, R1, -1),
1178                         BPF_ALU32_IMM(BPF_MOV, R2, 3),
1179                         BPF_ALU64_REG(BPF_MUL, R1, R2),
1180                         BPF_ALU64_IMM(BPF_RSH, R1, 8),
1181                         BPF_JMP_IMM(BPF_JEQ, R1, 0x2ffffff, 1),
1182                         BPF_EXIT_INSN(),
1183                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
1184                         BPF_EXIT_INSN(),
1185                 },
1186                 INTERNAL,
1187                 { },
1188                 { { 0, 1 } }
1189         },
1190         {
1191                 "INT: MUL32_X",
1192                 .u.insns_int = {
1193                         BPF_ALU32_IMM(BPF_MOV, R0, -1),
1194                         BPF_ALU64_IMM(BPF_MOV, R1, -1),
1195                         BPF_ALU32_IMM(BPF_MOV, R2, 3),
1196                         BPF_ALU32_REG(BPF_MUL, R1, R2),
1197                         BPF_ALU64_IMM(BPF_RSH, R1, 8),
1198                         BPF_JMP_IMM(BPF_JEQ, R1, 0xffffff, 1),
1199                         BPF_EXIT_INSN(),
1200                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
1201                         BPF_EXIT_INSN(),
1202                 },
1203                 INTERNAL,
1204                 { },
1205                 { { 0, 1 } }
1206         },
1207         {
1208                 /* Have to test all register combinations, since
1209                  * JITing of different registers will produce
1210                  * different asm code.
1211                  */
1212                 "INT: ADD 64-bit",
1213                 .u.insns_int = {
1214                         BPF_ALU64_IMM(BPF_MOV, R0, 0),
1215                         BPF_ALU64_IMM(BPF_MOV, R1, 1),
1216                         BPF_ALU64_IMM(BPF_MOV, R2, 2),
1217                         BPF_ALU64_IMM(BPF_MOV, R3, 3),
1218                         BPF_ALU64_IMM(BPF_MOV, R4, 4),
1219                         BPF_ALU64_IMM(BPF_MOV, R5, 5),
1220                         BPF_ALU64_IMM(BPF_MOV, R6, 6),
1221                         BPF_ALU64_IMM(BPF_MOV, R7, 7),
1222                         BPF_ALU64_IMM(BPF_MOV, R8, 8),
1223                         BPF_ALU64_IMM(BPF_MOV, R9, 9),
1224                         BPF_ALU64_IMM(BPF_ADD, R0, 20),
1225                         BPF_ALU64_IMM(BPF_ADD, R1, 20),
1226                         BPF_ALU64_IMM(BPF_ADD, R2, 20),
1227                         BPF_ALU64_IMM(BPF_ADD, R3, 20),
1228                         BPF_ALU64_IMM(BPF_ADD, R4, 20),
1229                         BPF_ALU64_IMM(BPF_ADD, R5, 20),
1230                         BPF_ALU64_IMM(BPF_ADD, R6, 20),
1231                         BPF_ALU64_IMM(BPF_ADD, R7, 20),
1232                         BPF_ALU64_IMM(BPF_ADD, R8, 20),
1233                         BPF_ALU64_IMM(BPF_ADD, R9, 20),
1234                         BPF_ALU64_IMM(BPF_SUB, R0, 10),
1235                         BPF_ALU64_IMM(BPF_SUB, R1, 10),
1236                         BPF_ALU64_IMM(BPF_SUB, R2, 10),
1237                         BPF_ALU64_IMM(BPF_SUB, R3, 10),
1238                         BPF_ALU64_IMM(BPF_SUB, R4, 10),
1239                         BPF_ALU64_IMM(BPF_SUB, R5, 10),
1240                         BPF_ALU64_IMM(BPF_SUB, R6, 10),
1241                         BPF_ALU64_IMM(BPF_SUB, R7, 10),
1242                         BPF_ALU64_IMM(BPF_SUB, R8, 10),
1243                         BPF_ALU64_IMM(BPF_SUB, R9, 10),
1244                         BPF_ALU64_REG(BPF_ADD, R0, R0),
1245                         BPF_ALU64_REG(BPF_ADD, R0, R1),
1246                         BPF_ALU64_REG(BPF_ADD, R0, R2),
1247                         BPF_ALU64_REG(BPF_ADD, R0, R3),
1248                         BPF_ALU64_REG(BPF_ADD, R0, R4),
1249                         BPF_ALU64_REG(BPF_ADD, R0, R5),
1250                         BPF_ALU64_REG(BPF_ADD, R0, R6),
1251                         BPF_ALU64_REG(BPF_ADD, R0, R7),
1252                         BPF_ALU64_REG(BPF_ADD, R0, R8),
1253                         BPF_ALU64_REG(BPF_ADD, R0, R9), /* R0 == 155 */
1254                         BPF_JMP_IMM(BPF_JEQ, R0, 155, 1),
1255                         BPF_EXIT_INSN(),
1256                         BPF_ALU64_REG(BPF_ADD, R1, R0),
1257                         BPF_ALU64_REG(BPF_ADD, R1, R1),
1258                         BPF_ALU64_REG(BPF_ADD, R1, R2),
1259                         BPF_ALU64_REG(BPF_ADD, R1, R3),
1260                         BPF_ALU64_REG(BPF_ADD, R1, R4),
1261                         BPF_ALU64_REG(BPF_ADD, R1, R5),
1262                         BPF_ALU64_REG(BPF_ADD, R1, R6),
1263                         BPF_ALU64_REG(BPF_ADD, R1, R7),
1264                         BPF_ALU64_REG(BPF_ADD, R1, R8),
1265                         BPF_ALU64_REG(BPF_ADD, R1, R9), /* R1 == 456 */
1266                         BPF_JMP_IMM(BPF_JEQ, R1, 456, 1),
1267                         BPF_EXIT_INSN(),
1268                         BPF_ALU64_REG(BPF_ADD, R2, R0),
1269                         BPF_ALU64_REG(BPF_ADD, R2, R1),
1270                         BPF_ALU64_REG(BPF_ADD, R2, R2),
1271                         BPF_ALU64_REG(BPF_ADD, R2, R3),
1272                         BPF_ALU64_REG(BPF_ADD, R2, R4),
1273                         BPF_ALU64_REG(BPF_ADD, R2, R5),
1274                         BPF_ALU64_REG(BPF_ADD, R2, R6),
1275                         BPF_ALU64_REG(BPF_ADD, R2, R7),
1276                         BPF_ALU64_REG(BPF_ADD, R2, R8),
1277                         BPF_ALU64_REG(BPF_ADD, R2, R9), /* R2 == 1358 */
1278                         BPF_JMP_IMM(BPF_JEQ, R2, 1358, 1),
1279                         BPF_EXIT_INSN(),
1280                         BPF_ALU64_REG(BPF_ADD, R3, R0),
1281                         BPF_ALU64_REG(BPF_ADD, R3, R1),
1282                         BPF_ALU64_REG(BPF_ADD, R3, R2),
1283                         BPF_ALU64_REG(BPF_ADD, R3, R3),
1284                         BPF_ALU64_REG(BPF_ADD, R3, R4),
1285                         BPF_ALU64_REG(BPF_ADD, R3, R5),
1286                         BPF_ALU64_REG(BPF_ADD, R3, R6),
1287                         BPF_ALU64_REG(BPF_ADD, R3, R7),
1288                         BPF_ALU64_REG(BPF_ADD, R3, R8),
1289                         BPF_ALU64_REG(BPF_ADD, R3, R9), /* R3 == 4063 */
1290                         BPF_JMP_IMM(BPF_JEQ, R3, 4063, 1),
1291                         BPF_EXIT_INSN(),
1292                         BPF_ALU64_REG(BPF_ADD, R4, R0),
1293                         BPF_ALU64_REG(BPF_ADD, R4, R1),
1294                         BPF_ALU64_REG(BPF_ADD, R4, R2),
1295                         BPF_ALU64_REG(BPF_ADD, R4, R3),
1296                         BPF_ALU64_REG(BPF_ADD, R4, R4),
1297                         BPF_ALU64_REG(BPF_ADD, R4, R5),
1298                         BPF_ALU64_REG(BPF_ADD, R4, R6),
1299                         BPF_ALU64_REG(BPF_ADD, R4, R7),
1300                         BPF_ALU64_REG(BPF_ADD, R4, R8),
1301                         BPF_ALU64_REG(BPF_ADD, R4, R9), /* R4 == 12177 */
1302                         BPF_JMP_IMM(BPF_JEQ, R4, 12177, 1),
1303                         BPF_EXIT_INSN(),
1304                         BPF_ALU64_REG(BPF_ADD, R5, R0),
1305                         BPF_ALU64_REG(BPF_ADD, R5, R1),
1306                         BPF_ALU64_REG(BPF_ADD, R5, R2),
1307                         BPF_ALU64_REG(BPF_ADD, R5, R3),
1308                         BPF_ALU64_REG(BPF_ADD, R5, R4),
1309                         BPF_ALU64_REG(BPF_ADD, R5, R5),
1310                         BPF_ALU64_REG(BPF_ADD, R5, R6),
1311                         BPF_ALU64_REG(BPF_ADD, R5, R7),
1312                         BPF_ALU64_REG(BPF_ADD, R5, R8),
1313                         BPF_ALU64_REG(BPF_ADD, R5, R9), /* R5 == 36518 */
1314                         BPF_JMP_IMM(BPF_JEQ, R5, 36518, 1),
1315                         BPF_EXIT_INSN(),
1316                         BPF_ALU64_REG(BPF_ADD, R6, R0),
1317                         BPF_ALU64_REG(BPF_ADD, R6, R1),
1318                         BPF_ALU64_REG(BPF_ADD, R6, R2),
1319                         BPF_ALU64_REG(BPF_ADD, R6, R3),
1320                         BPF_ALU64_REG(BPF_ADD, R6, R4),
1321                         BPF_ALU64_REG(BPF_ADD, R6, R5),
1322                         BPF_ALU64_REG(BPF_ADD, R6, R6),
1323                         BPF_ALU64_REG(BPF_ADD, R6, R7),
1324                         BPF_ALU64_REG(BPF_ADD, R6, R8),
1325                         BPF_ALU64_REG(BPF_ADD, R6, R9), /* R6 == 109540 */
1326                         BPF_JMP_IMM(BPF_JEQ, R6, 109540, 1),
1327                         BPF_EXIT_INSN(),
1328                         BPF_ALU64_REG(BPF_ADD, R7, R0),
1329                         BPF_ALU64_REG(BPF_ADD, R7, R1),
1330                         BPF_ALU64_REG(BPF_ADD, R7, R2),
1331                         BPF_ALU64_REG(BPF_ADD, R7, R3),
1332                         BPF_ALU64_REG(BPF_ADD, R7, R4),
1333                         BPF_ALU64_REG(BPF_ADD, R7, R5),
1334                         BPF_ALU64_REG(BPF_ADD, R7, R6),
1335                         BPF_ALU64_REG(BPF_ADD, R7, R7),
1336                         BPF_ALU64_REG(BPF_ADD, R7, R8),
1337                         BPF_ALU64_REG(BPF_ADD, R7, R9), /* R7 == 328605 */
1338                         BPF_JMP_IMM(BPF_JEQ, R7, 328605, 1),
1339                         BPF_EXIT_INSN(),
1340                         BPF_ALU64_REG(BPF_ADD, R8, R0),
1341                         BPF_ALU64_REG(BPF_ADD, R8, R1),
1342                         BPF_ALU64_REG(BPF_ADD, R8, R2),
1343                         BPF_ALU64_REG(BPF_ADD, R8, R3),
1344                         BPF_ALU64_REG(BPF_ADD, R8, R4),
1345                         BPF_ALU64_REG(BPF_ADD, R8, R5),
1346                         BPF_ALU64_REG(BPF_ADD, R8, R6),
1347                         BPF_ALU64_REG(BPF_ADD, R8, R7),
1348                         BPF_ALU64_REG(BPF_ADD, R8, R8),
1349                         BPF_ALU64_REG(BPF_ADD, R8, R9), /* R8 == 985799 */
1350                         BPF_JMP_IMM(BPF_JEQ, R8, 985799, 1),
1351                         BPF_EXIT_INSN(),
1352                         BPF_ALU64_REG(BPF_ADD, R9, R0),
1353                         BPF_ALU64_REG(BPF_ADD, R9, R1),
1354                         BPF_ALU64_REG(BPF_ADD, R9, R2),
1355                         BPF_ALU64_REG(BPF_ADD, R9, R3),
1356                         BPF_ALU64_REG(BPF_ADD, R9, R4),
1357                         BPF_ALU64_REG(BPF_ADD, R9, R5),
1358                         BPF_ALU64_REG(BPF_ADD, R9, R6),
1359                         BPF_ALU64_REG(BPF_ADD, R9, R7),
1360                         BPF_ALU64_REG(BPF_ADD, R9, R8),
1361                         BPF_ALU64_REG(BPF_ADD, R9, R9), /* R9 == 2957380 */
1362                         BPF_ALU64_REG(BPF_MOV, R0, R9),
1363                         BPF_EXIT_INSN(),
1364                 },
1365                 INTERNAL,
1366                 { },
1367                 { { 0, 2957380 } }
1368         },
1369         {
1370                 "INT: ADD 32-bit",
1371                 .u.insns_int = {
1372                         BPF_ALU32_IMM(BPF_MOV, R0, 20),
1373                         BPF_ALU32_IMM(BPF_MOV, R1, 1),
1374                         BPF_ALU32_IMM(BPF_MOV, R2, 2),
1375                         BPF_ALU32_IMM(BPF_MOV, R3, 3),
1376                         BPF_ALU32_IMM(BPF_MOV, R4, 4),
1377                         BPF_ALU32_IMM(BPF_MOV, R5, 5),
1378                         BPF_ALU32_IMM(BPF_MOV, R6, 6),
1379                         BPF_ALU32_IMM(BPF_MOV, R7, 7),
1380                         BPF_ALU32_IMM(BPF_MOV, R8, 8),
1381                         BPF_ALU32_IMM(BPF_MOV, R9, 9),
1382                         BPF_ALU64_IMM(BPF_ADD, R1, 10),
1383                         BPF_ALU64_IMM(BPF_ADD, R2, 10),
1384                         BPF_ALU64_IMM(BPF_ADD, R3, 10),
1385                         BPF_ALU64_IMM(BPF_ADD, R4, 10),
1386                         BPF_ALU64_IMM(BPF_ADD, R5, 10),
1387                         BPF_ALU64_IMM(BPF_ADD, R6, 10),
1388                         BPF_ALU64_IMM(BPF_ADD, R7, 10),
1389                         BPF_ALU64_IMM(BPF_ADD, R8, 10),
1390                         BPF_ALU64_IMM(BPF_ADD, R9, 10),
1391                         BPF_ALU32_REG(BPF_ADD, R0, R1),
1392                         BPF_ALU32_REG(BPF_ADD, R0, R2),
1393                         BPF_ALU32_REG(BPF_ADD, R0, R3),
1394                         BPF_ALU32_REG(BPF_ADD, R0, R4),
1395                         BPF_ALU32_REG(BPF_ADD, R0, R5),
1396                         BPF_ALU32_REG(BPF_ADD, R0, R6),
1397                         BPF_ALU32_REG(BPF_ADD, R0, R7),
1398                         BPF_ALU32_REG(BPF_ADD, R0, R8),
1399                         BPF_ALU32_REG(BPF_ADD, R0, R9), /* R0 == 155 */
1400                         BPF_JMP_IMM(BPF_JEQ, R0, 155, 1),
1401                         BPF_EXIT_INSN(),
1402                         BPF_ALU32_REG(BPF_ADD, R1, R0),
1403                         BPF_ALU32_REG(BPF_ADD, R1, R1),
1404                         BPF_ALU32_REG(BPF_ADD, R1, R2),
1405                         BPF_ALU32_REG(BPF_ADD, R1, R3),
1406                         BPF_ALU32_REG(BPF_ADD, R1, R4),
1407                         BPF_ALU32_REG(BPF_ADD, R1, R5),
1408                         BPF_ALU32_REG(BPF_ADD, R1, R6),
1409                         BPF_ALU32_REG(BPF_ADD, R1, R7),
1410                         BPF_ALU32_REG(BPF_ADD, R1, R8),
1411                         BPF_ALU32_REG(BPF_ADD, R1, R9), /* R1 == 456 */
1412                         BPF_JMP_IMM(BPF_JEQ, R1, 456, 1),
1413                         BPF_EXIT_INSN(),
1414                         BPF_ALU32_REG(BPF_ADD, R2, R0),
1415                         BPF_ALU32_REG(BPF_ADD, R2, R1),
1416                         BPF_ALU32_REG(BPF_ADD, R2, R2),
1417                         BPF_ALU32_REG(BPF_ADD, R2, R3),
1418                         BPF_ALU32_REG(BPF_ADD, R2, R4),
1419                         BPF_ALU32_REG(BPF_ADD, R2, R5),
1420                         BPF_ALU32_REG(BPF_ADD, R2, R6),
1421                         BPF_ALU32_REG(BPF_ADD, R2, R7),
1422                         BPF_ALU32_REG(BPF_ADD, R2, R8),
1423                         BPF_ALU32_REG(BPF_ADD, R2, R9), /* R2 == 1358 */
1424                         BPF_JMP_IMM(BPF_JEQ, R2, 1358, 1),
1425                         BPF_EXIT_INSN(),
1426                         BPF_ALU32_REG(BPF_ADD, R3, R0),
1427                         BPF_ALU32_REG(BPF_ADD, R3, R1),
1428                         BPF_ALU32_REG(BPF_ADD, R3, R2),
1429                         BPF_ALU32_REG(BPF_ADD, R3, R3),
1430                         BPF_ALU32_REG(BPF_ADD, R3, R4),
1431                         BPF_ALU32_REG(BPF_ADD, R3, R5),
1432                         BPF_ALU32_REG(BPF_ADD, R3, R6),
1433                         BPF_ALU32_REG(BPF_ADD, R3, R7),
1434                         BPF_ALU32_REG(BPF_ADD, R3, R8),
1435                         BPF_ALU32_REG(BPF_ADD, R3, R9), /* R3 == 4063 */
1436                         BPF_JMP_IMM(BPF_JEQ, R3, 4063, 1),
1437                         BPF_EXIT_INSN(),
1438                         BPF_ALU32_REG(BPF_ADD, R4, R0),
1439                         BPF_ALU32_REG(BPF_ADD, R4, R1),
1440                         BPF_ALU32_REG(BPF_ADD, R4, R2),
1441                         BPF_ALU32_REG(BPF_ADD, R4, R3),
1442                         BPF_ALU32_REG(BPF_ADD, R4, R4),
1443                         BPF_ALU32_REG(BPF_ADD, R4, R5),
1444                         BPF_ALU32_REG(BPF_ADD, R4, R6),
1445                         BPF_ALU32_REG(BPF_ADD, R4, R7),
1446                         BPF_ALU32_REG(BPF_ADD, R4, R8),
1447                         BPF_ALU32_REG(BPF_ADD, R4, R9), /* R4 == 12177 */
1448                         BPF_JMP_IMM(BPF_JEQ, R4, 12177, 1),
1449                         BPF_EXIT_INSN(),
1450                         BPF_ALU32_REG(BPF_ADD, R5, R0),
1451                         BPF_ALU32_REG(BPF_ADD, R5, R1),
1452                         BPF_ALU32_REG(BPF_ADD, R5, R2),
1453                         BPF_ALU32_REG(BPF_ADD, R5, R3),
1454                         BPF_ALU32_REG(BPF_ADD, R5, R4),
1455                         BPF_ALU32_REG(BPF_ADD, R5, R5),
1456                         BPF_ALU32_REG(BPF_ADD, R5, R6),
1457                         BPF_ALU32_REG(BPF_ADD, R5, R7),
1458                         BPF_ALU32_REG(BPF_ADD, R5, R8),
1459                         BPF_ALU32_REG(BPF_ADD, R5, R9), /* R5 == 36518 */
1460                         BPF_JMP_IMM(BPF_JEQ, R5, 36518, 1),
1461                         BPF_EXIT_INSN(),
1462                         BPF_ALU32_REG(BPF_ADD, R6, R0),
1463                         BPF_ALU32_REG(BPF_ADD, R6, R1),
1464                         BPF_ALU32_REG(BPF_ADD, R6, R2),
1465                         BPF_ALU32_REG(BPF_ADD, R6, R3),
1466                         BPF_ALU32_REG(BPF_ADD, R6, R4),
1467                         BPF_ALU32_REG(BPF_ADD, R6, R5),
1468                         BPF_ALU32_REG(BPF_ADD, R6, R6),
1469                         BPF_ALU32_REG(BPF_ADD, R6, R7),
1470                         BPF_ALU32_REG(BPF_ADD, R6, R8),
1471                         BPF_ALU32_REG(BPF_ADD, R6, R9), /* R6 == 109540 */
1472                         BPF_JMP_IMM(BPF_JEQ, R6, 109540, 1),
1473                         BPF_EXIT_INSN(),
1474                         BPF_ALU32_REG(BPF_ADD, R7, R0),
1475                         BPF_ALU32_REG(BPF_ADD, R7, R1),
1476                         BPF_ALU32_REG(BPF_ADD, R7, R2),
1477                         BPF_ALU32_REG(BPF_ADD, R7, R3),
1478                         BPF_ALU32_REG(BPF_ADD, R7, R4),
1479                         BPF_ALU32_REG(BPF_ADD, R7, R5),
1480                         BPF_ALU32_REG(BPF_ADD, R7, R6),
1481                         BPF_ALU32_REG(BPF_ADD, R7, R7),
1482                         BPF_ALU32_REG(BPF_ADD, R7, R8),
1483                         BPF_ALU32_REG(BPF_ADD, R7, R9), /* R7 == 328605 */
1484                         BPF_JMP_IMM(BPF_JEQ, R7, 328605, 1),
1485                         BPF_EXIT_INSN(),
1486                         BPF_ALU32_REG(BPF_ADD, R8, R0),
1487                         BPF_ALU32_REG(BPF_ADD, R8, R1),
1488                         BPF_ALU32_REG(BPF_ADD, R8, R2),
1489                         BPF_ALU32_REG(BPF_ADD, R8, R3),
1490                         BPF_ALU32_REG(BPF_ADD, R8, R4),
1491                         BPF_ALU32_REG(BPF_ADD, R8, R5),
1492                         BPF_ALU32_REG(BPF_ADD, R8, R6),
1493                         BPF_ALU32_REG(BPF_ADD, R8, R7),
1494                         BPF_ALU32_REG(BPF_ADD, R8, R8),
1495                         BPF_ALU32_REG(BPF_ADD, R8, R9), /* R8 == 985799 */
1496                         BPF_JMP_IMM(BPF_JEQ, R8, 985799, 1),
1497                         BPF_EXIT_INSN(),
1498                         BPF_ALU32_REG(BPF_ADD, R9, R0),
1499                         BPF_ALU32_REG(BPF_ADD, R9, R1),
1500                         BPF_ALU32_REG(BPF_ADD, R9, R2),
1501                         BPF_ALU32_REG(BPF_ADD, R9, R3),
1502                         BPF_ALU32_REG(BPF_ADD, R9, R4),
1503                         BPF_ALU32_REG(BPF_ADD, R9, R5),
1504                         BPF_ALU32_REG(BPF_ADD, R9, R6),
1505                         BPF_ALU32_REG(BPF_ADD, R9, R7),
1506                         BPF_ALU32_REG(BPF_ADD, R9, R8),
1507                         BPF_ALU32_REG(BPF_ADD, R9, R9), /* R9 == 2957380 */
1508                         BPF_ALU32_REG(BPF_MOV, R0, R9),
1509                         BPF_EXIT_INSN(),
1510                 },
1511                 INTERNAL,
1512                 { },
1513                 { { 0, 2957380 } }
1514         },
1515         {       /* Mainly checking JIT here. */
1516                 "INT: SUB",
1517                 .u.insns_int = {
1518                         BPF_ALU64_IMM(BPF_MOV, R0, 0),
1519                         BPF_ALU64_IMM(BPF_MOV, R1, 1),
1520                         BPF_ALU64_IMM(BPF_MOV, R2, 2),
1521                         BPF_ALU64_IMM(BPF_MOV, R3, 3),
1522                         BPF_ALU64_IMM(BPF_MOV, R4, 4),
1523                         BPF_ALU64_IMM(BPF_MOV, R5, 5),
1524                         BPF_ALU64_IMM(BPF_MOV, R6, 6),
1525                         BPF_ALU64_IMM(BPF_MOV, R7, 7),
1526                         BPF_ALU64_IMM(BPF_MOV, R8, 8),
1527                         BPF_ALU64_IMM(BPF_MOV, R9, 9),
1528                         BPF_ALU64_REG(BPF_SUB, R0, R0),
1529                         BPF_ALU64_REG(BPF_SUB, R0, R1),
1530                         BPF_ALU64_REG(BPF_SUB, R0, R2),
1531                         BPF_ALU64_REG(BPF_SUB, R0, R3),
1532                         BPF_ALU64_REG(BPF_SUB, R0, R4),
1533                         BPF_ALU64_REG(BPF_SUB, R0, R5),
1534                         BPF_ALU64_REG(BPF_SUB, R0, R6),
1535                         BPF_ALU64_REG(BPF_SUB, R0, R7),
1536                         BPF_ALU64_REG(BPF_SUB, R0, R8),
1537                         BPF_ALU64_REG(BPF_SUB, R0, R9),
1538                         BPF_ALU64_IMM(BPF_SUB, R0, 10),
1539                         BPF_JMP_IMM(BPF_JEQ, R0, -55, 1),
1540                         BPF_EXIT_INSN(),
1541                         BPF_ALU64_REG(BPF_SUB, R1, R0),
1542                         BPF_ALU64_REG(BPF_SUB, R1, R2),
1543                         BPF_ALU64_REG(BPF_SUB, R1, R3),
1544                         BPF_ALU64_REG(BPF_SUB, R1, R4),
1545                         BPF_ALU64_REG(BPF_SUB, R1, R5),
1546                         BPF_ALU64_REG(BPF_SUB, R1, R6),
1547                         BPF_ALU64_REG(BPF_SUB, R1, R7),
1548                         BPF_ALU64_REG(BPF_SUB, R1, R8),
1549                         BPF_ALU64_REG(BPF_SUB, R1, R9),
1550                         BPF_ALU64_IMM(BPF_SUB, R1, 10),
1551                         BPF_ALU64_REG(BPF_SUB, R2, R0),
1552                         BPF_ALU64_REG(BPF_SUB, R2, R1),
1553                         BPF_ALU64_REG(BPF_SUB, R2, R3),
1554                         BPF_ALU64_REG(BPF_SUB, R2, R4),
1555                         BPF_ALU64_REG(BPF_SUB, R2, R5),
1556                         BPF_ALU64_REG(BPF_SUB, R2, R6),
1557                         BPF_ALU64_REG(BPF_SUB, R2, R7),
1558                         BPF_ALU64_REG(BPF_SUB, R2, R8),
1559                         BPF_ALU64_REG(BPF_SUB, R2, R9),
1560                         BPF_ALU64_IMM(BPF_SUB, R2, 10),
1561                         BPF_ALU64_REG(BPF_SUB, R3, R0),
1562                         BPF_ALU64_REG(BPF_SUB, R3, R1),
1563                         BPF_ALU64_REG(BPF_SUB, R3, R2),
1564                         BPF_ALU64_REG(BPF_SUB, R3, R4),
1565                         BPF_ALU64_REG(BPF_SUB, R3, R5),
1566                         BPF_ALU64_REG(BPF_SUB, R3, R6),
1567                         BPF_ALU64_REG(BPF_SUB, R3, R7),
1568                         BPF_ALU64_REG(BPF_SUB, R3, R8),
1569                         BPF_ALU64_REG(BPF_SUB, R3, R9),
1570                         BPF_ALU64_IMM(BPF_SUB, R3, 10),
1571                         BPF_ALU64_REG(BPF_SUB, R4, R0),
1572                         BPF_ALU64_REG(BPF_SUB, R4, R1),
1573                         BPF_ALU64_REG(BPF_SUB, R4, R2),
1574                         BPF_ALU64_REG(BPF_SUB, R4, R3),
1575                         BPF_ALU64_REG(BPF_SUB, R4, R5),
1576                         BPF_ALU64_REG(BPF_SUB, R4, R6),
1577                         BPF_ALU64_REG(BPF_SUB, R4, R7),
1578                         BPF_ALU64_REG(BPF_SUB, R4, R8),
1579                         BPF_ALU64_REG(BPF_SUB, R4, R9),
1580                         BPF_ALU64_IMM(BPF_SUB, R4, 10),
1581                         BPF_ALU64_REG(BPF_SUB, R5, R0),
1582                         BPF_ALU64_REG(BPF_SUB, R5, R1),
1583                         BPF_ALU64_REG(BPF_SUB, R5, R2),
1584                         BPF_ALU64_REG(BPF_SUB, R5, R3),
1585                         BPF_ALU64_REG(BPF_SUB, R5, R4),
1586                         BPF_ALU64_REG(BPF_SUB, R5, R6),
1587                         BPF_ALU64_REG(BPF_SUB, R5, R7),
1588                         BPF_ALU64_REG(BPF_SUB, R5, R8),
1589                         BPF_ALU64_REG(BPF_SUB, R5, R9),
1590                         BPF_ALU64_IMM(BPF_SUB, R5, 10),
1591                         BPF_ALU64_REG(BPF_SUB, R6, R0),
1592                         BPF_ALU64_REG(BPF_SUB, R6, R1),
1593                         BPF_ALU64_REG(BPF_SUB, R6, R2),
1594                         BPF_ALU64_REG(BPF_SUB, R6, R3),
1595                         BPF_ALU64_REG(BPF_SUB, R6, R4),
1596                         BPF_ALU64_REG(BPF_SUB, R6, R5),
1597                         BPF_ALU64_REG(BPF_SUB, R6, R7),
1598                         BPF_ALU64_REG(BPF_SUB, R6, R8),
1599                         BPF_ALU64_REG(BPF_SUB, R6, R9),
1600                         BPF_ALU64_IMM(BPF_SUB, R6, 10),
1601                         BPF_ALU64_REG(BPF_SUB, R7, R0),
1602                         BPF_ALU64_REG(BPF_SUB, R7, R1),
1603                         BPF_ALU64_REG(BPF_SUB, R7, R2),
1604                         BPF_ALU64_REG(BPF_SUB, R7, R3),
1605                         BPF_ALU64_REG(BPF_SUB, R7, R4),
1606                         BPF_ALU64_REG(BPF_SUB, R7, R5),
1607                         BPF_ALU64_REG(BPF_SUB, R7, R6),
1608                         BPF_ALU64_REG(BPF_SUB, R7, R8),
1609                         BPF_ALU64_REG(BPF_SUB, R7, R9),
1610                         BPF_ALU64_IMM(BPF_SUB, R7, 10),
1611                         BPF_ALU64_REG(BPF_SUB, R8, R0),
1612                         BPF_ALU64_REG(BPF_SUB, R8, R1),
1613                         BPF_ALU64_REG(BPF_SUB, R8, R2),
1614                         BPF_ALU64_REG(BPF_SUB, R8, R3),
1615                         BPF_ALU64_REG(BPF_SUB, R8, R4),
1616                         BPF_ALU64_REG(BPF_SUB, R8, R5),
1617                         BPF_ALU64_REG(BPF_SUB, R8, R6),
1618                         BPF_ALU64_REG(BPF_SUB, R8, R7),
1619                         BPF_ALU64_REG(BPF_SUB, R8, R9),
1620                         BPF_ALU64_IMM(BPF_SUB, R8, 10),
1621                         BPF_ALU64_REG(BPF_SUB, R9, R0),
1622                         BPF_ALU64_REG(BPF_SUB, R9, R1),
1623                         BPF_ALU64_REG(BPF_SUB, R9, R2),
1624                         BPF_ALU64_REG(BPF_SUB, R9, R3),
1625                         BPF_ALU64_REG(BPF_SUB, R9, R4),
1626                         BPF_ALU64_REG(BPF_SUB, R9, R5),
1627                         BPF_ALU64_REG(BPF_SUB, R9, R6),
1628                         BPF_ALU64_REG(BPF_SUB, R9, R7),
1629                         BPF_ALU64_REG(BPF_SUB, R9, R8),
1630                         BPF_ALU64_IMM(BPF_SUB, R9, 10),
1631                         BPF_ALU64_IMM(BPF_SUB, R0, 10),
1632                         BPF_ALU64_IMM(BPF_NEG, R0, 0),
1633                         BPF_ALU64_REG(BPF_SUB, R0, R1),
1634                         BPF_ALU64_REG(BPF_SUB, R0, R2),
1635                         BPF_ALU64_REG(BPF_SUB, R0, R3),
1636                         BPF_ALU64_REG(BPF_SUB, R0, R4),
1637                         BPF_ALU64_REG(BPF_SUB, R0, R5),
1638                         BPF_ALU64_REG(BPF_SUB, R0, R6),
1639                         BPF_ALU64_REG(BPF_SUB, R0, R7),
1640                         BPF_ALU64_REG(BPF_SUB, R0, R8),
1641                         BPF_ALU64_REG(BPF_SUB, R0, R9),
1642                         BPF_EXIT_INSN(),
1643                 },
1644                 INTERNAL,
1645                 { },
1646                 { { 0, 11 } }
1647         },
1648         {       /* Mainly checking JIT here. */
1649                 "INT: XOR",
1650                 .u.insns_int = {
1651                         BPF_ALU64_REG(BPF_SUB, R0, R0),
1652                         BPF_ALU64_REG(BPF_XOR, R1, R1),
1653                         BPF_JMP_REG(BPF_JEQ, R0, R1, 1),
1654                         BPF_EXIT_INSN(),
1655                         BPF_ALU64_IMM(BPF_MOV, R0, 10),
1656                         BPF_ALU64_IMM(BPF_MOV, R1, -1),
1657                         BPF_ALU64_REG(BPF_SUB, R1, R1),
1658                         BPF_ALU64_REG(BPF_XOR, R2, R2),
1659                         BPF_JMP_REG(BPF_JEQ, R1, R2, 1),
1660                         BPF_EXIT_INSN(),
1661                         BPF_ALU64_REG(BPF_SUB, R2, R2),
1662                         BPF_ALU64_REG(BPF_XOR, R3, R3),
1663                         BPF_ALU64_IMM(BPF_MOV, R0, 10),
1664                         BPF_ALU64_IMM(BPF_MOV, R1, -1),
1665                         BPF_JMP_REG(BPF_JEQ, R2, R3, 1),
1666                         BPF_EXIT_INSN(),
1667                         BPF_ALU64_REG(BPF_SUB, R3, R3),
1668                         BPF_ALU64_REG(BPF_XOR, R4, R4),
1669                         BPF_ALU64_IMM(BPF_MOV, R2, 1),
1670                         BPF_ALU64_IMM(BPF_MOV, R5, -1),
1671                         BPF_JMP_REG(BPF_JEQ, R3, R4, 1),
1672                         BPF_EXIT_INSN(),
1673                         BPF_ALU64_REG(BPF_SUB, R4, R4),
1674                         BPF_ALU64_REG(BPF_XOR, R5, R5),
1675                         BPF_ALU64_IMM(BPF_MOV, R3, 1),
1676                         BPF_ALU64_IMM(BPF_MOV, R7, -1),
1677                         BPF_JMP_REG(BPF_JEQ, R5, R4, 1),
1678                         BPF_EXIT_INSN(),
1679                         BPF_ALU64_IMM(BPF_MOV, R5, 1),
1680                         BPF_ALU64_REG(BPF_SUB, R5, R5),
1681                         BPF_ALU64_REG(BPF_XOR, R6, R6),
1682                         BPF_ALU64_IMM(BPF_MOV, R1, 1),
1683                         BPF_ALU64_IMM(BPF_MOV, R8, -1),
1684                         BPF_JMP_REG(BPF_JEQ, R5, R6, 1),
1685                         BPF_EXIT_INSN(),
1686                         BPF_ALU64_REG(BPF_SUB, R6, R6),
1687                         BPF_ALU64_REG(BPF_XOR, R7, R7),
1688                         BPF_JMP_REG(BPF_JEQ, R7, R6, 1),
1689                         BPF_EXIT_INSN(),
1690                         BPF_ALU64_REG(BPF_SUB, R7, R7),
1691                         BPF_ALU64_REG(BPF_XOR, R8, R8),
1692                         BPF_JMP_REG(BPF_JEQ, R7, R8, 1),
1693                         BPF_EXIT_INSN(),
1694                         BPF_ALU64_REG(BPF_SUB, R8, R8),
1695                         BPF_ALU64_REG(BPF_XOR, R9, R9),
1696                         BPF_JMP_REG(BPF_JEQ, R9, R8, 1),
1697                         BPF_EXIT_INSN(),
1698                         BPF_ALU64_REG(BPF_SUB, R9, R9),
1699                         BPF_ALU64_REG(BPF_XOR, R0, R0),
1700                         BPF_JMP_REG(BPF_JEQ, R9, R0, 1),
1701                         BPF_EXIT_INSN(),
1702                         BPF_ALU64_REG(BPF_SUB, R1, R1),
1703                         BPF_ALU64_REG(BPF_XOR, R0, R0),
1704                         BPF_JMP_REG(BPF_JEQ, R9, R0, 2),
1705                         BPF_ALU64_IMM(BPF_MOV, R0, 0),
1706                         BPF_EXIT_INSN(),
1707                         BPF_ALU64_IMM(BPF_MOV, R0, 1),
1708                         BPF_EXIT_INSN(),
1709                 },
1710                 INTERNAL,
1711                 { },
1712                 { { 0, 1 } }
1713         },
1714         {       /* Mainly checking JIT here. */
1715                 "INT: MUL",
1716                 .u.insns_int = {
1717                         BPF_ALU64_IMM(BPF_MOV, R0, 11),
1718                         BPF_ALU64_IMM(BPF_MOV, R1, 1),
1719                         BPF_ALU64_IMM(BPF_MOV, R2, 2),
1720                         BPF_ALU64_IMM(BPF_MOV, R3, 3),
1721                         BPF_ALU64_IMM(BPF_MOV, R4, 4),
1722                         BPF_ALU64_IMM(BPF_MOV, R5, 5),
1723                         BPF_ALU64_IMM(BPF_MOV, R6, 6),
1724                         BPF_ALU64_IMM(BPF_MOV, R7, 7),
1725                         BPF_ALU64_IMM(BPF_MOV, R8, 8),
1726                         BPF_ALU64_IMM(BPF_MOV, R9, 9),
1727                         BPF_ALU64_REG(BPF_MUL, R0, R0),
1728                         BPF_ALU64_REG(BPF_MUL, R0, R1),
1729                         BPF_ALU64_REG(BPF_MUL, R0, R2),
1730                         BPF_ALU64_REG(BPF_MUL, R0, R3),
1731                         BPF_ALU64_REG(BPF_MUL, R0, R4),
1732                         BPF_ALU64_REG(BPF_MUL, R0, R5),
1733                         BPF_ALU64_REG(BPF_MUL, R0, R6),
1734                         BPF_ALU64_REG(BPF_MUL, R0, R7),
1735                         BPF_ALU64_REG(BPF_MUL, R0, R8),
1736                         BPF_ALU64_REG(BPF_MUL, R0, R9),
1737                         BPF_ALU64_IMM(BPF_MUL, R0, 10),
1738                         BPF_JMP_IMM(BPF_JEQ, R0, 439084800, 1),
1739                         BPF_EXIT_INSN(),
1740                         BPF_ALU64_REG(BPF_MUL, R1, R0),
1741                         BPF_ALU64_REG(BPF_MUL, R1, R2),
1742                         BPF_ALU64_REG(BPF_MUL, R1, R3),
1743                         BPF_ALU64_REG(BPF_MUL, R1, R4),
1744                         BPF_ALU64_REG(BPF_MUL, R1, R5),
1745                         BPF_ALU64_REG(BPF_MUL, R1, R6),
1746                         BPF_ALU64_REG(BPF_MUL, R1, R7),
1747                         BPF_ALU64_REG(BPF_MUL, R1, R8),
1748                         BPF_ALU64_REG(BPF_MUL, R1, R9),
1749                         BPF_ALU64_IMM(BPF_MUL, R1, 10),
1750                         BPF_ALU64_REG(BPF_MOV, R2, R1),
1751                         BPF_ALU64_IMM(BPF_RSH, R2, 32),
1752                         BPF_JMP_IMM(BPF_JEQ, R2, 0x5a924, 1),
1753                         BPF_EXIT_INSN(),
1754                         BPF_ALU64_IMM(BPF_LSH, R1, 32),
1755                         BPF_ALU64_IMM(BPF_ARSH, R1, 32),
1756                         BPF_JMP_IMM(BPF_JEQ, R1, 0xebb90000, 1),
1757                         BPF_EXIT_INSN(),
1758                         BPF_ALU64_REG(BPF_MUL, R2, R0),
1759                         BPF_ALU64_REG(BPF_MUL, R2, R1),
1760                         BPF_ALU64_REG(BPF_MUL, R2, R3),
1761                         BPF_ALU64_REG(BPF_MUL, R2, R4),
1762                         BPF_ALU64_REG(BPF_MUL, R2, R5),
1763                         BPF_ALU64_REG(BPF_MUL, R2, R6),
1764                         BPF_ALU64_REG(BPF_MUL, R2, R7),
1765                         BPF_ALU64_REG(BPF_MUL, R2, R8),
1766                         BPF_ALU64_REG(BPF_MUL, R2, R9),
1767                         BPF_ALU64_IMM(BPF_MUL, R2, 10),
1768                         BPF_ALU64_IMM(BPF_RSH, R2, 32),
1769                         BPF_ALU64_REG(BPF_MOV, R0, R2),
1770                         BPF_EXIT_INSN(),
1771                 },
1772                 INTERNAL,
1773                 { },
1774                 { { 0, 0x35d97ef2 } }
1775         },
1776         {       /* Mainly checking JIT here. */
1777                 "MOV REG64",
1778                 .u.insns_int = {
1779                         BPF_LD_IMM64(R0, 0xffffffffffffffffLL),
1780                         BPF_MOV64_REG(R1, R0),
1781                         BPF_MOV64_REG(R2, R1),
1782                         BPF_MOV64_REG(R3, R2),
1783                         BPF_MOV64_REG(R4, R3),
1784                         BPF_MOV64_REG(R5, R4),
1785                         BPF_MOV64_REG(R6, R5),
1786                         BPF_MOV64_REG(R7, R6),
1787                         BPF_MOV64_REG(R8, R7),
1788                         BPF_MOV64_REG(R9, R8),
1789                         BPF_ALU64_IMM(BPF_MOV, R0, 0),
1790                         BPF_ALU64_IMM(BPF_MOV, R1, 0),
1791                         BPF_ALU64_IMM(BPF_MOV, R2, 0),
1792                         BPF_ALU64_IMM(BPF_MOV, R3, 0),
1793                         BPF_ALU64_IMM(BPF_MOV, R4, 0),
1794                         BPF_ALU64_IMM(BPF_MOV, R5, 0),
1795                         BPF_ALU64_IMM(BPF_MOV, R6, 0),
1796                         BPF_ALU64_IMM(BPF_MOV, R7, 0),
1797                         BPF_ALU64_IMM(BPF_MOV, R8, 0),
1798                         BPF_ALU64_IMM(BPF_MOV, R9, 0),
1799                         BPF_ALU64_REG(BPF_ADD, R0, R0),
1800                         BPF_ALU64_REG(BPF_ADD, R0, R1),
1801                         BPF_ALU64_REG(BPF_ADD, R0, R2),
1802                         BPF_ALU64_REG(BPF_ADD, R0, R3),
1803                         BPF_ALU64_REG(BPF_ADD, R0, R4),
1804                         BPF_ALU64_REG(BPF_ADD, R0, R5),
1805                         BPF_ALU64_REG(BPF_ADD, R0, R6),
1806                         BPF_ALU64_REG(BPF_ADD, R0, R7),
1807                         BPF_ALU64_REG(BPF_ADD, R0, R8),
1808                         BPF_ALU64_REG(BPF_ADD, R0, R9),
1809                         BPF_ALU64_IMM(BPF_ADD, R0, 0xfefe),
1810                         BPF_EXIT_INSN(),
1811                 },
1812                 INTERNAL,
1813                 { },
1814                 { { 0, 0xfefe } }
1815         },
1816         {       /* Mainly checking JIT here. */
1817                 "MOV REG32",
1818                 .u.insns_int = {
1819                         BPF_LD_IMM64(R0, 0xffffffffffffffffLL),
1820                         BPF_MOV64_REG(R1, R0),
1821                         BPF_MOV64_REG(R2, R1),
1822                         BPF_MOV64_REG(R3, R2),
1823                         BPF_MOV64_REG(R4, R3),
1824                         BPF_MOV64_REG(R5, R4),
1825                         BPF_MOV64_REG(R6, R5),
1826                         BPF_MOV64_REG(R7, R6),
1827                         BPF_MOV64_REG(R8, R7),
1828                         BPF_MOV64_REG(R9, R8),
1829                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
1830                         BPF_ALU32_IMM(BPF_MOV, R1, 0),
1831                         BPF_ALU32_IMM(BPF_MOV, R2, 0),
1832                         BPF_ALU32_IMM(BPF_MOV, R3, 0),
1833                         BPF_ALU32_IMM(BPF_MOV, R4, 0),
1834                         BPF_ALU32_IMM(BPF_MOV, R5, 0),
1835                         BPF_ALU32_IMM(BPF_MOV, R6, 0),
1836                         BPF_ALU32_IMM(BPF_MOV, R7, 0),
1837                         BPF_ALU32_IMM(BPF_MOV, R8, 0),
1838                         BPF_ALU32_IMM(BPF_MOV, R9, 0),
1839                         BPF_ALU64_REG(BPF_ADD, R0, R0),
1840                         BPF_ALU64_REG(BPF_ADD, R0, R1),
1841                         BPF_ALU64_REG(BPF_ADD, R0, R2),
1842                         BPF_ALU64_REG(BPF_ADD, R0, R3),
1843                         BPF_ALU64_REG(BPF_ADD, R0, R4),
1844                         BPF_ALU64_REG(BPF_ADD, R0, R5),
1845                         BPF_ALU64_REG(BPF_ADD, R0, R6),
1846                         BPF_ALU64_REG(BPF_ADD, R0, R7),
1847                         BPF_ALU64_REG(BPF_ADD, R0, R8),
1848                         BPF_ALU64_REG(BPF_ADD, R0, R9),
1849                         BPF_ALU64_IMM(BPF_ADD, R0, 0xfefe),
1850                         BPF_EXIT_INSN(),
1851                 },
1852                 INTERNAL,
1853                 { },
1854                 { { 0, 0xfefe } }
1855         },
1856         {       /* Mainly checking JIT here. */
1857                 "LD IMM64",
1858                 .u.insns_int = {
1859                         BPF_LD_IMM64(R0, 0xffffffffffffffffLL),
1860                         BPF_MOV64_REG(R1, R0),
1861                         BPF_MOV64_REG(R2, R1),
1862                         BPF_MOV64_REG(R3, R2),
1863                         BPF_MOV64_REG(R4, R3),
1864                         BPF_MOV64_REG(R5, R4),
1865                         BPF_MOV64_REG(R6, R5),
1866                         BPF_MOV64_REG(R7, R6),
1867                         BPF_MOV64_REG(R8, R7),
1868                         BPF_MOV64_REG(R9, R8),
1869                         BPF_LD_IMM64(R0, 0x0LL),
1870                         BPF_LD_IMM64(R1, 0x0LL),
1871                         BPF_LD_IMM64(R2, 0x0LL),
1872                         BPF_LD_IMM64(R3, 0x0LL),
1873                         BPF_LD_IMM64(R4, 0x0LL),
1874                         BPF_LD_IMM64(R5, 0x0LL),
1875                         BPF_LD_IMM64(R6, 0x0LL),
1876                         BPF_LD_IMM64(R7, 0x0LL),
1877                         BPF_LD_IMM64(R8, 0x0LL),
1878                         BPF_LD_IMM64(R9, 0x0LL),
1879                         BPF_ALU64_REG(BPF_ADD, R0, R0),
1880                         BPF_ALU64_REG(BPF_ADD, R0, R1),
1881                         BPF_ALU64_REG(BPF_ADD, R0, R2),
1882                         BPF_ALU64_REG(BPF_ADD, R0, R3),
1883                         BPF_ALU64_REG(BPF_ADD, R0, R4),
1884                         BPF_ALU64_REG(BPF_ADD, R0, R5),
1885                         BPF_ALU64_REG(BPF_ADD, R0, R6),
1886                         BPF_ALU64_REG(BPF_ADD, R0, R7),
1887                         BPF_ALU64_REG(BPF_ADD, R0, R8),
1888                         BPF_ALU64_REG(BPF_ADD, R0, R9),
1889                         BPF_ALU64_IMM(BPF_ADD, R0, 0xfefe),
1890                         BPF_EXIT_INSN(),
1891                 },
1892                 INTERNAL,
1893                 { },
1894                 { { 0, 0xfefe } }
1895         },
1896         {
1897                 "INT: ALU MIX",
1898                 .u.insns_int = {
1899                         BPF_ALU64_IMM(BPF_MOV, R0, 11),
1900                         BPF_ALU64_IMM(BPF_ADD, R0, -1),
1901                         BPF_ALU64_IMM(BPF_MOV, R2, 2),
1902                         BPF_ALU64_IMM(BPF_XOR, R2, 3),
1903                         BPF_ALU64_REG(BPF_DIV, R0, R2),
1904                         BPF_JMP_IMM(BPF_JEQ, R0, 10, 1),
1905                         BPF_EXIT_INSN(),
1906                         BPF_ALU64_IMM(BPF_MOD, R0, 3),
1907                         BPF_JMP_IMM(BPF_JEQ, R0, 1, 1),
1908                         BPF_EXIT_INSN(),
1909                         BPF_ALU64_IMM(BPF_MOV, R0, -1),
1910                         BPF_EXIT_INSN(),
1911                 },
1912                 INTERNAL,
1913                 { },
1914                 { { 0, -1 } }
1915         },
1916         {
1917                 "INT: shifts by register",
1918                 .u.insns_int = {
1919                         BPF_MOV64_IMM(R0, -1234),
1920                         BPF_MOV64_IMM(R1, 1),
1921                         BPF_ALU32_REG(BPF_RSH, R0, R1),
1922                         BPF_JMP_IMM(BPF_JEQ, R0, 0x7ffffd97, 1),
1923                         BPF_EXIT_INSN(),
1924                         BPF_MOV64_IMM(R2, 1),
1925                         BPF_ALU64_REG(BPF_LSH, R0, R2),
1926                         BPF_MOV32_IMM(R4, -1234),
1927                         BPF_JMP_REG(BPF_JEQ, R0, R4, 1),
1928                         BPF_EXIT_INSN(),
1929                         BPF_ALU64_IMM(BPF_AND, R4, 63),
1930                         BPF_ALU64_REG(BPF_LSH, R0, R4), /* R0 <= 46 */
1931                         BPF_MOV64_IMM(R3, 47),
1932                         BPF_ALU64_REG(BPF_ARSH, R0, R3),
1933                         BPF_JMP_IMM(BPF_JEQ, R0, -617, 1),
1934                         BPF_EXIT_INSN(),
1935                         BPF_MOV64_IMM(R2, 1),
1936                         BPF_ALU64_REG(BPF_LSH, R4, R2), /* R4 = 46 << 1 */
1937                         BPF_JMP_IMM(BPF_JEQ, R4, 92, 1),
1938                         BPF_EXIT_INSN(),
1939                         BPF_MOV64_IMM(R4, 4),
1940                         BPF_ALU64_REG(BPF_LSH, R4, R4), /* R4 = 4 << 4 */
1941                         BPF_JMP_IMM(BPF_JEQ, R4, 64, 1),
1942                         BPF_EXIT_INSN(),
1943                         BPF_MOV64_IMM(R4, 5),
1944                         BPF_ALU32_REG(BPF_LSH, R4, R4), /* R4 = 5 << 5 */
1945                         BPF_JMP_IMM(BPF_JEQ, R4, 160, 1),
1946                         BPF_EXIT_INSN(),
1947                         BPF_MOV64_IMM(R0, -1),
1948                         BPF_EXIT_INSN(),
1949                 },
1950                 INTERNAL,
1951                 { },
1952                 { { 0, -1 } }
1953         },
1954         {
1955                 "INT: DIV + ABS",
1956                 .u.insns_int = {
1957                         BPF_ALU64_REG(BPF_MOV, R6, R1),
1958                         BPF_LD_ABS(BPF_B, 3),
1959                         BPF_ALU64_IMM(BPF_MOV, R2, 2),
1960                         BPF_ALU32_REG(BPF_DIV, R0, R2),
1961                         BPF_ALU64_REG(BPF_MOV, R8, R0),
1962                         BPF_LD_ABS(BPF_B, 4),
1963                         BPF_ALU64_REG(BPF_ADD, R8, R0),
1964                         BPF_LD_IND(BPF_B, R8, -70),
1965                         BPF_EXIT_INSN(),
1966                 },
1967                 INTERNAL,
1968                 { 10, 20, 30, 40, 50 },
1969                 { { 4, 0 }, { 5, 10 } }
1970         },
1971         {
1972                 "INT: DIV by zero",
1973                 .u.insns_int = {
1974                         BPF_ALU64_REG(BPF_MOV, R6, R1),
1975                         BPF_ALU64_IMM(BPF_MOV, R7, 0),
1976                         BPF_LD_ABS(BPF_B, 3),
1977                         BPF_ALU32_REG(BPF_DIV, R0, R7),
1978                         BPF_EXIT_INSN(),
1979                 },
1980                 INTERNAL,
1981                 { 10, 20, 30, 40, 50 },
1982                 { { 3, 0 }, { 4, 0 } }
1983         },
1984         {
1985                 "check: missing ret",
1986                 .u.insns = {
1987                         BPF_STMT(BPF_LD | BPF_IMM, 1),
1988                 },
1989                 CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL,
1990                 { },
1991                 { },
1992                 .fill_helper = NULL,
1993                 .expected_errcode = -EINVAL,
1994         },
1995         {
1996                 "check: div_k_0",
1997                 .u.insns = {
1998                         BPF_STMT(BPF_ALU | BPF_DIV | BPF_K, 0),
1999                         BPF_STMT(BPF_RET | BPF_K, 0)
2000                 },
2001                 CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL,
2002                 { },
2003                 { },
2004                 .fill_helper = NULL,
2005                 .expected_errcode = -EINVAL,
2006         },
2007         {
2008                 "check: unknown insn",
2009                 .u.insns = {
2010                         /* seccomp insn, rejected in socket filter */
2011                         BPF_STMT(BPF_LDX | BPF_W | BPF_ABS, 0),
2012                         BPF_STMT(BPF_RET | BPF_K, 0)
2013                 },
2014                 CLASSIC | FLAG_EXPECTED_FAIL,
2015                 { },
2016                 { },
2017                 .fill_helper = NULL,
2018                 .expected_errcode = -EINVAL,
2019         },
2020         {
2021                 "check: out of range spill/fill",
2022                 .u.insns = {
2023                         BPF_STMT(BPF_STX, 16),
2024                         BPF_STMT(BPF_RET | BPF_K, 0)
2025                 },
2026                 CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL,
2027                 { },
2028                 { },
2029                 .fill_helper = NULL,
2030                 .expected_errcode = -EINVAL,
2031         },
2032         {
2033                 "JUMPS + HOLES",
2034                 .u.insns = {
2035                         BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2036                         BPF_JUMP(BPF_JMP | BPF_JGE, 0, 13, 15),
2037                         BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2038                         BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2039                         BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2040                         BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2041                         BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2042                         BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2043                         BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2044                         BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2045                         BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2046                         BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2047                         BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2048                         BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2049                         BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2050                         BPF_JUMP(BPF_JMP | BPF_JEQ, 0x90c2894d, 3, 4),
2051                         BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2052                         BPF_JUMP(BPF_JMP | BPF_JEQ, 0x90c2894d, 1, 2),
2053                         BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2054                         BPF_JUMP(BPF_JMP | BPF_JGE, 0, 14, 15),
2055                         BPF_JUMP(BPF_JMP | BPF_JGE, 0, 13, 14),
2056                         BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2057                         BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2058                         BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2059                         BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2060                         BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2061                         BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2062                         BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2063                         BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2064                         BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2065                         BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2066                         BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2067                         BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2068                         BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2069                         BPF_JUMP(BPF_JMP | BPF_JEQ, 0x2ac28349, 2, 3),
2070                         BPF_JUMP(BPF_JMP | BPF_JEQ, 0x2ac28349, 1, 2),
2071                         BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2072                         BPF_JUMP(BPF_JMP | BPF_JGE, 0, 14, 15),
2073                         BPF_JUMP(BPF_JMP | BPF_JGE, 0, 13, 14),
2074                         BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2075                         BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2076                         BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2077                         BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2078                         BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2079                         BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2080                         BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2081                         BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2082                         BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2083                         BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2084                         BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2085                         BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2086                         BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2087                         BPF_JUMP(BPF_JMP | BPF_JEQ, 0x90d2ff41, 2, 3),
2088                         BPF_JUMP(BPF_JMP | BPF_JEQ, 0x90d2ff41, 1, 2),
2089                         BPF_STMT(BPF_LD | BPF_H | BPF_ABS, 0),
2090                         BPF_STMT(BPF_RET | BPF_A, 0),
2091                         BPF_STMT(BPF_RET | BPF_A, 0),
2092                 },
2093                 CLASSIC,
2094                 { 0x00, 0x1b, 0x21, 0x3c, 0x9d, 0xf8,
2095                   0x90, 0xe2, 0xba, 0x0a, 0x56, 0xb4,
2096                   0x08, 0x00,
2097                   0x45, 0x00, 0x00, 0x28, 0x00, 0x00,
2098                   0x20, 0x00, 0x40, 0x11, 0x00, 0x00, /* IP header */
2099                   0xc0, 0xa8, 0x33, 0x01,
2100                   0xc0, 0xa8, 0x33, 0x02,
2101                   0xbb, 0xb6,
2102                   0xa9, 0xfa,
2103                   0x00, 0x14, 0x00, 0x00,
2104                   0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
2105                   0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
2106                   0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
2107                   0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
2108                   0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
2109                   0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
2110                   0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
2111                   0xcc, 0xcc, 0xcc, 0xcc },
2112                 { { 88, 0x001b } }
2113         },
2114         {
2115                 "check: RET X",
2116                 .u.insns = {
2117                         BPF_STMT(BPF_RET | BPF_X, 0),
2118                 },
2119                 CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL,
2120                 { },
2121                 { },
2122                 .fill_helper = NULL,
2123                 .expected_errcode = -EINVAL,
2124         },
2125         {
2126                 "check: LDX + RET X",
2127                 .u.insns = {
2128                         BPF_STMT(BPF_LDX | BPF_IMM, 42),
2129                         BPF_STMT(BPF_RET | BPF_X, 0),
2130                 },
2131                 CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL,
2132                 { },
2133                 { },
2134                 .fill_helper = NULL,
2135                 .expected_errcode = -EINVAL,
2136         },
2137         {       /* Mainly checking JIT here. */
2138                 "M[]: alt STX + LDX",
2139                 .u.insns = {
2140                         BPF_STMT(BPF_LDX | BPF_IMM, 100),
2141                         BPF_STMT(BPF_STX, 0),
2142                         BPF_STMT(BPF_LDX | BPF_MEM, 0),
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, 1),
2147                         BPF_STMT(BPF_LDX | BPF_MEM, 1),
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, 2),
2152                         BPF_STMT(BPF_LDX | BPF_MEM, 2),
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_STX, 3),
2157                         BPF_STMT(BPF_LDX | BPF_MEM, 3),
2158                         BPF_STMT(BPF_MISC | BPF_TXA, 0),
2159                         BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1),
2160                         BPF_STMT(BPF_MISC | BPF_TAX, 0),
2161                         BPF_STMT(BPF_STX, 4),
2162                         BPF_STMT(BPF_LDX | BPF_MEM, 4),
2163                         BPF_STMT(BPF_MISC | BPF_TXA, 0),
2164                         BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1),
2165                         BPF_STMT(BPF_MISC | BPF_TAX, 0),
2166                         BPF_STMT(BPF_STX, 5),
2167                         BPF_STMT(BPF_LDX | BPF_MEM, 5),
2168                         BPF_STMT(BPF_MISC | BPF_TXA, 0),
2169                         BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1),
2170                         BPF_STMT(BPF_MISC | BPF_TAX, 0),
2171                         BPF_STMT(BPF_STX, 6),
2172                         BPF_STMT(BPF_LDX | BPF_MEM, 6),
2173                         BPF_STMT(BPF_MISC | BPF_TXA, 0),
2174                         BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1),
2175                         BPF_STMT(BPF_MISC | BPF_TAX, 0),
2176                         BPF_STMT(BPF_STX, 7),
2177                         BPF_STMT(BPF_LDX | BPF_MEM, 7),
2178                         BPF_STMT(BPF_MISC | BPF_TXA, 0),
2179                         BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1),
2180                         BPF_STMT(BPF_MISC | BPF_TAX, 0),
2181                         BPF_STMT(BPF_STX, 8),
2182                         BPF_STMT(BPF_LDX | BPF_MEM, 8),
2183                         BPF_STMT(BPF_MISC | BPF_TXA, 0),
2184                         BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1),
2185                         BPF_STMT(BPF_MISC | BPF_TAX, 0),
2186                         BPF_STMT(BPF_STX, 9),
2187                         BPF_STMT(BPF_LDX | BPF_MEM, 9),
2188                         BPF_STMT(BPF_MISC | BPF_TXA, 0),
2189                         BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1),
2190                         BPF_STMT(BPF_MISC | BPF_TAX, 0),
2191                         BPF_STMT(BPF_STX, 10),
2192                         BPF_STMT(BPF_LDX | BPF_MEM, 10),
2193                         BPF_STMT(BPF_MISC | BPF_TXA, 0),
2194                         BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1),
2195                         BPF_STMT(BPF_MISC | BPF_TAX, 0),
2196                         BPF_STMT(BPF_STX, 11),
2197                         BPF_STMT(BPF_LDX | BPF_MEM, 11),
2198                         BPF_STMT(BPF_MISC | BPF_TXA, 0),
2199                         BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1),
2200                         BPF_STMT(BPF_MISC | BPF_TAX, 0),
2201                         BPF_STMT(BPF_STX, 12),
2202                         BPF_STMT(BPF_LDX | BPF_MEM, 12),
2203                         BPF_STMT(BPF_MISC | BPF_TXA, 0),
2204                         BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1),
2205                         BPF_STMT(BPF_MISC | BPF_TAX, 0),
2206                         BPF_STMT(BPF_STX, 13),
2207                         BPF_STMT(BPF_LDX | BPF_MEM, 13),
2208                         BPF_STMT(BPF_MISC | BPF_TXA, 0),
2209                         BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1),
2210                         BPF_STMT(BPF_MISC | BPF_TAX, 0),
2211                         BPF_STMT(BPF_STX, 14),
2212                         BPF_STMT(BPF_LDX | BPF_MEM, 14),
2213                         BPF_STMT(BPF_MISC | BPF_TXA, 0),
2214                         BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1),
2215                         BPF_STMT(BPF_MISC | BPF_TAX, 0),
2216                         BPF_STMT(BPF_STX, 15),
2217                         BPF_STMT(BPF_LDX | BPF_MEM, 15),
2218                         BPF_STMT(BPF_MISC | BPF_TXA, 0),
2219                         BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 1),
2220                         BPF_STMT(BPF_MISC | BPF_TAX, 0),
2221                         BPF_STMT(BPF_RET | BPF_A, 0),
2222                 },
2223                 CLASSIC | FLAG_NO_DATA,
2224                 { },
2225                 { { 0, 116 } },
2226         },
2227         {       /* Mainly checking JIT here. */
2228                 "M[]: full STX + full LDX",
2229                 .u.insns = {
2230                         BPF_STMT(BPF_LDX | BPF_IMM, 0xbadfeedb),
2231                         BPF_STMT(BPF_STX, 0),
2232                         BPF_STMT(BPF_LDX | BPF_IMM, 0xecabedae),
2233                         BPF_STMT(BPF_STX, 1),
2234                         BPF_STMT(BPF_LDX | BPF_IMM, 0xafccfeaf),
2235                         BPF_STMT(BPF_STX, 2),
2236                         BPF_STMT(BPF_LDX | BPF_IMM, 0xbffdcedc),
2237                         BPF_STMT(BPF_STX, 3),
2238                         BPF_STMT(BPF_LDX | BPF_IMM, 0xfbbbdccb),
2239                         BPF_STMT(BPF_STX, 4),
2240                         BPF_STMT(BPF_LDX | BPF_IMM, 0xfbabcbda),
2241                         BPF_STMT(BPF_STX, 5),
2242                         BPF_STMT(BPF_LDX | BPF_IMM, 0xaedecbdb),
2243                         BPF_STMT(BPF_STX, 6),
2244                         BPF_STMT(BPF_LDX | BPF_IMM, 0xadebbade),
2245                         BPF_STMT(BPF_STX, 7),
2246                         BPF_STMT(BPF_LDX | BPF_IMM, 0xfcfcfaec),
2247                         BPF_STMT(BPF_STX, 8),
2248                         BPF_STMT(BPF_LDX | BPF_IMM, 0xbcdddbdc),
2249                         BPF_STMT(BPF_STX, 9),
2250                         BPF_STMT(BPF_LDX | BPF_IMM, 0xfeefdfac),
2251                         BPF_STMT(BPF_STX, 10),
2252                         BPF_STMT(BPF_LDX | BPF_IMM, 0xcddcdeea),
2253                         BPF_STMT(BPF_STX, 11),
2254                         BPF_STMT(BPF_LDX | BPF_IMM, 0xaccfaebb),
2255                         BPF_STMT(BPF_STX, 12),
2256                         BPF_STMT(BPF_LDX | BPF_IMM, 0xbdcccdcf),
2257                         BPF_STMT(BPF_STX, 13),
2258                         BPF_STMT(BPF_LDX | BPF_IMM, 0xaaedecde),
2259                         BPF_STMT(BPF_STX, 14),
2260                         BPF_STMT(BPF_LDX | BPF_IMM, 0xfaeacdad),
2261                         BPF_STMT(BPF_STX, 15),
2262                         BPF_STMT(BPF_LDX | BPF_MEM, 0),
2263                         BPF_STMT(BPF_MISC | BPF_TXA, 0),
2264                         BPF_STMT(BPF_LDX | BPF_MEM, 1),
2265                         BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
2266                         BPF_STMT(BPF_LDX | BPF_MEM, 2),
2267                         BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
2268                         BPF_STMT(BPF_LDX | BPF_MEM, 3),
2269                         BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
2270                         BPF_STMT(BPF_LDX | BPF_MEM, 4),
2271                         BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
2272                         BPF_STMT(BPF_LDX | BPF_MEM, 5),
2273                         BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
2274                         BPF_STMT(BPF_LDX | BPF_MEM, 6),
2275                         BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
2276                         BPF_STMT(BPF_LDX | BPF_MEM, 7),
2277                         BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
2278                         BPF_STMT(BPF_LDX | BPF_MEM, 8),
2279                         BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
2280                         BPF_STMT(BPF_LDX | BPF_MEM, 9),
2281                         BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
2282                         BPF_STMT(BPF_LDX | BPF_MEM, 10),
2283                         BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
2284                         BPF_STMT(BPF_LDX | BPF_MEM, 11),
2285                         BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
2286                         BPF_STMT(BPF_LDX | BPF_MEM, 12),
2287                         BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
2288                         BPF_STMT(BPF_LDX | BPF_MEM, 13),
2289                         BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
2290                         BPF_STMT(BPF_LDX | BPF_MEM, 14),
2291                         BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
2292                         BPF_STMT(BPF_LDX | BPF_MEM, 15),
2293                         BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
2294                         BPF_STMT(BPF_RET | BPF_A, 0),
2295                 },
2296                 CLASSIC | FLAG_NO_DATA,
2297                 { },
2298                 { { 0, 0x2a5a5e5 } },
2299         },
2300         {
2301                 "check: SKF_AD_MAX",
2302                 .u.insns = {
2303                         BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
2304                                  SKF_AD_OFF + SKF_AD_MAX),
2305                         BPF_STMT(BPF_RET | BPF_A, 0),
2306                 },
2307                 CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL,
2308                 { },
2309                 { },
2310                 .fill_helper = NULL,
2311                 .expected_errcode = -EINVAL,
2312         },
2313         {       /* Passes checker but fails during runtime. */
2314                 "LD [SKF_AD_OFF-1]",
2315                 .u.insns = {
2316                         BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
2317                                  SKF_AD_OFF - 1),
2318                         BPF_STMT(BPF_RET | BPF_K, 1),
2319                 },
2320                 CLASSIC,
2321                 { },
2322                 { { 1, 0 } },
2323         },
2324         {
2325                 "load 64-bit immediate",
2326                 .u.insns_int = {
2327                         BPF_LD_IMM64(R1, 0x567800001234LL),
2328                         BPF_MOV64_REG(R2, R1),
2329                         BPF_MOV64_REG(R3, R2),
2330                         BPF_ALU64_IMM(BPF_RSH, R2, 32),
2331                         BPF_ALU64_IMM(BPF_LSH, R3, 32),
2332                         BPF_ALU64_IMM(BPF_RSH, R3, 32),
2333                         BPF_ALU64_IMM(BPF_MOV, R0, 0),
2334                         BPF_JMP_IMM(BPF_JEQ, R2, 0x5678, 1),
2335                         BPF_EXIT_INSN(),
2336                         BPF_JMP_IMM(BPF_JEQ, R3, 0x1234, 1),
2337                         BPF_EXIT_INSN(),
2338                         BPF_LD_IMM64(R0, 0x1ffffffffLL),
2339                         BPF_ALU64_IMM(BPF_RSH, R0, 32), /* R0 = 1 */
2340                         BPF_EXIT_INSN(),
2341                 },
2342                 INTERNAL,
2343                 { },
2344                 { { 0, 1 } }
2345         },
2346         {
2347                 "nmap reduced",
2348                 .u.insns_int = {
2349                         BPF_MOV64_REG(R6, R1),
2350                         BPF_LD_ABS(BPF_H, 12),
2351                         BPF_JMP_IMM(BPF_JNE, R0, 0x806, 28),
2352                         BPF_LD_ABS(BPF_H, 12),
2353                         BPF_JMP_IMM(BPF_JNE, R0, 0x806, 26),
2354                         BPF_MOV32_IMM(R0, 18),
2355                         BPF_STX_MEM(BPF_W, R10, R0, -64),
2356                         BPF_LDX_MEM(BPF_W, R7, R10, -64),
2357                         BPF_LD_IND(BPF_W, R7, 14),
2358                         BPF_STX_MEM(BPF_W, R10, R0, -60),
2359                         BPF_MOV32_IMM(R0, 280971478),
2360                         BPF_STX_MEM(BPF_W, R10, R0, -56),
2361                         BPF_LDX_MEM(BPF_W, R7, R10, -56),
2362                         BPF_LDX_MEM(BPF_W, R0, R10, -60),
2363                         BPF_ALU32_REG(BPF_SUB, R0, R7),
2364                         BPF_JMP_IMM(BPF_JNE, R0, 0, 15),
2365                         BPF_LD_ABS(BPF_H, 12),
2366                         BPF_JMP_IMM(BPF_JNE, R0, 0x806, 13),
2367                         BPF_MOV32_IMM(R0, 22),
2368                         BPF_STX_MEM(BPF_W, R10, R0, -56),
2369                         BPF_LDX_MEM(BPF_W, R7, R10, -56),
2370                         BPF_LD_IND(BPF_H, R7, 14),
2371                         BPF_STX_MEM(BPF_W, R10, R0, -52),
2372                         BPF_MOV32_IMM(R0, 17366),
2373                         BPF_STX_MEM(BPF_W, R10, R0, -48),
2374                         BPF_LDX_MEM(BPF_W, R7, R10, -48),
2375                         BPF_LDX_MEM(BPF_W, R0, R10, -52),
2376                         BPF_ALU32_REG(BPF_SUB, R0, R7),
2377                         BPF_JMP_IMM(BPF_JNE, R0, 0, 2),
2378                         BPF_MOV32_IMM(R0, 256),
2379                         BPF_EXIT_INSN(),
2380                         BPF_MOV32_IMM(R0, 0),
2381                         BPF_EXIT_INSN(),
2382                 },
2383                 INTERNAL,
2384                 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x08, 0x06, 0, 0,
2385                   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2386                   0x10, 0xbf, 0x48, 0xd6, 0x43, 0xd6},
2387                 { { 38, 256 } },
2388                 .stack_depth = 64,
2389         },
2390         /* BPF_ALU | BPF_MOV | BPF_X */
2391         {
2392                 "ALU_MOV_X: dst = 2",
2393                 .u.insns_int = {
2394                         BPF_ALU32_IMM(BPF_MOV, R1, 2),
2395                         BPF_ALU32_REG(BPF_MOV, R0, R1),
2396                         BPF_EXIT_INSN(),
2397                 },
2398                 INTERNAL,
2399                 { },
2400                 { { 0, 2 } },
2401         },
2402         {
2403                 "ALU_MOV_X: dst = 4294967295",
2404                 .u.insns_int = {
2405                         BPF_ALU32_IMM(BPF_MOV, R1, 4294967295U),
2406                         BPF_ALU32_REG(BPF_MOV, R0, R1),
2407                         BPF_EXIT_INSN(),
2408                 },
2409                 INTERNAL,
2410                 { },
2411                 { { 0, 4294967295U } },
2412         },
2413         {
2414                 "ALU64_MOV_X: dst = 2",
2415                 .u.insns_int = {
2416                         BPF_ALU32_IMM(BPF_MOV, R1, 2),
2417                         BPF_ALU64_REG(BPF_MOV, R0, R1),
2418                         BPF_EXIT_INSN(),
2419                 },
2420                 INTERNAL,
2421                 { },
2422                 { { 0, 2 } },
2423         },
2424         {
2425                 "ALU64_MOV_X: dst = 4294967295",
2426                 .u.insns_int = {
2427                         BPF_ALU32_IMM(BPF_MOV, R1, 4294967295U),
2428                         BPF_ALU64_REG(BPF_MOV, R0, R1),
2429                         BPF_EXIT_INSN(),
2430                 },
2431                 INTERNAL,
2432                 { },
2433                 { { 0, 4294967295U } },
2434         },
2435         /* BPF_ALU | BPF_MOV | BPF_K */
2436         {
2437                 "ALU_MOV_K: dst = 2",
2438                 .u.insns_int = {
2439                         BPF_ALU32_IMM(BPF_MOV, R0, 2),
2440                         BPF_EXIT_INSN(),
2441                 },
2442                 INTERNAL,
2443                 { },
2444                 { { 0, 2 } },
2445         },
2446         {
2447                 "ALU_MOV_K: dst = 4294967295",
2448                 .u.insns_int = {
2449                         BPF_ALU32_IMM(BPF_MOV, R0, 4294967295U),
2450                         BPF_EXIT_INSN(),
2451                 },
2452                 INTERNAL,
2453                 { },
2454                 { { 0, 4294967295U } },
2455         },
2456         {
2457                 "ALU_MOV_K: 0x0000ffffffff0000 = 0x00000000ffffffff",
2458                 .u.insns_int = {
2459                         BPF_LD_IMM64(R2, 0x0000ffffffff0000LL),
2460                         BPF_LD_IMM64(R3, 0x00000000ffffffffLL),
2461                         BPF_ALU32_IMM(BPF_MOV, R2, 0xffffffff),
2462                         BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
2463                         BPF_MOV32_IMM(R0, 2),
2464                         BPF_EXIT_INSN(),
2465                         BPF_MOV32_IMM(R0, 1),
2466                         BPF_EXIT_INSN(),
2467                 },
2468                 INTERNAL,
2469                 { },
2470                 { { 0, 0x1 } },
2471         },
2472         {
2473                 "ALU64_MOV_K: dst = 2",
2474                 .u.insns_int = {
2475                         BPF_ALU64_IMM(BPF_MOV, R0, 2),
2476                         BPF_EXIT_INSN(),
2477                 },
2478                 INTERNAL,
2479                 { },
2480                 { { 0, 2 } },
2481         },
2482         {
2483                 "ALU64_MOV_K: dst = 2147483647",
2484                 .u.insns_int = {
2485                         BPF_ALU64_IMM(BPF_MOV, R0, 2147483647),
2486                         BPF_EXIT_INSN(),
2487                 },
2488                 INTERNAL,
2489                 { },
2490                 { { 0, 2147483647 } },
2491         },
2492         {
2493                 "ALU64_OR_K: dst = 0x0",
2494                 .u.insns_int = {
2495                         BPF_LD_IMM64(R2, 0x0000ffffffff0000LL),
2496                         BPF_LD_IMM64(R3, 0x0),
2497                         BPF_ALU64_IMM(BPF_MOV, R2, 0x0),
2498                         BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
2499                         BPF_MOV32_IMM(R0, 2),
2500                         BPF_EXIT_INSN(),
2501                         BPF_MOV32_IMM(R0, 1),
2502                         BPF_EXIT_INSN(),
2503                 },
2504                 INTERNAL,
2505                 { },
2506                 { { 0, 0x1 } },
2507         },
2508         {
2509                 "ALU64_MOV_K: dst = -1",
2510                 .u.insns_int = {
2511                         BPF_LD_IMM64(R2, 0x0000ffffffff0000LL),
2512                         BPF_LD_IMM64(R3, 0xffffffffffffffffLL),
2513                         BPF_ALU64_IMM(BPF_MOV, R2, 0xffffffff),
2514                         BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
2515                         BPF_MOV32_IMM(R0, 2),
2516                         BPF_EXIT_INSN(),
2517                         BPF_MOV32_IMM(R0, 1),
2518                         BPF_EXIT_INSN(),
2519                 },
2520                 INTERNAL,
2521                 { },
2522                 { { 0, 0x1 } },
2523         },
2524         /* BPF_ALU | BPF_ADD | BPF_X */
2525         {
2526                 "ALU_ADD_X: 1 + 2 = 3",
2527                 .u.insns_int = {
2528                         BPF_LD_IMM64(R0, 1),
2529                         BPF_ALU32_IMM(BPF_MOV, R1, 2),
2530                         BPF_ALU32_REG(BPF_ADD, R0, R1),
2531                         BPF_EXIT_INSN(),
2532                 },
2533                 INTERNAL,
2534                 { },
2535                 { { 0, 3 } },
2536         },
2537         {
2538                 "ALU_ADD_X: 1 + 4294967294 = 4294967295",
2539                 .u.insns_int = {
2540                         BPF_LD_IMM64(R0, 1),
2541                         BPF_ALU32_IMM(BPF_MOV, R1, 4294967294U),
2542                         BPF_ALU32_REG(BPF_ADD, R0, R1),
2543                         BPF_EXIT_INSN(),
2544                 },
2545                 INTERNAL,
2546                 { },
2547                 { { 0, 4294967295U } },
2548         },
2549         {
2550                 "ALU_ADD_X: 2 + 4294967294 = 0",
2551                 .u.insns_int = {
2552                         BPF_LD_IMM64(R0, 2),
2553                         BPF_LD_IMM64(R1, 4294967294U),
2554                         BPF_ALU32_REG(BPF_ADD, R0, R1),
2555                         BPF_JMP_IMM(BPF_JEQ, R0, 0, 2),
2556                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
2557                         BPF_EXIT_INSN(),
2558                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
2559                         BPF_EXIT_INSN(),
2560                 },
2561                 INTERNAL,
2562                 { },
2563                 { { 0, 1 } },
2564         },
2565         {
2566                 "ALU64_ADD_X: 1 + 2 = 3",
2567                 .u.insns_int = {
2568                         BPF_LD_IMM64(R0, 1),
2569                         BPF_ALU32_IMM(BPF_MOV, R1, 2),
2570                         BPF_ALU64_REG(BPF_ADD, R0, R1),
2571                         BPF_EXIT_INSN(),
2572                 },
2573                 INTERNAL,
2574                 { },
2575                 { { 0, 3 } },
2576         },
2577         {
2578                 "ALU64_ADD_X: 1 + 4294967294 = 4294967295",
2579                 .u.insns_int = {
2580                         BPF_LD_IMM64(R0, 1),
2581                         BPF_ALU32_IMM(BPF_MOV, R1, 4294967294U),
2582                         BPF_ALU64_REG(BPF_ADD, R0, R1),
2583                         BPF_EXIT_INSN(),
2584                 },
2585                 INTERNAL,
2586                 { },
2587                 { { 0, 4294967295U } },
2588         },
2589         {
2590                 "ALU64_ADD_X: 2 + 4294967294 = 4294967296",
2591                 .u.insns_int = {
2592                         BPF_LD_IMM64(R0, 2),
2593                         BPF_LD_IMM64(R1, 4294967294U),
2594                         BPF_LD_IMM64(R2, 4294967296ULL),
2595                         BPF_ALU64_REG(BPF_ADD, R0, R1),
2596                         BPF_JMP_REG(BPF_JEQ, R0, R2, 2),
2597                         BPF_MOV32_IMM(R0, 0),
2598                         BPF_EXIT_INSN(),
2599                         BPF_MOV32_IMM(R0, 1),
2600                         BPF_EXIT_INSN(),
2601                 },
2602                 INTERNAL,
2603                 { },
2604                 { { 0, 1 } },
2605         },
2606         /* BPF_ALU | BPF_ADD | BPF_K */
2607         {
2608                 "ALU_ADD_K: 1 + 2 = 3",
2609                 .u.insns_int = {
2610                         BPF_LD_IMM64(R0, 1),
2611                         BPF_ALU32_IMM(BPF_ADD, R0, 2),
2612                         BPF_EXIT_INSN(),
2613                 },
2614                 INTERNAL,
2615                 { },
2616                 { { 0, 3 } },
2617         },
2618         {
2619                 "ALU_ADD_K: 3 + 0 = 3",
2620                 .u.insns_int = {
2621                         BPF_LD_IMM64(R0, 3),
2622                         BPF_ALU32_IMM(BPF_ADD, R0, 0),
2623                         BPF_EXIT_INSN(),
2624                 },
2625                 INTERNAL,
2626                 { },
2627                 { { 0, 3 } },
2628         },
2629         {
2630                 "ALU_ADD_K: 1 + 4294967294 = 4294967295",
2631                 .u.insns_int = {
2632                         BPF_LD_IMM64(R0, 1),
2633                         BPF_ALU32_IMM(BPF_ADD, R0, 4294967294U),
2634                         BPF_EXIT_INSN(),
2635                 },
2636                 INTERNAL,
2637                 { },
2638                 { { 0, 4294967295U } },
2639         },
2640         {
2641                 "ALU_ADD_K: 4294967294 + 2 = 0",
2642                 .u.insns_int = {
2643                         BPF_LD_IMM64(R0, 4294967294U),
2644                         BPF_ALU32_IMM(BPF_ADD, R0, 2),
2645                         BPF_JMP_IMM(BPF_JEQ, R0, 0, 2),
2646                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
2647                         BPF_EXIT_INSN(),
2648                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
2649                         BPF_EXIT_INSN(),
2650                 },
2651                 INTERNAL,
2652                 { },
2653                 { { 0, 1 } },
2654         },
2655         {
2656                 "ALU_ADD_K: 0 + (-1) = 0x00000000ffffffff",
2657                 .u.insns_int = {
2658                         BPF_LD_IMM64(R2, 0x0),
2659                         BPF_LD_IMM64(R3, 0x00000000ffffffff),
2660                         BPF_ALU32_IMM(BPF_ADD, R2, 0xffffffff),
2661                         BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
2662                         BPF_MOV32_IMM(R0, 2),
2663                         BPF_EXIT_INSN(),
2664                         BPF_MOV32_IMM(R0, 1),
2665                         BPF_EXIT_INSN(),
2666                 },
2667                 INTERNAL,
2668                 { },
2669                 { { 0, 0x1 } },
2670         },
2671         {
2672                 "ALU_ADD_K: 0 + 0xffff = 0xffff",
2673                 .u.insns_int = {
2674                         BPF_LD_IMM64(R2, 0x0),
2675                         BPF_LD_IMM64(R3, 0xffff),
2676                         BPF_ALU32_IMM(BPF_ADD, R2, 0xffff),
2677                         BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
2678                         BPF_MOV32_IMM(R0, 2),
2679                         BPF_EXIT_INSN(),
2680                         BPF_MOV32_IMM(R0, 1),
2681                         BPF_EXIT_INSN(),
2682                 },
2683                 INTERNAL,
2684                 { },
2685                 { { 0, 0x1 } },
2686         },
2687         {
2688                 "ALU_ADD_K: 0 + 0x7fffffff = 0x7fffffff",
2689                 .u.insns_int = {
2690                         BPF_LD_IMM64(R2, 0x0),
2691                         BPF_LD_IMM64(R3, 0x7fffffff),
2692                         BPF_ALU32_IMM(BPF_ADD, R2, 0x7fffffff),
2693                         BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
2694                         BPF_MOV32_IMM(R0, 2),
2695                         BPF_EXIT_INSN(),
2696                         BPF_MOV32_IMM(R0, 1),
2697                         BPF_EXIT_INSN(),
2698                 },
2699                 INTERNAL,
2700                 { },
2701                 { { 0, 0x1 } },
2702         },
2703         {
2704                 "ALU_ADD_K: 0 + 0x80000000 = 0x80000000",
2705                 .u.insns_int = {
2706                         BPF_LD_IMM64(R2, 0x0),
2707                         BPF_LD_IMM64(R3, 0x80000000),
2708                         BPF_ALU32_IMM(BPF_ADD, R2, 0x80000000),
2709                         BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
2710                         BPF_MOV32_IMM(R0, 2),
2711                         BPF_EXIT_INSN(),
2712                         BPF_MOV32_IMM(R0, 1),
2713                         BPF_EXIT_INSN(),
2714                 },
2715                 INTERNAL,
2716                 { },
2717                 { { 0, 0x1 } },
2718         },
2719         {
2720                 "ALU_ADD_K: 0 + 0x80008000 = 0x80008000",
2721                 .u.insns_int = {
2722                         BPF_LD_IMM64(R2, 0x0),
2723                         BPF_LD_IMM64(R3, 0x80008000),
2724                         BPF_ALU32_IMM(BPF_ADD, R2, 0x80008000),
2725                         BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
2726                         BPF_MOV32_IMM(R0, 2),
2727                         BPF_EXIT_INSN(),
2728                         BPF_MOV32_IMM(R0, 1),
2729                         BPF_EXIT_INSN(),
2730                 },
2731                 INTERNAL,
2732                 { },
2733                 { { 0, 0x1 } },
2734         },
2735         {
2736                 "ALU64_ADD_K: 1 + 2 = 3",
2737                 .u.insns_int = {
2738                         BPF_LD_IMM64(R0, 1),
2739                         BPF_ALU64_IMM(BPF_ADD, R0, 2),
2740                         BPF_EXIT_INSN(),
2741                 },
2742                 INTERNAL,
2743                 { },
2744                 { { 0, 3 } },
2745         },
2746         {
2747                 "ALU64_ADD_K: 3 + 0 = 3",
2748                 .u.insns_int = {
2749                         BPF_LD_IMM64(R0, 3),
2750                         BPF_ALU64_IMM(BPF_ADD, R0, 0),
2751                         BPF_EXIT_INSN(),
2752                 },
2753                 INTERNAL,
2754                 { },
2755                 { { 0, 3 } },
2756         },
2757         {
2758                 "ALU64_ADD_K: 1 + 2147483646 = 2147483647",
2759                 .u.insns_int = {
2760                         BPF_LD_IMM64(R0, 1),
2761                         BPF_ALU64_IMM(BPF_ADD, R0, 2147483646),
2762                         BPF_EXIT_INSN(),
2763                 },
2764                 INTERNAL,
2765                 { },
2766                 { { 0, 2147483647 } },
2767         },
2768         {
2769                 "ALU64_ADD_K: 4294967294 + 2 = 4294967296",
2770                 .u.insns_int = {
2771                         BPF_LD_IMM64(R0, 4294967294U),
2772                         BPF_LD_IMM64(R1, 4294967296ULL),
2773                         BPF_ALU64_IMM(BPF_ADD, R0, 2),
2774                         BPF_JMP_REG(BPF_JEQ, R0, R1, 2),
2775                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
2776                         BPF_EXIT_INSN(),
2777                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
2778                         BPF_EXIT_INSN(),
2779                 },
2780                 INTERNAL,
2781                 { },
2782                 { { 0, 1 } },
2783         },
2784         {
2785                 "ALU64_ADD_K: 2147483646 + -2147483647 = -1",
2786                 .u.insns_int = {
2787                         BPF_LD_IMM64(R0, 2147483646),
2788                         BPF_ALU64_IMM(BPF_ADD, R0, -2147483647),
2789                         BPF_EXIT_INSN(),
2790                 },
2791                 INTERNAL,
2792                 { },
2793                 { { 0, -1 } },
2794         },
2795         {
2796                 "ALU64_ADD_K: 1 + 0 = 1",
2797                 .u.insns_int = {
2798                         BPF_LD_IMM64(R2, 0x1),
2799                         BPF_LD_IMM64(R3, 0x1),
2800                         BPF_ALU64_IMM(BPF_ADD, R2, 0x0),
2801                         BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
2802                         BPF_MOV32_IMM(R0, 2),
2803                         BPF_EXIT_INSN(),
2804                         BPF_MOV32_IMM(R0, 1),
2805                         BPF_EXIT_INSN(),
2806                 },
2807                 INTERNAL,
2808                 { },
2809                 { { 0, 0x1 } },
2810         },
2811         {
2812                 "ALU64_ADD_K: 0 + (-1) = 0xffffffffffffffff",
2813                 .u.insns_int = {
2814                         BPF_LD_IMM64(R2, 0x0),
2815                         BPF_LD_IMM64(R3, 0xffffffffffffffffLL),
2816                         BPF_ALU64_IMM(BPF_ADD, R2, 0xffffffff),
2817                         BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
2818                         BPF_MOV32_IMM(R0, 2),
2819                         BPF_EXIT_INSN(),
2820                         BPF_MOV32_IMM(R0, 1),
2821                         BPF_EXIT_INSN(),
2822                 },
2823                 INTERNAL,
2824                 { },
2825                 { { 0, 0x1 } },
2826         },
2827         {
2828                 "ALU64_ADD_K: 0 + 0xffff = 0xffff",
2829                 .u.insns_int = {
2830                         BPF_LD_IMM64(R2, 0x0),
2831                         BPF_LD_IMM64(R3, 0xffff),
2832                         BPF_ALU64_IMM(BPF_ADD, R2, 0xffff),
2833                         BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
2834                         BPF_MOV32_IMM(R0, 2),
2835                         BPF_EXIT_INSN(),
2836                         BPF_MOV32_IMM(R0, 1),
2837                         BPF_EXIT_INSN(),
2838                 },
2839                 INTERNAL,
2840                 { },
2841                 { { 0, 0x1 } },
2842         },
2843         {
2844                 "ALU64_ADD_K: 0 + 0x7fffffff = 0x7fffffff",
2845                 .u.insns_int = {
2846                         BPF_LD_IMM64(R2, 0x0),
2847                         BPF_LD_IMM64(R3, 0x7fffffff),
2848                         BPF_ALU64_IMM(BPF_ADD, R2, 0x7fffffff),
2849                         BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
2850                         BPF_MOV32_IMM(R0, 2),
2851                         BPF_EXIT_INSN(),
2852                         BPF_MOV32_IMM(R0, 1),
2853                         BPF_EXIT_INSN(),
2854                 },
2855                 INTERNAL,
2856                 { },
2857                 { { 0, 0x1 } },
2858         },
2859         {
2860                 "ALU64_ADD_K: 0 + 0x80000000 = 0xffffffff80000000",
2861                 .u.insns_int = {
2862                         BPF_LD_IMM64(R2, 0x0),
2863                         BPF_LD_IMM64(R3, 0xffffffff80000000LL),
2864                         BPF_ALU64_IMM(BPF_ADD, R2, 0x80000000),
2865                         BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
2866                         BPF_MOV32_IMM(R0, 2),
2867                         BPF_EXIT_INSN(),
2868                         BPF_MOV32_IMM(R0, 1),
2869                         BPF_EXIT_INSN(),
2870                 },
2871                 INTERNAL,
2872                 { },
2873                 { { 0, 0x1 } },
2874         },
2875         {
2876                 "ALU_ADD_K: 0 + 0x80008000 = 0xffffffff80008000",
2877                 .u.insns_int = {
2878                         BPF_LD_IMM64(R2, 0x0),
2879                         BPF_LD_IMM64(R3, 0xffffffff80008000LL),
2880                         BPF_ALU64_IMM(BPF_ADD, R2, 0x80008000),
2881                         BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
2882                         BPF_MOV32_IMM(R0, 2),
2883                         BPF_EXIT_INSN(),
2884                         BPF_MOV32_IMM(R0, 1),
2885                         BPF_EXIT_INSN(),
2886                 },
2887                 INTERNAL,
2888                 { },
2889                 { { 0, 0x1 } },
2890         },
2891         /* BPF_ALU | BPF_SUB | BPF_X */
2892         {
2893                 "ALU_SUB_X: 3 - 1 = 2",
2894                 .u.insns_int = {
2895                         BPF_LD_IMM64(R0, 3),
2896                         BPF_ALU32_IMM(BPF_MOV, R1, 1),
2897                         BPF_ALU32_REG(BPF_SUB, R0, R1),
2898                         BPF_EXIT_INSN(),
2899                 },
2900                 INTERNAL,
2901                 { },
2902                 { { 0, 2 } },
2903         },
2904         {
2905                 "ALU_SUB_X: 4294967295 - 4294967294 = 1",
2906                 .u.insns_int = {
2907                         BPF_LD_IMM64(R0, 4294967295U),
2908                         BPF_ALU32_IMM(BPF_MOV, R1, 4294967294U),
2909                         BPF_ALU32_REG(BPF_SUB, R0, R1),
2910                         BPF_EXIT_INSN(),
2911                 },
2912                 INTERNAL,
2913                 { },
2914                 { { 0, 1 } },
2915         },
2916         {
2917                 "ALU64_SUB_X: 3 - 1 = 2",
2918                 .u.insns_int = {
2919                         BPF_LD_IMM64(R0, 3),
2920                         BPF_ALU32_IMM(BPF_MOV, R1, 1),
2921                         BPF_ALU64_REG(BPF_SUB, R0, R1),
2922                         BPF_EXIT_INSN(),
2923                 },
2924                 INTERNAL,
2925                 { },
2926                 { { 0, 2 } },
2927         },
2928         {
2929                 "ALU64_SUB_X: 4294967295 - 4294967294 = 1",
2930                 .u.insns_int = {
2931                         BPF_LD_IMM64(R0, 4294967295U),
2932                         BPF_ALU32_IMM(BPF_MOV, R1, 4294967294U),
2933                         BPF_ALU64_REG(BPF_SUB, R0, R1),
2934                         BPF_EXIT_INSN(),
2935                 },
2936                 INTERNAL,
2937                 { },
2938                 { { 0, 1 } },
2939         },
2940         /* BPF_ALU | BPF_SUB | BPF_K */
2941         {
2942                 "ALU_SUB_K: 3 - 1 = 2",
2943                 .u.insns_int = {
2944                         BPF_LD_IMM64(R0, 3),
2945                         BPF_ALU32_IMM(BPF_SUB, R0, 1),
2946                         BPF_EXIT_INSN(),
2947                 },
2948                 INTERNAL,
2949                 { },
2950                 { { 0, 2 } },
2951         },
2952         {
2953                 "ALU_SUB_K: 3 - 0 = 3",
2954                 .u.insns_int = {
2955                         BPF_LD_IMM64(R0, 3),
2956                         BPF_ALU32_IMM(BPF_SUB, R0, 0),
2957                         BPF_EXIT_INSN(),
2958                 },
2959                 INTERNAL,
2960                 { },
2961                 { { 0, 3 } },
2962         },
2963         {
2964                 "ALU_SUB_K: 4294967295 - 4294967294 = 1",
2965                 .u.insns_int = {
2966                         BPF_LD_IMM64(R0, 4294967295U),
2967                         BPF_ALU32_IMM(BPF_SUB, R0, 4294967294U),
2968                         BPF_EXIT_INSN(),
2969                 },
2970                 INTERNAL,
2971                 { },
2972                 { { 0, 1 } },
2973         },
2974         {
2975                 "ALU64_SUB_K: 3 - 1 = 2",
2976                 .u.insns_int = {
2977                         BPF_LD_IMM64(R0, 3),
2978                         BPF_ALU64_IMM(BPF_SUB, R0, 1),
2979                         BPF_EXIT_INSN(),
2980                 },
2981                 INTERNAL,
2982                 { },
2983                 { { 0, 2 } },
2984         },
2985         {
2986                 "ALU64_SUB_K: 3 - 0 = 3",
2987                 .u.insns_int = {
2988                         BPF_LD_IMM64(R0, 3),
2989                         BPF_ALU64_IMM(BPF_SUB, R0, 0),
2990                         BPF_EXIT_INSN(),
2991                 },
2992                 INTERNAL,
2993                 { },
2994                 { { 0, 3 } },
2995         },
2996         {
2997                 "ALU64_SUB_K: 4294967294 - 4294967295 = -1",
2998                 .u.insns_int = {
2999                         BPF_LD_IMM64(R0, 4294967294U),
3000                         BPF_ALU64_IMM(BPF_SUB, R0, 4294967295U),
3001                         BPF_EXIT_INSN(),
3002                 },
3003                 INTERNAL,
3004                 { },
3005                 { { 0, -1 } },
3006         },
3007         {
3008                 "ALU64_ADD_K: 2147483646 - 2147483647 = -1",
3009                 .u.insns_int = {
3010                         BPF_LD_IMM64(R0, 2147483646),
3011                         BPF_ALU64_IMM(BPF_SUB, R0, 2147483647),
3012                         BPF_EXIT_INSN(),
3013                 },
3014                 INTERNAL,
3015                 { },
3016                 { { 0, -1 } },
3017         },
3018         /* BPF_ALU | BPF_MUL | BPF_X */
3019         {
3020                 "ALU_MUL_X: 2 * 3 = 6",
3021                 .u.insns_int = {
3022                         BPF_LD_IMM64(R0, 2),
3023                         BPF_ALU32_IMM(BPF_MOV, R1, 3),
3024                         BPF_ALU32_REG(BPF_MUL, R0, R1),
3025                         BPF_EXIT_INSN(),
3026                 },
3027                 INTERNAL,
3028                 { },
3029                 { { 0, 6 } },
3030         },
3031         {
3032                 "ALU_MUL_X: 2 * 0x7FFFFFF8 = 0xFFFFFFF0",
3033                 .u.insns_int = {
3034                         BPF_LD_IMM64(R0, 2),
3035                         BPF_ALU32_IMM(BPF_MOV, R1, 0x7FFFFFF8),
3036                         BPF_ALU32_REG(BPF_MUL, R0, R1),
3037                         BPF_EXIT_INSN(),
3038                 },
3039                 INTERNAL,
3040                 { },
3041                 { { 0, 0xFFFFFFF0 } },
3042         },
3043         {
3044                 "ALU_MUL_X: -1 * -1 = 1",
3045                 .u.insns_int = {
3046                         BPF_LD_IMM64(R0, -1),
3047                         BPF_ALU32_IMM(BPF_MOV, R1, -1),
3048                         BPF_ALU32_REG(BPF_MUL, R0, R1),
3049                         BPF_EXIT_INSN(),
3050                 },
3051                 INTERNAL,
3052                 { },
3053                 { { 0, 1 } },
3054         },
3055         {
3056                 "ALU64_MUL_X: 2 * 3 = 6",
3057                 .u.insns_int = {
3058                         BPF_LD_IMM64(R0, 2),
3059                         BPF_ALU32_IMM(BPF_MOV, R1, 3),
3060                         BPF_ALU64_REG(BPF_MUL, R0, R1),
3061                         BPF_EXIT_INSN(),
3062                 },
3063                 INTERNAL,
3064                 { },
3065                 { { 0, 6 } },
3066         },
3067         {
3068                 "ALU64_MUL_X: 1 * 2147483647 = 2147483647",
3069                 .u.insns_int = {
3070                         BPF_LD_IMM64(R0, 1),
3071                         BPF_ALU32_IMM(BPF_MOV, R1, 2147483647),
3072                         BPF_ALU64_REG(BPF_MUL, R0, R1),
3073                         BPF_EXIT_INSN(),
3074                 },
3075                 INTERNAL,
3076                 { },
3077                 { { 0, 2147483647 } },
3078         },
3079         /* BPF_ALU | BPF_MUL | BPF_K */
3080         {
3081                 "ALU_MUL_K: 2 * 3 = 6",
3082                 .u.insns_int = {
3083                         BPF_LD_IMM64(R0, 2),
3084                         BPF_ALU32_IMM(BPF_MUL, R0, 3),
3085                         BPF_EXIT_INSN(),
3086                 },
3087                 INTERNAL,
3088                 { },
3089                 { { 0, 6 } },
3090         },
3091         {
3092                 "ALU_MUL_K: 3 * 1 = 3",
3093                 .u.insns_int = {
3094                         BPF_LD_IMM64(R0, 3),
3095                         BPF_ALU32_IMM(BPF_MUL, R0, 1),
3096                         BPF_EXIT_INSN(),
3097                 },
3098                 INTERNAL,
3099                 { },
3100                 { { 0, 3 } },
3101         },
3102         {
3103                 "ALU_MUL_K: 2 * 0x7FFFFFF8 = 0xFFFFFFF0",
3104                 .u.insns_int = {
3105                         BPF_LD_IMM64(R0, 2),
3106                         BPF_ALU32_IMM(BPF_MUL, R0, 0x7FFFFFF8),
3107                         BPF_EXIT_INSN(),
3108                 },
3109                 INTERNAL,
3110                 { },
3111                 { { 0, 0xFFFFFFF0 } },
3112         },
3113         {
3114                 "ALU_MUL_K: 1 * (-1) = 0x00000000ffffffff",
3115                 .u.insns_int = {
3116                         BPF_LD_IMM64(R2, 0x1),
3117                         BPF_LD_IMM64(R3, 0x00000000ffffffff),
3118                         BPF_ALU32_IMM(BPF_MUL, R2, 0xffffffff),
3119                         BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
3120                         BPF_MOV32_IMM(R0, 2),
3121                         BPF_EXIT_INSN(),
3122                         BPF_MOV32_IMM(R0, 1),
3123                         BPF_EXIT_INSN(),
3124                 },
3125                 INTERNAL,
3126                 { },
3127                 { { 0, 0x1 } },
3128         },
3129         {
3130                 "ALU64_MUL_K: 2 * 3 = 6",
3131                 .u.insns_int = {
3132                         BPF_LD_IMM64(R0, 2),
3133                         BPF_ALU64_IMM(BPF_MUL, R0, 3),
3134                         BPF_EXIT_INSN(),
3135                 },
3136                 INTERNAL,
3137                 { },
3138                 { { 0, 6 } },
3139         },
3140         {
3141                 "ALU64_MUL_K: 3 * 1 = 3",
3142                 .u.insns_int = {
3143                         BPF_LD_IMM64(R0, 3),
3144                         BPF_ALU64_IMM(BPF_MUL, R0, 1),
3145                         BPF_EXIT_INSN(),
3146                 },
3147                 INTERNAL,
3148                 { },
3149                 { { 0, 3 } },
3150         },
3151         {
3152                 "ALU64_MUL_K: 1 * 2147483647 = 2147483647",
3153                 .u.insns_int = {
3154                         BPF_LD_IMM64(R0, 1),
3155                         BPF_ALU64_IMM(BPF_MUL, R0, 2147483647),
3156                         BPF_EXIT_INSN(),
3157                 },
3158                 INTERNAL,
3159                 { },
3160                 { { 0, 2147483647 } },
3161         },
3162         {
3163                 "ALU64_MUL_K: 1 * -2147483647 = -2147483647",
3164                 .u.insns_int = {
3165                         BPF_LD_IMM64(R0, 1),
3166                         BPF_ALU64_IMM(BPF_MUL, R0, -2147483647),
3167                         BPF_EXIT_INSN(),
3168                 },
3169                 INTERNAL,
3170                 { },
3171                 { { 0, -2147483647 } },
3172         },
3173         {
3174                 "ALU64_MUL_K: 1 * (-1) = 0xffffffffffffffff",
3175                 .u.insns_int = {
3176                         BPF_LD_IMM64(R2, 0x1),
3177                         BPF_LD_IMM64(R3, 0xffffffffffffffffLL),
3178                         BPF_ALU64_IMM(BPF_MUL, R2, 0xffffffff),
3179                         BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
3180                         BPF_MOV32_IMM(R0, 2),
3181                         BPF_EXIT_INSN(),
3182                         BPF_MOV32_IMM(R0, 1),
3183                         BPF_EXIT_INSN(),
3184                 },
3185                 INTERNAL,
3186                 { },
3187                 { { 0, 0x1 } },
3188         },
3189         /* BPF_ALU | BPF_DIV | BPF_X */
3190         {
3191                 "ALU_DIV_X: 6 / 2 = 3",
3192                 .u.insns_int = {
3193                         BPF_LD_IMM64(R0, 6),
3194                         BPF_ALU32_IMM(BPF_MOV, R1, 2),
3195                         BPF_ALU32_REG(BPF_DIV, R0, R1),
3196                         BPF_EXIT_INSN(),
3197                 },
3198                 INTERNAL,
3199                 { },
3200                 { { 0, 3 } },
3201         },
3202         {
3203                 "ALU_DIV_X: 4294967295 / 4294967295 = 1",
3204                 .u.insns_int = {
3205                         BPF_LD_IMM64(R0, 4294967295U),
3206                         BPF_ALU32_IMM(BPF_MOV, R1, 4294967295U),
3207                         BPF_ALU32_REG(BPF_DIV, R0, R1),
3208                         BPF_EXIT_INSN(),
3209                 },
3210                 INTERNAL,
3211                 { },
3212                 { { 0, 1 } },
3213         },
3214         {
3215                 "ALU64_DIV_X: 6 / 2 = 3",
3216                 .u.insns_int = {
3217                         BPF_LD_IMM64(R0, 6),
3218                         BPF_ALU32_IMM(BPF_MOV, R1, 2),
3219                         BPF_ALU64_REG(BPF_DIV, R0, R1),
3220                         BPF_EXIT_INSN(),
3221                 },
3222                 INTERNAL,
3223                 { },
3224                 { { 0, 3 } },
3225         },
3226         {
3227                 "ALU64_DIV_X: 2147483647 / 2147483647 = 1",
3228                 .u.insns_int = {
3229                         BPF_LD_IMM64(R0, 2147483647),
3230                         BPF_ALU32_IMM(BPF_MOV, R1, 2147483647),
3231                         BPF_ALU64_REG(BPF_DIV, R0, R1),
3232                         BPF_EXIT_INSN(),
3233                 },
3234                 INTERNAL,
3235                 { },
3236                 { { 0, 1 } },
3237         },
3238         {
3239                 "ALU64_DIV_X: 0xffffffffffffffff / (-1) = 0x0000000000000001",
3240                 .u.insns_int = {
3241                         BPF_LD_IMM64(R2, 0xffffffffffffffffLL),
3242                         BPF_LD_IMM64(R4, 0xffffffffffffffffLL),
3243                         BPF_LD_IMM64(R3, 0x0000000000000001LL),
3244                         BPF_ALU64_REG(BPF_DIV, R2, R4),
3245                         BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
3246                         BPF_MOV32_IMM(R0, 2),
3247                         BPF_EXIT_INSN(),
3248                         BPF_MOV32_IMM(R0, 1),
3249                         BPF_EXIT_INSN(),
3250                 },
3251                 INTERNAL,
3252                 { },
3253                 { { 0, 0x1 } },
3254         },
3255         /* BPF_ALU | BPF_DIV | BPF_K */
3256         {
3257                 "ALU_DIV_K: 6 / 2 = 3",
3258                 .u.insns_int = {
3259                         BPF_LD_IMM64(R0, 6),
3260                         BPF_ALU32_IMM(BPF_DIV, R0, 2),
3261                         BPF_EXIT_INSN(),
3262                 },
3263                 INTERNAL,
3264                 { },
3265                 { { 0, 3 } },
3266         },
3267         {
3268                 "ALU_DIV_K: 3 / 1 = 3",
3269                 .u.insns_int = {
3270                         BPF_LD_IMM64(R0, 3),
3271                         BPF_ALU32_IMM(BPF_DIV, R0, 1),
3272                         BPF_EXIT_INSN(),
3273                 },
3274                 INTERNAL,
3275                 { },
3276                 { { 0, 3 } },
3277         },
3278         {
3279                 "ALU_DIV_K: 4294967295 / 4294967295 = 1",
3280                 .u.insns_int = {
3281                         BPF_LD_IMM64(R0, 4294967295U),
3282                         BPF_ALU32_IMM(BPF_DIV, R0, 4294967295U),
3283                         BPF_EXIT_INSN(),
3284                 },
3285                 INTERNAL,
3286                 { },
3287                 { { 0, 1 } },
3288         },
3289         {
3290                 "ALU_DIV_K: 0xffffffffffffffff / (-1) = 0x1",
3291                 .u.insns_int = {
3292                         BPF_LD_IMM64(R2, 0xffffffffffffffffLL),
3293                         BPF_LD_IMM64(R3, 0x1UL),
3294                         BPF_ALU32_IMM(BPF_DIV, R2, 0xffffffff),
3295                         BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
3296                         BPF_MOV32_IMM(R0, 2),
3297                         BPF_EXIT_INSN(),
3298                         BPF_MOV32_IMM(R0, 1),
3299                         BPF_EXIT_INSN(),
3300                 },
3301                 INTERNAL,
3302                 { },
3303                 { { 0, 0x1 } },
3304         },
3305         {
3306                 "ALU64_DIV_K: 6 / 2 = 3",
3307                 .u.insns_int = {
3308                         BPF_LD_IMM64(R0, 6),
3309                         BPF_ALU64_IMM(BPF_DIV, R0, 2),
3310                         BPF_EXIT_INSN(),
3311                 },
3312                 INTERNAL,
3313                 { },
3314                 { { 0, 3 } },
3315         },
3316         {
3317                 "ALU64_DIV_K: 3 / 1 = 3",
3318                 .u.insns_int = {
3319                         BPF_LD_IMM64(R0, 3),
3320                         BPF_ALU64_IMM(BPF_DIV, R0, 1),
3321                         BPF_EXIT_INSN(),
3322                 },
3323                 INTERNAL,
3324                 { },
3325                 { { 0, 3 } },
3326         },
3327         {
3328                 "ALU64_DIV_K: 2147483647 / 2147483647 = 1",
3329                 .u.insns_int = {
3330                         BPF_LD_IMM64(R0, 2147483647),
3331                         BPF_ALU64_IMM(BPF_DIV, R0, 2147483647),
3332                         BPF_EXIT_INSN(),
3333                 },
3334                 INTERNAL,
3335                 { },
3336                 { { 0, 1 } },
3337         },
3338         {
3339                 "ALU64_DIV_K: 0xffffffffffffffff / (-1) = 0x0000000000000001",
3340                 .u.insns_int = {
3341                         BPF_LD_IMM64(R2, 0xffffffffffffffffLL),
3342                         BPF_LD_IMM64(R3, 0x0000000000000001LL),
3343                         BPF_ALU64_IMM(BPF_DIV, R2, 0xffffffff),
3344                         BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
3345                         BPF_MOV32_IMM(R0, 2),
3346                         BPF_EXIT_INSN(),
3347                         BPF_MOV32_IMM(R0, 1),
3348                         BPF_EXIT_INSN(),
3349                 },
3350                 INTERNAL,
3351                 { },
3352                 { { 0, 0x1 } },
3353         },
3354         /* BPF_ALU | BPF_MOD | BPF_X */
3355         {
3356                 "ALU_MOD_X: 3 % 2 = 1",
3357                 .u.insns_int = {
3358                         BPF_LD_IMM64(R0, 3),
3359                         BPF_ALU32_IMM(BPF_MOV, R1, 2),
3360                         BPF_ALU32_REG(BPF_MOD, R0, R1),
3361                         BPF_EXIT_INSN(),
3362                 },
3363                 INTERNAL,
3364                 { },
3365                 { { 0, 1 } },
3366         },
3367         {
3368                 "ALU_MOD_X: 4294967295 % 4294967293 = 2",
3369                 .u.insns_int = {
3370                         BPF_LD_IMM64(R0, 4294967295U),
3371                         BPF_ALU32_IMM(BPF_MOV, R1, 4294967293U),
3372                         BPF_ALU32_REG(BPF_MOD, R0, R1),
3373                         BPF_EXIT_INSN(),
3374                 },
3375                 INTERNAL,
3376                 { },
3377                 { { 0, 2 } },
3378         },
3379         {
3380                 "ALU64_MOD_X: 3 % 2 = 1",
3381                 .u.insns_int = {
3382                         BPF_LD_IMM64(R0, 3),
3383                         BPF_ALU32_IMM(BPF_MOV, R1, 2),
3384                         BPF_ALU64_REG(BPF_MOD, R0, R1),
3385                         BPF_EXIT_INSN(),
3386                 },
3387                 INTERNAL,
3388                 { },
3389                 { { 0, 1 } },
3390         },
3391         {
3392                 "ALU64_MOD_X: 2147483647 % 2147483645 = 2",
3393                 .u.insns_int = {
3394                         BPF_LD_IMM64(R0, 2147483647),
3395                         BPF_ALU32_IMM(BPF_MOV, R1, 2147483645),
3396                         BPF_ALU64_REG(BPF_MOD, R0, R1),
3397                         BPF_EXIT_INSN(),
3398                 },
3399                 INTERNAL,
3400                 { },
3401                 { { 0, 2 } },
3402         },
3403         /* BPF_ALU | BPF_MOD | BPF_K */
3404         {
3405                 "ALU_MOD_K: 3 % 2 = 1",
3406                 .u.insns_int = {
3407                         BPF_LD_IMM64(R0, 3),
3408                         BPF_ALU32_IMM(BPF_MOD, R0, 2),
3409                         BPF_EXIT_INSN(),
3410                 },
3411                 INTERNAL,
3412                 { },
3413                 { { 0, 1 } },
3414         },
3415         {
3416                 "ALU_MOD_K: 3 % 1 = 0",
3417                 .u.insns_int = {
3418                         BPF_LD_IMM64(R0, 3),
3419                         BPF_ALU32_IMM(BPF_MOD, R0, 1),
3420                         BPF_EXIT_INSN(),
3421                 },
3422                 INTERNAL,
3423                 { },
3424                 { { 0, 0 } },
3425         },
3426         {
3427                 "ALU_MOD_K: 4294967295 % 4294967293 = 2",
3428                 .u.insns_int = {
3429                         BPF_LD_IMM64(R0, 4294967295U),
3430                         BPF_ALU32_IMM(BPF_MOD, R0, 4294967293U),
3431                         BPF_EXIT_INSN(),
3432                 },
3433                 INTERNAL,
3434                 { },
3435                 { { 0, 2 } },
3436         },
3437         {
3438                 "ALU64_MOD_K: 3 % 2 = 1",
3439                 .u.insns_int = {
3440                         BPF_LD_IMM64(R0, 3),
3441                         BPF_ALU64_IMM(BPF_MOD, R0, 2),
3442                         BPF_EXIT_INSN(),
3443                 },
3444                 INTERNAL,
3445                 { },
3446                 { { 0, 1 } },
3447         },
3448         {
3449                 "ALU64_MOD_K: 3 % 1 = 0",
3450                 .u.insns_int = {
3451                         BPF_LD_IMM64(R0, 3),
3452                         BPF_ALU64_IMM(BPF_MOD, R0, 1),
3453                         BPF_EXIT_INSN(),
3454                 },
3455                 INTERNAL,
3456                 { },
3457                 { { 0, 0 } },
3458         },
3459         {
3460                 "ALU64_MOD_K: 2147483647 % 2147483645 = 2",
3461                 .u.insns_int = {
3462                         BPF_LD_IMM64(R0, 2147483647),
3463                         BPF_ALU64_IMM(BPF_MOD, R0, 2147483645),
3464                         BPF_EXIT_INSN(),
3465                 },
3466                 INTERNAL,
3467                 { },
3468                 { { 0, 2 } },
3469         },
3470         /* BPF_ALU | BPF_AND | BPF_X */
3471         {
3472                 "ALU_AND_X: 3 & 2 = 2",
3473                 .u.insns_int = {
3474                         BPF_LD_IMM64(R0, 3),
3475                         BPF_ALU32_IMM(BPF_MOV, R1, 2),
3476                         BPF_ALU32_REG(BPF_AND, R0, R1),
3477                         BPF_EXIT_INSN(),
3478                 },
3479                 INTERNAL,
3480                 { },
3481                 { { 0, 2 } },
3482         },
3483         {
3484                 "ALU_AND_X: 0xffffffff & 0xffffffff = 0xffffffff",
3485                 .u.insns_int = {
3486                         BPF_LD_IMM64(R0, 0xffffffff),
3487                         BPF_ALU32_IMM(BPF_MOV, R1, 0xffffffff),
3488                         BPF_ALU32_REG(BPF_AND, R0, R1),
3489                         BPF_EXIT_INSN(),
3490                 },
3491                 INTERNAL,
3492                 { },
3493                 { { 0, 0xffffffff } },
3494         },
3495         {
3496                 "ALU64_AND_X: 3 & 2 = 2",
3497                 .u.insns_int = {
3498                         BPF_LD_IMM64(R0, 3),
3499                         BPF_ALU32_IMM(BPF_MOV, R1, 2),
3500                         BPF_ALU64_REG(BPF_AND, R0, R1),
3501                         BPF_EXIT_INSN(),
3502                 },
3503                 INTERNAL,
3504                 { },
3505                 { { 0, 2 } },
3506         },
3507         {
3508                 "ALU64_AND_X: 0xffffffff & 0xffffffff = 0xffffffff",
3509                 .u.insns_int = {
3510                         BPF_LD_IMM64(R0, 0xffffffff),
3511                         BPF_ALU32_IMM(BPF_MOV, R1, 0xffffffff),
3512                         BPF_ALU64_REG(BPF_AND, R0, R1),
3513                         BPF_EXIT_INSN(),
3514                 },
3515                 INTERNAL,
3516                 { },
3517                 { { 0, 0xffffffff } },
3518         },
3519         /* BPF_ALU | BPF_AND | BPF_K */
3520         {
3521                 "ALU_AND_K: 3 & 2 = 2",
3522                 .u.insns_int = {
3523                         BPF_LD_IMM64(R0, 3),
3524                         BPF_ALU32_IMM(BPF_AND, R0, 2),
3525                         BPF_EXIT_INSN(),
3526                 },
3527                 INTERNAL,
3528                 { },
3529                 { { 0, 2 } },
3530         },
3531         {
3532                 "ALU_AND_K: 0xffffffff & 0xffffffff = 0xffffffff",
3533                 .u.insns_int = {
3534                         BPF_LD_IMM64(R0, 0xffffffff),
3535                         BPF_ALU32_IMM(BPF_AND, R0, 0xffffffff),
3536                         BPF_EXIT_INSN(),
3537                 },
3538                 INTERNAL,
3539                 { },
3540                 { { 0, 0xffffffff } },
3541         },
3542         {
3543                 "ALU64_AND_K: 3 & 2 = 2",
3544                 .u.insns_int = {
3545                         BPF_LD_IMM64(R0, 3),
3546                         BPF_ALU64_IMM(BPF_AND, R0, 2),
3547                         BPF_EXIT_INSN(),
3548                 },
3549                 INTERNAL,
3550                 { },
3551                 { { 0, 2 } },
3552         },
3553         {
3554                 "ALU64_AND_K: 0xffffffff & 0xffffffff = 0xffffffff",
3555                 .u.insns_int = {
3556                         BPF_LD_IMM64(R0, 0xffffffff),
3557                         BPF_ALU64_IMM(BPF_AND, R0, 0xffffffff),
3558                         BPF_EXIT_INSN(),
3559                 },
3560                 INTERNAL,
3561                 { },
3562                 { { 0, 0xffffffff } },
3563         },
3564         {
3565                 "ALU64_AND_K: 0x0000ffffffff0000 & 0x0 = 0x0000ffff00000000",
3566                 .u.insns_int = {
3567                         BPF_LD_IMM64(R2, 0x0000ffffffff0000LL),
3568                         BPF_LD_IMM64(R3, 0x0000000000000000LL),
3569                         BPF_ALU64_IMM(BPF_AND, R2, 0x0),
3570                         BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
3571                         BPF_MOV32_IMM(R0, 2),
3572                         BPF_EXIT_INSN(),
3573                         BPF_MOV32_IMM(R0, 1),
3574                         BPF_EXIT_INSN(),
3575                 },
3576                 INTERNAL,
3577                 { },
3578                 { { 0, 0x1 } },
3579         },
3580         {
3581                 "ALU64_AND_K: 0x0000ffffffff0000 & -1 = 0x0000ffffffffffff",
3582                 .u.insns_int = {
3583                         BPF_LD_IMM64(R2, 0x0000ffffffff0000LL),
3584                         BPF_LD_IMM64(R3, 0x0000ffffffff0000LL),
3585                         BPF_ALU64_IMM(BPF_AND, R2, 0xffffffff),
3586                         BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
3587                         BPF_MOV32_IMM(R0, 2),
3588                         BPF_EXIT_INSN(),
3589                         BPF_MOV32_IMM(R0, 1),
3590                         BPF_EXIT_INSN(),
3591                 },
3592                 INTERNAL,
3593                 { },
3594                 { { 0, 0x1 } },
3595         },
3596         {
3597                 "ALU64_AND_K: 0xffffffffffffffff & -1 = 0xffffffffffffffff",
3598                 .u.insns_int = {
3599                         BPF_LD_IMM64(R2, 0xffffffffffffffffLL),
3600                         BPF_LD_IMM64(R3, 0xffffffffffffffffLL),
3601                         BPF_ALU64_IMM(BPF_AND, R2, 0xffffffff),
3602                         BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
3603                         BPF_MOV32_IMM(R0, 2),
3604                         BPF_EXIT_INSN(),
3605                         BPF_MOV32_IMM(R0, 1),
3606                         BPF_EXIT_INSN(),
3607                 },
3608                 INTERNAL,
3609                 { },
3610                 { { 0, 0x1 } },
3611         },
3612         /* BPF_ALU | BPF_OR | BPF_X */
3613         {
3614                 "ALU_OR_X: 1 | 2 = 3",
3615                 .u.insns_int = {
3616                         BPF_LD_IMM64(R0, 1),
3617                         BPF_ALU32_IMM(BPF_MOV, R1, 2),
3618                         BPF_ALU32_REG(BPF_OR, R0, R1),
3619                         BPF_EXIT_INSN(),
3620                 },
3621                 INTERNAL,
3622                 { },
3623                 { { 0, 3 } },
3624         },
3625         {
3626                 "ALU_OR_X: 0x0 | 0xffffffff = 0xffffffff",
3627                 .u.insns_int = {
3628                         BPF_LD_IMM64(R0, 0),
3629                         BPF_ALU32_IMM(BPF_MOV, R1, 0xffffffff),
3630                         BPF_ALU32_REG(BPF_OR, R0, R1),
3631                         BPF_EXIT_INSN(),
3632                 },
3633                 INTERNAL,
3634                 { },
3635                 { { 0, 0xffffffff } },
3636         },
3637         {
3638                 "ALU64_OR_X: 1 | 2 = 3",
3639                 .u.insns_int = {
3640                         BPF_LD_IMM64(R0, 1),
3641                         BPF_ALU32_IMM(BPF_MOV, R1, 2),
3642                         BPF_ALU64_REG(BPF_OR, R0, R1),
3643                         BPF_EXIT_INSN(),
3644                 },
3645                 INTERNAL,
3646                 { },
3647                 { { 0, 3 } },
3648         },
3649         {
3650                 "ALU64_OR_X: 0 | 0xffffffff = 0xffffffff",
3651                 .u.insns_int = {
3652                         BPF_LD_IMM64(R0, 0),
3653                         BPF_ALU32_IMM(BPF_MOV, R1, 0xffffffff),
3654                         BPF_ALU64_REG(BPF_OR, R0, R1),
3655                         BPF_EXIT_INSN(),
3656                 },
3657                 INTERNAL,
3658                 { },
3659                 { { 0, 0xffffffff } },
3660         },
3661         /* BPF_ALU | BPF_OR | BPF_K */
3662         {
3663                 "ALU_OR_K: 1 | 2 = 3",
3664                 .u.insns_int = {
3665                         BPF_LD_IMM64(R0, 1),
3666                         BPF_ALU32_IMM(BPF_OR, R0, 2),
3667                         BPF_EXIT_INSN(),
3668                 },
3669                 INTERNAL,
3670                 { },
3671                 { { 0, 3 } },
3672         },
3673         {
3674                 "ALU_OR_K: 0 & 0xffffffff = 0xffffffff",
3675                 .u.insns_int = {
3676                         BPF_LD_IMM64(R0, 0),
3677                         BPF_ALU32_IMM(BPF_OR, R0, 0xffffffff),
3678                         BPF_EXIT_INSN(),
3679                 },
3680                 INTERNAL,
3681                 { },
3682                 { { 0, 0xffffffff } },
3683         },
3684         {
3685                 "ALU64_OR_K: 1 | 2 = 3",
3686                 .u.insns_int = {
3687                         BPF_LD_IMM64(R0, 1),
3688                         BPF_ALU64_IMM(BPF_OR, R0, 2),
3689                         BPF_EXIT_INSN(),
3690                 },
3691                 INTERNAL,
3692                 { },
3693                 { { 0, 3 } },
3694         },
3695         {
3696                 "ALU64_OR_K: 0 & 0xffffffff = 0xffffffff",
3697                 .u.insns_int = {
3698                         BPF_LD_IMM64(R0, 0),
3699                         BPF_ALU64_IMM(BPF_OR, R0, 0xffffffff),
3700                         BPF_EXIT_INSN(),
3701                 },
3702                 INTERNAL,
3703                 { },
3704                 { { 0, 0xffffffff } },
3705         },
3706         {
3707                 "ALU64_OR_K: 0x0000ffffffff0000 | 0x0 = 0x0000ffff00000000",
3708                 .u.insns_int = {
3709                         BPF_LD_IMM64(R2, 0x0000ffffffff0000LL),
3710                         BPF_LD_IMM64(R3, 0x0000ffffffff0000LL),
3711                         BPF_ALU64_IMM(BPF_OR, R2, 0x0),
3712                         BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
3713                         BPF_MOV32_IMM(R0, 2),
3714                         BPF_EXIT_INSN(),
3715                         BPF_MOV32_IMM(R0, 1),
3716                         BPF_EXIT_INSN(),
3717                 },
3718                 INTERNAL,
3719                 { },
3720                 { { 0, 0x1 } },
3721         },
3722         {
3723                 "ALU64_OR_K: 0x0000ffffffff0000 | -1 = 0xffffffffffffffff",
3724                 .u.insns_int = {
3725                         BPF_LD_IMM64(R2, 0x0000ffffffff0000LL),
3726                         BPF_LD_IMM64(R3, 0xffffffffffffffffLL),
3727                         BPF_ALU64_IMM(BPF_OR, R2, 0xffffffff),
3728                         BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
3729                         BPF_MOV32_IMM(R0, 2),
3730                         BPF_EXIT_INSN(),
3731                         BPF_MOV32_IMM(R0, 1),
3732                         BPF_EXIT_INSN(),
3733                 },
3734                 INTERNAL,
3735                 { },
3736                 { { 0, 0x1 } },
3737         },
3738         {
3739                 "ALU64_OR_K: 0x000000000000000 | -1 = 0xffffffffffffffff",
3740                 .u.insns_int = {
3741                         BPF_LD_IMM64(R2, 0x0000000000000000LL),
3742                         BPF_LD_IMM64(R3, 0xffffffffffffffffLL),
3743                         BPF_ALU64_IMM(BPF_OR, R2, 0xffffffff),
3744                         BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
3745                         BPF_MOV32_IMM(R0, 2),
3746                         BPF_EXIT_INSN(),
3747                         BPF_MOV32_IMM(R0, 1),
3748                         BPF_EXIT_INSN(),
3749                 },
3750                 INTERNAL,
3751                 { },
3752                 { { 0, 0x1 } },
3753         },
3754         /* BPF_ALU | BPF_XOR | BPF_X */
3755         {
3756                 "ALU_XOR_X: 5 ^ 6 = 3",
3757                 .u.insns_int = {
3758                         BPF_LD_IMM64(R0, 5),
3759                         BPF_ALU32_IMM(BPF_MOV, R1, 6),
3760                         BPF_ALU32_REG(BPF_XOR, R0, R1),
3761                         BPF_EXIT_INSN(),
3762                 },
3763                 INTERNAL,
3764                 { },
3765                 { { 0, 3 } },
3766         },
3767         {
3768                 "ALU_XOR_X: 0x1 ^ 0xffffffff = 0xfffffffe",
3769                 .u.insns_int = {
3770                         BPF_LD_IMM64(R0, 1),
3771                         BPF_ALU32_IMM(BPF_MOV, R1, 0xffffffff),
3772                         BPF_ALU32_REG(BPF_XOR, R0, R1),
3773                         BPF_EXIT_INSN(),
3774                 },
3775                 INTERNAL,
3776                 { },
3777                 { { 0, 0xfffffffe } },
3778         },
3779         {
3780                 "ALU64_XOR_X: 5 ^ 6 = 3",
3781                 .u.insns_int = {
3782                         BPF_LD_IMM64(R0, 5),
3783                         BPF_ALU32_IMM(BPF_MOV, R1, 6),
3784                         BPF_ALU64_REG(BPF_XOR, R0, R1),
3785                         BPF_EXIT_INSN(),
3786                 },
3787                 INTERNAL,
3788                 { },
3789                 { { 0, 3 } },
3790         },
3791         {
3792                 "ALU64_XOR_X: 1 ^ 0xffffffff = 0xfffffffe",
3793                 .u.insns_int = {
3794                         BPF_LD_IMM64(R0, 1),
3795                         BPF_ALU32_IMM(BPF_MOV, R1, 0xffffffff),
3796                         BPF_ALU64_REG(BPF_XOR, R0, R1),
3797                         BPF_EXIT_INSN(),
3798                 },
3799                 INTERNAL,
3800                 { },
3801                 { { 0, 0xfffffffe } },
3802         },
3803         /* BPF_ALU | BPF_XOR | BPF_K */
3804         {
3805                 "ALU_XOR_K: 5 ^ 6 = 3",
3806                 .u.insns_int = {
3807                         BPF_LD_IMM64(R0, 5),
3808                         BPF_ALU32_IMM(BPF_XOR, R0, 6),
3809                         BPF_EXIT_INSN(),
3810                 },
3811                 INTERNAL,
3812                 { },
3813                 { { 0, 3 } },
3814         },
3815         {
3816                 "ALU_XOR_K: 1 ^ 0xffffffff = 0xfffffffe",
3817                 .u.insns_int = {
3818                         BPF_LD_IMM64(R0, 1),
3819                         BPF_ALU32_IMM(BPF_XOR, R0, 0xffffffff),
3820                         BPF_EXIT_INSN(),
3821                 },
3822                 INTERNAL,
3823                 { },
3824                 { { 0, 0xfffffffe } },
3825         },
3826         {
3827                 "ALU64_XOR_K: 5 ^ 6 = 3",
3828                 .u.insns_int = {
3829                         BPF_LD_IMM64(R0, 5),
3830                         BPF_ALU64_IMM(BPF_XOR, R0, 6),
3831                         BPF_EXIT_INSN(),
3832                 },
3833                 INTERNAL,
3834                 { },
3835                 { { 0, 3 } },
3836         },
3837         {
3838                 "ALU64_XOR_K: 1 & 0xffffffff = 0xfffffffe",
3839                 .u.insns_int = {
3840                         BPF_LD_IMM64(R0, 1),
3841                         BPF_ALU64_IMM(BPF_XOR, R0, 0xffffffff),
3842                         BPF_EXIT_INSN(),
3843                 },
3844                 INTERNAL,
3845                 { },
3846                 { { 0, 0xfffffffe } },
3847         },
3848         {
3849                 "ALU64_XOR_K: 0x0000ffffffff0000 ^ 0x0 = 0x0000ffffffff0000",
3850                 .u.insns_int = {
3851                         BPF_LD_IMM64(R2, 0x0000ffffffff0000LL),
3852                         BPF_LD_IMM64(R3, 0x0000ffffffff0000LL),
3853                         BPF_ALU64_IMM(BPF_XOR, R2, 0x0),
3854                         BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
3855                         BPF_MOV32_IMM(R0, 2),
3856                         BPF_EXIT_INSN(),
3857                         BPF_MOV32_IMM(R0, 1),
3858                         BPF_EXIT_INSN(),
3859                 },
3860                 INTERNAL,
3861                 { },
3862                 { { 0, 0x1 } },
3863         },
3864         {
3865                 "ALU64_XOR_K: 0x0000ffffffff0000 ^ -1 = 0xffff00000000ffff",
3866                 .u.insns_int = {
3867                         BPF_LD_IMM64(R2, 0x0000ffffffff0000LL),
3868                         BPF_LD_IMM64(R3, 0xffff00000000ffffLL),
3869                         BPF_ALU64_IMM(BPF_XOR, R2, 0xffffffff),
3870                         BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
3871                         BPF_MOV32_IMM(R0, 2),
3872                         BPF_EXIT_INSN(),
3873                         BPF_MOV32_IMM(R0, 1),
3874                         BPF_EXIT_INSN(),
3875                 },
3876                 INTERNAL,
3877                 { },
3878                 { { 0, 0x1 } },
3879         },
3880         {
3881                 "ALU64_XOR_K: 0x000000000000000 ^ -1 = 0xffffffffffffffff",
3882                 .u.insns_int = {
3883                         BPF_LD_IMM64(R2, 0x0000000000000000LL),
3884                         BPF_LD_IMM64(R3, 0xffffffffffffffffLL),
3885                         BPF_ALU64_IMM(BPF_XOR, R2, 0xffffffff),
3886                         BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
3887                         BPF_MOV32_IMM(R0, 2),
3888                         BPF_EXIT_INSN(),
3889                         BPF_MOV32_IMM(R0, 1),
3890                         BPF_EXIT_INSN(),
3891                 },
3892                 INTERNAL,
3893                 { },
3894                 { { 0, 0x1 } },
3895         },
3896         /* BPF_ALU | BPF_LSH | BPF_X */
3897         {
3898                 "ALU_LSH_X: 1 << 1 = 2",
3899                 .u.insns_int = {
3900                         BPF_LD_IMM64(R0, 1),
3901                         BPF_ALU32_IMM(BPF_MOV, R1, 1),
3902                         BPF_ALU32_REG(BPF_LSH, R0, R1),
3903                         BPF_EXIT_INSN(),
3904                 },
3905                 INTERNAL,
3906                 { },
3907                 { { 0, 2 } },
3908         },
3909         {
3910                 "ALU_LSH_X: 1 << 31 = 0x80000000",
3911                 .u.insns_int = {
3912                         BPF_LD_IMM64(R0, 1),
3913                         BPF_ALU32_IMM(BPF_MOV, R1, 31),
3914                         BPF_ALU32_REG(BPF_LSH, R0, R1),
3915                         BPF_EXIT_INSN(),
3916                 },
3917                 INTERNAL,
3918                 { },
3919                 { { 0, 0x80000000 } },
3920         },
3921         {
3922                 "ALU64_LSH_X: 1 << 1 = 2",
3923                 .u.insns_int = {
3924                         BPF_LD_IMM64(R0, 1),
3925                         BPF_ALU32_IMM(BPF_MOV, R1, 1),
3926                         BPF_ALU64_REG(BPF_LSH, R0, R1),
3927                         BPF_EXIT_INSN(),
3928                 },
3929                 INTERNAL,
3930                 { },
3931                 { { 0, 2 } },
3932         },
3933         {
3934                 "ALU64_LSH_X: 1 << 31 = 0x80000000",
3935                 .u.insns_int = {
3936                         BPF_LD_IMM64(R0, 1),
3937                         BPF_ALU32_IMM(BPF_MOV, R1, 31),
3938                         BPF_ALU64_REG(BPF_LSH, R0, R1),
3939                         BPF_EXIT_INSN(),
3940                 },
3941                 INTERNAL,
3942                 { },
3943                 { { 0, 0x80000000 } },
3944         },
3945         /* BPF_ALU | BPF_LSH | BPF_K */
3946         {
3947                 "ALU_LSH_K: 1 << 1 = 2",
3948                 .u.insns_int = {
3949                         BPF_LD_IMM64(R0, 1),
3950                         BPF_ALU32_IMM(BPF_LSH, R0, 1),
3951                         BPF_EXIT_INSN(),
3952                 },
3953                 INTERNAL,
3954                 { },
3955                 { { 0, 2 } },
3956         },
3957         {
3958                 "ALU_LSH_K: 1 << 31 = 0x80000000",
3959                 .u.insns_int = {
3960                         BPF_LD_IMM64(R0, 1),
3961                         BPF_ALU32_IMM(BPF_LSH, R0, 31),
3962                         BPF_EXIT_INSN(),
3963                 },
3964                 INTERNAL,
3965                 { },
3966                 { { 0, 0x80000000 } },
3967         },
3968         {
3969                 "ALU64_LSH_K: 1 << 1 = 2",
3970                 .u.insns_int = {
3971                         BPF_LD_IMM64(R0, 1),
3972                         BPF_ALU64_IMM(BPF_LSH, R0, 1),
3973                         BPF_EXIT_INSN(),
3974                 },
3975                 INTERNAL,
3976                 { },
3977                 { { 0, 2 } },
3978         },
3979         {
3980                 "ALU64_LSH_K: 1 << 31 = 0x80000000",
3981                 .u.insns_int = {
3982                         BPF_LD_IMM64(R0, 1),
3983                         BPF_ALU64_IMM(BPF_LSH, R0, 31),
3984                         BPF_EXIT_INSN(),
3985                 },
3986                 INTERNAL,
3987                 { },
3988                 { { 0, 0x80000000 } },
3989         },
3990         /* BPF_ALU | BPF_RSH | BPF_X */
3991         {
3992                 "ALU_RSH_X: 2 >> 1 = 1",
3993                 .u.insns_int = {
3994                         BPF_LD_IMM64(R0, 2),
3995                         BPF_ALU32_IMM(BPF_MOV, R1, 1),
3996                         BPF_ALU32_REG(BPF_RSH, R0, R1),
3997                         BPF_EXIT_INSN(),
3998                 },
3999                 INTERNAL,
4000                 { },
4001                 { { 0, 1 } },
4002         },
4003         {
4004                 "ALU_RSH_X: 0x80000000 >> 31 = 1",
4005                 .u.insns_int = {
4006                         BPF_LD_IMM64(R0, 0x80000000),
4007                         BPF_ALU32_IMM(BPF_MOV, R1, 31),
4008                         BPF_ALU32_REG(BPF_RSH, R0, R1),
4009                         BPF_EXIT_INSN(),
4010                 },
4011                 INTERNAL,
4012                 { },
4013                 { { 0, 1 } },
4014         },
4015         {
4016                 "ALU64_RSH_X: 2 >> 1 = 1",
4017                 .u.insns_int = {
4018                         BPF_LD_IMM64(R0, 2),
4019                         BPF_ALU32_IMM(BPF_MOV, R1, 1),
4020                         BPF_ALU64_REG(BPF_RSH, R0, R1),
4021                         BPF_EXIT_INSN(),
4022                 },
4023                 INTERNAL,
4024                 { },
4025                 { { 0, 1 } },
4026         },
4027         {
4028                 "ALU64_RSH_X: 0x80000000 >> 31 = 1",
4029                 .u.insns_int = {
4030                         BPF_LD_IMM64(R0, 0x80000000),
4031                         BPF_ALU32_IMM(BPF_MOV, R1, 31),
4032                         BPF_ALU64_REG(BPF_RSH, R0, R1),
4033                         BPF_EXIT_INSN(),
4034                 },
4035                 INTERNAL,
4036                 { },
4037                 { { 0, 1 } },
4038         },
4039         /* BPF_ALU | BPF_RSH | BPF_K */
4040         {
4041                 "ALU_RSH_K: 2 >> 1 = 1",
4042                 .u.insns_int = {
4043                         BPF_LD_IMM64(R0, 2),
4044                         BPF_ALU32_IMM(BPF_RSH, R0, 1),
4045                         BPF_EXIT_INSN(),
4046                 },
4047                 INTERNAL,
4048                 { },
4049                 { { 0, 1 } },
4050         },
4051         {
4052                 "ALU_RSH_K: 0x80000000 >> 31 = 1",
4053                 .u.insns_int = {
4054                         BPF_LD_IMM64(R0, 0x80000000),
4055                         BPF_ALU32_IMM(BPF_RSH, R0, 31),
4056                         BPF_EXIT_INSN(),
4057                 },
4058                 INTERNAL,
4059                 { },
4060                 { { 0, 1 } },
4061         },
4062         {
4063                 "ALU64_RSH_K: 2 >> 1 = 1",
4064                 .u.insns_int = {
4065                         BPF_LD_IMM64(R0, 2),
4066                         BPF_ALU64_IMM(BPF_RSH, R0, 1),
4067                         BPF_EXIT_INSN(),
4068                 },
4069                 INTERNAL,
4070                 { },
4071                 { { 0, 1 } },
4072         },
4073         {
4074                 "ALU64_RSH_K: 0x80000000 >> 31 = 1",
4075                 .u.insns_int = {
4076                         BPF_LD_IMM64(R0, 0x80000000),
4077                         BPF_ALU64_IMM(BPF_RSH, R0, 31),
4078                         BPF_EXIT_INSN(),
4079                 },
4080                 INTERNAL,
4081                 { },
4082                 { { 0, 1 } },
4083         },
4084         /* BPF_ALU | BPF_ARSH | BPF_X */
4085         {
4086                 "ALU_ARSH_X: 0xff00ff0000000000 >> 40 = 0xffffffffffff00ff",
4087                 .u.insns_int = {
4088                         BPF_LD_IMM64(R0, 0xff00ff0000000000LL),
4089                         BPF_ALU32_IMM(BPF_MOV, R1, 40),
4090                         BPF_ALU64_REG(BPF_ARSH, R0, R1),
4091                         BPF_EXIT_INSN(),
4092                 },
4093                 INTERNAL,
4094                 { },
4095                 { { 0, 0xffff00ff } },
4096         },
4097         /* BPF_ALU | BPF_ARSH | BPF_K */
4098         {
4099                 "ALU_ARSH_K: 0xff00ff0000000000 >> 40 = 0xffffffffffff00ff",
4100                 .u.insns_int = {
4101                         BPF_LD_IMM64(R0, 0xff00ff0000000000LL),
4102                         BPF_ALU64_IMM(BPF_ARSH, R0, 40),
4103                         BPF_EXIT_INSN(),
4104                 },
4105                 INTERNAL,
4106                 { },
4107                 { { 0, 0xffff00ff } },
4108         },
4109         /* BPF_ALU | BPF_NEG */
4110         {
4111                 "ALU_NEG: -(3) = -3",
4112                 .u.insns_int = {
4113                         BPF_ALU32_IMM(BPF_MOV, R0, 3),
4114                         BPF_ALU32_IMM(BPF_NEG, R0, 0),
4115                         BPF_EXIT_INSN(),
4116                 },
4117                 INTERNAL,
4118                 { },
4119                 { { 0, -3 } },
4120         },
4121         {
4122                 "ALU_NEG: -(-3) = 3",
4123                 .u.insns_int = {
4124                         BPF_ALU32_IMM(BPF_MOV, R0, -3),
4125                         BPF_ALU32_IMM(BPF_NEG, R0, 0),
4126                         BPF_EXIT_INSN(),
4127                 },
4128                 INTERNAL,
4129                 { },
4130                 { { 0, 3 } },
4131         },
4132         {
4133                 "ALU64_NEG: -(3) = -3",
4134                 .u.insns_int = {
4135                         BPF_LD_IMM64(R0, 3),
4136                         BPF_ALU64_IMM(BPF_NEG, R0, 0),
4137                         BPF_EXIT_INSN(),
4138                 },
4139                 INTERNAL,
4140                 { },
4141                 { { 0, -3 } },
4142         },
4143         {
4144                 "ALU64_NEG: -(-3) = 3",
4145                 .u.insns_int = {
4146                         BPF_LD_IMM64(R0, -3),
4147                         BPF_ALU64_IMM(BPF_NEG, R0, 0),
4148                         BPF_EXIT_INSN(),
4149                 },
4150                 INTERNAL,
4151                 { },
4152                 { { 0, 3 } },
4153         },
4154         /* BPF_ALU | BPF_END | BPF_FROM_BE */
4155         {
4156                 "ALU_END_FROM_BE 16: 0x0123456789abcdef -> 0xcdef",
4157                 .u.insns_int = {
4158                         BPF_LD_IMM64(R0, 0x0123456789abcdefLL),
4159                         BPF_ENDIAN(BPF_FROM_BE, R0, 16),
4160                         BPF_EXIT_INSN(),
4161                 },
4162                 INTERNAL,
4163                 { },
4164                 { { 0,  cpu_to_be16(0xcdef) } },
4165         },
4166         {
4167                 "ALU_END_FROM_BE 32: 0x0123456789abcdef -> 0x89abcdef",
4168                 .u.insns_int = {
4169                         BPF_LD_IMM64(R0, 0x0123456789abcdefLL),
4170                         BPF_ENDIAN(BPF_FROM_BE, R0, 32),
4171                         BPF_ALU64_REG(BPF_MOV, R1, R0),
4172                         BPF_ALU64_IMM(BPF_RSH, R1, 32),
4173                         BPF_ALU32_REG(BPF_ADD, R0, R1), /* R1 = 0 */
4174                         BPF_EXIT_INSN(),
4175                 },
4176                 INTERNAL,
4177                 { },
4178                 { { 0, cpu_to_be32(0x89abcdef) } },
4179         },
4180         {
4181                 "ALU_END_FROM_BE 64: 0x0123456789abcdef -> 0x89abcdef",
4182                 .u.insns_int = {
4183                         BPF_LD_IMM64(R0, 0x0123456789abcdefLL),
4184                         BPF_ENDIAN(BPF_FROM_BE, R0, 64),
4185                         BPF_EXIT_INSN(),
4186                 },
4187                 INTERNAL,
4188                 { },
4189                 { { 0, (u32) cpu_to_be64(0x0123456789abcdefLL) } },
4190         },
4191         /* BPF_ALU | BPF_END | BPF_FROM_LE */
4192         {
4193                 "ALU_END_FROM_LE 16: 0x0123456789abcdef -> 0xefcd",
4194                 .u.insns_int = {
4195                         BPF_LD_IMM64(R0, 0x0123456789abcdefLL),
4196                         BPF_ENDIAN(BPF_FROM_LE, R0, 16),
4197                         BPF_EXIT_INSN(),
4198                 },
4199                 INTERNAL,
4200                 { },
4201                 { { 0, cpu_to_le16(0xcdef) } },
4202         },
4203         {
4204                 "ALU_END_FROM_LE 32: 0x0123456789abcdef -> 0xefcdab89",
4205                 .u.insns_int = {
4206                         BPF_LD_IMM64(R0, 0x0123456789abcdefLL),
4207                         BPF_ENDIAN(BPF_FROM_LE, R0, 32),
4208                         BPF_ALU64_REG(BPF_MOV, R1, R0),
4209                         BPF_ALU64_IMM(BPF_RSH, R1, 32),
4210                         BPF_ALU32_REG(BPF_ADD, R0, R1), /* R1 = 0 */
4211                         BPF_EXIT_INSN(),
4212                 },
4213                 INTERNAL,
4214                 { },
4215                 { { 0, cpu_to_le32(0x89abcdef) } },
4216         },
4217         {
4218                 "ALU_END_FROM_LE 64: 0x0123456789abcdef -> 0x67452301",
4219                 .u.insns_int = {
4220                         BPF_LD_IMM64(R0, 0x0123456789abcdefLL),
4221                         BPF_ENDIAN(BPF_FROM_LE, R0, 64),
4222                         BPF_EXIT_INSN(),
4223                 },
4224                 INTERNAL,
4225                 { },
4226                 { { 0, (u32) cpu_to_le64(0x0123456789abcdefLL) } },
4227         },
4228         /* BPF_ST(X) | BPF_MEM | BPF_B/H/W/DW */
4229         {
4230                 "ST_MEM_B: Store/Load byte: max negative",
4231                 .u.insns_int = {
4232                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
4233                         BPF_ST_MEM(BPF_B, R10, -40, 0xff),
4234                         BPF_LDX_MEM(BPF_B, R0, R10, -40),
4235                         BPF_EXIT_INSN(),
4236                 },
4237                 INTERNAL,
4238                 { },
4239                 { { 0, 0xff } },
4240                 .stack_depth = 40,
4241         },
4242         {
4243                 "ST_MEM_B: Store/Load byte: max positive",
4244                 .u.insns_int = {
4245                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
4246                         BPF_ST_MEM(BPF_H, R10, -40, 0x7f),
4247                         BPF_LDX_MEM(BPF_H, R0, R10, -40),
4248                         BPF_EXIT_INSN(),
4249                 },
4250                 INTERNAL,
4251                 { },
4252                 { { 0, 0x7f } },
4253                 .stack_depth = 40,
4254         },
4255         {
4256                 "STX_MEM_B: Store/Load byte: max negative",
4257                 .u.insns_int = {
4258                         BPF_LD_IMM64(R0, 0),
4259                         BPF_LD_IMM64(R1, 0xffLL),
4260                         BPF_STX_MEM(BPF_B, R10, R1, -40),
4261                         BPF_LDX_MEM(BPF_B, R0, R10, -40),
4262                         BPF_EXIT_INSN(),
4263                 },
4264                 INTERNAL,
4265                 { },
4266                 { { 0, 0xff } },
4267                 .stack_depth = 40,
4268         },
4269         {
4270                 "ST_MEM_H: Store/Load half word: max negative",
4271                 .u.insns_int = {
4272                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
4273                         BPF_ST_MEM(BPF_H, R10, -40, 0xffff),
4274                         BPF_LDX_MEM(BPF_H, R0, R10, -40),
4275                         BPF_EXIT_INSN(),
4276                 },
4277                 INTERNAL,
4278                 { },
4279                 { { 0, 0xffff } },
4280                 .stack_depth = 40,
4281         },
4282         {
4283                 "ST_MEM_H: Store/Load half word: max positive",
4284                 .u.insns_int = {
4285                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
4286                         BPF_ST_MEM(BPF_H, R10, -40, 0x7fff),
4287                         BPF_LDX_MEM(BPF_H, R0, R10, -40),
4288                         BPF_EXIT_INSN(),
4289                 },
4290                 INTERNAL,
4291                 { },
4292                 { { 0, 0x7fff } },
4293                 .stack_depth = 40,
4294         },
4295         {
4296                 "STX_MEM_H: Store/Load half word: max negative",
4297                 .u.insns_int = {
4298                         BPF_LD_IMM64(R0, 0),
4299                         BPF_LD_IMM64(R1, 0xffffLL),
4300                         BPF_STX_MEM(BPF_H, R10, R1, -40),
4301                         BPF_LDX_MEM(BPF_H, R0, R10, -40),
4302                         BPF_EXIT_INSN(),
4303                 },
4304                 INTERNAL,
4305                 { },
4306                 { { 0, 0xffff } },
4307                 .stack_depth = 40,
4308         },
4309         {
4310                 "ST_MEM_W: Store/Load word: max negative",
4311                 .u.insns_int = {
4312                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
4313                         BPF_ST_MEM(BPF_W, R10, -40, 0xffffffff),
4314                         BPF_LDX_MEM(BPF_W, R0, R10, -40),
4315                         BPF_EXIT_INSN(),
4316                 },
4317                 INTERNAL,
4318                 { },
4319                 { { 0, 0xffffffff } },
4320                 .stack_depth = 40,
4321         },
4322         {
4323                 "ST_MEM_W: Store/Load word: max positive",
4324                 .u.insns_int = {
4325                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
4326                         BPF_ST_MEM(BPF_W, R10, -40, 0x7fffffff),
4327                         BPF_LDX_MEM(BPF_W, R0, R10, -40),
4328                         BPF_EXIT_INSN(),
4329                 },
4330                 INTERNAL,
4331                 { },
4332                 { { 0, 0x7fffffff } },
4333                 .stack_depth = 40,
4334         },
4335         {
4336                 "STX_MEM_W: Store/Load word: max negative",
4337                 .u.insns_int = {
4338                         BPF_LD_IMM64(R0, 0),
4339                         BPF_LD_IMM64(R1, 0xffffffffLL),
4340                         BPF_STX_MEM(BPF_W, R10, R1, -40),
4341                         BPF_LDX_MEM(BPF_W, R0, R10, -40),
4342                         BPF_EXIT_INSN(),
4343                 },
4344                 INTERNAL,
4345                 { },
4346                 { { 0, 0xffffffff } },
4347                 .stack_depth = 40,
4348         },
4349         {
4350                 "ST_MEM_DW: Store/Load double word: max negative",
4351                 .u.insns_int = {
4352                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
4353                         BPF_ST_MEM(BPF_DW, R10, -40, 0xffffffff),
4354                         BPF_LDX_MEM(BPF_DW, R0, R10, -40),
4355                         BPF_EXIT_INSN(),
4356                 },
4357                 INTERNAL,
4358                 { },
4359                 { { 0, 0xffffffff } },
4360                 .stack_depth = 40,
4361         },
4362         {
4363                 "ST_MEM_DW: Store/Load double word: max negative 2",
4364                 .u.insns_int = {
4365                         BPF_LD_IMM64(R2, 0xffff00000000ffffLL),
4366                         BPF_LD_IMM64(R3, 0xffffffffffffffffLL),
4367                         BPF_ST_MEM(BPF_DW, R10, -40, 0xffffffff),
4368                         BPF_LDX_MEM(BPF_DW, R2, R10, -40),
4369                         BPF_JMP_REG(BPF_JEQ, R2, R3, 2),
4370                         BPF_MOV32_IMM(R0, 2),
4371                         BPF_EXIT_INSN(),
4372                         BPF_MOV32_IMM(R0, 1),
4373                         BPF_EXIT_INSN(),
4374                 },
4375                 INTERNAL,
4376                 { },
4377                 { { 0, 0x1 } },
4378                 .stack_depth = 40,
4379         },
4380         {
4381                 "ST_MEM_DW: Store/Load double word: max positive",
4382                 .u.insns_int = {
4383                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
4384                         BPF_ST_MEM(BPF_DW, R10, -40, 0x7fffffff),
4385                         BPF_LDX_MEM(BPF_DW, R0, R10, -40),
4386                         BPF_EXIT_INSN(),
4387                 },
4388                 INTERNAL,
4389                 { },
4390                 { { 0, 0x7fffffff } },
4391                 .stack_depth = 40,
4392         },
4393         {
4394                 "STX_MEM_DW: Store/Load double word: max negative",
4395                 .u.insns_int = {
4396                         BPF_LD_IMM64(R0, 0),
4397                         BPF_LD_IMM64(R1, 0xffffffffffffffffLL),
4398                         BPF_STX_MEM(BPF_W, R10, R1, -40),
4399                         BPF_LDX_MEM(BPF_W, R0, R10, -40),
4400                         BPF_EXIT_INSN(),
4401                 },
4402                 INTERNAL,
4403                 { },
4404                 { { 0, 0xffffffff } },
4405                 .stack_depth = 40,
4406         },
4407         /* BPF_STX | BPF_XADD | BPF_W/DW */
4408         {
4409                 "STX_XADD_W: Test: 0x12 + 0x10 = 0x22",
4410                 .u.insns_int = {
4411                         BPF_ALU32_IMM(BPF_MOV, R0, 0x12),
4412                         BPF_ST_MEM(BPF_W, R10, -40, 0x10),
4413                         BPF_STX_XADD(BPF_W, R10, R0, -40),
4414                         BPF_LDX_MEM(BPF_W, R0, R10, -40),
4415                         BPF_EXIT_INSN(),
4416                 },
4417                 INTERNAL,
4418                 { },
4419                 { { 0, 0x22 } },
4420                 .stack_depth = 40,
4421         },
4422         {
4423                 "STX_XADD_W: Test side-effects, r10: 0x12 + 0x10 = 0x22",
4424                 .u.insns_int = {
4425                         BPF_ALU64_REG(BPF_MOV, R1, R10),
4426                         BPF_ALU32_IMM(BPF_MOV, R0, 0x12),
4427                         BPF_ST_MEM(BPF_W, R10, -40, 0x10),
4428                         BPF_STX_XADD(BPF_W, R10, R0, -40),
4429                         BPF_ALU64_REG(BPF_MOV, R0, R10),
4430                         BPF_ALU64_REG(BPF_SUB, R0, R1),
4431                         BPF_EXIT_INSN(),
4432                 },
4433                 INTERNAL,
4434                 { },
4435                 { { 0, 0 } },
4436                 .stack_depth = 40,
4437         },
4438         {
4439                 "STX_XADD_W: Test side-effects, r0: 0x12 + 0x10 = 0x22",
4440                 .u.insns_int = {
4441                         BPF_ALU32_IMM(BPF_MOV, R0, 0x12),
4442                         BPF_ST_MEM(BPF_W, R10, -40, 0x10),
4443                         BPF_STX_XADD(BPF_W, R10, R0, -40),
4444                         BPF_EXIT_INSN(),
4445                 },
4446                 INTERNAL,
4447                 { },
4448                 { { 0, 0x12 } },
4449                 .stack_depth = 40,
4450         },
4451         {
4452                 "STX_XADD_W: X + 1 + 1 + 1 + ...",
4453                 { },
4454                 INTERNAL,
4455                 { },
4456                 { { 0, 4134 } },
4457                 .fill_helper = bpf_fill_stxw,
4458         },
4459         {
4460                 "STX_XADD_DW: Test: 0x12 + 0x10 = 0x22",
4461                 .u.insns_int = {
4462                         BPF_ALU32_IMM(BPF_MOV, R0, 0x12),
4463                         BPF_ST_MEM(BPF_DW, R10, -40, 0x10),
4464                         BPF_STX_XADD(BPF_DW, R10, R0, -40),
4465                         BPF_LDX_MEM(BPF_DW, R0, R10, -40),
4466                         BPF_EXIT_INSN(),
4467                 },
4468                 INTERNAL,
4469                 { },
4470                 { { 0, 0x22 } },
4471                 .stack_depth = 40,
4472         },
4473         {
4474                 "STX_XADD_DW: Test side-effects, r10: 0x12 + 0x10 = 0x22",
4475                 .u.insns_int = {
4476                         BPF_ALU64_REG(BPF_MOV, R1, R10),
4477                         BPF_ALU32_IMM(BPF_MOV, R0, 0x12),
4478                         BPF_ST_MEM(BPF_DW, R10, -40, 0x10),
4479                         BPF_STX_XADD(BPF_DW, R10, R0, -40),
4480                         BPF_ALU64_REG(BPF_MOV, R0, R10),
4481                         BPF_ALU64_REG(BPF_SUB, R0, R1),
4482                         BPF_EXIT_INSN(),
4483                 },
4484                 INTERNAL,
4485                 { },
4486                 { { 0, 0 } },
4487                 .stack_depth = 40,
4488         },
4489         {
4490                 "STX_XADD_DW: Test side-effects, r0: 0x12 + 0x10 = 0x22",
4491                 .u.insns_int = {
4492                         BPF_ALU32_IMM(BPF_MOV, R0, 0x12),
4493                         BPF_ST_MEM(BPF_DW, R10, -40, 0x10),
4494                         BPF_STX_XADD(BPF_DW, R10, R0, -40),
4495                         BPF_EXIT_INSN(),
4496                 },
4497                 INTERNAL,
4498                 { },
4499                 { { 0, 0x12 } },
4500                 .stack_depth = 40,
4501         },
4502         {
4503                 "STX_XADD_DW: X + 1 + 1 + 1 + ...",
4504                 { },
4505                 INTERNAL,
4506                 { },
4507                 { { 0, 4134 } },
4508                 .fill_helper = bpf_fill_stxdw,
4509         },
4510         /* BPF_JMP | BPF_EXIT */
4511         {
4512                 "JMP_EXIT",
4513                 .u.insns_int = {
4514                         BPF_ALU32_IMM(BPF_MOV, R0, 0x4711),
4515                         BPF_EXIT_INSN(),
4516                         BPF_ALU32_IMM(BPF_MOV, R0, 0x4712),
4517                 },
4518                 INTERNAL,
4519                 { },
4520                 { { 0, 0x4711 } },
4521         },
4522         /* BPF_JMP | BPF_JA */
4523         {
4524                 "JMP_JA: Unconditional jump: if (true) return 1",
4525                 .u.insns_int = {
4526                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
4527                         BPF_JMP_IMM(BPF_JA, 0, 0, 1),
4528                         BPF_EXIT_INSN(),
4529                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
4530                         BPF_EXIT_INSN(),
4531                 },
4532                 INTERNAL,
4533                 { },
4534                 { { 0, 1 } },
4535         },
4536         /* BPF_JMP | BPF_JSLT | BPF_K */
4537         {
4538                 "JMP_JSLT_K: Signed jump: if (-2 < -1) return 1",
4539                 .u.insns_int = {
4540                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
4541                         BPF_LD_IMM64(R1, 0xfffffffffffffffeLL),
4542                         BPF_JMP_IMM(BPF_JSLT, R1, -1, 1),
4543                         BPF_EXIT_INSN(),
4544                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
4545                         BPF_EXIT_INSN(),
4546                 },
4547                 INTERNAL,
4548                 { },
4549                 { { 0, 1 } },
4550         },
4551         {
4552                 "JMP_JSLT_K: Signed jump: if (-1 < -1) return 0",
4553                 .u.insns_int = {
4554                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
4555                         BPF_LD_IMM64(R1, 0xffffffffffffffffLL),
4556                         BPF_JMP_IMM(BPF_JSLT, R1, -1, 1),
4557                         BPF_EXIT_INSN(),
4558                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
4559                         BPF_EXIT_INSN(),
4560                 },
4561                 INTERNAL,
4562                 { },
4563                 { { 0, 1 } },
4564         },
4565         /* BPF_JMP | BPF_JSGT | BPF_K */
4566         {
4567                 "JMP_JSGT_K: Signed jump: if (-1 > -2) return 1",
4568                 .u.insns_int = {
4569                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
4570                         BPF_LD_IMM64(R1, 0xffffffffffffffffLL),
4571                         BPF_JMP_IMM(BPF_JSGT, R1, -2, 1),
4572                         BPF_EXIT_INSN(),
4573                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
4574                         BPF_EXIT_INSN(),
4575                 },
4576                 INTERNAL,
4577                 { },
4578                 { { 0, 1 } },
4579         },
4580         {
4581                 "JMP_JSGT_K: Signed jump: if (-1 > -1) return 0",
4582                 .u.insns_int = {
4583                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
4584                         BPF_LD_IMM64(R1, 0xffffffffffffffffLL),
4585                         BPF_JMP_IMM(BPF_JSGT, R1, -1, 1),
4586                         BPF_EXIT_INSN(),
4587                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
4588                         BPF_EXIT_INSN(),
4589                 },
4590                 INTERNAL,
4591                 { },
4592                 { { 0, 1 } },
4593         },
4594         /* BPF_JMP | BPF_JSLE | BPF_K */
4595         {
4596                 "JMP_JSLE_K: Signed jump: if (-2 <= -1) return 1",
4597                 .u.insns_int = {
4598                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
4599                         BPF_LD_IMM64(R1, 0xfffffffffffffffeLL),
4600                         BPF_JMP_IMM(BPF_JSLE, R1, -1, 1),
4601                         BPF_EXIT_INSN(),
4602                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
4603                         BPF_EXIT_INSN(),
4604                 },
4605                 INTERNAL,
4606                 { },
4607                 { { 0, 1 } },
4608         },
4609         {
4610                 "JMP_JSLE_K: Signed jump: if (-1 <= -1) return 1",
4611                 .u.insns_int = {
4612                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
4613                         BPF_LD_IMM64(R1, 0xffffffffffffffffLL),
4614                         BPF_JMP_IMM(BPF_JSLE, R1, -1, 1),
4615                         BPF_EXIT_INSN(),
4616                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
4617                         BPF_EXIT_INSN(),
4618                 },
4619                 INTERNAL,
4620                 { },
4621                 { { 0, 1 } },
4622         },
4623         {
4624                 "JMP_JSLE_K: Signed jump: value walk 1",
4625                 .u.insns_int = {
4626                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
4627                         BPF_LD_IMM64(R1, 3),
4628                         BPF_JMP_IMM(BPF_JSLE, R1, 0, 6),
4629                         BPF_ALU64_IMM(BPF_SUB, R1, 1),
4630                         BPF_JMP_IMM(BPF_JSLE, R1, 0, 4),
4631                         BPF_ALU64_IMM(BPF_SUB, R1, 1),
4632                         BPF_JMP_IMM(BPF_JSLE, R1, 0, 2),
4633                         BPF_ALU64_IMM(BPF_SUB, R1, 1),
4634                         BPF_JMP_IMM(BPF_JSLE, R1, 0, 1),
4635                         BPF_EXIT_INSN(),                /* bad exit */
4636                         BPF_ALU32_IMM(BPF_MOV, R0, 1),  /* good exit */
4637                         BPF_EXIT_INSN(),
4638                 },
4639                 INTERNAL,
4640                 { },
4641                 { { 0, 1 } },
4642         },
4643         {
4644                 "JMP_JSLE_K: Signed jump: value walk 2",
4645                 .u.insns_int = {
4646                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
4647                         BPF_LD_IMM64(R1, 3),
4648                         BPF_JMP_IMM(BPF_JSLE, R1, 0, 4),
4649                         BPF_ALU64_IMM(BPF_SUB, R1, 2),
4650                         BPF_JMP_IMM(BPF_JSLE, R1, 0, 2),
4651                         BPF_ALU64_IMM(BPF_SUB, R1, 2),
4652                         BPF_JMP_IMM(BPF_JSLE, R1, 0, 1),
4653                         BPF_EXIT_INSN(),                /* bad exit */
4654                         BPF_ALU32_IMM(BPF_MOV, R0, 1),  /* good exit */
4655                         BPF_EXIT_INSN(),
4656                 },
4657                 INTERNAL,
4658                 { },
4659                 { { 0, 1 } },
4660         },
4661         /* BPF_JMP | BPF_JSGE | BPF_K */
4662         {
4663                 "JMP_JSGE_K: Signed jump: if (-1 >= -2) return 1",
4664                 .u.insns_int = {
4665                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
4666                         BPF_LD_IMM64(R1, 0xffffffffffffffffLL),
4667                         BPF_JMP_IMM(BPF_JSGE, R1, -2, 1),
4668                         BPF_EXIT_INSN(),
4669                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
4670                         BPF_EXIT_INSN(),
4671                 },
4672                 INTERNAL,
4673                 { },
4674                 { { 0, 1 } },
4675         },
4676         {
4677                 "JMP_JSGE_K: Signed jump: if (-1 >= -1) return 1",
4678                 .u.insns_int = {
4679                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
4680                         BPF_LD_IMM64(R1, 0xffffffffffffffffLL),
4681                         BPF_JMP_IMM(BPF_JSGE, R1, -1, 1),
4682                         BPF_EXIT_INSN(),
4683                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
4684                         BPF_EXIT_INSN(),
4685                 },
4686                 INTERNAL,
4687                 { },
4688                 { { 0, 1 } },
4689         },
4690         {
4691                 "JMP_JSGE_K: Signed jump: value walk 1",
4692                 .u.insns_int = {
4693                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
4694                         BPF_LD_IMM64(R1, -3),
4695                         BPF_JMP_IMM(BPF_JSGE, R1, 0, 6),
4696                         BPF_ALU64_IMM(BPF_ADD, R1, 1),
4697                         BPF_JMP_IMM(BPF_JSGE, R1, 0, 4),
4698                         BPF_ALU64_IMM(BPF_ADD, R1, 1),
4699                         BPF_JMP_IMM(BPF_JSGE, R1, 0, 2),
4700                         BPF_ALU64_IMM(BPF_ADD, R1, 1),
4701                         BPF_JMP_IMM(BPF_JSGE, R1, 0, 1),
4702                         BPF_EXIT_INSN(),                /* bad exit */
4703                         BPF_ALU32_IMM(BPF_MOV, R0, 1),  /* good exit */
4704                         BPF_EXIT_INSN(),
4705                 },
4706                 INTERNAL,
4707                 { },
4708                 { { 0, 1 } },
4709         },
4710         {
4711                 "JMP_JSGE_K: Signed jump: value walk 2",
4712                 .u.insns_int = {
4713                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
4714                         BPF_LD_IMM64(R1, -3),
4715                         BPF_JMP_IMM(BPF_JSGE, R1, 0, 4),
4716                         BPF_ALU64_IMM(BPF_ADD, R1, 2),
4717                         BPF_JMP_IMM(BPF_JSGE, R1, 0, 2),
4718                         BPF_ALU64_IMM(BPF_ADD, R1, 2),
4719                         BPF_JMP_IMM(BPF_JSGE, R1, 0, 1),
4720                         BPF_EXIT_INSN(),                /* bad exit */
4721                         BPF_ALU32_IMM(BPF_MOV, R0, 1),  /* good exit */
4722                         BPF_EXIT_INSN(),
4723                 },
4724                 INTERNAL,
4725                 { },
4726                 { { 0, 1 } },
4727         },
4728         /* BPF_JMP | BPF_JGT | BPF_K */
4729         {
4730                 "JMP_JGT_K: if (3 > 2) return 1",
4731                 .u.insns_int = {
4732                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
4733                         BPF_LD_IMM64(R1, 3),
4734                         BPF_JMP_IMM(BPF_JGT, R1, 2, 1),
4735                         BPF_EXIT_INSN(),
4736                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
4737                         BPF_EXIT_INSN(),
4738                 },
4739                 INTERNAL,
4740                 { },
4741                 { { 0, 1 } },
4742         },
4743         {
4744                 "JMP_JGT_K: Unsigned jump: if (-1 > 1) return 1",
4745                 .u.insns_int = {
4746                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
4747                         BPF_LD_IMM64(R1, -1),
4748                         BPF_JMP_IMM(BPF_JGT, R1, 1, 1),
4749                         BPF_EXIT_INSN(),
4750                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
4751                         BPF_EXIT_INSN(),
4752                 },
4753                 INTERNAL,
4754                 { },
4755                 { { 0, 1 } },
4756         },
4757         /* BPF_JMP | BPF_JLT | BPF_K */
4758         {
4759                 "JMP_JLT_K: if (2 < 3) return 1",
4760                 .u.insns_int = {
4761                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
4762                         BPF_LD_IMM64(R1, 2),
4763                         BPF_JMP_IMM(BPF_JLT, R1, 3, 1),
4764                         BPF_EXIT_INSN(),
4765                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
4766                         BPF_EXIT_INSN(),
4767                 },
4768                 INTERNAL,
4769                 { },
4770                 { { 0, 1 } },
4771         },
4772         {
4773                 "JMP_JGT_K: Unsigned jump: if (1 < -1) return 1",
4774                 .u.insns_int = {
4775                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
4776                         BPF_LD_IMM64(R1, 1),
4777                         BPF_JMP_IMM(BPF_JLT, R1, -1, 1),
4778                         BPF_EXIT_INSN(),
4779                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
4780                         BPF_EXIT_INSN(),
4781                 },
4782                 INTERNAL,
4783                 { },
4784                 { { 0, 1 } },
4785         },
4786         /* BPF_JMP | BPF_JGE | BPF_K */
4787         {
4788                 "JMP_JGE_K: if (3 >= 2) return 1",
4789                 .u.insns_int = {
4790                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
4791                         BPF_LD_IMM64(R1, 3),
4792                         BPF_JMP_IMM(BPF_JGE, R1, 2, 1),
4793                         BPF_EXIT_INSN(),
4794                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
4795                         BPF_EXIT_INSN(),
4796                 },
4797                 INTERNAL,
4798                 { },
4799                 { { 0, 1 } },
4800         },
4801         /* BPF_JMP | BPF_JLE | BPF_K */
4802         {
4803                 "JMP_JLE_K: if (2 <= 3) return 1",
4804                 .u.insns_int = {
4805                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
4806                         BPF_LD_IMM64(R1, 2),
4807                         BPF_JMP_IMM(BPF_JLE, R1, 3, 1),
4808                         BPF_EXIT_INSN(),
4809                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
4810                         BPF_EXIT_INSN(),
4811                 },
4812                 INTERNAL,
4813                 { },
4814                 { { 0, 1 } },
4815         },
4816         /* BPF_JMP | BPF_JGT | BPF_K jump backwards */
4817         {
4818                 "JMP_JGT_K: if (3 > 2) return 1 (jump backwards)",
4819                 .u.insns_int = {
4820                         BPF_JMP_IMM(BPF_JA, 0, 0, 2), /* goto start */
4821                         BPF_ALU32_IMM(BPF_MOV, R0, 1), /* out: */
4822                         BPF_EXIT_INSN(),
4823                         BPF_ALU32_IMM(BPF_MOV, R0, 0), /* start: */
4824                         BPF_LD_IMM64(R1, 3), /* note: this takes 2 insns */
4825                         BPF_JMP_IMM(BPF_JGT, R1, 2, -6), /* goto out */
4826                         BPF_EXIT_INSN(),
4827                 },
4828                 INTERNAL,
4829                 { },
4830                 { { 0, 1 } },
4831         },
4832         {
4833                 "JMP_JGE_K: if (3 >= 3) return 1",
4834                 .u.insns_int = {
4835                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
4836                         BPF_LD_IMM64(R1, 3),
4837                         BPF_JMP_IMM(BPF_JGE, R1, 3, 1),
4838                         BPF_EXIT_INSN(),
4839                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
4840                         BPF_EXIT_INSN(),
4841                 },
4842                 INTERNAL,
4843                 { },
4844                 { { 0, 1 } },
4845         },
4846         /* BPF_JMP | BPF_JLT | BPF_K jump backwards */
4847         {
4848                 "JMP_JGT_K: if (2 < 3) return 1 (jump backwards)",
4849                 .u.insns_int = {
4850                         BPF_JMP_IMM(BPF_JA, 0, 0, 2), /* goto start */
4851                         BPF_ALU32_IMM(BPF_MOV, R0, 1), /* out: */
4852                         BPF_EXIT_INSN(),
4853                         BPF_ALU32_IMM(BPF_MOV, R0, 0), /* start: */
4854                         BPF_LD_IMM64(R1, 2), /* note: this takes 2 insns */
4855                         BPF_JMP_IMM(BPF_JLT, R1, 3, -6), /* goto out */
4856                         BPF_EXIT_INSN(),
4857                 },
4858                 INTERNAL,
4859                 { },
4860                 { { 0, 1 } },
4861         },
4862         {
4863                 "JMP_JLE_K: if (3 <= 3) return 1",
4864                 .u.insns_int = {
4865                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
4866                         BPF_LD_IMM64(R1, 3),
4867                         BPF_JMP_IMM(BPF_JLE, R1, 3, 1),
4868                         BPF_EXIT_INSN(),
4869                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
4870                         BPF_EXIT_INSN(),
4871                 },
4872                 INTERNAL,
4873                 { },
4874                 { { 0, 1 } },
4875         },
4876         /* BPF_JMP | BPF_JNE | BPF_K */
4877         {
4878                 "JMP_JNE_K: if (3 != 2) return 1",
4879                 .u.insns_int = {
4880                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
4881                         BPF_LD_IMM64(R1, 3),
4882                         BPF_JMP_IMM(BPF_JNE, R1, 2, 1),
4883                         BPF_EXIT_INSN(),
4884                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
4885                         BPF_EXIT_INSN(),
4886                 },
4887                 INTERNAL,
4888                 { },
4889                 { { 0, 1 } },
4890         },
4891         /* BPF_JMP | BPF_JEQ | BPF_K */
4892         {
4893                 "JMP_JEQ_K: if (3 == 3) return 1",
4894                 .u.insns_int = {
4895                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
4896                         BPF_LD_IMM64(R1, 3),
4897                         BPF_JMP_IMM(BPF_JEQ, R1, 3, 1),
4898                         BPF_EXIT_INSN(),
4899                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
4900                         BPF_EXIT_INSN(),
4901                 },
4902                 INTERNAL,
4903                 { },
4904                 { { 0, 1 } },
4905         },
4906         /* BPF_JMP | BPF_JSET | BPF_K */
4907         {
4908                 "JMP_JSET_K: if (0x3 & 0x2) return 1",
4909                 .u.insns_int = {
4910                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
4911                         BPF_LD_IMM64(R1, 3),
4912                         BPF_JMP_IMM(BPF_JSET, R1, 2, 1),
4913                         BPF_EXIT_INSN(),
4914                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
4915                         BPF_EXIT_INSN(),
4916                 },
4917                 INTERNAL,
4918                 { },
4919                 { { 0, 1 } },
4920         },
4921         {
4922                 "JMP_JSET_K: if (0x3 & 0xffffffff) return 1",
4923                 .u.insns_int = {
4924                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
4925                         BPF_LD_IMM64(R1, 3),
4926                         BPF_JMP_IMM(BPF_JSET, R1, 0xffffffff, 1),
4927                         BPF_EXIT_INSN(),
4928                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
4929                         BPF_EXIT_INSN(),
4930                 },
4931                 INTERNAL,
4932                 { },
4933                 { { 0, 1 } },
4934         },
4935         /* BPF_JMP | BPF_JSGT | BPF_X */
4936         {
4937                 "JMP_JSGT_X: Signed jump: if (-1 > -2) return 1",
4938                 .u.insns_int = {
4939                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
4940                         BPF_LD_IMM64(R1, -1),
4941                         BPF_LD_IMM64(R2, -2),
4942                         BPF_JMP_REG(BPF_JSGT, R1, R2, 1),
4943                         BPF_EXIT_INSN(),
4944                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
4945                         BPF_EXIT_INSN(),
4946                 },
4947                 INTERNAL,
4948                 { },
4949                 { { 0, 1 } },
4950         },
4951         {
4952                 "JMP_JSGT_X: Signed jump: if (-1 > -1) return 0",
4953                 .u.insns_int = {
4954                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
4955                         BPF_LD_IMM64(R1, -1),
4956                         BPF_LD_IMM64(R2, -1),
4957                         BPF_JMP_REG(BPF_JSGT, R1, R2, 1),
4958                         BPF_EXIT_INSN(),
4959                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
4960                         BPF_EXIT_INSN(),
4961                 },
4962                 INTERNAL,
4963                 { },
4964                 { { 0, 1 } },
4965         },
4966         /* BPF_JMP | BPF_JSLT | BPF_X */
4967         {
4968                 "JMP_JSLT_X: Signed jump: if (-2 < -1) return 1",
4969                 .u.insns_int = {
4970                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
4971                         BPF_LD_IMM64(R1, -1),
4972                         BPF_LD_IMM64(R2, -2),
4973                         BPF_JMP_REG(BPF_JSLT, R2, R1, 1),
4974                         BPF_EXIT_INSN(),
4975                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
4976                         BPF_EXIT_INSN(),
4977                 },
4978                 INTERNAL,
4979                 { },
4980                 { { 0, 1 } },
4981         },
4982         {
4983                 "JMP_JSLT_X: Signed jump: if (-1 < -1) return 0",
4984                 .u.insns_int = {
4985                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
4986                         BPF_LD_IMM64(R1, -1),
4987                         BPF_LD_IMM64(R2, -1),
4988                         BPF_JMP_REG(BPF_JSLT, R1, R2, 1),
4989                         BPF_EXIT_INSN(),
4990                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
4991                         BPF_EXIT_INSN(),
4992                 },
4993                 INTERNAL,
4994                 { },
4995                 { { 0, 1 } },
4996         },
4997         /* BPF_JMP | BPF_JSGE | BPF_X */
4998         {
4999                 "JMP_JSGE_X: Signed jump: if (-1 >= -2) return 1",
5000                 .u.insns_int = {
5001                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
5002                         BPF_LD_IMM64(R1, -1),
5003                         BPF_LD_IMM64(R2, -2),
5004                         BPF_JMP_REG(BPF_JSGE, R1, R2, 1),
5005                         BPF_EXIT_INSN(),
5006                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
5007                         BPF_EXIT_INSN(),
5008                 },
5009                 INTERNAL,
5010                 { },
5011                 { { 0, 1 } },
5012         },
5013         {
5014                 "JMP_JSGE_X: Signed jump: if (-1 >= -1) return 1",
5015                 .u.insns_int = {
5016                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
5017                         BPF_LD_IMM64(R1, -1),
5018                         BPF_LD_IMM64(R2, -1),
5019                         BPF_JMP_REG(BPF_JSGE, R1, R2, 1),
5020                         BPF_EXIT_INSN(),
5021                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
5022                         BPF_EXIT_INSN(),
5023                 },
5024                 INTERNAL,
5025                 { },
5026                 { { 0, 1 } },
5027         },
5028         /* BPF_JMP | BPF_JSLE | BPF_X */
5029         {
5030                 "JMP_JSLE_X: Signed jump: if (-2 <= -1) return 1",
5031                 .u.insns_int = {
5032                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
5033                         BPF_LD_IMM64(R1, -1),
5034                         BPF_LD_IMM64(R2, -2),
5035                         BPF_JMP_REG(BPF_JSLE, R2, R1, 1),
5036                         BPF_EXIT_INSN(),
5037                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
5038                         BPF_EXIT_INSN(),
5039                 },
5040                 INTERNAL,
5041                 { },
5042                 { { 0, 1 } },
5043         },
5044         {
5045                 "JMP_JSLE_X: Signed jump: if (-1 <= -1) return 1",
5046                 .u.insns_int = {
5047                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
5048                         BPF_LD_IMM64(R1, -1),
5049                         BPF_LD_IMM64(R2, -1),
5050                         BPF_JMP_REG(BPF_JSLE, R1, R2, 1),
5051                         BPF_EXIT_INSN(),
5052                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
5053                         BPF_EXIT_INSN(),
5054                 },
5055                 INTERNAL,
5056                 { },
5057                 { { 0, 1 } },
5058         },
5059         /* BPF_JMP | BPF_JGT | BPF_X */
5060         {
5061                 "JMP_JGT_X: if (3 > 2) return 1",
5062                 .u.insns_int = {
5063                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
5064                         BPF_LD_IMM64(R1, 3),
5065                         BPF_LD_IMM64(R2, 2),
5066                         BPF_JMP_REG(BPF_JGT, R1, R2, 1),
5067                         BPF_EXIT_INSN(),
5068                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
5069                         BPF_EXIT_INSN(),
5070                 },
5071                 INTERNAL,
5072                 { },
5073                 { { 0, 1 } },
5074         },
5075         {
5076                 "JMP_JGT_X: Unsigned jump: if (-1 > 1) return 1",
5077                 .u.insns_int = {
5078                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
5079                         BPF_LD_IMM64(R1, -1),
5080                         BPF_LD_IMM64(R2, 1),
5081                         BPF_JMP_REG(BPF_JGT, R1, R2, 1),
5082                         BPF_EXIT_INSN(),
5083                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
5084                         BPF_EXIT_INSN(),
5085                 },
5086                 INTERNAL,
5087                 { },
5088                 { { 0, 1 } },
5089         },
5090         /* BPF_JMP | BPF_JLT | BPF_X */
5091         {
5092                 "JMP_JLT_X: if (2 < 3) return 1",
5093                 .u.insns_int = {
5094                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
5095                         BPF_LD_IMM64(R1, 3),
5096                         BPF_LD_IMM64(R2, 2),
5097                         BPF_JMP_REG(BPF_JLT, R2, R1, 1),
5098                         BPF_EXIT_INSN(),
5099                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
5100                         BPF_EXIT_INSN(),
5101                 },
5102                 INTERNAL,
5103                 { },
5104                 { { 0, 1 } },
5105         },
5106         {
5107                 "JMP_JLT_X: Unsigned jump: if (1 < -1) return 1",
5108                 .u.insns_int = {
5109                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
5110                         BPF_LD_IMM64(R1, -1),
5111                         BPF_LD_IMM64(R2, 1),
5112                         BPF_JMP_REG(BPF_JLT, R2, R1, 1),
5113                         BPF_EXIT_INSN(),
5114                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
5115                         BPF_EXIT_INSN(),
5116                 },
5117                 INTERNAL,
5118                 { },
5119                 { { 0, 1 } },
5120         },
5121         /* BPF_JMP | BPF_JGE | BPF_X */
5122         {
5123                 "JMP_JGE_X: if (3 >= 2) return 1",
5124                 .u.insns_int = {
5125                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
5126                         BPF_LD_IMM64(R1, 3),
5127                         BPF_LD_IMM64(R2, 2),
5128                         BPF_JMP_REG(BPF_JGE, R1, R2, 1),
5129                         BPF_EXIT_INSN(),
5130                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
5131                         BPF_EXIT_INSN(),
5132                 },
5133                 INTERNAL,
5134                 { },
5135                 { { 0, 1 } },
5136         },
5137         {
5138                 "JMP_JGE_X: if (3 >= 3) return 1",
5139                 .u.insns_int = {
5140                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
5141                         BPF_LD_IMM64(R1, 3),
5142                         BPF_LD_IMM64(R2, 3),
5143                         BPF_JMP_REG(BPF_JGE, R1, R2, 1),
5144                         BPF_EXIT_INSN(),
5145                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
5146                         BPF_EXIT_INSN(),
5147                 },
5148                 INTERNAL,
5149                 { },
5150                 { { 0, 1 } },
5151         },
5152         /* BPF_JMP | BPF_JLE | BPF_X */
5153         {
5154                 "JMP_JLE_X: if (2 <= 3) return 1",
5155                 .u.insns_int = {
5156                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
5157                         BPF_LD_IMM64(R1, 3),
5158                         BPF_LD_IMM64(R2, 2),
5159                         BPF_JMP_REG(BPF_JLE, R2, R1, 1),
5160                         BPF_EXIT_INSN(),
5161                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
5162                         BPF_EXIT_INSN(),
5163                 },
5164                 INTERNAL,
5165                 { },
5166                 { { 0, 1 } },
5167         },
5168         {
5169                 "JMP_JLE_X: if (3 <= 3) return 1",
5170                 .u.insns_int = {
5171                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
5172                         BPF_LD_IMM64(R1, 3),
5173                         BPF_LD_IMM64(R2, 3),
5174                         BPF_JMP_REG(BPF_JLE, R1, R2, 1),
5175                         BPF_EXIT_INSN(),
5176                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
5177                         BPF_EXIT_INSN(),
5178                 },
5179                 INTERNAL,
5180                 { },
5181                 { { 0, 1 } },
5182         },
5183         {
5184                 /* Mainly testing JIT + imm64 here. */
5185                 "JMP_JGE_X: ldimm64 test 1",
5186                 .u.insns_int = {
5187                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
5188                         BPF_LD_IMM64(R1, 3),
5189                         BPF_LD_IMM64(R2, 2),
5190                         BPF_JMP_REG(BPF_JGE, R1, R2, 2),
5191                         BPF_LD_IMM64(R0, 0xffffffffffffffffULL),
5192                         BPF_LD_IMM64(R0, 0xeeeeeeeeeeeeeeeeULL),
5193                         BPF_EXIT_INSN(),
5194                 },
5195                 INTERNAL,
5196                 { },
5197                 { { 0, 0xeeeeeeeeU } },
5198         },
5199         {
5200                 "JMP_JGE_X: ldimm64 test 2",
5201                 .u.insns_int = {
5202                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
5203                         BPF_LD_IMM64(R1, 3),
5204                         BPF_LD_IMM64(R2, 2),
5205                         BPF_JMP_REG(BPF_JGE, R1, R2, 0),
5206                         BPF_LD_IMM64(R0, 0xffffffffffffffffULL),
5207                         BPF_EXIT_INSN(),
5208                 },
5209                 INTERNAL,
5210                 { },
5211                 { { 0, 0xffffffffU } },
5212         },
5213         {
5214                 "JMP_JGE_X: ldimm64 test 3",
5215                 .u.insns_int = {
5216                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
5217                         BPF_LD_IMM64(R1, 3),
5218                         BPF_LD_IMM64(R2, 2),
5219                         BPF_JMP_REG(BPF_JGE, R1, R2, 4),
5220                         BPF_LD_IMM64(R0, 0xffffffffffffffffULL),
5221                         BPF_LD_IMM64(R0, 0xeeeeeeeeeeeeeeeeULL),
5222                         BPF_EXIT_INSN(),
5223                 },
5224                 INTERNAL,
5225                 { },
5226                 { { 0, 1 } },
5227         },
5228         {
5229                 "JMP_JLE_X: ldimm64 test 1",
5230                 .u.insns_int = {
5231                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
5232                         BPF_LD_IMM64(R1, 3),
5233                         BPF_LD_IMM64(R2, 2),
5234                         BPF_JMP_REG(BPF_JLE, R2, R1, 2),
5235                         BPF_LD_IMM64(R0, 0xffffffffffffffffULL),
5236                         BPF_LD_IMM64(R0, 0xeeeeeeeeeeeeeeeeULL),
5237                         BPF_EXIT_INSN(),
5238                 },
5239                 INTERNAL,
5240                 { },
5241                 { { 0, 0xeeeeeeeeU } },
5242         },
5243         {
5244                 "JMP_JLE_X: ldimm64 test 2",
5245                 .u.insns_int = {
5246                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
5247                         BPF_LD_IMM64(R1, 3),
5248                         BPF_LD_IMM64(R2, 2),
5249                         BPF_JMP_REG(BPF_JLE, R2, R1, 0),
5250                         BPF_LD_IMM64(R0, 0xffffffffffffffffULL),
5251                         BPF_EXIT_INSN(),
5252                 },
5253                 INTERNAL,
5254                 { },
5255                 { { 0, 0xffffffffU } },
5256         },
5257         {
5258                 "JMP_JLE_X: ldimm64 test 3",
5259                 .u.insns_int = {
5260                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
5261                         BPF_LD_IMM64(R1, 3),
5262                         BPF_LD_IMM64(R2, 2),
5263                         BPF_JMP_REG(BPF_JLE, R2, R1, 4),
5264                         BPF_LD_IMM64(R0, 0xffffffffffffffffULL),
5265                         BPF_LD_IMM64(R0, 0xeeeeeeeeeeeeeeeeULL),
5266                         BPF_EXIT_INSN(),
5267                 },
5268                 INTERNAL,
5269                 { },
5270                 { { 0, 1 } },
5271         },
5272         /* BPF_JMP | BPF_JNE | BPF_X */
5273         {
5274                 "JMP_JNE_X: if (3 != 2) return 1",
5275                 .u.insns_int = {
5276                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
5277                         BPF_LD_IMM64(R1, 3),
5278                         BPF_LD_IMM64(R2, 2),
5279                         BPF_JMP_REG(BPF_JNE, R1, R2, 1),
5280                         BPF_EXIT_INSN(),
5281                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
5282                         BPF_EXIT_INSN(),
5283                 },
5284                 INTERNAL,
5285                 { },
5286                 { { 0, 1 } },
5287         },
5288         /* BPF_JMP | BPF_JEQ | BPF_X */
5289         {
5290                 "JMP_JEQ_X: if (3 == 3) return 1",
5291                 .u.insns_int = {
5292                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
5293                         BPF_LD_IMM64(R1, 3),
5294                         BPF_LD_IMM64(R2, 3),
5295                         BPF_JMP_REG(BPF_JEQ, R1, R2, 1),
5296                         BPF_EXIT_INSN(),
5297                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
5298                         BPF_EXIT_INSN(),
5299                 },
5300                 INTERNAL,
5301                 { },
5302                 { { 0, 1 } },
5303         },
5304         /* BPF_JMP | BPF_JSET | BPF_X */
5305         {
5306                 "JMP_JSET_X: if (0x3 & 0x2) return 1",
5307                 .u.insns_int = {
5308                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
5309                         BPF_LD_IMM64(R1, 3),
5310                         BPF_LD_IMM64(R2, 2),
5311                         BPF_JMP_REG(BPF_JSET, R1, R2, 1),
5312                         BPF_EXIT_INSN(),
5313                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
5314                         BPF_EXIT_INSN(),
5315                 },
5316                 INTERNAL,
5317                 { },
5318                 { { 0, 1 } },
5319         },
5320         {
5321                 "JMP_JSET_X: if (0x3 & 0xffffffff) return 1",
5322                 .u.insns_int = {
5323                         BPF_ALU32_IMM(BPF_MOV, R0, 0),
5324                         BPF_LD_IMM64(R1, 3),
5325                         BPF_LD_IMM64(R2, 0xffffffff),
5326                         BPF_JMP_REG(BPF_JSET, R1, R2, 1),
5327                         BPF_EXIT_INSN(),
5328                         BPF_ALU32_IMM(BPF_MOV, R0, 1),
5329                         BPF_EXIT_INSN(),
5330                 },
5331                 INTERNAL,
5332                 { },
5333                 { { 0, 1 } },
5334         },
5335         {
5336                 "JMP_JA: Jump, gap, jump, ...",
5337                 { },
5338                 CLASSIC | FLAG_NO_DATA,
5339                 { },
5340                 { { 0, 0xababcbac } },
5341                 .fill_helper = bpf_fill_ja,
5342         },
5343         {       /* Mainly checking JIT here. */
5344                 "BPF_MAXINSNS: Maximum possible literals",
5345                 { },
5346                 CLASSIC | FLAG_NO_DATA,
5347                 { },
5348                 { { 0, 0xffffffff } },
5349                 .fill_helper = bpf_fill_maxinsns1,
5350         },
5351         {       /* Mainly checking JIT here. */
5352                 "BPF_MAXINSNS: Single literal",
5353                 { },
5354                 CLASSIC | FLAG_NO_DATA,
5355                 { },
5356                 { { 0, 0xfefefefe } },
5357                 .fill_helper = bpf_fill_maxinsns2,
5358         },
5359         {       /* Mainly checking JIT here. */
5360                 "BPF_MAXINSNS: Run/add until end",
5361                 { },
5362                 CLASSIC | FLAG_NO_DATA,
5363                 { },
5364                 { { 0, 0x947bf368 } },
5365                 .fill_helper = bpf_fill_maxinsns3,
5366         },
5367         {
5368                 "BPF_MAXINSNS: Too many instructions",
5369                 { },
5370                 CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL,
5371                 { },
5372                 { },
5373                 .fill_helper = bpf_fill_maxinsns4,
5374                 .expected_errcode = -EINVAL,
5375         },
5376         {       /* Mainly checking JIT here. */
5377                 "BPF_MAXINSNS: Very long jump",
5378                 { },
5379                 CLASSIC | FLAG_NO_DATA,
5380                 { },
5381                 { { 0, 0xabababab } },
5382                 .fill_helper = bpf_fill_maxinsns5,
5383         },
5384         {       /* Mainly checking JIT here. */
5385                 "BPF_MAXINSNS: Ctx heavy transformations",
5386                 { },
5387                 CLASSIC,
5388                 { },
5389                 {
5390                         {  1, !!(SKB_VLAN_TCI & VLAN_TAG_PRESENT) },
5391                         { 10, !!(SKB_VLAN_TCI & VLAN_TAG_PRESENT) }
5392                 },
5393                 .fill_helper = bpf_fill_maxinsns6,
5394         },
5395         {       /* Mainly checking JIT here. */
5396                 "BPF_MAXINSNS: Call heavy transformations",
5397                 { },
5398                 CLASSIC | FLAG_NO_DATA,
5399                 { },
5400                 { { 1, 0 }, { 10, 0 } },
5401                 .fill_helper = bpf_fill_maxinsns7,
5402         },
5403         {       /* Mainly checking JIT here. */
5404                 "BPF_MAXINSNS: Jump heavy test",
5405                 { },
5406                 CLASSIC | FLAG_NO_DATA,
5407                 { },
5408                 { { 0, 0xffffffff } },
5409                 .fill_helper = bpf_fill_maxinsns8,
5410         },
5411         {       /* Mainly checking JIT here. */
5412                 "BPF_MAXINSNS: Very long jump backwards",
5413                 { },
5414                 INTERNAL | FLAG_NO_DATA,
5415                 { },
5416                 { { 0, 0xcbababab } },
5417                 .fill_helper = bpf_fill_maxinsns9,
5418         },
5419         {       /* Mainly checking JIT here. */
5420                 "BPF_MAXINSNS: Edge hopping nuthouse",
5421                 { },
5422                 INTERNAL | FLAG_NO_DATA,
5423                 { },
5424                 { { 0, 0xabababac } },
5425                 .fill_helper = bpf_fill_maxinsns10,
5426         },
5427         {
5428                 "BPF_MAXINSNS: Jump, gap, jump, ...",
5429                 { },
5430 #ifdef CONFIG_BPF_JIT_ALWAYS_ON
5431                 CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL,
5432 #else
5433                 CLASSIC | FLAG_NO_DATA,
5434 #endif
5435                 { },
5436                 { { 0, 0xababcbac } },
5437                 .fill_helper = bpf_fill_maxinsns11,
5438                 .expected_errcode = -ENOTSUPP,
5439         },
5440         {
5441                 "BPF_MAXINSNS: ld_abs+get_processor_id",
5442                 { },
5443                 CLASSIC,
5444                 { },
5445                 { { 1, 0xbee } },
5446                 .fill_helper = bpf_fill_ld_abs_get_processor_id,
5447         },
5448         {
5449                 "BPF_MAXINSNS: ld_abs+vlan_push/pop",
5450                 { },
5451                 INTERNAL,
5452                 { 0x34 },
5453                 { { ETH_HLEN, 0xbef } },
5454                 .fill_helper = bpf_fill_ld_abs_vlan_push_pop,
5455         },
5456         {
5457                 "BPF_MAXINSNS: jump around ld_abs",
5458                 { },
5459                 INTERNAL,
5460                 { 10, 11 },
5461                 { { 2, 10 } },
5462                 .fill_helper = bpf_fill_jump_around_ld_abs,
5463         },
5464         /*
5465          * LD_IND / LD_ABS on fragmented SKBs
5466          */
5467         {
5468                 "LD_IND byte frag",
5469                 .u.insns = {
5470                         BPF_STMT(BPF_LDX | BPF_IMM, 0x40),
5471                         BPF_STMT(BPF_LD | BPF_IND | BPF_B, 0x0),
5472                         BPF_STMT(BPF_RET | BPF_A, 0x0),
5473                 },
5474                 CLASSIC | FLAG_SKB_FRAG,
5475                 { },
5476                 { {0x40, 0x42} },
5477                 .frag_data = {
5478                         0x42, 0x00, 0x00, 0x00,
5479                         0x43, 0x44, 0x00, 0x00,
5480                         0x21, 0x07, 0x19, 0x83,
5481                 },
5482         },
5483         {
5484                 "LD_IND halfword frag",
5485                 .u.insns = {
5486                         BPF_STMT(BPF_LDX | BPF_IMM, 0x40),
5487                         BPF_STMT(BPF_LD | BPF_IND | BPF_H, 0x4),
5488                         BPF_STMT(BPF_RET | BPF_A, 0x0),
5489                 },
5490                 CLASSIC | FLAG_SKB_FRAG,
5491                 { },
5492                 { {0x40, 0x4344} },
5493                 .frag_data = {
5494                         0x42, 0x00, 0x00, 0x00,
5495                         0x43, 0x44, 0x00, 0x00,
5496                         0x21, 0x07, 0x19, 0x83,
5497                 },
5498         },
5499         {
5500                 "LD_IND word frag",
5501                 .u.insns = {
5502                         BPF_STMT(BPF_LDX | BPF_IMM, 0x40),
5503                         BPF_STMT(BPF_LD | BPF_IND | BPF_W, 0x8),
5504                         BPF_STMT(BPF_RET | BPF_A, 0x0),
5505                 },
5506                 CLASSIC | FLAG_SKB_FRAG,
5507                 { },
5508                 { {0x40, 0x21071983} },
5509                 .frag_data = {
5510                         0x42, 0x00, 0x00, 0x00,
5511                         0x43, 0x44, 0x00, 0x00,
5512                         0x21, 0x07, 0x19, 0x83,
5513                 },
5514         },
5515         {
5516                 "LD_IND halfword mixed head/frag",
5517                 .u.insns = {
5518                         BPF_STMT(BPF_LDX | BPF_IMM, 0x40),
5519                         BPF_STMT(BPF_LD | BPF_IND | BPF_H, -0x1),
5520                         BPF_STMT(BPF_RET | BPF_A, 0x0),
5521                 },
5522                 CLASSIC | FLAG_SKB_FRAG,
5523                 { [0x3e] = 0x25, [0x3f] = 0x05, },
5524                 { {0x40, 0x0519} },
5525                 .frag_data = { 0x19, 0x82 },
5526         },
5527         {
5528                 "LD_IND word mixed head/frag",
5529                 .u.insns = {
5530                         BPF_STMT(BPF_LDX | BPF_IMM, 0x40),
5531                         BPF_STMT(BPF_LD | BPF_IND | BPF_W, -0x2),
5532                         BPF_STMT(BPF_RET | BPF_A, 0x0),
5533                 },
5534                 CLASSIC | FLAG_SKB_FRAG,
5535                 { [0x3e] = 0x25, [0x3f] = 0x05, },
5536                 { {0x40, 0x25051982} },
5537                 .frag_data = { 0x19, 0x82 },
5538         },
5539         {
5540                 "LD_ABS byte frag",
5541                 .u.insns = {
5542                         BPF_STMT(BPF_LD | BPF_ABS | BPF_B, 0x40),
5543                         BPF_STMT(BPF_RET | BPF_A, 0x0),
5544                 },
5545                 CLASSIC | FLAG_SKB_FRAG,
5546                 { },
5547                 { {0x40, 0x42} },
5548                 .frag_data = {
5549                         0x42, 0x00, 0x00, 0x00,
5550                         0x43, 0x44, 0x00, 0x00,
5551                         0x21, 0x07, 0x19, 0x83,
5552                 },
5553         },
5554         {
5555                 "LD_ABS halfword frag",
5556                 .u.insns = {
5557                         BPF_STMT(BPF_LD | BPF_ABS | BPF_H, 0x44),
5558                         BPF_STMT(BPF_RET | BPF_A, 0x0),
5559                 },
5560                 CLASSIC | FLAG_SKB_FRAG,
5561                 { },
5562                 { {0x40, 0x4344} },
5563                 .frag_data = {
5564                         0x42, 0x00, 0x00, 0x00,
5565                         0x43, 0x44, 0x00, 0x00,
5566                         0x21, 0x07, 0x19, 0x83,
5567                 },
5568         },
5569         {
5570                 "LD_ABS word frag",
5571                 .u.insns = {
5572                         BPF_STMT(BPF_LD | BPF_ABS | BPF_W, 0x48),
5573                         BPF_STMT(BPF_RET | BPF_A, 0x0),
5574                 },
5575                 CLASSIC | FLAG_SKB_FRAG,
5576                 { },
5577                 { {0x40, 0x21071983} },
5578                 .frag_data = {
5579                         0x42, 0x00, 0x00, 0x00,
5580                         0x43, 0x44, 0x00, 0x00,
5581                         0x21, 0x07, 0x19, 0x83,
5582                 },
5583         },
5584         {
5585                 "LD_ABS halfword mixed head/frag",
5586                 .u.insns = {
5587                         BPF_STMT(BPF_LD | BPF_ABS | BPF_H, 0x3f),
5588                         BPF_STMT(BPF_RET | BPF_A, 0x0),
5589                 },
5590                 CLASSIC | FLAG_SKB_FRAG,
5591                 { [0x3e] = 0x25, [0x3f] = 0x05, },
5592                 { {0x40, 0x0519} },
5593                 .frag_data = { 0x19, 0x82 },
5594         },
5595         {
5596                 "LD_ABS word mixed head/frag",
5597                 .u.insns = {
5598                         BPF_STMT(BPF_LD | BPF_ABS | BPF_W, 0x3e),
5599                         BPF_STMT(BPF_RET | BPF_A, 0x0),
5600                 },
5601                 CLASSIC | FLAG_SKB_FRAG,
5602                 { [0x3e] = 0x25, [0x3f] = 0x05, },
5603                 { {0x40, 0x25051982} },
5604                 .frag_data = { 0x19, 0x82 },
5605         },
5606         /*
5607          * LD_IND / LD_ABS on non fragmented SKBs
5608          */
5609         {
5610                 /*
5611                  * this tests that the JIT/interpreter correctly resets X
5612                  * before using it in an LD_IND instruction.
5613                  */
5614                 "LD_IND byte default X",
5615                 .u.insns = {
5616                         BPF_STMT(BPF_LD | BPF_IND | BPF_B, 0x1),
5617                         BPF_STMT(BPF_RET | BPF_A, 0x0),
5618                 },
5619                 CLASSIC,
5620                 { [0x1] = 0x42 },
5621                 { {0x40, 0x42 } },
5622         },
5623         {
5624                 "LD_IND byte positive offset",
5625                 .u.insns = {
5626                         BPF_STMT(BPF_LDX | BPF_IMM, 0x3e),
5627                         BPF_STMT(BPF_LD | BPF_IND | BPF_B, 0x1),
5628                         BPF_STMT(BPF_RET | BPF_A, 0x0),
5629                 },
5630                 CLASSIC,
5631                 { [0x3c] = 0x25, [0x3d] = 0x05,  [0x3e] = 0x19, [0x3f] = 0x82 },
5632                 { {0x40, 0x82 } },
5633         },
5634         {
5635                 "LD_IND byte negative offset",
5636                 .u.insns = {
5637                         BPF_STMT(BPF_LDX | BPF_IMM, 0x3e),
5638                         BPF_STMT(BPF_LD | BPF_IND | BPF_B, -0x1),
5639                         BPF_STMT(BPF_RET | BPF_A, 0x0),
5640                 },
5641                 CLASSIC,
5642                 { [0x3c] = 0x25, [0x3d] = 0x05,  [0x3e] = 0x19, [0x3f] = 0x82 },
5643                 { {0x40, 0x05 } },
5644         },
5645         {
5646                 "LD_IND halfword positive offset",
5647                 .u.insns = {
5648                         BPF_STMT(BPF_LDX | BPF_IMM, 0x20),
5649                         BPF_STMT(BPF_LD | BPF_IND | BPF_H, 0x2),
5650                         BPF_STMT(BPF_RET | BPF_A, 0x0),
5651                 },
5652                 CLASSIC,
5653                 {
5654                         [0x1c] = 0xaa, [0x1d] = 0x55,
5655                         [0x1e] = 0xbb, [0x1f] = 0x66,
5656                         [0x20] = 0xcc, [0x21] = 0x77,
5657                         [0x22] = 0xdd, [0x23] = 0x88,
5658                 },
5659                 { {0x40, 0xdd88 } },
5660         },
5661         {
5662                 "LD_IND halfword negative offset",
5663                 .u.insns = {
5664                         BPF_STMT(BPF_LDX | BPF_IMM, 0x20),
5665                         BPF_STMT(BPF_LD | BPF_IND | BPF_H, -0x2),
5666                         BPF_STMT(BPF_RET | BPF_A, 0x0),
5667                 },
5668                 CLASSIC,
5669                 {
5670                         [0x1c] = 0xaa, [0x1d] = 0x55,
5671                         [0x1e] = 0xbb, [0x1f] = 0x66,
5672                         [0x20] = 0xcc, [0x21] = 0x77,
5673                         [0x22] = 0xdd, [0x23] = 0x88,
5674                 },
5675                 { {0x40, 0xbb66 } },
5676         },
5677         {
5678                 "LD_IND halfword unaligned",
5679                 .u.insns = {
5680                         BPF_STMT(BPF_LDX | BPF_IMM, 0x20),
5681                         BPF_STMT(BPF_LD | BPF_IND | BPF_H, -0x1),
5682                         BPF_STMT(BPF_RET | BPF_A, 0x0),
5683                 },
5684                 CLASSIC,
5685                 {
5686                         [0x1c] = 0xaa, [0x1d] = 0x55,
5687                         [0x1e] = 0xbb, [0x1f] = 0x66,
5688                         [0x20] = 0xcc, [0x21] = 0x77,
5689                         [0x22] = 0xdd, [0x23] = 0x88,
5690                 },
5691                 { {0x40, 0x66cc } },
5692         },
5693         {
5694                 "LD_IND word positive offset",
5695                 .u.insns = {
5696                         BPF_STMT(BPF_LDX | BPF_IMM, 0x20),
5697                         BPF_STMT(BPF_LD | BPF_IND | BPF_W, 0x4),
5698                         BPF_STMT(BPF_RET | BPF_A, 0x0),
5699                 },
5700                 CLASSIC,
5701                 {
5702                         [0x1c] = 0xaa, [0x1d] = 0x55,
5703                         [0x1e] = 0xbb, [0x1f] = 0x66,
5704                         [0x20] = 0xcc, [0x21] = 0x77,
5705                         [0x22] = 0xdd, [0x23] = 0x88,
5706                         [0x24] = 0xee, [0x25] = 0x99,
5707                         [0x26] = 0xff, [0x27] = 0xaa,
5708                 },
5709                 { {0x40, 0xee99ffaa } },
5710         },
5711         {
5712                 "LD_IND word negative offset",
5713                 .u.insns = {
5714                         BPF_STMT(BPF_LDX | BPF_IMM, 0x20),
5715                         BPF_STMT(BPF_LD | BPF_IND | BPF_W, -0x4),
5716                         BPF_STMT(BPF_RET | BPF_A, 0x0),
5717                 },
5718                 CLASSIC,
5719                 {
5720                         [0x1c] = 0xaa, [0x1d] = 0x55,
5721                         [0x1e] = 0xbb, [0x1f] = 0x66,
5722                         [0x20] = 0xcc, [0x21] = 0x77,
5723                         [0x22] = 0xdd, [0x23] = 0x88,
5724                         [0x24] = 0xee, [0x25] = 0x99,
5725                         [0x26] = 0xff, [0x27] = 0xaa,
5726                 },
5727                 { {0x40, 0xaa55bb66 } },
5728         },
5729         {
5730                 "LD_IND word unaligned (addr & 3 == 2)",
5731                 .u.insns = {
5732                         BPF_STMT(BPF_LDX | BPF_IMM, 0x20),
5733                         BPF_STMT(BPF_LD | BPF_IND | BPF_W, -0x2),
5734                         BPF_STMT(BPF_RET | BPF_A, 0x0),
5735                 },
5736                 CLASSIC,
5737                 {
5738                         [0x1c] = 0xaa, [0x1d] = 0x55,
5739                         [0x1e] = 0xbb, [0x1f] = 0x66,
5740                         [0x20] = 0xcc, [0x21] = 0x77,
5741                         [0x22] = 0xdd, [0x23] = 0x88,
5742                         [0x24] = 0xee, [0x25] = 0x99,
5743                         [0x26] = 0xff, [0x27] = 0xaa,
5744                 },
5745                 { {0x40, 0xbb66cc77 } },
5746         },
5747         {
5748                 "LD_IND word unaligned (addr & 3 == 1)",
5749                 .u.insns = {
5750                         BPF_STMT(BPF_LDX | BPF_IMM, 0x20),
5751                         BPF_STMT(BPF_LD | BPF_IND | BPF_W, -0x3),
5752                         BPF_STMT(BPF_RET | BPF_A, 0x0),
5753                 },
5754                 CLASSIC,
5755                 {
5756                         [0x1c] = 0xaa, [0x1d] = 0x55,
5757                         [0x1e] = 0xbb, [0x1f] = 0x66,
5758                         [0x20] = 0xcc, [0x21] = 0x77,
5759                         [0x22] = 0xdd, [0x23] = 0x88,
5760                         [0x24] = 0xee, [0x25] = 0x99,
5761                         [0x26] = 0xff, [0x27] = 0xaa,
5762                 },
5763                 { {0x40, 0x55bb66cc } },
5764         },
5765         {
5766                 "LD_IND word unaligned (addr & 3 == 3)",
5767                 .u.insns = {
5768                         BPF_STMT(BPF_LDX | BPF_IMM, 0x20),
5769                         BPF_STMT(BPF_LD | BPF_IND | BPF_W, -0x1),
5770                         BPF_STMT(BPF_RET | BPF_A, 0x0),
5771                 },
5772                 CLASSIC,
5773                 {
5774                         [0x1c] = 0xaa, [0x1d] = 0x55,
5775                         [0x1e] = 0xbb, [0x1f] = 0x66,
5776                         [0x20] = 0xcc, [0x21] = 0x77,
5777                         [0x22] = 0xdd, [0x23] = 0x88,
5778                         [0x24] = 0xee, [0x25] = 0x99,
5779                         [0x26] = 0xff, [0x27] = 0xaa,
5780                 },
5781                 { {0x40, 0x66cc77dd } },
5782         },
5783         {
5784                 "LD_ABS byte",
5785                 .u.insns = {
5786                         BPF_STMT(BPF_LD | BPF_ABS | BPF_B, 0x20),
5787                         BPF_STMT(BPF_RET | BPF_A, 0x0),
5788                 },
5789                 CLASSIC,
5790                 {
5791                         [0x1c] = 0xaa, [0x1d] = 0x55,
5792                         [0x1e] = 0xbb, [0x1f] = 0x66,
5793                         [0x20] = 0xcc, [0x21] = 0x77,
5794                         [0x22] = 0xdd, [0x23] = 0x88,
5795                         [0x24] = 0xee, [0x25] = 0x99,
5796                         [0x26] = 0xff, [0x27] = 0xaa,
5797                 },
5798                 { {0x40, 0xcc } },
5799         },
5800         {
5801                 "LD_ABS halfword",
5802                 .u.insns = {
5803                         BPF_STMT(BPF_LD | BPF_ABS | BPF_H, 0x22),
5804                         BPF_STMT(BPF_RET | BPF_A, 0x0),
5805                 },
5806                 CLASSIC,
5807                 {
5808                         [0x1c] = 0xaa, [0x1d] = 0x55,
5809                         [0x1e] = 0xbb, [0x1f] = 0x66,
5810                         [0x20] = 0xcc, [0x21] = 0x77,
5811                         [0x22] = 0xdd, [0x23] = 0x88,
5812                         [0x24] = 0xee, [0x25] = 0x99,
5813                         [0x26] = 0xff, [0x27] = 0xaa,
5814                 },
5815                 { {0x40, 0xdd88 } },
5816         },
5817         {
5818                 "LD_ABS halfword unaligned",
5819                 .u.insns = {
5820                         BPF_STMT(BPF_LD | BPF_ABS | BPF_H, 0x25),
5821                         BPF_STMT(BPF_RET | BPF_A, 0x0),
5822                 },
5823                 CLASSIC,
5824                 {
5825                         [0x1c] = 0xaa, [0x1d] = 0x55,
5826                         [0x1e] = 0xbb, [0x1f] = 0x66,
5827                         [0x20] = 0xcc, [0x21] = 0x77,
5828                         [0x22] = 0xdd, [0x23] = 0x88,
5829                         [0x24] = 0xee, [0x25] = 0x99,
5830                         [0x26] = 0xff, [0x27] = 0xaa,
5831                 },
5832                 { {0x40, 0x99ff } },
5833         },
5834         {
5835                 "LD_ABS word",
5836                 .u.insns = {
5837                         BPF_STMT(BPF_LD | BPF_ABS | BPF_W, 0x1c),
5838                         BPF_STMT(BPF_RET | BPF_A, 0x0),
5839                 },
5840                 CLASSIC,
5841                 {
5842                         [0x1c] = 0xaa, [0x1d] = 0x55,
5843                         [0x1e] = 0xbb, [0x1f] = 0x66,
5844                         [0x20] = 0xcc, [0x21] = 0x77,
5845                         [0x22] = 0xdd, [0x23] = 0x88,
5846                         [0x24] = 0xee, [0x25] = 0x99,
5847                         [0x26] = 0xff, [0x27] = 0xaa,
5848                 },
5849                 { {0x40, 0xaa55bb66 } },
5850         },
5851         {
5852                 "LD_ABS word unaligned (addr & 3 == 2)",
5853                 .u.insns = {
5854                         BPF_STMT(BPF_LD | BPF_ABS | BPF_W, 0x22),
5855                         BPF_STMT(BPF_RET | BPF_A, 0x0),
5856                 },
5857                 CLASSIC,
5858                 {
5859                         [0x1c] = 0xaa, [0x1d] = 0x55,
5860                         [0x1e] = 0xbb, [0x1f] = 0x66,
5861                         [0x20] = 0xcc, [0x21] = 0x77,
5862                         [0x22] = 0xdd, [0x23] = 0x88,
5863                         [0x24] = 0xee, [0x25] = 0x99,
5864                         [0x26] = 0xff, [0x27] = 0xaa,
5865                 },
5866                 { {0x40, 0xdd88ee99 } },
5867         },
5868         {
5869                 "LD_ABS word unaligned (addr & 3 == 1)",
5870                 .u.insns = {
5871                         BPF_STMT(BPF_LD | BPF_ABS | BPF_W, 0x21),
5872                         BPF_STMT(BPF_RET | BPF_A, 0x0),
5873                 },
5874                 CLASSIC,
5875                 {
5876                         [0x1c] = 0xaa, [0x1d] = 0x55,
5877                         [0x1e] = 0xbb, [0x1f] = 0x66,
5878                         [0x20] = 0xcc, [0x21] = 0x77,
5879                         [0x22] = 0xdd, [0x23] = 0x88,
5880                         [0x24] = 0xee, [0x25] = 0x99,
5881                         [0x26] = 0xff, [0x27] = 0xaa,
5882                 },
5883                 { {0x40, 0x77dd88ee } },
5884         },
5885         {
5886                 "LD_ABS word unaligned (addr & 3 == 3)",
5887                 .u.insns = {
5888                         BPF_STMT(BPF_LD | BPF_ABS | BPF_W, 0x23),
5889                         BPF_STMT(BPF_RET | BPF_A, 0x0),
5890                 },
5891                 CLASSIC,
5892                 {
5893                         [0x1c] = 0xaa, [0x1d] = 0x55,
5894                         [0x1e] = 0xbb, [0x1f] = 0x66,
5895                         [0x20] = 0xcc, [0x21] = 0x77,
5896                         [0x22] = 0xdd, [0x23] = 0x88,
5897                         [0x24] = 0xee, [0x25] = 0x99,
5898                         [0x26] = 0xff, [0x27] = 0xaa,
5899                 },
5900                 { {0x40, 0x88ee99ff } },
5901         },
5902         /*
5903          * verify that the interpreter or JIT correctly sets A and X
5904          * to 0.
5905          */
5906         {
5907                 "ADD default X",
5908                 .u.insns = {
5909                         /*
5910                          * A = 0x42
5911                          * A = A + X
5912                          * ret A
5913                          */
5914                         BPF_STMT(BPF_LD | BPF_IMM, 0x42),
5915                         BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
5916                         BPF_STMT(BPF_RET | BPF_A, 0x0),
5917                 },
5918                 CLASSIC | FLAG_NO_DATA,
5919                 {},
5920                 { {0x1, 0x42 } },
5921         },
5922         {
5923                 "ADD default A",
5924                 .u.insns = {
5925                         /*
5926                          * A = A + 0x42
5927                          * ret A
5928                          */
5929                         BPF_STMT(BPF_ALU | BPF_ADD | BPF_K, 0x42),
5930                         BPF_STMT(BPF_RET | BPF_A, 0x0),
5931                 },
5932                 CLASSIC | FLAG_NO_DATA,
5933                 {},
5934                 { {0x1, 0x42 } },
5935         },
5936         {
5937                 "SUB default X",
5938                 .u.insns = {
5939                         /*
5940                          * A = 0x66
5941                          * A = A - X
5942                          * ret A
5943                          */
5944                         BPF_STMT(BPF_LD | BPF_IMM, 0x66),
5945                         BPF_STMT(BPF_ALU | BPF_SUB | BPF_X, 0),
5946                         BPF_STMT(BPF_RET | BPF_A, 0x0),
5947                 },
5948                 CLASSIC | FLAG_NO_DATA,
5949                 {},
5950                 { {0x1, 0x66 } },
5951         },
5952         {
5953                 "SUB default A",
5954                 .u.insns = {
5955                         /*
5956                          * A = A - -0x66
5957                          * ret A
5958                          */
5959                         BPF_STMT(BPF_ALU | BPF_SUB | BPF_K, -0x66),
5960                         BPF_STMT(BPF_RET | BPF_A, 0x0),
5961                 },
5962                 CLASSIC | FLAG_NO_DATA,
5963                 {},
5964                 { {0x1, 0x66 } },
5965         },
5966         {
5967                 "MUL default X",
5968                 .u.insns = {
5969                         /*
5970                          * A = 0x42
5971                          * A = A * X
5972                          * ret A
5973                          */
5974                         BPF_STMT(BPF_LD | BPF_IMM, 0x42),
5975                         BPF_STMT(BPF_ALU | BPF_MUL | BPF_X, 0),
5976                         BPF_STMT(BPF_RET | BPF_A, 0x0),
5977                 },
5978                 CLASSIC | FLAG_NO_DATA,
5979                 {},
5980                 { {0x1, 0x0 } },
5981         },
5982         {
5983                 "MUL default A",
5984                 .u.insns = {
5985                         /*
5986                          * A = A * 0x66
5987                          * ret A
5988                          */
5989                         BPF_STMT(BPF_ALU | BPF_MUL | BPF_K, 0x66),
5990                         BPF_STMT(BPF_RET | BPF_A, 0x0),
5991                 },
5992                 CLASSIC | FLAG_NO_DATA,
5993                 {},
5994                 { {0x1, 0x0 } },
5995         },
5996         {
5997                 "DIV default X",
5998                 .u.insns = {
5999                         /*
6000                          * A = 0x42
6001                          * A = A / X ; this halt the filter execution if X is 0
6002                          * ret 0x42
6003                          */
6004                         BPF_STMT(BPF_LD | BPF_IMM, 0x42),
6005                         BPF_STMT(BPF_ALU | BPF_DIV | BPF_X, 0),
6006                         BPF_STMT(BPF_RET | BPF_K, 0x42),
6007                 },
6008                 CLASSIC | FLAG_NO_DATA,
6009                 {},
6010                 { {0x1, 0x0 } },
6011         },
6012         {
6013                 "DIV default A",
6014                 .u.insns = {
6015                         /*
6016                          * A = A / 1
6017                          * ret A
6018                          */
6019                         BPF_STMT(BPF_ALU | BPF_DIV | BPF_K, 0x1),
6020                         BPF_STMT(BPF_RET | BPF_A, 0x0),
6021                 },
6022                 CLASSIC | FLAG_NO_DATA,
6023                 {},
6024                 { {0x1, 0x0 } },
6025         },
6026         {
6027                 "MOD default X",
6028                 .u.insns = {
6029                         /*
6030                          * A = 0x42
6031                          * A = A mod X ; this halt the filter execution if X is 0
6032                          * ret 0x42
6033                          */
6034                         BPF_STMT(BPF_LD | BPF_IMM, 0x42),
6035                         BPF_STMT(BPF_ALU | BPF_MOD | BPF_X, 0),
6036                         BPF_STMT(BPF_RET | BPF_K, 0x42),
6037                 },
6038                 CLASSIC | FLAG_NO_DATA,
6039                 {},
6040                 { {0x1, 0x0 } },
6041         },
6042         {
6043                 "MOD default A",
6044                 .u.insns = {
6045                         /*
6046                          * A = A mod 1
6047                          * ret A
6048                          */
6049                         BPF_STMT(BPF_ALU | BPF_MOD | BPF_K, 0x1),
6050                         BPF_STMT(BPF_RET | BPF_A, 0x0),
6051                 },
6052                 CLASSIC | FLAG_NO_DATA,
6053                 {},
6054                 { {0x1, 0x0 } },
6055         },
6056         {
6057                 "JMP EQ default A",
6058                 .u.insns = {
6059                         /*
6060                          * cmp A, 0x0, 0, 1
6061                          * ret 0x42
6062                          * ret 0x66
6063                          */
6064                         BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x0, 0, 1),
6065                         BPF_STMT(BPF_RET | BPF_K, 0x42),
6066                         BPF_STMT(BPF_RET | BPF_K, 0x66),
6067                 },
6068                 CLASSIC | FLAG_NO_DATA,
6069                 {},
6070                 { {0x1, 0x42 } },
6071         },
6072         {
6073                 "JMP EQ default X",
6074                 .u.insns = {
6075                         /*
6076                          * A = 0x0
6077                          * cmp A, X, 0, 1
6078                          * ret 0x42
6079                          * ret 0x66
6080                          */
6081                         BPF_STMT(BPF_LD | BPF_IMM, 0x0),
6082                         BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_X, 0x0, 0, 1),
6083                         BPF_STMT(BPF_RET | BPF_K, 0x42),
6084                         BPF_STMT(BPF_RET | BPF_K, 0x66),
6085                 },
6086                 CLASSIC | FLAG_NO_DATA,
6087                 {},
6088                 { {0x1, 0x42 } },
6089         },
6090 };
6091
6092 static struct net_device dev;
6093
6094 static struct sk_buff *populate_skb(char *buf, int size)
6095 {
6096         struct sk_buff *skb;
6097
6098         if (size >= MAX_DATA)
6099                 return NULL;
6100
6101         skb = alloc_skb(MAX_DATA, GFP_KERNEL);
6102         if (!skb)
6103                 return NULL;
6104
6105         __skb_put_data(skb, buf, size);
6106
6107         /* Initialize a fake skb with test pattern. */
6108         skb_reset_mac_header(skb);
6109         skb->protocol = htons(ETH_P_IP);
6110         skb->pkt_type = SKB_TYPE;
6111         skb->mark = SKB_MARK;
6112         skb->hash = SKB_HASH;
6113         skb->queue_mapping = SKB_QUEUE_MAP;
6114         skb->vlan_tci = SKB_VLAN_TCI;
6115         skb->vlan_proto = htons(ETH_P_IP);
6116         skb->dev = &dev;
6117         skb->dev->ifindex = SKB_DEV_IFINDEX;
6118         skb->dev->type = SKB_DEV_TYPE;
6119         skb_set_network_header(skb, min(size, ETH_HLEN));
6120
6121         return skb;
6122 }
6123
6124 static void *generate_test_data(struct bpf_test *test, int sub)
6125 {
6126         struct sk_buff *skb;
6127         struct page *page;
6128
6129         if (test->aux & FLAG_NO_DATA)
6130                 return NULL;
6131
6132         /* Test case expects an skb, so populate one. Various
6133          * subtests generate skbs of different sizes based on
6134          * the same data.
6135          */
6136         skb = populate_skb(test->data, test->test[sub].data_size);
6137         if (!skb)
6138                 return NULL;
6139
6140         if (test->aux & FLAG_SKB_FRAG) {
6141                 /*
6142                  * when the test requires a fragmented skb, add a
6143                  * single fragment to the skb, filled with
6144                  * test->frag_data.
6145                  */
6146                 void *ptr;
6147
6148                 page = alloc_page(GFP_KERNEL);
6149
6150                 if (!page)
6151                         goto err_kfree_skb;
6152
6153                 ptr = kmap(page);
6154                 if (!ptr)
6155                         goto err_free_page;
6156                 memcpy(ptr, test->frag_data, MAX_DATA);
6157                 kunmap(page);
6158                 skb_add_rx_frag(skb, 0, page, 0, MAX_DATA, MAX_DATA);
6159         }
6160
6161         return skb;
6162
6163 err_free_page:
6164         __free_page(page);
6165 err_kfree_skb:
6166         kfree_skb(skb);
6167         return NULL;
6168 }
6169
6170 static void release_test_data(const struct bpf_test *test, void *data)
6171 {
6172         if (test->aux & FLAG_NO_DATA)
6173                 return;
6174
6175         kfree_skb(data);
6176 }
6177
6178 static int filter_length(int which)
6179 {
6180         struct sock_filter *fp;
6181         int len;
6182
6183         if (tests[which].fill_helper)
6184                 return tests[which].u.ptr.len;
6185
6186         fp = tests[which].u.insns;
6187         for (len = MAX_INSNS - 1; len > 0; --len)
6188                 if (fp[len].code != 0 || fp[len].k != 0)
6189                         break;
6190
6191         return len + 1;
6192 }
6193
6194 static void *filter_pointer(int which)
6195 {
6196         if (tests[which].fill_helper)
6197                 return tests[which].u.ptr.insns;
6198         else
6199                 return tests[which].u.insns;
6200 }
6201
6202 static struct bpf_prog *generate_filter(int which, int *err)
6203 {
6204         __u8 test_type = tests[which].aux & TEST_TYPE_MASK;
6205         unsigned int flen = filter_length(which);
6206         void *fptr = filter_pointer(which);
6207         struct sock_fprog_kern fprog;
6208         struct bpf_prog *fp;
6209
6210         switch (test_type) {
6211         case CLASSIC:
6212                 fprog.filter = fptr;
6213                 fprog.len = flen;
6214
6215                 *err = bpf_prog_create(&fp, &fprog);
6216                 if (tests[which].aux & FLAG_EXPECTED_FAIL) {
6217                         if (*err == tests[which].expected_errcode) {
6218                                 pr_cont("PASS\n");
6219                                 /* Verifier rejected filter as expected. */
6220                                 *err = 0;
6221                                 return NULL;
6222                         } else {
6223                                 pr_cont("UNEXPECTED_PASS\n");
6224                                 /* Verifier didn't reject the test that's
6225                                  * bad enough, just return!
6226                                  */
6227                                 *err = -EINVAL;
6228                                 return NULL;
6229                         }
6230                 }
6231                 if (*err) {
6232                         pr_cont("FAIL to prog_create err=%d len=%d\n",
6233                                 *err, fprog.len);
6234                         return NULL;
6235                 }
6236                 break;
6237
6238         case INTERNAL:
6239                 fp = bpf_prog_alloc(bpf_prog_size(flen), 0);
6240                 if (fp == NULL) {
6241                         pr_cont("UNEXPECTED_FAIL no memory left\n");
6242                         *err = -ENOMEM;
6243                         return NULL;
6244                 }
6245
6246                 fp->len = flen;
6247                 /* Type doesn't really matter here as long as it's not unspec. */
6248                 fp->type = BPF_PROG_TYPE_SOCKET_FILTER;
6249                 memcpy(fp->insnsi, fptr, fp->len * sizeof(struct bpf_insn));
6250                 fp->aux->stack_depth = tests[which].stack_depth;
6251
6252                 /* We cannot error here as we don't need type compatibility
6253                  * checks.
6254                  */
6255                 fp = bpf_prog_select_runtime(fp, err);
6256                 if (*err) {
6257                         pr_cont("FAIL to select_runtime err=%d\n", *err);
6258                         return NULL;
6259                 }
6260                 break;
6261         }
6262
6263         *err = 0;
6264         return fp;
6265 }
6266
6267 static void release_filter(struct bpf_prog *fp, int which)
6268 {
6269         __u8 test_type = tests[which].aux & TEST_TYPE_MASK;
6270
6271         switch (test_type) {
6272         case CLASSIC:
6273                 bpf_prog_destroy(fp);
6274                 break;
6275         case INTERNAL:
6276                 bpf_prog_free(fp);
6277                 break;
6278         }
6279 }
6280
6281 static int __run_one(const struct bpf_prog *fp, const void *data,
6282                      int runs, u64 *duration)
6283 {
6284         u64 start, finish;
6285         int ret = 0, i;
6286
6287         start = ktime_get_ns();
6288
6289         for (i = 0; i < runs; i++)
6290                 ret = BPF_PROG_RUN(fp, data);
6291
6292         finish = ktime_get_ns();
6293
6294         *duration = finish - start;
6295         do_div(*duration, runs);
6296
6297         return ret;
6298 }
6299
6300 static int run_one(const struct bpf_prog *fp, struct bpf_test *test)
6301 {
6302         int err_cnt = 0, i, runs = MAX_TESTRUNS;
6303
6304         for (i = 0; i < MAX_SUBTESTS; i++) {
6305                 void *data;
6306                 u64 duration;
6307                 u32 ret;
6308
6309                 if (test->test[i].data_size == 0 &&
6310                     test->test[i].result == 0)
6311                         break;
6312
6313                 data = generate_test_data(test, i);
6314                 if (!data && !(test->aux & FLAG_NO_DATA)) {
6315                         pr_cont("data generation failed ");
6316                         err_cnt++;
6317                         break;
6318                 }
6319                 ret = __run_one(fp, data, runs, &duration);
6320                 release_test_data(test, data);
6321
6322                 if (ret == test->test[i].result) {
6323                         pr_cont("%lld ", duration);
6324                 } else {
6325                         pr_cont("ret %d != %d ", ret,
6326                                 test->test[i].result);
6327                         err_cnt++;
6328                 }
6329         }
6330
6331         return err_cnt;
6332 }
6333
6334 static char test_name[64];
6335 module_param_string(test_name, test_name, sizeof(test_name), 0);
6336
6337 static int test_id = -1;
6338 module_param(test_id, int, 0);
6339
6340 static int test_range[2] = { 0, ARRAY_SIZE(tests) - 1 };
6341 module_param_array(test_range, int, NULL, 0);
6342
6343 static __init int find_test_index(const char *test_name)
6344 {
6345         int i;
6346
6347         for (i = 0; i < ARRAY_SIZE(tests); i++) {
6348                 if (!strcmp(tests[i].descr, test_name))
6349                         return i;
6350         }
6351         return -1;
6352 }
6353
6354 static __init int prepare_bpf_tests(void)
6355 {
6356         int i;
6357
6358         if (test_id >= 0) {
6359                 /*
6360                  * if a test_id was specified, use test_range to
6361                  * cover only that test.
6362                  */
6363                 if (test_id >= ARRAY_SIZE(tests)) {
6364                         pr_err("test_bpf: invalid test_id specified.\n");
6365                         return -EINVAL;
6366                 }
6367
6368                 test_range[0] = test_id;
6369                 test_range[1] = test_id;
6370         } else if (*test_name) {
6371                 /*
6372                  * if a test_name was specified, find it and setup
6373                  * test_range to cover only that test.
6374                  */
6375                 int idx = find_test_index(test_name);
6376
6377                 if (idx < 0) {
6378                         pr_err("test_bpf: no test named '%s' found.\n",
6379                                test_name);
6380                         return -EINVAL;
6381                 }
6382                 test_range[0] = idx;
6383                 test_range[1] = idx;
6384         } else {
6385                 /*
6386                  * check that the supplied test_range is valid.
6387                  */
6388                 if (test_range[0] >= ARRAY_SIZE(tests) ||
6389                     test_range[1] >= ARRAY_SIZE(tests) ||
6390                     test_range[0] < 0 || test_range[1] < 0) {
6391                         pr_err("test_bpf: test_range is out of bound.\n");
6392                         return -EINVAL;
6393                 }
6394
6395                 if (test_range[1] < test_range[0]) {
6396                         pr_err("test_bpf: test_range is ending before it starts.\n");
6397                         return -EINVAL;
6398                 }
6399         }
6400
6401         for (i = 0; i < ARRAY_SIZE(tests); i++) {
6402                 if (tests[i].fill_helper &&
6403                     tests[i].fill_helper(&tests[i]) < 0)
6404                         return -ENOMEM;
6405         }
6406
6407         return 0;
6408 }
6409
6410 static __init void destroy_bpf_tests(void)
6411 {
6412         int i;
6413
6414         for (i = 0; i < ARRAY_SIZE(tests); i++) {
6415                 if (tests[i].fill_helper)
6416                         kfree(tests[i].u.ptr.insns);
6417         }
6418 }
6419
6420 static bool exclude_test(int test_id)
6421 {
6422         return test_id < test_range[0] || test_id > test_range[1];
6423 }
6424
6425 static __init int test_bpf(void)
6426 {
6427         int i, err_cnt = 0, pass_cnt = 0;
6428         int jit_cnt = 0, run_cnt = 0;
6429
6430         for (i = 0; i < ARRAY_SIZE(tests); i++) {
6431                 struct bpf_prog *fp;
6432                 int err;
6433
6434                 if (exclude_test(i))
6435                         continue;
6436
6437                 pr_info("#%d %s ", i, tests[i].descr);
6438
6439                 fp = generate_filter(i, &err);
6440                 if (fp == NULL) {
6441                         if (err == 0) {
6442                                 pass_cnt++;
6443                                 continue;
6444                         }
6445                         err_cnt++;
6446                         continue;
6447                 }
6448
6449                 pr_cont("jited:%u ", fp->jited);
6450
6451                 run_cnt++;
6452                 if (fp->jited)
6453                         jit_cnt++;
6454
6455                 err = run_one(fp, &tests[i]);
6456                 release_filter(fp, i);
6457
6458                 if (err) {
6459                         pr_cont("FAIL (%d times)\n", err);
6460                         err_cnt++;
6461                 } else {
6462                         pr_cont("PASS\n");
6463                         pass_cnt++;
6464                 }
6465         }
6466
6467         pr_info("Summary: %d PASSED, %d FAILED, [%d/%d JIT'ed]\n",
6468                 pass_cnt, err_cnt, jit_cnt, run_cnt);
6469
6470         return err_cnt ? -EINVAL : 0;
6471 }
6472
6473 static int __init test_bpf_init(void)
6474 {
6475         int ret;
6476
6477         ret = prepare_bpf_tests();
6478         if (ret < 0)
6479                 return ret;
6480
6481         ret = test_bpf();
6482
6483         destroy_bpf_tests();
6484         return ret;
6485 }
6486
6487 static void __exit test_bpf_exit(void)
6488 {
6489 }
6490
6491 module_init(test_bpf_init);
6492 module_exit(test_bpf_exit);
6493
6494 MODULE_LICENSE("GPL");