1 {
2 	"jset32: BPF_K",
3 	.insns = {
4 	BPF_DIRECT_PKT_R2,
5 	BPF_LDX_MEM(BPF_DW, BPF_REG_7, BPF_REG_2, 0),
6 	/* reg, high bits shouldn't be tested */
7 	BPF_JMP32_IMM(BPF_JSET, BPF_REG_7, -2, 1),
8 	BPF_JMP_IMM(BPF_JA, 0, 0, 1),
9 	BPF_EXIT_INSN(),
10 
11 	BPF_JMP32_IMM(BPF_JSET, BPF_REG_7, 1, 1),
12 	BPF_EXIT_INSN(),
13 	BPF_MOV64_IMM(BPF_REG_0, 2),
14 	BPF_EXIT_INSN(),
15 	},
16 	.prog_type = BPF_PROG_TYPE_SCHED_CLS,
17 	.result = ACCEPT,
18 	.runs = 3,
19 	.retvals = {
20 		{ .retval = 0,
21 		  .data64 = { 1ULL << 63, }
22 		},
23 		{ .retval = 2,
24 		  .data64 = { 1, }
25 		},
26 		{ .retval = 2,
27 		  .data64 = { 1ULL << 63 | 1, }
28 		},
29 	},
30 	.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
31 },
32 {
33 	"jset32: BPF_X",
34 	.insns = {
35 	BPF_DIRECT_PKT_R2,
36 	BPF_LDX_MEM(BPF_DW, BPF_REG_7, BPF_REG_2, 0),
37 	BPF_LD_IMM64(BPF_REG_8, 0x8000000000000000),
38 	BPF_JMP32_REG(BPF_JSET, BPF_REG_7, BPF_REG_8, 1),
39 	BPF_JMP_IMM(BPF_JA, 0, 0, 1),
40 	BPF_EXIT_INSN(),
41 
42 	BPF_LD_IMM64(BPF_REG_8, 0x8000000000000001),
43 	BPF_JMP32_REG(BPF_JSET, BPF_REG_7, BPF_REG_8, 1),
44 	BPF_EXIT_INSN(),
45 	BPF_MOV64_IMM(BPF_REG_0, 2),
46 	BPF_EXIT_INSN(),
47 	},
48 	.prog_type = BPF_PROG_TYPE_SCHED_CLS,
49 	.result = ACCEPT,
50 	.runs = 3,
51 	.retvals = {
52 		{ .retval = 0,
53 		  .data64 = { 1ULL << 63, }
54 		},
55 		{ .retval = 2,
56 		  .data64 = { 1, }
57 		},
58 		{ .retval = 2,
59 		  .data64 = { 1ULL << 63 | 1, }
60 		},
61 	},
62 	.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
63 },
64 {
65 	"jset32: ignores upper bits",
66 	.insns = {
67 	BPF_MOV64_IMM(BPF_REG_0, 0),
68 	BPF_LD_IMM64(BPF_REG_7, 0x8000000000000000),
69 	BPF_LD_IMM64(BPF_REG_8, 0x8000000000000000),
70 	BPF_JMP_REG(BPF_JSET, BPF_REG_7, BPF_REG_8, 1),
71 	BPF_EXIT_INSN(),
72 	BPF_JMP32_REG(BPF_JSET, BPF_REG_7, BPF_REG_8, 1),
73 	BPF_MOV64_IMM(BPF_REG_0, 2),
74 	BPF_EXIT_INSN(),
75 	},
76 	.result = ACCEPT,
77 	.retval = 2,
78 },
79 {
80 	"jset32: min/max deduction",
81 	.insns = {
82 	BPF_RAND_UEXT_R7,
83 	BPF_MOV64_IMM(BPF_REG_0, 0),
84 	BPF_JMP32_IMM(BPF_JSET, BPF_REG_7, 0x10, 1),
85 	BPF_EXIT_INSN(),
86 	BPF_JMP32_IMM(BPF_JGE, BPF_REG_7, 0x10, 1),
87 	BPF_LDX_MEM(BPF_B, BPF_REG_8, BPF_REG_9, 0),
88 	BPF_EXIT_INSN(),
89 	},
90 	.result = ACCEPT,
91 },
92 {
93 	"jeq32: BPF_K",
94 	.insns = {
95 	BPF_DIRECT_PKT_R2,
96 	BPF_LDX_MEM(BPF_DW, BPF_REG_7, BPF_REG_2, 0),
97 	BPF_JMP32_IMM(BPF_JEQ, BPF_REG_7, -1, 1),
98 	BPF_EXIT_INSN(),
99 	BPF_MOV64_IMM(BPF_REG_0, 2),
100 	BPF_EXIT_INSN(),
101 	},
102 	.prog_type = BPF_PROG_TYPE_SCHED_CLS,
103 	.result = ACCEPT,
104 	.runs = 2,
105 	.retvals = {
106 		{ .retval = 0,
107 		  .data64 = { -2, }
108 		},
109 		{ .retval = 2,
110 		  .data64 = { -1, }
111 		},
112 	},
113 	.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
114 },
115 {
116 	"jeq32: BPF_X",
117 	.insns = {
118 	BPF_DIRECT_PKT_R2,
119 	BPF_LDX_MEM(BPF_DW, BPF_REG_7, BPF_REG_2, 0),
120 	BPF_LD_IMM64(BPF_REG_8, 0x7000000000000001),
121 	BPF_JMP32_REG(BPF_JEQ, BPF_REG_7, BPF_REG_8, 1),
122 	BPF_EXIT_INSN(),
123 	BPF_MOV64_IMM(BPF_REG_0, 2),
124 	BPF_EXIT_INSN(),
125 	},
126 	.prog_type = BPF_PROG_TYPE_SCHED_CLS,
127 	.result = ACCEPT,
128 	.runs = 3,
129 	.retvals = {
130 		{ .retval = 0,
131 		  .data64 = { 2, }
132 		},
133 		{ .retval = 2,
134 		  .data64 = { 1, }
135 		},
136 		{ .retval = 2,
137 		  .data64 = { 1ULL << 63 | 1, }
138 		},
139 	},
140 	.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
141 },
142 {
143 	"jeq32: min/max deduction",
144 	.insns = {
145 	BPF_RAND_UEXT_R7,
146 	BPF_MOV64_IMM(BPF_REG_0, 0),
147 	BPF_JMP32_IMM(BPF_JEQ, BPF_REG_7, 0x10, 1),
148 	BPF_EXIT_INSN(),
149 	BPF_JMP32_IMM(BPF_JSGE, BPF_REG_7, 0xf, 1),
150 	BPF_LDX_MEM(BPF_B, BPF_REG_8, BPF_REG_9, 0),
151 	BPF_EXIT_INSN(),
152 	},
153 	.result = ACCEPT,
154 },
155 {
156 	"jne32: BPF_K",
157 	.insns = {
158 	BPF_DIRECT_PKT_R2,
159 	BPF_LDX_MEM(BPF_DW, BPF_REG_7, BPF_REG_2, 0),
160 	BPF_JMP32_IMM(BPF_JNE, BPF_REG_7, -1, 1),
161 	BPF_EXIT_INSN(),
162 	BPF_MOV64_IMM(BPF_REG_0, 2),
163 	BPF_EXIT_INSN(),
164 	},
165 	.prog_type = BPF_PROG_TYPE_SCHED_CLS,
166 	.result = ACCEPT,
167 	.runs = 2,
168 	.retvals = {
169 		{ .retval = 2,
170 		  .data64 = { 1, }
171 		},
172 		{ .retval = 0,
173 		  .data64 = { -1, }
174 		},
175 	},
176 	.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
177 },
178 {
179 	"jne32: BPF_X",
180 	.insns = {
181 	BPF_DIRECT_PKT_R2,
182 	BPF_LDX_MEM(BPF_DW, BPF_REG_7, BPF_REG_2, 0),
183 	BPF_LD_IMM64(BPF_REG_8, 0x8000000000000001),
184 	BPF_JMP32_REG(BPF_JNE, BPF_REG_7, BPF_REG_8, 1),
185 	BPF_EXIT_INSN(),
186 	BPF_MOV64_IMM(BPF_REG_0, 2),
187 	BPF_EXIT_INSN(),
188 	},
189 	.prog_type = BPF_PROG_TYPE_SCHED_CLS,
190 	.result = ACCEPT,
191 	.runs = 3,
192 	.retvals = {
193 		{ .retval = 0,
194 		  .data64 = { 1, }
195 		},
196 		{ .retval = 2,
197 		  .data64 = { 2, }
198 		},
199 		{ .retval = 2,
200 		  .data64 = { 1ULL << 63 | 2, }
201 		},
202 	},
203 	.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
204 },
205 {
206 	"jne32: min/max deduction",
207 	.insns = {
208 	BPF_RAND_UEXT_R7,
209 	BPF_MOV64_IMM(BPF_REG_0, 0),
210 	BPF_JMP32_IMM(BPF_JNE, BPF_REG_7, 0x10, 1),
211 	BPF_JMP_IMM(BPF_JNE, BPF_REG_7, 0x10, 1),
212 	BPF_EXIT_INSN(),
213 	BPF_LDX_MEM(BPF_B, BPF_REG_8, BPF_REG_9, 0),
214 	BPF_EXIT_INSN(),
215 	},
216 	.result = ACCEPT,
217 },
218 {
219 	"jge32: BPF_K",
220 	.insns = {
221 	BPF_DIRECT_PKT_R2,
222 	BPF_LDX_MEM(BPF_DW, BPF_REG_7, BPF_REG_2, 0),
223 	BPF_JMP32_IMM(BPF_JGE, BPF_REG_7, UINT_MAX - 1, 1),
224 	BPF_EXIT_INSN(),
225 	BPF_ALU32_IMM(BPF_MOV, BPF_REG_0, 2),
226 	BPF_EXIT_INSN(),
227 	},
228 	.prog_type = BPF_PROG_TYPE_SCHED_CLS,
229 	.result = ACCEPT,
230 	.runs = 3,
231 	.retvals = {
232 		{ .retval = 2,
233 		  .data64 = { UINT_MAX, }
234 		},
235 		{ .retval = 2,
236 		  .data64 = { UINT_MAX - 1, }
237 		},
238 		{ .retval = 0,
239 		  .data64 = { 0, }
240 		},
241 	},
242 	.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
243 },
244 {
245 	"jge32: BPF_X",
246 	.insns = {
247 	BPF_DIRECT_PKT_R2,
248 	BPF_LD_IMM64(BPF_REG_8, UINT_MAX | 1ULL << 32),
249 	BPF_LDX_MEM(BPF_DW, BPF_REG_7, BPF_REG_2, 0),
250 	BPF_JMP32_REG(BPF_JGE, BPF_REG_7, BPF_REG_8, 1),
251 	BPF_EXIT_INSN(),
252 	BPF_ALU32_IMM(BPF_MOV, BPF_REG_0, 2),
253 	BPF_EXIT_INSN(),
254 	},
255 	.prog_type = BPF_PROG_TYPE_SCHED_CLS,
256 	.result = ACCEPT,
257 	.runs = 3,
258 	.retvals = {
259 		{ .retval = 2,
260 		  .data64 = { UINT_MAX, }
261 		},
262 		{ .retval = 0,
263 		  .data64 = { INT_MAX, }
264 		},
265 		{ .retval = 0,
266 		  .data64 = { (UINT_MAX - 1) | 2ULL << 32, }
267 		},
268 	},
269 	.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
270 },
271 {
272 	"jge32: min/max deduction",
273 	.insns = {
274 	BPF_RAND_UEXT_R7,
275 	BPF_ALU32_IMM(BPF_MOV, BPF_REG_0, 2),
276 	BPF_LD_IMM64(BPF_REG_8, 0x7ffffff0 | 1ULL << 32),
277 	BPF_JMP32_REG(BPF_JGE, BPF_REG_7, BPF_REG_8, 1),
278 	BPF_EXIT_INSN(),
279 	BPF_JMP32_IMM(BPF_JGE, BPF_REG_7, 0x7ffffff0, 1),
280 	BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_0, 0),
281 	BPF_EXIT_INSN(),
282 	},
283 	.result = ACCEPT,
284 	.retval = 2,
285 },
286 {
287 	"jgt32: BPF_K",
288 	.insns = {
289 	BPF_DIRECT_PKT_R2,
290 	BPF_LDX_MEM(BPF_DW, BPF_REG_7, BPF_REG_2, 0),
291 	BPF_JMP32_IMM(BPF_JGT, BPF_REG_7, UINT_MAX - 1, 1),
292 	BPF_EXIT_INSN(),
293 	BPF_ALU32_IMM(BPF_MOV, BPF_REG_0, 2),
294 	BPF_EXIT_INSN(),
295 	},
296 	.prog_type = BPF_PROG_TYPE_SCHED_CLS,
297 	.result = ACCEPT,
298 	.runs = 3,
299 	.retvals = {
300 		{ .retval = 2,
301 		  .data64 = { UINT_MAX, }
302 		},
303 		{ .retval = 0,
304 		  .data64 = { UINT_MAX - 1, }
305 		},
306 		{ .retval = 0,
307 		  .data64 = { 0, }
308 		},
309 	},
310 	.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
311 },
312 {
313 	"jgt32: BPF_X",
314 	.insns = {
315 	BPF_DIRECT_PKT_R2,
316 	BPF_LD_IMM64(BPF_REG_8, (UINT_MAX - 1) | 1ULL << 32),
317 	BPF_LDX_MEM(BPF_DW, BPF_REG_7, BPF_REG_2, 0),
318 	BPF_JMP32_REG(BPF_JGT, BPF_REG_7, BPF_REG_8, 1),
319 	BPF_EXIT_INSN(),
320 	BPF_ALU32_IMM(BPF_MOV, BPF_REG_0, 2),
321 	BPF_EXIT_INSN(),
322 	},
323 	.prog_type = BPF_PROG_TYPE_SCHED_CLS,
324 	.result = ACCEPT,
325 	.runs = 3,
326 	.retvals = {
327 		{ .retval = 2,
328 		  .data64 = { UINT_MAX, }
329 		},
330 		{ .retval = 0,
331 		  .data64 = { UINT_MAX - 1, }
332 		},
333 		{ .retval = 0,
334 		  .data64 = { (UINT_MAX - 1) | 2ULL << 32, }
335 		},
336 	},
337 	.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
338 },
339 {
340 	"jgt32: min/max deduction",
341 	.insns = {
342 	BPF_RAND_UEXT_R7,
343 	BPF_ALU32_IMM(BPF_MOV, BPF_REG_0, 2),
344 	BPF_LD_IMM64(BPF_REG_8, 0x7ffffff0 | 1ULL << 32),
345 	BPF_JMP32_REG(BPF_JGT, BPF_REG_7, BPF_REG_8, 1),
346 	BPF_EXIT_INSN(),
347 	BPF_JMP_IMM(BPF_JGT, BPF_REG_7, 0x7ffffff0, 1),
348 	BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_0, 0),
349 	BPF_EXIT_INSN(),
350 	},
351 	.result = ACCEPT,
352 	.retval = 2,
353 },
354 {
355 	"jle32: BPF_K",
356 	.insns = {
357 	BPF_DIRECT_PKT_R2,
358 	BPF_LDX_MEM(BPF_DW, BPF_REG_7, BPF_REG_2, 0),
359 	BPF_JMP32_IMM(BPF_JLE, BPF_REG_7, INT_MAX, 1),
360 	BPF_EXIT_INSN(),
361 	BPF_ALU32_IMM(BPF_MOV, BPF_REG_0, 2),
362 	BPF_EXIT_INSN(),
363 	},
364 	.prog_type = BPF_PROG_TYPE_SCHED_CLS,
365 	.result = ACCEPT,
366 	.runs = 3,
367 	.retvals = {
368 		{ .retval = 2,
369 		  .data64 = { INT_MAX - 1, }
370 		},
371 		{ .retval = 0,
372 		  .data64 = { UINT_MAX, }
373 		},
374 		{ .retval = 2,
375 		  .data64 = { INT_MAX, }
376 		},
377 	},
378 	.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
379 },
380 {
381 	"jle32: BPF_X",
382 	.insns = {
383 	BPF_DIRECT_PKT_R2,
384 	BPF_LD_IMM64(BPF_REG_8, (INT_MAX - 1) | 2ULL << 32),
385 	BPF_LDX_MEM(BPF_DW, BPF_REG_7, BPF_REG_2, 0),
386 	BPF_JMP32_REG(BPF_JLE, BPF_REG_7, BPF_REG_8, 1),
387 	BPF_EXIT_INSN(),
388 	BPF_ALU32_IMM(BPF_MOV, BPF_REG_0, 2),
389 	BPF_EXIT_INSN(),
390 	},
391 	.prog_type = BPF_PROG_TYPE_SCHED_CLS,
392 	.result = ACCEPT,
393 	.runs = 3,
394 	.retvals = {
395 		{ .retval = 0,
396 		  .data64 = { INT_MAX | 1ULL << 32, }
397 		},
398 		{ .retval = 2,
399 		  .data64 = { INT_MAX - 2, }
400 		},
401 		{ .retval = 0,
402 		  .data64 = { UINT_MAX, }
403 		},
404 	},
405 	.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
406 },
407 {
408 	"jle32: min/max deduction",
409 	.insns = {
410 	BPF_RAND_UEXT_R7,
411 	BPF_ALU32_IMM(BPF_MOV, BPF_REG_0, 2),
412 	BPF_LD_IMM64(BPF_REG_8, 0x7ffffff0 | 1ULL << 32),
413 	BPF_JMP32_REG(BPF_JLE, BPF_REG_7, BPF_REG_8, 1),
414 	BPF_EXIT_INSN(),
415 	BPF_JMP32_IMM(BPF_JLE, BPF_REG_7, 0x7ffffff0, 1),
416 	BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_0, 0),
417 	BPF_EXIT_INSN(),
418 	},
419 	.result = ACCEPT,
420 	.retval = 2,
421 },
422 {
423 	"jlt32: BPF_K",
424 	.insns = {
425 	BPF_DIRECT_PKT_R2,
426 	BPF_LDX_MEM(BPF_DW, BPF_REG_7, BPF_REG_2, 0),
427 	BPF_JMP32_IMM(BPF_JLT, BPF_REG_7, INT_MAX, 1),
428 	BPF_EXIT_INSN(),
429 	BPF_ALU32_IMM(BPF_MOV, BPF_REG_0, 2),
430 	BPF_EXIT_INSN(),
431 	},
432 	.prog_type = BPF_PROG_TYPE_SCHED_CLS,
433 	.result = ACCEPT,
434 	.runs = 3,
435 	.retvals = {
436 		{ .retval = 0,
437 		  .data64 = { INT_MAX, }
438 		},
439 		{ .retval = 0,
440 		  .data64 = { UINT_MAX, }
441 		},
442 		{ .retval = 2,
443 		  .data64 = { INT_MAX - 1, }
444 		},
445 	},
446 	.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
447 },
448 {
449 	"jlt32: BPF_X",
450 	.insns = {
451 	BPF_DIRECT_PKT_R2,
452 	BPF_LD_IMM64(BPF_REG_8, INT_MAX | 2ULL << 32),
453 	BPF_LDX_MEM(BPF_DW, BPF_REG_7, BPF_REG_2, 0),
454 	BPF_JMP32_REG(BPF_JLT, BPF_REG_7, BPF_REG_8, 1),
455 	BPF_EXIT_INSN(),
456 	BPF_ALU32_IMM(BPF_MOV, BPF_REG_0, 2),
457 	BPF_EXIT_INSN(),
458 	},
459 	.prog_type = BPF_PROG_TYPE_SCHED_CLS,
460 	.result = ACCEPT,
461 	.runs = 3,
462 	.retvals = {
463 		{ .retval = 0,
464 		  .data64 = { INT_MAX | 1ULL << 32, }
465 		},
466 		{ .retval = 0,
467 		  .data64 = { UINT_MAX, }
468 		},
469 		{ .retval = 2,
470 		  .data64 = { (INT_MAX - 1) | 3ULL << 32, }
471 		},
472 	},
473 	.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
474 },
475 {
476 	"jlt32: min/max deduction",
477 	.insns = {
478 	BPF_RAND_UEXT_R7,
479 	BPF_ALU32_IMM(BPF_MOV, BPF_REG_0, 2),
480 	BPF_LD_IMM64(BPF_REG_8, 0x7ffffff0 | 1ULL << 32),
481 	BPF_JMP32_REG(BPF_JLT, BPF_REG_7, BPF_REG_8, 1),
482 	BPF_EXIT_INSN(),
483 	BPF_JMP_IMM(BPF_JSLT, BPF_REG_7, 0x7ffffff0, 1),
484 	BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_0, 0),
485 	BPF_EXIT_INSN(),
486 	},
487 	.result = ACCEPT,
488 	.retval = 2,
489 },
490 {
491 	"jsge32: BPF_K",
492 	.insns = {
493 	BPF_DIRECT_PKT_R2,
494 	BPF_LDX_MEM(BPF_DW, BPF_REG_7, BPF_REG_2, 0),
495 	BPF_JMP32_IMM(BPF_JSGE, BPF_REG_7, -1, 1),
496 	BPF_EXIT_INSN(),
497 	BPF_ALU32_IMM(BPF_MOV, BPF_REG_0, 2),
498 	BPF_EXIT_INSN(),
499 	},
500 	.prog_type = BPF_PROG_TYPE_SCHED_CLS,
501 	.result = ACCEPT,
502 	.runs = 3,
503 	.retvals = {
504 		{ .retval = 2,
505 		  .data64 = { 0, }
506 		},
507 		{ .retval = 2,
508 		  .data64 = { -1, }
509 		},
510 		{ .retval = 0,
511 		  .data64 = { -2, }
512 		},
513 	},
514 	.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
515 },
516 {
517 	"jsge32: BPF_X",
518 	.insns = {
519 	BPF_DIRECT_PKT_R2,
520 	BPF_LD_IMM64(BPF_REG_8, (__u32)-1 | 2ULL << 32),
521 	BPF_LDX_MEM(BPF_DW, BPF_REG_7, BPF_REG_2, 0),
522 	BPF_JMP32_REG(BPF_JSGE, BPF_REG_7, BPF_REG_8, 1),
523 	BPF_EXIT_INSN(),
524 	BPF_ALU32_IMM(BPF_MOV, BPF_REG_0, 2),
525 	BPF_EXIT_INSN(),
526 	},
527 	.prog_type = BPF_PROG_TYPE_SCHED_CLS,
528 	.result = ACCEPT,
529 	.runs = 3,
530 	.retvals = {
531 		{ .retval = 2,
532 		  .data64 = { -1, }
533 		},
534 		{ .retval = 2,
535 		  .data64 = { 0x7fffffff | 1ULL << 32, }
536 		},
537 		{ .retval = 0,
538 		  .data64 = { -2, }
539 		},
540 	},
541 	.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
542 },
543 {
544 	"jsge32: min/max deduction",
545 	.insns = {
546 	BPF_RAND_UEXT_R7,
547 	BPF_ALU32_IMM(BPF_MOV, BPF_REG_0, 2),
548 	BPF_LD_IMM64(BPF_REG_8, 0x7ffffff0 | 1ULL << 32),
549 	BPF_JMP32_REG(BPF_JSGE, BPF_REG_7, BPF_REG_8, 1),
550 	BPF_EXIT_INSN(),
551 	BPF_JMP_IMM(BPF_JSGE, BPF_REG_7, 0x7ffffff0, 1),
552 	BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_0, 0),
553 	BPF_EXIT_INSN(),
554 	},
555 	.result = ACCEPT,
556 	.retval = 2,
557 },
558 {
559 	"jsgt32: BPF_K",
560 	.insns = {
561 	BPF_DIRECT_PKT_R2,
562 	BPF_LDX_MEM(BPF_DW, BPF_REG_7, BPF_REG_2, 0),
563 	BPF_JMP32_IMM(BPF_JSGT, BPF_REG_7, -1, 1),
564 	BPF_EXIT_INSN(),
565 	BPF_ALU32_IMM(BPF_MOV, BPF_REG_0, 2),
566 	BPF_EXIT_INSN(),
567 	},
568 	.prog_type = BPF_PROG_TYPE_SCHED_CLS,
569 	.result = ACCEPT,
570 	.runs = 3,
571 	.retvals = {
572 		{ .retval = 0,
573 		  .data64 = { (__u32)-2, }
574 		},
575 		{ .retval = 0,
576 		  .data64 = { -1, }
577 		},
578 		{ .retval = 2,
579 		  .data64 = { 1, }
580 		},
581 	},
582 	.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
583 },
584 {
585 	"jsgt32: BPF_X",
586 	.insns = {
587 	BPF_DIRECT_PKT_R2,
588 	BPF_LD_IMM64(BPF_REG_8, 0x7ffffffe | 1ULL << 32),
589 	BPF_LDX_MEM(BPF_DW, BPF_REG_7, BPF_REG_2, 0),
590 	BPF_JMP32_REG(BPF_JSGT, BPF_REG_7, BPF_REG_8, 1),
591 	BPF_EXIT_INSN(),
592 	BPF_ALU32_IMM(BPF_MOV, BPF_REG_0, 2),
593 	BPF_EXIT_INSN(),
594 	},
595 	.prog_type = BPF_PROG_TYPE_SCHED_CLS,
596 	.result = ACCEPT,
597 	.runs = 3,
598 	.retvals = {
599 		{ .retval = 0,
600 		  .data64 = { 0x7ffffffe, }
601 		},
602 		{ .retval = 0,
603 		  .data64 = { 0x1ffffffffULL, }
604 		},
605 		{ .retval = 2,
606 		  .data64 = { 0x7fffffff, }
607 		},
608 	},
609 	.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
610 },
611 {
612 	"jsgt32: min/max deduction",
613 	.insns = {
614 	BPF_RAND_SEXT_R7,
615 	BPF_ALU32_IMM(BPF_MOV, BPF_REG_0, 2),
616 	BPF_LD_IMM64(BPF_REG_8, (__u32)(-2) | 1ULL << 32),
617 	BPF_JMP32_REG(BPF_JSGT, BPF_REG_7, BPF_REG_8, 1),
618 	BPF_EXIT_INSN(),
619 	BPF_JMP_IMM(BPF_JSGT, BPF_REG_7, -2, 1),
620 	BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_0, 0),
621 	BPF_EXIT_INSN(),
622 	},
623 	.result = ACCEPT,
624 	.retval = 2,
625 },
626 {
627 	"jsle32: BPF_K",
628 	.insns = {
629 	BPF_DIRECT_PKT_R2,
630 	BPF_LDX_MEM(BPF_DW, BPF_REG_7, BPF_REG_2, 0),
631 	BPF_JMP32_IMM(BPF_JSLE, BPF_REG_7, -1, 1),
632 	BPF_EXIT_INSN(),
633 	BPF_ALU32_IMM(BPF_MOV, BPF_REG_0, 2),
634 	BPF_EXIT_INSN(),
635 	},
636 	.prog_type = BPF_PROG_TYPE_SCHED_CLS,
637 	.result = ACCEPT,
638 	.runs = 3,
639 	.retvals = {
640 		{ .retval = 2,
641 		  .data64 = { (__u32)-2, }
642 		},
643 		{ .retval = 2,
644 		  .data64 = { -1, }
645 		},
646 		{ .retval = 0,
647 		  .data64 = { 1, }
648 		},
649 	},
650 	.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
651 },
652 {
653 	"jsle32: BPF_X",
654 	.insns = {
655 	BPF_DIRECT_PKT_R2,
656 	BPF_LD_IMM64(BPF_REG_8, 0x7ffffffe | 1ULL << 32),
657 	BPF_LDX_MEM(BPF_DW, BPF_REG_7, BPF_REG_2, 0),
658 	BPF_JMP32_REG(BPF_JSLE, BPF_REG_7, BPF_REG_8, 1),
659 	BPF_EXIT_INSN(),
660 	BPF_ALU32_IMM(BPF_MOV, BPF_REG_0, 2),
661 	BPF_EXIT_INSN(),
662 	},
663 	.prog_type = BPF_PROG_TYPE_SCHED_CLS,
664 	.result = ACCEPT,
665 	.runs = 3,
666 	.retvals = {
667 		{ .retval = 2,
668 		  .data64 = { 0x7ffffffe, }
669 		},
670 		{ .retval = 2,
671 		  .data64 = { (__u32)-1, }
672 		},
673 		{ .retval = 0,
674 		  .data64 = { 0x7fffffff | 2ULL << 32, }
675 		},
676 	},
677 	.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
678 },
679 {
680 	"jsle32: min/max deduction",
681 	.insns = {
682 	BPF_RAND_UEXT_R7,
683 	BPF_ALU32_IMM(BPF_MOV, BPF_REG_0, 2),
684 	BPF_LD_IMM64(BPF_REG_8, 0x7ffffff0 | 1ULL << 32),
685 	BPF_JMP32_REG(BPF_JSLE, BPF_REG_7, BPF_REG_8, 1),
686 	BPF_EXIT_INSN(),
687 	BPF_JMP_IMM(BPF_JSLE, BPF_REG_7, 0x7ffffff0, 1),
688 	BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_0, 0),
689 	BPF_EXIT_INSN(),
690 	},
691 	.result = ACCEPT,
692 	.retval = 2,
693 },
694 {
695 	"jslt32: BPF_K",
696 	.insns = {
697 	BPF_DIRECT_PKT_R2,
698 	BPF_LDX_MEM(BPF_DW, BPF_REG_7, BPF_REG_2, 0),
699 	BPF_JMP32_IMM(BPF_JSLT, BPF_REG_7, -1, 1),
700 	BPF_EXIT_INSN(),
701 	BPF_ALU32_IMM(BPF_MOV, BPF_REG_0, 2),
702 	BPF_EXIT_INSN(),
703 	},
704 	.prog_type = BPF_PROG_TYPE_SCHED_CLS,
705 	.result = ACCEPT,
706 	.runs = 3,
707 	.retvals = {
708 		{ .retval = 2,
709 		  .data64 = { (__u32)-2, }
710 		},
711 		{ .retval = 0,
712 		  .data64 = { -1, }
713 		},
714 		{ .retval = 0,
715 		  .data64 = { 1, }
716 		},
717 	},
718 	.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
719 },
720 {
721 	"jslt32: BPF_X",
722 	.insns = {
723 	BPF_DIRECT_PKT_R2,
724 	BPF_LD_IMM64(BPF_REG_8, 0x7fffffff | 1ULL << 32),
725 	BPF_LDX_MEM(BPF_DW, BPF_REG_7, BPF_REG_2, 0),
726 	BPF_JMP32_REG(BPF_JSLT, BPF_REG_7, BPF_REG_8, 1),
727 	BPF_EXIT_INSN(),
728 	BPF_ALU32_IMM(BPF_MOV, BPF_REG_0, 2),
729 	BPF_EXIT_INSN(),
730 	},
731 	.prog_type = BPF_PROG_TYPE_SCHED_CLS,
732 	.result = ACCEPT,
733 	.runs = 3,
734 	.retvals = {
735 		{ .retval = 2,
736 		  .data64 = { 0x7ffffffe, }
737 		},
738 		{ .retval = 2,
739 		  .data64 = { 0xffffffff, }
740 		},
741 		{ .retval = 0,
742 		  .data64 = { 0x7fffffff | 2ULL << 32, }
743 		},
744 	},
745 	.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
746 },
747 {
748 	"jslt32: min/max deduction",
749 	.insns = {
750 	BPF_RAND_SEXT_R7,
751 	BPF_ALU32_IMM(BPF_MOV, BPF_REG_0, 2),
752 	BPF_LD_IMM64(BPF_REG_8, (__u32)(-1) | 1ULL << 32),
753 	BPF_JMP32_REG(BPF_JSLT, BPF_REG_7, BPF_REG_8, 1),
754 	BPF_EXIT_INSN(),
755 	BPF_JMP32_IMM(BPF_JSLT, BPF_REG_7, -1, 1),
756 	BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_0, 0),
757 	BPF_EXIT_INSN(),
758 	},
759 	.result = ACCEPT,
760 	.retval = 2,
761 },
762 {
763 	"jgt32: range bound deduction, reg op imm",
764 	.insns = {
765 	BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
766 	BPF_MOV64_REG(BPF_REG_8, BPF_REG_1),
767 	BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
768 	BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
769 	BPF_LD_MAP_FD(BPF_REG_1, 0),
770 	BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_map_lookup_elem),
771 	BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 9),
772 	BPF_MOV64_REG(BPF_REG_1, BPF_REG_8),
773 	BPF_MOV64_REG(BPF_REG_8, BPF_REG_0),
774 	BPF_EMIT_CALL(BPF_FUNC_get_cgroup_classid),
775 	BPF_JMP32_IMM(BPF_JGT, BPF_REG_0, 1, 5),
776 	BPF_MOV32_REG(BPF_REG_6, BPF_REG_0),
777 	BPF_ALU64_IMM(BPF_LSH, BPF_REG_6, 32),
778 	BPF_ALU64_IMM(BPF_RSH, BPF_REG_6, 32),
779 	BPF_ALU64_REG(BPF_ADD, BPF_REG_8, BPF_REG_6),
780 	BPF_ST_MEM(BPF_B, BPF_REG_8, 0, 0),
781 	BPF_MOV32_IMM(BPF_REG_0, 0),
782 	BPF_EXIT_INSN(),
783 	},
784 	.prog_type = BPF_PROG_TYPE_SCHED_CLS,
785 	.fixup_map_hash_48b = { 4 },
786 	.result = ACCEPT,
787 	.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
788 },
789 {
790 	"jgt32: range bound deduction, reg1 op reg2, reg1 unknown",
791 	.insns = {
792 	BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
793 	BPF_MOV64_REG(BPF_REG_8, BPF_REG_1),
794 	BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
795 	BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
796 	BPF_LD_MAP_FD(BPF_REG_1, 0),
797 	BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_map_lookup_elem),
798 	BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 10),
799 	BPF_MOV64_REG(BPF_REG_1, BPF_REG_8),
800 	BPF_MOV64_REG(BPF_REG_8, BPF_REG_0),
801 	BPF_EMIT_CALL(BPF_FUNC_get_cgroup_classid),
802 	BPF_MOV32_IMM(BPF_REG_2, 1),
803 	BPF_JMP32_REG(BPF_JGT, BPF_REG_0, BPF_REG_2, 5),
804 	BPF_MOV32_REG(BPF_REG_6, BPF_REG_0),
805 	BPF_ALU64_IMM(BPF_LSH, BPF_REG_6, 32),
806 	BPF_ALU64_IMM(BPF_RSH, BPF_REG_6, 32),
807 	BPF_ALU64_REG(BPF_ADD, BPF_REG_8, BPF_REG_6),
808 	BPF_ST_MEM(BPF_B, BPF_REG_8, 0, 0),
809 	BPF_MOV32_IMM(BPF_REG_0, 0),
810 	BPF_EXIT_INSN(),
811 	},
812 	.prog_type = BPF_PROG_TYPE_SCHED_CLS,
813 	.fixup_map_hash_48b = { 4 },
814 	.result = ACCEPT,
815 	.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
816 },
817 {
818 	"jle32: range bound deduction, reg1 op reg2, reg2 unknown",
819 	.insns = {
820 	BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
821 	BPF_MOV64_REG(BPF_REG_8, BPF_REG_1),
822 	BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
823 	BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
824 	BPF_LD_MAP_FD(BPF_REG_1, 0),
825 	BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_map_lookup_elem),
826 	BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 10),
827 	BPF_MOV64_REG(BPF_REG_1, BPF_REG_8),
828 	BPF_MOV64_REG(BPF_REG_8, BPF_REG_0),
829 	BPF_EMIT_CALL(BPF_FUNC_get_cgroup_classid),
830 	BPF_MOV32_IMM(BPF_REG_2, 1),
831 	BPF_JMP32_REG(BPF_JLE, BPF_REG_2, BPF_REG_0, 5),
832 	BPF_MOV32_REG(BPF_REG_6, BPF_REG_0),
833 	BPF_ALU64_IMM(BPF_LSH, BPF_REG_6, 32),
834 	BPF_ALU64_IMM(BPF_RSH, BPF_REG_6, 32),
835 	BPF_ALU64_REG(BPF_ADD, BPF_REG_8, BPF_REG_6),
836 	BPF_ST_MEM(BPF_B, BPF_REG_8, 0, 0),
837 	BPF_MOV32_IMM(BPF_REG_0, 0),
838 	BPF_EXIT_INSN(),
839 	},
840 	.prog_type = BPF_PROG_TYPE_SCHED_CLS,
841 	.fixup_map_hash_48b = { 4 },
842 	.result = ACCEPT,
843 	.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
844 },
845