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