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