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