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