1 // SPDX-License-Identifier: GPL-2.0-only
3 * Testsuite for BPF interpreter and BPF JIT compiler
5 * Copyright (c) 2011-2014 PLUMgrid, http://plumgrid.com
8 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
10 #include <linux/init.h>
11 #include <linux/module.h>
12 #include <linux/filter.h>
13 #include <linux/bpf.h>
14 #include <linux/skbuff.h>
15 #include <linux/netdevice.h>
16 #include <linux/if_vlan.h>
17 #include <linux/prandom.h>
18 #include <linux/highmem.h>
19 #include <linux/sched.h>
21 /* General test specific settings */
22 #define MAX_SUBTESTS 3
23 #define MAX_TESTRUNS 1000
26 #define MAX_K 0xffffFFFF
28 /* Few constants used to init test 'skb' */
30 #define SKB_MARK 0x1234aaaa
31 #define SKB_HASH 0x1234aaab
32 #define SKB_QUEUE_MAP 123
33 #define SKB_VLAN_TCI 0xffff
34 #define SKB_VLAN_PRESENT 1
35 #define SKB_DEV_IFINDEX 577
36 #define SKB_DEV_TYPE 588
38 /* Redefine REGs to make tests less verbose */
49 #define R10 BPF_REG_10
51 /* Flags that can be passed to test cases */
52 #define FLAG_NO_DATA BIT(0)
53 #define FLAG_EXPECTED_FAIL BIT(1)
54 #define FLAG_SKB_FRAG BIT(2)
55 #define FLAG_VERIFIER_ZEXT BIT(3)
56 #define FLAG_LARGE_MEM BIT(4)
59 CLASSIC
= BIT(6), /* Old BPF instructions only. */
60 INTERNAL
= BIT(7), /* Extended instruction set. */
63 #define TEST_TYPE_MASK (CLASSIC | INTERNAL)
68 struct sock_filter insns
[MAX_INSNS
];
69 struct bpf_insn insns_int
[MAX_INSNS
];
81 int (*fill_helper
)(struct bpf_test
*self
);
82 int expected_errcode
; /* used when FLAG_EXPECTED_FAIL is set in the aux */
83 __u8 frag_data
[MAX_DATA
];
84 int stack_depth
; /* for eBPF only, since tests don't call verifier */
85 int nr_testruns
; /* Custom run count, defaults to MAX_TESTRUNS if 0 */
88 /* Large test cases need separate allocation and fill handler. */
90 static int bpf_fill_maxinsns1(struct bpf_test
*self
)
92 unsigned int len
= BPF_MAXINSNS
;
93 struct sock_filter
*insn
;
97 insn
= kmalloc_array(len
, sizeof(*insn
), GFP_KERNEL
);
101 for (i
= 0; i
< len
; i
++, k
--)
102 insn
[i
] = __BPF_STMT(BPF_RET
| BPF_K
, k
);
104 self
->u
.ptr
.insns
= insn
;
105 self
->u
.ptr
.len
= len
;
110 static int bpf_fill_maxinsns2(struct bpf_test
*self
)
112 unsigned int len
= BPF_MAXINSNS
;
113 struct sock_filter
*insn
;
116 insn
= kmalloc_array(len
, sizeof(*insn
), GFP_KERNEL
);
120 for (i
= 0; i
< len
; i
++)
121 insn
[i
] = __BPF_STMT(BPF_RET
| BPF_K
, 0xfefefefe);
123 self
->u
.ptr
.insns
= insn
;
124 self
->u
.ptr
.len
= len
;
129 static int bpf_fill_maxinsns3(struct bpf_test
*self
)
131 unsigned int len
= BPF_MAXINSNS
;
132 struct sock_filter
*insn
;
133 struct rnd_state rnd
;
136 insn
= kmalloc_array(len
, sizeof(*insn
), GFP_KERNEL
);
140 prandom_seed_state(&rnd
, 3141592653589793238ULL);
142 for (i
= 0; i
< len
- 1; i
++) {
143 __u32 k
= prandom_u32_state(&rnd
);
145 insn
[i
] = __BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, k
);
148 insn
[len
- 1] = __BPF_STMT(BPF_RET
| BPF_A
, 0);
150 self
->u
.ptr
.insns
= insn
;
151 self
->u
.ptr
.len
= len
;
156 static int bpf_fill_maxinsns4(struct bpf_test
*self
)
158 unsigned int len
= BPF_MAXINSNS
+ 1;
159 struct sock_filter
*insn
;
162 insn
= kmalloc_array(len
, sizeof(*insn
), GFP_KERNEL
);
166 for (i
= 0; i
< len
; i
++)
167 insn
[i
] = __BPF_STMT(BPF_RET
| BPF_K
, 0xfefefefe);
169 self
->u
.ptr
.insns
= insn
;
170 self
->u
.ptr
.len
= len
;
175 static int bpf_fill_maxinsns5(struct bpf_test
*self
)
177 unsigned int len
= BPF_MAXINSNS
;
178 struct sock_filter
*insn
;
181 insn
= kmalloc_array(len
, sizeof(*insn
), GFP_KERNEL
);
185 insn
[0] = __BPF_JUMP(BPF_JMP
| BPF_JA
, len
- 2, 0, 0);
187 for (i
= 1; i
< len
- 1; i
++)
188 insn
[i
] = __BPF_STMT(BPF_RET
| BPF_K
, 0xfefefefe);
190 insn
[len
- 1] = __BPF_STMT(BPF_RET
| BPF_K
, 0xabababab);
192 self
->u
.ptr
.insns
= insn
;
193 self
->u
.ptr
.len
= len
;
198 static int bpf_fill_maxinsns6(struct bpf_test
*self
)
200 unsigned int len
= BPF_MAXINSNS
;
201 struct sock_filter
*insn
;
204 insn
= kmalloc_array(len
, sizeof(*insn
), GFP_KERNEL
);
208 for (i
= 0; i
< len
- 1; i
++)
209 insn
[i
] = __BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
, SKF_AD_OFF
+
210 SKF_AD_VLAN_TAG_PRESENT
);
212 insn
[len
- 1] = __BPF_STMT(BPF_RET
| BPF_A
, 0);
214 self
->u
.ptr
.insns
= insn
;
215 self
->u
.ptr
.len
= len
;
220 static int bpf_fill_maxinsns7(struct bpf_test
*self
)
222 unsigned int len
= BPF_MAXINSNS
;
223 struct sock_filter
*insn
;
226 insn
= kmalloc_array(len
, sizeof(*insn
), GFP_KERNEL
);
230 for (i
= 0; i
< len
- 4; i
++)
231 insn
[i
] = __BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
, SKF_AD_OFF
+
234 insn
[len
- 4] = __BPF_STMT(BPF_MISC
| BPF_TAX
, 0);
235 insn
[len
- 3] = __BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
, SKF_AD_OFF
+
237 insn
[len
- 2] = __BPF_STMT(BPF_ALU
| BPF_SUB
| BPF_X
, 0);
238 insn
[len
- 1] = __BPF_STMT(BPF_RET
| BPF_A
, 0);
240 self
->u
.ptr
.insns
= insn
;
241 self
->u
.ptr
.len
= len
;
246 static int bpf_fill_maxinsns8(struct bpf_test
*self
)
248 unsigned int len
= BPF_MAXINSNS
;
249 struct sock_filter
*insn
;
250 int i
, jmp_off
= len
- 3;
252 insn
= kmalloc_array(len
, sizeof(*insn
), GFP_KERNEL
);
256 insn
[0] = __BPF_STMT(BPF_LD
| BPF_IMM
, 0xffffffff);
258 for (i
= 1; i
< len
- 1; i
++)
259 insn
[i
] = __BPF_JUMP(BPF_JMP
| BPF_JGT
, 0xffffffff, jmp_off
--, 0);
261 insn
[len
- 1] = __BPF_STMT(BPF_RET
| BPF_A
, 0);
263 self
->u
.ptr
.insns
= insn
;
264 self
->u
.ptr
.len
= len
;
269 static int bpf_fill_maxinsns9(struct bpf_test
*self
)
271 unsigned int len
= BPF_MAXINSNS
;
272 struct bpf_insn
*insn
;
275 insn
= kmalloc_array(len
, sizeof(*insn
), GFP_KERNEL
);
279 insn
[0] = BPF_JMP_IMM(BPF_JA
, 0, 0, len
- 2);
280 insn
[1] = BPF_ALU32_IMM(BPF_MOV
, R0
, 0xcbababab);
281 insn
[2] = BPF_EXIT_INSN();
283 for (i
= 3; i
< len
- 2; i
++)
284 insn
[i
] = BPF_ALU32_IMM(BPF_MOV
, R0
, 0xfefefefe);
286 insn
[len
- 2] = BPF_EXIT_INSN();
287 insn
[len
- 1] = BPF_JMP_IMM(BPF_JA
, 0, 0, -(len
- 1));
289 self
->u
.ptr
.insns
= insn
;
290 self
->u
.ptr
.len
= len
;
295 static int bpf_fill_maxinsns10(struct bpf_test
*self
)
297 unsigned int len
= BPF_MAXINSNS
, hlen
= len
- 2;
298 struct bpf_insn
*insn
;
301 insn
= kmalloc_array(len
, sizeof(*insn
), GFP_KERNEL
);
305 for (i
= 0; i
< hlen
/ 2; i
++)
306 insn
[i
] = BPF_JMP_IMM(BPF_JA
, 0, 0, hlen
- 2 - 2 * i
);
307 for (i
= hlen
- 1; i
> hlen
/ 2; i
--)
308 insn
[i
] = BPF_JMP_IMM(BPF_JA
, 0, 0, hlen
- 1 - 2 * i
);
310 insn
[hlen
/ 2] = BPF_JMP_IMM(BPF_JA
, 0, 0, hlen
/ 2 - 1);
311 insn
[hlen
] = BPF_ALU32_IMM(BPF_MOV
, R0
, 0xabababac);
312 insn
[hlen
+ 1] = BPF_EXIT_INSN();
314 self
->u
.ptr
.insns
= insn
;
315 self
->u
.ptr
.len
= len
;
320 static int __bpf_fill_ja(struct bpf_test
*self
, unsigned int len
,
323 struct sock_filter
*insn
;
327 insn
= kmalloc_array(len
, sizeof(*insn
), GFP_KERNEL
);
331 rlen
= (len
% plen
) - 1;
333 for (i
= 0; i
+ plen
< len
; i
+= plen
)
334 for (j
= 0; j
< plen
; j
++)
335 insn
[i
+ j
] = __BPF_JUMP(BPF_JMP
| BPF_JA
,
337 for (j
= 0; j
< rlen
; j
++)
338 insn
[i
+ j
] = __BPF_JUMP(BPF_JMP
| BPF_JA
, rlen
- 1 - j
,
341 insn
[len
- 1] = __BPF_STMT(BPF_RET
| BPF_K
, 0xababcbac);
343 self
->u
.ptr
.insns
= insn
;
344 self
->u
.ptr
.len
= len
;
349 static int bpf_fill_maxinsns11(struct bpf_test
*self
)
351 /* Hits 70 passes on x86_64 and triggers NOPs padding. */
352 return __bpf_fill_ja(self
, BPF_MAXINSNS
, 68);
355 static int bpf_fill_maxinsns12(struct bpf_test
*self
)
357 unsigned int len
= BPF_MAXINSNS
;
358 struct sock_filter
*insn
;
361 insn
= kmalloc_array(len
, sizeof(*insn
), GFP_KERNEL
);
365 insn
[0] = __BPF_JUMP(BPF_JMP
| BPF_JA
, len
- 2, 0, 0);
367 for (i
= 1; i
< len
- 1; i
++)
368 insn
[i
] = __BPF_STMT(BPF_LDX
| BPF_B
| BPF_MSH
, 0);
370 insn
[len
- 1] = __BPF_STMT(BPF_RET
| BPF_K
, 0xabababab);
372 self
->u
.ptr
.insns
= insn
;
373 self
->u
.ptr
.len
= len
;
378 static int bpf_fill_maxinsns13(struct bpf_test
*self
)
380 unsigned int len
= BPF_MAXINSNS
;
381 struct sock_filter
*insn
;
384 insn
= kmalloc_array(len
, sizeof(*insn
), GFP_KERNEL
);
388 for (i
= 0; i
< len
- 3; i
++)
389 insn
[i
] = __BPF_STMT(BPF_LDX
| BPF_B
| BPF_MSH
, 0);
391 insn
[len
- 3] = __BPF_STMT(BPF_LD
| BPF_IMM
, 0xabababab);
392 insn
[len
- 2] = __BPF_STMT(BPF_ALU
| BPF_XOR
| BPF_X
, 0);
393 insn
[len
- 1] = __BPF_STMT(BPF_RET
| BPF_A
, 0);
395 self
->u
.ptr
.insns
= insn
;
396 self
->u
.ptr
.len
= len
;
401 static int bpf_fill_ja(struct bpf_test
*self
)
403 /* Hits exactly 11 passes on x86_64 JIT. */
404 return __bpf_fill_ja(self
, 12, 9);
407 static int bpf_fill_ld_abs_get_processor_id(struct bpf_test
*self
)
409 unsigned int len
= BPF_MAXINSNS
;
410 struct sock_filter
*insn
;
413 insn
= kmalloc_array(len
, sizeof(*insn
), GFP_KERNEL
);
417 for (i
= 0; i
< len
- 1; i
+= 2) {
418 insn
[i
] = __BPF_STMT(BPF_LD
| BPF_B
| BPF_ABS
, 0);
419 insn
[i
+ 1] = __BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
420 SKF_AD_OFF
+ SKF_AD_CPU
);
423 insn
[len
- 1] = __BPF_STMT(BPF_RET
| BPF_K
, 0xbee);
425 self
->u
.ptr
.insns
= insn
;
426 self
->u
.ptr
.len
= len
;
431 static int __bpf_fill_stxdw(struct bpf_test
*self
, int size
)
433 unsigned int len
= BPF_MAXINSNS
;
434 struct bpf_insn
*insn
;
437 insn
= kmalloc_array(len
, sizeof(*insn
), GFP_KERNEL
);
441 insn
[0] = BPF_ALU32_IMM(BPF_MOV
, R0
, 1);
442 insn
[1] = BPF_ST_MEM(size
, R10
, -40, 42);
444 for (i
= 2; i
< len
- 2; i
++)
445 insn
[i
] = BPF_STX_XADD(size
, R10
, R0
, -40);
447 insn
[len
- 2] = BPF_LDX_MEM(size
, R0
, R10
, -40);
448 insn
[len
- 1] = BPF_EXIT_INSN();
450 self
->u
.ptr
.insns
= insn
;
451 self
->u
.ptr
.len
= len
;
452 self
->stack_depth
= 40;
457 static int bpf_fill_stxw(struct bpf_test
*self
)
459 return __bpf_fill_stxdw(self
, BPF_W
);
462 static int bpf_fill_stxdw(struct bpf_test
*self
)
464 return __bpf_fill_stxdw(self
, BPF_DW
);
467 static int __bpf_ld_imm64(struct bpf_insn insns
[2], u8 reg
, s64 imm64
)
469 struct bpf_insn tmp
[] = {BPF_LD_IMM64(reg
, imm64
)};
471 memcpy(insns
, tmp
, sizeof(tmp
));
476 * Branch conversion tests. Complex operations can expand to a lot
477 * of instructions when JITed. This in turn may cause jump offsets
478 * to overflow the field size of the native instruction, triggering
479 * a branch conversion mechanism in some JITs.
481 static int __bpf_fill_max_jmp(struct bpf_test
*self
, int jmp
, int imm
)
483 struct bpf_insn
*insns
;
484 int len
= S16_MAX
+ 5;
487 insns
= kmalloc_array(len
, sizeof(*insns
), GFP_KERNEL
);
491 i
= __bpf_ld_imm64(insns
, R1
, 0x0123456789abcdefULL
);
492 insns
[i
++] = BPF_ALU64_IMM(BPF_MOV
, R0
, 1);
493 insns
[i
++] = BPF_JMP_IMM(jmp
, R0
, imm
, S16_MAX
);
494 insns
[i
++] = BPF_ALU64_IMM(BPF_MOV
, R0
, 2);
495 insns
[i
++] = BPF_EXIT_INSN();
497 while (i
< len
- 1) {
498 static const int ops
[] = {
499 BPF_LSH
, BPF_RSH
, BPF_ARSH
, BPF_ADD
,
500 BPF_SUB
, BPF_MUL
, BPF_DIV
, BPF_MOD
,
502 int op
= ops
[(i
>> 1) % ARRAY_SIZE(ops
)];
505 insns
[i
++] = BPF_ALU32_REG(op
, R0
, R1
);
507 insns
[i
++] = BPF_ALU64_REG(op
, R0
, R1
);
510 insns
[i
++] = BPF_EXIT_INSN();
511 self
->u
.ptr
.insns
= insns
;
512 self
->u
.ptr
.len
= len
;
518 /* Branch taken by runtime decision */
519 static int bpf_fill_max_jmp_taken(struct bpf_test
*self
)
521 return __bpf_fill_max_jmp(self
, BPF_JEQ
, 1);
524 /* Branch not taken by runtime decision */
525 static int bpf_fill_max_jmp_not_taken(struct bpf_test
*self
)
527 return __bpf_fill_max_jmp(self
, BPF_JEQ
, 0);
530 /* Branch always taken, known at JIT time */
531 static int bpf_fill_max_jmp_always_taken(struct bpf_test
*self
)
533 return __bpf_fill_max_jmp(self
, BPF_JGE
, 0);
536 /* Branch never taken, known at JIT time */
537 static int bpf_fill_max_jmp_never_taken(struct bpf_test
*self
)
539 return __bpf_fill_max_jmp(self
, BPF_JLT
, 0);
542 /* ALU result computation used in tests */
543 static bool __bpf_alu_result(u64
*res
, u64 v1
, u64 v2
, u8 op
)
567 if (v2
> 0 && v1
> S64_MAX
)
568 *res
|= ~0ULL << (64 - v2
);
582 *res
= div64_u64(v1
, v2
);
587 div64_u64_rem(v1
, v2
, res
);
593 /* Test an ALU shift operation for all valid shift values */
594 static int __bpf_fill_alu_shift(struct bpf_test
*self
, u8 op
,
597 static const s64 regs
[] = {
598 0x0123456789abcdefLL
, /* dword > 0, word < 0 */
599 0xfedcba9876543210LL
, /* dword < 0, word > 0 */
600 0xfedcba0198765432LL
, /* dword < 0, word < 0 */
601 0x0123458967abcdefLL
, /* dword > 0, word > 0 */
603 int bits
= alu32
? 32 : 64;
604 int len
= (2 + 7 * bits
) * ARRAY_SIZE(regs
) + 3;
605 struct bpf_insn
*insn
;
609 insn
= kmalloc_array(len
, sizeof(*insn
), GFP_KERNEL
);
613 insn
[i
++] = BPF_ALU64_IMM(BPF_MOV
, R0
, 0);
615 for (k
= 0; k
< ARRAY_SIZE(regs
); k
++) {
618 i
+= __bpf_ld_imm64(&insn
[i
], R3
, reg
);
620 for (imm
= 0; imm
< bits
; imm
++) {
623 /* Perform operation */
624 insn
[i
++] = BPF_ALU64_REG(BPF_MOV
, R1
, R3
);
625 insn
[i
++] = BPF_ALU64_IMM(BPF_MOV
, R2
, imm
);
628 insn
[i
++] = BPF_ALU32_IMM(op
, R1
, imm
);
630 insn
[i
++] = BPF_ALU32_REG(op
, R1
, R2
);
636 __bpf_alu_result(&val
, reg
, imm
, op
);
640 insn
[i
++] = BPF_ALU64_IMM(op
, R1
, imm
);
642 insn
[i
++] = BPF_ALU64_REG(op
, R1
, R2
);
643 __bpf_alu_result(&val
, reg
, imm
, op
);
647 * When debugging a JIT that fails this test, one
648 * can write the immediate value to R0 here to find
649 * out which operand values that fail.
652 /* Load reference and check the result */
653 i
+= __bpf_ld_imm64(&insn
[i
], R4
, val
);
654 insn
[i
++] = BPF_JMP_REG(BPF_JEQ
, R1
, R4
, 1);
655 insn
[i
++] = BPF_EXIT_INSN();
659 insn
[i
++] = BPF_ALU64_IMM(BPF_MOV
, R0
, 1);
660 insn
[i
++] = BPF_EXIT_INSN();
662 self
->u
.ptr
.insns
= insn
;
663 self
->u
.ptr
.len
= len
;
669 static int bpf_fill_alu64_lsh_imm(struct bpf_test
*self
)
671 return __bpf_fill_alu_shift(self
, BPF_LSH
, BPF_K
, false);
674 static int bpf_fill_alu64_rsh_imm(struct bpf_test
*self
)
676 return __bpf_fill_alu_shift(self
, BPF_RSH
, BPF_K
, false);
679 static int bpf_fill_alu64_arsh_imm(struct bpf_test
*self
)
681 return __bpf_fill_alu_shift(self
, BPF_ARSH
, BPF_K
, false);
684 static int bpf_fill_alu64_lsh_reg(struct bpf_test
*self
)
686 return __bpf_fill_alu_shift(self
, BPF_LSH
, BPF_X
, false);
689 static int bpf_fill_alu64_rsh_reg(struct bpf_test
*self
)
691 return __bpf_fill_alu_shift(self
, BPF_RSH
, BPF_X
, false);
694 static int bpf_fill_alu64_arsh_reg(struct bpf_test
*self
)
696 return __bpf_fill_alu_shift(self
, BPF_ARSH
, BPF_X
, false);
699 static int bpf_fill_alu32_lsh_imm(struct bpf_test
*self
)
701 return __bpf_fill_alu_shift(self
, BPF_LSH
, BPF_K
, true);
704 static int bpf_fill_alu32_rsh_imm(struct bpf_test
*self
)
706 return __bpf_fill_alu_shift(self
, BPF_RSH
, BPF_K
, true);
709 static int bpf_fill_alu32_arsh_imm(struct bpf_test
*self
)
711 return __bpf_fill_alu_shift(self
, BPF_ARSH
, BPF_K
, true);
714 static int bpf_fill_alu32_lsh_reg(struct bpf_test
*self
)
716 return __bpf_fill_alu_shift(self
, BPF_LSH
, BPF_X
, true);
719 static int bpf_fill_alu32_rsh_reg(struct bpf_test
*self
)
721 return __bpf_fill_alu_shift(self
, BPF_RSH
, BPF_X
, true);
724 static int bpf_fill_alu32_arsh_reg(struct bpf_test
*self
)
726 return __bpf_fill_alu_shift(self
, BPF_ARSH
, BPF_X
, true);
730 * Test an ALU register shift operation for all valid shift values
731 * for the case when the source and destination are the same.
733 static int __bpf_fill_alu_shift_same_reg(struct bpf_test
*self
, u8 op
,
736 int bits
= alu32
? 32 : 64;
737 int len
= 3 + 6 * bits
;
738 struct bpf_insn
*insn
;
742 insn
= kmalloc_array(len
, sizeof(*insn
), GFP_KERNEL
);
746 insn
[i
++] = BPF_ALU64_IMM(BPF_MOV
, R0
, 0);
748 for (val
= 0; val
< bits
; val
++) {
751 /* Perform operation */
752 insn
[i
++] = BPF_ALU64_IMM(BPF_MOV
, R1
, val
);
754 insn
[i
++] = BPF_ALU32_REG(op
, R1
, R1
);
756 insn
[i
++] = BPF_ALU64_REG(op
, R1
, R1
);
758 /* Compute the reference result */
759 __bpf_alu_result(&res
, val
, val
, op
);
762 i
+= __bpf_ld_imm64(&insn
[i
], R2
, res
);
764 /* Check the actual result */
765 insn
[i
++] = BPF_JMP_REG(BPF_JEQ
, R1
, R2
, 1);
766 insn
[i
++] = BPF_EXIT_INSN();
769 insn
[i
++] = BPF_ALU64_IMM(BPF_MOV
, R0
, 1);
770 insn
[i
++] = BPF_EXIT_INSN();
772 self
->u
.ptr
.insns
= insn
;
773 self
->u
.ptr
.len
= len
;
779 static int bpf_fill_alu64_lsh_same_reg(struct bpf_test
*self
)
781 return __bpf_fill_alu_shift_same_reg(self
, BPF_LSH
, false);
784 static int bpf_fill_alu64_rsh_same_reg(struct bpf_test
*self
)
786 return __bpf_fill_alu_shift_same_reg(self
, BPF_RSH
, false);
789 static int bpf_fill_alu64_arsh_same_reg(struct bpf_test
*self
)
791 return __bpf_fill_alu_shift_same_reg(self
, BPF_ARSH
, false);
794 static int bpf_fill_alu32_lsh_same_reg(struct bpf_test
*self
)
796 return __bpf_fill_alu_shift_same_reg(self
, BPF_LSH
, true);
799 static int bpf_fill_alu32_rsh_same_reg(struct bpf_test
*self
)
801 return __bpf_fill_alu_shift_same_reg(self
, BPF_RSH
, true);
804 static int bpf_fill_alu32_arsh_same_reg(struct bpf_test
*self
)
806 return __bpf_fill_alu_shift_same_reg(self
, BPF_ARSH
, true);
810 * Common operand pattern generator for exhaustive power-of-two magnitudes
811 * tests. The block size parameters can be adjusted to increase/reduce the
812 * number of combinatons tested and thereby execution speed and memory
816 static inline s64
value(int msb
, int delta
, int sign
)
818 return sign
* (1LL << msb
) + delta
;
821 static int __bpf_fill_pattern(struct bpf_test
*self
, void *arg
,
822 int dbits
, int sbits
, int block1
, int block2
,
823 int (*emit
)(struct bpf_test
*, void*,
824 struct bpf_insn
*, s64
, s64
))
826 static const int sgn
[][2] = {{1, 1}, {1, -1}, {-1, 1}, {-1, -1}};
827 struct bpf_insn
*insns
;
828 int di
, si
, bt
, db
, sb
;
833 /* Total number of iterations for the two pattern */
834 count
= (dbits
- 1) * (sbits
- 1) * block1
* block1
* ARRAY_SIZE(sgn
);
835 count
+= (max(dbits
, sbits
) - 1) * block2
* block2
* ARRAY_SIZE(sgn
);
837 /* Compute the maximum number of insns and allocate the buffer */
838 len
= extra
+ count
* (*emit
)(self
, arg
, NULL
, 0, 0);
839 insns
= kmalloc_array(len
, sizeof(*insns
), GFP_KERNEL
);
843 /* Add head instruction(s) */
844 insns
[i
++] = BPF_ALU64_IMM(BPF_MOV
, R0
, 0);
847 * Pattern 1: all combinations of power-of-two magnitudes and sign,
848 * and with a block of contiguous values around each magnitude.
850 for (di
= 0; di
< dbits
- 1; di
++) /* Dst magnitudes */
851 for (si
= 0; si
< sbits
- 1; si
++) /* Src magnitudes */
852 for (k
= 0; k
< ARRAY_SIZE(sgn
); k
++) /* Sign combos */
853 for (db
= -(block1
/ 2);
854 db
< (block1
+ 1) / 2; db
++)
855 for (sb
= -(block1
/ 2);
856 sb
< (block1
+ 1) / 2; sb
++) {
859 dst
= value(di
, db
, sgn
[k
][0]);
860 src
= value(si
, sb
, sgn
[k
][1]);
861 i
+= (*emit
)(self
, arg
,
866 * Pattern 2: all combinations for a larger block of values
867 * for each power-of-two magnitude and sign, where the magnitude is
868 * the same for both operands.
870 for (bt
= 0; bt
< max(dbits
, sbits
) - 1; bt
++) /* Magnitude */
871 for (k
= 0; k
< ARRAY_SIZE(sgn
); k
++) /* Sign combos */
872 for (db
= -(block2
/ 2); db
< (block2
+ 1) / 2; db
++)
873 for (sb
= -(block2
/ 2);
874 sb
< (block2
+ 1) / 2; sb
++) {
877 dst
= value(bt
% dbits
, db
, sgn
[k
][0]);
878 src
= value(bt
% sbits
, sb
, sgn
[k
][1]);
879 i
+= (*emit
)(self
, arg
, &insns
[i
],
883 /* Append tail instructions */
884 insns
[i
++] = BPF_ALU64_IMM(BPF_MOV
, R0
, 1);
885 insns
[i
++] = BPF_EXIT_INSN();
888 self
->u
.ptr
.insns
= insns
;
895 * Block size parameters used in pattern tests below. une as needed to
896 * increase/reduce the number combinations tested, see following examples.
897 * block values per operand MSB
898 * ----------------------------------------
901 * 2 (1 << MSB) + [-1, 0]
902 * 3 (1 << MSB) + [-1, 0, 1]
904 #define PATTERN_BLOCK1 1
905 #define PATTERN_BLOCK2 5
907 /* Number of test runs for a pattern test */
908 #define NR_PATTERN_RUNS 1
911 * Exhaustive tests of ALU operations for all combinations of power-of-two
912 * magnitudes of the operands, both for positive and negative values. The
913 * test is designed to verify e.g. the ALU and ALU64 operations for JITs that
914 * emit different code depending on the magnitude of the immediate value.
916 static int __bpf_emit_alu64_imm(struct bpf_test
*self
, void *arg
,
917 struct bpf_insn
*insns
, s64 dst
, s64 imm
)
919 int op
= *(int *)arg
;
926 if (__bpf_alu_result(&res
, dst
, (s32
)imm
, op
)) {
927 i
+= __bpf_ld_imm64(&insns
[i
], R1
, dst
);
928 i
+= __bpf_ld_imm64(&insns
[i
], R3
, res
);
929 insns
[i
++] = BPF_ALU64_IMM(op
, R1
, imm
);
930 insns
[i
++] = BPF_JMP_REG(BPF_JEQ
, R1
, R3
, 1);
931 insns
[i
++] = BPF_EXIT_INSN();
937 static int __bpf_emit_alu32_imm(struct bpf_test
*self
, void *arg
,
938 struct bpf_insn
*insns
, s64 dst
, s64 imm
)
940 int op
= *(int *)arg
;
947 if (__bpf_alu_result(&res
, (u32
)dst
, (u32
)imm
, op
)) {
948 i
+= __bpf_ld_imm64(&insns
[i
], R1
, dst
);
949 i
+= __bpf_ld_imm64(&insns
[i
], R3
, (u32
)res
);
950 insns
[i
++] = BPF_ALU32_IMM(op
, R1
, imm
);
951 insns
[i
++] = BPF_JMP_REG(BPF_JEQ
, R1
, R3
, 1);
952 insns
[i
++] = BPF_EXIT_INSN();
958 static int __bpf_emit_alu64_reg(struct bpf_test
*self
, void *arg
,
959 struct bpf_insn
*insns
, s64 dst
, s64 src
)
961 int op
= *(int *)arg
;
968 if (__bpf_alu_result(&res
, dst
, src
, op
)) {
969 i
+= __bpf_ld_imm64(&insns
[i
], R1
, dst
);
970 i
+= __bpf_ld_imm64(&insns
[i
], R2
, src
);
971 i
+= __bpf_ld_imm64(&insns
[i
], R3
, res
);
972 insns
[i
++] = BPF_ALU64_REG(op
, R1
, R2
);
973 insns
[i
++] = BPF_JMP_REG(BPF_JEQ
, R1
, R3
, 1);
974 insns
[i
++] = BPF_EXIT_INSN();
980 static int __bpf_emit_alu32_reg(struct bpf_test
*self
, void *arg
,
981 struct bpf_insn
*insns
, s64 dst
, s64 src
)
983 int op
= *(int *)arg
;
990 if (__bpf_alu_result(&res
, (u32
)dst
, (u32
)src
, op
)) {
991 i
+= __bpf_ld_imm64(&insns
[i
], R1
, dst
);
992 i
+= __bpf_ld_imm64(&insns
[i
], R2
, src
);
993 i
+= __bpf_ld_imm64(&insns
[i
], R3
, (u32
)res
);
994 insns
[i
++] = BPF_ALU32_REG(op
, R1
, R2
);
995 insns
[i
++] = BPF_JMP_REG(BPF_JEQ
, R1
, R3
, 1);
996 insns
[i
++] = BPF_EXIT_INSN();
1002 static int __bpf_fill_alu64_imm(struct bpf_test
*self
, int op
)
1004 return __bpf_fill_pattern(self
, &op
, 64, 32,
1005 PATTERN_BLOCK1
, PATTERN_BLOCK2
,
1006 &__bpf_emit_alu64_imm
);
1009 static int __bpf_fill_alu32_imm(struct bpf_test
*self
, int op
)
1011 return __bpf_fill_pattern(self
, &op
, 64, 32,
1012 PATTERN_BLOCK1
, PATTERN_BLOCK2
,
1013 &__bpf_emit_alu32_imm
);
1016 static int __bpf_fill_alu64_reg(struct bpf_test
*self
, int op
)
1018 return __bpf_fill_pattern(self
, &op
, 64, 64,
1019 PATTERN_BLOCK1
, PATTERN_BLOCK2
,
1020 &__bpf_emit_alu64_reg
);
1023 static int __bpf_fill_alu32_reg(struct bpf_test
*self
, int op
)
1025 return __bpf_fill_pattern(self
, &op
, 64, 64,
1026 PATTERN_BLOCK1
, PATTERN_BLOCK2
,
1027 &__bpf_emit_alu32_reg
);
1030 /* ALU64 immediate operations */
1031 static int bpf_fill_alu64_mov_imm(struct bpf_test
*self
)
1033 return __bpf_fill_alu64_imm(self
, BPF_MOV
);
1036 static int bpf_fill_alu64_and_imm(struct bpf_test
*self
)
1038 return __bpf_fill_alu64_imm(self
, BPF_AND
);
1041 static int bpf_fill_alu64_or_imm(struct bpf_test
*self
)
1043 return __bpf_fill_alu64_imm(self
, BPF_OR
);
1046 static int bpf_fill_alu64_xor_imm(struct bpf_test
*self
)
1048 return __bpf_fill_alu64_imm(self
, BPF_XOR
);
1051 static int bpf_fill_alu64_add_imm(struct bpf_test
*self
)
1053 return __bpf_fill_alu64_imm(self
, BPF_ADD
);
1056 static int bpf_fill_alu64_sub_imm(struct bpf_test
*self
)
1058 return __bpf_fill_alu64_imm(self
, BPF_SUB
);
1061 static int bpf_fill_alu64_mul_imm(struct bpf_test
*self
)
1063 return __bpf_fill_alu64_imm(self
, BPF_MUL
);
1066 static int bpf_fill_alu64_div_imm(struct bpf_test
*self
)
1068 return __bpf_fill_alu64_imm(self
, BPF_DIV
);
1071 static int bpf_fill_alu64_mod_imm(struct bpf_test
*self
)
1073 return __bpf_fill_alu64_imm(self
, BPF_MOD
);
1076 /* ALU32 immediate operations */
1077 static int bpf_fill_alu32_mov_imm(struct bpf_test
*self
)
1079 return __bpf_fill_alu32_imm(self
, BPF_MOV
);
1082 static int bpf_fill_alu32_and_imm(struct bpf_test
*self
)
1084 return __bpf_fill_alu32_imm(self
, BPF_AND
);
1087 static int bpf_fill_alu32_or_imm(struct bpf_test
*self
)
1089 return __bpf_fill_alu32_imm(self
, BPF_OR
);
1092 static int bpf_fill_alu32_xor_imm(struct bpf_test
*self
)
1094 return __bpf_fill_alu32_imm(self
, BPF_XOR
);
1097 static int bpf_fill_alu32_add_imm(struct bpf_test
*self
)
1099 return __bpf_fill_alu32_imm(self
, BPF_ADD
);
1102 static int bpf_fill_alu32_sub_imm(struct bpf_test
*self
)
1104 return __bpf_fill_alu32_imm(self
, BPF_SUB
);
1107 static int bpf_fill_alu32_mul_imm(struct bpf_test
*self
)
1109 return __bpf_fill_alu32_imm(self
, BPF_MUL
);
1112 static int bpf_fill_alu32_div_imm(struct bpf_test
*self
)
1114 return __bpf_fill_alu32_imm(self
, BPF_DIV
);
1117 static int bpf_fill_alu32_mod_imm(struct bpf_test
*self
)
1119 return __bpf_fill_alu32_imm(self
, BPF_MOD
);
1122 /* ALU64 register operations */
1123 static int bpf_fill_alu64_mov_reg(struct bpf_test
*self
)
1125 return __bpf_fill_alu64_reg(self
, BPF_MOV
);
1128 static int bpf_fill_alu64_and_reg(struct bpf_test
*self
)
1130 return __bpf_fill_alu64_reg(self
, BPF_AND
);
1133 static int bpf_fill_alu64_or_reg(struct bpf_test
*self
)
1135 return __bpf_fill_alu64_reg(self
, BPF_OR
);
1138 static int bpf_fill_alu64_xor_reg(struct bpf_test
*self
)
1140 return __bpf_fill_alu64_reg(self
, BPF_XOR
);
1143 static int bpf_fill_alu64_add_reg(struct bpf_test
*self
)
1145 return __bpf_fill_alu64_reg(self
, BPF_ADD
);
1148 static int bpf_fill_alu64_sub_reg(struct bpf_test
*self
)
1150 return __bpf_fill_alu64_reg(self
, BPF_SUB
);
1153 static int bpf_fill_alu64_mul_reg(struct bpf_test
*self
)
1155 return __bpf_fill_alu64_reg(self
, BPF_MUL
);
1158 static int bpf_fill_alu64_div_reg(struct bpf_test
*self
)
1160 return __bpf_fill_alu64_reg(self
, BPF_DIV
);
1163 static int bpf_fill_alu64_mod_reg(struct bpf_test
*self
)
1165 return __bpf_fill_alu64_reg(self
, BPF_MOD
);
1168 /* ALU32 register operations */
1169 static int bpf_fill_alu32_mov_reg(struct bpf_test
*self
)
1171 return __bpf_fill_alu32_reg(self
, BPF_MOV
);
1174 static int bpf_fill_alu32_and_reg(struct bpf_test
*self
)
1176 return __bpf_fill_alu32_reg(self
, BPF_AND
);
1179 static int bpf_fill_alu32_or_reg(struct bpf_test
*self
)
1181 return __bpf_fill_alu32_reg(self
, BPF_OR
);
1184 static int bpf_fill_alu32_xor_reg(struct bpf_test
*self
)
1186 return __bpf_fill_alu32_reg(self
, BPF_XOR
);
1189 static int bpf_fill_alu32_add_reg(struct bpf_test
*self
)
1191 return __bpf_fill_alu32_reg(self
, BPF_ADD
);
1194 static int bpf_fill_alu32_sub_reg(struct bpf_test
*self
)
1196 return __bpf_fill_alu32_reg(self
, BPF_SUB
);
1199 static int bpf_fill_alu32_mul_reg(struct bpf_test
*self
)
1201 return __bpf_fill_alu32_reg(self
, BPF_MUL
);
1204 static int bpf_fill_alu32_div_reg(struct bpf_test
*self
)
1206 return __bpf_fill_alu32_reg(self
, BPF_DIV
);
1209 static int bpf_fill_alu32_mod_reg(struct bpf_test
*self
)
1211 return __bpf_fill_alu32_reg(self
, BPF_MOD
);
1215 * Test JITs that implement complex ALU operations as function
1216 * calls, and must re-arrange operands for argument passing.
1218 static int __bpf_fill_alu_imm_regs(struct bpf_test
*self
, u8 op
, bool alu32
)
1220 int len
= 2 + 10 * 10;
1221 struct bpf_insn
*insns
;
1227 insns
= kmalloc_array(len
, sizeof(*insns
), GFP_KERNEL
);
1231 /* Operand and result values according to operation */
1235 dst
= 0x7edcba9876543210ULL
;
1238 if (op
== BPF_LSH
|| op
== BPF_RSH
|| op
== BPF_ARSH
)
1241 __bpf_alu_result(&res
, dst
, imm
, op
);
1246 /* Check all operand registers */
1247 for (rd
= R0
; rd
<= R9
; rd
++) {
1248 i
+= __bpf_ld_imm64(&insns
[i
], rd
, dst
);
1251 insns
[i
++] = BPF_ALU32_IMM(op
, rd
, imm
);
1253 insns
[i
++] = BPF_ALU64_IMM(op
, rd
, imm
);
1255 insns
[i
++] = BPF_JMP32_IMM(BPF_JEQ
, rd
, res
, 2);
1256 insns
[i
++] = BPF_MOV64_IMM(R0
, __LINE__
);
1257 insns
[i
++] = BPF_EXIT_INSN();
1259 insns
[i
++] = BPF_ALU64_IMM(BPF_RSH
, rd
, 32);
1260 insns
[i
++] = BPF_JMP32_IMM(BPF_JEQ
, rd
, res
>> 32, 2);
1261 insns
[i
++] = BPF_MOV64_IMM(R0
, __LINE__
);
1262 insns
[i
++] = BPF_EXIT_INSN();
1265 insns
[i
++] = BPF_MOV64_IMM(R0
, 1);
1266 insns
[i
++] = BPF_EXIT_INSN();
1268 self
->u
.ptr
.insns
= insns
;
1269 self
->u
.ptr
.len
= len
;
1275 /* ALU64 K registers */
1276 static int bpf_fill_alu64_mov_imm_regs(struct bpf_test
*self
)
1278 return __bpf_fill_alu_imm_regs(self
, BPF_MOV
, false);
1281 static int bpf_fill_alu64_and_imm_regs(struct bpf_test
*self
)
1283 return __bpf_fill_alu_imm_regs(self
, BPF_AND
, false);
1286 static int bpf_fill_alu64_or_imm_regs(struct bpf_test
*self
)
1288 return __bpf_fill_alu_imm_regs(self
, BPF_OR
, false);
1291 static int bpf_fill_alu64_xor_imm_regs(struct bpf_test
*self
)
1293 return __bpf_fill_alu_imm_regs(self
, BPF_XOR
, false);
1296 static int bpf_fill_alu64_lsh_imm_regs(struct bpf_test
*self
)
1298 return __bpf_fill_alu_imm_regs(self
, BPF_LSH
, false);
1301 static int bpf_fill_alu64_rsh_imm_regs(struct bpf_test
*self
)
1303 return __bpf_fill_alu_imm_regs(self
, BPF_RSH
, false);
1306 static int bpf_fill_alu64_arsh_imm_regs(struct bpf_test
*self
)
1308 return __bpf_fill_alu_imm_regs(self
, BPF_ARSH
, false);
1311 static int bpf_fill_alu64_add_imm_regs(struct bpf_test
*self
)
1313 return __bpf_fill_alu_imm_regs(self
, BPF_ADD
, false);
1316 static int bpf_fill_alu64_sub_imm_regs(struct bpf_test
*self
)
1318 return __bpf_fill_alu_imm_regs(self
, BPF_SUB
, false);
1321 static int bpf_fill_alu64_mul_imm_regs(struct bpf_test
*self
)
1323 return __bpf_fill_alu_imm_regs(self
, BPF_MUL
, false);
1326 static int bpf_fill_alu64_div_imm_regs(struct bpf_test
*self
)
1328 return __bpf_fill_alu_imm_regs(self
, BPF_DIV
, false);
1331 static int bpf_fill_alu64_mod_imm_regs(struct bpf_test
*self
)
1333 return __bpf_fill_alu_imm_regs(self
, BPF_MOD
, false);
1336 /* ALU32 K registers */
1337 static int bpf_fill_alu32_mov_imm_regs(struct bpf_test
*self
)
1339 return __bpf_fill_alu_imm_regs(self
, BPF_MOV
, true);
1342 static int bpf_fill_alu32_and_imm_regs(struct bpf_test
*self
)
1344 return __bpf_fill_alu_imm_regs(self
, BPF_AND
, true);
1347 static int bpf_fill_alu32_or_imm_regs(struct bpf_test
*self
)
1349 return __bpf_fill_alu_imm_regs(self
, BPF_OR
, true);
1352 static int bpf_fill_alu32_xor_imm_regs(struct bpf_test
*self
)
1354 return __bpf_fill_alu_imm_regs(self
, BPF_XOR
, true);
1357 static int bpf_fill_alu32_lsh_imm_regs(struct bpf_test
*self
)
1359 return __bpf_fill_alu_imm_regs(self
, BPF_LSH
, true);
1362 static int bpf_fill_alu32_rsh_imm_regs(struct bpf_test
*self
)
1364 return __bpf_fill_alu_imm_regs(self
, BPF_RSH
, true);
1367 static int bpf_fill_alu32_arsh_imm_regs(struct bpf_test
*self
)
1369 return __bpf_fill_alu_imm_regs(self
, BPF_ARSH
, true);
1372 static int bpf_fill_alu32_add_imm_regs(struct bpf_test
*self
)
1374 return __bpf_fill_alu_imm_regs(self
, BPF_ADD
, true);
1377 static int bpf_fill_alu32_sub_imm_regs(struct bpf_test
*self
)
1379 return __bpf_fill_alu_imm_regs(self
, BPF_SUB
, true);
1382 static int bpf_fill_alu32_mul_imm_regs(struct bpf_test
*self
)
1384 return __bpf_fill_alu_imm_regs(self
, BPF_MUL
, true);
1387 static int bpf_fill_alu32_div_imm_regs(struct bpf_test
*self
)
1389 return __bpf_fill_alu_imm_regs(self
, BPF_DIV
, true);
1392 static int bpf_fill_alu32_mod_imm_regs(struct bpf_test
*self
)
1394 return __bpf_fill_alu_imm_regs(self
, BPF_MOD
, true);
1398 * Test JITs that implement complex ALU operations as function
1399 * calls, and must re-arrange operands for argument passing.
1401 static int __bpf_fill_alu_reg_pairs(struct bpf_test
*self
, u8 op
, bool alu32
)
1403 int len
= 2 + 10 * 10 * 12;
1404 u64 dst
, src
, res
, same
;
1405 struct bpf_insn
*insns
;
1409 insns
= kmalloc_array(len
, sizeof(*insns
), GFP_KERNEL
);
1413 /* Operand and result values according to operation */
1418 dst
= 0x7edcba9876543210ULL
;
1419 src
= 0x0123456789abcdefULL
;
1422 if (op
== BPF_LSH
|| op
== BPF_RSH
|| op
== BPF_ARSH
)
1425 __bpf_alu_result(&res
, dst
, src
, op
);
1426 __bpf_alu_result(&same
, src
, src
, op
);
1433 /* Check all combinations of operand registers */
1434 for (rd
= R0
; rd
<= R9
; rd
++) {
1435 for (rs
= R0
; rs
<= R9
; rs
++) {
1436 u64 val
= rd
== rs
? same
: res
;
1438 i
+= __bpf_ld_imm64(&insns
[i
], rd
, dst
);
1439 i
+= __bpf_ld_imm64(&insns
[i
], rs
, src
);
1442 insns
[i
++] = BPF_ALU32_REG(op
, rd
, rs
);
1444 insns
[i
++] = BPF_ALU64_REG(op
, rd
, rs
);
1446 insns
[i
++] = BPF_JMP32_IMM(BPF_JEQ
, rd
, val
, 2);
1447 insns
[i
++] = BPF_MOV64_IMM(R0
, __LINE__
);
1448 insns
[i
++] = BPF_EXIT_INSN();
1450 insns
[i
++] = BPF_ALU64_IMM(BPF_RSH
, rd
, 32);
1451 insns
[i
++] = BPF_JMP32_IMM(BPF_JEQ
, rd
, val
>> 32, 2);
1452 insns
[i
++] = BPF_MOV64_IMM(R0
, __LINE__
);
1453 insns
[i
++] = BPF_EXIT_INSN();
1457 insns
[i
++] = BPF_MOV64_IMM(R0
, 1);
1458 insns
[i
++] = BPF_EXIT_INSN();
1460 self
->u
.ptr
.insns
= insns
;
1461 self
->u
.ptr
.len
= len
;
1467 /* ALU64 X register combinations */
1468 static int bpf_fill_alu64_mov_reg_pairs(struct bpf_test
*self
)
1470 return __bpf_fill_alu_reg_pairs(self
, BPF_MOV
, false);
1473 static int bpf_fill_alu64_and_reg_pairs(struct bpf_test
*self
)
1475 return __bpf_fill_alu_reg_pairs(self
, BPF_AND
, false);
1478 static int bpf_fill_alu64_or_reg_pairs(struct bpf_test
*self
)
1480 return __bpf_fill_alu_reg_pairs(self
, BPF_OR
, false);
1483 static int bpf_fill_alu64_xor_reg_pairs(struct bpf_test
*self
)
1485 return __bpf_fill_alu_reg_pairs(self
, BPF_XOR
, false);
1488 static int bpf_fill_alu64_lsh_reg_pairs(struct bpf_test
*self
)
1490 return __bpf_fill_alu_reg_pairs(self
, BPF_LSH
, false);
1493 static int bpf_fill_alu64_rsh_reg_pairs(struct bpf_test
*self
)
1495 return __bpf_fill_alu_reg_pairs(self
, BPF_RSH
, false);
1498 static int bpf_fill_alu64_arsh_reg_pairs(struct bpf_test
*self
)
1500 return __bpf_fill_alu_reg_pairs(self
, BPF_ARSH
, false);
1503 static int bpf_fill_alu64_add_reg_pairs(struct bpf_test
*self
)
1505 return __bpf_fill_alu_reg_pairs(self
, BPF_ADD
, false);
1508 static int bpf_fill_alu64_sub_reg_pairs(struct bpf_test
*self
)
1510 return __bpf_fill_alu_reg_pairs(self
, BPF_SUB
, false);
1513 static int bpf_fill_alu64_mul_reg_pairs(struct bpf_test
*self
)
1515 return __bpf_fill_alu_reg_pairs(self
, BPF_MUL
, false);
1518 static int bpf_fill_alu64_div_reg_pairs(struct bpf_test
*self
)
1520 return __bpf_fill_alu_reg_pairs(self
, BPF_DIV
, false);
1523 static int bpf_fill_alu64_mod_reg_pairs(struct bpf_test
*self
)
1525 return __bpf_fill_alu_reg_pairs(self
, BPF_MOD
, false);
1528 /* ALU32 X register combinations */
1529 static int bpf_fill_alu32_mov_reg_pairs(struct bpf_test
*self
)
1531 return __bpf_fill_alu_reg_pairs(self
, BPF_MOV
, true);
1534 static int bpf_fill_alu32_and_reg_pairs(struct bpf_test
*self
)
1536 return __bpf_fill_alu_reg_pairs(self
, BPF_AND
, true);
1539 static int bpf_fill_alu32_or_reg_pairs(struct bpf_test
*self
)
1541 return __bpf_fill_alu_reg_pairs(self
, BPF_OR
, true);
1544 static int bpf_fill_alu32_xor_reg_pairs(struct bpf_test
*self
)
1546 return __bpf_fill_alu_reg_pairs(self
, BPF_XOR
, true);
1549 static int bpf_fill_alu32_lsh_reg_pairs(struct bpf_test
*self
)
1551 return __bpf_fill_alu_reg_pairs(self
, BPF_LSH
, true);
1554 static int bpf_fill_alu32_rsh_reg_pairs(struct bpf_test
*self
)
1556 return __bpf_fill_alu_reg_pairs(self
, BPF_RSH
, true);
1559 static int bpf_fill_alu32_arsh_reg_pairs(struct bpf_test
*self
)
1561 return __bpf_fill_alu_reg_pairs(self
, BPF_ARSH
, true);
1564 static int bpf_fill_alu32_add_reg_pairs(struct bpf_test
*self
)
1566 return __bpf_fill_alu_reg_pairs(self
, BPF_ADD
, true);
1569 static int bpf_fill_alu32_sub_reg_pairs(struct bpf_test
*self
)
1571 return __bpf_fill_alu_reg_pairs(self
, BPF_SUB
, true);
1574 static int bpf_fill_alu32_mul_reg_pairs(struct bpf_test
*self
)
1576 return __bpf_fill_alu_reg_pairs(self
, BPF_MUL
, true);
1579 static int bpf_fill_alu32_div_reg_pairs(struct bpf_test
*self
)
1581 return __bpf_fill_alu_reg_pairs(self
, BPF_DIV
, true);
1584 static int bpf_fill_alu32_mod_reg_pairs(struct bpf_test
*self
)
1586 return __bpf_fill_alu_reg_pairs(self
, BPF_MOD
, true);
1590 * Exhaustive tests of atomic operations for all power-of-two operand
1591 * magnitudes, both for positive and negative values.
1594 static int __bpf_emit_atomic64(struct bpf_test
*self
, void *arg
,
1595 struct bpf_insn
*insns
, s64 dst
, s64 src
)
1597 int op
= *(int *)arg
;
1598 u64 keep
, fetch
, res
;
1609 __bpf_alu_result(&res
, dst
, src
, BPF_OP(op
));
1612 keep
= 0x0123456789abcdefULL
;
1618 i
+= __bpf_ld_imm64(&insns
[i
], R0
, keep
);
1619 i
+= __bpf_ld_imm64(&insns
[i
], R1
, dst
);
1620 i
+= __bpf_ld_imm64(&insns
[i
], R2
, src
);
1621 i
+= __bpf_ld_imm64(&insns
[i
], R3
, res
);
1622 i
+= __bpf_ld_imm64(&insns
[i
], R4
, fetch
);
1623 i
+= __bpf_ld_imm64(&insns
[i
], R5
, keep
);
1625 insns
[i
++] = BPF_STX_MEM(BPF_DW
, R10
, R1
, -8);
1626 insns
[i
++] = BPF_ATOMIC_OP(BPF_DW
, op
, R10
, R2
, -8);
1627 insns
[i
++] = BPF_LDX_MEM(BPF_DW
, R1
, R10
, -8);
1629 insns
[i
++] = BPF_JMP_REG(BPF_JEQ
, R1
, R3
, 1);
1630 insns
[i
++] = BPF_EXIT_INSN();
1632 insns
[i
++] = BPF_JMP_REG(BPF_JEQ
, R2
, R4
, 1);
1633 insns
[i
++] = BPF_EXIT_INSN();
1635 insns
[i
++] = BPF_JMP_REG(BPF_JEQ
, R0
, R5
, 1);
1636 insns
[i
++] = BPF_EXIT_INSN();
1641 static int __bpf_emit_atomic32(struct bpf_test
*self
, void *arg
,
1642 struct bpf_insn
*insns
, s64 dst
, s64 src
)
1644 int op
= *(int *)arg
;
1645 u64 keep
, fetch
, res
;
1656 __bpf_alu_result(&res
, (u32
)dst
, (u32
)src
, BPF_OP(op
));
1659 keep
= 0x0123456789abcdefULL
;
1665 i
+= __bpf_ld_imm64(&insns
[i
], R0
, keep
);
1666 i
+= __bpf_ld_imm64(&insns
[i
], R1
, (u32
)dst
);
1667 i
+= __bpf_ld_imm64(&insns
[i
], R2
, src
);
1668 i
+= __bpf_ld_imm64(&insns
[i
], R3
, (u32
)res
);
1669 i
+= __bpf_ld_imm64(&insns
[i
], R4
, fetch
);
1670 i
+= __bpf_ld_imm64(&insns
[i
], R5
, keep
);
1672 insns
[i
++] = BPF_STX_MEM(BPF_W
, R10
, R1
, -4);
1673 insns
[i
++] = BPF_ATOMIC_OP(BPF_W
, op
, R10
, R2
, -4);
1674 insns
[i
++] = BPF_LDX_MEM(BPF_W
, R1
, R10
, -4);
1676 insns
[i
++] = BPF_JMP_REG(BPF_JEQ
, R1
, R3
, 1);
1677 insns
[i
++] = BPF_EXIT_INSN();
1679 insns
[i
++] = BPF_JMP_REG(BPF_JEQ
, R2
, R4
, 1);
1680 insns
[i
++] = BPF_EXIT_INSN();
1682 insns
[i
++] = BPF_JMP_REG(BPF_JEQ
, R0
, R5
, 1);
1683 insns
[i
++] = BPF_EXIT_INSN();
1688 static int __bpf_emit_cmpxchg64(struct bpf_test
*self
, void *arg
,
1689 struct bpf_insn
*insns
, s64 dst
, s64 src
)
1696 i
+= __bpf_ld_imm64(&insns
[i
], R0
, ~dst
);
1697 i
+= __bpf_ld_imm64(&insns
[i
], R1
, dst
);
1698 i
+= __bpf_ld_imm64(&insns
[i
], R2
, src
);
1700 /* Result unsuccessful */
1701 insns
[i
++] = BPF_STX_MEM(BPF_DW
, R10
, R1
, -8);
1702 insns
[i
++] = BPF_ATOMIC_OP(BPF_DW
, BPF_CMPXCHG
, R10
, R2
, -8);
1703 insns
[i
++] = BPF_LDX_MEM(BPF_DW
, R3
, R10
, -8);
1705 insns
[i
++] = BPF_JMP_REG(BPF_JEQ
, R1
, R3
, 2);
1706 insns
[i
++] = BPF_MOV64_IMM(R0
, __LINE__
);
1707 insns
[i
++] = BPF_EXIT_INSN();
1709 insns
[i
++] = BPF_JMP_REG(BPF_JEQ
, R0
, R3
, 2);
1710 insns
[i
++] = BPF_MOV64_IMM(R0
, __LINE__
);
1711 insns
[i
++] = BPF_EXIT_INSN();
1713 /* Result successful */
1714 insns
[i
++] = BPF_ATOMIC_OP(BPF_DW
, BPF_CMPXCHG
, R10
, R2
, -8);
1715 insns
[i
++] = BPF_LDX_MEM(BPF_DW
, R3
, R10
, -8);
1717 insns
[i
++] = BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2);
1718 insns
[i
++] = BPF_MOV64_IMM(R0
, __LINE__
);
1719 insns
[i
++] = BPF_EXIT_INSN();
1721 insns
[i
++] = BPF_JMP_REG(BPF_JEQ
, R0
, R1
, 2);
1722 insns
[i
++] = BPF_MOV64_IMM(R0
, __LINE__
);
1723 insns
[i
++] = BPF_EXIT_INSN();
1728 static int __bpf_emit_cmpxchg32(struct bpf_test
*self
, void *arg
,
1729 struct bpf_insn
*insns
, s64 dst
, s64 src
)
1736 i
+= __bpf_ld_imm64(&insns
[i
], R0
, ~dst
);
1737 i
+= __bpf_ld_imm64(&insns
[i
], R1
, (u32
)dst
);
1738 i
+= __bpf_ld_imm64(&insns
[i
], R2
, src
);
1740 /* Result unsuccessful */
1741 insns
[i
++] = BPF_STX_MEM(BPF_W
, R10
, R1
, -4);
1742 insns
[i
++] = BPF_ATOMIC_OP(BPF_W
, BPF_CMPXCHG
, R10
, R2
, -4);
1743 insns
[i
++] = BPF_ZEXT_REG(R0
); /* Zext always inserted by verifier */
1744 insns
[i
++] = BPF_LDX_MEM(BPF_W
, R3
, R10
, -4);
1746 insns
[i
++] = BPF_JMP32_REG(BPF_JEQ
, R1
, R3
, 2);
1747 insns
[i
++] = BPF_MOV32_IMM(R0
, __LINE__
);
1748 insns
[i
++] = BPF_EXIT_INSN();
1750 insns
[i
++] = BPF_JMP_REG(BPF_JEQ
, R0
, R3
, 2);
1751 insns
[i
++] = BPF_MOV32_IMM(R0
, __LINE__
);
1752 insns
[i
++] = BPF_EXIT_INSN();
1754 /* Result successful */
1755 i
+= __bpf_ld_imm64(&insns
[i
], R0
, dst
);
1756 insns
[i
++] = BPF_ATOMIC_OP(BPF_W
, BPF_CMPXCHG
, R10
, R2
, -4);
1757 insns
[i
++] = BPF_ZEXT_REG(R0
); /* Zext always inserted by verifier */
1758 insns
[i
++] = BPF_LDX_MEM(BPF_W
, R3
, R10
, -4);
1760 insns
[i
++] = BPF_JMP32_REG(BPF_JEQ
, R2
, R3
, 2);
1761 insns
[i
++] = BPF_MOV32_IMM(R0
, __LINE__
);
1762 insns
[i
++] = BPF_EXIT_INSN();
1764 insns
[i
++] = BPF_JMP_REG(BPF_JEQ
, R0
, R1
, 2);
1765 insns
[i
++] = BPF_MOV32_IMM(R0
, __LINE__
);
1766 insns
[i
++] = BPF_EXIT_INSN();
1771 static int __bpf_fill_atomic64(struct bpf_test
*self
, int op
)
1773 return __bpf_fill_pattern(self
, &op
, 64, 64,
1775 &__bpf_emit_atomic64
);
1778 static int __bpf_fill_atomic32(struct bpf_test
*self
, int op
)
1780 return __bpf_fill_pattern(self
, &op
, 64, 64,
1782 &__bpf_emit_atomic32
);
1785 /* 64-bit atomic operations */
1786 static int bpf_fill_atomic64_add(struct bpf_test
*self
)
1788 return __bpf_fill_atomic64(self
, BPF_ADD
);
1791 static int bpf_fill_atomic64_and(struct bpf_test
*self
)
1793 return __bpf_fill_atomic64(self
, BPF_AND
);
1796 static int bpf_fill_atomic64_or(struct bpf_test
*self
)
1798 return __bpf_fill_atomic64(self
, BPF_OR
);
1801 static int bpf_fill_atomic64_xor(struct bpf_test
*self
)
1803 return __bpf_fill_atomic64(self
, BPF_XOR
);
1806 static int bpf_fill_atomic64_add_fetch(struct bpf_test
*self
)
1808 return __bpf_fill_atomic64(self
, BPF_ADD
| BPF_FETCH
);
1811 static int bpf_fill_atomic64_and_fetch(struct bpf_test
*self
)
1813 return __bpf_fill_atomic64(self
, BPF_AND
| BPF_FETCH
);
1816 static int bpf_fill_atomic64_or_fetch(struct bpf_test
*self
)
1818 return __bpf_fill_atomic64(self
, BPF_OR
| BPF_FETCH
);
1821 static int bpf_fill_atomic64_xor_fetch(struct bpf_test
*self
)
1823 return __bpf_fill_atomic64(self
, BPF_XOR
| BPF_FETCH
);
1826 static int bpf_fill_atomic64_xchg(struct bpf_test
*self
)
1828 return __bpf_fill_atomic64(self
, BPF_XCHG
);
1831 static int bpf_fill_cmpxchg64(struct bpf_test
*self
)
1833 return __bpf_fill_pattern(self
, NULL
, 64, 64, 0, PATTERN_BLOCK2
,
1834 &__bpf_emit_cmpxchg64
);
1837 /* 32-bit atomic operations */
1838 static int bpf_fill_atomic32_add(struct bpf_test
*self
)
1840 return __bpf_fill_atomic32(self
, BPF_ADD
);
1843 static int bpf_fill_atomic32_and(struct bpf_test
*self
)
1845 return __bpf_fill_atomic32(self
, BPF_AND
);
1848 static int bpf_fill_atomic32_or(struct bpf_test
*self
)
1850 return __bpf_fill_atomic32(self
, BPF_OR
);
1853 static int bpf_fill_atomic32_xor(struct bpf_test
*self
)
1855 return __bpf_fill_atomic32(self
, BPF_XOR
);
1858 static int bpf_fill_atomic32_add_fetch(struct bpf_test
*self
)
1860 return __bpf_fill_atomic32(self
, BPF_ADD
| BPF_FETCH
);
1863 static int bpf_fill_atomic32_and_fetch(struct bpf_test
*self
)
1865 return __bpf_fill_atomic32(self
, BPF_AND
| BPF_FETCH
);
1868 static int bpf_fill_atomic32_or_fetch(struct bpf_test
*self
)
1870 return __bpf_fill_atomic32(self
, BPF_OR
| BPF_FETCH
);
1873 static int bpf_fill_atomic32_xor_fetch(struct bpf_test
*self
)
1875 return __bpf_fill_atomic32(self
, BPF_XOR
| BPF_FETCH
);
1878 static int bpf_fill_atomic32_xchg(struct bpf_test
*self
)
1880 return __bpf_fill_atomic32(self
, BPF_XCHG
);
1883 static int bpf_fill_cmpxchg32(struct bpf_test
*self
)
1885 return __bpf_fill_pattern(self
, NULL
, 64, 64, 0, PATTERN_BLOCK2
,
1886 &__bpf_emit_cmpxchg32
);
1890 * Test JITs that implement ATOMIC operations as function calls or
1891 * other primitives, and must re-arrange operands for argument passing.
1893 static int __bpf_fill_atomic_reg_pairs(struct bpf_test
*self
, u8 width
, u8 op
)
1895 struct bpf_insn
*insn
;
1896 int len
= 2 + 34 * 10 * 10;
1900 insn
= kmalloc_array(len
, sizeof(*insn
), GFP_KERNEL
);
1904 /* Operand and memory values */
1905 if (width
== BPF_DW
) {
1906 mem
= 0x0123456789abcdefULL
;
1907 upd
= 0xfedcba9876543210ULL
;
1908 } else { /* BPF_W */
1913 /* Memory updated according to operation */
1922 __bpf_alu_result(&res
, mem
, upd
, BPF_OP(op
));
1925 /* Test all operand registers */
1926 for (rd
= R0
; rd
<= R9
; rd
++) {
1927 for (rs
= R0
; rs
<= R9
; rs
++) {
1930 /* Initialize value in memory */
1931 i
+= __bpf_ld_imm64(&insn
[i
], R0
, mem
);
1932 insn
[i
++] = BPF_STX_MEM(width
, R10
, R0
, -8);
1934 /* Initialize registers in order */
1935 i
+= __bpf_ld_imm64(&insn
[i
], R0
, ~mem
);
1936 i
+= __bpf_ld_imm64(&insn
[i
], rs
, upd
);
1937 insn
[i
++] = BPF_MOV64_REG(rd
, R10
);
1939 /* Perform atomic operation */
1940 insn
[i
++] = BPF_ATOMIC_OP(width
, op
, rd
, rs
, -8);
1941 if (op
== BPF_CMPXCHG
&& width
== BPF_W
)
1942 insn
[i
++] = BPF_ZEXT_REG(R0
);
1944 /* Check R0 register value */
1945 if (op
== BPF_CMPXCHG
)
1946 cmp
= mem
; /* Expect value from memory */
1947 else if (R0
== rd
|| R0
== rs
)
1948 cmp
= 0; /* Aliased, checked below */
1950 cmp
= ~mem
; /* Expect value to be preserved */
1952 insn
[i
++] = BPF_JMP32_IMM(BPF_JEQ
, R0
,
1954 insn
[i
++] = BPF_MOV32_IMM(R0
, __LINE__
);
1955 insn
[i
++] = BPF_EXIT_INSN();
1956 insn
[i
++] = BPF_ALU64_IMM(BPF_RSH
, R0
, 32);
1957 insn
[i
++] = BPF_JMP32_IMM(BPF_JEQ
, R0
,
1959 insn
[i
++] = BPF_MOV32_IMM(R0
, __LINE__
);
1960 insn
[i
++] = BPF_EXIT_INSN();
1963 /* Check source register value */
1964 if (rs
== R0
&& op
== BPF_CMPXCHG
)
1965 src
= 0; /* Aliased with R0, checked above */
1966 else if (rs
== rd
&& (op
== BPF_CMPXCHG
||
1968 src
= 0; /* Aliased with rd, checked below */
1969 else if (op
== BPF_CMPXCHG
)
1970 src
= upd
; /* Expect value to be preserved */
1971 else if (op
& BPF_FETCH
)
1972 src
= mem
; /* Expect fetched value from mem */
1974 src
= upd
; /* Expect value to be preserved */
1976 insn
[i
++] = BPF_JMP32_IMM(BPF_JEQ
, rs
,
1978 insn
[i
++] = BPF_MOV32_IMM(R0
, __LINE__
);
1979 insn
[i
++] = BPF_EXIT_INSN();
1980 insn
[i
++] = BPF_ALU64_IMM(BPF_RSH
, rs
, 32);
1981 insn
[i
++] = BPF_JMP32_IMM(BPF_JEQ
, rs
,
1983 insn
[i
++] = BPF_MOV32_IMM(R0
, __LINE__
);
1984 insn
[i
++] = BPF_EXIT_INSN();
1987 /* Check destination register value */
1988 if (!(rd
== R0
&& op
== BPF_CMPXCHG
) &&
1989 !(rd
== rs
&& (op
& BPF_FETCH
))) {
1990 insn
[i
++] = BPF_JMP_REG(BPF_JEQ
, rd
, R10
, 2);
1991 insn
[i
++] = BPF_MOV32_IMM(R0
, __LINE__
);
1992 insn
[i
++] = BPF_EXIT_INSN();
1995 /* Check value in memory */
1996 if (rs
!= rd
) { /* No aliasing */
1997 i
+= __bpf_ld_imm64(&insn
[i
], R1
, res
);
1998 } else if (op
== BPF_XCHG
) { /* Aliased, XCHG */
1999 insn
[i
++] = BPF_MOV64_REG(R1
, R10
);
2000 } else if (op
== BPF_CMPXCHG
) { /* Aliased, CMPXCHG */
2001 i
+= __bpf_ld_imm64(&insn
[i
], R1
, mem
);
2002 } else { /* Aliased, ALU oper */
2003 i
+= __bpf_ld_imm64(&insn
[i
], R1
, mem
);
2004 insn
[i
++] = BPF_ALU64_REG(BPF_OP(op
), R1
, R10
);
2007 insn
[i
++] = BPF_LDX_MEM(width
, R0
, R10
, -8);
2008 if (width
== BPF_DW
)
2009 insn
[i
++] = BPF_JMP_REG(BPF_JEQ
, R0
, R1
, 2);
2010 else /* width == BPF_W */
2011 insn
[i
++] = BPF_JMP32_REG(BPF_JEQ
, R0
, R1
, 2);
2012 insn
[i
++] = BPF_MOV32_IMM(R0
, __LINE__
);
2013 insn
[i
++] = BPF_EXIT_INSN();
2017 insn
[i
++] = BPF_MOV64_IMM(R0
, 1);
2018 insn
[i
++] = BPF_EXIT_INSN();
2020 self
->u
.ptr
.insns
= insn
;
2021 self
->u
.ptr
.len
= i
;
2027 /* 64-bit atomic register tests */
2028 static int bpf_fill_atomic64_add_reg_pairs(struct bpf_test
*self
)
2030 return __bpf_fill_atomic_reg_pairs(self
, BPF_DW
, BPF_ADD
);
2033 static int bpf_fill_atomic64_and_reg_pairs(struct bpf_test
*self
)
2035 return __bpf_fill_atomic_reg_pairs(self
, BPF_DW
, BPF_AND
);
2038 static int bpf_fill_atomic64_or_reg_pairs(struct bpf_test
*self
)
2040 return __bpf_fill_atomic_reg_pairs(self
, BPF_DW
, BPF_OR
);
2043 static int bpf_fill_atomic64_xor_reg_pairs(struct bpf_test
*self
)
2045 return __bpf_fill_atomic_reg_pairs(self
, BPF_DW
, BPF_XOR
);
2048 static int bpf_fill_atomic64_add_fetch_reg_pairs(struct bpf_test
*self
)
2050 return __bpf_fill_atomic_reg_pairs(self
, BPF_DW
, BPF_ADD
| BPF_FETCH
);
2053 static int bpf_fill_atomic64_and_fetch_reg_pairs(struct bpf_test
*self
)
2055 return __bpf_fill_atomic_reg_pairs(self
, BPF_DW
, BPF_AND
| BPF_FETCH
);
2058 static int bpf_fill_atomic64_or_fetch_reg_pairs(struct bpf_test
*self
)
2060 return __bpf_fill_atomic_reg_pairs(self
, BPF_DW
, BPF_OR
| BPF_FETCH
);
2063 static int bpf_fill_atomic64_xor_fetch_reg_pairs(struct bpf_test
*self
)
2065 return __bpf_fill_atomic_reg_pairs(self
, BPF_DW
, BPF_XOR
| BPF_FETCH
);
2068 static int bpf_fill_atomic64_xchg_reg_pairs(struct bpf_test
*self
)
2070 return __bpf_fill_atomic_reg_pairs(self
, BPF_DW
, BPF_XCHG
);
2073 static int bpf_fill_atomic64_cmpxchg_reg_pairs(struct bpf_test
*self
)
2075 return __bpf_fill_atomic_reg_pairs(self
, BPF_DW
, BPF_CMPXCHG
);
2078 /* 32-bit atomic register tests */
2079 static int bpf_fill_atomic32_add_reg_pairs(struct bpf_test
*self
)
2081 return __bpf_fill_atomic_reg_pairs(self
, BPF_W
, BPF_ADD
);
2084 static int bpf_fill_atomic32_and_reg_pairs(struct bpf_test
*self
)
2086 return __bpf_fill_atomic_reg_pairs(self
, BPF_W
, BPF_AND
);
2089 static int bpf_fill_atomic32_or_reg_pairs(struct bpf_test
*self
)
2091 return __bpf_fill_atomic_reg_pairs(self
, BPF_W
, BPF_OR
);
2094 static int bpf_fill_atomic32_xor_reg_pairs(struct bpf_test
*self
)
2096 return __bpf_fill_atomic_reg_pairs(self
, BPF_W
, BPF_XOR
);
2099 static int bpf_fill_atomic32_add_fetch_reg_pairs(struct bpf_test
*self
)
2101 return __bpf_fill_atomic_reg_pairs(self
, BPF_W
, BPF_ADD
| BPF_FETCH
);
2104 static int bpf_fill_atomic32_and_fetch_reg_pairs(struct bpf_test
*self
)
2106 return __bpf_fill_atomic_reg_pairs(self
, BPF_W
, BPF_AND
| BPF_FETCH
);
2109 static int bpf_fill_atomic32_or_fetch_reg_pairs(struct bpf_test
*self
)
2111 return __bpf_fill_atomic_reg_pairs(self
, BPF_W
, BPF_OR
| BPF_FETCH
);
2114 static int bpf_fill_atomic32_xor_fetch_reg_pairs(struct bpf_test
*self
)
2116 return __bpf_fill_atomic_reg_pairs(self
, BPF_W
, BPF_XOR
| BPF_FETCH
);
2119 static int bpf_fill_atomic32_xchg_reg_pairs(struct bpf_test
*self
)
2121 return __bpf_fill_atomic_reg_pairs(self
, BPF_W
, BPF_XCHG
);
2124 static int bpf_fill_atomic32_cmpxchg_reg_pairs(struct bpf_test
*self
)
2126 return __bpf_fill_atomic_reg_pairs(self
, BPF_W
, BPF_CMPXCHG
);
2130 * Test the two-instruction 64-bit immediate load operation for all
2131 * power-of-two magnitudes of the immediate operand. For each MSB, a block
2132 * of immediate values centered around the power-of-two MSB are tested,
2133 * both for positive and negative values. The test is designed to verify
2134 * the operation for JITs that emit different code depending on the magnitude
2135 * of the immediate value. This is often the case if the native instruction
2136 * immediate field width is narrower than 32 bits.
2138 static int bpf_fill_ld_imm64_magn(struct bpf_test
*self
)
2140 int block
= 64; /* Increase for more tests per MSB position */
2141 int len
= 3 + 8 * 63 * block
* 2;
2142 struct bpf_insn
*insn
;
2146 insn
= kmalloc_array(len
, sizeof(*insn
), GFP_KERNEL
);
2150 insn
[i
++] = BPF_ALU64_IMM(BPF_MOV
, R0
, 0);
2152 for (bit
= 0; bit
<= 62; bit
++) {
2153 for (adj
= -block
/ 2; adj
< block
/ 2; adj
++) {
2154 for (sign
= -1; sign
<= 1; sign
+= 2) {
2155 s64 imm
= sign
* ((1LL << bit
) + adj
);
2157 /* Perform operation */
2158 i
+= __bpf_ld_imm64(&insn
[i
], R1
, imm
);
2160 /* Load reference */
2161 insn
[i
++] = BPF_ALU32_IMM(BPF_MOV
, R2
, imm
);
2162 insn
[i
++] = BPF_ALU32_IMM(BPF_MOV
, R3
,
2164 insn
[i
++] = BPF_ALU64_IMM(BPF_LSH
, R3
, 32);
2165 insn
[i
++] = BPF_ALU64_REG(BPF_OR
, R2
, R3
);
2168 insn
[i
++] = BPF_JMP_REG(BPF_JEQ
, R1
, R2
, 1);
2169 insn
[i
++] = BPF_EXIT_INSN();
2174 insn
[i
++] = BPF_ALU64_IMM(BPF_MOV
, R0
, 1);
2175 insn
[i
++] = BPF_EXIT_INSN();
2177 self
->u
.ptr
.insns
= insn
;
2178 self
->u
.ptr
.len
= len
;
2185 * Test the two-instruction 64-bit immediate load operation for different
2186 * combinations of bytes. Each byte in the 64-bit word is constructed as
2187 * (base & mask) | (rand() & ~mask), where rand() is a deterministic LCG.
2188 * All patterns (base1, mask1) and (base2, mask2) bytes are tested.
2190 static int __bpf_fill_ld_imm64_bytes(struct bpf_test
*self
,
2194 struct bpf_insn
*insn
;
2195 int len
= 3 + 8 * BIT(8);
2200 insn
= kmalloc_array(len
, sizeof(*insn
), GFP_KERNEL
);
2204 insn
[i
++] = BPF_ALU64_IMM(BPF_MOV
, R0
, 0);
2206 for (pattern
= 0; pattern
< BIT(8); pattern
++) {
2209 for (index
= 0; index
< 8; index
++) {
2212 if (pattern
& BIT(index
))
2213 byte
= (base1
& mask1
) | (rand
& ~mask1
);
2215 byte
= (base2
& mask2
) | (rand
& ~mask2
);
2216 imm
= (imm
<< 8) | byte
;
2219 /* Update our LCG */
2220 rand
= rand
* 1664525 + 1013904223;
2222 /* Perform operation */
2223 i
+= __bpf_ld_imm64(&insn
[i
], R1
, imm
);
2225 /* Load reference */
2226 insn
[i
++] = BPF_ALU32_IMM(BPF_MOV
, R2
, imm
);
2227 insn
[i
++] = BPF_ALU32_IMM(BPF_MOV
, R3
, (u32
)(imm
>> 32));
2228 insn
[i
++] = BPF_ALU64_IMM(BPF_LSH
, R3
, 32);
2229 insn
[i
++] = BPF_ALU64_REG(BPF_OR
, R2
, R3
);
2232 insn
[i
++] = BPF_JMP_REG(BPF_JEQ
, R1
, R2
, 1);
2233 insn
[i
++] = BPF_EXIT_INSN();
2236 insn
[i
++] = BPF_ALU64_IMM(BPF_MOV
, R0
, 1);
2237 insn
[i
++] = BPF_EXIT_INSN();
2239 self
->u
.ptr
.insns
= insn
;
2240 self
->u
.ptr
.len
= len
;
2246 static int bpf_fill_ld_imm64_checker(struct bpf_test
*self
)
2248 return __bpf_fill_ld_imm64_bytes(self
, 0, 0xff, 0xff, 0xff);
2251 static int bpf_fill_ld_imm64_pos_neg(struct bpf_test
*self
)
2253 return __bpf_fill_ld_imm64_bytes(self
, 1, 0x81, 0x80, 0x80);
2256 static int bpf_fill_ld_imm64_pos_zero(struct bpf_test
*self
)
2258 return __bpf_fill_ld_imm64_bytes(self
, 1, 0x81, 0, 0xff);
2261 static int bpf_fill_ld_imm64_neg_zero(struct bpf_test
*self
)
2263 return __bpf_fill_ld_imm64_bytes(self
, 0x80, 0x80, 0, 0xff);
2267 * Exhaustive tests of JMP operations for all combinations of power-of-two
2268 * magnitudes of the operands, both for positive and negative values. The
2269 * test is designed to verify e.g. the JMP and JMP32 operations for JITs that
2270 * emit different code depending on the magnitude of the immediate value.
2273 static bool __bpf_match_jmp_cond(s64 v1
, s64 v2
, u8 op
)
2283 return (u64
)v1
> (u64
)v2
;
2285 return (u64
)v1
>= (u64
)v2
;
2287 return (u64
)v1
< (u64
)v2
;
2289 return (u64
)v1
<= (u64
)v2
;
2302 static int __bpf_emit_jmp_imm(struct bpf_test
*self
, void *arg
,
2303 struct bpf_insn
*insns
, s64 dst
, s64 imm
)
2305 int op
= *(int *)arg
;
2308 bool match
= __bpf_match_jmp_cond(dst
, (s32
)imm
, op
);
2311 insns
[i
++] = BPF_ALU32_IMM(BPF_MOV
, R0
, match
);
2313 i
+= __bpf_ld_imm64(&insns
[i
], R1
, dst
);
2314 insns
[i
++] = BPF_JMP_IMM(op
, R1
, imm
, 1);
2316 insns
[i
++] = BPF_JMP_IMM(BPF_JA
, 0, 0, 1);
2317 insns
[i
++] = BPF_EXIT_INSN();
2325 static int __bpf_emit_jmp32_imm(struct bpf_test
*self
, void *arg
,
2326 struct bpf_insn
*insns
, s64 dst
, s64 imm
)
2328 int op
= *(int *)arg
;
2331 bool match
= __bpf_match_jmp_cond((s32
)dst
, (s32
)imm
, op
);
2334 i
+= __bpf_ld_imm64(&insns
[i
], R1
, dst
);
2335 insns
[i
++] = BPF_JMP32_IMM(op
, R1
, imm
, 1);
2337 insns
[i
++] = BPF_JMP_IMM(BPF_JA
, 0, 0, 1);
2338 insns
[i
++] = BPF_EXIT_INSN();
2346 static int __bpf_emit_jmp_reg(struct bpf_test
*self
, void *arg
,
2347 struct bpf_insn
*insns
, s64 dst
, s64 src
)
2349 int op
= *(int *)arg
;
2352 bool match
= __bpf_match_jmp_cond(dst
, src
, op
);
2355 i
+= __bpf_ld_imm64(&insns
[i
], R1
, dst
);
2356 i
+= __bpf_ld_imm64(&insns
[i
], R2
, src
);
2357 insns
[i
++] = BPF_JMP_REG(op
, R1
, R2
, 1);
2359 insns
[i
++] = BPF_JMP_IMM(BPF_JA
, 0, 0, 1);
2360 insns
[i
++] = BPF_EXIT_INSN();
2368 static int __bpf_emit_jmp32_reg(struct bpf_test
*self
, void *arg
,
2369 struct bpf_insn
*insns
, s64 dst
, s64 src
)
2371 int op
= *(int *)arg
;
2374 bool match
= __bpf_match_jmp_cond((s32
)dst
, (s32
)src
, op
);
2377 i
+= __bpf_ld_imm64(&insns
[i
], R1
, dst
);
2378 i
+= __bpf_ld_imm64(&insns
[i
], R2
, src
);
2379 insns
[i
++] = BPF_JMP32_REG(op
, R1
, R2
, 1);
2381 insns
[i
++] = BPF_JMP_IMM(BPF_JA
, 0, 0, 1);
2382 insns
[i
++] = BPF_EXIT_INSN();
2390 static int __bpf_fill_jmp_imm(struct bpf_test
*self
, int op
)
2392 return __bpf_fill_pattern(self
, &op
, 64, 32,
2393 PATTERN_BLOCK1
, PATTERN_BLOCK2
,
2394 &__bpf_emit_jmp_imm
);
2397 static int __bpf_fill_jmp32_imm(struct bpf_test
*self
, int op
)
2399 return __bpf_fill_pattern(self
, &op
, 64, 32,
2400 PATTERN_BLOCK1
, PATTERN_BLOCK2
,
2401 &__bpf_emit_jmp32_imm
);
2404 static int __bpf_fill_jmp_reg(struct bpf_test
*self
, int op
)
2406 return __bpf_fill_pattern(self
, &op
, 64, 64,
2407 PATTERN_BLOCK1
, PATTERN_BLOCK2
,
2408 &__bpf_emit_jmp_reg
);
2411 static int __bpf_fill_jmp32_reg(struct bpf_test
*self
, int op
)
2413 return __bpf_fill_pattern(self
, &op
, 64, 64,
2414 PATTERN_BLOCK1
, PATTERN_BLOCK2
,
2415 &__bpf_emit_jmp32_reg
);
2418 /* JMP immediate tests */
2419 static int bpf_fill_jmp_jset_imm(struct bpf_test
*self
)
2421 return __bpf_fill_jmp_imm(self
, BPF_JSET
);
2424 static int bpf_fill_jmp_jeq_imm(struct bpf_test
*self
)
2426 return __bpf_fill_jmp_imm(self
, BPF_JEQ
);
2429 static int bpf_fill_jmp_jne_imm(struct bpf_test
*self
)
2431 return __bpf_fill_jmp_imm(self
, BPF_JNE
);
2434 static int bpf_fill_jmp_jgt_imm(struct bpf_test
*self
)
2436 return __bpf_fill_jmp_imm(self
, BPF_JGT
);
2439 static int bpf_fill_jmp_jge_imm(struct bpf_test
*self
)
2441 return __bpf_fill_jmp_imm(self
, BPF_JGE
);
2444 static int bpf_fill_jmp_jlt_imm(struct bpf_test
*self
)
2446 return __bpf_fill_jmp_imm(self
, BPF_JLT
);
2449 static int bpf_fill_jmp_jle_imm(struct bpf_test
*self
)
2451 return __bpf_fill_jmp_imm(self
, BPF_JLE
);
2454 static int bpf_fill_jmp_jsgt_imm(struct bpf_test
*self
)
2456 return __bpf_fill_jmp_imm(self
, BPF_JSGT
);
2459 static int bpf_fill_jmp_jsge_imm(struct bpf_test
*self
)
2461 return __bpf_fill_jmp_imm(self
, BPF_JSGE
);
2464 static int bpf_fill_jmp_jslt_imm(struct bpf_test
*self
)
2466 return __bpf_fill_jmp_imm(self
, BPF_JSLT
);
2469 static int bpf_fill_jmp_jsle_imm(struct bpf_test
*self
)
2471 return __bpf_fill_jmp_imm(self
, BPF_JSLE
);
2474 /* JMP32 immediate tests */
2475 static int bpf_fill_jmp32_jset_imm(struct bpf_test
*self
)
2477 return __bpf_fill_jmp32_imm(self
, BPF_JSET
);
2480 static int bpf_fill_jmp32_jeq_imm(struct bpf_test
*self
)
2482 return __bpf_fill_jmp32_imm(self
, BPF_JEQ
);
2485 static int bpf_fill_jmp32_jne_imm(struct bpf_test
*self
)
2487 return __bpf_fill_jmp32_imm(self
, BPF_JNE
);
2490 static int bpf_fill_jmp32_jgt_imm(struct bpf_test
*self
)
2492 return __bpf_fill_jmp32_imm(self
, BPF_JGT
);
2495 static int bpf_fill_jmp32_jge_imm(struct bpf_test
*self
)
2497 return __bpf_fill_jmp32_imm(self
, BPF_JGE
);
2500 static int bpf_fill_jmp32_jlt_imm(struct bpf_test
*self
)
2502 return __bpf_fill_jmp32_imm(self
, BPF_JLT
);
2505 static int bpf_fill_jmp32_jle_imm(struct bpf_test
*self
)
2507 return __bpf_fill_jmp32_imm(self
, BPF_JLE
);
2510 static int bpf_fill_jmp32_jsgt_imm(struct bpf_test
*self
)
2512 return __bpf_fill_jmp32_imm(self
, BPF_JSGT
);
2515 static int bpf_fill_jmp32_jsge_imm(struct bpf_test
*self
)
2517 return __bpf_fill_jmp32_imm(self
, BPF_JSGE
);
2520 static int bpf_fill_jmp32_jslt_imm(struct bpf_test
*self
)
2522 return __bpf_fill_jmp32_imm(self
, BPF_JSLT
);
2525 static int bpf_fill_jmp32_jsle_imm(struct bpf_test
*self
)
2527 return __bpf_fill_jmp32_imm(self
, BPF_JSLE
);
2530 /* JMP register tests */
2531 static int bpf_fill_jmp_jset_reg(struct bpf_test
*self
)
2533 return __bpf_fill_jmp_reg(self
, BPF_JSET
);
2536 static int bpf_fill_jmp_jeq_reg(struct bpf_test
*self
)
2538 return __bpf_fill_jmp_reg(self
, BPF_JEQ
);
2541 static int bpf_fill_jmp_jne_reg(struct bpf_test
*self
)
2543 return __bpf_fill_jmp_reg(self
, BPF_JNE
);
2546 static int bpf_fill_jmp_jgt_reg(struct bpf_test
*self
)
2548 return __bpf_fill_jmp_reg(self
, BPF_JGT
);
2551 static int bpf_fill_jmp_jge_reg(struct bpf_test
*self
)
2553 return __bpf_fill_jmp_reg(self
, BPF_JGE
);
2556 static int bpf_fill_jmp_jlt_reg(struct bpf_test
*self
)
2558 return __bpf_fill_jmp_reg(self
, BPF_JLT
);
2561 static int bpf_fill_jmp_jle_reg(struct bpf_test
*self
)
2563 return __bpf_fill_jmp_reg(self
, BPF_JLE
);
2566 static int bpf_fill_jmp_jsgt_reg(struct bpf_test
*self
)
2568 return __bpf_fill_jmp_reg(self
, BPF_JSGT
);
2571 static int bpf_fill_jmp_jsge_reg(struct bpf_test
*self
)
2573 return __bpf_fill_jmp_reg(self
, BPF_JSGE
);
2576 static int bpf_fill_jmp_jslt_reg(struct bpf_test
*self
)
2578 return __bpf_fill_jmp_reg(self
, BPF_JSLT
);
2581 static int bpf_fill_jmp_jsle_reg(struct bpf_test
*self
)
2583 return __bpf_fill_jmp_reg(self
, BPF_JSLE
);
2586 /* JMP32 register tests */
2587 static int bpf_fill_jmp32_jset_reg(struct bpf_test
*self
)
2589 return __bpf_fill_jmp32_reg(self
, BPF_JSET
);
2592 static int bpf_fill_jmp32_jeq_reg(struct bpf_test
*self
)
2594 return __bpf_fill_jmp32_reg(self
, BPF_JEQ
);
2597 static int bpf_fill_jmp32_jne_reg(struct bpf_test
*self
)
2599 return __bpf_fill_jmp32_reg(self
, BPF_JNE
);
2602 static int bpf_fill_jmp32_jgt_reg(struct bpf_test
*self
)
2604 return __bpf_fill_jmp32_reg(self
, BPF_JGT
);
2607 static int bpf_fill_jmp32_jge_reg(struct bpf_test
*self
)
2609 return __bpf_fill_jmp32_reg(self
, BPF_JGE
);
2612 static int bpf_fill_jmp32_jlt_reg(struct bpf_test
*self
)
2614 return __bpf_fill_jmp32_reg(self
, BPF_JLT
);
2617 static int bpf_fill_jmp32_jle_reg(struct bpf_test
*self
)
2619 return __bpf_fill_jmp32_reg(self
, BPF_JLE
);
2622 static int bpf_fill_jmp32_jsgt_reg(struct bpf_test
*self
)
2624 return __bpf_fill_jmp32_reg(self
, BPF_JSGT
);
2627 static int bpf_fill_jmp32_jsge_reg(struct bpf_test
*self
)
2629 return __bpf_fill_jmp32_reg(self
, BPF_JSGE
);
2632 static int bpf_fill_jmp32_jslt_reg(struct bpf_test
*self
)
2634 return __bpf_fill_jmp32_reg(self
, BPF_JSLT
);
2637 static int bpf_fill_jmp32_jsle_reg(struct bpf_test
*self
)
2639 return __bpf_fill_jmp32_reg(self
, BPF_JSLE
);
2643 * Set up a sequence of staggered jumps, forwards and backwards with
2644 * increasing offset. This tests the conversion of relative jumps to
2645 * JITed native jumps. On some architectures, for example MIPS, a large
2646 * PC-relative jump offset may overflow the immediate field of the native
2647 * conditional branch instruction, triggering a conversion to use an
2648 * absolute jump instead. Since this changes the jump offsets, another
2649 * offset computation pass is necessary, and that may in turn trigger
2650 * another branch conversion. This jump sequence is particularly nasty
2653 * The sequence generation is parameterized by size and jump type.
2654 * The size must be even, and the expected result is always size + 1.
2655 * Below is an example with size=8 and result=9.
2657 * ________________________Start
2661 * ,------- JMP +4 * 3______________Preamble: 4 insns
2662 * ,----------|-ind 0- if R0 != 7 JMP 8 * 3 + 1 <--------------------.
2664 * | | JMP +7 * 3 ------------------------.
2665 * | ,--------|-----1- if R0 != 5 JMP 7 * 3 + 1 <--------------. | |
2666 * | | | R0 = 6 | | |
2667 * | | | JMP +5 * 3 ------------------. | |
2668 * | | ,------|-----2- if R0 != 3 JMP 6 * 3 + 1 <--------. | | | |
2669 * | | | | R0 = 4 | | | | |
2670 * | | | | JMP +3 * 3 ------------. | | | |
2671 * | | | ,----|-----3- if R0 != 1 JMP 5 * 3 + 1 <--. | | | | | |
2672 * | | | | | R0 = 2 | | | | | | |
2673 * | | | | | JMP +1 * 3 ------. | | | | | |
2674 * | | | | ,--t=====4> if R0 != 0 JMP 4 * 3 + 1 1 2 3 4 5 6 7 8 loc
2675 * | | | | | R0 = 1 -1 +2 -3 +4 -5 +6 -7 +8 off
2676 * | | | | | JMP -2 * 3 ---' | | | | | | |
2677 * | | | | | ,------5- if R0 != 2 JMP 3 * 3 + 1 <-----' | | | | | |
2678 * | | | | | | R0 = 3 | | | | | |
2679 * | | | | | | JMP -4 * 3 ---------' | | | | |
2680 * | | | | | | ,----6- if R0 != 4 JMP 2 * 3 + 1 <-----------' | | | |
2681 * | | | | | | | R0 = 5 | | | |
2682 * | | | | | | | JMP -6 * 3 ---------------' | | |
2683 * | | | | | | | ,--7- if R0 != 6 JMP 1 * 3 + 1 <-----------------' | |
2684 * | | | | | | | | R0 = 7 | |
2685 * | | Error | | | JMP -8 * 3 ---------------------' |
2686 * | | paths | | | ,8- if R0 != 8 JMP 0 * 3 + 1 <-----------------------'
2687 * | | | | | | | | | R0 = 9__________________Sequence: 3 * size - 1 insns
2688 * `-+-+-+-+-+-+-+-+-> EXIT____________________Return: 1 insn
2692 /* The maximum size parameter */
2693 #define MAX_STAGGERED_JMP_SIZE ((0x7fff / 3) & ~1)
2695 /* We use a reduced number of iterations to get a reasonable execution time */
2696 #define NR_STAGGERED_JMP_RUNS 10
2698 static int __bpf_fill_staggered_jumps(struct bpf_test
*self
,
2699 const struct bpf_insn
*jmp
,
2702 int size
= self
->test
[0].result
- 1;
2703 int len
= 4 + 3 * (size
+ 1);
2704 struct bpf_insn
*insns
;
2707 insns
= kmalloc_array(len
, sizeof(*insns
), GFP_KERNEL
);
2712 insns
[0] = BPF_ALU64_IMM(BPF_MOV
, R0
, 0);
2713 insns
[1] = BPF_ALU64_IMM(BPF_MOV
, R1
, r1
);
2714 insns
[2] = BPF_ALU64_IMM(BPF_MOV
, R2
, r2
);
2715 insns
[3] = BPF_JMP_IMM(BPF_JA
, 0, 0, 3 * size
/ 2);
2718 for (ind
= 0, off
= size
; ind
<= size
; ind
++, off
-= 2) {
2719 struct bpf_insn
*ins
= &insns
[4 + 3 * ind
];
2726 ins
[0] = BPF_JMP_IMM(BPF_JNE
, R0
, loc
- 1,
2727 3 * (size
- ind
) + 1);
2728 ins
[1] = BPF_ALU64_IMM(BPF_MOV
, R0
, loc
);
2730 ins
[2].off
= 3 * (off
- 1);
2734 insns
[len
- 1] = BPF_EXIT_INSN();
2736 self
->u
.ptr
.insns
= insns
;
2737 self
->u
.ptr
.len
= len
;
2742 /* 64-bit unconditional jump */
2743 static int bpf_fill_staggered_ja(struct bpf_test
*self
)
2745 struct bpf_insn jmp
= BPF_JMP_IMM(BPF_JA
, 0, 0, 0);
2747 return __bpf_fill_staggered_jumps(self
, &jmp
, 0, 0);
2750 /* 64-bit immediate jumps */
2751 static int bpf_fill_staggered_jeq_imm(struct bpf_test
*self
)
2753 struct bpf_insn jmp
= BPF_JMP_IMM(BPF_JEQ
, R1
, 1234, 0);
2755 return __bpf_fill_staggered_jumps(self
, &jmp
, 1234, 0);
2758 static int bpf_fill_staggered_jne_imm(struct bpf_test
*self
)
2760 struct bpf_insn jmp
= BPF_JMP_IMM(BPF_JNE
, R1
, 1234, 0);
2762 return __bpf_fill_staggered_jumps(self
, &jmp
, 4321, 0);
2765 static int bpf_fill_staggered_jset_imm(struct bpf_test
*self
)
2767 struct bpf_insn jmp
= BPF_JMP_IMM(BPF_JSET
, R1
, 0x82, 0);
2769 return __bpf_fill_staggered_jumps(self
, &jmp
, 0x86, 0);
2772 static int bpf_fill_staggered_jgt_imm(struct bpf_test
*self
)
2774 struct bpf_insn jmp
= BPF_JMP_IMM(BPF_JGT
, R1
, 1234, 0);
2776 return __bpf_fill_staggered_jumps(self
, &jmp
, 0x80000000, 0);
2779 static int bpf_fill_staggered_jge_imm(struct bpf_test
*self
)
2781 struct bpf_insn jmp
= BPF_JMP_IMM(BPF_JGE
, R1
, 1234, 0);
2783 return __bpf_fill_staggered_jumps(self
, &jmp
, 1234, 0);
2786 static int bpf_fill_staggered_jlt_imm(struct bpf_test
*self
)
2788 struct bpf_insn jmp
= BPF_JMP_IMM(BPF_JLT
, R1
, 0x80000000, 0);
2790 return __bpf_fill_staggered_jumps(self
, &jmp
, 1234, 0);
2793 static int bpf_fill_staggered_jle_imm(struct bpf_test
*self
)
2795 struct bpf_insn jmp
= BPF_JMP_IMM(BPF_JLE
, R1
, 1234, 0);
2797 return __bpf_fill_staggered_jumps(self
, &jmp
, 1234, 0);
2800 static int bpf_fill_staggered_jsgt_imm(struct bpf_test
*self
)
2802 struct bpf_insn jmp
= BPF_JMP_IMM(BPF_JSGT
, R1
, -2, 0);
2804 return __bpf_fill_staggered_jumps(self
, &jmp
, -1, 0);
2807 static int bpf_fill_staggered_jsge_imm(struct bpf_test
*self
)
2809 struct bpf_insn jmp
= BPF_JMP_IMM(BPF_JSGE
, R1
, -2, 0);
2811 return __bpf_fill_staggered_jumps(self
, &jmp
, -2, 0);
2814 static int bpf_fill_staggered_jslt_imm(struct bpf_test
*self
)
2816 struct bpf_insn jmp
= BPF_JMP_IMM(BPF_JSLT
, R1
, -1, 0);
2818 return __bpf_fill_staggered_jumps(self
, &jmp
, -2, 0);
2821 static int bpf_fill_staggered_jsle_imm(struct bpf_test
*self
)
2823 struct bpf_insn jmp
= BPF_JMP_IMM(BPF_JSLE
, R1
, -1, 0);
2825 return __bpf_fill_staggered_jumps(self
, &jmp
, -1, 0);
2828 /* 64-bit register jumps */
2829 static int bpf_fill_staggered_jeq_reg(struct bpf_test
*self
)
2831 struct bpf_insn jmp
= BPF_JMP_REG(BPF_JEQ
, R1
, R2
, 0);
2833 return __bpf_fill_staggered_jumps(self
, &jmp
, 1234, 1234);
2836 static int bpf_fill_staggered_jne_reg(struct bpf_test
*self
)
2838 struct bpf_insn jmp
= BPF_JMP_REG(BPF_JNE
, R1
, R2
, 0);
2840 return __bpf_fill_staggered_jumps(self
, &jmp
, 4321, 1234);
2843 static int bpf_fill_staggered_jset_reg(struct bpf_test
*self
)
2845 struct bpf_insn jmp
= BPF_JMP_REG(BPF_JSET
, R1
, R2
, 0);
2847 return __bpf_fill_staggered_jumps(self
, &jmp
, 0x86, 0x82);
2850 static int bpf_fill_staggered_jgt_reg(struct bpf_test
*self
)
2852 struct bpf_insn jmp
= BPF_JMP_REG(BPF_JGT
, R1
, R2
, 0);
2854 return __bpf_fill_staggered_jumps(self
, &jmp
, 0x80000000, 1234);
2857 static int bpf_fill_staggered_jge_reg(struct bpf_test
*self
)
2859 struct bpf_insn jmp
= BPF_JMP_REG(BPF_JGE
, R1
, R2
, 0);
2861 return __bpf_fill_staggered_jumps(self
, &jmp
, 1234, 1234);
2864 static int bpf_fill_staggered_jlt_reg(struct bpf_test
*self
)
2866 struct bpf_insn jmp
= BPF_JMP_REG(BPF_JLT
, R1
, R2
, 0);
2868 return __bpf_fill_staggered_jumps(self
, &jmp
, 1234, 0x80000000);
2871 static int bpf_fill_staggered_jle_reg(struct bpf_test
*self
)
2873 struct bpf_insn jmp
= BPF_JMP_REG(BPF_JLE
, R1
, R2
, 0);
2875 return __bpf_fill_staggered_jumps(self
, &jmp
, 1234, 1234);
2878 static int bpf_fill_staggered_jsgt_reg(struct bpf_test
*self
)
2880 struct bpf_insn jmp
= BPF_JMP_REG(BPF_JSGT
, R1
, R2
, 0);
2882 return __bpf_fill_staggered_jumps(self
, &jmp
, -1, -2);
2885 static int bpf_fill_staggered_jsge_reg(struct bpf_test
*self
)
2887 struct bpf_insn jmp
= BPF_JMP_REG(BPF_JSGE
, R1
, R2
, 0);
2889 return __bpf_fill_staggered_jumps(self
, &jmp
, -2, -2);
2892 static int bpf_fill_staggered_jslt_reg(struct bpf_test
*self
)
2894 struct bpf_insn jmp
= BPF_JMP_REG(BPF_JSLT
, R1
, R2
, 0);
2896 return __bpf_fill_staggered_jumps(self
, &jmp
, -2, -1);
2899 static int bpf_fill_staggered_jsle_reg(struct bpf_test
*self
)
2901 struct bpf_insn jmp
= BPF_JMP_REG(BPF_JSLE
, R1
, R2
, 0);
2903 return __bpf_fill_staggered_jumps(self
, &jmp
, -1, -1);
2906 /* 32-bit immediate jumps */
2907 static int bpf_fill_staggered_jeq32_imm(struct bpf_test
*self
)
2909 struct bpf_insn jmp
= BPF_JMP32_IMM(BPF_JEQ
, R1
, 1234, 0);
2911 return __bpf_fill_staggered_jumps(self
, &jmp
, 1234, 0);
2914 static int bpf_fill_staggered_jne32_imm(struct bpf_test
*self
)
2916 struct bpf_insn jmp
= BPF_JMP32_IMM(BPF_JNE
, R1
, 1234, 0);
2918 return __bpf_fill_staggered_jumps(self
, &jmp
, 4321, 0);
2921 static int bpf_fill_staggered_jset32_imm(struct bpf_test
*self
)
2923 struct bpf_insn jmp
= BPF_JMP32_IMM(BPF_JSET
, R1
, 0x82, 0);
2925 return __bpf_fill_staggered_jumps(self
, &jmp
, 0x86, 0);
2928 static int bpf_fill_staggered_jgt32_imm(struct bpf_test
*self
)
2930 struct bpf_insn jmp
= BPF_JMP32_IMM(BPF_JGT
, R1
, 1234, 0);
2932 return __bpf_fill_staggered_jumps(self
, &jmp
, 0x80000000, 0);
2935 static int bpf_fill_staggered_jge32_imm(struct bpf_test
*self
)
2937 struct bpf_insn jmp
= BPF_JMP32_IMM(BPF_JGE
, R1
, 1234, 0);
2939 return __bpf_fill_staggered_jumps(self
, &jmp
, 1234, 0);
2942 static int bpf_fill_staggered_jlt32_imm(struct bpf_test
*self
)
2944 struct bpf_insn jmp
= BPF_JMP32_IMM(BPF_JLT
, R1
, 0x80000000, 0);
2946 return __bpf_fill_staggered_jumps(self
, &jmp
, 1234, 0);
2949 static int bpf_fill_staggered_jle32_imm(struct bpf_test
*self
)
2951 struct bpf_insn jmp
= BPF_JMP32_IMM(BPF_JLE
, R1
, 1234, 0);
2953 return __bpf_fill_staggered_jumps(self
, &jmp
, 1234, 0);
2956 static int bpf_fill_staggered_jsgt32_imm(struct bpf_test
*self
)
2958 struct bpf_insn jmp
= BPF_JMP32_IMM(BPF_JSGT
, R1
, -2, 0);
2960 return __bpf_fill_staggered_jumps(self
, &jmp
, -1, 0);
2963 static int bpf_fill_staggered_jsge32_imm(struct bpf_test
*self
)
2965 struct bpf_insn jmp
= BPF_JMP32_IMM(BPF_JSGE
, R1
, -2, 0);
2967 return __bpf_fill_staggered_jumps(self
, &jmp
, -2, 0);
2970 static int bpf_fill_staggered_jslt32_imm(struct bpf_test
*self
)
2972 struct bpf_insn jmp
= BPF_JMP32_IMM(BPF_JSLT
, R1
, -1, 0);
2974 return __bpf_fill_staggered_jumps(self
, &jmp
, -2, 0);
2977 static int bpf_fill_staggered_jsle32_imm(struct bpf_test
*self
)
2979 struct bpf_insn jmp
= BPF_JMP32_IMM(BPF_JSLE
, R1
, -1, 0);
2981 return __bpf_fill_staggered_jumps(self
, &jmp
, -1, 0);
2984 /* 32-bit register jumps */
2985 static int bpf_fill_staggered_jeq32_reg(struct bpf_test
*self
)
2987 struct bpf_insn jmp
= BPF_JMP32_REG(BPF_JEQ
, R1
, R2
, 0);
2989 return __bpf_fill_staggered_jumps(self
, &jmp
, 1234, 1234);
2992 static int bpf_fill_staggered_jne32_reg(struct bpf_test
*self
)
2994 struct bpf_insn jmp
= BPF_JMP32_REG(BPF_JNE
, R1
, R2
, 0);
2996 return __bpf_fill_staggered_jumps(self
, &jmp
, 4321, 1234);
2999 static int bpf_fill_staggered_jset32_reg(struct bpf_test
*self
)
3001 struct bpf_insn jmp
= BPF_JMP32_REG(BPF_JSET
, R1
, R2
, 0);
3003 return __bpf_fill_staggered_jumps(self
, &jmp
, 0x86, 0x82);
3006 static int bpf_fill_staggered_jgt32_reg(struct bpf_test
*self
)
3008 struct bpf_insn jmp
= BPF_JMP32_REG(BPF_JGT
, R1
, R2
, 0);
3010 return __bpf_fill_staggered_jumps(self
, &jmp
, 0x80000000, 1234);
3013 static int bpf_fill_staggered_jge32_reg(struct bpf_test
*self
)
3015 struct bpf_insn jmp
= BPF_JMP32_REG(BPF_JGE
, R1
, R2
, 0);
3017 return __bpf_fill_staggered_jumps(self
, &jmp
, 1234, 1234);
3020 static int bpf_fill_staggered_jlt32_reg(struct bpf_test
*self
)
3022 struct bpf_insn jmp
= BPF_JMP32_REG(BPF_JLT
, R1
, R2
, 0);
3024 return __bpf_fill_staggered_jumps(self
, &jmp
, 1234, 0x80000000);
3027 static int bpf_fill_staggered_jle32_reg(struct bpf_test
*self
)
3029 struct bpf_insn jmp
= BPF_JMP32_REG(BPF_JLE
, R1
, R2
, 0);
3031 return __bpf_fill_staggered_jumps(self
, &jmp
, 1234, 1234);
3034 static int bpf_fill_staggered_jsgt32_reg(struct bpf_test
*self
)
3036 struct bpf_insn jmp
= BPF_JMP32_REG(BPF_JSGT
, R1
, R2
, 0);
3038 return __bpf_fill_staggered_jumps(self
, &jmp
, -1, -2);
3041 static int bpf_fill_staggered_jsge32_reg(struct bpf_test
*self
)
3043 struct bpf_insn jmp
= BPF_JMP32_REG(BPF_JSGE
, R1
, R2
, 0);
3045 return __bpf_fill_staggered_jumps(self
, &jmp
, -2, -2);
3048 static int bpf_fill_staggered_jslt32_reg(struct bpf_test
*self
)
3050 struct bpf_insn jmp
= BPF_JMP32_REG(BPF_JSLT
, R1
, R2
, 0);
3052 return __bpf_fill_staggered_jumps(self
, &jmp
, -2, -1);
3055 static int bpf_fill_staggered_jsle32_reg(struct bpf_test
*self
)
3057 struct bpf_insn jmp
= BPF_JMP32_REG(BPF_JSLE
, R1
, R2
, 0);
3059 return __bpf_fill_staggered_jumps(self
, &jmp
, -1, -1);
3063 static struct bpf_test tests
[] = {
3067 BPF_STMT(BPF_LD
| BPF_IMM
, 1),
3068 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
3069 BPF_STMT(BPF_LD
| BPF_IMM
, 2),
3070 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
3071 BPF_STMT(BPF_ALU
| BPF_NEG
, 0), /* A == -3 */
3072 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
3073 BPF_STMT(BPF_LD
| BPF_LEN
, 0),
3074 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
3075 BPF_STMT(BPF_MISC
| BPF_TAX
, 0), /* X == len - 3 */
3076 BPF_STMT(BPF_LD
| BPF_B
| BPF_IND
, 1),
3077 BPF_STMT(BPF_RET
| BPF_A
, 0)
3080 { 10, 20, 30, 40, 50 },
3081 { { 2, 10 }, { 3, 20 }, { 4, 30 } },
3086 BPF_STMT(BPF_LDX
| BPF_LEN
, 0),
3087 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
3088 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
3089 BPF_STMT(BPF_RET
| BPF_A
, 0) /* A == len * 2 */
3092 { 10, 20, 30, 40, 50 },
3093 { { 1, 2 }, { 3, 6 }, { 4, 8 } },
3098 BPF_STMT(BPF_LD
| BPF_IMM
, 1),
3099 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 2),
3100 BPF_STMT(BPF_LDX
| BPF_IMM
, 3),
3101 BPF_STMT(BPF_ALU
| BPF_SUB
| BPF_X
, 0),
3102 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 0xffffffff),
3103 BPF_STMT(BPF_ALU
| BPF_MUL
| BPF_K
, 3),
3104 BPF_STMT(BPF_RET
| BPF_A
, 0)
3106 CLASSIC
| FLAG_NO_DATA
,
3108 { { 0, 0xfffffffd } }
3113 BPF_STMT(BPF_LD
| BPF_IMM
, 8),
3114 BPF_STMT(BPF_ALU
| BPF_DIV
| BPF_K
, 2),
3115 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
3116 BPF_STMT(BPF_LD
| BPF_IMM
, 0xffffffff),
3117 BPF_STMT(BPF_ALU
| BPF_DIV
| BPF_X
, 0),
3118 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
3119 BPF_STMT(BPF_LD
| BPF_IMM
, 0xffffffff),
3120 BPF_STMT(BPF_ALU
| BPF_DIV
| BPF_K
, 0x70000000),
3121 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
3122 BPF_STMT(BPF_LD
| BPF_IMM
, 0xffffffff),
3123 BPF_STMT(BPF_ALU
| BPF_MOD
| BPF_X
, 0),
3124 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
3125 BPF_STMT(BPF_LD
| BPF_IMM
, 0xffffffff),
3126 BPF_STMT(BPF_ALU
| BPF_MOD
| BPF_K
, 0x70000000),
3127 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
3128 BPF_STMT(BPF_RET
| BPF_A
, 0)
3130 CLASSIC
| FLAG_NO_DATA
,
3132 { { 0, 0x20000000 } }
3137 BPF_STMT(BPF_LD
| BPF_IMM
, 0xff),
3138 BPF_STMT(BPF_ALU
| BPF_AND
| BPF_K
, 0xf0),
3139 BPF_STMT(BPF_ALU
| BPF_LSH
| BPF_K
, 27),
3140 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
3141 BPF_STMT(BPF_LD
| BPF_IMM
, 0xf),
3142 BPF_STMT(BPF_ALU
| BPF_OR
| BPF_K
, 0xf0),
3143 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
3144 BPF_STMT(BPF_RET
| BPF_A
, 0)
3146 CLASSIC
| FLAG_NO_DATA
,
3148 { { 0, 0x800000ff }, { 1, 0x800000ff } },
3153 BPF_STMT(BPF_LD
| BPF_IMM
, 0), /* ld #0 */
3154 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 0, 1, 0),
3155 BPF_STMT(BPF_RET
| BPF_K
, 0),
3156 BPF_STMT(BPF_RET
| BPF_K
, 1),
3165 BPF_STMT(BPF_LDX
| BPF_LEN
, 0),
3166 BPF_STMT(BPF_LD
| BPF_H
| BPF_IND
, MAX_K
),
3167 BPF_STMT(BPF_RET
| BPF_K
, 1)
3171 { { 1, 0 }, { 10, 0 }, { 60, 0 } },
3176 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
, 1000),
3177 BPF_STMT(BPF_RET
| BPF_K
, 1)
3181 { { 1, 0 }, { 10, 0 }, { 60, 0 } },
3186 BPF_STMT(BPF_LD
| BPF_B
| BPF_ABS
, SKF_LL_OFF
),
3187 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
3188 BPF_STMT(BPF_LD
| BPF_B
| BPF_ABS
, SKF_LL_OFF
+ 1),
3189 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
3190 BPF_STMT(BPF_RET
| BPF_A
, 0)
3194 { { 1, 0 }, { 2, 3 } },
3199 BPF_STMT(BPF_LD
| BPF_IMM
, SKF_LL_OFF
- 1),
3200 BPF_STMT(BPF_LDX
| BPF_LEN
, 0),
3201 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
3202 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
3203 BPF_STMT(BPF_LD
| BPF_B
| BPF_IND
, 0),
3204 BPF_STMT(BPF_RET
| BPF_A
, 0)
3208 { { 1, 1 }, { 3, 3 }, { 4, 0xff } },
3213 BPF_STMT(BPF_LD
| BPF_B
| BPF_ABS
, SKF_NET_OFF
),
3214 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
3215 BPF_STMT(BPF_LD
| BPF_B
| BPF_ABS
, SKF_NET_OFF
+ 1),
3216 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
3217 BPF_STMT(BPF_RET
| BPF_A
, 0)
3220 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3 },
3221 { { 15, 0 }, { 16, 3 } },
3226 BPF_STMT(BPF_LD
| BPF_IMM
, SKF_NET_OFF
- 15),
3227 BPF_STMT(BPF_LDX
| BPF_LEN
, 0),
3228 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
3229 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
3230 BPF_STMT(BPF_LD
| BPF_B
| BPF_IND
, 0),
3231 BPF_STMT(BPF_RET
| BPF_A
, 0)
3234 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3 },
3235 { { 14, 0 }, { 15, 1 }, { 17, 3 } },
3240 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
3241 SKF_AD_OFF
+ SKF_AD_PKTTYPE
),
3242 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, SKB_TYPE
, 1, 0),
3243 BPF_STMT(BPF_RET
| BPF_K
, 1),
3244 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
3245 SKF_AD_OFF
+ SKF_AD_PKTTYPE
),
3246 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, SKB_TYPE
, 1, 0),
3247 BPF_STMT(BPF_RET
| BPF_K
, 1),
3248 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
3249 SKF_AD_OFF
+ SKF_AD_PKTTYPE
),
3250 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, SKB_TYPE
, 1, 0),
3251 BPF_STMT(BPF_RET
| BPF_K
, 1),
3252 BPF_STMT(BPF_RET
| BPF_A
, 0)
3256 { { 1, 3 }, { 10, 3 } },
3261 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
3262 SKF_AD_OFF
+ SKF_AD_MARK
),
3263 BPF_STMT(BPF_RET
| BPF_A
, 0)
3267 { { 1, SKB_MARK
}, { 10, SKB_MARK
} },
3272 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
3273 SKF_AD_OFF
+ SKF_AD_RXHASH
),
3274 BPF_STMT(BPF_RET
| BPF_A
, 0)
3278 { { 1, SKB_HASH
}, { 10, SKB_HASH
} },
3283 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
3284 SKF_AD_OFF
+ SKF_AD_QUEUE
),
3285 BPF_STMT(BPF_RET
| BPF_A
, 0)
3289 { { 1, SKB_QUEUE_MAP
}, { 10, SKB_QUEUE_MAP
} },
3294 BPF_STMT(BPF_LD
| BPF_B
| BPF_ABS
, 1),
3295 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 20, 1, 0),
3296 BPF_STMT(BPF_RET
| BPF_K
, 0),
3297 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
3298 SKF_AD_OFF
+ SKF_AD_PROTOCOL
),
3299 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
3300 BPF_STMT(BPF_LD
| BPF_B
| BPF_ABS
, 2),
3301 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 30, 1, 0),
3302 BPF_STMT(BPF_RET
| BPF_K
, 0),
3303 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
3304 BPF_STMT(BPF_RET
| BPF_A
, 0)
3308 { { 10, ETH_P_IP
}, { 100, ETH_P_IP
} },
3313 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
3314 SKF_AD_OFF
+ SKF_AD_VLAN_TAG
),
3315 BPF_STMT(BPF_RET
| BPF_A
, 0)
3320 { 1, SKB_VLAN_TCI
},
3321 { 10, SKB_VLAN_TCI
}
3325 "LD_VLAN_TAG_PRESENT",
3327 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
3328 SKF_AD_OFF
+ SKF_AD_VLAN_TAG_PRESENT
),
3329 BPF_STMT(BPF_RET
| BPF_A
, 0)
3334 { 1, SKB_VLAN_PRESENT
},
3335 { 10, SKB_VLAN_PRESENT
}
3341 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
3342 SKF_AD_OFF
+ SKF_AD_IFINDEX
),
3343 BPF_STMT(BPF_RET
| BPF_A
, 0)
3347 { { 1, SKB_DEV_IFINDEX
}, { 10, SKB_DEV_IFINDEX
} },
3352 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
3353 SKF_AD_OFF
+ SKF_AD_HATYPE
),
3354 BPF_STMT(BPF_RET
| BPF_A
, 0)
3358 { { 1, SKB_DEV_TYPE
}, { 10, SKB_DEV_TYPE
} },
3363 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
3364 SKF_AD_OFF
+ SKF_AD_CPU
),
3365 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
3366 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
3367 SKF_AD_OFF
+ SKF_AD_CPU
),
3368 BPF_STMT(BPF_ALU
| BPF_SUB
| BPF_X
, 0),
3369 BPF_STMT(BPF_RET
| BPF_A
, 0)
3373 { { 1, 0 }, { 10, 0 } },
3378 BPF_STMT(BPF_LDX
| BPF_IMM
, 2),
3379 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
3380 BPF_STMT(BPF_LDX
| BPF_IMM
, 3),
3381 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
3382 SKF_AD_OFF
+ SKF_AD_NLATTR
),
3383 BPF_STMT(BPF_RET
| BPF_A
, 0)
3387 { 0xff, 0xff, 0, 4, 0, 2, 0, 4, 0, 3 },
3389 { 0xff, 0xff, 4, 0, 2, 0, 4, 0, 3, 0 },
3391 { { 4, 0 }, { 20, 6 } },
3396 BPF_STMT(BPF_LD
| BPF_IMM
, 2),
3397 BPF_STMT(BPF_LDX
| BPF_IMM
, 3),
3398 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
3399 SKF_AD_OFF
+ SKF_AD_NLATTR_NEST
),
3400 BPF_STMT(BPF_LD
| BPF_IMM
, 2),
3401 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
3402 SKF_AD_OFF
+ SKF_AD_NLATTR_NEST
),
3403 BPF_STMT(BPF_LD
| BPF_IMM
, 2),
3404 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
3405 SKF_AD_OFF
+ SKF_AD_NLATTR_NEST
),
3406 BPF_STMT(BPF_LD
| BPF_IMM
, 2),
3407 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
3408 SKF_AD_OFF
+ SKF_AD_NLATTR_NEST
),
3409 BPF_STMT(BPF_LD
| BPF_IMM
, 2),
3410 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
3411 SKF_AD_OFF
+ SKF_AD_NLATTR_NEST
),
3412 BPF_STMT(BPF_LD
| BPF_IMM
, 2),
3413 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
3414 SKF_AD_OFF
+ SKF_AD_NLATTR_NEST
),
3415 BPF_STMT(BPF_LD
| BPF_IMM
, 2),
3416 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
3417 SKF_AD_OFF
+ SKF_AD_NLATTR_NEST
),
3418 BPF_STMT(BPF_LD
| BPF_IMM
, 2),
3419 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
3420 SKF_AD_OFF
+ SKF_AD_NLATTR_NEST
),
3421 BPF_STMT(BPF_RET
| BPF_A
, 0)
3425 { 0xff, 0xff, 0, 12, 0, 1, 0, 4, 0, 2, 0, 4, 0, 3 },
3427 { 0xff, 0xff, 12, 0, 1, 0, 4, 0, 2, 0, 4, 0, 3, 0 },
3429 { { 4, 0 }, { 20, 10 } },
3434 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
3435 SKF_AD_OFF
+ SKF_AD_PAY_OFFSET
),
3436 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
3437 SKF_AD_OFF
+ SKF_AD_PAY_OFFSET
),
3438 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
3439 SKF_AD_OFF
+ SKF_AD_PAY_OFFSET
),
3440 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
3441 SKF_AD_OFF
+ SKF_AD_PAY_OFFSET
),
3442 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
3443 SKF_AD_OFF
+ SKF_AD_PAY_OFFSET
),
3444 BPF_STMT(BPF_RET
| BPF_A
, 0)
3447 /* 00:00:00:00:00:00 > 00:00:00:00:00:00, ethtype IPv4 (0x0800),
3448 * length 98: 127.0.0.1 > 127.0.0.1: ICMP echo request,
3449 * id 9737, seq 1, length 64
3451 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3452 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
3454 0x45, 0x00, 0x00, 0x54, 0xac, 0x8b, 0x40, 0x00, 0x40,
3455 0x01, 0x90, 0x1b, 0x7f, 0x00, 0x00, 0x01 },
3456 { { 30, 0 }, { 100, 42 } },
3461 BPF_STMT(BPF_LD
| BPF_IMM
, 10),
3462 BPF_STMT(BPF_LDX
| BPF_IMM
, 300),
3463 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
3464 SKF_AD_OFF
+ SKF_AD_ALU_XOR_X
),
3465 BPF_STMT(BPF_RET
| BPF_A
, 0)
3469 { { 4, 0xA ^ 300 }, { 20, 0xA ^ 300 } },
3474 BPF_STMT(BPF_LDX
| BPF_LEN
, 0),
3475 BPF_STMT(BPF_LD
| BPF_IMM
, 2),
3476 BPF_STMT(BPF_ALU
| BPF_RSH
, 1),
3477 BPF_STMT(BPF_ALU
| BPF_XOR
| BPF_X
, 0),
3478 BPF_STMT(BPF_ST
, 1), /* M1 = 1 ^ len */
3479 BPF_STMT(BPF_ALU
| BPF_XOR
| BPF_K
, 0x80000000),
3480 BPF_STMT(BPF_ST
, 2), /* M2 = 1 ^ len ^ 0x80000000 */
3481 BPF_STMT(BPF_STX
, 15), /* M3 = len */
3482 BPF_STMT(BPF_LDX
| BPF_MEM
, 1),
3483 BPF_STMT(BPF_LD
| BPF_MEM
, 2),
3484 BPF_STMT(BPF_ALU
| BPF_XOR
| BPF_X
, 0),
3485 BPF_STMT(BPF_LDX
| BPF_MEM
, 15),
3486 BPF_STMT(BPF_ALU
| BPF_XOR
| BPF_X
, 0),
3487 BPF_STMT(BPF_RET
| BPF_A
, 0)
3491 { { 1, 0x80000001 }, { 2, 0x80000002 }, { 60, 0x80000000 ^ 60 } }
3496 BPF_STMT(BPF_LDX
| BPF_LEN
, 0),
3497 BPF_STMT(BPF_LD
| BPF_B
| BPF_ABS
, 2),
3498 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_X
, 0, 0, 1),
3499 BPF_STMT(BPF_RET
| BPF_K
, 1),
3500 BPF_STMT(BPF_RET
| BPF_K
, MAX_K
)
3504 { { 1, 0 }, { 3, 1 }, { 4, MAX_K
} },
3509 BPF_STMT(BPF_LDX
| BPF_LEN
, 0),
3510 BPF_STMT(BPF_LD
| BPF_B
| BPF_ABS
, 2),
3511 BPF_JUMP(BPF_JMP
| BPF_JGT
| BPF_X
, 0, 0, 1),
3512 BPF_STMT(BPF_RET
| BPF_K
, 1),
3513 BPF_STMT(BPF_RET
| BPF_K
, MAX_K
)
3517 { { 2, 0 }, { 3, 1 }, { 4, MAX_K
} },
3520 "JGE (jt 0), test 1",
3522 BPF_STMT(BPF_LDX
| BPF_LEN
, 0),
3523 BPF_STMT(BPF_LD
| BPF_B
| BPF_ABS
, 2),
3524 BPF_JUMP(BPF_JMP
| BPF_JGE
| BPF_X
, 0, 0, 1),
3525 BPF_STMT(BPF_RET
| BPF_K
, 1),
3526 BPF_STMT(BPF_RET
| BPF_K
, MAX_K
)
3530 { { 2, 0 }, { 3, 1 }, { 4, 1 } },
3533 "JGE (jt 0), test 2",
3535 BPF_STMT(BPF_LDX
| BPF_LEN
, 0),
3536 BPF_STMT(BPF_LD
| BPF_B
| BPF_ABS
, 2),
3537 BPF_JUMP(BPF_JMP
| BPF_JGE
| BPF_X
, 0, 0, 1),
3538 BPF_STMT(BPF_RET
| BPF_K
, 1),
3539 BPF_STMT(BPF_RET
| BPF_K
, MAX_K
)
3543 { { 4, 1 }, { 5, 1 }, { 6, MAX_K
} },
3548 BPF_STMT(BPF_LDX
| BPF_LEN
, 0),
3549 BPF_STMT(BPF_LD
| BPF_B
| BPF_IND
, MAX_K
),
3550 BPF_JUMP(BPF_JMP
| BPF_JGE
| BPF_K
, 1, 1, 0),
3551 BPF_STMT(BPF_RET
| BPF_K
, 10),
3552 BPF_JUMP(BPF_JMP
| BPF_JGE
| BPF_K
, 2, 1, 0),
3553 BPF_STMT(BPF_RET
| BPF_K
, 20),
3554 BPF_JUMP(BPF_JMP
| BPF_JGE
| BPF_K
, 3, 1, 0),
3555 BPF_STMT(BPF_RET
| BPF_K
, 30),
3556 BPF_JUMP(BPF_JMP
| BPF_JGE
| BPF_K
, 4, 1, 0),
3557 BPF_STMT(BPF_RET
| BPF_K
, 40),
3558 BPF_STMT(BPF_RET
| BPF_K
, MAX_K
)
3562 { { 1, 20 }, { 3, 40 }, { 5, MAX_K
} },
3567 BPF_JUMP(BPF_JMP
| BPF_JA
, 0, 0, 0),
3568 BPF_JUMP(BPF_JMP
| BPF_JA
, 1, 1, 1),
3569 BPF_JUMP(BPF_JMP
| BPF_JA
, 0, 0, 0),
3570 BPF_JUMP(BPF_JMP
| BPF_JA
, 0, 0, 0),
3571 BPF_STMT(BPF_LDX
| BPF_LEN
, 0),
3572 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
3573 BPF_STMT(BPF_ALU
| BPF_SUB
| BPF_K
, 4),
3574 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
3575 BPF_STMT(BPF_LD
| BPF_W
| BPF_IND
, 0),
3576 BPF_JUMP(BPF_JMP
| BPF_JSET
| BPF_K
, 1, 0, 1),
3577 BPF_STMT(BPF_RET
| BPF_K
, 10),
3578 BPF_JUMP(BPF_JMP
| BPF_JSET
| BPF_K
, 0x80000000, 0, 1),
3579 BPF_STMT(BPF_RET
| BPF_K
, 20),
3580 BPF_JUMP(BPF_JMP
| BPF_JSET
| BPF_K
, 0xffffff, 1, 0),
3581 BPF_STMT(BPF_RET
| BPF_K
, 30),
3582 BPF_JUMP(BPF_JMP
| BPF_JSET
| BPF_K
, 0xffffff, 1, 0),
3583 BPF_STMT(BPF_RET
| BPF_K
, 30),
3584 BPF_JUMP(BPF_JMP
| BPF_JSET
| BPF_K
, 0xffffff, 1, 0),
3585 BPF_STMT(BPF_RET
| BPF_K
, 30),
3586 BPF_JUMP(BPF_JMP
| BPF_JSET
| BPF_K
, 0xffffff, 1, 0),
3587 BPF_STMT(BPF_RET
| BPF_K
, 30),
3588 BPF_JUMP(BPF_JMP
| BPF_JSET
| BPF_K
, 0xffffff, 1, 0),
3589 BPF_STMT(BPF_RET
| BPF_K
, 30),
3590 BPF_STMT(BPF_RET
| BPF_K
, MAX_K
)
3593 { 0, 0xAA, 0x55, 1 },
3594 { { 4, 10 }, { 5, 20 }, { 6, MAX_K
} },
3599 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 12),
3600 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 0x86dd, 0, 8), /* IPv6 */
3601 BPF_STMT(BPF_LD
| BPF_B
| BPF_ABS
, 20),
3602 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 0x84, 2, 0),
3603 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 0x6, 1, 0),
3604 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 0x11, 0, 17),
3605 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 54),
3606 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 22, 14, 0),
3607 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 56),
3608 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 22, 12, 13),
3609 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 0x0800, 0, 12), /* IPv4 */
3610 BPF_STMT(BPF_LD
| BPF_B
| BPF_ABS
, 23),
3611 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 0x84, 2, 0),
3612 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 0x6, 1, 0),
3613 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 0x11, 0, 8),
3614 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 20),
3615 BPF_JUMP(BPF_JMP
| BPF_JSET
| BPF_K
, 0x1fff, 6, 0),
3616 BPF_STMT(BPF_LDX
| BPF_B
| BPF_MSH
, 14),
3617 BPF_STMT(BPF_LD
| BPF_H
| BPF_IND
, 14),
3618 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 22, 2, 0),
3619 BPF_STMT(BPF_LD
| BPF_H
| BPF_IND
, 16),
3620 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 22, 0, 1),
3621 BPF_STMT(BPF_RET
| BPF_K
, 0xffff),
3622 BPF_STMT(BPF_RET
| BPF_K
, 0),
3625 /* 3c:07:54:43:e5:76 > 10:bf:48:d6:43:d6, ethertype IPv4(0x0800)
3626 * length 114: 10.1.1.149.49700 > 10.1.2.10.22: Flags [P.],
3627 * seq 1305692979:1305693027, ack 3650467037, win 65535,
3628 * options [nop,nop,TS val 2502645400 ecr 3971138], length 48
3630 { 0x10, 0xbf, 0x48, 0xd6, 0x43, 0xd6,
3631 0x3c, 0x07, 0x54, 0x43, 0xe5, 0x76,
3633 0x45, 0x10, 0x00, 0x64, 0x75, 0xb5,
3634 0x40, 0x00, 0x40, 0x06, 0xad, 0x2e, /* IP header */
3635 0x0a, 0x01, 0x01, 0x95, /* ip src */
3636 0x0a, 0x01, 0x02, 0x0a, /* ip dst */
3638 0x00, 0x16 /* dst port */ },
3639 { { 10, 0 }, { 30, 0 }, { 100, 65535 } },
3644 /* tcpdump -nei eth0 'tcp port 22 and (((ip[2:2] -
3645 * ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0) and
3646 * (len > 115 or len < 30000000000)' -d
3648 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 12),
3649 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 0x86dd, 30, 0),
3650 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 0x800, 0, 29),
3651 BPF_STMT(BPF_LD
| BPF_B
| BPF_ABS
, 23),
3652 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 0x6, 0, 27),
3653 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 20),
3654 BPF_JUMP(BPF_JMP
| BPF_JSET
| BPF_K
, 0x1fff, 25, 0),
3655 BPF_STMT(BPF_LDX
| BPF_B
| BPF_MSH
, 14),
3656 BPF_STMT(BPF_LD
| BPF_H
| BPF_IND
, 14),
3657 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 22, 2, 0),
3658 BPF_STMT(BPF_LD
| BPF_H
| BPF_IND
, 16),
3659 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 22, 0, 20),
3660 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 16),
3661 BPF_STMT(BPF_ST
, 1),
3662 BPF_STMT(BPF_LD
| BPF_B
| BPF_ABS
, 14),
3663 BPF_STMT(BPF_ALU
| BPF_AND
| BPF_K
, 0xf),
3664 BPF_STMT(BPF_ALU
| BPF_LSH
| BPF_K
, 2),
3665 BPF_STMT(BPF_MISC
| BPF_TAX
, 0x5), /* libpcap emits K on TAX */
3666 BPF_STMT(BPF_LD
| BPF_MEM
, 1),
3667 BPF_STMT(BPF_ALU
| BPF_SUB
| BPF_X
, 0),
3668 BPF_STMT(BPF_ST
, 5),
3669 BPF_STMT(BPF_LDX
| BPF_B
| BPF_MSH
, 14),
3670 BPF_STMT(BPF_LD
| BPF_B
| BPF_IND
, 26),
3671 BPF_STMT(BPF_ALU
| BPF_AND
| BPF_K
, 0xf0),
3672 BPF_STMT(BPF_ALU
| BPF_RSH
| BPF_K
, 2),
3673 BPF_STMT(BPF_MISC
| BPF_TAX
, 0x9), /* libpcap emits K on TAX */
3674 BPF_STMT(BPF_LD
| BPF_MEM
, 5),
3675 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_X
, 0, 4, 0),
3676 BPF_STMT(BPF_LD
| BPF_LEN
, 0),
3677 BPF_JUMP(BPF_JMP
| BPF_JGT
| BPF_K
, 0x73, 1, 0),
3678 BPF_JUMP(BPF_JMP
| BPF_JGE
| BPF_K
, 0xfc23ac00, 1, 0),
3679 BPF_STMT(BPF_RET
| BPF_K
, 0xffff),
3680 BPF_STMT(BPF_RET
| BPF_K
, 0),
3683 { 0x10, 0xbf, 0x48, 0xd6, 0x43, 0xd6,
3684 0x3c, 0x07, 0x54, 0x43, 0xe5, 0x76,
3686 0x45, 0x10, 0x00, 0x64, 0x75, 0xb5,
3687 0x40, 0x00, 0x40, 0x06, 0xad, 0x2e, /* IP header */
3688 0x0a, 0x01, 0x01, 0x95, /* ip src */
3689 0x0a, 0x01, 0x02, 0x0a, /* ip dst */
3691 0x00, 0x16 /* dst port */ },
3692 { { 10, 0 }, { 30, 0 }, { 100, 65535 } },
3697 /* check that uninitialized X and A contain zeros */
3698 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
3699 BPF_STMT(BPF_RET
| BPF_A
, 0)
3708 BPF_ALU64_IMM(BPF_MOV
, R1
, 1),
3709 BPF_ALU64_IMM(BPF_ADD
, R1
, 2),
3710 BPF_ALU64_IMM(BPF_MOV
, R2
, 3),
3711 BPF_ALU64_REG(BPF_SUB
, R1
, R2
),
3712 BPF_ALU64_IMM(BPF_ADD
, R1
, -1),
3713 BPF_ALU64_IMM(BPF_MUL
, R1
, 3),
3714 BPF_ALU64_REG(BPF_MOV
, R0
, R1
),
3719 { { 0, 0xfffffffd } }
3724 BPF_ALU64_IMM(BPF_MOV
, R0
, -1),
3725 BPF_ALU64_IMM(BPF_MOV
, R1
, -1),
3726 BPF_ALU64_IMM(BPF_MOV
, R2
, 3),
3727 BPF_ALU64_REG(BPF_MUL
, R1
, R2
),
3728 BPF_JMP_IMM(BPF_JEQ
, R1
, 0xfffffffd, 1),
3730 BPF_ALU64_IMM(BPF_MOV
, R0
, 1),
3740 BPF_ALU32_IMM(BPF_MOV
, R0
, -1),
3741 BPF_ALU32_IMM(BPF_MOV
, R1
, -1),
3742 BPF_ALU32_IMM(BPF_MOV
, R2
, 3),
3743 BPF_ALU64_REG(BPF_MUL
, R1
, R2
),
3744 BPF_ALU64_IMM(BPF_RSH
, R1
, 8),
3745 BPF_JMP_IMM(BPF_JEQ
, R1
, 0x2ffffff, 1),
3747 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
3757 BPF_ALU32_IMM(BPF_MOV
, R0
, -1),
3758 BPF_ALU64_IMM(BPF_MOV
, R1
, -1),
3759 BPF_ALU32_IMM(BPF_MOV
, R2
, 3),
3760 BPF_ALU32_REG(BPF_MUL
, R1
, R2
),
3761 BPF_ALU64_IMM(BPF_RSH
, R1
, 8),
3762 BPF_JMP_IMM(BPF_JEQ
, R1
, 0xffffff, 1),
3764 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
3772 /* Have to test all register combinations, since
3773 * JITing of different registers will produce
3774 * different asm code.
3778 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
3779 BPF_ALU64_IMM(BPF_MOV
, R1
, 1),
3780 BPF_ALU64_IMM(BPF_MOV
, R2
, 2),
3781 BPF_ALU64_IMM(BPF_MOV
, R3
, 3),
3782 BPF_ALU64_IMM(BPF_MOV
, R4
, 4),
3783 BPF_ALU64_IMM(BPF_MOV
, R5
, 5),
3784 BPF_ALU64_IMM(BPF_MOV
, R6
, 6),
3785 BPF_ALU64_IMM(BPF_MOV
, R7
, 7),
3786 BPF_ALU64_IMM(BPF_MOV
, R8
, 8),
3787 BPF_ALU64_IMM(BPF_MOV
, R9
, 9),
3788 BPF_ALU64_IMM(BPF_ADD
, R0
, 20),
3789 BPF_ALU64_IMM(BPF_ADD
, R1
, 20),
3790 BPF_ALU64_IMM(BPF_ADD
, R2
, 20),
3791 BPF_ALU64_IMM(BPF_ADD
, R3
, 20),
3792 BPF_ALU64_IMM(BPF_ADD
, R4
, 20),
3793 BPF_ALU64_IMM(BPF_ADD
, R5
, 20),
3794 BPF_ALU64_IMM(BPF_ADD
, R6
, 20),
3795 BPF_ALU64_IMM(BPF_ADD
, R7
, 20),
3796 BPF_ALU64_IMM(BPF_ADD
, R8
, 20),
3797 BPF_ALU64_IMM(BPF_ADD
, R9
, 20),
3798 BPF_ALU64_IMM(BPF_SUB
, R0
, 10),
3799 BPF_ALU64_IMM(BPF_SUB
, R1
, 10),
3800 BPF_ALU64_IMM(BPF_SUB
, R2
, 10),
3801 BPF_ALU64_IMM(BPF_SUB
, R3
, 10),
3802 BPF_ALU64_IMM(BPF_SUB
, R4
, 10),
3803 BPF_ALU64_IMM(BPF_SUB
, R5
, 10),
3804 BPF_ALU64_IMM(BPF_SUB
, R6
, 10),
3805 BPF_ALU64_IMM(BPF_SUB
, R7
, 10),
3806 BPF_ALU64_IMM(BPF_SUB
, R8
, 10),
3807 BPF_ALU64_IMM(BPF_SUB
, R9
, 10),
3808 BPF_ALU64_REG(BPF_ADD
, R0
, R0
),
3809 BPF_ALU64_REG(BPF_ADD
, R0
, R1
),
3810 BPF_ALU64_REG(BPF_ADD
, R0
, R2
),
3811 BPF_ALU64_REG(BPF_ADD
, R0
, R3
),
3812 BPF_ALU64_REG(BPF_ADD
, R0
, R4
),
3813 BPF_ALU64_REG(BPF_ADD
, R0
, R5
),
3814 BPF_ALU64_REG(BPF_ADD
, R0
, R6
),
3815 BPF_ALU64_REG(BPF_ADD
, R0
, R7
),
3816 BPF_ALU64_REG(BPF_ADD
, R0
, R8
),
3817 BPF_ALU64_REG(BPF_ADD
, R0
, R9
), /* R0 == 155 */
3818 BPF_JMP_IMM(BPF_JEQ
, R0
, 155, 1),
3820 BPF_ALU64_REG(BPF_ADD
, R1
, R0
),
3821 BPF_ALU64_REG(BPF_ADD
, R1
, R1
),
3822 BPF_ALU64_REG(BPF_ADD
, R1
, R2
),
3823 BPF_ALU64_REG(BPF_ADD
, R1
, R3
),
3824 BPF_ALU64_REG(BPF_ADD
, R1
, R4
),
3825 BPF_ALU64_REG(BPF_ADD
, R1
, R5
),
3826 BPF_ALU64_REG(BPF_ADD
, R1
, R6
),
3827 BPF_ALU64_REG(BPF_ADD
, R1
, R7
),
3828 BPF_ALU64_REG(BPF_ADD
, R1
, R8
),
3829 BPF_ALU64_REG(BPF_ADD
, R1
, R9
), /* R1 == 456 */
3830 BPF_JMP_IMM(BPF_JEQ
, R1
, 456, 1),
3832 BPF_ALU64_REG(BPF_ADD
, R2
, R0
),
3833 BPF_ALU64_REG(BPF_ADD
, R2
, R1
),
3834 BPF_ALU64_REG(BPF_ADD
, R2
, R2
),
3835 BPF_ALU64_REG(BPF_ADD
, R2
, R3
),
3836 BPF_ALU64_REG(BPF_ADD
, R2
, R4
),
3837 BPF_ALU64_REG(BPF_ADD
, R2
, R5
),
3838 BPF_ALU64_REG(BPF_ADD
, R2
, R6
),
3839 BPF_ALU64_REG(BPF_ADD
, R2
, R7
),
3840 BPF_ALU64_REG(BPF_ADD
, R2
, R8
),
3841 BPF_ALU64_REG(BPF_ADD
, R2
, R9
), /* R2 == 1358 */
3842 BPF_JMP_IMM(BPF_JEQ
, R2
, 1358, 1),
3844 BPF_ALU64_REG(BPF_ADD
, R3
, R0
),
3845 BPF_ALU64_REG(BPF_ADD
, R3
, R1
),
3846 BPF_ALU64_REG(BPF_ADD
, R3
, R2
),
3847 BPF_ALU64_REG(BPF_ADD
, R3
, R3
),
3848 BPF_ALU64_REG(BPF_ADD
, R3
, R4
),
3849 BPF_ALU64_REG(BPF_ADD
, R3
, R5
),
3850 BPF_ALU64_REG(BPF_ADD
, R3
, R6
),
3851 BPF_ALU64_REG(BPF_ADD
, R3
, R7
),
3852 BPF_ALU64_REG(BPF_ADD
, R3
, R8
),
3853 BPF_ALU64_REG(BPF_ADD
, R3
, R9
), /* R3 == 4063 */
3854 BPF_JMP_IMM(BPF_JEQ
, R3
, 4063, 1),
3856 BPF_ALU64_REG(BPF_ADD
, R4
, R0
),
3857 BPF_ALU64_REG(BPF_ADD
, R4
, R1
),
3858 BPF_ALU64_REG(BPF_ADD
, R4
, R2
),
3859 BPF_ALU64_REG(BPF_ADD
, R4
, R3
),
3860 BPF_ALU64_REG(BPF_ADD
, R4
, R4
),
3861 BPF_ALU64_REG(BPF_ADD
, R4
, R5
),
3862 BPF_ALU64_REG(BPF_ADD
, R4
, R6
),
3863 BPF_ALU64_REG(BPF_ADD
, R4
, R7
),
3864 BPF_ALU64_REG(BPF_ADD
, R4
, R8
),
3865 BPF_ALU64_REG(BPF_ADD
, R4
, R9
), /* R4 == 12177 */
3866 BPF_JMP_IMM(BPF_JEQ
, R4
, 12177, 1),
3868 BPF_ALU64_REG(BPF_ADD
, R5
, R0
),
3869 BPF_ALU64_REG(BPF_ADD
, R5
, R1
),
3870 BPF_ALU64_REG(BPF_ADD
, R5
, R2
),
3871 BPF_ALU64_REG(BPF_ADD
, R5
, R3
),
3872 BPF_ALU64_REG(BPF_ADD
, R5
, R4
),
3873 BPF_ALU64_REG(BPF_ADD
, R5
, R5
),
3874 BPF_ALU64_REG(BPF_ADD
, R5
, R6
),
3875 BPF_ALU64_REG(BPF_ADD
, R5
, R7
),
3876 BPF_ALU64_REG(BPF_ADD
, R5
, R8
),
3877 BPF_ALU64_REG(BPF_ADD
, R5
, R9
), /* R5 == 36518 */
3878 BPF_JMP_IMM(BPF_JEQ
, R5
, 36518, 1),
3880 BPF_ALU64_REG(BPF_ADD
, R6
, R0
),
3881 BPF_ALU64_REG(BPF_ADD
, R6
, R1
),
3882 BPF_ALU64_REG(BPF_ADD
, R6
, R2
),
3883 BPF_ALU64_REG(BPF_ADD
, R6
, R3
),
3884 BPF_ALU64_REG(BPF_ADD
, R6
, R4
),
3885 BPF_ALU64_REG(BPF_ADD
, R6
, R5
),
3886 BPF_ALU64_REG(BPF_ADD
, R6
, R6
),
3887 BPF_ALU64_REG(BPF_ADD
, R6
, R7
),
3888 BPF_ALU64_REG(BPF_ADD
, R6
, R8
),
3889 BPF_ALU64_REG(BPF_ADD
, R6
, R9
), /* R6 == 109540 */
3890 BPF_JMP_IMM(BPF_JEQ
, R6
, 109540, 1),
3892 BPF_ALU64_REG(BPF_ADD
, R7
, R0
),
3893 BPF_ALU64_REG(BPF_ADD
, R7
, R1
),
3894 BPF_ALU64_REG(BPF_ADD
, R7
, R2
),
3895 BPF_ALU64_REG(BPF_ADD
, R7
, R3
),
3896 BPF_ALU64_REG(BPF_ADD
, R7
, R4
),
3897 BPF_ALU64_REG(BPF_ADD
, R7
, R5
),
3898 BPF_ALU64_REG(BPF_ADD
, R7
, R6
),
3899 BPF_ALU64_REG(BPF_ADD
, R7
, R7
),
3900 BPF_ALU64_REG(BPF_ADD
, R7
, R8
),
3901 BPF_ALU64_REG(BPF_ADD
, R7
, R9
), /* R7 == 328605 */
3902 BPF_JMP_IMM(BPF_JEQ
, R7
, 328605, 1),
3904 BPF_ALU64_REG(BPF_ADD
, R8
, R0
),
3905 BPF_ALU64_REG(BPF_ADD
, R8
, R1
),
3906 BPF_ALU64_REG(BPF_ADD
, R8
, R2
),
3907 BPF_ALU64_REG(BPF_ADD
, R8
, R3
),
3908 BPF_ALU64_REG(BPF_ADD
, R8
, R4
),
3909 BPF_ALU64_REG(BPF_ADD
, R8
, R5
),
3910 BPF_ALU64_REG(BPF_ADD
, R8
, R6
),
3911 BPF_ALU64_REG(BPF_ADD
, R8
, R7
),
3912 BPF_ALU64_REG(BPF_ADD
, R8
, R8
),
3913 BPF_ALU64_REG(BPF_ADD
, R8
, R9
), /* R8 == 985799 */
3914 BPF_JMP_IMM(BPF_JEQ
, R8
, 985799, 1),
3916 BPF_ALU64_REG(BPF_ADD
, R9
, R0
),
3917 BPF_ALU64_REG(BPF_ADD
, R9
, R1
),
3918 BPF_ALU64_REG(BPF_ADD
, R9
, R2
),
3919 BPF_ALU64_REG(BPF_ADD
, R9
, R3
),
3920 BPF_ALU64_REG(BPF_ADD
, R9
, R4
),
3921 BPF_ALU64_REG(BPF_ADD
, R9
, R5
),
3922 BPF_ALU64_REG(BPF_ADD
, R9
, R6
),
3923 BPF_ALU64_REG(BPF_ADD
, R9
, R7
),
3924 BPF_ALU64_REG(BPF_ADD
, R9
, R8
),
3925 BPF_ALU64_REG(BPF_ADD
, R9
, R9
), /* R9 == 2957380 */
3926 BPF_ALU64_REG(BPF_MOV
, R0
, R9
),
3936 BPF_ALU32_IMM(BPF_MOV
, R0
, 20),
3937 BPF_ALU32_IMM(BPF_MOV
, R1
, 1),
3938 BPF_ALU32_IMM(BPF_MOV
, R2
, 2),
3939 BPF_ALU32_IMM(BPF_MOV
, R3
, 3),
3940 BPF_ALU32_IMM(BPF_MOV
, R4
, 4),
3941 BPF_ALU32_IMM(BPF_MOV
, R5
, 5),
3942 BPF_ALU32_IMM(BPF_MOV
, R6
, 6),
3943 BPF_ALU32_IMM(BPF_MOV
, R7
, 7),
3944 BPF_ALU32_IMM(BPF_MOV
, R8
, 8),
3945 BPF_ALU32_IMM(BPF_MOV
, R9
, 9),
3946 BPF_ALU64_IMM(BPF_ADD
, R1
, 10),
3947 BPF_ALU64_IMM(BPF_ADD
, R2
, 10),
3948 BPF_ALU64_IMM(BPF_ADD
, R3
, 10),
3949 BPF_ALU64_IMM(BPF_ADD
, R4
, 10),
3950 BPF_ALU64_IMM(BPF_ADD
, R5
, 10),
3951 BPF_ALU64_IMM(BPF_ADD
, R6
, 10),
3952 BPF_ALU64_IMM(BPF_ADD
, R7
, 10),
3953 BPF_ALU64_IMM(BPF_ADD
, R8
, 10),
3954 BPF_ALU64_IMM(BPF_ADD
, R9
, 10),
3955 BPF_ALU32_REG(BPF_ADD
, R0
, R1
),
3956 BPF_ALU32_REG(BPF_ADD
, R0
, R2
),
3957 BPF_ALU32_REG(BPF_ADD
, R0
, R3
),
3958 BPF_ALU32_REG(BPF_ADD
, R0
, R4
),
3959 BPF_ALU32_REG(BPF_ADD
, R0
, R5
),
3960 BPF_ALU32_REG(BPF_ADD
, R0
, R6
),
3961 BPF_ALU32_REG(BPF_ADD
, R0
, R7
),
3962 BPF_ALU32_REG(BPF_ADD
, R0
, R8
),
3963 BPF_ALU32_REG(BPF_ADD
, R0
, R9
), /* R0 == 155 */
3964 BPF_JMP_IMM(BPF_JEQ
, R0
, 155, 1),
3966 BPF_ALU32_REG(BPF_ADD
, R1
, R0
),
3967 BPF_ALU32_REG(BPF_ADD
, R1
, R1
),
3968 BPF_ALU32_REG(BPF_ADD
, R1
, R2
),
3969 BPF_ALU32_REG(BPF_ADD
, R1
, R3
),
3970 BPF_ALU32_REG(BPF_ADD
, R1
, R4
),
3971 BPF_ALU32_REG(BPF_ADD
, R1
, R5
),
3972 BPF_ALU32_REG(BPF_ADD
, R1
, R6
),
3973 BPF_ALU32_REG(BPF_ADD
, R1
, R7
),
3974 BPF_ALU32_REG(BPF_ADD
, R1
, R8
),
3975 BPF_ALU32_REG(BPF_ADD
, R1
, R9
), /* R1 == 456 */
3976 BPF_JMP_IMM(BPF_JEQ
, R1
, 456, 1),
3978 BPF_ALU32_REG(BPF_ADD
, R2
, R0
),
3979 BPF_ALU32_REG(BPF_ADD
, R2
, R1
),
3980 BPF_ALU32_REG(BPF_ADD
, R2
, R2
),
3981 BPF_ALU32_REG(BPF_ADD
, R2
, R3
),
3982 BPF_ALU32_REG(BPF_ADD
, R2
, R4
),
3983 BPF_ALU32_REG(BPF_ADD
, R2
, R5
),
3984 BPF_ALU32_REG(BPF_ADD
, R2
, R6
),
3985 BPF_ALU32_REG(BPF_ADD
, R2
, R7
),
3986 BPF_ALU32_REG(BPF_ADD
, R2
, R8
),
3987 BPF_ALU32_REG(BPF_ADD
, R2
, R9
), /* R2 == 1358 */
3988 BPF_JMP_IMM(BPF_JEQ
, R2
, 1358, 1),
3990 BPF_ALU32_REG(BPF_ADD
, R3
, R0
),
3991 BPF_ALU32_REG(BPF_ADD
, R3
, R1
),
3992 BPF_ALU32_REG(BPF_ADD
, R3
, R2
),
3993 BPF_ALU32_REG(BPF_ADD
, R3
, R3
),
3994 BPF_ALU32_REG(BPF_ADD
, R3
, R4
),
3995 BPF_ALU32_REG(BPF_ADD
, R3
, R5
),
3996 BPF_ALU32_REG(BPF_ADD
, R3
, R6
),
3997 BPF_ALU32_REG(BPF_ADD
, R3
, R7
),
3998 BPF_ALU32_REG(BPF_ADD
, R3
, R8
),
3999 BPF_ALU32_REG(BPF_ADD
, R3
, R9
), /* R3 == 4063 */
4000 BPF_JMP_IMM(BPF_JEQ
, R3
, 4063, 1),
4002 BPF_ALU32_REG(BPF_ADD
, R4
, R0
),
4003 BPF_ALU32_REG(BPF_ADD
, R4
, R1
),
4004 BPF_ALU32_REG(BPF_ADD
, R4
, R2
),
4005 BPF_ALU32_REG(BPF_ADD
, R4
, R3
),
4006 BPF_ALU32_REG(BPF_ADD
, R4
, R4
),
4007 BPF_ALU32_REG(BPF_ADD
, R4
, R5
),
4008 BPF_ALU32_REG(BPF_ADD
, R4
, R6
),
4009 BPF_ALU32_REG(BPF_ADD
, R4
, R7
),
4010 BPF_ALU32_REG(BPF_ADD
, R4
, R8
),
4011 BPF_ALU32_REG(BPF_ADD
, R4
, R9
), /* R4 == 12177 */
4012 BPF_JMP_IMM(BPF_JEQ
, R4
, 12177, 1),
4014 BPF_ALU32_REG(BPF_ADD
, R5
, R0
),
4015 BPF_ALU32_REG(BPF_ADD
, R5
, R1
),
4016 BPF_ALU32_REG(BPF_ADD
, R5
, R2
),
4017 BPF_ALU32_REG(BPF_ADD
, R5
, R3
),
4018 BPF_ALU32_REG(BPF_ADD
, R5
, R4
),
4019 BPF_ALU32_REG(BPF_ADD
, R5
, R5
),
4020 BPF_ALU32_REG(BPF_ADD
, R5
, R6
),
4021 BPF_ALU32_REG(BPF_ADD
, R5
, R7
),
4022 BPF_ALU32_REG(BPF_ADD
, R5
, R8
),
4023 BPF_ALU32_REG(BPF_ADD
, R5
, R9
), /* R5 == 36518 */
4024 BPF_JMP_IMM(BPF_JEQ
, R5
, 36518, 1),
4026 BPF_ALU32_REG(BPF_ADD
, R6
, R0
),
4027 BPF_ALU32_REG(BPF_ADD
, R6
, R1
),
4028 BPF_ALU32_REG(BPF_ADD
, R6
, R2
),
4029 BPF_ALU32_REG(BPF_ADD
, R6
, R3
),
4030 BPF_ALU32_REG(BPF_ADD
, R6
, R4
),
4031 BPF_ALU32_REG(BPF_ADD
, R6
, R5
),
4032 BPF_ALU32_REG(BPF_ADD
, R6
, R6
),
4033 BPF_ALU32_REG(BPF_ADD
, R6
, R7
),
4034 BPF_ALU32_REG(BPF_ADD
, R6
, R8
),
4035 BPF_ALU32_REG(BPF_ADD
, R6
, R9
), /* R6 == 109540 */
4036 BPF_JMP_IMM(BPF_JEQ
, R6
, 109540, 1),
4038 BPF_ALU32_REG(BPF_ADD
, R7
, R0
),
4039 BPF_ALU32_REG(BPF_ADD
, R7
, R1
),
4040 BPF_ALU32_REG(BPF_ADD
, R7
, R2
),
4041 BPF_ALU32_REG(BPF_ADD
, R7
, R3
),
4042 BPF_ALU32_REG(BPF_ADD
, R7
, R4
),
4043 BPF_ALU32_REG(BPF_ADD
, R7
, R5
),
4044 BPF_ALU32_REG(BPF_ADD
, R7
, R6
),
4045 BPF_ALU32_REG(BPF_ADD
, R7
, R7
),
4046 BPF_ALU32_REG(BPF_ADD
, R7
, R8
),
4047 BPF_ALU32_REG(BPF_ADD
, R7
, R9
), /* R7 == 328605 */
4048 BPF_JMP_IMM(BPF_JEQ
, R7
, 328605, 1),
4050 BPF_ALU32_REG(BPF_ADD
, R8
, R0
),
4051 BPF_ALU32_REG(BPF_ADD
, R8
, R1
),
4052 BPF_ALU32_REG(BPF_ADD
, R8
, R2
),
4053 BPF_ALU32_REG(BPF_ADD
, R8
, R3
),
4054 BPF_ALU32_REG(BPF_ADD
, R8
, R4
),
4055 BPF_ALU32_REG(BPF_ADD
, R8
, R5
),
4056 BPF_ALU32_REG(BPF_ADD
, R8
, R6
),
4057 BPF_ALU32_REG(BPF_ADD
, R8
, R7
),
4058 BPF_ALU32_REG(BPF_ADD
, R8
, R8
),
4059 BPF_ALU32_REG(BPF_ADD
, R8
, R9
), /* R8 == 985799 */
4060 BPF_JMP_IMM(BPF_JEQ
, R8
, 985799, 1),
4062 BPF_ALU32_REG(BPF_ADD
, R9
, R0
),
4063 BPF_ALU32_REG(BPF_ADD
, R9
, R1
),
4064 BPF_ALU32_REG(BPF_ADD
, R9
, R2
),
4065 BPF_ALU32_REG(BPF_ADD
, R9
, R3
),
4066 BPF_ALU32_REG(BPF_ADD
, R9
, R4
),
4067 BPF_ALU32_REG(BPF_ADD
, R9
, R5
),
4068 BPF_ALU32_REG(BPF_ADD
, R9
, R6
),
4069 BPF_ALU32_REG(BPF_ADD
, R9
, R7
),
4070 BPF_ALU32_REG(BPF_ADD
, R9
, R8
),
4071 BPF_ALU32_REG(BPF_ADD
, R9
, R9
), /* R9 == 2957380 */
4072 BPF_ALU32_REG(BPF_MOV
, R0
, R9
),
4079 { /* Mainly checking JIT here. */
4082 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
4083 BPF_ALU64_IMM(BPF_MOV
, R1
, 1),
4084 BPF_ALU64_IMM(BPF_MOV
, R2
, 2),
4085 BPF_ALU64_IMM(BPF_MOV
, R3
, 3),
4086 BPF_ALU64_IMM(BPF_MOV
, R4
, 4),
4087 BPF_ALU64_IMM(BPF_MOV
, R5
, 5),
4088 BPF_ALU64_IMM(BPF_MOV
, R6
, 6),
4089 BPF_ALU64_IMM(BPF_MOV
, R7
, 7),
4090 BPF_ALU64_IMM(BPF_MOV
, R8
, 8),
4091 BPF_ALU64_IMM(BPF_MOV
, R9
, 9),
4092 BPF_ALU64_REG(BPF_SUB
, R0
, R0
),
4093 BPF_ALU64_REG(BPF_SUB
, R0
, R1
),
4094 BPF_ALU64_REG(BPF_SUB
, R0
, R2
),
4095 BPF_ALU64_REG(BPF_SUB
, R0
, R3
),
4096 BPF_ALU64_REG(BPF_SUB
, R0
, R4
),
4097 BPF_ALU64_REG(BPF_SUB
, R0
, R5
),
4098 BPF_ALU64_REG(BPF_SUB
, R0
, R6
),
4099 BPF_ALU64_REG(BPF_SUB
, R0
, R7
),
4100 BPF_ALU64_REG(BPF_SUB
, R0
, R8
),
4101 BPF_ALU64_REG(BPF_SUB
, R0
, R9
),
4102 BPF_ALU64_IMM(BPF_SUB
, R0
, 10),
4103 BPF_JMP_IMM(BPF_JEQ
, R0
, -55, 1),
4105 BPF_ALU64_REG(BPF_SUB
, R1
, R0
),
4106 BPF_ALU64_REG(BPF_SUB
, R1
, R2
),
4107 BPF_ALU64_REG(BPF_SUB
, R1
, R3
),
4108 BPF_ALU64_REG(BPF_SUB
, R1
, R4
),
4109 BPF_ALU64_REG(BPF_SUB
, R1
, R5
),
4110 BPF_ALU64_REG(BPF_SUB
, R1
, R6
),
4111 BPF_ALU64_REG(BPF_SUB
, R1
, R7
),
4112 BPF_ALU64_REG(BPF_SUB
, R1
, R8
),
4113 BPF_ALU64_REG(BPF_SUB
, R1
, R9
),
4114 BPF_ALU64_IMM(BPF_SUB
, R1
, 10),
4115 BPF_ALU64_REG(BPF_SUB
, R2
, R0
),
4116 BPF_ALU64_REG(BPF_SUB
, R2
, R1
),
4117 BPF_ALU64_REG(BPF_SUB
, R2
, R3
),
4118 BPF_ALU64_REG(BPF_SUB
, R2
, R4
),
4119 BPF_ALU64_REG(BPF_SUB
, R2
, R5
),
4120 BPF_ALU64_REG(BPF_SUB
, R2
, R6
),
4121 BPF_ALU64_REG(BPF_SUB
, R2
, R7
),
4122 BPF_ALU64_REG(BPF_SUB
, R2
, R8
),
4123 BPF_ALU64_REG(BPF_SUB
, R2
, R9
),
4124 BPF_ALU64_IMM(BPF_SUB
, R2
, 10),
4125 BPF_ALU64_REG(BPF_SUB
, R3
, R0
),
4126 BPF_ALU64_REG(BPF_SUB
, R3
, R1
),
4127 BPF_ALU64_REG(BPF_SUB
, R3
, R2
),
4128 BPF_ALU64_REG(BPF_SUB
, R3
, R4
),
4129 BPF_ALU64_REG(BPF_SUB
, R3
, R5
),
4130 BPF_ALU64_REG(BPF_SUB
, R3
, R6
),
4131 BPF_ALU64_REG(BPF_SUB
, R3
, R7
),
4132 BPF_ALU64_REG(BPF_SUB
, R3
, R8
),
4133 BPF_ALU64_REG(BPF_SUB
, R3
, R9
),
4134 BPF_ALU64_IMM(BPF_SUB
, R3
, 10),
4135 BPF_ALU64_REG(BPF_SUB
, R4
, R0
),
4136 BPF_ALU64_REG(BPF_SUB
, R4
, R1
),
4137 BPF_ALU64_REG(BPF_SUB
, R4
, R2
),
4138 BPF_ALU64_REG(BPF_SUB
, R4
, R3
),
4139 BPF_ALU64_REG(BPF_SUB
, R4
, R5
),
4140 BPF_ALU64_REG(BPF_SUB
, R4
, R6
),
4141 BPF_ALU64_REG(BPF_SUB
, R4
, R7
),
4142 BPF_ALU64_REG(BPF_SUB
, R4
, R8
),
4143 BPF_ALU64_REG(BPF_SUB
, R4
, R9
),
4144 BPF_ALU64_IMM(BPF_SUB
, R4
, 10),
4145 BPF_ALU64_REG(BPF_SUB
, R5
, R0
),
4146 BPF_ALU64_REG(BPF_SUB
, R5
, R1
),
4147 BPF_ALU64_REG(BPF_SUB
, R5
, R2
),
4148 BPF_ALU64_REG(BPF_SUB
, R5
, R3
),
4149 BPF_ALU64_REG(BPF_SUB
, R5
, R4
),
4150 BPF_ALU64_REG(BPF_SUB
, R5
, R6
),
4151 BPF_ALU64_REG(BPF_SUB
, R5
, R7
),
4152 BPF_ALU64_REG(BPF_SUB
, R5
, R8
),
4153 BPF_ALU64_REG(BPF_SUB
, R5
, R9
),
4154 BPF_ALU64_IMM(BPF_SUB
, R5
, 10),
4155 BPF_ALU64_REG(BPF_SUB
, R6
, R0
),
4156 BPF_ALU64_REG(BPF_SUB
, R6
, R1
),
4157 BPF_ALU64_REG(BPF_SUB
, R6
, R2
),
4158 BPF_ALU64_REG(BPF_SUB
, R6
, R3
),
4159 BPF_ALU64_REG(BPF_SUB
, R6
, R4
),
4160 BPF_ALU64_REG(BPF_SUB
, R6
, R5
),
4161 BPF_ALU64_REG(BPF_SUB
, R6
, R7
),
4162 BPF_ALU64_REG(BPF_SUB
, R6
, R8
),
4163 BPF_ALU64_REG(BPF_SUB
, R6
, R9
),
4164 BPF_ALU64_IMM(BPF_SUB
, R6
, 10),
4165 BPF_ALU64_REG(BPF_SUB
, R7
, R0
),
4166 BPF_ALU64_REG(BPF_SUB
, R7
, R1
),
4167 BPF_ALU64_REG(BPF_SUB
, R7
, R2
),
4168 BPF_ALU64_REG(BPF_SUB
, R7
, R3
),
4169 BPF_ALU64_REG(BPF_SUB
, R7
, R4
),
4170 BPF_ALU64_REG(BPF_SUB
, R7
, R5
),
4171 BPF_ALU64_REG(BPF_SUB
, R7
, R6
),
4172 BPF_ALU64_REG(BPF_SUB
, R7
, R8
),
4173 BPF_ALU64_REG(BPF_SUB
, R7
, R9
),
4174 BPF_ALU64_IMM(BPF_SUB
, R7
, 10),
4175 BPF_ALU64_REG(BPF_SUB
, R8
, R0
),
4176 BPF_ALU64_REG(BPF_SUB
, R8
, R1
),
4177 BPF_ALU64_REG(BPF_SUB
, R8
, R2
),
4178 BPF_ALU64_REG(BPF_SUB
, R8
, R3
),
4179 BPF_ALU64_REG(BPF_SUB
, R8
, R4
),
4180 BPF_ALU64_REG(BPF_SUB
, R8
, R5
),
4181 BPF_ALU64_REG(BPF_SUB
, R8
, R6
),
4182 BPF_ALU64_REG(BPF_SUB
, R8
, R7
),
4183 BPF_ALU64_REG(BPF_SUB
, R8
, R9
),
4184 BPF_ALU64_IMM(BPF_SUB
, R8
, 10),
4185 BPF_ALU64_REG(BPF_SUB
, R9
, R0
),
4186 BPF_ALU64_REG(BPF_SUB
, R9
, R1
),
4187 BPF_ALU64_REG(BPF_SUB
, R9
, R2
),
4188 BPF_ALU64_REG(BPF_SUB
, R9
, R3
),
4189 BPF_ALU64_REG(BPF_SUB
, R9
, R4
),
4190 BPF_ALU64_REG(BPF_SUB
, R9
, R5
),
4191 BPF_ALU64_REG(BPF_SUB
, R9
, R6
),
4192 BPF_ALU64_REG(BPF_SUB
, R9
, R7
),
4193 BPF_ALU64_REG(BPF_SUB
, R9
, R8
),
4194 BPF_ALU64_IMM(BPF_SUB
, R9
, 10),
4195 BPF_ALU64_IMM(BPF_SUB
, R0
, 10),
4196 BPF_ALU64_IMM(BPF_NEG
, R0
, 0),
4197 BPF_ALU64_REG(BPF_SUB
, R0
, R1
),
4198 BPF_ALU64_REG(BPF_SUB
, R0
, R2
),
4199 BPF_ALU64_REG(BPF_SUB
, R0
, R3
),
4200 BPF_ALU64_REG(BPF_SUB
, R0
, R4
),
4201 BPF_ALU64_REG(BPF_SUB
, R0
, R5
),
4202 BPF_ALU64_REG(BPF_SUB
, R0
, R6
),
4203 BPF_ALU64_REG(BPF_SUB
, R0
, R7
),
4204 BPF_ALU64_REG(BPF_SUB
, R0
, R8
),
4205 BPF_ALU64_REG(BPF_SUB
, R0
, R9
),
4212 { /* Mainly checking JIT here. */
4215 BPF_ALU64_REG(BPF_SUB
, R0
, R0
),
4216 BPF_ALU64_REG(BPF_XOR
, R1
, R1
),
4217 BPF_JMP_REG(BPF_JEQ
, R0
, R1
, 1),
4219 BPF_ALU64_IMM(BPF_MOV
, R0
, 10),
4220 BPF_ALU64_IMM(BPF_MOV
, R1
, -1),
4221 BPF_ALU64_REG(BPF_SUB
, R1
, R1
),
4222 BPF_ALU64_REG(BPF_XOR
, R2
, R2
),
4223 BPF_JMP_REG(BPF_JEQ
, R1
, R2
, 1),
4225 BPF_ALU64_REG(BPF_SUB
, R2
, R2
),
4226 BPF_ALU64_REG(BPF_XOR
, R3
, R3
),
4227 BPF_ALU64_IMM(BPF_MOV
, R0
, 10),
4228 BPF_ALU64_IMM(BPF_MOV
, R1
, -1),
4229 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 1),
4231 BPF_ALU64_REG(BPF_SUB
, R3
, R3
),
4232 BPF_ALU64_REG(BPF_XOR
, R4
, R4
),
4233 BPF_ALU64_IMM(BPF_MOV
, R2
, 1),
4234 BPF_ALU64_IMM(BPF_MOV
, R5
, -1),
4235 BPF_JMP_REG(BPF_JEQ
, R3
, R4
, 1),
4237 BPF_ALU64_REG(BPF_SUB
, R4
, R4
),
4238 BPF_ALU64_REG(BPF_XOR
, R5
, R5
),
4239 BPF_ALU64_IMM(BPF_MOV
, R3
, 1),
4240 BPF_ALU64_IMM(BPF_MOV
, R7
, -1),
4241 BPF_JMP_REG(BPF_JEQ
, R5
, R4
, 1),
4243 BPF_ALU64_IMM(BPF_MOV
, R5
, 1),
4244 BPF_ALU64_REG(BPF_SUB
, R5
, R5
),
4245 BPF_ALU64_REG(BPF_XOR
, R6
, R6
),
4246 BPF_ALU64_IMM(BPF_MOV
, R1
, 1),
4247 BPF_ALU64_IMM(BPF_MOV
, R8
, -1),
4248 BPF_JMP_REG(BPF_JEQ
, R5
, R6
, 1),
4250 BPF_ALU64_REG(BPF_SUB
, R6
, R6
),
4251 BPF_ALU64_REG(BPF_XOR
, R7
, R7
),
4252 BPF_JMP_REG(BPF_JEQ
, R7
, R6
, 1),
4254 BPF_ALU64_REG(BPF_SUB
, R7
, R7
),
4255 BPF_ALU64_REG(BPF_XOR
, R8
, R8
),
4256 BPF_JMP_REG(BPF_JEQ
, R7
, R8
, 1),
4258 BPF_ALU64_REG(BPF_SUB
, R8
, R8
),
4259 BPF_ALU64_REG(BPF_XOR
, R9
, R9
),
4260 BPF_JMP_REG(BPF_JEQ
, R9
, R8
, 1),
4262 BPF_ALU64_REG(BPF_SUB
, R9
, R9
),
4263 BPF_ALU64_REG(BPF_XOR
, R0
, R0
),
4264 BPF_JMP_REG(BPF_JEQ
, R9
, R0
, 1),
4266 BPF_ALU64_REG(BPF_SUB
, R1
, R1
),
4267 BPF_ALU64_REG(BPF_XOR
, R0
, R0
),
4268 BPF_JMP_REG(BPF_JEQ
, R9
, R0
, 2),
4269 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
4271 BPF_ALU64_IMM(BPF_MOV
, R0
, 1),
4278 { /* Mainly checking JIT here. */
4281 BPF_ALU64_IMM(BPF_MOV
, R0
, 11),
4282 BPF_ALU64_IMM(BPF_MOV
, R1
, 1),
4283 BPF_ALU64_IMM(BPF_MOV
, R2
, 2),
4284 BPF_ALU64_IMM(BPF_MOV
, R3
, 3),
4285 BPF_ALU64_IMM(BPF_MOV
, R4
, 4),
4286 BPF_ALU64_IMM(BPF_MOV
, R5
, 5),
4287 BPF_ALU64_IMM(BPF_MOV
, R6
, 6),
4288 BPF_ALU64_IMM(BPF_MOV
, R7
, 7),
4289 BPF_ALU64_IMM(BPF_MOV
, R8
, 8),
4290 BPF_ALU64_IMM(BPF_MOV
, R9
, 9),
4291 BPF_ALU64_REG(BPF_MUL
, R0
, R0
),
4292 BPF_ALU64_REG(BPF_MUL
, R0
, R1
),
4293 BPF_ALU64_REG(BPF_MUL
, R0
, R2
),
4294 BPF_ALU64_REG(BPF_MUL
, R0
, R3
),
4295 BPF_ALU64_REG(BPF_MUL
, R0
, R4
),
4296 BPF_ALU64_REG(BPF_MUL
, R0
, R5
),
4297 BPF_ALU64_REG(BPF_MUL
, R0
, R6
),
4298 BPF_ALU64_REG(BPF_MUL
, R0
, R7
),
4299 BPF_ALU64_REG(BPF_MUL
, R0
, R8
),
4300 BPF_ALU64_REG(BPF_MUL
, R0
, R9
),
4301 BPF_ALU64_IMM(BPF_MUL
, R0
, 10),
4302 BPF_JMP_IMM(BPF_JEQ
, R0
, 439084800, 1),
4304 BPF_ALU64_REG(BPF_MUL
, R1
, R0
),
4305 BPF_ALU64_REG(BPF_MUL
, R1
, R2
),
4306 BPF_ALU64_REG(BPF_MUL
, R1
, R3
),
4307 BPF_ALU64_REG(BPF_MUL
, R1
, R4
),
4308 BPF_ALU64_REG(BPF_MUL
, R1
, R5
),
4309 BPF_ALU64_REG(BPF_MUL
, R1
, R6
),
4310 BPF_ALU64_REG(BPF_MUL
, R1
, R7
),
4311 BPF_ALU64_REG(BPF_MUL
, R1
, R8
),
4312 BPF_ALU64_REG(BPF_MUL
, R1
, R9
),
4313 BPF_ALU64_IMM(BPF_MUL
, R1
, 10),
4314 BPF_ALU64_REG(BPF_MOV
, R2
, R1
),
4315 BPF_ALU64_IMM(BPF_RSH
, R2
, 32),
4316 BPF_JMP_IMM(BPF_JEQ
, R2
, 0x5a924, 1),
4318 BPF_ALU64_IMM(BPF_LSH
, R1
, 32),
4319 BPF_ALU64_IMM(BPF_ARSH
, R1
, 32),
4320 BPF_JMP_IMM(BPF_JEQ
, R1
, 0xebb90000, 1),
4322 BPF_ALU64_REG(BPF_MUL
, R2
, R0
),
4323 BPF_ALU64_REG(BPF_MUL
, R2
, R1
),
4324 BPF_ALU64_REG(BPF_MUL
, R2
, R3
),
4325 BPF_ALU64_REG(BPF_MUL
, R2
, R4
),
4326 BPF_ALU64_REG(BPF_MUL
, R2
, R5
),
4327 BPF_ALU64_REG(BPF_MUL
, R2
, R6
),
4328 BPF_ALU64_REG(BPF_MUL
, R2
, R7
),
4329 BPF_ALU64_REG(BPF_MUL
, R2
, R8
),
4330 BPF_ALU64_REG(BPF_MUL
, R2
, R9
),
4331 BPF_ALU64_IMM(BPF_MUL
, R2
, 10),
4332 BPF_ALU64_IMM(BPF_RSH
, R2
, 32),
4333 BPF_ALU64_REG(BPF_MOV
, R0
, R2
),
4338 { { 0, 0x35d97ef2 } }
4340 { /* Mainly checking JIT here. */
4343 BPF_LD_IMM64(R0
, 0xffffffffffffffffLL
),
4344 BPF_MOV64_REG(R1
, R0
),
4345 BPF_MOV64_REG(R2
, R1
),
4346 BPF_MOV64_REG(R3
, R2
),
4347 BPF_MOV64_REG(R4
, R3
),
4348 BPF_MOV64_REG(R5
, R4
),
4349 BPF_MOV64_REG(R6
, R5
),
4350 BPF_MOV64_REG(R7
, R6
),
4351 BPF_MOV64_REG(R8
, R7
),
4352 BPF_MOV64_REG(R9
, R8
),
4353 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
4354 BPF_ALU64_IMM(BPF_MOV
, R1
, 0),
4355 BPF_ALU64_IMM(BPF_MOV
, R2
, 0),
4356 BPF_ALU64_IMM(BPF_MOV
, R3
, 0),
4357 BPF_ALU64_IMM(BPF_MOV
, R4
, 0),
4358 BPF_ALU64_IMM(BPF_MOV
, R5
, 0),
4359 BPF_ALU64_IMM(BPF_MOV
, R6
, 0),
4360 BPF_ALU64_IMM(BPF_MOV
, R7
, 0),
4361 BPF_ALU64_IMM(BPF_MOV
, R8
, 0),
4362 BPF_ALU64_IMM(BPF_MOV
, R9
, 0),
4363 BPF_ALU64_REG(BPF_ADD
, R0
, R0
),
4364 BPF_ALU64_REG(BPF_ADD
, R0
, R1
),
4365 BPF_ALU64_REG(BPF_ADD
, R0
, R2
),
4366 BPF_ALU64_REG(BPF_ADD
, R0
, R3
),
4367 BPF_ALU64_REG(BPF_ADD
, R0
, R4
),
4368 BPF_ALU64_REG(BPF_ADD
, R0
, R5
),
4369 BPF_ALU64_REG(BPF_ADD
, R0
, R6
),
4370 BPF_ALU64_REG(BPF_ADD
, R0
, R7
),
4371 BPF_ALU64_REG(BPF_ADD
, R0
, R8
),
4372 BPF_ALU64_REG(BPF_ADD
, R0
, R9
),
4373 BPF_ALU64_IMM(BPF_ADD
, R0
, 0xfefe),
4380 { /* Mainly checking JIT here. */
4383 BPF_LD_IMM64(R0
, 0xffffffffffffffffLL
),
4384 BPF_MOV64_REG(R1
, R0
),
4385 BPF_MOV64_REG(R2
, R1
),
4386 BPF_MOV64_REG(R3
, R2
),
4387 BPF_MOV64_REG(R4
, R3
),
4388 BPF_MOV64_REG(R5
, R4
),
4389 BPF_MOV64_REG(R6
, R5
),
4390 BPF_MOV64_REG(R7
, R6
),
4391 BPF_MOV64_REG(R8
, R7
),
4392 BPF_MOV64_REG(R9
, R8
),
4393 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
4394 BPF_ALU32_IMM(BPF_MOV
, R1
, 0),
4395 BPF_ALU32_IMM(BPF_MOV
, R2
, 0),
4396 BPF_ALU32_IMM(BPF_MOV
, R3
, 0),
4397 BPF_ALU32_IMM(BPF_MOV
, R4
, 0),
4398 BPF_ALU32_IMM(BPF_MOV
, R5
, 0),
4399 BPF_ALU32_IMM(BPF_MOV
, R6
, 0),
4400 BPF_ALU32_IMM(BPF_MOV
, R7
, 0),
4401 BPF_ALU32_IMM(BPF_MOV
, R8
, 0),
4402 BPF_ALU32_IMM(BPF_MOV
, R9
, 0),
4403 BPF_ALU64_REG(BPF_ADD
, R0
, R0
),
4404 BPF_ALU64_REG(BPF_ADD
, R0
, R1
),
4405 BPF_ALU64_REG(BPF_ADD
, R0
, R2
),
4406 BPF_ALU64_REG(BPF_ADD
, R0
, R3
),
4407 BPF_ALU64_REG(BPF_ADD
, R0
, R4
),
4408 BPF_ALU64_REG(BPF_ADD
, R0
, R5
),
4409 BPF_ALU64_REG(BPF_ADD
, R0
, R6
),
4410 BPF_ALU64_REG(BPF_ADD
, R0
, R7
),
4411 BPF_ALU64_REG(BPF_ADD
, R0
, R8
),
4412 BPF_ALU64_REG(BPF_ADD
, R0
, R9
),
4413 BPF_ALU64_IMM(BPF_ADD
, R0
, 0xfefe),
4420 { /* Mainly checking JIT here. */
4423 BPF_LD_IMM64(R0
, 0xffffffffffffffffLL
),
4424 BPF_MOV64_REG(R1
, R0
),
4425 BPF_MOV64_REG(R2
, R1
),
4426 BPF_MOV64_REG(R3
, R2
),
4427 BPF_MOV64_REG(R4
, R3
),
4428 BPF_MOV64_REG(R5
, R4
),
4429 BPF_MOV64_REG(R6
, R5
),
4430 BPF_MOV64_REG(R7
, R6
),
4431 BPF_MOV64_REG(R8
, R7
),
4432 BPF_MOV64_REG(R9
, R8
),
4433 BPF_LD_IMM64(R0
, 0x0LL
),
4434 BPF_LD_IMM64(R1
, 0x0LL
),
4435 BPF_LD_IMM64(R2
, 0x0LL
),
4436 BPF_LD_IMM64(R3
, 0x0LL
),
4437 BPF_LD_IMM64(R4
, 0x0LL
),
4438 BPF_LD_IMM64(R5
, 0x0LL
),
4439 BPF_LD_IMM64(R6
, 0x0LL
),
4440 BPF_LD_IMM64(R7
, 0x0LL
),
4441 BPF_LD_IMM64(R8
, 0x0LL
),
4442 BPF_LD_IMM64(R9
, 0x0LL
),
4443 BPF_ALU64_REG(BPF_ADD
, R0
, R0
),
4444 BPF_ALU64_REG(BPF_ADD
, R0
, R1
),
4445 BPF_ALU64_REG(BPF_ADD
, R0
, R2
),
4446 BPF_ALU64_REG(BPF_ADD
, R0
, R3
),
4447 BPF_ALU64_REG(BPF_ADD
, R0
, R4
),
4448 BPF_ALU64_REG(BPF_ADD
, R0
, R5
),
4449 BPF_ALU64_REG(BPF_ADD
, R0
, R6
),
4450 BPF_ALU64_REG(BPF_ADD
, R0
, R7
),
4451 BPF_ALU64_REG(BPF_ADD
, R0
, R8
),
4452 BPF_ALU64_REG(BPF_ADD
, R0
, R9
),
4453 BPF_ALU64_IMM(BPF_ADD
, R0
, 0xfefe),
4463 BPF_ALU64_IMM(BPF_MOV
, R0
, 11),
4464 BPF_ALU64_IMM(BPF_ADD
, R0
, -1),
4465 BPF_ALU64_IMM(BPF_MOV
, R2
, 2),
4466 BPF_ALU64_IMM(BPF_XOR
, R2
, 3),
4467 BPF_ALU64_REG(BPF_DIV
, R0
, R2
),
4468 BPF_JMP_IMM(BPF_JEQ
, R0
, 10, 1),
4470 BPF_ALU64_IMM(BPF_MOD
, R0
, 3),
4471 BPF_JMP_IMM(BPF_JEQ
, R0
, 1, 1),
4473 BPF_ALU64_IMM(BPF_MOV
, R0
, -1),
4481 "INT: shifts by register",
4483 BPF_MOV64_IMM(R0
, -1234),
4484 BPF_MOV64_IMM(R1
, 1),
4485 BPF_ALU32_REG(BPF_RSH
, R0
, R1
),
4486 BPF_JMP_IMM(BPF_JEQ
, R0
, 0x7ffffd97, 1),
4488 BPF_MOV64_IMM(R2
, 1),
4489 BPF_ALU64_REG(BPF_LSH
, R0
, R2
),
4490 BPF_MOV32_IMM(R4
, -1234),
4491 BPF_JMP_REG(BPF_JEQ
, R0
, R4
, 1),
4493 BPF_ALU64_IMM(BPF_AND
, R4
, 63),
4494 BPF_ALU64_REG(BPF_LSH
, R0
, R4
), /* R0 <= 46 */
4495 BPF_MOV64_IMM(R3
, 47),
4496 BPF_ALU64_REG(BPF_ARSH
, R0
, R3
),
4497 BPF_JMP_IMM(BPF_JEQ
, R0
, -617, 1),
4499 BPF_MOV64_IMM(R2
, 1),
4500 BPF_ALU64_REG(BPF_LSH
, R4
, R2
), /* R4 = 46 << 1 */
4501 BPF_JMP_IMM(BPF_JEQ
, R4
, 92, 1),
4503 BPF_MOV64_IMM(R4
, 4),
4504 BPF_ALU64_REG(BPF_LSH
, R4
, R4
), /* R4 = 4 << 4 */
4505 BPF_JMP_IMM(BPF_JEQ
, R4
, 64, 1),
4507 BPF_MOV64_IMM(R4
, 5),
4508 BPF_ALU32_REG(BPF_LSH
, R4
, R4
), /* R4 = 5 << 5 */
4509 BPF_JMP_IMM(BPF_JEQ
, R4
, 160, 1),
4511 BPF_MOV64_IMM(R0
, -1),
4520 "INT: 32-bit context pointer word order and zero-extension",
4522 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
4523 BPF_JMP32_IMM(BPF_JEQ
, R1
, 0, 3),
4524 BPF_ALU64_IMM(BPF_RSH
, R1
, 32),
4525 BPF_JMP32_IMM(BPF_JNE
, R1
, 0, 1),
4526 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
4535 "check: missing ret",
4537 BPF_STMT(BPF_LD
| BPF_IMM
, 1),
4539 CLASSIC
| FLAG_NO_DATA
| FLAG_EXPECTED_FAIL
,
4542 .fill_helper
= NULL
,
4543 .expected_errcode
= -EINVAL
,
4548 BPF_STMT(BPF_ALU
| BPF_DIV
| BPF_K
, 0),
4549 BPF_STMT(BPF_RET
| BPF_K
, 0)
4551 CLASSIC
| FLAG_NO_DATA
| FLAG_EXPECTED_FAIL
,
4554 .fill_helper
= NULL
,
4555 .expected_errcode
= -EINVAL
,
4558 "check: unknown insn",
4560 /* seccomp insn, rejected in socket filter */
4561 BPF_STMT(BPF_LDX
| BPF_W
| BPF_ABS
, 0),
4562 BPF_STMT(BPF_RET
| BPF_K
, 0)
4564 CLASSIC
| FLAG_EXPECTED_FAIL
,
4567 .fill_helper
= NULL
,
4568 .expected_errcode
= -EINVAL
,
4571 "check: out of range spill/fill",
4573 BPF_STMT(BPF_STX
, 16),
4574 BPF_STMT(BPF_RET
| BPF_K
, 0)
4576 CLASSIC
| FLAG_NO_DATA
| FLAG_EXPECTED_FAIL
,
4579 .fill_helper
= NULL
,
4580 .expected_errcode
= -EINVAL
,
4585 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
4586 BPF_JUMP(BPF_JMP
| BPF_JGE
, 0, 13, 15),
4587 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
4588 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
4589 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
4590 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
4591 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
4592 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
4593 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
4594 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
4595 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
4596 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
4597 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
4598 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
4599 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
4600 BPF_JUMP(BPF_JMP
| BPF_JEQ
, 0x90c2894d, 3, 4),
4601 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
4602 BPF_JUMP(BPF_JMP
| BPF_JEQ
, 0x90c2894d, 1, 2),
4603 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
4604 BPF_JUMP(BPF_JMP
| BPF_JGE
, 0, 14, 15),
4605 BPF_JUMP(BPF_JMP
| BPF_JGE
, 0, 13, 14),
4606 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
4607 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
4608 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
4609 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
4610 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
4611 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
4612 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
4613 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
4614 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
4615 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
4616 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
4617 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
4618 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
4619 BPF_JUMP(BPF_JMP
| BPF_JEQ
, 0x2ac28349, 2, 3),
4620 BPF_JUMP(BPF_JMP
| BPF_JEQ
, 0x2ac28349, 1, 2),
4621 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
4622 BPF_JUMP(BPF_JMP
| BPF_JGE
, 0, 14, 15),
4623 BPF_JUMP(BPF_JMP
| BPF_JGE
, 0, 13, 14),
4624 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
4625 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
4626 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
4627 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
4628 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
4629 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
4630 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
4631 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
4632 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
4633 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
4634 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
4635 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
4636 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
4637 BPF_JUMP(BPF_JMP
| BPF_JEQ
, 0x90d2ff41, 2, 3),
4638 BPF_JUMP(BPF_JMP
| BPF_JEQ
, 0x90d2ff41, 1, 2),
4639 BPF_STMT(BPF_LD
| BPF_H
| BPF_ABS
, 0),
4640 BPF_STMT(BPF_RET
| BPF_A
, 0),
4641 BPF_STMT(BPF_RET
| BPF_A
, 0),
4644 { 0x00, 0x1b, 0x21, 0x3c, 0x9d, 0xf8,
4645 0x90, 0xe2, 0xba, 0x0a, 0x56, 0xb4,
4647 0x45, 0x00, 0x00, 0x28, 0x00, 0x00,
4648 0x20, 0x00, 0x40, 0x11, 0x00, 0x00, /* IP header */
4649 0xc0, 0xa8, 0x33, 0x01,
4650 0xc0, 0xa8, 0x33, 0x02,
4653 0x00, 0x14, 0x00, 0x00,
4654 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
4655 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
4656 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
4657 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
4658 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
4659 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
4660 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
4661 0xcc, 0xcc, 0xcc, 0xcc },
4667 BPF_STMT(BPF_RET
| BPF_X
, 0),
4669 CLASSIC
| FLAG_NO_DATA
| FLAG_EXPECTED_FAIL
,
4672 .fill_helper
= NULL
,
4673 .expected_errcode
= -EINVAL
,
4676 "check: LDX + RET X",
4678 BPF_STMT(BPF_LDX
| BPF_IMM
, 42),
4679 BPF_STMT(BPF_RET
| BPF_X
, 0),
4681 CLASSIC
| FLAG_NO_DATA
| FLAG_EXPECTED_FAIL
,
4684 .fill_helper
= NULL
,
4685 .expected_errcode
= -EINVAL
,
4687 { /* Mainly checking JIT here. */
4688 "M[]: alt STX + LDX",
4690 BPF_STMT(BPF_LDX
| BPF_IMM
, 100),
4691 BPF_STMT(BPF_STX
, 0),
4692 BPF_STMT(BPF_LDX
| BPF_MEM
, 0),
4693 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
4694 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 1),
4695 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
4696 BPF_STMT(BPF_STX
, 1),
4697 BPF_STMT(BPF_LDX
| BPF_MEM
, 1),
4698 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
4699 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 1),
4700 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
4701 BPF_STMT(BPF_STX
, 2),
4702 BPF_STMT(BPF_LDX
| BPF_MEM
, 2),
4703 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
4704 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 1),
4705 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
4706 BPF_STMT(BPF_STX
, 3),
4707 BPF_STMT(BPF_LDX
| BPF_MEM
, 3),
4708 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
4709 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 1),
4710 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
4711 BPF_STMT(BPF_STX
, 4),
4712 BPF_STMT(BPF_LDX
| BPF_MEM
, 4),
4713 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
4714 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 1),
4715 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
4716 BPF_STMT(BPF_STX
, 5),
4717 BPF_STMT(BPF_LDX
| BPF_MEM
, 5),
4718 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
4719 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 1),
4720 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
4721 BPF_STMT(BPF_STX
, 6),
4722 BPF_STMT(BPF_LDX
| BPF_MEM
, 6),
4723 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
4724 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 1),
4725 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
4726 BPF_STMT(BPF_STX
, 7),
4727 BPF_STMT(BPF_LDX
| BPF_MEM
, 7),
4728 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
4729 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 1),
4730 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
4731 BPF_STMT(BPF_STX
, 8),
4732 BPF_STMT(BPF_LDX
| BPF_MEM
, 8),
4733 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
4734 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 1),
4735 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
4736 BPF_STMT(BPF_STX
, 9),
4737 BPF_STMT(BPF_LDX
| BPF_MEM
, 9),
4738 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
4739 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 1),
4740 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
4741 BPF_STMT(BPF_STX
, 10),
4742 BPF_STMT(BPF_LDX
| BPF_MEM
, 10),
4743 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
4744 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 1),
4745 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
4746 BPF_STMT(BPF_STX
, 11),
4747 BPF_STMT(BPF_LDX
| BPF_MEM
, 11),
4748 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
4749 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 1),
4750 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
4751 BPF_STMT(BPF_STX
, 12),
4752 BPF_STMT(BPF_LDX
| BPF_MEM
, 12),
4753 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
4754 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 1),
4755 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
4756 BPF_STMT(BPF_STX
, 13),
4757 BPF_STMT(BPF_LDX
| BPF_MEM
, 13),
4758 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
4759 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 1),
4760 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
4761 BPF_STMT(BPF_STX
, 14),
4762 BPF_STMT(BPF_LDX
| BPF_MEM
, 14),
4763 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
4764 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 1),
4765 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
4766 BPF_STMT(BPF_STX
, 15),
4767 BPF_STMT(BPF_LDX
| BPF_MEM
, 15),
4768 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
4769 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 1),
4770 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
4771 BPF_STMT(BPF_RET
| BPF_A
, 0),
4773 CLASSIC
| FLAG_NO_DATA
,
4777 { /* Mainly checking JIT here. */
4778 "M[]: full STX + full LDX",
4780 BPF_STMT(BPF_LDX
| BPF_IMM
, 0xbadfeedb),
4781 BPF_STMT(BPF_STX
, 0),
4782 BPF_STMT(BPF_LDX
| BPF_IMM
, 0xecabedae),
4783 BPF_STMT(BPF_STX
, 1),
4784 BPF_STMT(BPF_LDX
| BPF_IMM
, 0xafccfeaf),
4785 BPF_STMT(BPF_STX
, 2),
4786 BPF_STMT(BPF_LDX
| BPF_IMM
, 0xbffdcedc),
4787 BPF_STMT(BPF_STX
, 3),
4788 BPF_STMT(BPF_LDX
| BPF_IMM
, 0xfbbbdccb),
4789 BPF_STMT(BPF_STX
, 4),
4790 BPF_STMT(BPF_LDX
| BPF_IMM
, 0xfbabcbda),
4791 BPF_STMT(BPF_STX
, 5),
4792 BPF_STMT(BPF_LDX
| BPF_IMM
, 0xaedecbdb),
4793 BPF_STMT(BPF_STX
, 6),
4794 BPF_STMT(BPF_LDX
| BPF_IMM
, 0xadebbade),
4795 BPF_STMT(BPF_STX
, 7),
4796 BPF_STMT(BPF_LDX
| BPF_IMM
, 0xfcfcfaec),
4797 BPF_STMT(BPF_STX
, 8),
4798 BPF_STMT(BPF_LDX
| BPF_IMM
, 0xbcdddbdc),
4799 BPF_STMT(BPF_STX
, 9),
4800 BPF_STMT(BPF_LDX
| BPF_IMM
, 0xfeefdfac),
4801 BPF_STMT(BPF_STX
, 10),
4802 BPF_STMT(BPF_LDX
| BPF_IMM
, 0xcddcdeea),
4803 BPF_STMT(BPF_STX
, 11),
4804 BPF_STMT(BPF_LDX
| BPF_IMM
, 0xaccfaebb),
4805 BPF_STMT(BPF_STX
, 12),
4806 BPF_STMT(BPF_LDX
| BPF_IMM
, 0xbdcccdcf),
4807 BPF_STMT(BPF_STX
, 13),
4808 BPF_STMT(BPF_LDX
| BPF_IMM
, 0xaaedecde),
4809 BPF_STMT(BPF_STX
, 14),
4810 BPF_STMT(BPF_LDX
| BPF_IMM
, 0xfaeacdad),
4811 BPF_STMT(BPF_STX
, 15),
4812 BPF_STMT(BPF_LDX
| BPF_MEM
, 0),
4813 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
4814 BPF_STMT(BPF_LDX
| BPF_MEM
, 1),
4815 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
4816 BPF_STMT(BPF_LDX
| BPF_MEM
, 2),
4817 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
4818 BPF_STMT(BPF_LDX
| BPF_MEM
, 3),
4819 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
4820 BPF_STMT(BPF_LDX
| BPF_MEM
, 4),
4821 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
4822 BPF_STMT(BPF_LDX
| BPF_MEM
, 5),
4823 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
4824 BPF_STMT(BPF_LDX
| BPF_MEM
, 6),
4825 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
4826 BPF_STMT(BPF_LDX
| BPF_MEM
, 7),
4827 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
4828 BPF_STMT(BPF_LDX
| BPF_MEM
, 8),
4829 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
4830 BPF_STMT(BPF_LDX
| BPF_MEM
, 9),
4831 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
4832 BPF_STMT(BPF_LDX
| BPF_MEM
, 10),
4833 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
4834 BPF_STMT(BPF_LDX
| BPF_MEM
, 11),
4835 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
4836 BPF_STMT(BPF_LDX
| BPF_MEM
, 12),
4837 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
4838 BPF_STMT(BPF_LDX
| BPF_MEM
, 13),
4839 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
4840 BPF_STMT(BPF_LDX
| BPF_MEM
, 14),
4841 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
4842 BPF_STMT(BPF_LDX
| BPF_MEM
, 15),
4843 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
4844 BPF_STMT(BPF_RET
| BPF_A
, 0),
4846 CLASSIC
| FLAG_NO_DATA
,
4848 { { 0, 0x2a5a5e5 } },
4851 "check: SKF_AD_MAX",
4853 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
4854 SKF_AD_OFF
+ SKF_AD_MAX
),
4855 BPF_STMT(BPF_RET
| BPF_A
, 0),
4857 CLASSIC
| FLAG_NO_DATA
| FLAG_EXPECTED_FAIL
,
4860 .fill_helper
= NULL
,
4861 .expected_errcode
= -EINVAL
,
4863 { /* Passes checker but fails during runtime. */
4864 "LD [SKF_AD_OFF-1]",
4866 BPF_STMT(BPF_LD
| BPF_W
| BPF_ABS
,
4868 BPF_STMT(BPF_RET
| BPF_K
, 1),
4875 "load 64-bit immediate",
4877 BPF_LD_IMM64(R1
, 0x567800001234LL
),
4878 BPF_MOV64_REG(R2
, R1
),
4879 BPF_MOV64_REG(R3
, R2
),
4880 BPF_ALU64_IMM(BPF_RSH
, R2
, 32),
4881 BPF_ALU64_IMM(BPF_LSH
, R3
, 32),
4882 BPF_ALU64_IMM(BPF_RSH
, R3
, 32),
4883 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
4884 BPF_JMP_IMM(BPF_JEQ
, R2
, 0x5678, 1),
4886 BPF_JMP_IMM(BPF_JEQ
, R3
, 0x1234, 1),
4888 BPF_LD_IMM64(R0
, 0x1ffffffffLL
),
4889 BPF_ALU64_IMM(BPF_RSH
, R0
, 32), /* R0 = 1 */
4896 /* BPF_ALU | BPF_MOV | BPF_X */
4898 "ALU_MOV_X: dst = 2",
4900 BPF_ALU32_IMM(BPF_MOV
, R1
, 2),
4901 BPF_ALU32_REG(BPF_MOV
, R0
, R1
),
4909 "ALU_MOV_X: dst = 4294967295",
4911 BPF_ALU32_IMM(BPF_MOV
, R1
, 4294967295U),
4912 BPF_ALU32_REG(BPF_MOV
, R0
, R1
),
4917 { { 0, 4294967295U } },
4920 "ALU64_MOV_X: dst = 2",
4922 BPF_ALU32_IMM(BPF_MOV
, R1
, 2),
4923 BPF_ALU64_REG(BPF_MOV
, R0
, R1
),
4931 "ALU64_MOV_X: dst = 4294967295",
4933 BPF_ALU32_IMM(BPF_MOV
, R1
, 4294967295U),
4934 BPF_ALU64_REG(BPF_MOV
, R0
, R1
),
4939 { { 0, 4294967295U } },
4941 /* BPF_ALU | BPF_MOV | BPF_K */
4943 "ALU_MOV_K: dst = 2",
4945 BPF_ALU32_IMM(BPF_MOV
, R0
, 2),
4953 "ALU_MOV_K: dst = 4294967295",
4955 BPF_ALU32_IMM(BPF_MOV
, R0
, 4294967295U),
4960 { { 0, 4294967295U } },
4963 "ALU_MOV_K: 0x0000ffffffff0000 = 0x00000000ffffffff",
4965 BPF_LD_IMM64(R2
, 0x0000ffffffff0000LL
),
4966 BPF_LD_IMM64(R3
, 0x00000000ffffffffLL
),
4967 BPF_ALU32_IMM(BPF_MOV
, R2
, 0xffffffff),
4968 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
4969 BPF_MOV32_IMM(R0
, 2),
4971 BPF_MOV32_IMM(R0
, 1),
4979 "ALU_MOV_K: small negative",
4981 BPF_ALU32_IMM(BPF_MOV
, R0
, -123),
4989 "ALU_MOV_K: small negative zero extension",
4991 BPF_ALU32_IMM(BPF_MOV
, R0
, -123),
4992 BPF_ALU64_IMM(BPF_RSH
, R0
, 32),
5000 "ALU_MOV_K: large negative",
5002 BPF_ALU32_IMM(BPF_MOV
, R0
, -123456789),
5007 { { 0, -123456789 } }
5010 "ALU_MOV_K: large negative zero extension",
5012 BPF_ALU32_IMM(BPF_MOV
, R0
, -123456789),
5013 BPF_ALU64_IMM(BPF_RSH
, R0
, 32),
5021 "ALU64_MOV_K: dst = 2",
5023 BPF_ALU64_IMM(BPF_MOV
, R0
, 2),
5031 "ALU64_MOV_K: dst = 2147483647",
5033 BPF_ALU64_IMM(BPF_MOV
, R0
, 2147483647),
5038 { { 0, 2147483647 } },
5041 "ALU64_OR_K: dst = 0x0",
5043 BPF_LD_IMM64(R2
, 0x0000ffffffff0000LL
),
5044 BPF_LD_IMM64(R3
, 0x0),
5045 BPF_ALU64_IMM(BPF_MOV
, R2
, 0x0),
5046 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
5047 BPF_MOV32_IMM(R0
, 2),
5049 BPF_MOV32_IMM(R0
, 1),
5057 "ALU64_MOV_K: dst = -1",
5059 BPF_LD_IMM64(R2
, 0x0000ffffffff0000LL
),
5060 BPF_LD_IMM64(R3
, 0xffffffffffffffffLL
),
5061 BPF_ALU64_IMM(BPF_MOV
, R2
, 0xffffffff),
5062 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
5063 BPF_MOV32_IMM(R0
, 2),
5065 BPF_MOV32_IMM(R0
, 1),
5073 "ALU64_MOV_K: small negative",
5075 BPF_ALU64_IMM(BPF_MOV
, R0
, -123),
5083 "ALU64_MOV_K: small negative sign extension",
5085 BPF_ALU64_IMM(BPF_MOV
, R0
, -123),
5086 BPF_ALU64_IMM(BPF_RSH
, R0
, 32),
5091 { { 0, 0xffffffff } }
5094 "ALU64_MOV_K: large negative",
5096 BPF_ALU64_IMM(BPF_MOV
, R0
, -123456789),
5101 { { 0, -123456789 } }
5104 "ALU64_MOV_K: large negative sign extension",
5106 BPF_ALU64_IMM(BPF_MOV
, R0
, -123456789),
5107 BPF_ALU64_IMM(BPF_RSH
, R0
, 32),
5112 { { 0, 0xffffffff } }
5116 "ALU_MOVSX | BPF_B",
5118 BPF_LD_IMM64(R2
, 0x00000000ffffffefLL
),
5119 BPF_LD_IMM64(R3
, 0xdeadbeefdeadbeefLL
),
5120 BPF_MOVSX32_REG(R1
, R3
, 8),
5121 BPF_JMP_REG(BPF_JEQ
, R2
, R1
, 2),
5122 BPF_MOV32_IMM(R0
, 2),
5124 BPF_MOV32_IMM(R0
, 1),
5132 "ALU_MOVSX | BPF_H",
5134 BPF_LD_IMM64(R2
, 0x00000000ffffbeefLL
),
5135 BPF_LD_IMM64(R3
, 0xdeadbeefdeadbeefLL
),
5136 BPF_MOVSX32_REG(R1
, R3
, 16),
5137 BPF_JMP_REG(BPF_JEQ
, R2
, R1
, 2),
5138 BPF_MOV32_IMM(R0
, 2),
5140 BPF_MOV32_IMM(R0
, 1),
5149 "ALU64_MOVSX | BPF_B",
5151 BPF_LD_IMM64(R2
, 0xffffffffffffffefLL
),
5152 BPF_LD_IMM64(R3
, 0xdeadbeefdeadbeefLL
),
5153 BPF_MOVSX64_REG(R1
, R3
, 8),
5154 BPF_JMP_REG(BPF_JEQ
, R2
, R1
, 2),
5155 BPF_MOV32_IMM(R0
, 2),
5157 BPF_MOV32_IMM(R0
, 1),
5165 "ALU64_MOVSX | BPF_H",
5167 BPF_LD_IMM64(R2
, 0xffffffffffffbeefLL
),
5168 BPF_LD_IMM64(R3
, 0xdeadbeefdeadbeefLL
),
5169 BPF_MOVSX64_REG(R1
, R3
, 16),
5170 BPF_JMP_REG(BPF_JEQ
, R2
, R1
, 2),
5171 BPF_MOV32_IMM(R0
, 2),
5173 BPF_MOV32_IMM(R0
, 1),
5181 "ALU64_MOVSX | BPF_W",
5183 BPF_LD_IMM64(R2
, 0xffffffffdeadbeefLL
),
5184 BPF_LD_IMM64(R3
, 0xdeadbeefdeadbeefLL
),
5185 BPF_MOVSX64_REG(R1
, R3
, 32),
5186 BPF_JMP_REG(BPF_JEQ
, R2
, R1
, 2),
5187 BPF_MOV32_IMM(R0
, 2),
5189 BPF_MOV32_IMM(R0
, 1),
5196 /* BPF_ALU | BPF_ADD | BPF_X */
5198 "ALU_ADD_X: 1 + 2 = 3",
5200 BPF_LD_IMM64(R0
, 1),
5201 BPF_ALU32_IMM(BPF_MOV
, R1
, 2),
5202 BPF_ALU32_REG(BPF_ADD
, R0
, R1
),
5210 "ALU_ADD_X: 1 + 4294967294 = 4294967295",
5212 BPF_LD_IMM64(R0
, 1),
5213 BPF_ALU32_IMM(BPF_MOV
, R1
, 4294967294U),
5214 BPF_ALU32_REG(BPF_ADD
, R0
, R1
),
5219 { { 0, 4294967295U } },
5222 "ALU_ADD_X: 2 + 4294967294 = 0",
5224 BPF_LD_IMM64(R0
, 2),
5225 BPF_LD_IMM64(R1
, 4294967294U),
5226 BPF_ALU32_REG(BPF_ADD
, R0
, R1
),
5227 BPF_JMP_IMM(BPF_JEQ
, R0
, 0, 2),
5228 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
5230 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
5238 "ALU64_ADD_X: 1 + 2 = 3",
5240 BPF_LD_IMM64(R0
, 1),
5241 BPF_ALU32_IMM(BPF_MOV
, R1
, 2),
5242 BPF_ALU64_REG(BPF_ADD
, R0
, R1
),
5250 "ALU64_ADD_X: 1 + 4294967294 = 4294967295",
5252 BPF_LD_IMM64(R0
, 1),
5253 BPF_ALU32_IMM(BPF_MOV
, R1
, 4294967294U),
5254 BPF_ALU64_REG(BPF_ADD
, R0
, R1
),
5259 { { 0, 4294967295U } },
5262 "ALU64_ADD_X: 2 + 4294967294 = 4294967296",
5264 BPF_LD_IMM64(R0
, 2),
5265 BPF_LD_IMM64(R1
, 4294967294U),
5266 BPF_LD_IMM64(R2
, 4294967296ULL),
5267 BPF_ALU64_REG(BPF_ADD
, R0
, R1
),
5268 BPF_JMP_REG(BPF_JEQ
, R0
, R2
, 2),
5269 BPF_MOV32_IMM(R0
, 0),
5271 BPF_MOV32_IMM(R0
, 1),
5278 /* BPF_ALU | BPF_ADD | BPF_K */
5280 "ALU_ADD_K: 1 + 2 = 3",
5282 BPF_LD_IMM64(R0
, 1),
5283 BPF_ALU32_IMM(BPF_ADD
, R0
, 2),
5291 "ALU_ADD_K: 3 + 0 = 3",
5293 BPF_LD_IMM64(R0
, 3),
5294 BPF_ALU32_IMM(BPF_ADD
, R0
, 0),
5302 "ALU_ADD_K: 1 + 4294967294 = 4294967295",
5304 BPF_LD_IMM64(R0
, 1),
5305 BPF_ALU32_IMM(BPF_ADD
, R0
, 4294967294U),
5310 { { 0, 4294967295U } },
5313 "ALU_ADD_K: 4294967294 + 2 = 0",
5315 BPF_LD_IMM64(R0
, 4294967294U),
5316 BPF_ALU32_IMM(BPF_ADD
, R0
, 2),
5317 BPF_JMP_IMM(BPF_JEQ
, R0
, 0, 2),
5318 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
5320 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
5328 "ALU_ADD_K: 0 + (-1) = 0x00000000ffffffff",
5330 BPF_LD_IMM64(R2
, 0x0),
5331 BPF_LD_IMM64(R3
, 0x00000000ffffffff),
5332 BPF_ALU32_IMM(BPF_ADD
, R2
, 0xffffffff),
5333 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
5334 BPF_MOV32_IMM(R0
, 2),
5336 BPF_MOV32_IMM(R0
, 1),
5344 "ALU_ADD_K: 0 + 0xffff = 0xffff",
5346 BPF_LD_IMM64(R2
, 0x0),
5347 BPF_LD_IMM64(R3
, 0xffff),
5348 BPF_ALU32_IMM(BPF_ADD
, R2
, 0xffff),
5349 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
5350 BPF_MOV32_IMM(R0
, 2),
5352 BPF_MOV32_IMM(R0
, 1),
5360 "ALU_ADD_K: 0 + 0x7fffffff = 0x7fffffff",
5362 BPF_LD_IMM64(R2
, 0x0),
5363 BPF_LD_IMM64(R3
, 0x7fffffff),
5364 BPF_ALU32_IMM(BPF_ADD
, R2
, 0x7fffffff),
5365 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
5366 BPF_MOV32_IMM(R0
, 2),
5368 BPF_MOV32_IMM(R0
, 1),
5376 "ALU_ADD_K: 0 + 0x80000000 = 0x80000000",
5378 BPF_LD_IMM64(R2
, 0x0),
5379 BPF_LD_IMM64(R3
, 0x80000000),
5380 BPF_ALU32_IMM(BPF_ADD
, R2
, 0x80000000),
5381 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
5382 BPF_MOV32_IMM(R0
, 2),
5384 BPF_MOV32_IMM(R0
, 1),
5392 "ALU_ADD_K: 0 + 0x80008000 = 0x80008000",
5394 BPF_LD_IMM64(R2
, 0x0),
5395 BPF_LD_IMM64(R3
, 0x80008000),
5396 BPF_ALU32_IMM(BPF_ADD
, R2
, 0x80008000),
5397 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
5398 BPF_MOV32_IMM(R0
, 2),
5400 BPF_MOV32_IMM(R0
, 1),
5408 "ALU64_ADD_K: 1 + 2 = 3",
5410 BPF_LD_IMM64(R0
, 1),
5411 BPF_ALU64_IMM(BPF_ADD
, R0
, 2),
5419 "ALU64_ADD_K: 3 + 0 = 3",
5421 BPF_LD_IMM64(R0
, 3),
5422 BPF_ALU64_IMM(BPF_ADD
, R0
, 0),
5430 "ALU64_ADD_K: 1 + 2147483646 = 2147483647",
5432 BPF_LD_IMM64(R0
, 1),
5433 BPF_ALU64_IMM(BPF_ADD
, R0
, 2147483646),
5438 { { 0, 2147483647 } },
5441 "ALU64_ADD_K: 4294967294 + 2 = 4294967296",
5443 BPF_LD_IMM64(R0
, 4294967294U),
5444 BPF_LD_IMM64(R1
, 4294967296ULL),
5445 BPF_ALU64_IMM(BPF_ADD
, R0
, 2),
5446 BPF_JMP_REG(BPF_JEQ
, R0
, R1
, 2),
5447 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
5449 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
5457 "ALU64_ADD_K: 2147483646 + -2147483647 = -1",
5459 BPF_LD_IMM64(R0
, 2147483646),
5460 BPF_ALU64_IMM(BPF_ADD
, R0
, -2147483647),
5468 "ALU64_ADD_K: 1 + 0 = 1",
5470 BPF_LD_IMM64(R2
, 0x1),
5471 BPF_LD_IMM64(R3
, 0x1),
5472 BPF_ALU64_IMM(BPF_ADD
, R2
, 0x0),
5473 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
5474 BPF_MOV32_IMM(R0
, 2),
5476 BPF_MOV32_IMM(R0
, 1),
5484 "ALU64_ADD_K: 0 + (-1) = 0xffffffffffffffff",
5486 BPF_LD_IMM64(R2
, 0x0),
5487 BPF_LD_IMM64(R3
, 0xffffffffffffffffLL
),
5488 BPF_ALU64_IMM(BPF_ADD
, R2
, 0xffffffff),
5489 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
5490 BPF_MOV32_IMM(R0
, 2),
5492 BPF_MOV32_IMM(R0
, 1),
5500 "ALU64_ADD_K: 0 + 0xffff = 0xffff",
5502 BPF_LD_IMM64(R2
, 0x0),
5503 BPF_LD_IMM64(R3
, 0xffff),
5504 BPF_ALU64_IMM(BPF_ADD
, R2
, 0xffff),
5505 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
5506 BPF_MOV32_IMM(R0
, 2),
5508 BPF_MOV32_IMM(R0
, 1),
5516 "ALU64_ADD_K: 0 + 0x7fffffff = 0x7fffffff",
5518 BPF_LD_IMM64(R2
, 0x0),
5519 BPF_LD_IMM64(R3
, 0x7fffffff),
5520 BPF_ALU64_IMM(BPF_ADD
, R2
, 0x7fffffff),
5521 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
5522 BPF_MOV32_IMM(R0
, 2),
5524 BPF_MOV32_IMM(R0
, 1),
5532 "ALU64_ADD_K: 0 + 0x80000000 = 0xffffffff80000000",
5534 BPF_LD_IMM64(R2
, 0x0),
5535 BPF_LD_IMM64(R3
, 0xffffffff80000000LL
),
5536 BPF_ALU64_IMM(BPF_ADD
, R2
, 0x80000000),
5537 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
5538 BPF_MOV32_IMM(R0
, 2),
5540 BPF_MOV32_IMM(R0
, 1),
5548 "ALU_ADD_K: 0 + 0x80008000 = 0xffffffff80008000",
5550 BPF_LD_IMM64(R2
, 0x0),
5551 BPF_LD_IMM64(R3
, 0xffffffff80008000LL
),
5552 BPF_ALU64_IMM(BPF_ADD
, R2
, 0x80008000),
5553 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
5554 BPF_MOV32_IMM(R0
, 2),
5556 BPF_MOV32_IMM(R0
, 1),
5563 /* BPF_ALU | BPF_SUB | BPF_X */
5565 "ALU_SUB_X: 3 - 1 = 2",
5567 BPF_LD_IMM64(R0
, 3),
5568 BPF_ALU32_IMM(BPF_MOV
, R1
, 1),
5569 BPF_ALU32_REG(BPF_SUB
, R0
, R1
),
5577 "ALU_SUB_X: 4294967295 - 4294967294 = 1",
5579 BPF_LD_IMM64(R0
, 4294967295U),
5580 BPF_ALU32_IMM(BPF_MOV
, R1
, 4294967294U),
5581 BPF_ALU32_REG(BPF_SUB
, R0
, R1
),
5589 "ALU64_SUB_X: 3 - 1 = 2",
5591 BPF_LD_IMM64(R0
, 3),
5592 BPF_ALU32_IMM(BPF_MOV
, R1
, 1),
5593 BPF_ALU64_REG(BPF_SUB
, R0
, R1
),
5601 "ALU64_SUB_X: 4294967295 - 4294967294 = 1",
5603 BPF_LD_IMM64(R0
, 4294967295U),
5604 BPF_ALU32_IMM(BPF_MOV
, R1
, 4294967294U),
5605 BPF_ALU64_REG(BPF_SUB
, R0
, R1
),
5612 /* BPF_ALU | BPF_SUB | BPF_K */
5614 "ALU_SUB_K: 3 - 1 = 2",
5616 BPF_LD_IMM64(R0
, 3),
5617 BPF_ALU32_IMM(BPF_SUB
, R0
, 1),
5625 "ALU_SUB_K: 3 - 0 = 3",
5627 BPF_LD_IMM64(R0
, 3),
5628 BPF_ALU32_IMM(BPF_SUB
, R0
, 0),
5636 "ALU_SUB_K: 4294967295 - 4294967294 = 1",
5638 BPF_LD_IMM64(R0
, 4294967295U),
5639 BPF_ALU32_IMM(BPF_SUB
, R0
, 4294967294U),
5647 "ALU64_SUB_K: 3 - 1 = 2",
5649 BPF_LD_IMM64(R0
, 3),
5650 BPF_ALU64_IMM(BPF_SUB
, R0
, 1),
5658 "ALU64_SUB_K: 3 - 0 = 3",
5660 BPF_LD_IMM64(R0
, 3),
5661 BPF_ALU64_IMM(BPF_SUB
, R0
, 0),
5669 "ALU64_SUB_K: 4294967294 - 4294967295 = -1",
5671 BPF_LD_IMM64(R0
, 4294967294U),
5672 BPF_ALU64_IMM(BPF_SUB
, R0
, 4294967295U),
5680 "ALU64_ADD_K: 2147483646 - 2147483647 = -1",
5682 BPF_LD_IMM64(R0
, 2147483646),
5683 BPF_ALU64_IMM(BPF_SUB
, R0
, 2147483647),
5690 /* BPF_ALU | BPF_MUL | BPF_X */
5692 "ALU_MUL_X: 2 * 3 = 6",
5694 BPF_LD_IMM64(R0
, 2),
5695 BPF_ALU32_IMM(BPF_MOV
, R1
, 3),
5696 BPF_ALU32_REG(BPF_MUL
, R0
, R1
),
5704 "ALU_MUL_X: 2 * 0x7FFFFFF8 = 0xFFFFFFF0",
5706 BPF_LD_IMM64(R0
, 2),
5707 BPF_ALU32_IMM(BPF_MOV
, R1
, 0x7FFFFFF8),
5708 BPF_ALU32_REG(BPF_MUL
, R0
, R1
),
5713 { { 0, 0xFFFFFFF0 } },
5716 "ALU_MUL_X: -1 * -1 = 1",
5718 BPF_LD_IMM64(R0
, -1),
5719 BPF_ALU32_IMM(BPF_MOV
, R1
, -1),
5720 BPF_ALU32_REG(BPF_MUL
, R0
, R1
),
5728 "ALU64_MUL_X: 2 * 3 = 6",
5730 BPF_LD_IMM64(R0
, 2),
5731 BPF_ALU32_IMM(BPF_MOV
, R1
, 3),
5732 BPF_ALU64_REG(BPF_MUL
, R0
, R1
),
5740 "ALU64_MUL_X: 1 * 2147483647 = 2147483647",
5742 BPF_LD_IMM64(R0
, 1),
5743 BPF_ALU32_IMM(BPF_MOV
, R1
, 2147483647),
5744 BPF_ALU64_REG(BPF_MUL
, R0
, R1
),
5749 { { 0, 2147483647 } },
5752 "ALU64_MUL_X: 64x64 multiply, low word",
5754 BPF_LD_IMM64(R0
, 0x0fedcba987654321LL
),
5755 BPF_LD_IMM64(R1
, 0x123456789abcdef0LL
),
5756 BPF_ALU64_REG(BPF_MUL
, R0
, R1
),
5761 { { 0, 0xe5618cf0 } }
5764 "ALU64_MUL_X: 64x64 multiply, high word",
5766 BPF_LD_IMM64(R0
, 0x0fedcba987654321LL
),
5767 BPF_LD_IMM64(R1
, 0x123456789abcdef0LL
),
5768 BPF_ALU64_REG(BPF_MUL
, R0
, R1
),
5769 BPF_ALU64_IMM(BPF_RSH
, R0
, 32),
5774 { { 0, 0x2236d88f } }
5776 /* BPF_ALU | BPF_MUL | BPF_K */
5778 "ALU_MUL_K: 2 * 3 = 6",
5780 BPF_LD_IMM64(R0
, 2),
5781 BPF_ALU32_IMM(BPF_MUL
, R0
, 3),
5789 "ALU_MUL_K: 3 * 1 = 3",
5791 BPF_LD_IMM64(R0
, 3),
5792 BPF_ALU32_IMM(BPF_MUL
, R0
, 1),
5800 "ALU_MUL_K: 2 * 0x7FFFFFF8 = 0xFFFFFFF0",
5802 BPF_LD_IMM64(R0
, 2),
5803 BPF_ALU32_IMM(BPF_MUL
, R0
, 0x7FFFFFF8),
5808 { { 0, 0xFFFFFFF0 } },
5811 "ALU_MUL_K: 1 * (-1) = 0x00000000ffffffff",
5813 BPF_LD_IMM64(R2
, 0x1),
5814 BPF_LD_IMM64(R3
, 0x00000000ffffffff),
5815 BPF_ALU32_IMM(BPF_MUL
, R2
, 0xffffffff),
5816 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
5817 BPF_MOV32_IMM(R0
, 2),
5819 BPF_MOV32_IMM(R0
, 1),
5827 "ALU64_MUL_K: 2 * 3 = 6",
5829 BPF_LD_IMM64(R0
, 2),
5830 BPF_ALU64_IMM(BPF_MUL
, R0
, 3),
5838 "ALU64_MUL_K: 3 * 1 = 3",
5840 BPF_LD_IMM64(R0
, 3),
5841 BPF_ALU64_IMM(BPF_MUL
, R0
, 1),
5849 "ALU64_MUL_K: 1 * 2147483647 = 2147483647",
5851 BPF_LD_IMM64(R0
, 1),
5852 BPF_ALU64_IMM(BPF_MUL
, R0
, 2147483647),
5857 { { 0, 2147483647 } },
5860 "ALU64_MUL_K: 1 * -2147483647 = -2147483647",
5862 BPF_LD_IMM64(R0
, 1),
5863 BPF_ALU64_IMM(BPF_MUL
, R0
, -2147483647),
5868 { { 0, -2147483647 } },
5871 "ALU64_MUL_K: 1 * (-1) = 0xffffffffffffffff",
5873 BPF_LD_IMM64(R2
, 0x1),
5874 BPF_LD_IMM64(R3
, 0xffffffffffffffffLL
),
5875 BPF_ALU64_IMM(BPF_MUL
, R2
, 0xffffffff),
5876 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
5877 BPF_MOV32_IMM(R0
, 2),
5879 BPF_MOV32_IMM(R0
, 1),
5887 "ALU64_MUL_K: 64x32 multiply, low word",
5889 BPF_LD_IMM64(R0
, 0x0123456789abcdefLL
),
5890 BPF_ALU64_IMM(BPF_MUL
, R0
, 0x12345678),
5895 { { 0, 0xe242d208 } }
5898 "ALU64_MUL_K: 64x32 multiply, high word",
5900 BPF_LD_IMM64(R0
, 0x0123456789abcdefLL
),
5901 BPF_ALU64_IMM(BPF_MUL
, R0
, 0x12345678),
5902 BPF_ALU64_IMM(BPF_RSH
, R0
, 32),
5907 { { 0, 0xc28f5c28 } }
5909 /* BPF_ALU | BPF_DIV | BPF_X */
5911 "ALU_DIV_X: 6 / 2 = 3",
5913 BPF_LD_IMM64(R0
, 6),
5914 BPF_ALU32_IMM(BPF_MOV
, R1
, 2),
5915 BPF_ALU32_REG(BPF_DIV
, R0
, R1
),
5923 "ALU_DIV_X: 4294967295 / 4294967295 = 1",
5925 BPF_LD_IMM64(R0
, 4294967295U),
5926 BPF_ALU32_IMM(BPF_MOV
, R1
, 4294967295U),
5927 BPF_ALU32_REG(BPF_DIV
, R0
, R1
),
5935 "ALU64_DIV_X: 6 / 2 = 3",
5937 BPF_LD_IMM64(R0
, 6),
5938 BPF_ALU32_IMM(BPF_MOV
, R1
, 2),
5939 BPF_ALU64_REG(BPF_DIV
, R0
, R1
),
5947 "ALU64_DIV_X: 2147483647 / 2147483647 = 1",
5949 BPF_LD_IMM64(R0
, 2147483647),
5950 BPF_ALU32_IMM(BPF_MOV
, R1
, 2147483647),
5951 BPF_ALU64_REG(BPF_DIV
, R0
, R1
),
5959 "ALU64_DIV_X: 0xffffffffffffffff / (-1) = 0x0000000000000001",
5961 BPF_LD_IMM64(R2
, 0xffffffffffffffffLL
),
5962 BPF_LD_IMM64(R4
, 0xffffffffffffffffLL
),
5963 BPF_LD_IMM64(R3
, 0x0000000000000001LL
),
5964 BPF_ALU64_REG(BPF_DIV
, R2
, R4
),
5965 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
5966 BPF_MOV32_IMM(R0
, 2),
5968 BPF_MOV32_IMM(R0
, 1),
5975 /* BPF_ALU | BPF_DIV | BPF_K */
5977 "ALU_DIV_K: 6 / 2 = 3",
5979 BPF_LD_IMM64(R0
, 6),
5980 BPF_ALU32_IMM(BPF_DIV
, R0
, 2),
5988 "ALU_DIV_K: 3 / 1 = 3",
5990 BPF_LD_IMM64(R0
, 3),
5991 BPF_ALU32_IMM(BPF_DIV
, R0
, 1),
5999 "ALU_DIV_K: 4294967295 / 4294967295 = 1",
6001 BPF_LD_IMM64(R0
, 4294967295U),
6002 BPF_ALU32_IMM(BPF_DIV
, R0
, 4294967295U),
6010 "ALU_DIV_K: 0xffffffffffffffff / (-1) = 0x1",
6012 BPF_LD_IMM64(R2
, 0xffffffffffffffffLL
),
6013 BPF_LD_IMM64(R3
, 0x1UL
),
6014 BPF_ALU32_IMM(BPF_DIV
, R2
, 0xffffffff),
6015 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
6016 BPF_MOV32_IMM(R0
, 2),
6018 BPF_MOV32_IMM(R0
, 1),
6026 "ALU64_DIV_K: 6 / 2 = 3",
6028 BPF_LD_IMM64(R0
, 6),
6029 BPF_ALU64_IMM(BPF_DIV
, R0
, 2),
6037 "ALU64_DIV_K: 3 / 1 = 3",
6039 BPF_LD_IMM64(R0
, 3),
6040 BPF_ALU64_IMM(BPF_DIV
, R0
, 1),
6048 "ALU64_DIV_K: 2147483647 / 2147483647 = 1",
6050 BPF_LD_IMM64(R0
, 2147483647),
6051 BPF_ALU64_IMM(BPF_DIV
, R0
, 2147483647),
6059 "ALU64_DIV_K: 0xffffffffffffffff / (-1) = 0x0000000000000001",
6061 BPF_LD_IMM64(R2
, 0xffffffffffffffffLL
),
6062 BPF_LD_IMM64(R3
, 0x0000000000000001LL
),
6063 BPF_ALU64_IMM(BPF_DIV
, R2
, 0xffffffff),
6064 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
6065 BPF_MOV32_IMM(R0
, 2),
6067 BPF_MOV32_IMM(R0
, 1),
6074 /* BPF_ALU | BPF_MOD | BPF_X */
6076 "ALU_MOD_X: 3 % 2 = 1",
6078 BPF_LD_IMM64(R0
, 3),
6079 BPF_ALU32_IMM(BPF_MOV
, R1
, 2),
6080 BPF_ALU32_REG(BPF_MOD
, R0
, R1
),
6088 "ALU_MOD_X: 4294967295 % 4294967293 = 2",
6090 BPF_LD_IMM64(R0
, 4294967295U),
6091 BPF_ALU32_IMM(BPF_MOV
, R1
, 4294967293U),
6092 BPF_ALU32_REG(BPF_MOD
, R0
, R1
),
6100 "ALU64_MOD_X: 3 % 2 = 1",
6102 BPF_LD_IMM64(R0
, 3),
6103 BPF_ALU32_IMM(BPF_MOV
, R1
, 2),
6104 BPF_ALU64_REG(BPF_MOD
, R0
, R1
),
6112 "ALU64_MOD_X: 2147483647 % 2147483645 = 2",
6114 BPF_LD_IMM64(R0
, 2147483647),
6115 BPF_ALU32_IMM(BPF_MOV
, R1
, 2147483645),
6116 BPF_ALU64_REG(BPF_MOD
, R0
, R1
),
6123 /* BPF_ALU | BPF_MOD | BPF_K */
6125 "ALU_MOD_K: 3 % 2 = 1",
6127 BPF_LD_IMM64(R0
, 3),
6128 BPF_ALU32_IMM(BPF_MOD
, R0
, 2),
6136 "ALU_MOD_K: 3 % 1 = 0",
6138 BPF_LD_IMM64(R0
, 3),
6139 BPF_ALU32_IMM(BPF_MOD
, R0
, 1),
6147 "ALU_MOD_K: 4294967295 % 4294967293 = 2",
6149 BPF_LD_IMM64(R0
, 4294967295U),
6150 BPF_ALU32_IMM(BPF_MOD
, R0
, 4294967293U),
6158 "ALU64_MOD_K: 3 % 2 = 1",
6160 BPF_LD_IMM64(R0
, 3),
6161 BPF_ALU64_IMM(BPF_MOD
, R0
, 2),
6169 "ALU64_MOD_K: 3 % 1 = 0",
6171 BPF_LD_IMM64(R0
, 3),
6172 BPF_ALU64_IMM(BPF_MOD
, R0
, 1),
6180 "ALU64_MOD_K: 2147483647 % 2147483645 = 2",
6182 BPF_LD_IMM64(R0
, 2147483647),
6183 BPF_ALU64_IMM(BPF_MOD
, R0
, 2147483645),
6190 /* BPF_ALU | BPF_DIV | BPF_X off=1 (SDIV) */
6192 "ALU_SDIV_X: -6 / 2 = -3",
6194 BPF_LD_IMM64(R0
, -6),
6195 BPF_ALU32_IMM(BPF_MOV
, R1
, 2),
6196 BPF_ALU32_REG_OFF(BPF_DIV
, R0
, R1
, 1),
6203 /* BPF_ALU | BPF_DIV | BPF_K off=1 (SDIV) */
6205 "ALU_SDIV_K: -6 / 2 = -3",
6207 BPF_LD_IMM64(R0
, -6),
6208 BPF_ALU32_IMM_OFF(BPF_DIV
, R0
, 2, 1),
6215 /* BPF_ALU64 | BPF_DIV | BPF_X off=1 (SDIV64) */
6217 "ALU64_SDIV_X: -6 / 2 = -3",
6219 BPF_LD_IMM64(R0
, -6),
6220 BPF_ALU32_IMM(BPF_MOV
, R1
, 2),
6221 BPF_ALU64_REG_OFF(BPF_DIV
, R0
, R1
, 1),
6228 /* BPF_ALU64 | BPF_DIV | BPF_K off=1 (SDIV64) */
6230 "ALU64_SDIV_K: -6 / 2 = -3",
6232 BPF_LD_IMM64(R0
, -6),
6233 BPF_ALU64_IMM_OFF(BPF_DIV
, R0
, 2, 1),
6240 /* BPF_ALU | BPF_MOD | BPF_X off=1 (SMOD) */
6242 "ALU_SMOD_X: -7 % 2 = -1",
6244 BPF_LD_IMM64(R0
, -7),
6245 BPF_ALU32_IMM(BPF_MOV
, R1
, 2),
6246 BPF_ALU32_REG_OFF(BPF_MOD
, R0
, R1
, 1),
6253 /* BPF_ALU | BPF_MOD | BPF_K off=1 (SMOD) */
6255 "ALU_SMOD_K: -7 % 2 = -1",
6257 BPF_LD_IMM64(R0
, -7),
6258 BPF_ALU32_IMM_OFF(BPF_MOD
, R0
, 2, 1),
6265 /* BPF_ALU64 | BPF_MOD | BPF_X off=1 (SMOD64) */
6267 "ALU64_SMOD_X: -7 % 2 = -1",
6269 BPF_LD_IMM64(R0
, -7),
6270 BPF_ALU32_IMM(BPF_MOV
, R1
, 2),
6271 BPF_ALU64_REG_OFF(BPF_MOD
, R0
, R1
, 1),
6278 /* BPF_ALU64 | BPF_MOD | BPF_K off=1 (SMOD64) */
6280 "ALU64_SMOD_K: -7 % 2 = -1",
6282 BPF_LD_IMM64(R0
, -7),
6283 BPF_ALU64_IMM_OFF(BPF_MOD
, R0
, 2, 1),
6290 /* BPF_ALU | BPF_AND | BPF_X */
6292 "ALU_AND_X: 3 & 2 = 2",
6294 BPF_LD_IMM64(R0
, 3),
6295 BPF_ALU32_IMM(BPF_MOV
, R1
, 2),
6296 BPF_ALU32_REG(BPF_AND
, R0
, R1
),
6304 "ALU_AND_X: 0xffffffff & 0xffffffff = 0xffffffff",
6306 BPF_LD_IMM64(R0
, 0xffffffff),
6307 BPF_ALU32_IMM(BPF_MOV
, R1
, 0xffffffff),
6308 BPF_ALU32_REG(BPF_AND
, R0
, R1
),
6313 { { 0, 0xffffffff } },
6316 "ALU64_AND_X: 3 & 2 = 2",
6318 BPF_LD_IMM64(R0
, 3),
6319 BPF_ALU32_IMM(BPF_MOV
, R1
, 2),
6320 BPF_ALU64_REG(BPF_AND
, R0
, R1
),
6328 "ALU64_AND_X: 0xffffffff & 0xffffffff = 0xffffffff",
6330 BPF_LD_IMM64(R0
, 0xffffffff),
6331 BPF_ALU32_IMM(BPF_MOV
, R1
, 0xffffffff),
6332 BPF_ALU64_REG(BPF_AND
, R0
, R1
),
6337 { { 0, 0xffffffff } },
6339 /* BPF_ALU | BPF_AND | BPF_K */
6341 "ALU_AND_K: 3 & 2 = 2",
6343 BPF_LD_IMM64(R0
, 3),
6344 BPF_ALU32_IMM(BPF_AND
, R0
, 2),
6352 "ALU_AND_K: 0xffffffff & 0xffffffff = 0xffffffff",
6354 BPF_LD_IMM64(R0
, 0xffffffff),
6355 BPF_ALU32_IMM(BPF_AND
, R0
, 0xffffffff),
6360 { { 0, 0xffffffff } },
6363 "ALU_AND_K: Small immediate",
6365 BPF_ALU32_IMM(BPF_MOV
, R0
, 0x01020304),
6366 BPF_ALU32_IMM(BPF_AND
, R0
, 15),
6374 "ALU_AND_K: Large immediate",
6376 BPF_ALU32_IMM(BPF_MOV
, R0
, 0xf1f2f3f4),
6377 BPF_ALU32_IMM(BPF_AND
, R0
, 0xafbfcfdf),
6382 { { 0, 0xa1b2c3d4 } }
6385 "ALU_AND_K: Zero extension",
6387 BPF_LD_IMM64(R0
, 0x0123456789abcdefLL
),
6388 BPF_LD_IMM64(R1
, 0x0000000080a0c0e0LL
),
6389 BPF_ALU32_IMM(BPF_AND
, R0
, 0xf0f0f0f0),
6390 BPF_JMP_REG(BPF_JEQ
, R0
, R1
, 2),
6391 BPF_MOV32_IMM(R0
, 2),
6393 BPF_MOV32_IMM(R0
, 1),
6401 "ALU64_AND_K: 3 & 2 = 2",
6403 BPF_LD_IMM64(R0
, 3),
6404 BPF_ALU64_IMM(BPF_AND
, R0
, 2),
6412 "ALU64_AND_K: 0xffffffff & 0xffffffff = 0xffffffff",
6414 BPF_LD_IMM64(R0
, 0xffffffff),
6415 BPF_ALU64_IMM(BPF_AND
, R0
, 0xffffffff),
6420 { { 0, 0xffffffff } },
6423 "ALU64_AND_K: 0x0000ffffffff0000 & 0x0 = 0x0000000000000000",
6425 BPF_LD_IMM64(R2
, 0x0000ffffffff0000LL
),
6426 BPF_LD_IMM64(R3
, 0x0000000000000000LL
),
6427 BPF_ALU64_IMM(BPF_AND
, R2
, 0x0),
6428 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
6429 BPF_MOV32_IMM(R0
, 2),
6431 BPF_MOV32_IMM(R0
, 1),
6439 "ALU64_AND_K: 0x0000ffffffff0000 & -1 = 0x0000ffffffff0000",
6441 BPF_LD_IMM64(R2
, 0x0000ffffffff0000LL
),
6442 BPF_LD_IMM64(R3
, 0x0000ffffffff0000LL
),
6443 BPF_ALU64_IMM(BPF_AND
, R2
, 0xffffffff),
6444 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
6445 BPF_MOV32_IMM(R0
, 2),
6447 BPF_MOV32_IMM(R0
, 1),
6455 "ALU64_AND_K: 0xffffffffffffffff & -1 = 0xffffffffffffffff",
6457 BPF_LD_IMM64(R2
, 0xffffffffffffffffLL
),
6458 BPF_LD_IMM64(R3
, 0xffffffffffffffffLL
),
6459 BPF_ALU64_IMM(BPF_AND
, R2
, 0xffffffff),
6460 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
6461 BPF_MOV32_IMM(R0
, 2),
6463 BPF_MOV32_IMM(R0
, 1),
6471 "ALU64_AND_K: Sign extension 1",
6473 BPF_LD_IMM64(R0
, 0x0123456789abcdefLL
),
6474 BPF_LD_IMM64(R1
, 0x00000000090b0d0fLL
),
6475 BPF_ALU64_IMM(BPF_AND
, R0
, 0x0f0f0f0f),
6476 BPF_JMP_REG(BPF_JEQ
, R0
, R1
, 2),
6477 BPF_MOV32_IMM(R0
, 2),
6479 BPF_MOV32_IMM(R0
, 1),
6487 "ALU64_AND_K: Sign extension 2",
6489 BPF_LD_IMM64(R0
, 0x0123456789abcdefLL
),
6490 BPF_LD_IMM64(R1
, 0x0123456780a0c0e0LL
),
6491 BPF_ALU64_IMM(BPF_AND
, R0
, 0xf0f0f0f0),
6492 BPF_JMP_REG(BPF_JEQ
, R0
, R1
, 2),
6493 BPF_MOV32_IMM(R0
, 2),
6495 BPF_MOV32_IMM(R0
, 1),
6502 /* BPF_ALU | BPF_OR | BPF_X */
6504 "ALU_OR_X: 1 | 2 = 3",
6506 BPF_LD_IMM64(R0
, 1),
6507 BPF_ALU32_IMM(BPF_MOV
, R1
, 2),
6508 BPF_ALU32_REG(BPF_OR
, R0
, R1
),
6516 "ALU_OR_X: 0x0 | 0xffffffff = 0xffffffff",
6518 BPF_LD_IMM64(R0
, 0),
6519 BPF_ALU32_IMM(BPF_MOV
, R1
, 0xffffffff),
6520 BPF_ALU32_REG(BPF_OR
, R0
, R1
),
6525 { { 0, 0xffffffff } },
6528 "ALU64_OR_X: 1 | 2 = 3",
6530 BPF_LD_IMM64(R0
, 1),
6531 BPF_ALU32_IMM(BPF_MOV
, R1
, 2),
6532 BPF_ALU64_REG(BPF_OR
, R0
, R1
),
6540 "ALU64_OR_X: 0 | 0xffffffff = 0xffffffff",
6542 BPF_LD_IMM64(R0
, 0),
6543 BPF_ALU32_IMM(BPF_MOV
, R1
, 0xffffffff),
6544 BPF_ALU64_REG(BPF_OR
, R0
, R1
),
6549 { { 0, 0xffffffff } },
6551 /* BPF_ALU | BPF_OR | BPF_K */
6553 "ALU_OR_K: 1 | 2 = 3",
6555 BPF_LD_IMM64(R0
, 1),
6556 BPF_ALU32_IMM(BPF_OR
, R0
, 2),
6564 "ALU_OR_K: 0 & 0xffffffff = 0xffffffff",
6566 BPF_LD_IMM64(R0
, 0),
6567 BPF_ALU32_IMM(BPF_OR
, R0
, 0xffffffff),
6572 { { 0, 0xffffffff } },
6575 "ALU_OR_K: Small immediate",
6577 BPF_ALU32_IMM(BPF_MOV
, R0
, 0x01020304),
6578 BPF_ALU32_IMM(BPF_OR
, R0
, 1),
6583 { { 0, 0x01020305 } }
6586 "ALU_OR_K: Large immediate",
6588 BPF_ALU32_IMM(BPF_MOV
, R0
, 0x01020304),
6589 BPF_ALU32_IMM(BPF_OR
, R0
, 0xa0b0c0d0),
6594 { { 0, 0xa1b2c3d4 } }
6597 "ALU_OR_K: Zero extension",
6599 BPF_LD_IMM64(R0
, 0x0123456789abcdefLL
),
6600 BPF_LD_IMM64(R1
, 0x00000000f9fbfdffLL
),
6601 BPF_ALU32_IMM(BPF_OR
, R0
, 0xf0f0f0f0),
6602 BPF_JMP_REG(BPF_JEQ
, R0
, R1
, 2),
6603 BPF_MOV32_IMM(R0
, 2),
6605 BPF_MOV32_IMM(R0
, 1),
6613 "ALU64_OR_K: 1 | 2 = 3",
6615 BPF_LD_IMM64(R0
, 1),
6616 BPF_ALU64_IMM(BPF_OR
, R0
, 2),
6624 "ALU64_OR_K: 0 & 0xffffffff = 0xffffffff",
6626 BPF_LD_IMM64(R0
, 0),
6627 BPF_ALU64_IMM(BPF_OR
, R0
, 0xffffffff),
6632 { { 0, 0xffffffff } },
6635 "ALU64_OR_K: 0x0000ffffffff0000 | 0x0 = 0x0000ffffffff0000",
6637 BPF_LD_IMM64(R2
, 0x0000ffffffff0000LL
),
6638 BPF_LD_IMM64(R3
, 0x0000ffffffff0000LL
),
6639 BPF_ALU64_IMM(BPF_OR
, R2
, 0x0),
6640 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
6641 BPF_MOV32_IMM(R0
, 2),
6643 BPF_MOV32_IMM(R0
, 1),
6651 "ALU64_OR_K: 0x0000ffffffff0000 | -1 = 0xffffffffffffffff",
6653 BPF_LD_IMM64(R2
, 0x0000ffffffff0000LL
),
6654 BPF_LD_IMM64(R3
, 0xffffffffffffffffLL
),
6655 BPF_ALU64_IMM(BPF_OR
, R2
, 0xffffffff),
6656 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
6657 BPF_MOV32_IMM(R0
, 2),
6659 BPF_MOV32_IMM(R0
, 1),
6667 "ALU64_OR_K: 0x000000000000000 | -1 = 0xffffffffffffffff",
6669 BPF_LD_IMM64(R2
, 0x0000000000000000LL
),
6670 BPF_LD_IMM64(R3
, 0xffffffffffffffffLL
),
6671 BPF_ALU64_IMM(BPF_OR
, R2
, 0xffffffff),
6672 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
6673 BPF_MOV32_IMM(R0
, 2),
6675 BPF_MOV32_IMM(R0
, 1),
6683 "ALU64_OR_K: Sign extension 1",
6685 BPF_LD_IMM64(R0
, 0x0123456789abcdefLL
),
6686 BPF_LD_IMM64(R1
, 0x012345678fafcfefLL
),
6687 BPF_ALU64_IMM(BPF_OR
, R0
, 0x0f0f0f0f),
6688 BPF_JMP_REG(BPF_JEQ
, R0
, R1
, 2),
6689 BPF_MOV32_IMM(R0
, 2),
6691 BPF_MOV32_IMM(R0
, 1),
6699 "ALU64_OR_K: Sign extension 2",
6701 BPF_LD_IMM64(R0
, 0x0123456789abcdefLL
),
6702 BPF_LD_IMM64(R1
, 0xfffffffff9fbfdffLL
),
6703 BPF_ALU64_IMM(BPF_OR
, R0
, 0xf0f0f0f0),
6704 BPF_JMP_REG(BPF_JEQ
, R0
, R1
, 2),
6705 BPF_MOV32_IMM(R0
, 2),
6707 BPF_MOV32_IMM(R0
, 1),
6714 /* BPF_ALU | BPF_XOR | BPF_X */
6716 "ALU_XOR_X: 5 ^ 6 = 3",
6718 BPF_LD_IMM64(R0
, 5),
6719 BPF_ALU32_IMM(BPF_MOV
, R1
, 6),
6720 BPF_ALU32_REG(BPF_XOR
, R0
, R1
),
6728 "ALU_XOR_X: 0x1 ^ 0xffffffff = 0xfffffffe",
6730 BPF_LD_IMM64(R0
, 1),
6731 BPF_ALU32_IMM(BPF_MOV
, R1
, 0xffffffff),
6732 BPF_ALU32_REG(BPF_XOR
, R0
, R1
),
6737 { { 0, 0xfffffffe } },
6740 "ALU64_XOR_X: 5 ^ 6 = 3",
6742 BPF_LD_IMM64(R0
, 5),
6743 BPF_ALU32_IMM(BPF_MOV
, R1
, 6),
6744 BPF_ALU64_REG(BPF_XOR
, R0
, R1
),
6752 "ALU64_XOR_X: 1 ^ 0xffffffff = 0xfffffffe",
6754 BPF_LD_IMM64(R0
, 1),
6755 BPF_ALU32_IMM(BPF_MOV
, R1
, 0xffffffff),
6756 BPF_ALU64_REG(BPF_XOR
, R0
, R1
),
6761 { { 0, 0xfffffffe } },
6763 /* BPF_ALU | BPF_XOR | BPF_K */
6765 "ALU_XOR_K: 5 ^ 6 = 3",
6767 BPF_LD_IMM64(R0
, 5),
6768 BPF_ALU32_IMM(BPF_XOR
, R0
, 6),
6776 "ALU_XOR_K: 1 ^ 0xffffffff = 0xfffffffe",
6778 BPF_LD_IMM64(R0
, 1),
6779 BPF_ALU32_IMM(BPF_XOR
, R0
, 0xffffffff),
6784 { { 0, 0xfffffffe } },
6787 "ALU_XOR_K: Small immediate",
6789 BPF_ALU32_IMM(BPF_MOV
, R0
, 0x01020304),
6790 BPF_ALU32_IMM(BPF_XOR
, R0
, 15),
6795 { { 0, 0x0102030b } }
6798 "ALU_XOR_K: Large immediate",
6800 BPF_ALU32_IMM(BPF_MOV
, R0
, 0xf1f2f3f4),
6801 BPF_ALU32_IMM(BPF_XOR
, R0
, 0xafbfcfdf),
6806 { { 0, 0x5e4d3c2b } }
6809 "ALU_XOR_K: Zero extension",
6811 BPF_LD_IMM64(R0
, 0x0123456789abcdefLL
),
6812 BPF_LD_IMM64(R1
, 0x00000000795b3d1fLL
),
6813 BPF_ALU32_IMM(BPF_XOR
, R0
, 0xf0f0f0f0),
6814 BPF_JMP_REG(BPF_JEQ
, R0
, R1
, 2),
6815 BPF_MOV32_IMM(R0
, 2),
6817 BPF_MOV32_IMM(R0
, 1),
6825 "ALU64_XOR_K: 5 ^ 6 = 3",
6827 BPF_LD_IMM64(R0
, 5),
6828 BPF_ALU64_IMM(BPF_XOR
, R0
, 6),
6836 "ALU64_XOR_K: 1 ^ 0xffffffff = 0xfffffffe",
6838 BPF_LD_IMM64(R0
, 1),
6839 BPF_ALU64_IMM(BPF_XOR
, R0
, 0xffffffff),
6844 { { 0, 0xfffffffe } },
6847 "ALU64_XOR_K: 0x0000ffffffff0000 ^ 0x0 = 0x0000ffffffff0000",
6849 BPF_LD_IMM64(R2
, 0x0000ffffffff0000LL
),
6850 BPF_LD_IMM64(R3
, 0x0000ffffffff0000LL
),
6851 BPF_ALU64_IMM(BPF_XOR
, R2
, 0x0),
6852 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
6853 BPF_MOV32_IMM(R0
, 2),
6855 BPF_MOV32_IMM(R0
, 1),
6863 "ALU64_XOR_K: 0x0000ffffffff0000 ^ -1 = 0xffff00000000ffff",
6865 BPF_LD_IMM64(R2
, 0x0000ffffffff0000LL
),
6866 BPF_LD_IMM64(R3
, 0xffff00000000ffffLL
),
6867 BPF_ALU64_IMM(BPF_XOR
, R2
, 0xffffffff),
6868 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
6869 BPF_MOV32_IMM(R0
, 2),
6871 BPF_MOV32_IMM(R0
, 1),
6879 "ALU64_XOR_K: 0x000000000000000 ^ -1 = 0xffffffffffffffff",
6881 BPF_LD_IMM64(R2
, 0x0000000000000000LL
),
6882 BPF_LD_IMM64(R3
, 0xffffffffffffffffLL
),
6883 BPF_ALU64_IMM(BPF_XOR
, R2
, 0xffffffff),
6884 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
6885 BPF_MOV32_IMM(R0
, 2),
6887 BPF_MOV32_IMM(R0
, 1),
6895 "ALU64_XOR_K: Sign extension 1",
6897 BPF_LD_IMM64(R0
, 0x0123456789abcdefLL
),
6898 BPF_LD_IMM64(R1
, 0x0123456786a4c2e0LL
),
6899 BPF_ALU64_IMM(BPF_XOR
, R0
, 0x0f0f0f0f),
6900 BPF_JMP_REG(BPF_JEQ
, R0
, R1
, 2),
6901 BPF_MOV32_IMM(R0
, 2),
6903 BPF_MOV32_IMM(R0
, 1),
6911 "ALU64_XOR_K: Sign extension 2",
6913 BPF_LD_IMM64(R0
, 0x0123456789abcdefLL
),
6914 BPF_LD_IMM64(R1
, 0xfedcba98795b3d1fLL
),
6915 BPF_ALU64_IMM(BPF_XOR
, R0
, 0xf0f0f0f0),
6916 BPF_JMP_REG(BPF_JEQ
, R0
, R1
, 2),
6917 BPF_MOV32_IMM(R0
, 2),
6919 BPF_MOV32_IMM(R0
, 1),
6926 /* BPF_ALU | BPF_LSH | BPF_X */
6928 "ALU_LSH_X: 1 << 1 = 2",
6930 BPF_LD_IMM64(R0
, 1),
6931 BPF_ALU32_IMM(BPF_MOV
, R1
, 1),
6932 BPF_ALU32_REG(BPF_LSH
, R0
, R1
),
6940 "ALU_LSH_X: 1 << 31 = 0x80000000",
6942 BPF_LD_IMM64(R0
, 1),
6943 BPF_ALU32_IMM(BPF_MOV
, R1
, 31),
6944 BPF_ALU32_REG(BPF_LSH
, R0
, R1
),
6949 { { 0, 0x80000000 } },
6952 "ALU_LSH_X: 0x12345678 << 12 = 0x45678000",
6954 BPF_ALU32_IMM(BPF_MOV
, R0
, 0x12345678),
6955 BPF_ALU32_IMM(BPF_MOV
, R1
, 12),
6956 BPF_ALU32_REG(BPF_LSH
, R0
, R1
),
6961 { { 0, 0x45678000 } }
6964 "ALU64_LSH_X: 1 << 1 = 2",
6966 BPF_LD_IMM64(R0
, 1),
6967 BPF_ALU32_IMM(BPF_MOV
, R1
, 1),
6968 BPF_ALU64_REG(BPF_LSH
, R0
, R1
),
6976 "ALU64_LSH_X: 1 << 31 = 0x80000000",
6978 BPF_LD_IMM64(R0
, 1),
6979 BPF_ALU32_IMM(BPF_MOV
, R1
, 31),
6980 BPF_ALU64_REG(BPF_LSH
, R0
, R1
),
6985 { { 0, 0x80000000 } },
6988 "ALU64_LSH_X: Shift < 32, low word",
6990 BPF_LD_IMM64(R0
, 0x0123456789abcdefLL
),
6991 BPF_ALU32_IMM(BPF_MOV
, R1
, 12),
6992 BPF_ALU64_REG(BPF_LSH
, R0
, R1
),
6997 { { 0, 0xbcdef000 } }
7000 "ALU64_LSH_X: Shift < 32, high word",
7002 BPF_LD_IMM64(R0
, 0x0123456789abcdefLL
),
7003 BPF_ALU32_IMM(BPF_MOV
, R1
, 12),
7004 BPF_ALU64_REG(BPF_LSH
, R0
, R1
),
7005 BPF_ALU64_IMM(BPF_RSH
, R0
, 32),
7010 { { 0, 0x3456789a } }
7013 "ALU64_LSH_X: Shift > 32, low word",
7015 BPF_LD_IMM64(R0
, 0x0123456789abcdefLL
),
7016 BPF_ALU32_IMM(BPF_MOV
, R1
, 36),
7017 BPF_ALU64_REG(BPF_LSH
, R0
, R1
),
7025 "ALU64_LSH_X: Shift > 32, high word",
7027 BPF_LD_IMM64(R0
, 0x0123456789abcdefLL
),
7028 BPF_ALU32_IMM(BPF_MOV
, R1
, 36),
7029 BPF_ALU64_REG(BPF_LSH
, R0
, R1
),
7030 BPF_ALU64_IMM(BPF_RSH
, R0
, 32),
7035 { { 0, 0x9abcdef0 } }
7038 "ALU64_LSH_X: Shift == 32, low word",
7040 BPF_LD_IMM64(R0
, 0x0123456789abcdefLL
),
7041 BPF_ALU32_IMM(BPF_MOV
, R1
, 32),
7042 BPF_ALU64_REG(BPF_LSH
, R0
, R1
),
7050 "ALU64_LSH_X: Shift == 32, high word",
7052 BPF_LD_IMM64(R0
, 0x0123456789abcdefLL
),
7053 BPF_ALU32_IMM(BPF_MOV
, R1
, 32),
7054 BPF_ALU64_REG(BPF_LSH
, R0
, R1
),
7055 BPF_ALU64_IMM(BPF_RSH
, R0
, 32),
7060 { { 0, 0x89abcdef } }
7063 "ALU64_LSH_X: Zero shift, low word",
7065 BPF_LD_IMM64(R0
, 0x0123456789abcdefLL
),
7066 BPF_ALU32_IMM(BPF_MOV
, R1
, 0),
7067 BPF_ALU64_REG(BPF_LSH
, R0
, R1
),
7072 { { 0, 0x89abcdef } }
7075 "ALU64_LSH_X: Zero shift, high word",
7077 BPF_LD_IMM64(R0
, 0x0123456789abcdefLL
),
7078 BPF_ALU32_IMM(BPF_MOV
, R1
, 0),
7079 BPF_ALU64_REG(BPF_LSH
, R0
, R1
),
7080 BPF_ALU64_IMM(BPF_RSH
, R0
, 32),
7085 { { 0, 0x01234567 } }
7087 /* BPF_ALU | BPF_LSH | BPF_K */
7089 "ALU_LSH_K: 1 << 1 = 2",
7091 BPF_LD_IMM64(R0
, 1),
7092 BPF_ALU32_IMM(BPF_LSH
, R0
, 1),
7100 "ALU_LSH_K: 1 << 31 = 0x80000000",
7102 BPF_LD_IMM64(R0
, 1),
7103 BPF_ALU32_IMM(BPF_LSH
, R0
, 31),
7108 { { 0, 0x80000000 } },
7111 "ALU_LSH_K: 0x12345678 << 12 = 0x45678000",
7113 BPF_ALU32_IMM(BPF_MOV
, R0
, 0x12345678),
7114 BPF_ALU32_IMM(BPF_LSH
, R0
, 12),
7119 { { 0, 0x45678000 } }
7122 "ALU_LSH_K: 0x12345678 << 0 = 0x12345678",
7124 BPF_ALU32_IMM(BPF_MOV
, R0
, 0x12345678),
7125 BPF_ALU32_IMM(BPF_LSH
, R0
, 0),
7130 { { 0, 0x12345678 } }
7133 "ALU64_LSH_K: 1 << 1 = 2",
7135 BPF_LD_IMM64(R0
, 1),
7136 BPF_ALU64_IMM(BPF_LSH
, R0
, 1),
7144 "ALU64_LSH_K: 1 << 31 = 0x80000000",
7146 BPF_LD_IMM64(R0
, 1),
7147 BPF_ALU64_IMM(BPF_LSH
, R0
, 31),
7152 { { 0, 0x80000000 } },
7155 "ALU64_LSH_K: Shift < 32, low word",
7157 BPF_LD_IMM64(R0
, 0x0123456789abcdefLL
),
7158 BPF_ALU64_IMM(BPF_LSH
, R0
, 12),
7163 { { 0, 0xbcdef000 } }
7166 "ALU64_LSH_K: Shift < 32, high word",
7168 BPF_LD_IMM64(R0
, 0x0123456789abcdefLL
),
7169 BPF_ALU64_IMM(BPF_LSH
, R0
, 12),
7170 BPF_ALU64_IMM(BPF_RSH
, R0
, 32),
7175 { { 0, 0x3456789a } }
7178 "ALU64_LSH_K: Shift > 32, low word",
7180 BPF_LD_IMM64(R0
, 0x0123456789abcdefLL
),
7181 BPF_ALU64_IMM(BPF_LSH
, R0
, 36),
7189 "ALU64_LSH_K: Shift > 32, high word",
7191 BPF_LD_IMM64(R0
, 0x0123456789abcdefLL
),
7192 BPF_ALU64_IMM(BPF_LSH
, R0
, 36),
7193 BPF_ALU64_IMM(BPF_RSH
, R0
, 32),
7198 { { 0, 0x9abcdef0 } }
7201 "ALU64_LSH_K: Shift == 32, low word",
7203 BPF_LD_IMM64(R0
, 0x0123456789abcdefLL
),
7204 BPF_ALU64_IMM(BPF_LSH
, R0
, 32),
7212 "ALU64_LSH_K: Shift == 32, high word",
7214 BPF_LD_IMM64(R0
, 0x0123456789abcdefLL
),
7215 BPF_ALU64_IMM(BPF_LSH
, R0
, 32),
7216 BPF_ALU64_IMM(BPF_RSH
, R0
, 32),
7221 { { 0, 0x89abcdef } }
7224 "ALU64_LSH_K: Zero shift",
7226 BPF_LD_IMM64(R0
, 0x0123456789abcdefLL
),
7227 BPF_ALU64_IMM(BPF_LSH
, R0
, 0),
7232 { { 0, 0x89abcdef } }
7234 /* BPF_ALU | BPF_RSH | BPF_X */
7236 "ALU_RSH_X: 2 >> 1 = 1",
7238 BPF_LD_IMM64(R0
, 2),
7239 BPF_ALU32_IMM(BPF_MOV
, R1
, 1),
7240 BPF_ALU32_REG(BPF_RSH
, R0
, R1
),
7248 "ALU_RSH_X: 0x80000000 >> 31 = 1",
7250 BPF_LD_IMM64(R0
, 0x80000000),
7251 BPF_ALU32_IMM(BPF_MOV
, R1
, 31),
7252 BPF_ALU32_REG(BPF_RSH
, R0
, R1
),
7260 "ALU_RSH_X: 0x12345678 >> 20 = 0x123",
7262 BPF_ALU32_IMM(BPF_MOV
, R0
, 0x12345678),
7263 BPF_ALU32_IMM(BPF_MOV
, R1
, 20),
7264 BPF_ALU32_REG(BPF_RSH
, R0
, R1
),
7272 "ALU64_RSH_X: 2 >> 1 = 1",
7274 BPF_LD_IMM64(R0
, 2),
7275 BPF_ALU32_IMM(BPF_MOV
, R1
, 1),
7276 BPF_ALU64_REG(BPF_RSH
, R0
, R1
),
7284 "ALU64_RSH_X: 0x80000000 >> 31 = 1",
7286 BPF_LD_IMM64(R0
, 0x80000000),
7287 BPF_ALU32_IMM(BPF_MOV
, R1
, 31),
7288 BPF_ALU64_REG(BPF_RSH
, R0
, R1
),
7296 "ALU64_RSH_X: Shift < 32, low word",
7298 BPF_LD_IMM64(R0
, 0x8123456789abcdefLL
),
7299 BPF_ALU32_IMM(BPF_MOV
, R1
, 12),
7300 BPF_ALU64_REG(BPF_RSH
, R0
, R1
),
7305 { { 0, 0x56789abc } }
7308 "ALU64_RSH_X: Shift < 32, high word",
7310 BPF_LD_IMM64(R0
, 0x8123456789abcdefLL
),
7311 BPF_ALU32_IMM(BPF_MOV
, R1
, 12),
7312 BPF_ALU64_REG(BPF_RSH
, R0
, R1
),
7313 BPF_ALU64_IMM(BPF_RSH
, R0
, 32),
7318 { { 0, 0x00081234 } }
7321 "ALU64_RSH_X: Shift > 32, low word",
7323 BPF_LD_IMM64(R0
, 0x8123456789abcdefLL
),
7324 BPF_ALU32_IMM(BPF_MOV
, R1
, 36),
7325 BPF_ALU64_REG(BPF_RSH
, R0
, R1
),
7330 { { 0, 0x08123456 } }
7333 "ALU64_RSH_X: Shift > 32, high word",
7335 BPF_LD_IMM64(R0
, 0x8123456789abcdefLL
),
7336 BPF_ALU32_IMM(BPF_MOV
, R1
, 36),
7337 BPF_ALU64_REG(BPF_RSH
, R0
, R1
),
7338 BPF_ALU64_IMM(BPF_RSH
, R0
, 32),
7346 "ALU64_RSH_X: Shift == 32, low word",
7348 BPF_LD_IMM64(R0
, 0x8123456789abcdefLL
),
7349 BPF_ALU32_IMM(BPF_MOV
, R1
, 32),
7350 BPF_ALU64_REG(BPF_RSH
, R0
, R1
),
7355 { { 0, 0x81234567 } }
7358 "ALU64_RSH_X: Shift == 32, high word",
7360 BPF_LD_IMM64(R0
, 0x8123456789abcdefLL
),
7361 BPF_ALU32_IMM(BPF_MOV
, R1
, 32),
7362 BPF_ALU64_REG(BPF_RSH
, R0
, R1
),
7363 BPF_ALU64_IMM(BPF_RSH
, R0
, 32),
7371 "ALU64_RSH_X: Zero shift, low word",
7373 BPF_LD_IMM64(R0
, 0x8123456789abcdefLL
),
7374 BPF_ALU32_IMM(BPF_MOV
, R1
, 0),
7375 BPF_ALU64_REG(BPF_RSH
, R0
, R1
),
7380 { { 0, 0x89abcdef } }
7383 "ALU64_RSH_X: Zero shift, high word",
7385 BPF_LD_IMM64(R0
, 0x8123456789abcdefLL
),
7386 BPF_ALU32_IMM(BPF_MOV
, R1
, 0),
7387 BPF_ALU64_REG(BPF_RSH
, R0
, R1
),
7388 BPF_ALU64_IMM(BPF_RSH
, R0
, 32),
7393 { { 0, 0x81234567 } }
7395 /* BPF_ALU | BPF_RSH | BPF_K */
7397 "ALU_RSH_K: 2 >> 1 = 1",
7399 BPF_LD_IMM64(R0
, 2),
7400 BPF_ALU32_IMM(BPF_RSH
, R0
, 1),
7408 "ALU_RSH_K: 0x80000000 >> 31 = 1",
7410 BPF_LD_IMM64(R0
, 0x80000000),
7411 BPF_ALU32_IMM(BPF_RSH
, R0
, 31),
7419 "ALU_RSH_K: 0x12345678 >> 20 = 0x123",
7421 BPF_ALU32_IMM(BPF_MOV
, R0
, 0x12345678),
7422 BPF_ALU32_IMM(BPF_RSH
, R0
, 20),
7430 "ALU_RSH_K: 0x12345678 >> 0 = 0x12345678",
7432 BPF_ALU32_IMM(BPF_MOV
, R0
, 0x12345678),
7433 BPF_ALU32_IMM(BPF_RSH
, R0
, 0),
7438 { { 0, 0x12345678 } }
7441 "ALU64_RSH_K: 2 >> 1 = 1",
7443 BPF_LD_IMM64(R0
, 2),
7444 BPF_ALU64_IMM(BPF_RSH
, R0
, 1),
7452 "ALU64_RSH_K: 0x80000000 >> 31 = 1",
7454 BPF_LD_IMM64(R0
, 0x80000000),
7455 BPF_ALU64_IMM(BPF_RSH
, R0
, 31),
7463 "ALU64_RSH_K: Shift < 32, low word",
7465 BPF_LD_IMM64(R0
, 0x8123456789abcdefLL
),
7466 BPF_ALU64_IMM(BPF_RSH
, R0
, 12),
7471 { { 0, 0x56789abc } }
7474 "ALU64_RSH_K: Shift < 32, high word",
7476 BPF_LD_IMM64(R0
, 0x8123456789abcdefLL
),
7477 BPF_ALU64_IMM(BPF_RSH
, R0
, 12),
7478 BPF_ALU64_IMM(BPF_RSH
, R0
, 32),
7483 { { 0, 0x00081234 } }
7486 "ALU64_RSH_K: Shift > 32, low word",
7488 BPF_LD_IMM64(R0
, 0x8123456789abcdefLL
),
7489 BPF_ALU64_IMM(BPF_RSH
, R0
, 36),
7494 { { 0, 0x08123456 } }
7497 "ALU64_RSH_K: Shift > 32, high word",
7499 BPF_LD_IMM64(R0
, 0x8123456789abcdefLL
),
7500 BPF_ALU64_IMM(BPF_RSH
, R0
, 36),
7501 BPF_ALU64_IMM(BPF_RSH
, R0
, 32),
7509 "ALU64_RSH_K: Shift == 32, low word",
7511 BPF_LD_IMM64(R0
, 0x8123456789abcdefLL
),
7512 BPF_ALU64_IMM(BPF_RSH
, R0
, 32),
7517 { { 0, 0x81234567 } }
7520 "ALU64_RSH_K: Shift == 32, high word",
7522 BPF_LD_IMM64(R0
, 0x8123456789abcdefLL
),
7523 BPF_ALU64_IMM(BPF_RSH
, R0
, 32),
7524 BPF_ALU64_IMM(BPF_RSH
, R0
, 32),
7532 "ALU64_RSH_K: Zero shift",
7534 BPF_LD_IMM64(R0
, 0x0123456789abcdefLL
),
7535 BPF_ALU64_IMM(BPF_RSH
, R0
, 0),
7540 { { 0, 0x89abcdef } }
7542 /* BPF_ALU | BPF_ARSH | BPF_X */
7544 "ALU32_ARSH_X: -1234 >> 7 = -10",
7546 BPF_ALU32_IMM(BPF_MOV
, R0
, -1234),
7547 BPF_ALU32_IMM(BPF_MOV
, R1
, 7),
7548 BPF_ALU32_REG(BPF_ARSH
, R0
, R1
),
7556 "ALU64_ARSH_X: 0xff00ff0000000000 >> 40 = 0xffffffffffff00ff",
7558 BPF_LD_IMM64(R0
, 0xff00ff0000000000LL
),
7559 BPF_ALU32_IMM(BPF_MOV
, R1
, 40),
7560 BPF_ALU64_REG(BPF_ARSH
, R0
, R1
),
7565 { { 0, 0xffff00ff } },
7568 "ALU64_ARSH_X: Shift < 32, low word",
7570 BPF_LD_IMM64(R0
, 0x8123456789abcdefLL
),
7571 BPF_ALU32_IMM(BPF_MOV
, R1
, 12),
7572 BPF_ALU64_REG(BPF_ARSH
, R0
, R1
),
7577 { { 0, 0x56789abc } }
7580 "ALU64_ARSH_X: Shift < 32, high word",
7582 BPF_LD_IMM64(R0
, 0x8123456789abcdefLL
),
7583 BPF_ALU32_IMM(BPF_MOV
, R1
, 12),
7584 BPF_ALU64_REG(BPF_ARSH
, R0
, R1
),
7585 BPF_ALU64_IMM(BPF_RSH
, R0
, 32),
7590 { { 0, 0xfff81234 } }
7593 "ALU64_ARSH_X: Shift > 32, low word",
7595 BPF_LD_IMM64(R0
, 0x8123456789abcdefLL
),
7596 BPF_ALU32_IMM(BPF_MOV
, R1
, 36),
7597 BPF_ALU64_REG(BPF_ARSH
, R0
, R1
),
7602 { { 0, 0xf8123456 } }
7605 "ALU64_ARSH_X: Shift > 32, high word",
7607 BPF_LD_IMM64(R0
, 0x8123456789abcdefLL
),
7608 BPF_ALU32_IMM(BPF_MOV
, R1
, 36),
7609 BPF_ALU64_REG(BPF_ARSH
, R0
, R1
),
7610 BPF_ALU64_IMM(BPF_RSH
, R0
, 32),
7618 "ALU64_ARSH_X: Shift == 32, low word",
7620 BPF_LD_IMM64(R0
, 0x8123456789abcdefLL
),
7621 BPF_ALU32_IMM(BPF_MOV
, R1
, 32),
7622 BPF_ALU64_REG(BPF_ARSH
, R0
, R1
),
7627 { { 0, 0x81234567 } }
7630 "ALU64_ARSH_X: Shift == 32, high word",
7632 BPF_LD_IMM64(R0
, 0x8123456789abcdefLL
),
7633 BPF_ALU32_IMM(BPF_MOV
, R1
, 32),
7634 BPF_ALU64_REG(BPF_ARSH
, R0
, R1
),
7635 BPF_ALU64_IMM(BPF_RSH
, R0
, 32),
7643 "ALU64_ARSH_X: Zero shift, low word",
7645 BPF_LD_IMM64(R0
, 0x8123456789abcdefLL
),
7646 BPF_ALU32_IMM(BPF_MOV
, R1
, 0),
7647 BPF_ALU64_REG(BPF_ARSH
, R0
, R1
),
7652 { { 0, 0x89abcdef } }
7655 "ALU64_ARSH_X: Zero shift, high word",
7657 BPF_LD_IMM64(R0
, 0x8123456789abcdefLL
),
7658 BPF_ALU32_IMM(BPF_MOV
, R1
, 0),
7659 BPF_ALU64_REG(BPF_ARSH
, R0
, R1
),
7660 BPF_ALU64_IMM(BPF_RSH
, R0
, 32),
7665 { { 0, 0x81234567 } }
7667 /* BPF_ALU | BPF_ARSH | BPF_K */
7669 "ALU32_ARSH_K: -1234 >> 7 = -10",
7671 BPF_ALU32_IMM(BPF_MOV
, R0
, -1234),
7672 BPF_ALU32_IMM(BPF_ARSH
, R0
, 7),
7680 "ALU32_ARSH_K: -1234 >> 0 = -1234",
7682 BPF_ALU32_IMM(BPF_MOV
, R0
, -1234),
7683 BPF_ALU32_IMM(BPF_ARSH
, R0
, 0),
7691 "ALU64_ARSH_K: 0xff00ff0000000000 >> 40 = 0xffffffffffff00ff",
7693 BPF_LD_IMM64(R0
, 0xff00ff0000000000LL
),
7694 BPF_ALU64_IMM(BPF_ARSH
, R0
, 40),
7699 { { 0, 0xffff00ff } },
7702 "ALU64_ARSH_K: Shift < 32, low word",
7704 BPF_LD_IMM64(R0
, 0x8123456789abcdefLL
),
7705 BPF_ALU64_IMM(BPF_RSH
, R0
, 12),
7710 { { 0, 0x56789abc } }
7713 "ALU64_ARSH_K: Shift < 32, high word",
7715 BPF_LD_IMM64(R0
, 0x8123456789abcdefLL
),
7716 BPF_ALU64_IMM(BPF_ARSH
, R0
, 12),
7717 BPF_ALU64_IMM(BPF_RSH
, R0
, 32),
7722 { { 0, 0xfff81234 } }
7725 "ALU64_ARSH_K: Shift > 32, low word",
7727 BPF_LD_IMM64(R0
, 0x8123456789abcdefLL
),
7728 BPF_ALU64_IMM(BPF_ARSH
, R0
, 36),
7733 { { 0, 0xf8123456 } }
7736 "ALU64_ARSH_K: Shift > 32, high word",
7738 BPF_LD_IMM64(R0
, 0xf123456789abcdefLL
),
7739 BPF_ALU64_IMM(BPF_ARSH
, R0
, 36),
7740 BPF_ALU64_IMM(BPF_RSH
, R0
, 32),
7748 "ALU64_ARSH_K: Shift == 32, low word",
7750 BPF_LD_IMM64(R0
, 0x8123456789abcdefLL
),
7751 BPF_ALU64_IMM(BPF_ARSH
, R0
, 32),
7756 { { 0, 0x81234567 } }
7759 "ALU64_ARSH_K: Shift == 32, high word",
7761 BPF_LD_IMM64(R0
, 0x8123456789abcdefLL
),
7762 BPF_ALU64_IMM(BPF_ARSH
, R0
, 32),
7763 BPF_ALU64_IMM(BPF_RSH
, R0
, 32),
7771 "ALU64_ARSH_K: Zero shift",
7773 BPF_LD_IMM64(R0
, 0x8123456789abcdefLL
),
7774 BPF_ALU64_IMM(BPF_ARSH
, R0
, 0),
7779 { { 0, 0x89abcdef } }
7781 /* BPF_ALU | BPF_NEG */
7783 "ALU_NEG: -(3) = -3",
7785 BPF_ALU32_IMM(BPF_MOV
, R0
, 3),
7786 BPF_ALU32_IMM(BPF_NEG
, R0
, 0),
7794 "ALU_NEG: -(-3) = 3",
7796 BPF_ALU32_IMM(BPF_MOV
, R0
, -3),
7797 BPF_ALU32_IMM(BPF_NEG
, R0
, 0),
7805 "ALU64_NEG: -(3) = -3",
7807 BPF_LD_IMM64(R0
, 3),
7808 BPF_ALU64_IMM(BPF_NEG
, R0
, 0),
7816 "ALU64_NEG: -(-3) = 3",
7818 BPF_LD_IMM64(R0
, -3),
7819 BPF_ALU64_IMM(BPF_NEG
, R0
, 0),
7826 /* BPF_ALU | BPF_END | BPF_FROM_BE */
7828 "ALU_END_FROM_BE 16: 0x0123456789abcdef -> 0xcdef",
7830 BPF_LD_IMM64(R0
, 0x0123456789abcdefLL
),
7831 BPF_ENDIAN(BPF_FROM_BE
, R0
, 16),
7836 { { 0, cpu_to_be16(0xcdef) } },
7839 "ALU_END_FROM_BE 32: 0x0123456789abcdef -> 0x89abcdef",
7841 BPF_LD_IMM64(R0
, 0x0123456789abcdefLL
),
7842 BPF_ENDIAN(BPF_FROM_BE
, R0
, 32),
7843 BPF_ALU64_REG(BPF_MOV
, R1
, R0
),
7844 BPF_ALU64_IMM(BPF_RSH
, R1
, 32),
7845 BPF_ALU32_REG(BPF_ADD
, R0
, R1
), /* R1 = 0 */
7850 { { 0, cpu_to_be32(0x89abcdef) } },
7853 "ALU_END_FROM_BE 64: 0x0123456789abcdef -> 0x89abcdef",
7855 BPF_LD_IMM64(R0
, 0x0123456789abcdefLL
),
7856 BPF_ENDIAN(BPF_FROM_BE
, R0
, 64),
7861 { { 0, (u32
) cpu_to_be64(0x0123456789abcdefLL
) } },
7864 "ALU_END_FROM_BE 64: 0x0123456789abcdef >> 32 -> 0x01234567",
7866 BPF_LD_IMM64(R0
, 0x0123456789abcdefLL
),
7867 BPF_ENDIAN(BPF_FROM_BE
, R0
, 64),
7868 BPF_ALU64_IMM(BPF_RSH
, R0
, 32),
7873 { { 0, (u32
) (cpu_to_be64(0x0123456789abcdefLL
) >> 32) } },
7875 /* BPF_ALU | BPF_END | BPF_FROM_BE, reversed */
7877 "ALU_END_FROM_BE 16: 0xfedcba9876543210 -> 0x3210",
7879 BPF_LD_IMM64(R0
, 0xfedcba9876543210ULL
),
7880 BPF_ENDIAN(BPF_FROM_BE
, R0
, 16),
7885 { { 0, cpu_to_be16(0x3210) } },
7888 "ALU_END_FROM_BE 32: 0xfedcba9876543210 -> 0x76543210",
7890 BPF_LD_IMM64(R0
, 0xfedcba9876543210ULL
),
7891 BPF_ENDIAN(BPF_FROM_BE
, R0
, 32),
7892 BPF_ALU64_REG(BPF_MOV
, R1
, R0
),
7893 BPF_ALU64_IMM(BPF_RSH
, R1
, 32),
7894 BPF_ALU32_REG(BPF_ADD
, R0
, R1
), /* R1 = 0 */
7899 { { 0, cpu_to_be32(0x76543210) } },
7902 "ALU_END_FROM_BE 64: 0xfedcba9876543210 -> 0x76543210",
7904 BPF_LD_IMM64(R0
, 0xfedcba9876543210ULL
),
7905 BPF_ENDIAN(BPF_FROM_BE
, R0
, 64),
7910 { { 0, (u32
) cpu_to_be64(0xfedcba9876543210ULL
) } },
7913 "ALU_END_FROM_BE 64: 0xfedcba9876543210 >> 32 -> 0xfedcba98",
7915 BPF_LD_IMM64(R0
, 0xfedcba9876543210ULL
),
7916 BPF_ENDIAN(BPF_FROM_BE
, R0
, 64),
7917 BPF_ALU64_IMM(BPF_RSH
, R0
, 32),
7922 { { 0, (u32
) (cpu_to_be64(0xfedcba9876543210ULL
) >> 32) } },
7924 /* BPF_ALU | BPF_END | BPF_FROM_LE */
7926 "ALU_END_FROM_LE 16: 0x0123456789abcdef -> 0xefcd",
7928 BPF_LD_IMM64(R0
, 0x0123456789abcdefLL
),
7929 BPF_ENDIAN(BPF_FROM_LE
, R0
, 16),
7934 { { 0, cpu_to_le16(0xcdef) } },
7937 "ALU_END_FROM_LE 32: 0x0123456789abcdef -> 0xefcdab89",
7939 BPF_LD_IMM64(R0
, 0x0123456789abcdefLL
),
7940 BPF_ENDIAN(BPF_FROM_LE
, R0
, 32),
7941 BPF_ALU64_REG(BPF_MOV
, R1
, R0
),
7942 BPF_ALU64_IMM(BPF_RSH
, R1
, 32),
7943 BPF_ALU32_REG(BPF_ADD
, R0
, R1
), /* R1 = 0 */
7948 { { 0, cpu_to_le32(0x89abcdef) } },
7951 "ALU_END_FROM_LE 64: 0x0123456789abcdef -> 0x67452301",
7953 BPF_LD_IMM64(R0
, 0x0123456789abcdefLL
),
7954 BPF_ENDIAN(BPF_FROM_LE
, R0
, 64),
7959 { { 0, (u32
) cpu_to_le64(0x0123456789abcdefLL
) } },
7962 "ALU_END_FROM_LE 64: 0x0123456789abcdef >> 32 -> 0xefcdab89",
7964 BPF_LD_IMM64(R0
, 0x0123456789abcdefLL
),
7965 BPF_ENDIAN(BPF_FROM_LE
, R0
, 64),
7966 BPF_ALU64_IMM(BPF_RSH
, R0
, 32),
7971 { { 0, (u32
) (cpu_to_le64(0x0123456789abcdefLL
) >> 32) } },
7973 /* BPF_ALU | BPF_END | BPF_FROM_LE, reversed */
7975 "ALU_END_FROM_LE 16: 0xfedcba9876543210 -> 0x1032",
7977 BPF_LD_IMM64(R0
, 0xfedcba9876543210ULL
),
7978 BPF_ENDIAN(BPF_FROM_LE
, R0
, 16),
7983 { { 0, cpu_to_le16(0x3210) } },
7986 "ALU_END_FROM_LE 32: 0xfedcba9876543210 -> 0x10325476",
7988 BPF_LD_IMM64(R0
, 0xfedcba9876543210ULL
),
7989 BPF_ENDIAN(BPF_FROM_LE
, R0
, 32),
7990 BPF_ALU64_REG(BPF_MOV
, R1
, R0
),
7991 BPF_ALU64_IMM(BPF_RSH
, R1
, 32),
7992 BPF_ALU32_REG(BPF_ADD
, R0
, R1
), /* R1 = 0 */
7997 { { 0, cpu_to_le32(0x76543210) } },
8000 "ALU_END_FROM_LE 64: 0xfedcba9876543210 -> 0x10325476",
8002 BPF_LD_IMM64(R0
, 0xfedcba9876543210ULL
),
8003 BPF_ENDIAN(BPF_FROM_LE
, R0
, 64),
8008 { { 0, (u32
) cpu_to_le64(0xfedcba9876543210ULL
) } },
8011 "ALU_END_FROM_LE 64: 0xfedcba9876543210 >> 32 -> 0x98badcfe",
8013 BPF_LD_IMM64(R0
, 0xfedcba9876543210ULL
),
8014 BPF_ENDIAN(BPF_FROM_LE
, R0
, 64),
8015 BPF_ALU64_IMM(BPF_RSH
, R0
, 32),
8020 { { 0, (u32
) (cpu_to_le64(0xfedcba9876543210ULL
) >> 32) } },
8024 "BSWAP 16: 0x0123456789abcdef -> 0xefcd",
8026 BPF_LD_IMM64(R0
, 0x0123456789abcdefLL
),
8035 "BSWAP 32: 0x0123456789abcdef -> 0xefcdab89",
8037 BPF_LD_IMM64(R0
, 0x0123456789abcdefLL
),
8039 BPF_ALU64_REG(BPF_MOV
, R1
, R0
),
8040 BPF_ALU64_IMM(BPF_RSH
, R1
, 32),
8041 BPF_ALU32_REG(BPF_ADD
, R0
, R1
), /* R1 = 0 */
8046 { { 0, 0xefcdab89 } },
8049 "BSWAP 64: 0x0123456789abcdef -> 0x67452301",
8051 BPF_LD_IMM64(R0
, 0x0123456789abcdefLL
),
8057 { { 0, 0x67452301 } },
8060 "BSWAP 64: 0x0123456789abcdef >> 32 -> 0xefcdab89",
8062 BPF_LD_IMM64(R0
, 0x0123456789abcdefLL
),
8064 BPF_ALU64_IMM(BPF_RSH
, R0
, 32),
8069 { { 0, 0xefcdab89 } },
8071 /* BSWAP, reversed */
8073 "BSWAP 16: 0xfedcba9876543210 -> 0x1032",
8075 BPF_LD_IMM64(R0
, 0xfedcba9876543210ULL
),
8084 "BSWAP 32: 0xfedcba9876543210 -> 0x10325476",
8086 BPF_LD_IMM64(R0
, 0xfedcba9876543210ULL
),
8088 BPF_ALU64_REG(BPF_MOV
, R1
, R0
),
8089 BPF_ALU64_IMM(BPF_RSH
, R1
, 32),
8090 BPF_ALU32_REG(BPF_ADD
, R0
, R1
), /* R1 = 0 */
8095 { { 0, 0x10325476 } },
8098 "BSWAP 64: 0xfedcba9876543210 -> 0x98badcfe",
8100 BPF_LD_IMM64(R0
, 0xfedcba9876543210ULL
),
8106 { { 0, 0x98badcfe } },
8109 "BSWAP 64: 0xfedcba9876543210 >> 32 -> 0x10325476",
8111 BPF_LD_IMM64(R0
, 0xfedcba9876543210ULL
),
8113 BPF_ALU64_IMM(BPF_RSH
, R0
, 32),
8118 { { 0, 0x10325476 } },
8120 /* BPF_LDX_MEM B/H/W/DW */
8122 "BPF_LDX_MEM | BPF_B, base",
8124 BPF_LD_IMM64(R1
, 0x0102030405060708ULL
),
8125 BPF_LD_IMM64(R2
, 0x0000000000000008ULL
),
8126 BPF_STX_MEM(BPF_DW
, R10
, R1
, -8),
8128 BPF_LDX_MEM(BPF_B
, R0
, R10
, -1),
8130 BPF_LDX_MEM(BPF_B
, R0
, R10
, -8),
8132 BPF_JMP_REG(BPF_JNE
, R0
, R2
, 1),
8133 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
8142 "BPF_LDX_MEM | BPF_B, MSB set",
8144 BPF_LD_IMM64(R1
, 0x8182838485868788ULL
),
8145 BPF_LD_IMM64(R2
, 0x0000000000000088ULL
),
8146 BPF_STX_MEM(BPF_DW
, R10
, R1
, -8),
8148 BPF_LDX_MEM(BPF_B
, R0
, R10
, -1),
8150 BPF_LDX_MEM(BPF_B
, R0
, R10
, -8),
8152 BPF_JMP_REG(BPF_JNE
, R0
, R2
, 1),
8153 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
8162 "BPF_LDX_MEM | BPF_B, negative offset",
8164 BPF_LD_IMM64(R2
, 0x8182838485868788ULL
),
8165 BPF_LD_IMM64(R3
, 0x0000000000000088ULL
),
8166 BPF_ALU64_IMM(BPF_ADD
, R1
, 512),
8167 BPF_STX_MEM(BPF_B
, R1
, R2
, -256),
8168 BPF_LDX_MEM(BPF_B
, R0
, R1
, -256),
8169 BPF_JMP_REG(BPF_JNE
, R0
, R3
, 1),
8170 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
8173 INTERNAL
| FLAG_LARGE_MEM
,
8179 "BPF_LDX_MEM | BPF_B, small positive offset",
8181 BPF_LD_IMM64(R2
, 0x8182838485868788ULL
),
8182 BPF_LD_IMM64(R3
, 0x0000000000000088ULL
),
8183 BPF_STX_MEM(BPF_B
, R1
, R2
, 256),
8184 BPF_LDX_MEM(BPF_B
, R0
, R1
, 256),
8185 BPF_JMP_REG(BPF_JNE
, R0
, R3
, 1),
8186 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
8189 INTERNAL
| FLAG_LARGE_MEM
,
8195 "BPF_LDX_MEM | BPF_B, large positive offset",
8197 BPF_LD_IMM64(R2
, 0x8182838485868788ULL
),
8198 BPF_LD_IMM64(R3
, 0x0000000000000088ULL
),
8199 BPF_STX_MEM(BPF_B
, R1
, R2
, 4096),
8200 BPF_LDX_MEM(BPF_B
, R0
, R1
, 4096),
8201 BPF_JMP_REG(BPF_JNE
, R0
, R3
, 1),
8202 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
8205 INTERNAL
| FLAG_LARGE_MEM
,
8207 { { 4096 + 16, 0 } },
8211 "BPF_LDX_MEM | BPF_H, base",
8213 BPF_LD_IMM64(R1
, 0x0102030405060708ULL
),
8214 BPF_LD_IMM64(R2
, 0x0000000000000708ULL
),
8215 BPF_STX_MEM(BPF_DW
, R10
, R1
, -8),
8217 BPF_LDX_MEM(BPF_H
, R0
, R10
, -2),
8219 BPF_LDX_MEM(BPF_H
, R0
, R10
, -8),
8221 BPF_JMP_REG(BPF_JNE
, R0
, R2
, 1),
8222 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
8231 "BPF_LDX_MEM | BPF_H, MSB set",
8233 BPF_LD_IMM64(R1
, 0x8182838485868788ULL
),
8234 BPF_LD_IMM64(R2
, 0x0000000000008788ULL
),
8235 BPF_STX_MEM(BPF_DW
, R10
, R1
, -8),
8237 BPF_LDX_MEM(BPF_H
, R0
, R10
, -2),
8239 BPF_LDX_MEM(BPF_H
, R0
, R10
, -8),
8241 BPF_JMP_REG(BPF_JNE
, R0
, R2
, 1),
8242 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
8251 "BPF_LDX_MEM | BPF_H, negative offset",
8253 BPF_LD_IMM64(R2
, 0x8182838485868788ULL
),
8254 BPF_LD_IMM64(R3
, 0x0000000000008788ULL
),
8255 BPF_ALU64_IMM(BPF_ADD
, R1
, 512),
8256 BPF_STX_MEM(BPF_H
, R1
, R2
, -256),
8257 BPF_LDX_MEM(BPF_H
, R0
, R1
, -256),
8258 BPF_JMP_REG(BPF_JNE
, R0
, R3
, 1),
8259 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
8262 INTERNAL
| FLAG_LARGE_MEM
,
8268 "BPF_LDX_MEM | BPF_H, small positive offset",
8270 BPF_LD_IMM64(R2
, 0x8182838485868788ULL
),
8271 BPF_LD_IMM64(R3
, 0x0000000000008788ULL
),
8272 BPF_STX_MEM(BPF_H
, R1
, R2
, 256),
8273 BPF_LDX_MEM(BPF_H
, R0
, R1
, 256),
8274 BPF_JMP_REG(BPF_JNE
, R0
, R3
, 1),
8275 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
8278 INTERNAL
| FLAG_LARGE_MEM
,
8284 "BPF_LDX_MEM | BPF_H, large positive offset",
8286 BPF_LD_IMM64(R2
, 0x8182838485868788ULL
),
8287 BPF_LD_IMM64(R3
, 0x0000000000008788ULL
),
8288 BPF_STX_MEM(BPF_H
, R1
, R2
, 8192),
8289 BPF_LDX_MEM(BPF_H
, R0
, R1
, 8192),
8290 BPF_JMP_REG(BPF_JNE
, R0
, R3
, 1),
8291 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
8294 INTERNAL
| FLAG_LARGE_MEM
,
8296 { { 8192 + 16, 0 } },
8300 "BPF_LDX_MEM | BPF_H, unaligned positive offset",
8302 BPF_LD_IMM64(R2
, 0x8182838485868788ULL
),
8303 BPF_LD_IMM64(R3
, 0x0000000000008788ULL
),
8304 BPF_STX_MEM(BPF_H
, R1
, R2
, 13),
8305 BPF_LDX_MEM(BPF_H
, R0
, R1
, 13),
8306 BPF_JMP_REG(BPF_JNE
, R0
, R3
, 1),
8307 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
8310 INTERNAL
| FLAG_LARGE_MEM
,
8316 "BPF_LDX_MEM | BPF_W, base",
8318 BPF_LD_IMM64(R1
, 0x0102030405060708ULL
),
8319 BPF_LD_IMM64(R2
, 0x0000000005060708ULL
),
8320 BPF_STX_MEM(BPF_DW
, R10
, R1
, -8),
8322 BPF_LDX_MEM(BPF_W
, R0
, R10
, -4),
8324 BPF_LDX_MEM(BPF_W
, R0
, R10
, -8),
8326 BPF_JMP_REG(BPF_JNE
, R0
, R2
, 1),
8327 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
8336 "BPF_LDX_MEM | BPF_W, MSB set",
8338 BPF_LD_IMM64(R1
, 0x8182838485868788ULL
),
8339 BPF_LD_IMM64(R2
, 0x0000000085868788ULL
),
8340 BPF_STX_MEM(BPF_DW
, R10
, R1
, -8),
8342 BPF_LDX_MEM(BPF_W
, R0
, R10
, -4),
8344 BPF_LDX_MEM(BPF_W
, R0
, R10
, -8),
8346 BPF_JMP_REG(BPF_JNE
, R0
, R2
, 1),
8347 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
8356 "BPF_LDX_MEM | BPF_W, negative offset",
8358 BPF_LD_IMM64(R2
, 0x8182838485868788ULL
),
8359 BPF_LD_IMM64(R3
, 0x0000000085868788ULL
),
8360 BPF_ALU64_IMM(BPF_ADD
, R1
, 512),
8361 BPF_STX_MEM(BPF_W
, R1
, R2
, -256),
8362 BPF_LDX_MEM(BPF_W
, R0
, R1
, -256),
8363 BPF_JMP_REG(BPF_JNE
, R0
, R3
, 1),
8364 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
8367 INTERNAL
| FLAG_LARGE_MEM
,
8373 "BPF_LDX_MEM | BPF_W, small positive offset",
8375 BPF_LD_IMM64(R2
, 0x8182838485868788ULL
),
8376 BPF_LD_IMM64(R3
, 0x0000000085868788ULL
),
8377 BPF_STX_MEM(BPF_W
, R1
, R2
, 256),
8378 BPF_LDX_MEM(BPF_W
, R0
, R1
, 256),
8379 BPF_JMP_REG(BPF_JNE
, R0
, R3
, 1),
8380 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
8383 INTERNAL
| FLAG_LARGE_MEM
,
8389 "BPF_LDX_MEM | BPF_W, large positive offset",
8391 BPF_LD_IMM64(R2
, 0x8182838485868788ULL
),
8392 BPF_LD_IMM64(R3
, 0x0000000085868788ULL
),
8393 BPF_STX_MEM(BPF_W
, R1
, R2
, 16384),
8394 BPF_LDX_MEM(BPF_W
, R0
, R1
, 16384),
8395 BPF_JMP_REG(BPF_JNE
, R0
, R3
, 1),
8396 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
8399 INTERNAL
| FLAG_LARGE_MEM
,
8401 { { 16384 + 16, 0 } },
8405 "BPF_LDX_MEM | BPF_W, unaligned positive offset",
8407 BPF_LD_IMM64(R2
, 0x8182838485868788ULL
),
8408 BPF_LD_IMM64(R3
, 0x0000000085868788ULL
),
8409 BPF_STX_MEM(BPF_W
, R1
, R2
, 13),
8410 BPF_LDX_MEM(BPF_W
, R0
, R1
, 13),
8411 BPF_JMP_REG(BPF_JNE
, R0
, R3
, 1),
8412 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
8415 INTERNAL
| FLAG_LARGE_MEM
,
8421 "BPF_LDX_MEM | BPF_DW, base",
8423 BPF_LD_IMM64(R1
, 0x0102030405060708ULL
),
8424 BPF_STX_MEM(BPF_DW
, R10
, R1
, -8),
8425 BPF_LDX_MEM(BPF_DW
, R0
, R10
, -8),
8426 BPF_JMP_REG(BPF_JNE
, R0
, R1
, 1),
8427 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
8436 "BPF_LDX_MEM | BPF_DW, MSB set",
8438 BPF_LD_IMM64(R1
, 0x8182838485868788ULL
),
8439 BPF_STX_MEM(BPF_DW
, R10
, R1
, -8),
8440 BPF_LDX_MEM(BPF_DW
, R0
, R10
, -8),
8441 BPF_JMP_REG(BPF_JNE
, R0
, R1
, 1),
8442 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
8451 "BPF_LDX_MEM | BPF_DW, negative offset",
8453 BPF_LD_IMM64(R2
, 0x8182838485868788ULL
),
8454 BPF_ALU64_IMM(BPF_ADD
, R1
, 512),
8455 BPF_STX_MEM(BPF_DW
, R1
, R2
, -256),
8456 BPF_LDX_MEM(BPF_DW
, R0
, R1
, -256),
8457 BPF_JMP_REG(BPF_JNE
, R0
, R2
, 1),
8458 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
8461 INTERNAL
| FLAG_LARGE_MEM
,
8467 "BPF_LDX_MEM | BPF_DW, small positive offset",
8469 BPF_LD_IMM64(R2
, 0x8182838485868788ULL
),
8470 BPF_STX_MEM(BPF_DW
, R1
, R2
, 256),
8471 BPF_LDX_MEM(BPF_DW
, R0
, R1
, 256),
8472 BPF_JMP_REG(BPF_JNE
, R0
, R2
, 1),
8473 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
8476 INTERNAL
| FLAG_LARGE_MEM
,
8482 "BPF_LDX_MEM | BPF_DW, large positive offset",
8484 BPF_LD_IMM64(R2
, 0x8182838485868788ULL
),
8485 BPF_STX_MEM(BPF_DW
, R1
, R2
, 32760),
8486 BPF_LDX_MEM(BPF_DW
, R0
, R1
, 32760),
8487 BPF_JMP_REG(BPF_JNE
, R0
, R2
, 1),
8488 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
8491 INTERNAL
| FLAG_LARGE_MEM
,
8497 "BPF_LDX_MEM | BPF_DW, unaligned positive offset",
8499 BPF_LD_IMM64(R2
, 0x8182838485868788ULL
),
8500 BPF_STX_MEM(BPF_DW
, R1
, R2
, 13),
8501 BPF_LDX_MEM(BPF_DW
, R0
, R1
, 13),
8502 BPF_JMP_REG(BPF_JNE
, R0
, R2
, 1),
8503 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
8506 INTERNAL
| FLAG_LARGE_MEM
,
8511 /* BPF_LDX_MEMSX B/H/W */
8513 "BPF_LDX_MEMSX | BPF_B",
8515 BPF_LD_IMM64(R1
, 0xdead0000000000f0ULL
),
8516 BPF_LD_IMM64(R2
, 0xfffffffffffffff0ULL
),
8517 BPF_STX_MEM(BPF_DW
, R10
, R1
, -8),
8519 BPF_LDX_MEMSX(BPF_B
, R0
, R10
, -1),
8521 BPF_LDX_MEMSX(BPF_B
, R0
, R10
, -8),
8523 BPF_JMP_REG(BPF_JNE
, R0
, R2
, 1),
8524 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
8533 "BPF_LDX_MEMSX | BPF_H",
8535 BPF_LD_IMM64(R1
, 0xdead00000000f123ULL
),
8536 BPF_LD_IMM64(R2
, 0xfffffffffffff123ULL
),
8537 BPF_STX_MEM(BPF_DW
, R10
, R1
, -8),
8539 BPF_LDX_MEMSX(BPF_H
, R0
, R10
, -2),
8541 BPF_LDX_MEMSX(BPF_H
, R0
, R10
, -8),
8543 BPF_JMP_REG(BPF_JNE
, R0
, R2
, 1),
8544 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
8553 "BPF_LDX_MEMSX | BPF_W",
8555 BPF_LD_IMM64(R1
, 0x00000000deadbeefULL
),
8556 BPF_LD_IMM64(R2
, 0xffffffffdeadbeefULL
),
8557 BPF_STX_MEM(BPF_DW
, R10
, R1
, -8),
8559 BPF_LDX_MEMSX(BPF_W
, R0
, R10
, -4),
8561 BPF_LDX_MEMSX(BPF_W
, R0
, R10
, -8),
8563 BPF_JMP_REG(BPF_JNE
, R0
, R2
, 1),
8564 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
8572 /* BPF_STX_MEM B/H/W/DW */
8574 "BPF_STX_MEM | BPF_B",
8576 BPF_LD_IMM64(R1
, 0x8090a0b0c0d0e0f0ULL
),
8577 BPF_LD_IMM64(R2
, 0x0102030405060708ULL
),
8578 BPF_LD_IMM64(R3
, 0x8090a0b0c0d0e008ULL
),
8579 BPF_STX_MEM(BPF_DW
, R10
, R1
, -8),
8581 BPF_STX_MEM(BPF_B
, R10
, R2
, -1),
8583 BPF_STX_MEM(BPF_B
, R10
, R2
, -8),
8585 BPF_LDX_MEM(BPF_DW
, R0
, R10
, -8),
8586 BPF_JMP_REG(BPF_JNE
, R0
, R3
, 1),
8587 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
8596 "BPF_STX_MEM | BPF_B, MSB set",
8598 BPF_LD_IMM64(R1
, 0x8090a0b0c0d0e0f0ULL
),
8599 BPF_LD_IMM64(R2
, 0x8182838485868788ULL
),
8600 BPF_LD_IMM64(R3
, 0x8090a0b0c0d0e088ULL
),
8601 BPF_STX_MEM(BPF_DW
, R10
, R1
, -8),
8603 BPF_STX_MEM(BPF_B
, R10
, R2
, -1),
8605 BPF_STX_MEM(BPF_B
, R10
, R2
, -8),
8607 BPF_LDX_MEM(BPF_DW
, R0
, R10
, -8),
8608 BPF_JMP_REG(BPF_JNE
, R0
, R3
, 1),
8609 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
8618 "BPF_STX_MEM | BPF_H",
8620 BPF_LD_IMM64(R1
, 0x8090a0b0c0d0e0f0ULL
),
8621 BPF_LD_IMM64(R2
, 0x0102030405060708ULL
),
8622 BPF_LD_IMM64(R3
, 0x8090a0b0c0d00708ULL
),
8623 BPF_STX_MEM(BPF_DW
, R10
, R1
, -8),
8625 BPF_STX_MEM(BPF_H
, R10
, R2
, -2),
8627 BPF_STX_MEM(BPF_H
, R10
, R2
, -8),
8629 BPF_LDX_MEM(BPF_DW
, R0
, R10
, -8),
8630 BPF_JMP_REG(BPF_JNE
, R0
, R3
, 1),
8631 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
8640 "BPF_STX_MEM | BPF_H, MSB set",
8642 BPF_LD_IMM64(R1
, 0x8090a0b0c0d0e0f0ULL
),
8643 BPF_LD_IMM64(R2
, 0x8182838485868788ULL
),
8644 BPF_LD_IMM64(R3
, 0x8090a0b0c0d08788ULL
),
8645 BPF_STX_MEM(BPF_DW
, R10
, R1
, -8),
8647 BPF_STX_MEM(BPF_H
, R10
, R2
, -2),
8649 BPF_STX_MEM(BPF_H
, R10
, R2
, -8),
8651 BPF_LDX_MEM(BPF_DW
, R0
, R10
, -8),
8652 BPF_JMP_REG(BPF_JNE
, R0
, R3
, 1),
8653 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
8662 "BPF_STX_MEM | BPF_W",
8664 BPF_LD_IMM64(R1
, 0x8090a0b0c0d0e0f0ULL
),
8665 BPF_LD_IMM64(R2
, 0x0102030405060708ULL
),
8666 BPF_LD_IMM64(R3
, 0x8090a0b005060708ULL
),
8667 BPF_STX_MEM(BPF_DW
, R10
, R1
, -8),
8669 BPF_STX_MEM(BPF_W
, R10
, R2
, -4),
8671 BPF_STX_MEM(BPF_W
, R10
, R2
, -8),
8673 BPF_LDX_MEM(BPF_DW
, R0
, R10
, -8),
8674 BPF_JMP_REG(BPF_JNE
, R0
, R3
, 1),
8675 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
8684 "BPF_STX_MEM | BPF_W, MSB set",
8686 BPF_LD_IMM64(R1
, 0x8090a0b0c0d0e0f0ULL
),
8687 BPF_LD_IMM64(R2
, 0x8182838485868788ULL
),
8688 BPF_LD_IMM64(R3
, 0x8090a0b085868788ULL
),
8689 BPF_STX_MEM(BPF_DW
, R10
, R1
, -8),
8691 BPF_STX_MEM(BPF_W
, R10
, R2
, -4),
8693 BPF_STX_MEM(BPF_W
, R10
, R2
, -8),
8695 BPF_LDX_MEM(BPF_DW
, R0
, R10
, -8),
8696 BPF_JMP_REG(BPF_JNE
, R0
, R3
, 1),
8697 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
8705 /* BPF_ST(X) | BPF_MEM | BPF_B/H/W/DW */
8707 "ST_MEM_B: Store/Load byte: max negative",
8709 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
8710 BPF_ST_MEM(BPF_B
, R10
, -40, 0xff),
8711 BPF_LDX_MEM(BPF_B
, R0
, R10
, -40),
8720 "ST_MEM_B: Store/Load byte: max positive",
8722 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
8723 BPF_ST_MEM(BPF_H
, R10
, -40, 0x7f),
8724 BPF_LDX_MEM(BPF_H
, R0
, R10
, -40),
8733 "STX_MEM_B: Store/Load byte: max negative",
8735 BPF_LD_IMM64(R0
, 0),
8736 BPF_LD_IMM64(R1
, 0xffLL
),
8737 BPF_STX_MEM(BPF_B
, R10
, R1
, -40),
8738 BPF_LDX_MEM(BPF_B
, R0
, R10
, -40),
8747 "ST_MEM_H: Store/Load half word: max negative",
8749 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
8750 BPF_ST_MEM(BPF_H
, R10
, -40, 0xffff),
8751 BPF_LDX_MEM(BPF_H
, R0
, R10
, -40),
8760 "ST_MEM_H: Store/Load half word: max positive",
8762 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
8763 BPF_ST_MEM(BPF_H
, R10
, -40, 0x7fff),
8764 BPF_LDX_MEM(BPF_H
, R0
, R10
, -40),
8773 "STX_MEM_H: Store/Load half word: max negative",
8775 BPF_LD_IMM64(R0
, 0),
8776 BPF_LD_IMM64(R1
, 0xffffLL
),
8777 BPF_STX_MEM(BPF_H
, R10
, R1
, -40),
8778 BPF_LDX_MEM(BPF_H
, R0
, R10
, -40),
8787 "ST_MEM_W: Store/Load word: max negative",
8789 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
8790 BPF_ST_MEM(BPF_W
, R10
, -40, 0xffffffff),
8791 BPF_LDX_MEM(BPF_W
, R0
, R10
, -40),
8796 { { 0, 0xffffffff } },
8800 "ST_MEM_W: Store/Load word: max positive",
8802 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
8803 BPF_ST_MEM(BPF_W
, R10
, -40, 0x7fffffff),
8804 BPF_LDX_MEM(BPF_W
, R0
, R10
, -40),
8809 { { 0, 0x7fffffff } },
8813 "STX_MEM_W: Store/Load word: max negative",
8815 BPF_LD_IMM64(R0
, 0),
8816 BPF_LD_IMM64(R1
, 0xffffffffLL
),
8817 BPF_STX_MEM(BPF_W
, R10
, R1
, -40),
8818 BPF_LDX_MEM(BPF_W
, R0
, R10
, -40),
8823 { { 0, 0xffffffff } },
8827 "ST_MEM_DW: Store/Load double word: max negative",
8829 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
8830 BPF_ST_MEM(BPF_DW
, R10
, -40, 0xffffffff),
8831 BPF_LDX_MEM(BPF_DW
, R0
, R10
, -40),
8836 { { 0, 0xffffffff } },
8840 "ST_MEM_DW: Store/Load double word: max negative 2",
8842 BPF_LD_IMM64(R2
, 0xffff00000000ffffLL
),
8843 BPF_LD_IMM64(R3
, 0xffffffffffffffffLL
),
8844 BPF_ST_MEM(BPF_DW
, R10
, -40, 0xffffffff),
8845 BPF_LDX_MEM(BPF_DW
, R2
, R10
, -40),
8846 BPF_JMP_REG(BPF_JEQ
, R2
, R3
, 2),
8847 BPF_MOV32_IMM(R0
, 2),
8849 BPF_MOV32_IMM(R0
, 1),
8858 "ST_MEM_DW: Store/Load double word: max positive",
8860 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
8861 BPF_ST_MEM(BPF_DW
, R10
, -40, 0x7fffffff),
8862 BPF_LDX_MEM(BPF_DW
, R0
, R10
, -40),
8867 { { 0, 0x7fffffff } },
8871 "STX_MEM_DW: Store/Load double word: max negative",
8873 BPF_LD_IMM64(R0
, 0),
8874 BPF_LD_IMM64(R1
, 0xffffffffffffffffLL
),
8875 BPF_STX_MEM(BPF_DW
, R10
, R1
, -40),
8876 BPF_LDX_MEM(BPF_DW
, R0
, R10
, -40),
8881 { { 0, 0xffffffff } },
8885 "STX_MEM_DW: Store double word: first word in memory",
8887 BPF_LD_IMM64(R0
, 0),
8888 BPF_LD_IMM64(R1
, 0x0123456789abcdefLL
),
8889 BPF_STX_MEM(BPF_DW
, R10
, R1
, -40),
8890 BPF_LDX_MEM(BPF_W
, R0
, R10
, -40),
8896 { { 0, 0x01234567 } },
8898 { { 0, 0x89abcdef } },
8903 "STX_MEM_DW: Store double word: second word in memory",
8905 BPF_LD_IMM64(R0
, 0),
8906 BPF_LD_IMM64(R1
, 0x0123456789abcdefLL
),
8907 BPF_STX_MEM(BPF_DW
, R10
, R1
, -40),
8908 BPF_LDX_MEM(BPF_W
, R0
, R10
, -36),
8914 { { 0, 0x89abcdef } },
8916 { { 0, 0x01234567 } },
8920 /* BPF_STX | BPF_ATOMIC | BPF_W/DW */
8922 "STX_XADD_W: X + 1 + 1 + 1 + ...",
8927 .fill_helper
= bpf_fill_stxw
,
8930 "STX_XADD_DW: X + 1 + 1 + 1 + ...",
8935 .fill_helper
= bpf_fill_stxdw
,
8938 * Exhaustive tests of atomic operation variants.
8939 * Individual tests are expanded from template macros for all
8940 * combinations of ALU operation, word size and fetching.
8942 #define BPF_ATOMIC_POISON(width) ((width) == BPF_W ? (0xbaadf00dULL << 32) : 0)
8944 #define BPF_ATOMIC_OP_TEST1(width, op, logic, old, update, result) \
8946 "BPF_ATOMIC | " #width ", " #op ": Test: " \
8947 #old " " #logic " " #update " = " #result, \
8949 BPF_LD_IMM64(R5, (update) | BPF_ATOMIC_POISON(width)), \
8950 BPF_ST_MEM(width, R10, -40, old), \
8951 BPF_ATOMIC_OP(width, op, R10, R5, -40), \
8952 BPF_LDX_MEM(width, R0, R10, -40), \
8953 BPF_ALU64_REG(BPF_MOV, R1, R0), \
8954 BPF_ALU64_IMM(BPF_RSH, R1, 32), \
8955 BPF_ALU64_REG(BPF_OR, R0, R1), \
8960 { { 0, result } }, \
8961 .stack_depth = 40, \
8963 #define BPF_ATOMIC_OP_TEST2(width, op, logic, old, update, result) \
8965 "BPF_ATOMIC | " #width ", " #op ": Test side effects, r10: " \
8966 #old " " #logic " " #update " = " #result, \
8968 BPF_ALU64_REG(BPF_MOV, R1, R10), \
8969 BPF_LD_IMM64(R0, (update) | BPF_ATOMIC_POISON(width)), \
8970 BPF_ST_MEM(BPF_W, R10, -40, old), \
8971 BPF_ATOMIC_OP(width, op, R10, R0, -40), \
8972 BPF_ALU64_REG(BPF_MOV, R0, R10), \
8973 BPF_ALU64_REG(BPF_SUB, R0, R1), \
8974 BPF_ALU64_REG(BPF_MOV, R1, R0), \
8975 BPF_ALU64_IMM(BPF_RSH, R1, 32), \
8976 BPF_ALU64_REG(BPF_OR, R0, R1), \
8982 .stack_depth = 40, \
8984 #define BPF_ATOMIC_OP_TEST3(width, op, logic, old, update, result) \
8986 "BPF_ATOMIC | " #width ", " #op ": Test side effects, r0: " \
8987 #old " " #logic " " #update " = " #result, \
8989 BPF_ALU64_REG(BPF_MOV, R0, R10), \
8990 BPF_LD_IMM64(R1, (update) | BPF_ATOMIC_POISON(width)), \
8991 BPF_ST_MEM(width, R10, -40, old), \
8992 BPF_ATOMIC_OP(width, op, R10, R1, -40), \
8993 BPF_ALU64_REG(BPF_SUB, R0, R10), \
8994 BPF_ALU64_REG(BPF_MOV, R1, R0), \
8995 BPF_ALU64_IMM(BPF_RSH, R1, 32), \
8996 BPF_ALU64_REG(BPF_OR, R0, R1), \
9002 .stack_depth = 40, \
9004 #define BPF_ATOMIC_OP_TEST4(width, op, logic, old, update, result) \
9006 "BPF_ATOMIC | " #width ", " #op ": Test fetch: " \
9007 #old " " #logic " " #update " = " #result, \
9009 BPF_LD_IMM64(R3, (update) | BPF_ATOMIC_POISON(width)), \
9010 BPF_ST_MEM(width, R10, -40, old), \
9011 BPF_ATOMIC_OP(width, op, R10, R3, -40), \
9012 BPF_ALU32_REG(BPF_MOV, R0, R3), \
9017 { { 0, (op) & BPF_FETCH ? old : update } }, \
9018 .stack_depth = 40, \
9020 /* BPF_ATOMIC | BPF_W: BPF_ADD */
9021 BPF_ATOMIC_OP_TEST1(BPF_W
, BPF_ADD
, +, 0x12, 0xab, 0xbd),
9022 BPF_ATOMIC_OP_TEST2(BPF_W
, BPF_ADD
, +, 0x12, 0xab, 0xbd),
9023 BPF_ATOMIC_OP_TEST3(BPF_W
, BPF_ADD
, +, 0x12, 0xab, 0xbd),
9024 BPF_ATOMIC_OP_TEST4(BPF_W
, BPF_ADD
, +, 0x12, 0xab, 0xbd),
9025 /* BPF_ATOMIC | BPF_W: BPF_ADD | BPF_FETCH */
9026 BPF_ATOMIC_OP_TEST1(BPF_W
, BPF_ADD
| BPF_FETCH
, +, 0x12, 0xab, 0xbd),
9027 BPF_ATOMIC_OP_TEST2(BPF_W
, BPF_ADD
| BPF_FETCH
, +, 0x12, 0xab, 0xbd),
9028 BPF_ATOMIC_OP_TEST3(BPF_W
, BPF_ADD
| BPF_FETCH
, +, 0x12, 0xab, 0xbd),
9029 BPF_ATOMIC_OP_TEST4(BPF_W
, BPF_ADD
| BPF_FETCH
, +, 0x12, 0xab, 0xbd),
9030 /* BPF_ATOMIC | BPF_DW: BPF_ADD */
9031 BPF_ATOMIC_OP_TEST1(BPF_DW
, BPF_ADD
, +, 0x12, 0xab, 0xbd),
9032 BPF_ATOMIC_OP_TEST2(BPF_DW
, BPF_ADD
, +, 0x12, 0xab, 0xbd),
9033 BPF_ATOMIC_OP_TEST3(BPF_DW
, BPF_ADD
, +, 0x12, 0xab, 0xbd),
9034 BPF_ATOMIC_OP_TEST4(BPF_DW
, BPF_ADD
, +, 0x12, 0xab, 0xbd),
9035 /* BPF_ATOMIC | BPF_DW: BPF_ADD | BPF_FETCH */
9036 BPF_ATOMIC_OP_TEST1(BPF_DW
, BPF_ADD
| BPF_FETCH
, +, 0x12, 0xab, 0xbd),
9037 BPF_ATOMIC_OP_TEST2(BPF_DW
, BPF_ADD
| BPF_FETCH
, +, 0x12, 0xab, 0xbd),
9038 BPF_ATOMIC_OP_TEST3(BPF_DW
, BPF_ADD
| BPF_FETCH
, +, 0x12, 0xab, 0xbd),
9039 BPF_ATOMIC_OP_TEST4(BPF_DW
, BPF_ADD
| BPF_FETCH
, +, 0x12, 0xab, 0xbd),
9040 /* BPF_ATOMIC | BPF_W: BPF_AND */
9041 BPF_ATOMIC_OP_TEST1(BPF_W
, BPF_AND
, &, 0x12, 0xab, 0x02),
9042 BPF_ATOMIC_OP_TEST2(BPF_W
, BPF_AND
, &, 0x12, 0xab, 0x02),
9043 BPF_ATOMIC_OP_TEST3(BPF_W
, BPF_AND
, &, 0x12, 0xab, 0x02),
9044 BPF_ATOMIC_OP_TEST4(BPF_W
, BPF_AND
, &, 0x12, 0xab, 0x02),
9045 /* BPF_ATOMIC | BPF_W: BPF_AND | BPF_FETCH */
9046 BPF_ATOMIC_OP_TEST1(BPF_W
, BPF_AND
| BPF_FETCH
, &, 0x12, 0xab, 0x02),
9047 BPF_ATOMIC_OP_TEST2(BPF_W
, BPF_AND
| BPF_FETCH
, &, 0x12, 0xab, 0x02),
9048 BPF_ATOMIC_OP_TEST3(BPF_W
, BPF_AND
| BPF_FETCH
, &, 0x12, 0xab, 0x02),
9049 BPF_ATOMIC_OP_TEST4(BPF_W
, BPF_AND
| BPF_FETCH
, &, 0x12, 0xab, 0x02),
9050 /* BPF_ATOMIC | BPF_DW: BPF_AND */
9051 BPF_ATOMIC_OP_TEST1(BPF_DW
, BPF_AND
, &, 0x12, 0xab, 0x02),
9052 BPF_ATOMIC_OP_TEST2(BPF_DW
, BPF_AND
, &, 0x12, 0xab, 0x02),
9053 BPF_ATOMIC_OP_TEST3(BPF_DW
, BPF_AND
, &, 0x12, 0xab, 0x02),
9054 BPF_ATOMIC_OP_TEST4(BPF_DW
, BPF_AND
, &, 0x12, 0xab, 0x02),
9055 /* BPF_ATOMIC | BPF_DW: BPF_AND | BPF_FETCH */
9056 BPF_ATOMIC_OP_TEST1(BPF_DW
, BPF_AND
| BPF_FETCH
, &, 0x12, 0xab, 0x02),
9057 BPF_ATOMIC_OP_TEST2(BPF_DW
, BPF_AND
| BPF_FETCH
, &, 0x12, 0xab, 0x02),
9058 BPF_ATOMIC_OP_TEST3(BPF_DW
, BPF_AND
| BPF_FETCH
, &, 0x12, 0xab, 0x02),
9059 BPF_ATOMIC_OP_TEST4(BPF_DW
, BPF_AND
| BPF_FETCH
, &, 0x12, 0xab, 0x02),
9060 /* BPF_ATOMIC | BPF_W: BPF_OR */
9061 BPF_ATOMIC_OP_TEST1(BPF_W
, BPF_OR
, |, 0x12, 0xab, 0xbb),
9062 BPF_ATOMIC_OP_TEST2(BPF_W
, BPF_OR
, |, 0x12, 0xab, 0xbb),
9063 BPF_ATOMIC_OP_TEST3(BPF_W
, BPF_OR
, |, 0x12, 0xab, 0xbb),
9064 BPF_ATOMIC_OP_TEST4(BPF_W
, BPF_OR
, |, 0x12, 0xab, 0xbb),
9065 /* BPF_ATOMIC | BPF_W: BPF_OR | BPF_FETCH */
9066 BPF_ATOMIC_OP_TEST1(BPF_W
, BPF_OR
| BPF_FETCH
, |, 0x12, 0xab, 0xbb),
9067 BPF_ATOMIC_OP_TEST2(BPF_W
, BPF_OR
| BPF_FETCH
, |, 0x12, 0xab, 0xbb),
9068 BPF_ATOMIC_OP_TEST3(BPF_W
, BPF_OR
| BPF_FETCH
, |, 0x12, 0xab, 0xbb),
9069 BPF_ATOMIC_OP_TEST4(BPF_W
, BPF_OR
| BPF_FETCH
, |, 0x12, 0xab, 0xbb),
9070 /* BPF_ATOMIC | BPF_DW: BPF_OR */
9071 BPF_ATOMIC_OP_TEST1(BPF_DW
, BPF_OR
, |, 0x12, 0xab, 0xbb),
9072 BPF_ATOMIC_OP_TEST2(BPF_DW
, BPF_OR
, |, 0x12, 0xab, 0xbb),
9073 BPF_ATOMIC_OP_TEST3(BPF_DW
, BPF_OR
, |, 0x12, 0xab, 0xbb),
9074 BPF_ATOMIC_OP_TEST4(BPF_DW
, BPF_OR
, |, 0x12, 0xab, 0xbb),
9075 /* BPF_ATOMIC | BPF_DW: BPF_OR | BPF_FETCH */
9076 BPF_ATOMIC_OP_TEST1(BPF_DW
, BPF_OR
| BPF_FETCH
, |, 0x12, 0xab, 0xbb),
9077 BPF_ATOMIC_OP_TEST2(BPF_DW
, BPF_OR
| BPF_FETCH
, |, 0x12, 0xab, 0xbb),
9078 BPF_ATOMIC_OP_TEST3(BPF_DW
, BPF_OR
| BPF_FETCH
, |, 0x12, 0xab, 0xbb),
9079 BPF_ATOMIC_OP_TEST4(BPF_DW
, BPF_OR
| BPF_FETCH
, |, 0x12, 0xab, 0xbb),
9080 /* BPF_ATOMIC | BPF_W: BPF_XOR */
9081 BPF_ATOMIC_OP_TEST1(BPF_W
, BPF_XOR
, ^, 0x12, 0xab, 0xb9),
9082 BPF_ATOMIC_OP_TEST2(BPF_W
, BPF_XOR
, ^, 0x12, 0xab, 0xb9),
9083 BPF_ATOMIC_OP_TEST3(BPF_W
, BPF_XOR
, ^, 0x12, 0xab, 0xb9),
9084 BPF_ATOMIC_OP_TEST4(BPF_W
, BPF_XOR
, ^, 0x12, 0xab, 0xb9),
9085 /* BPF_ATOMIC | BPF_W: BPF_XOR | BPF_FETCH */
9086 BPF_ATOMIC_OP_TEST1(BPF_W
, BPF_XOR
| BPF_FETCH
, ^, 0x12, 0xab, 0xb9),
9087 BPF_ATOMIC_OP_TEST2(BPF_W
, BPF_XOR
| BPF_FETCH
, ^, 0x12, 0xab, 0xb9),
9088 BPF_ATOMIC_OP_TEST3(BPF_W
, BPF_XOR
| BPF_FETCH
, ^, 0x12, 0xab, 0xb9),
9089 BPF_ATOMIC_OP_TEST4(BPF_W
, BPF_XOR
| BPF_FETCH
, ^, 0x12, 0xab, 0xb9),
9090 /* BPF_ATOMIC | BPF_DW: BPF_XOR */
9091 BPF_ATOMIC_OP_TEST1(BPF_DW
, BPF_XOR
, ^, 0x12, 0xab, 0xb9),
9092 BPF_ATOMIC_OP_TEST2(BPF_DW
, BPF_XOR
, ^, 0x12, 0xab, 0xb9),
9093 BPF_ATOMIC_OP_TEST3(BPF_DW
, BPF_XOR
, ^, 0x12, 0xab, 0xb9),
9094 BPF_ATOMIC_OP_TEST4(BPF_DW
, BPF_XOR
, ^, 0x12, 0xab, 0xb9),
9095 /* BPF_ATOMIC | BPF_DW: BPF_XOR | BPF_FETCH */
9096 BPF_ATOMIC_OP_TEST1(BPF_DW
, BPF_XOR
| BPF_FETCH
, ^, 0x12, 0xab, 0xb9),
9097 BPF_ATOMIC_OP_TEST2(BPF_DW
, BPF_XOR
| BPF_FETCH
, ^, 0x12, 0xab, 0xb9),
9098 BPF_ATOMIC_OP_TEST3(BPF_DW
, BPF_XOR
| BPF_FETCH
, ^, 0x12, 0xab, 0xb9),
9099 BPF_ATOMIC_OP_TEST4(BPF_DW
, BPF_XOR
| BPF_FETCH
, ^, 0x12, 0xab, 0xb9),
9100 /* BPF_ATOMIC | BPF_W: BPF_XCHG */
9101 BPF_ATOMIC_OP_TEST1(BPF_W
, BPF_XCHG
, xchg
, 0x12, 0xab, 0xab),
9102 BPF_ATOMIC_OP_TEST2(BPF_W
, BPF_XCHG
, xchg
, 0x12, 0xab, 0xab),
9103 BPF_ATOMIC_OP_TEST3(BPF_W
, BPF_XCHG
, xchg
, 0x12, 0xab, 0xab),
9104 BPF_ATOMIC_OP_TEST4(BPF_W
, BPF_XCHG
, xchg
, 0x12, 0xab, 0xab),
9105 /* BPF_ATOMIC | BPF_DW: BPF_XCHG */
9106 BPF_ATOMIC_OP_TEST1(BPF_DW
, BPF_XCHG
, xchg
, 0x12, 0xab, 0xab),
9107 BPF_ATOMIC_OP_TEST2(BPF_DW
, BPF_XCHG
, xchg
, 0x12, 0xab, 0xab),
9108 BPF_ATOMIC_OP_TEST3(BPF_DW
, BPF_XCHG
, xchg
, 0x12, 0xab, 0xab),
9109 BPF_ATOMIC_OP_TEST4(BPF_DW
, BPF_XCHG
, xchg
, 0x12, 0xab, 0xab),
9110 #undef BPF_ATOMIC_POISON
9111 #undef BPF_ATOMIC_OP_TEST1
9112 #undef BPF_ATOMIC_OP_TEST2
9113 #undef BPF_ATOMIC_OP_TEST3
9114 #undef BPF_ATOMIC_OP_TEST4
9115 /* BPF_ATOMIC | BPF_W, BPF_CMPXCHG */
9117 "BPF_ATOMIC | BPF_W, BPF_CMPXCHG: Test successful return",
9119 BPF_ST_MEM(BPF_W
, R10
, -40, 0x01234567),
9120 BPF_ALU32_IMM(BPF_MOV
, R0
, 0x01234567),
9121 BPF_ALU32_IMM(BPF_MOV
, R3
, 0x89abcdef),
9122 BPF_ATOMIC_OP(BPF_W
, BPF_CMPXCHG
, R10
, R3
, -40),
9127 { { 0, 0x01234567 } },
9131 "BPF_ATOMIC | BPF_W, BPF_CMPXCHG: Test successful store",
9133 BPF_ST_MEM(BPF_W
, R10
, -40, 0x01234567),
9134 BPF_ALU32_IMM(BPF_MOV
, R0
, 0x01234567),
9135 BPF_ALU32_IMM(BPF_MOV
, R3
, 0x89abcdef),
9136 BPF_ATOMIC_OP(BPF_W
, BPF_CMPXCHG
, R10
, R3
, -40),
9137 BPF_LDX_MEM(BPF_W
, R0
, R10
, -40),
9142 { { 0, 0x89abcdef } },
9146 "BPF_ATOMIC | BPF_W, BPF_CMPXCHG: Test failure return",
9148 BPF_ST_MEM(BPF_W
, R10
, -40, 0x01234567),
9149 BPF_ALU32_IMM(BPF_MOV
, R0
, 0x76543210),
9150 BPF_ALU32_IMM(BPF_MOV
, R3
, 0x89abcdef),
9151 BPF_ATOMIC_OP(BPF_W
, BPF_CMPXCHG
, R10
, R3
, -40),
9156 { { 0, 0x01234567 } },
9160 "BPF_ATOMIC | BPF_W, BPF_CMPXCHG: Test failure store",
9162 BPF_ST_MEM(BPF_W
, R10
, -40, 0x01234567),
9163 BPF_ALU32_IMM(BPF_MOV
, R0
, 0x76543210),
9164 BPF_ALU32_IMM(BPF_MOV
, R3
, 0x89abcdef),
9165 BPF_ATOMIC_OP(BPF_W
, BPF_CMPXCHG
, R10
, R3
, -40),
9166 BPF_LDX_MEM(BPF_W
, R0
, R10
, -40),
9171 { { 0, 0x01234567 } },
9175 "BPF_ATOMIC | BPF_W, BPF_CMPXCHG: Test side effects",
9177 BPF_ST_MEM(BPF_W
, R10
, -40, 0x01234567),
9178 BPF_ALU32_IMM(BPF_MOV
, R0
, 0x01234567),
9179 BPF_ALU32_IMM(BPF_MOV
, R3
, 0x89abcdef),
9180 BPF_ATOMIC_OP(BPF_W
, BPF_CMPXCHG
, R10
, R3
, -40),
9181 BPF_ATOMIC_OP(BPF_W
, BPF_CMPXCHG
, R10
, R3
, -40),
9182 BPF_ALU32_REG(BPF_MOV
, R0
, R3
),
9187 { { 0, 0x89abcdef } },
9190 /* BPF_ATOMIC | BPF_DW, BPF_CMPXCHG */
9192 "BPF_ATOMIC | BPF_DW, BPF_CMPXCHG: Test successful return",
9194 BPF_LD_IMM64(R1
, 0x0123456789abcdefULL
),
9195 BPF_LD_IMM64(R2
, 0xfedcba9876543210ULL
),
9196 BPF_ALU64_REG(BPF_MOV
, R0
, R1
),
9197 BPF_STX_MEM(BPF_DW
, R10
, R1
, -40),
9198 BPF_ATOMIC_OP(BPF_DW
, BPF_CMPXCHG
, R10
, R2
, -40),
9199 BPF_JMP_REG(BPF_JNE
, R0
, R1
, 1),
9200 BPF_ALU64_REG(BPF_SUB
, R0
, R1
),
9209 "BPF_ATOMIC | BPF_DW, BPF_CMPXCHG: Test successful store",
9211 BPF_LD_IMM64(R1
, 0x0123456789abcdefULL
),
9212 BPF_LD_IMM64(R2
, 0xfedcba9876543210ULL
),
9213 BPF_ALU64_REG(BPF_MOV
, R0
, R1
),
9214 BPF_STX_MEM(BPF_DW
, R10
, R0
, -40),
9215 BPF_ATOMIC_OP(BPF_DW
, BPF_CMPXCHG
, R10
, R2
, -40),
9216 BPF_LDX_MEM(BPF_DW
, R0
, R10
, -40),
9217 BPF_JMP_REG(BPF_JNE
, R0
, R2
, 1),
9218 BPF_ALU64_REG(BPF_SUB
, R0
, R2
),
9227 "BPF_ATOMIC | BPF_DW, BPF_CMPXCHG: Test failure return",
9229 BPF_LD_IMM64(R1
, 0x0123456789abcdefULL
),
9230 BPF_LD_IMM64(R2
, 0xfedcba9876543210ULL
),
9231 BPF_ALU64_REG(BPF_MOV
, R0
, R1
),
9232 BPF_ALU64_IMM(BPF_ADD
, R0
, 1),
9233 BPF_STX_MEM(BPF_DW
, R10
, R1
, -40),
9234 BPF_ATOMIC_OP(BPF_DW
, BPF_CMPXCHG
, R10
, R2
, -40),
9235 BPF_JMP_REG(BPF_JNE
, R0
, R1
, 1),
9236 BPF_ALU64_REG(BPF_SUB
, R0
, R1
),
9245 "BPF_ATOMIC | BPF_DW, BPF_CMPXCHG: Test failure store",
9247 BPF_LD_IMM64(R1
, 0x0123456789abcdefULL
),
9248 BPF_LD_IMM64(R2
, 0xfedcba9876543210ULL
),
9249 BPF_ALU64_REG(BPF_MOV
, R0
, R1
),
9250 BPF_ALU64_IMM(BPF_ADD
, R0
, 1),
9251 BPF_STX_MEM(BPF_DW
, R10
, R1
, -40),
9252 BPF_ATOMIC_OP(BPF_DW
, BPF_CMPXCHG
, R10
, R2
, -40),
9253 BPF_LDX_MEM(BPF_DW
, R0
, R10
, -40),
9254 BPF_JMP_REG(BPF_JNE
, R0
, R1
, 1),
9255 BPF_ALU64_REG(BPF_SUB
, R0
, R1
),
9264 "BPF_ATOMIC | BPF_DW, BPF_CMPXCHG: Test side effects",
9266 BPF_LD_IMM64(R1
, 0x0123456789abcdefULL
),
9267 BPF_LD_IMM64(R2
, 0xfedcba9876543210ULL
),
9268 BPF_ALU64_REG(BPF_MOV
, R0
, R1
),
9269 BPF_STX_MEM(BPF_DW
, R10
, R1
, -40),
9270 BPF_ATOMIC_OP(BPF_DW
, BPF_CMPXCHG
, R10
, R2
, -40),
9271 BPF_LD_IMM64(R0
, 0xfedcba9876543210ULL
),
9272 BPF_JMP_REG(BPF_JNE
, R0
, R2
, 1),
9273 BPF_ALU64_REG(BPF_SUB
, R0
, R2
),
9281 /* BPF_JMP32 | BPF_JEQ | BPF_K */
9283 "JMP32_JEQ_K: Small immediate",
9285 BPF_ALU32_IMM(BPF_MOV
, R0
, 123),
9286 BPF_JMP32_IMM(BPF_JEQ
, R0
, 321, 1),
9287 BPF_JMP32_IMM(BPF_JEQ
, R0
, 123, 1),
9288 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
9296 "JMP32_JEQ_K: Large immediate",
9298 BPF_ALU32_IMM(BPF_MOV
, R0
, 12345678),
9299 BPF_JMP32_IMM(BPF_JEQ
, R0
, 12345678 & 0xffff, 1),
9300 BPF_JMP32_IMM(BPF_JEQ
, R0
, 12345678, 1),
9301 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
9309 "JMP32_JEQ_K: negative immediate",
9311 BPF_ALU32_IMM(BPF_MOV
, R0
, -123),
9312 BPF_JMP32_IMM(BPF_JEQ
, R0
, 123, 1),
9313 BPF_JMP32_IMM(BPF_JEQ
, R0
, -123, 1),
9314 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
9321 /* BPF_JMP32 | BPF_JEQ | BPF_X */
9325 BPF_ALU32_IMM(BPF_MOV
, R0
, 1234),
9326 BPF_ALU32_IMM(BPF_MOV
, R1
, 4321),
9327 BPF_JMP32_REG(BPF_JEQ
, R0
, R1
, 2),
9328 BPF_ALU32_IMM(BPF_MOV
, R1
, 1234),
9329 BPF_JMP32_REG(BPF_JEQ
, R0
, R1
, 1),
9330 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
9337 /* BPF_JMP32 | BPF_JNE | BPF_K */
9339 "JMP32_JNE_K: Small immediate",
9341 BPF_ALU32_IMM(BPF_MOV
, R0
, 123),
9342 BPF_JMP32_IMM(BPF_JNE
, R0
, 123, 1),
9343 BPF_JMP32_IMM(BPF_JNE
, R0
, 321, 1),
9344 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
9352 "JMP32_JNE_K: Large immediate",
9354 BPF_ALU32_IMM(BPF_MOV
, R0
, 12345678),
9355 BPF_JMP32_IMM(BPF_JNE
, R0
, 12345678, 1),
9356 BPF_JMP32_IMM(BPF_JNE
, R0
, 12345678 & 0xffff, 1),
9357 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
9365 "JMP32_JNE_K: negative immediate",
9367 BPF_ALU32_IMM(BPF_MOV
, R0
, -123),
9368 BPF_JMP32_IMM(BPF_JNE
, R0
, -123, 1),
9369 BPF_JMP32_IMM(BPF_JNE
, R0
, 123, 1),
9370 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
9377 /* BPF_JMP32 | BPF_JNE | BPF_X */
9381 BPF_ALU32_IMM(BPF_MOV
, R0
, 1234),
9382 BPF_ALU32_IMM(BPF_MOV
, R1
, 1234),
9383 BPF_JMP32_REG(BPF_JNE
, R0
, R1
, 2),
9384 BPF_ALU32_IMM(BPF_MOV
, R1
, 4321),
9385 BPF_JMP32_REG(BPF_JNE
, R0
, R1
, 1),
9386 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
9393 /* BPF_JMP32 | BPF_JSET | BPF_K */
9395 "JMP32_JSET_K: Small immediate",
9397 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
9398 BPF_JMP32_IMM(BPF_JSET
, R0
, 2, 1),
9399 BPF_JMP32_IMM(BPF_JSET
, R0
, 3, 1),
9400 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
9408 "JMP32_JSET_K: Large immediate",
9410 BPF_ALU32_IMM(BPF_MOV
, R0
, 0x40000000),
9411 BPF_JMP32_IMM(BPF_JSET
, R0
, 0x3fffffff, 1),
9412 BPF_JMP32_IMM(BPF_JSET
, R0
, 0x60000000, 1),
9413 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
9418 { { 0, 0x40000000 } }
9421 "JMP32_JSET_K: negative immediate",
9423 BPF_ALU32_IMM(BPF_MOV
, R0
, -123),
9424 BPF_JMP32_IMM(BPF_JSET
, R0
, -1, 1),
9425 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
9432 /* BPF_JMP32 | BPF_JSET | BPF_X */
9436 BPF_ALU32_IMM(BPF_MOV
, R0
, 8),
9437 BPF_ALU32_IMM(BPF_MOV
, R1
, 7),
9438 BPF_JMP32_REG(BPF_JSET
, R0
, R1
, 2),
9439 BPF_ALU32_IMM(BPF_MOV
, R1
, 8 | 2),
9440 BPF_JMP32_REG(BPF_JNE
, R0
, R1
, 1),
9441 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
9448 /* BPF_JMP32 | BPF_JGT | BPF_K */
9450 "JMP32_JGT_K: Small immediate",
9452 BPF_ALU32_IMM(BPF_MOV
, R0
, 123),
9453 BPF_JMP32_IMM(BPF_JGT
, R0
, 123, 1),
9454 BPF_JMP32_IMM(BPF_JGT
, R0
, 122, 1),
9455 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
9463 "JMP32_JGT_K: Large immediate",
9465 BPF_ALU32_IMM(BPF_MOV
, R0
, 0xfffffffe),
9466 BPF_JMP32_IMM(BPF_JGT
, R0
, 0xffffffff, 1),
9467 BPF_JMP32_IMM(BPF_JGT
, R0
, 0xfffffffd, 1),
9468 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
9473 { { 0, 0xfffffffe } }
9475 /* BPF_JMP32 | BPF_JGT | BPF_X */
9479 BPF_ALU32_IMM(BPF_MOV
, R0
, 0xfffffffe),
9480 BPF_ALU32_IMM(BPF_MOV
, R1
, 0xffffffff),
9481 BPF_JMP32_REG(BPF_JGT
, R0
, R1
, 2),
9482 BPF_ALU32_IMM(BPF_MOV
, R1
, 0xfffffffd),
9483 BPF_JMP32_REG(BPF_JGT
, R0
, R1
, 1),
9484 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
9489 { { 0, 0xfffffffe } }
9491 /* BPF_JMP32 | BPF_JGE | BPF_K */
9493 "JMP32_JGE_K: Small immediate",
9495 BPF_ALU32_IMM(BPF_MOV
, R0
, 123),
9496 BPF_JMP32_IMM(BPF_JGE
, R0
, 124, 1),
9497 BPF_JMP32_IMM(BPF_JGE
, R0
, 123, 1),
9498 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
9506 "JMP32_JGE_K: Large immediate",
9508 BPF_ALU32_IMM(BPF_MOV
, R0
, 0xfffffffe),
9509 BPF_JMP32_IMM(BPF_JGE
, R0
, 0xffffffff, 1),
9510 BPF_JMP32_IMM(BPF_JGE
, R0
, 0xfffffffe, 1),
9511 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
9516 { { 0, 0xfffffffe } }
9518 /* BPF_JMP32 | BPF_JGE | BPF_X */
9522 BPF_ALU32_IMM(BPF_MOV
, R0
, 0xfffffffe),
9523 BPF_ALU32_IMM(BPF_MOV
, R1
, 0xffffffff),
9524 BPF_JMP32_REG(BPF_JGE
, R0
, R1
, 2),
9525 BPF_ALU32_IMM(BPF_MOV
, R1
, 0xfffffffe),
9526 BPF_JMP32_REG(BPF_JGE
, R0
, R1
, 1),
9527 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
9532 { { 0, 0xfffffffe } }
9534 /* BPF_JMP32 | BPF_JLT | BPF_K */
9536 "JMP32_JLT_K: Small immediate",
9538 BPF_ALU32_IMM(BPF_MOV
, R0
, 123),
9539 BPF_JMP32_IMM(BPF_JLT
, R0
, 123, 1),
9540 BPF_JMP32_IMM(BPF_JLT
, R0
, 124, 1),
9541 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
9549 "JMP32_JLT_K: Large immediate",
9551 BPF_ALU32_IMM(BPF_MOV
, R0
, 0xfffffffe),
9552 BPF_JMP32_IMM(BPF_JLT
, R0
, 0xfffffffd, 1),
9553 BPF_JMP32_IMM(BPF_JLT
, R0
, 0xffffffff, 1),
9554 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
9559 { { 0, 0xfffffffe } }
9561 /* BPF_JMP32 | BPF_JLT | BPF_X */
9565 BPF_ALU32_IMM(BPF_MOV
, R0
, 0xfffffffe),
9566 BPF_ALU32_IMM(BPF_MOV
, R1
, 0xfffffffd),
9567 BPF_JMP32_REG(BPF_JLT
, R0
, R1
, 2),
9568 BPF_ALU32_IMM(BPF_MOV
, R1
, 0xffffffff),
9569 BPF_JMP32_REG(BPF_JLT
, R0
, R1
, 1),
9570 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
9575 { { 0, 0xfffffffe } }
9577 /* BPF_JMP32 | BPF_JLE | BPF_K */
9579 "JMP32_JLE_K: Small immediate",
9581 BPF_ALU32_IMM(BPF_MOV
, R0
, 123),
9582 BPF_JMP32_IMM(BPF_JLE
, R0
, 122, 1),
9583 BPF_JMP32_IMM(BPF_JLE
, R0
, 123, 1),
9584 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
9592 "JMP32_JLE_K: Large immediate",
9594 BPF_ALU32_IMM(BPF_MOV
, R0
, 0xfffffffe),
9595 BPF_JMP32_IMM(BPF_JLE
, R0
, 0xfffffffd, 1),
9596 BPF_JMP32_IMM(BPF_JLE
, R0
, 0xfffffffe, 1),
9597 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
9602 { { 0, 0xfffffffe } }
9604 /* BPF_JMP32 | BPF_JLE | BPF_X */
9608 BPF_ALU32_IMM(BPF_MOV
, R0
, 0xfffffffe),
9609 BPF_ALU32_IMM(BPF_MOV
, R1
, 0xfffffffd),
9610 BPF_JMP32_REG(BPF_JLE
, R0
, R1
, 2),
9611 BPF_ALU32_IMM(BPF_MOV
, R1
, 0xfffffffe),
9612 BPF_JMP32_REG(BPF_JLE
, R0
, R1
, 1),
9613 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
9618 { { 0, 0xfffffffe } }
9620 /* BPF_JMP32 | BPF_JSGT | BPF_K */
9622 "JMP32_JSGT_K: Small immediate",
9624 BPF_ALU32_IMM(BPF_MOV
, R0
, -123),
9625 BPF_JMP32_IMM(BPF_JSGT
, R0
, -123, 1),
9626 BPF_JMP32_IMM(BPF_JSGT
, R0
, -124, 1),
9627 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
9635 "JMP32_JSGT_K: Large immediate",
9637 BPF_ALU32_IMM(BPF_MOV
, R0
, -12345678),
9638 BPF_JMP32_IMM(BPF_JSGT
, R0
, -12345678, 1),
9639 BPF_JMP32_IMM(BPF_JSGT
, R0
, -12345679, 1),
9640 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
9645 { { 0, -12345678 } }
9647 /* BPF_JMP32 | BPF_JSGT | BPF_X */
9651 BPF_ALU32_IMM(BPF_MOV
, R0
, -12345678),
9652 BPF_ALU32_IMM(BPF_MOV
, R1
, -12345678),
9653 BPF_JMP32_REG(BPF_JSGT
, R0
, R1
, 2),
9654 BPF_ALU32_IMM(BPF_MOV
, R1
, -12345679),
9655 BPF_JMP32_REG(BPF_JSGT
, R0
, R1
, 1),
9656 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
9661 { { 0, -12345678 } }
9663 /* BPF_JMP32 | BPF_JSGE | BPF_K */
9665 "JMP32_JSGE_K: Small immediate",
9667 BPF_ALU32_IMM(BPF_MOV
, R0
, -123),
9668 BPF_JMP32_IMM(BPF_JSGE
, R0
, -122, 1),
9669 BPF_JMP32_IMM(BPF_JSGE
, R0
, -123, 1),
9670 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
9678 "JMP32_JSGE_K: Large immediate",
9680 BPF_ALU32_IMM(BPF_MOV
, R0
, -12345678),
9681 BPF_JMP32_IMM(BPF_JSGE
, R0
, -12345677, 1),
9682 BPF_JMP32_IMM(BPF_JSGE
, R0
, -12345678, 1),
9683 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
9688 { { 0, -12345678 } }
9690 /* BPF_JMP32 | BPF_JSGE | BPF_X */
9694 BPF_ALU32_IMM(BPF_MOV
, R0
, -12345678),
9695 BPF_ALU32_IMM(BPF_MOV
, R1
, -12345677),
9696 BPF_JMP32_REG(BPF_JSGE
, R0
, R1
, 2),
9697 BPF_ALU32_IMM(BPF_MOV
, R1
, -12345678),
9698 BPF_JMP32_REG(BPF_JSGE
, R0
, R1
, 1),
9699 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
9704 { { 0, -12345678 } }
9706 /* BPF_JMP32 | BPF_JSLT | BPF_K */
9708 "JMP32_JSLT_K: Small immediate",
9710 BPF_ALU32_IMM(BPF_MOV
, R0
, -123),
9711 BPF_JMP32_IMM(BPF_JSLT
, R0
, -123, 1),
9712 BPF_JMP32_IMM(BPF_JSLT
, R0
, -122, 1),
9713 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
9721 "JMP32_JSLT_K: Large immediate",
9723 BPF_ALU32_IMM(BPF_MOV
, R0
, -12345678),
9724 BPF_JMP32_IMM(BPF_JSLT
, R0
, -12345678, 1),
9725 BPF_JMP32_IMM(BPF_JSLT
, R0
, -12345677, 1),
9726 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
9731 { { 0, -12345678 } }
9733 /* BPF_JMP32 | BPF_JSLT | BPF_X */
9737 BPF_ALU32_IMM(BPF_MOV
, R0
, -12345678),
9738 BPF_ALU32_IMM(BPF_MOV
, R1
, -12345678),
9739 BPF_JMP32_REG(BPF_JSLT
, R0
, R1
, 2),
9740 BPF_ALU32_IMM(BPF_MOV
, R1
, -12345677),
9741 BPF_JMP32_REG(BPF_JSLT
, R0
, R1
, 1),
9742 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
9747 { { 0, -12345678 } }
9749 /* BPF_JMP32 | BPF_JSLE | BPF_K */
9751 "JMP32_JSLE_K: Small immediate",
9753 BPF_ALU32_IMM(BPF_MOV
, R0
, -123),
9754 BPF_JMP32_IMM(BPF_JSLE
, R0
, -124, 1),
9755 BPF_JMP32_IMM(BPF_JSLE
, R0
, -123, 1),
9756 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
9764 "JMP32_JSLE_K: Large immediate",
9766 BPF_ALU32_IMM(BPF_MOV
, R0
, -12345678),
9767 BPF_JMP32_IMM(BPF_JSLE
, R0
, -12345679, 1),
9768 BPF_JMP32_IMM(BPF_JSLE
, R0
, -12345678, 1),
9769 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
9774 { { 0, -12345678 } }
9776 /* BPF_JMP32 | BPF_JSLE | BPF_K */
9780 BPF_ALU32_IMM(BPF_MOV
, R0
, -12345678),
9781 BPF_ALU32_IMM(BPF_MOV
, R1
, -12345679),
9782 BPF_JMP32_REG(BPF_JSLE
, R0
, R1
, 2),
9783 BPF_ALU32_IMM(BPF_MOV
, R1
, -12345678),
9784 BPF_JMP32_REG(BPF_JSLE
, R0
, R1
, 1),
9785 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
9790 { { 0, -12345678 } }
9792 /* BPF_JMP | BPF_EXIT */
9796 BPF_ALU32_IMM(BPF_MOV
, R0
, 0x4711),
9798 BPF_ALU32_IMM(BPF_MOV
, R0
, 0x4712),
9804 /* BPF_JMP | BPF_JA */
9806 "JMP_JA: Unconditional jump: if (true) return 1",
9808 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
9809 BPF_JMP_IMM(BPF_JA
, 0, 0, 1),
9811 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
9818 /* BPF_JMP32 | BPF_JA */
9820 "JMP32_JA: Unconditional jump: if (true) return 1",
9822 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
9823 BPF_JMP32_IMM(BPF_JA
, 0, 1, 0),
9825 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
9832 /* BPF_JMP | BPF_JSLT | BPF_K */
9834 "JMP_JSLT_K: Signed jump: if (-2 < -1) return 1",
9836 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
9837 BPF_LD_IMM64(R1
, 0xfffffffffffffffeLL
),
9838 BPF_JMP_IMM(BPF_JSLT
, R1
, -1, 1),
9840 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
9848 "JMP_JSLT_K: Signed jump: if (-1 < -1) return 0",
9850 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
9851 BPF_LD_IMM64(R1
, 0xffffffffffffffffLL
),
9852 BPF_JMP_IMM(BPF_JSLT
, R1
, -1, 1),
9854 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
9861 /* BPF_JMP | BPF_JSGT | BPF_K */
9863 "JMP_JSGT_K: Signed jump: if (-1 > -2) return 1",
9865 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
9866 BPF_LD_IMM64(R1
, 0xffffffffffffffffLL
),
9867 BPF_JMP_IMM(BPF_JSGT
, R1
, -2, 1),
9869 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
9877 "JMP_JSGT_K: Signed jump: if (-1 > -1) return 0",
9879 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
9880 BPF_LD_IMM64(R1
, 0xffffffffffffffffLL
),
9881 BPF_JMP_IMM(BPF_JSGT
, R1
, -1, 1),
9883 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
9890 /* BPF_JMP | BPF_JSLE | BPF_K */
9892 "JMP_JSLE_K: Signed jump: if (-2 <= -1) return 1",
9894 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
9895 BPF_LD_IMM64(R1
, 0xfffffffffffffffeLL
),
9896 BPF_JMP_IMM(BPF_JSLE
, R1
, -1, 1),
9898 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
9906 "JMP_JSLE_K: Signed jump: if (-1 <= -1) return 1",
9908 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
9909 BPF_LD_IMM64(R1
, 0xffffffffffffffffLL
),
9910 BPF_JMP_IMM(BPF_JSLE
, R1
, -1, 1),
9912 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
9920 "JMP_JSLE_K: Signed jump: value walk 1",
9922 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
9923 BPF_LD_IMM64(R1
, 3),
9924 BPF_JMP_IMM(BPF_JSLE
, R1
, 0, 6),
9925 BPF_ALU64_IMM(BPF_SUB
, R1
, 1),
9926 BPF_JMP_IMM(BPF_JSLE
, R1
, 0, 4),
9927 BPF_ALU64_IMM(BPF_SUB
, R1
, 1),
9928 BPF_JMP_IMM(BPF_JSLE
, R1
, 0, 2),
9929 BPF_ALU64_IMM(BPF_SUB
, R1
, 1),
9930 BPF_JMP_IMM(BPF_JSLE
, R1
, 0, 1),
9931 BPF_EXIT_INSN(), /* bad exit */
9932 BPF_ALU32_IMM(BPF_MOV
, R0
, 1), /* good exit */
9940 "JMP_JSLE_K: Signed jump: value walk 2",
9942 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
9943 BPF_LD_IMM64(R1
, 3),
9944 BPF_JMP_IMM(BPF_JSLE
, R1
, 0, 4),
9945 BPF_ALU64_IMM(BPF_SUB
, R1
, 2),
9946 BPF_JMP_IMM(BPF_JSLE
, R1
, 0, 2),
9947 BPF_ALU64_IMM(BPF_SUB
, R1
, 2),
9948 BPF_JMP_IMM(BPF_JSLE
, R1
, 0, 1),
9949 BPF_EXIT_INSN(), /* bad exit */
9950 BPF_ALU32_IMM(BPF_MOV
, R0
, 1), /* good exit */
9957 /* BPF_JMP | BPF_JSGE | BPF_K */
9959 "JMP_JSGE_K: Signed jump: if (-1 >= -2) return 1",
9961 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
9962 BPF_LD_IMM64(R1
, 0xffffffffffffffffLL
),
9963 BPF_JMP_IMM(BPF_JSGE
, R1
, -2, 1),
9965 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
9973 "JMP_JSGE_K: Signed jump: if (-1 >= -1) return 1",
9975 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
9976 BPF_LD_IMM64(R1
, 0xffffffffffffffffLL
),
9977 BPF_JMP_IMM(BPF_JSGE
, R1
, -1, 1),
9979 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
9987 "JMP_JSGE_K: Signed jump: value walk 1",
9989 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
9990 BPF_LD_IMM64(R1
, -3),
9991 BPF_JMP_IMM(BPF_JSGE
, R1
, 0, 6),
9992 BPF_ALU64_IMM(BPF_ADD
, R1
, 1),
9993 BPF_JMP_IMM(BPF_JSGE
, R1
, 0, 4),
9994 BPF_ALU64_IMM(BPF_ADD
, R1
, 1),
9995 BPF_JMP_IMM(BPF_JSGE
, R1
, 0, 2),
9996 BPF_ALU64_IMM(BPF_ADD
, R1
, 1),
9997 BPF_JMP_IMM(BPF_JSGE
, R1
, 0, 1),
9998 BPF_EXIT_INSN(), /* bad exit */
9999 BPF_ALU32_IMM(BPF_MOV
, R0
, 1), /* good exit */
10007 "JMP_JSGE_K: Signed jump: value walk 2",
10009 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
10010 BPF_LD_IMM64(R1
, -3),
10011 BPF_JMP_IMM(BPF_JSGE
, R1
, 0, 4),
10012 BPF_ALU64_IMM(BPF_ADD
, R1
, 2),
10013 BPF_JMP_IMM(BPF_JSGE
, R1
, 0, 2),
10014 BPF_ALU64_IMM(BPF_ADD
, R1
, 2),
10015 BPF_JMP_IMM(BPF_JSGE
, R1
, 0, 1),
10016 BPF_EXIT_INSN(), /* bad exit */
10017 BPF_ALU32_IMM(BPF_MOV
, R0
, 1), /* good exit */
10024 /* BPF_JMP | BPF_JGT | BPF_K */
10026 "JMP_JGT_K: if (3 > 2) return 1",
10028 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
10029 BPF_LD_IMM64(R1
, 3),
10030 BPF_JMP_IMM(BPF_JGT
, R1
, 2, 1),
10032 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
10040 "JMP_JGT_K: Unsigned jump: if (-1 > 1) return 1",
10042 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
10043 BPF_LD_IMM64(R1
, -1),
10044 BPF_JMP_IMM(BPF_JGT
, R1
, 1, 1),
10046 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
10053 /* BPF_JMP | BPF_JLT | BPF_K */
10055 "JMP_JLT_K: if (2 < 3) return 1",
10057 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
10058 BPF_LD_IMM64(R1
, 2),
10059 BPF_JMP_IMM(BPF_JLT
, R1
, 3, 1),
10061 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
10069 "JMP_JGT_K: Unsigned jump: if (1 < -1) return 1",
10071 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
10072 BPF_LD_IMM64(R1
, 1),
10073 BPF_JMP_IMM(BPF_JLT
, R1
, -1, 1),
10075 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
10082 /* BPF_JMP | BPF_JGE | BPF_K */
10084 "JMP_JGE_K: if (3 >= 2) return 1",
10086 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
10087 BPF_LD_IMM64(R1
, 3),
10088 BPF_JMP_IMM(BPF_JGE
, R1
, 2, 1),
10090 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
10097 /* BPF_JMP | BPF_JLE | BPF_K */
10099 "JMP_JLE_K: if (2 <= 3) return 1",
10101 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
10102 BPF_LD_IMM64(R1
, 2),
10103 BPF_JMP_IMM(BPF_JLE
, R1
, 3, 1),
10105 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
10112 /* BPF_JMP | BPF_JGT | BPF_K jump backwards */
10114 "JMP_JGT_K: if (3 > 2) return 1 (jump backwards)",
10116 BPF_JMP_IMM(BPF_JA
, 0, 0, 2), /* goto start */
10117 BPF_ALU32_IMM(BPF_MOV
, R0
, 1), /* out: */
10119 BPF_ALU32_IMM(BPF_MOV
, R0
, 0), /* start: */
10120 BPF_LD_IMM64(R1
, 3), /* note: this takes 2 insns */
10121 BPF_JMP_IMM(BPF_JGT
, R1
, 2, -6), /* goto out */
10129 "JMP_JGE_K: if (3 >= 3) return 1",
10131 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
10132 BPF_LD_IMM64(R1
, 3),
10133 BPF_JMP_IMM(BPF_JGE
, R1
, 3, 1),
10135 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
10142 /* BPF_JMP | BPF_JLT | BPF_K jump backwards */
10144 "JMP_JGT_K: if (2 < 3) return 1 (jump backwards)",
10146 BPF_JMP_IMM(BPF_JA
, 0, 0, 2), /* goto start */
10147 BPF_ALU32_IMM(BPF_MOV
, R0
, 1), /* out: */
10149 BPF_ALU32_IMM(BPF_MOV
, R0
, 0), /* start: */
10150 BPF_LD_IMM64(R1
, 2), /* note: this takes 2 insns */
10151 BPF_JMP_IMM(BPF_JLT
, R1
, 3, -6), /* goto out */
10159 "JMP_JLE_K: if (3 <= 3) return 1",
10161 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
10162 BPF_LD_IMM64(R1
, 3),
10163 BPF_JMP_IMM(BPF_JLE
, R1
, 3, 1),
10165 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
10172 /* BPF_JMP | BPF_JNE | BPF_K */
10174 "JMP_JNE_K: if (3 != 2) return 1",
10176 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
10177 BPF_LD_IMM64(R1
, 3),
10178 BPF_JMP_IMM(BPF_JNE
, R1
, 2, 1),
10180 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
10187 /* BPF_JMP | BPF_JEQ | BPF_K */
10189 "JMP_JEQ_K: if (3 == 3) return 1",
10191 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
10192 BPF_LD_IMM64(R1
, 3),
10193 BPF_JMP_IMM(BPF_JEQ
, R1
, 3, 1),
10195 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
10202 /* BPF_JMP | BPF_JSET | BPF_K */
10204 "JMP_JSET_K: if (0x3 & 0x2) return 1",
10206 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
10207 BPF_LD_IMM64(R1
, 3),
10208 BPF_JMP_IMM(BPF_JSET
, R1
, 2, 1),
10210 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
10218 "JMP_JSET_K: if (0x3 & 0xffffffff) return 1",
10220 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
10221 BPF_LD_IMM64(R1
, 3),
10222 BPF_JMP_IMM(BPF_JSET
, R1
, 0xffffffff, 1),
10224 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
10231 /* BPF_JMP | BPF_JSGT | BPF_X */
10233 "JMP_JSGT_X: Signed jump: if (-1 > -2) return 1",
10235 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
10236 BPF_LD_IMM64(R1
, -1),
10237 BPF_LD_IMM64(R2
, -2),
10238 BPF_JMP_REG(BPF_JSGT
, R1
, R2
, 1),
10240 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
10248 "JMP_JSGT_X: Signed jump: if (-1 > -1) return 0",
10250 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
10251 BPF_LD_IMM64(R1
, -1),
10252 BPF_LD_IMM64(R2
, -1),
10253 BPF_JMP_REG(BPF_JSGT
, R1
, R2
, 1),
10255 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
10262 /* BPF_JMP | BPF_JSLT | BPF_X */
10264 "JMP_JSLT_X: Signed jump: if (-2 < -1) return 1",
10266 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
10267 BPF_LD_IMM64(R1
, -1),
10268 BPF_LD_IMM64(R2
, -2),
10269 BPF_JMP_REG(BPF_JSLT
, R2
, R1
, 1),
10271 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
10279 "JMP_JSLT_X: Signed jump: if (-1 < -1) return 0",
10281 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
10282 BPF_LD_IMM64(R1
, -1),
10283 BPF_LD_IMM64(R2
, -1),
10284 BPF_JMP_REG(BPF_JSLT
, R1
, R2
, 1),
10286 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
10293 /* BPF_JMP | BPF_JSGE | BPF_X */
10295 "JMP_JSGE_X: Signed jump: if (-1 >= -2) return 1",
10297 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
10298 BPF_LD_IMM64(R1
, -1),
10299 BPF_LD_IMM64(R2
, -2),
10300 BPF_JMP_REG(BPF_JSGE
, R1
, R2
, 1),
10302 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
10310 "JMP_JSGE_X: Signed jump: if (-1 >= -1) return 1",
10312 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
10313 BPF_LD_IMM64(R1
, -1),
10314 BPF_LD_IMM64(R2
, -1),
10315 BPF_JMP_REG(BPF_JSGE
, R1
, R2
, 1),
10317 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
10324 /* BPF_JMP | BPF_JSLE | BPF_X */
10326 "JMP_JSLE_X: Signed jump: if (-2 <= -1) return 1",
10328 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
10329 BPF_LD_IMM64(R1
, -1),
10330 BPF_LD_IMM64(R2
, -2),
10331 BPF_JMP_REG(BPF_JSLE
, R2
, R1
, 1),
10333 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
10341 "JMP_JSLE_X: Signed jump: if (-1 <= -1) return 1",
10343 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
10344 BPF_LD_IMM64(R1
, -1),
10345 BPF_LD_IMM64(R2
, -1),
10346 BPF_JMP_REG(BPF_JSLE
, R1
, R2
, 1),
10348 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
10355 /* BPF_JMP | BPF_JGT | BPF_X */
10357 "JMP_JGT_X: if (3 > 2) return 1",
10359 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
10360 BPF_LD_IMM64(R1
, 3),
10361 BPF_LD_IMM64(R2
, 2),
10362 BPF_JMP_REG(BPF_JGT
, R1
, R2
, 1),
10364 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
10372 "JMP_JGT_X: Unsigned jump: if (-1 > 1) return 1",
10374 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
10375 BPF_LD_IMM64(R1
, -1),
10376 BPF_LD_IMM64(R2
, 1),
10377 BPF_JMP_REG(BPF_JGT
, R1
, R2
, 1),
10379 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
10386 /* BPF_JMP | BPF_JLT | BPF_X */
10388 "JMP_JLT_X: if (2 < 3) return 1",
10390 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
10391 BPF_LD_IMM64(R1
, 3),
10392 BPF_LD_IMM64(R2
, 2),
10393 BPF_JMP_REG(BPF_JLT
, R2
, R1
, 1),
10395 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
10403 "JMP_JLT_X: Unsigned jump: if (1 < -1) return 1",
10405 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
10406 BPF_LD_IMM64(R1
, -1),
10407 BPF_LD_IMM64(R2
, 1),
10408 BPF_JMP_REG(BPF_JLT
, R2
, R1
, 1),
10410 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
10417 /* BPF_JMP | BPF_JGE | BPF_X */
10419 "JMP_JGE_X: if (3 >= 2) return 1",
10421 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
10422 BPF_LD_IMM64(R1
, 3),
10423 BPF_LD_IMM64(R2
, 2),
10424 BPF_JMP_REG(BPF_JGE
, R1
, R2
, 1),
10426 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
10434 "JMP_JGE_X: if (3 >= 3) return 1",
10436 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
10437 BPF_LD_IMM64(R1
, 3),
10438 BPF_LD_IMM64(R2
, 3),
10439 BPF_JMP_REG(BPF_JGE
, R1
, R2
, 1),
10441 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
10448 /* BPF_JMP | BPF_JLE | BPF_X */
10450 "JMP_JLE_X: if (2 <= 3) return 1",
10452 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
10453 BPF_LD_IMM64(R1
, 3),
10454 BPF_LD_IMM64(R2
, 2),
10455 BPF_JMP_REG(BPF_JLE
, R2
, R1
, 1),
10457 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
10465 "JMP_JLE_X: if (3 <= 3) return 1",
10467 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
10468 BPF_LD_IMM64(R1
, 3),
10469 BPF_LD_IMM64(R2
, 3),
10470 BPF_JMP_REG(BPF_JLE
, R1
, R2
, 1),
10472 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
10480 /* Mainly testing JIT + imm64 here. */
10481 "JMP_JGE_X: ldimm64 test 1",
10483 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
10484 BPF_LD_IMM64(R1
, 3),
10485 BPF_LD_IMM64(R2
, 2),
10486 BPF_JMP_REG(BPF_JGE
, R1
, R2
, 2),
10487 BPF_LD_IMM64(R0
, 0xffffffffffffffffULL
),
10488 BPF_LD_IMM64(R0
, 0xeeeeeeeeeeeeeeeeULL
),
10493 { { 0, 0xeeeeeeeeU
} },
10496 "JMP_JGE_X: ldimm64 test 2",
10498 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
10499 BPF_LD_IMM64(R1
, 3),
10500 BPF_LD_IMM64(R2
, 2),
10501 BPF_JMP_REG(BPF_JGE
, R1
, R2
, 0),
10502 BPF_LD_IMM64(R0
, 0xffffffffffffffffULL
),
10507 { { 0, 0xffffffffU
} },
10510 "JMP_JGE_X: ldimm64 test 3",
10512 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
10513 BPF_LD_IMM64(R1
, 3),
10514 BPF_LD_IMM64(R2
, 2),
10515 BPF_JMP_REG(BPF_JGE
, R1
, R2
, 4),
10516 BPF_LD_IMM64(R0
, 0xffffffffffffffffULL
),
10517 BPF_LD_IMM64(R0
, 0xeeeeeeeeeeeeeeeeULL
),
10525 "JMP_JLE_X: ldimm64 test 1",
10527 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
10528 BPF_LD_IMM64(R1
, 3),
10529 BPF_LD_IMM64(R2
, 2),
10530 BPF_JMP_REG(BPF_JLE
, R2
, R1
, 2),
10531 BPF_LD_IMM64(R0
, 0xffffffffffffffffULL
),
10532 BPF_LD_IMM64(R0
, 0xeeeeeeeeeeeeeeeeULL
),
10537 { { 0, 0xeeeeeeeeU
} },
10540 "JMP_JLE_X: ldimm64 test 2",
10542 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
10543 BPF_LD_IMM64(R1
, 3),
10544 BPF_LD_IMM64(R2
, 2),
10545 BPF_JMP_REG(BPF_JLE
, R2
, R1
, 0),
10546 BPF_LD_IMM64(R0
, 0xffffffffffffffffULL
),
10551 { { 0, 0xffffffffU
} },
10554 "JMP_JLE_X: ldimm64 test 3",
10556 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
10557 BPF_LD_IMM64(R1
, 3),
10558 BPF_LD_IMM64(R2
, 2),
10559 BPF_JMP_REG(BPF_JLE
, R2
, R1
, 4),
10560 BPF_LD_IMM64(R0
, 0xffffffffffffffffULL
),
10561 BPF_LD_IMM64(R0
, 0xeeeeeeeeeeeeeeeeULL
),
10568 /* BPF_JMP | BPF_JNE | BPF_X */
10570 "JMP_JNE_X: if (3 != 2) return 1",
10572 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
10573 BPF_LD_IMM64(R1
, 3),
10574 BPF_LD_IMM64(R2
, 2),
10575 BPF_JMP_REG(BPF_JNE
, R1
, R2
, 1),
10577 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
10584 /* BPF_JMP | BPF_JEQ | BPF_X */
10586 "JMP_JEQ_X: if (3 == 3) return 1",
10588 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
10589 BPF_LD_IMM64(R1
, 3),
10590 BPF_LD_IMM64(R2
, 3),
10591 BPF_JMP_REG(BPF_JEQ
, R1
, R2
, 1),
10593 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
10600 /* BPF_JMP | BPF_JSET | BPF_X */
10602 "JMP_JSET_X: if (0x3 & 0x2) return 1",
10604 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
10605 BPF_LD_IMM64(R1
, 3),
10606 BPF_LD_IMM64(R2
, 2),
10607 BPF_JMP_REG(BPF_JSET
, R1
, R2
, 1),
10609 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
10617 "JMP_JSET_X: if (0x3 & 0xffffffff) return 1",
10619 BPF_ALU32_IMM(BPF_MOV
, R0
, 0),
10620 BPF_LD_IMM64(R1
, 3),
10621 BPF_LD_IMM64(R2
, 0xffffffff),
10622 BPF_JMP_REG(BPF_JSET
, R1
, R2
, 1),
10624 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
10632 "JMP_JA: Jump, gap, jump, ...",
10634 CLASSIC
| FLAG_NO_DATA
,
10636 { { 0, 0xababcbac } },
10637 .fill_helper
= bpf_fill_ja
,
10639 { /* Mainly checking JIT here. */
10640 "BPF_MAXINSNS: Maximum possible literals",
10642 CLASSIC
| FLAG_NO_DATA
,
10644 { { 0, 0xffffffff } },
10645 .fill_helper
= bpf_fill_maxinsns1
,
10647 { /* Mainly checking JIT here. */
10648 "BPF_MAXINSNS: Single literal",
10650 CLASSIC
| FLAG_NO_DATA
,
10652 { { 0, 0xfefefefe } },
10653 .fill_helper
= bpf_fill_maxinsns2
,
10655 { /* Mainly checking JIT here. */
10656 "BPF_MAXINSNS: Run/add until end",
10658 CLASSIC
| FLAG_NO_DATA
,
10660 { { 0, 0x947bf368 } },
10661 .fill_helper
= bpf_fill_maxinsns3
,
10664 "BPF_MAXINSNS: Too many instructions",
10666 CLASSIC
| FLAG_NO_DATA
| FLAG_EXPECTED_FAIL
,
10669 .fill_helper
= bpf_fill_maxinsns4
,
10670 .expected_errcode
= -EINVAL
,
10672 { /* Mainly checking JIT here. */
10673 "BPF_MAXINSNS: Very long jump",
10675 CLASSIC
| FLAG_NO_DATA
,
10677 { { 0, 0xabababab } },
10678 .fill_helper
= bpf_fill_maxinsns5
,
10680 { /* Mainly checking JIT here. */
10681 "BPF_MAXINSNS: Ctx heavy transformations",
10686 { 1, SKB_VLAN_PRESENT
},
10687 { 10, SKB_VLAN_PRESENT
}
10689 .fill_helper
= bpf_fill_maxinsns6
,
10691 { /* Mainly checking JIT here. */
10692 "BPF_MAXINSNS: Call heavy transformations",
10694 CLASSIC
| FLAG_NO_DATA
,
10696 { { 1, 0 }, { 10, 0 } },
10697 .fill_helper
= bpf_fill_maxinsns7
,
10699 { /* Mainly checking JIT here. */
10700 "BPF_MAXINSNS: Jump heavy test",
10702 CLASSIC
| FLAG_NO_DATA
,
10704 { { 0, 0xffffffff } },
10705 .fill_helper
= bpf_fill_maxinsns8
,
10707 { /* Mainly checking JIT here. */
10708 "BPF_MAXINSNS: Very long jump backwards",
10710 INTERNAL
| FLAG_NO_DATA
,
10712 { { 0, 0xcbababab } },
10713 .fill_helper
= bpf_fill_maxinsns9
,
10715 { /* Mainly checking JIT here. */
10716 "BPF_MAXINSNS: Edge hopping nuthouse",
10718 INTERNAL
| FLAG_NO_DATA
,
10720 { { 0, 0xabababac } },
10721 .fill_helper
= bpf_fill_maxinsns10
,
10724 "BPF_MAXINSNS: Jump, gap, jump, ...",
10726 CLASSIC
| FLAG_NO_DATA
,
10728 { { 0, 0xababcbac } },
10729 .fill_helper
= bpf_fill_maxinsns11
,
10732 "BPF_MAXINSNS: jump over MSH",
10734 CLASSIC
| FLAG_EXPECTED_FAIL
,
10735 { 0xfa, 0xfb, 0xfc, 0xfd, },
10736 { { 4, 0xabababab } },
10737 .fill_helper
= bpf_fill_maxinsns12
,
10738 .expected_errcode
= -EINVAL
,
10741 "BPF_MAXINSNS: exec all MSH",
10744 { 0xfa, 0xfb, 0xfc, 0xfd, },
10745 { { 4, 0xababab83 } },
10746 .fill_helper
= bpf_fill_maxinsns13
,
10749 "BPF_MAXINSNS: ld_abs+get_processor_id",
10754 .fill_helper
= bpf_fill_ld_abs_get_processor_id
,
10757 * LD_IND / LD_ABS on fragmented SKBs
10760 "LD_IND byte frag",
10762 BPF_STMT(BPF_LDX
| BPF_IMM
, 0x40),
10763 BPF_STMT(BPF_LD
| BPF_IND
| BPF_B
, 0x0),
10764 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
10766 CLASSIC
| FLAG_SKB_FRAG
,
10770 0x42, 0x00, 0x00, 0x00,
10771 0x43, 0x44, 0x00, 0x00,
10772 0x21, 0x07, 0x19, 0x83,
10776 "LD_IND halfword frag",
10778 BPF_STMT(BPF_LDX
| BPF_IMM
, 0x40),
10779 BPF_STMT(BPF_LD
| BPF_IND
| BPF_H
, 0x4),
10780 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
10782 CLASSIC
| FLAG_SKB_FRAG
,
10784 { {0x40, 0x4344} },
10786 0x42, 0x00, 0x00, 0x00,
10787 0x43, 0x44, 0x00, 0x00,
10788 0x21, 0x07, 0x19, 0x83,
10792 "LD_IND word frag",
10794 BPF_STMT(BPF_LDX
| BPF_IMM
, 0x40),
10795 BPF_STMT(BPF_LD
| BPF_IND
| BPF_W
, 0x8),
10796 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
10798 CLASSIC
| FLAG_SKB_FRAG
,
10800 { {0x40, 0x21071983} },
10802 0x42, 0x00, 0x00, 0x00,
10803 0x43, 0x44, 0x00, 0x00,
10804 0x21, 0x07, 0x19, 0x83,
10808 "LD_IND halfword mixed head/frag",
10810 BPF_STMT(BPF_LDX
| BPF_IMM
, 0x40),
10811 BPF_STMT(BPF_LD
| BPF_IND
| BPF_H
, -0x1),
10812 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
10814 CLASSIC
| FLAG_SKB_FRAG
,
10815 { [0x3e] = 0x25, [0x3f] = 0x05, },
10816 { {0x40, 0x0519} },
10817 .frag_data
= { 0x19, 0x82 },
10820 "LD_IND word mixed head/frag",
10822 BPF_STMT(BPF_LDX
| BPF_IMM
, 0x40),
10823 BPF_STMT(BPF_LD
| BPF_IND
| BPF_W
, -0x2),
10824 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
10826 CLASSIC
| FLAG_SKB_FRAG
,
10827 { [0x3e] = 0x25, [0x3f] = 0x05, },
10828 { {0x40, 0x25051982} },
10829 .frag_data
= { 0x19, 0x82 },
10832 "LD_ABS byte frag",
10834 BPF_STMT(BPF_LD
| BPF_ABS
| BPF_B
, 0x40),
10835 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
10837 CLASSIC
| FLAG_SKB_FRAG
,
10841 0x42, 0x00, 0x00, 0x00,
10842 0x43, 0x44, 0x00, 0x00,
10843 0x21, 0x07, 0x19, 0x83,
10847 "LD_ABS halfword frag",
10849 BPF_STMT(BPF_LD
| BPF_ABS
| BPF_H
, 0x44),
10850 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
10852 CLASSIC
| FLAG_SKB_FRAG
,
10854 { {0x40, 0x4344} },
10856 0x42, 0x00, 0x00, 0x00,
10857 0x43, 0x44, 0x00, 0x00,
10858 0x21, 0x07, 0x19, 0x83,
10862 "LD_ABS word frag",
10864 BPF_STMT(BPF_LD
| BPF_ABS
| BPF_W
, 0x48),
10865 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
10867 CLASSIC
| FLAG_SKB_FRAG
,
10869 { {0x40, 0x21071983} },
10871 0x42, 0x00, 0x00, 0x00,
10872 0x43, 0x44, 0x00, 0x00,
10873 0x21, 0x07, 0x19, 0x83,
10877 "LD_ABS halfword mixed head/frag",
10879 BPF_STMT(BPF_LD
| BPF_ABS
| BPF_H
, 0x3f),
10880 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
10882 CLASSIC
| FLAG_SKB_FRAG
,
10883 { [0x3e] = 0x25, [0x3f] = 0x05, },
10884 { {0x40, 0x0519} },
10885 .frag_data
= { 0x19, 0x82 },
10888 "LD_ABS word mixed head/frag",
10890 BPF_STMT(BPF_LD
| BPF_ABS
| BPF_W
, 0x3e),
10891 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
10893 CLASSIC
| FLAG_SKB_FRAG
,
10894 { [0x3e] = 0x25, [0x3f] = 0x05, },
10895 { {0x40, 0x25051982} },
10896 .frag_data
= { 0x19, 0x82 },
10899 * LD_IND / LD_ABS on non fragmented SKBs
10903 * this tests that the JIT/interpreter correctly resets X
10904 * before using it in an LD_IND instruction.
10906 "LD_IND byte default X",
10908 BPF_STMT(BPF_LD
| BPF_IND
| BPF_B
, 0x1),
10909 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
10916 "LD_IND byte positive offset",
10918 BPF_STMT(BPF_LDX
| BPF_IMM
, 0x3e),
10919 BPF_STMT(BPF_LD
| BPF_IND
| BPF_B
, 0x1),
10920 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
10923 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
10927 "LD_IND byte negative offset",
10929 BPF_STMT(BPF_LDX
| BPF_IMM
, 0x3e),
10930 BPF_STMT(BPF_LD
| BPF_IND
| BPF_B
, -0x1),
10931 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
10934 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
10938 "LD_IND byte positive offset, all ff",
10940 BPF_STMT(BPF_LDX
| BPF_IMM
, 0x3e),
10941 BPF_STMT(BPF_LD
| BPF_IND
| BPF_B
, 0x1),
10942 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
10945 { [0x3c] = 0xff, [0x3d] = 0xff, [0x3e] = 0xff, [0x3f] = 0xff },
10949 "LD_IND byte positive offset, out of bounds",
10951 BPF_STMT(BPF_LDX
| BPF_IMM
, 0x3e),
10952 BPF_STMT(BPF_LD
| BPF_IND
| BPF_B
, 0x1),
10953 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
10956 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
10960 "LD_IND byte negative offset, out of bounds",
10962 BPF_STMT(BPF_LDX
| BPF_IMM
, 0x3e),
10963 BPF_STMT(BPF_LD
| BPF_IND
| BPF_B
, -0x3f),
10964 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
10967 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
10971 "LD_IND byte negative offset, multiple calls",
10973 BPF_STMT(BPF_LDX
| BPF_IMM
, 0x3b),
10974 BPF_STMT(BPF_LD
| BPF_IND
| BPF_B
, SKF_LL_OFF
+ 1),
10975 BPF_STMT(BPF_LD
| BPF_IND
| BPF_B
, SKF_LL_OFF
+ 2),
10976 BPF_STMT(BPF_LD
| BPF_IND
| BPF_B
, SKF_LL_OFF
+ 3),
10977 BPF_STMT(BPF_LD
| BPF_IND
| BPF_B
, SKF_LL_OFF
+ 4),
10978 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
10981 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
10982 { {0x40, 0x82 }, },
10985 "LD_IND halfword positive offset",
10987 BPF_STMT(BPF_LDX
| BPF_IMM
, 0x20),
10988 BPF_STMT(BPF_LD
| BPF_IND
| BPF_H
, 0x2),
10989 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
10993 [0x1c] = 0xaa, [0x1d] = 0x55,
10994 [0x1e] = 0xbb, [0x1f] = 0x66,
10995 [0x20] = 0xcc, [0x21] = 0x77,
10996 [0x22] = 0xdd, [0x23] = 0x88,
10998 { {0x40, 0xdd88 } },
11001 "LD_IND halfword negative offset",
11003 BPF_STMT(BPF_LDX
| BPF_IMM
, 0x20),
11004 BPF_STMT(BPF_LD
| BPF_IND
| BPF_H
, -0x2),
11005 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
11009 [0x1c] = 0xaa, [0x1d] = 0x55,
11010 [0x1e] = 0xbb, [0x1f] = 0x66,
11011 [0x20] = 0xcc, [0x21] = 0x77,
11012 [0x22] = 0xdd, [0x23] = 0x88,
11014 { {0x40, 0xbb66 } },
11017 "LD_IND halfword unaligned",
11019 BPF_STMT(BPF_LDX
| BPF_IMM
, 0x20),
11020 BPF_STMT(BPF_LD
| BPF_IND
| BPF_H
, -0x1),
11021 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
11025 [0x1c] = 0xaa, [0x1d] = 0x55,
11026 [0x1e] = 0xbb, [0x1f] = 0x66,
11027 [0x20] = 0xcc, [0x21] = 0x77,
11028 [0x22] = 0xdd, [0x23] = 0x88,
11030 { {0x40, 0x66cc } },
11033 "LD_IND halfword positive offset, all ff",
11035 BPF_STMT(BPF_LDX
| BPF_IMM
, 0x3d),
11036 BPF_STMT(BPF_LD
| BPF_IND
| BPF_H
, 0x1),
11037 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
11040 { [0x3c] = 0xff, [0x3d] = 0xff, [0x3e] = 0xff, [0x3f] = 0xff },
11041 { {0x40, 0xffff } },
11044 "LD_IND halfword positive offset, out of bounds",
11046 BPF_STMT(BPF_LDX
| BPF_IMM
, 0x3e),
11047 BPF_STMT(BPF_LD
| BPF_IND
| BPF_H
, 0x1),
11048 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
11051 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
11055 "LD_IND halfword negative offset, out of bounds",
11057 BPF_STMT(BPF_LDX
| BPF_IMM
, 0x3e),
11058 BPF_STMT(BPF_LD
| BPF_IND
| BPF_H
, -0x3f),
11059 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
11062 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
11066 "LD_IND word positive offset",
11068 BPF_STMT(BPF_LDX
| BPF_IMM
, 0x20),
11069 BPF_STMT(BPF_LD
| BPF_IND
| BPF_W
, 0x4),
11070 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
11074 [0x1c] = 0xaa, [0x1d] = 0x55,
11075 [0x1e] = 0xbb, [0x1f] = 0x66,
11076 [0x20] = 0xcc, [0x21] = 0x77,
11077 [0x22] = 0xdd, [0x23] = 0x88,
11078 [0x24] = 0xee, [0x25] = 0x99,
11079 [0x26] = 0xff, [0x27] = 0xaa,
11081 { {0x40, 0xee99ffaa } },
11084 "LD_IND word negative offset",
11086 BPF_STMT(BPF_LDX
| BPF_IMM
, 0x20),
11087 BPF_STMT(BPF_LD
| BPF_IND
| BPF_W
, -0x4),
11088 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
11092 [0x1c] = 0xaa, [0x1d] = 0x55,
11093 [0x1e] = 0xbb, [0x1f] = 0x66,
11094 [0x20] = 0xcc, [0x21] = 0x77,
11095 [0x22] = 0xdd, [0x23] = 0x88,
11096 [0x24] = 0xee, [0x25] = 0x99,
11097 [0x26] = 0xff, [0x27] = 0xaa,
11099 { {0x40, 0xaa55bb66 } },
11102 "LD_IND word unaligned (addr & 3 == 2)",
11104 BPF_STMT(BPF_LDX
| BPF_IMM
, 0x20),
11105 BPF_STMT(BPF_LD
| BPF_IND
| BPF_W
, -0x2),
11106 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
11110 [0x1c] = 0xaa, [0x1d] = 0x55,
11111 [0x1e] = 0xbb, [0x1f] = 0x66,
11112 [0x20] = 0xcc, [0x21] = 0x77,
11113 [0x22] = 0xdd, [0x23] = 0x88,
11114 [0x24] = 0xee, [0x25] = 0x99,
11115 [0x26] = 0xff, [0x27] = 0xaa,
11117 { {0x40, 0xbb66cc77 } },
11120 "LD_IND word unaligned (addr & 3 == 1)",
11122 BPF_STMT(BPF_LDX
| BPF_IMM
, 0x20),
11123 BPF_STMT(BPF_LD
| BPF_IND
| BPF_W
, -0x3),
11124 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
11128 [0x1c] = 0xaa, [0x1d] = 0x55,
11129 [0x1e] = 0xbb, [0x1f] = 0x66,
11130 [0x20] = 0xcc, [0x21] = 0x77,
11131 [0x22] = 0xdd, [0x23] = 0x88,
11132 [0x24] = 0xee, [0x25] = 0x99,
11133 [0x26] = 0xff, [0x27] = 0xaa,
11135 { {0x40, 0x55bb66cc } },
11138 "LD_IND word unaligned (addr & 3 == 3)",
11140 BPF_STMT(BPF_LDX
| BPF_IMM
, 0x20),
11141 BPF_STMT(BPF_LD
| BPF_IND
| BPF_W
, -0x1),
11142 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
11146 [0x1c] = 0xaa, [0x1d] = 0x55,
11147 [0x1e] = 0xbb, [0x1f] = 0x66,
11148 [0x20] = 0xcc, [0x21] = 0x77,
11149 [0x22] = 0xdd, [0x23] = 0x88,
11150 [0x24] = 0xee, [0x25] = 0x99,
11151 [0x26] = 0xff, [0x27] = 0xaa,
11153 { {0x40, 0x66cc77dd } },
11156 "LD_IND word positive offset, all ff",
11158 BPF_STMT(BPF_LDX
| BPF_IMM
, 0x3b),
11159 BPF_STMT(BPF_LD
| BPF_IND
| BPF_W
, 0x1),
11160 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
11163 { [0x3c] = 0xff, [0x3d] = 0xff, [0x3e] = 0xff, [0x3f] = 0xff },
11164 { {0x40, 0xffffffff } },
11167 "LD_IND word positive offset, out of bounds",
11169 BPF_STMT(BPF_LDX
| BPF_IMM
, 0x3e),
11170 BPF_STMT(BPF_LD
| BPF_IND
| BPF_W
, 0x1),
11171 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
11174 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
11178 "LD_IND word negative offset, out of bounds",
11180 BPF_STMT(BPF_LDX
| BPF_IMM
, 0x3e),
11181 BPF_STMT(BPF_LD
| BPF_IND
| BPF_W
, -0x3f),
11182 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
11185 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
11191 BPF_STMT(BPF_LD
| BPF_ABS
| BPF_B
, 0x20),
11192 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
11196 [0x1c] = 0xaa, [0x1d] = 0x55,
11197 [0x1e] = 0xbb, [0x1f] = 0x66,
11198 [0x20] = 0xcc, [0x21] = 0x77,
11199 [0x22] = 0xdd, [0x23] = 0x88,
11200 [0x24] = 0xee, [0x25] = 0x99,
11201 [0x26] = 0xff, [0x27] = 0xaa,
11206 "LD_ABS byte positive offset, all ff",
11208 BPF_STMT(BPF_LD
| BPF_ABS
| BPF_B
, 0x3f),
11209 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
11212 { [0x3c] = 0xff, [0x3d] = 0xff, [0x3e] = 0xff, [0x3f] = 0xff },
11216 "LD_ABS byte positive offset, out of bounds",
11218 BPF_STMT(BPF_LD
| BPF_ABS
| BPF_B
, 0x3f),
11219 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
11222 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
11226 "LD_ABS byte negative offset, out of bounds load",
11228 BPF_STMT(BPF_LD
| BPF_ABS
| BPF_B
, -1),
11229 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
11231 CLASSIC
| FLAG_EXPECTED_FAIL
,
11232 .expected_errcode
= -EINVAL
,
11235 "LD_ABS byte negative offset, in bounds",
11237 BPF_STMT(BPF_LD
| BPF_ABS
| BPF_B
, SKF_LL_OFF
+ 0x3f),
11238 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
11241 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
11242 { {0x40, 0x82 }, },
11245 "LD_ABS byte negative offset, out of bounds",
11247 BPF_STMT(BPF_LD
| BPF_ABS
| BPF_B
, SKF_LL_OFF
+ 0x3f),
11248 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
11251 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
11255 "LD_ABS byte negative offset, multiple calls",
11257 BPF_STMT(BPF_LD
| BPF_ABS
| BPF_B
, SKF_LL_OFF
+ 0x3c),
11258 BPF_STMT(BPF_LD
| BPF_ABS
| BPF_B
, SKF_LL_OFF
+ 0x3d),
11259 BPF_STMT(BPF_LD
| BPF_ABS
| BPF_B
, SKF_LL_OFF
+ 0x3e),
11260 BPF_STMT(BPF_LD
| BPF_ABS
| BPF_B
, SKF_LL_OFF
+ 0x3f),
11261 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
11264 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
11265 { {0x40, 0x82 }, },
11270 BPF_STMT(BPF_LD
| BPF_ABS
| BPF_H
, 0x22),
11271 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
11275 [0x1c] = 0xaa, [0x1d] = 0x55,
11276 [0x1e] = 0xbb, [0x1f] = 0x66,
11277 [0x20] = 0xcc, [0x21] = 0x77,
11278 [0x22] = 0xdd, [0x23] = 0x88,
11279 [0x24] = 0xee, [0x25] = 0x99,
11280 [0x26] = 0xff, [0x27] = 0xaa,
11282 { {0x40, 0xdd88 } },
11285 "LD_ABS halfword unaligned",
11287 BPF_STMT(BPF_LD
| BPF_ABS
| BPF_H
, 0x25),
11288 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
11292 [0x1c] = 0xaa, [0x1d] = 0x55,
11293 [0x1e] = 0xbb, [0x1f] = 0x66,
11294 [0x20] = 0xcc, [0x21] = 0x77,
11295 [0x22] = 0xdd, [0x23] = 0x88,
11296 [0x24] = 0xee, [0x25] = 0x99,
11297 [0x26] = 0xff, [0x27] = 0xaa,
11299 { {0x40, 0x99ff } },
11302 "LD_ABS halfword positive offset, all ff",
11304 BPF_STMT(BPF_LD
| BPF_ABS
| BPF_H
, 0x3e),
11305 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
11308 { [0x3c] = 0xff, [0x3d] = 0xff, [0x3e] = 0xff, [0x3f] = 0xff },
11309 { {0x40, 0xffff } },
11312 "LD_ABS halfword positive offset, out of bounds",
11314 BPF_STMT(BPF_LD
| BPF_ABS
| BPF_H
, 0x3f),
11315 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
11318 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
11322 "LD_ABS halfword negative offset, out of bounds load",
11324 BPF_STMT(BPF_LD
| BPF_ABS
| BPF_H
, -1),
11325 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
11327 CLASSIC
| FLAG_EXPECTED_FAIL
,
11328 .expected_errcode
= -EINVAL
,
11331 "LD_ABS halfword negative offset, in bounds",
11333 BPF_STMT(BPF_LD
| BPF_ABS
| BPF_H
, SKF_LL_OFF
+ 0x3e),
11334 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
11337 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
11338 { {0x40, 0x1982 }, },
11341 "LD_ABS halfword negative offset, out of bounds",
11343 BPF_STMT(BPF_LD
| BPF_ABS
| BPF_H
, SKF_LL_OFF
+ 0x3e),
11344 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
11347 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
11353 BPF_STMT(BPF_LD
| BPF_ABS
| BPF_W
, 0x1c),
11354 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
11358 [0x1c] = 0xaa, [0x1d] = 0x55,
11359 [0x1e] = 0xbb, [0x1f] = 0x66,
11360 [0x20] = 0xcc, [0x21] = 0x77,
11361 [0x22] = 0xdd, [0x23] = 0x88,
11362 [0x24] = 0xee, [0x25] = 0x99,
11363 [0x26] = 0xff, [0x27] = 0xaa,
11365 { {0x40, 0xaa55bb66 } },
11368 "LD_ABS word unaligned (addr & 3 == 2)",
11370 BPF_STMT(BPF_LD
| BPF_ABS
| BPF_W
, 0x22),
11371 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
11375 [0x1c] = 0xaa, [0x1d] = 0x55,
11376 [0x1e] = 0xbb, [0x1f] = 0x66,
11377 [0x20] = 0xcc, [0x21] = 0x77,
11378 [0x22] = 0xdd, [0x23] = 0x88,
11379 [0x24] = 0xee, [0x25] = 0x99,
11380 [0x26] = 0xff, [0x27] = 0xaa,
11382 { {0x40, 0xdd88ee99 } },
11385 "LD_ABS word unaligned (addr & 3 == 1)",
11387 BPF_STMT(BPF_LD
| BPF_ABS
| BPF_W
, 0x21),
11388 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
11392 [0x1c] = 0xaa, [0x1d] = 0x55,
11393 [0x1e] = 0xbb, [0x1f] = 0x66,
11394 [0x20] = 0xcc, [0x21] = 0x77,
11395 [0x22] = 0xdd, [0x23] = 0x88,
11396 [0x24] = 0xee, [0x25] = 0x99,
11397 [0x26] = 0xff, [0x27] = 0xaa,
11399 { {0x40, 0x77dd88ee } },
11402 "LD_ABS word unaligned (addr & 3 == 3)",
11404 BPF_STMT(BPF_LD
| BPF_ABS
| BPF_W
, 0x23),
11405 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
11409 [0x1c] = 0xaa, [0x1d] = 0x55,
11410 [0x1e] = 0xbb, [0x1f] = 0x66,
11411 [0x20] = 0xcc, [0x21] = 0x77,
11412 [0x22] = 0xdd, [0x23] = 0x88,
11413 [0x24] = 0xee, [0x25] = 0x99,
11414 [0x26] = 0xff, [0x27] = 0xaa,
11416 { {0x40, 0x88ee99ff } },
11419 "LD_ABS word positive offset, all ff",
11421 BPF_STMT(BPF_LD
| BPF_ABS
| BPF_W
, 0x3c),
11422 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
11425 { [0x3c] = 0xff, [0x3d] = 0xff, [0x3e] = 0xff, [0x3f] = 0xff },
11426 { {0x40, 0xffffffff } },
11429 "LD_ABS word positive offset, out of bounds",
11431 BPF_STMT(BPF_LD
| BPF_ABS
| BPF_W
, 0x3f),
11432 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
11435 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
11439 "LD_ABS word negative offset, out of bounds load",
11441 BPF_STMT(BPF_LD
| BPF_ABS
| BPF_W
, -1),
11442 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
11444 CLASSIC
| FLAG_EXPECTED_FAIL
,
11445 .expected_errcode
= -EINVAL
,
11448 "LD_ABS word negative offset, in bounds",
11450 BPF_STMT(BPF_LD
| BPF_ABS
| BPF_W
, SKF_LL_OFF
+ 0x3c),
11451 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
11454 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
11455 { {0x40, 0x25051982 }, },
11458 "LD_ABS word negative offset, out of bounds",
11460 BPF_STMT(BPF_LD
| BPF_ABS
| BPF_W
, SKF_LL_OFF
+ 0x3c),
11461 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
11464 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
11468 "LDX_MSH standalone, preserved A",
11470 BPF_STMT(BPF_LD
| BPF_IMM
, 0xffeebbaa),
11471 BPF_STMT(BPF_LDX
| BPF_B
| BPF_MSH
, 0x3c),
11472 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
11475 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
11476 { {0x40, 0xffeebbaa }, },
11479 "LDX_MSH standalone, preserved A 2",
11481 BPF_STMT(BPF_LD
| BPF_IMM
, 0x175e9d63),
11482 BPF_STMT(BPF_LDX
| BPF_B
| BPF_MSH
, 0x3c),
11483 BPF_STMT(BPF_LDX
| BPF_B
| BPF_MSH
, 0x3d),
11484 BPF_STMT(BPF_LDX
| BPF_B
| BPF_MSH
, 0x3e),
11485 BPF_STMT(BPF_LDX
| BPF_B
| BPF_MSH
, 0x3f),
11486 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
11489 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
11490 { {0x40, 0x175e9d63 }, },
11493 "LDX_MSH standalone, test result 1",
11495 BPF_STMT(BPF_LD
| BPF_IMM
, 0xffeebbaa),
11496 BPF_STMT(BPF_LDX
| BPF_B
| BPF_MSH
, 0x3c),
11497 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
11498 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
11501 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
11502 { {0x40, 0x14 }, },
11505 "LDX_MSH standalone, test result 2",
11507 BPF_STMT(BPF_LD
| BPF_IMM
, 0xffeebbaa),
11508 BPF_STMT(BPF_LDX
| BPF_B
| BPF_MSH
, 0x3e),
11509 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
11510 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
11513 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
11514 { {0x40, 0x24 }, },
11517 "LDX_MSH standalone, negative offset",
11519 BPF_STMT(BPF_LD
| BPF_IMM
, 0xffeebbaa),
11520 BPF_STMT(BPF_LDX
| BPF_B
| BPF_MSH
, -1),
11521 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
11522 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
11525 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
11529 "LDX_MSH standalone, negative offset 2",
11531 BPF_STMT(BPF_LD
| BPF_IMM
, 0xffeebbaa),
11532 BPF_STMT(BPF_LDX
| BPF_B
| BPF_MSH
, SKF_LL_OFF
+ 0x3e),
11533 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
11534 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
11537 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
11538 { {0x40, 0x24 }, },
11541 "LDX_MSH standalone, out of bounds",
11543 BPF_STMT(BPF_LD
| BPF_IMM
, 0xffeebbaa),
11544 BPF_STMT(BPF_LDX
| BPF_B
| BPF_MSH
, 0x40),
11545 BPF_STMT(BPF_MISC
| BPF_TXA
, 0),
11546 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
11549 { [0x3c] = 0x25, [0x3d] = 0x05, [0x3e] = 0x19, [0x3f] = 0x82 },
11553 * verify that the interpreter or JIT correctly sets A and X
11564 BPF_STMT(BPF_LD
| BPF_IMM
, 0x42),
11565 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_X
, 0),
11566 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
11568 CLASSIC
| FLAG_NO_DATA
,
11579 BPF_STMT(BPF_ALU
| BPF_ADD
| BPF_K
, 0x42),
11580 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
11582 CLASSIC
| FLAG_NO_DATA
,
11594 BPF_STMT(BPF_LD
| BPF_IMM
, 0x66),
11595 BPF_STMT(BPF_ALU
| BPF_SUB
| BPF_X
, 0),
11596 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
11598 CLASSIC
| FLAG_NO_DATA
,
11609 BPF_STMT(BPF_ALU
| BPF_SUB
| BPF_K
, -0x66),
11610 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
11612 CLASSIC
| FLAG_NO_DATA
,
11624 BPF_STMT(BPF_LD
| BPF_IMM
, 0x42),
11625 BPF_STMT(BPF_ALU
| BPF_MUL
| BPF_X
, 0),
11626 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
11628 CLASSIC
| FLAG_NO_DATA
,
11639 BPF_STMT(BPF_ALU
| BPF_MUL
| BPF_K
, 0x66),
11640 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
11642 CLASSIC
| FLAG_NO_DATA
,
11651 * A = A / X ; this halt the filter execution if X is 0
11654 BPF_STMT(BPF_LD
| BPF_IMM
, 0x42),
11655 BPF_STMT(BPF_ALU
| BPF_DIV
| BPF_X
, 0),
11656 BPF_STMT(BPF_RET
| BPF_K
, 0x42),
11658 CLASSIC
| FLAG_NO_DATA
,
11669 BPF_STMT(BPF_ALU
| BPF_DIV
| BPF_K
, 0x1),
11670 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
11672 CLASSIC
| FLAG_NO_DATA
,
11681 * A = A mod X ; this halt the filter execution if X is 0
11684 BPF_STMT(BPF_LD
| BPF_IMM
, 0x42),
11685 BPF_STMT(BPF_ALU
| BPF_MOD
| BPF_X
, 0),
11686 BPF_STMT(BPF_RET
| BPF_K
, 0x42),
11688 CLASSIC
| FLAG_NO_DATA
,
11699 BPF_STMT(BPF_ALU
| BPF_MOD
| BPF_K
, 0x1),
11700 BPF_STMT(BPF_RET
| BPF_A
, 0x0),
11702 CLASSIC
| FLAG_NO_DATA
,
11707 "JMP EQ default A",
11714 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 0x0, 0, 1),
11715 BPF_STMT(BPF_RET
| BPF_K
, 0x42),
11716 BPF_STMT(BPF_RET
| BPF_K
, 0x66),
11718 CLASSIC
| FLAG_NO_DATA
,
11723 "JMP EQ default X",
11731 BPF_STMT(BPF_LD
| BPF_IMM
, 0x0),
11732 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_X
, 0x0, 0, 1),
11733 BPF_STMT(BPF_RET
| BPF_K
, 0x42),
11734 BPF_STMT(BPF_RET
| BPF_K
, 0x66),
11736 CLASSIC
| FLAG_NO_DATA
,
11740 /* Checking interpreter vs JIT wrt signed extended imms. */
11742 "JNE signed compare, test 1",
11744 BPF_ALU32_IMM(BPF_MOV
, R1
, 0xfefbbc12),
11745 BPF_ALU32_IMM(BPF_MOV
, R3
, 0xffff0000),
11746 BPF_MOV64_REG(R2
, R1
),
11747 BPF_ALU64_REG(BPF_AND
, R2
, R3
),
11748 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
11749 BPF_JMP_IMM(BPF_JNE
, R2
, -17104896, 1),
11750 BPF_ALU32_IMM(BPF_MOV
, R0
, 2),
11758 "JNE signed compare, test 2",
11760 BPF_ALU32_IMM(BPF_MOV
, R1
, 0xfefbbc12),
11761 BPF_ALU32_IMM(BPF_MOV
, R3
, 0xffff0000),
11762 BPF_MOV64_REG(R2
, R1
),
11763 BPF_ALU64_REG(BPF_AND
, R2
, R3
),
11764 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
11765 BPF_JMP_IMM(BPF_JNE
, R2
, 0xfefb0000, 1),
11766 BPF_ALU32_IMM(BPF_MOV
, R0
, 2),
11774 "JNE signed compare, test 3",
11776 BPF_ALU32_IMM(BPF_MOV
, R1
, 0xfefbbc12),
11777 BPF_ALU32_IMM(BPF_MOV
, R3
, 0xffff0000),
11778 BPF_ALU32_IMM(BPF_MOV
, R4
, 0xfefb0000),
11779 BPF_MOV64_REG(R2
, R1
),
11780 BPF_ALU64_REG(BPF_AND
, R2
, R3
),
11781 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
11782 BPF_JMP_REG(BPF_JNE
, R2
, R4
, 1),
11783 BPF_ALU32_IMM(BPF_MOV
, R0
, 2),
11791 "JNE signed compare, test 4",
11793 BPF_LD_IMM64(R1
, -17104896),
11794 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
11795 BPF_JMP_IMM(BPF_JNE
, R1
, -17104896, 1),
11796 BPF_ALU32_IMM(BPF_MOV
, R0
, 2),
11804 "JNE signed compare, test 5",
11806 BPF_LD_IMM64(R1
, 0xfefb0000),
11807 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
11808 BPF_JMP_IMM(BPF_JNE
, R1
, 0xfefb0000, 1),
11809 BPF_ALU32_IMM(BPF_MOV
, R0
, 2),
11817 "JNE signed compare, test 6",
11819 BPF_LD_IMM64(R1
, 0x7efb0000),
11820 BPF_ALU32_IMM(BPF_MOV
, R0
, 1),
11821 BPF_JMP_IMM(BPF_JNE
, R1
, 0x7efb0000, 1),
11822 BPF_ALU32_IMM(BPF_MOV
, R0
, 2),
11830 "JNE signed compare, test 7",
11832 BPF_STMT(BPF_LD
| BPF_IMM
, 0xffff0000),
11833 BPF_STMT(BPF_MISC
| BPF_TAX
, 0),
11834 BPF_STMT(BPF_LD
| BPF_IMM
, 0xfefbbc12),
11835 BPF_STMT(BPF_ALU
| BPF_AND
| BPF_X
, 0),
11836 BPF_JUMP(BPF_JMP
| BPF_JEQ
| BPF_K
, 0xfefb0000, 1, 0),
11837 BPF_STMT(BPF_RET
| BPF_K
, 1),
11838 BPF_STMT(BPF_RET
| BPF_K
, 2),
11840 CLASSIC
| FLAG_NO_DATA
,
11844 /* BPF_LDX_MEM with operand aliasing */
11846 "LDX_MEM_B: operand register aliasing",
11848 BPF_ST_MEM(BPF_B
, R10
, -8, 123),
11849 BPF_MOV64_REG(R0
, R10
),
11850 BPF_LDX_MEM(BPF_B
, R0
, R0
, -8),
11859 "LDX_MEM_H: operand register aliasing",
11861 BPF_ST_MEM(BPF_H
, R10
, -8, 12345),
11862 BPF_MOV64_REG(R0
, R10
),
11863 BPF_LDX_MEM(BPF_H
, R0
, R0
, -8),
11872 "LDX_MEM_W: operand register aliasing",
11874 BPF_ST_MEM(BPF_W
, R10
, -8, 123456789),
11875 BPF_MOV64_REG(R0
, R10
),
11876 BPF_LDX_MEM(BPF_W
, R0
, R0
, -8),
11881 { { 0, 123456789 } },
11885 "LDX_MEM_DW: operand register aliasing",
11887 BPF_LD_IMM64(R1
, 0x123456789abcdefULL
),
11888 BPF_STX_MEM(BPF_DW
, R10
, R1
, -8),
11889 BPF_MOV64_REG(R0
, R10
),
11890 BPF_LDX_MEM(BPF_DW
, R0
, R0
, -8),
11891 BPF_ALU64_REG(BPF_SUB
, R0
, R1
),
11892 BPF_MOV64_REG(R1
, R0
),
11893 BPF_ALU64_IMM(BPF_RSH
, R1
, 32),
11894 BPF_ALU64_REG(BPF_OR
, R0
, R1
),
11903 * Register (non-)clobbering tests for the case where a JIT implements
11904 * complex ALU or ATOMIC operations via function calls. If so, the
11905 * function call must be transparent to the eBPF registers. The JIT
11906 * must therefore save and restore relevant registers across the call.
11907 * The following tests check that the eBPF registers retain their
11908 * values after such an operation. Mainly intended for complex ALU
11909 * and atomic operation, but we run it for all. You never know...
11911 * Note that each operations should be tested twice with different
11912 * destinations, to check preservation for all registers.
11914 #define BPF_TEST_CLOBBER_ALU(alu, op, dst, src) \
11916 #alu "_" #op " to " #dst ": no clobbering", \
11918 BPF_ALU64_IMM(BPF_MOV, R0, R0), \
11919 BPF_ALU64_IMM(BPF_MOV, R1, R1), \
11920 BPF_ALU64_IMM(BPF_MOV, R2, R2), \
11921 BPF_ALU64_IMM(BPF_MOV, R3, R3), \
11922 BPF_ALU64_IMM(BPF_MOV, R4, R4), \
11923 BPF_ALU64_IMM(BPF_MOV, R5, R5), \
11924 BPF_ALU64_IMM(BPF_MOV, R6, R6), \
11925 BPF_ALU64_IMM(BPF_MOV, R7, R7), \
11926 BPF_ALU64_IMM(BPF_MOV, R8, R8), \
11927 BPF_ALU64_IMM(BPF_MOV, R9, R9), \
11928 BPF_##alu(BPF_ ##op, dst, src), \
11929 BPF_ALU32_IMM(BPF_MOV, dst, dst), \
11930 BPF_JMP_IMM(BPF_JNE, R0, R0, 10), \
11931 BPF_JMP_IMM(BPF_JNE, R1, R1, 9), \
11932 BPF_JMP_IMM(BPF_JNE, R2, R2, 8), \
11933 BPF_JMP_IMM(BPF_JNE, R3, R3, 7), \
11934 BPF_JMP_IMM(BPF_JNE, R4, R4, 6), \
11935 BPF_JMP_IMM(BPF_JNE, R5, R5, 5), \
11936 BPF_JMP_IMM(BPF_JNE, R6, R6, 4), \
11937 BPF_JMP_IMM(BPF_JNE, R7, R7, 3), \
11938 BPF_JMP_IMM(BPF_JNE, R8, R8, 2), \
11939 BPF_JMP_IMM(BPF_JNE, R9, R9, 1), \
11940 BPF_ALU64_IMM(BPF_MOV, R0, 1), \
11947 /* ALU64 operations, register clobbering */
11948 BPF_TEST_CLOBBER_ALU(ALU64_IMM
, AND
, R8
, 123456789),
11949 BPF_TEST_CLOBBER_ALU(ALU64_IMM
, AND
, R9
, 123456789),
11950 BPF_TEST_CLOBBER_ALU(ALU64_IMM
, OR
, R8
, 123456789),
11951 BPF_TEST_CLOBBER_ALU(ALU64_IMM
, OR
, R9
, 123456789),
11952 BPF_TEST_CLOBBER_ALU(ALU64_IMM
, XOR
, R8
, 123456789),
11953 BPF_TEST_CLOBBER_ALU(ALU64_IMM
, XOR
, R9
, 123456789),
11954 BPF_TEST_CLOBBER_ALU(ALU64_IMM
, LSH
, R8
, 12),
11955 BPF_TEST_CLOBBER_ALU(ALU64_IMM
, LSH
, R9
, 12),
11956 BPF_TEST_CLOBBER_ALU(ALU64_IMM
, RSH
, R8
, 12),
11957 BPF_TEST_CLOBBER_ALU(ALU64_IMM
, RSH
, R9
, 12),
11958 BPF_TEST_CLOBBER_ALU(ALU64_IMM
, ARSH
, R8
, 12),
11959 BPF_TEST_CLOBBER_ALU(ALU64_IMM
, ARSH
, R9
, 12),
11960 BPF_TEST_CLOBBER_ALU(ALU64_IMM
, ADD
, R8
, 123456789),
11961 BPF_TEST_CLOBBER_ALU(ALU64_IMM
, ADD
, R9
, 123456789),
11962 BPF_TEST_CLOBBER_ALU(ALU64_IMM
, SUB
, R8
, 123456789),
11963 BPF_TEST_CLOBBER_ALU(ALU64_IMM
, SUB
, R9
, 123456789),
11964 BPF_TEST_CLOBBER_ALU(ALU64_IMM
, MUL
, R8
, 123456789),
11965 BPF_TEST_CLOBBER_ALU(ALU64_IMM
, MUL
, R9
, 123456789),
11966 BPF_TEST_CLOBBER_ALU(ALU64_IMM
, DIV
, R8
, 123456789),
11967 BPF_TEST_CLOBBER_ALU(ALU64_IMM
, DIV
, R9
, 123456789),
11968 BPF_TEST_CLOBBER_ALU(ALU64_IMM
, MOD
, R8
, 123456789),
11969 BPF_TEST_CLOBBER_ALU(ALU64_IMM
, MOD
, R9
, 123456789),
11970 /* ALU32 immediate operations, register clobbering */
11971 BPF_TEST_CLOBBER_ALU(ALU32_IMM
, AND
, R8
, 123456789),
11972 BPF_TEST_CLOBBER_ALU(ALU32_IMM
, AND
, R9
, 123456789),
11973 BPF_TEST_CLOBBER_ALU(ALU32_IMM
, OR
, R8
, 123456789),
11974 BPF_TEST_CLOBBER_ALU(ALU32_IMM
, OR
, R9
, 123456789),
11975 BPF_TEST_CLOBBER_ALU(ALU32_IMM
, XOR
, R8
, 123456789),
11976 BPF_TEST_CLOBBER_ALU(ALU32_IMM
, XOR
, R9
, 123456789),
11977 BPF_TEST_CLOBBER_ALU(ALU32_IMM
, LSH
, R8
, 12),
11978 BPF_TEST_CLOBBER_ALU(ALU32_IMM
, LSH
, R9
, 12),
11979 BPF_TEST_CLOBBER_ALU(ALU32_IMM
, RSH
, R8
, 12),
11980 BPF_TEST_CLOBBER_ALU(ALU32_IMM
, RSH
, R9
, 12),
11981 BPF_TEST_CLOBBER_ALU(ALU32_IMM
, ARSH
, R8
, 12),
11982 BPF_TEST_CLOBBER_ALU(ALU32_IMM
, ARSH
, R9
, 12),
11983 BPF_TEST_CLOBBER_ALU(ALU32_IMM
, ADD
, R8
, 123456789),
11984 BPF_TEST_CLOBBER_ALU(ALU32_IMM
, ADD
, R9
, 123456789),
11985 BPF_TEST_CLOBBER_ALU(ALU32_IMM
, SUB
, R8
, 123456789),
11986 BPF_TEST_CLOBBER_ALU(ALU32_IMM
, SUB
, R9
, 123456789),
11987 BPF_TEST_CLOBBER_ALU(ALU32_IMM
, MUL
, R8
, 123456789),
11988 BPF_TEST_CLOBBER_ALU(ALU32_IMM
, MUL
, R9
, 123456789),
11989 BPF_TEST_CLOBBER_ALU(ALU32_IMM
, DIV
, R8
, 123456789),
11990 BPF_TEST_CLOBBER_ALU(ALU32_IMM
, DIV
, R9
, 123456789),
11991 BPF_TEST_CLOBBER_ALU(ALU32_IMM
, MOD
, R8
, 123456789),
11992 BPF_TEST_CLOBBER_ALU(ALU32_IMM
, MOD
, R9
, 123456789),
11993 /* ALU64 register operations, register clobbering */
11994 BPF_TEST_CLOBBER_ALU(ALU64_REG
, AND
, R8
, R1
),
11995 BPF_TEST_CLOBBER_ALU(ALU64_REG
, AND
, R9
, R1
),
11996 BPF_TEST_CLOBBER_ALU(ALU64_REG
, OR
, R8
, R1
),
11997 BPF_TEST_CLOBBER_ALU(ALU64_REG
, OR
, R9
, R1
),
11998 BPF_TEST_CLOBBER_ALU(ALU64_REG
, XOR
, R8
, R1
),
11999 BPF_TEST_CLOBBER_ALU(ALU64_REG
, XOR
, R9
, R1
),
12000 BPF_TEST_CLOBBER_ALU(ALU64_REG
, LSH
, R8
, R1
),
12001 BPF_TEST_CLOBBER_ALU(ALU64_REG
, LSH
, R9
, R1
),
12002 BPF_TEST_CLOBBER_ALU(ALU64_REG
, RSH
, R8
, R1
),
12003 BPF_TEST_CLOBBER_ALU(ALU64_REG
, RSH
, R9
, R1
),
12004 BPF_TEST_CLOBBER_ALU(ALU64_REG
, ARSH
, R8
, R1
),
12005 BPF_TEST_CLOBBER_ALU(ALU64_REG
, ARSH
, R9
, R1
),
12006 BPF_TEST_CLOBBER_ALU(ALU64_REG
, ADD
, R8
, R1
),
12007 BPF_TEST_CLOBBER_ALU(ALU64_REG
, ADD
, R9
, R1
),
12008 BPF_TEST_CLOBBER_ALU(ALU64_REG
, SUB
, R8
, R1
),
12009 BPF_TEST_CLOBBER_ALU(ALU64_REG
, SUB
, R9
, R1
),
12010 BPF_TEST_CLOBBER_ALU(ALU64_REG
, MUL
, R8
, R1
),
12011 BPF_TEST_CLOBBER_ALU(ALU64_REG
, MUL
, R9
, R1
),
12012 BPF_TEST_CLOBBER_ALU(ALU64_REG
, DIV
, R8
, R1
),
12013 BPF_TEST_CLOBBER_ALU(ALU64_REG
, DIV
, R9
, R1
),
12014 BPF_TEST_CLOBBER_ALU(ALU64_REG
, MOD
, R8
, R1
),
12015 BPF_TEST_CLOBBER_ALU(ALU64_REG
, MOD
, R9
, R1
),
12016 /* ALU32 register operations, register clobbering */
12017 BPF_TEST_CLOBBER_ALU(ALU32_REG
, AND
, R8
, R1
),
12018 BPF_TEST_CLOBBER_ALU(ALU32_REG
, AND
, R9
, R1
),
12019 BPF_TEST_CLOBBER_ALU(ALU32_REG
, OR
, R8
, R1
),
12020 BPF_TEST_CLOBBER_ALU(ALU32_REG
, OR
, R9
, R1
),
12021 BPF_TEST_CLOBBER_ALU(ALU32_REG
, XOR
, R8
, R1
),
12022 BPF_TEST_CLOBBER_ALU(ALU32_REG
, XOR
, R9
, R1
),
12023 BPF_TEST_CLOBBER_ALU(ALU32_REG
, LSH
, R8
, R1
),
12024 BPF_TEST_CLOBBER_ALU(ALU32_REG
, LSH
, R9
, R1
),
12025 BPF_TEST_CLOBBER_ALU(ALU32_REG
, RSH
, R8
, R1
),
12026 BPF_TEST_CLOBBER_ALU(ALU32_REG
, RSH
, R9
, R1
),
12027 BPF_TEST_CLOBBER_ALU(ALU32_REG
, ARSH
, R8
, R1
),
12028 BPF_TEST_CLOBBER_ALU(ALU32_REG
, ARSH
, R9
, R1
),
12029 BPF_TEST_CLOBBER_ALU(ALU32_REG
, ADD
, R8
, R1
),
12030 BPF_TEST_CLOBBER_ALU(ALU32_REG
, ADD
, R9
, R1
),
12031 BPF_TEST_CLOBBER_ALU(ALU32_REG
, SUB
, R8
, R1
),
12032 BPF_TEST_CLOBBER_ALU(ALU32_REG
, SUB
, R9
, R1
),
12033 BPF_TEST_CLOBBER_ALU(ALU32_REG
, MUL
, R8
, R1
),
12034 BPF_TEST_CLOBBER_ALU(ALU32_REG
, MUL
, R9
, R1
),
12035 BPF_TEST_CLOBBER_ALU(ALU32_REG
, DIV
, R8
, R1
),
12036 BPF_TEST_CLOBBER_ALU(ALU32_REG
, DIV
, R9
, R1
),
12037 BPF_TEST_CLOBBER_ALU(ALU32_REG
, MOD
, R8
, R1
),
12038 BPF_TEST_CLOBBER_ALU(ALU32_REG
, MOD
, R9
, R1
),
12039 #undef BPF_TEST_CLOBBER_ALU
12040 #define BPF_TEST_CLOBBER_ATOMIC(width, op) \
12042 "Atomic_" #width " " #op ": no clobbering", \
12044 BPF_ALU64_IMM(BPF_MOV, R0, 0), \
12045 BPF_ALU64_IMM(BPF_MOV, R1, 1), \
12046 BPF_ALU64_IMM(BPF_MOV, R2, 2), \
12047 BPF_ALU64_IMM(BPF_MOV, R3, 3), \
12048 BPF_ALU64_IMM(BPF_MOV, R4, 4), \
12049 BPF_ALU64_IMM(BPF_MOV, R5, 5), \
12050 BPF_ALU64_IMM(BPF_MOV, R6, 6), \
12051 BPF_ALU64_IMM(BPF_MOV, R7, 7), \
12052 BPF_ALU64_IMM(BPF_MOV, R8, 8), \
12053 BPF_ALU64_IMM(BPF_MOV, R9, 9), \
12054 BPF_ST_MEM(width, R10, -8, \
12055 (op) == BPF_CMPXCHG ? 0 : \
12056 (op) & BPF_FETCH ? 1 : 0), \
12057 BPF_ATOMIC_OP(width, op, R10, R1, -8), \
12058 BPF_JMP_IMM(BPF_JNE, R0, 0, 10), \
12059 BPF_JMP_IMM(BPF_JNE, R1, 1, 9), \
12060 BPF_JMP_IMM(BPF_JNE, R2, 2, 8), \
12061 BPF_JMP_IMM(BPF_JNE, R3, 3, 7), \
12062 BPF_JMP_IMM(BPF_JNE, R4, 4, 6), \
12063 BPF_JMP_IMM(BPF_JNE, R5, 5, 5), \
12064 BPF_JMP_IMM(BPF_JNE, R6, 6, 4), \
12065 BPF_JMP_IMM(BPF_JNE, R7, 7, 3), \
12066 BPF_JMP_IMM(BPF_JNE, R8, 8, 2), \
12067 BPF_JMP_IMM(BPF_JNE, R9, 9, 1), \
12068 BPF_ALU64_IMM(BPF_MOV, R0, 1), \
12074 .stack_depth = 8, \
12076 /* 64-bit atomic operations, register clobbering */
12077 BPF_TEST_CLOBBER_ATOMIC(BPF_DW
, BPF_ADD
),
12078 BPF_TEST_CLOBBER_ATOMIC(BPF_DW
, BPF_AND
),
12079 BPF_TEST_CLOBBER_ATOMIC(BPF_DW
, BPF_OR
),
12080 BPF_TEST_CLOBBER_ATOMIC(BPF_DW
, BPF_XOR
),
12081 BPF_TEST_CLOBBER_ATOMIC(BPF_DW
, BPF_ADD
| BPF_FETCH
),
12082 BPF_TEST_CLOBBER_ATOMIC(BPF_DW
, BPF_AND
| BPF_FETCH
),
12083 BPF_TEST_CLOBBER_ATOMIC(BPF_DW
, BPF_OR
| BPF_FETCH
),
12084 BPF_TEST_CLOBBER_ATOMIC(BPF_DW
, BPF_XOR
| BPF_FETCH
),
12085 BPF_TEST_CLOBBER_ATOMIC(BPF_DW
, BPF_XCHG
),
12086 BPF_TEST_CLOBBER_ATOMIC(BPF_DW
, BPF_CMPXCHG
),
12087 /* 32-bit atomic operations, register clobbering */
12088 BPF_TEST_CLOBBER_ATOMIC(BPF_W
, BPF_ADD
),
12089 BPF_TEST_CLOBBER_ATOMIC(BPF_W
, BPF_AND
),
12090 BPF_TEST_CLOBBER_ATOMIC(BPF_W
, BPF_OR
),
12091 BPF_TEST_CLOBBER_ATOMIC(BPF_W
, BPF_XOR
),
12092 BPF_TEST_CLOBBER_ATOMIC(BPF_W
, BPF_ADD
| BPF_FETCH
),
12093 BPF_TEST_CLOBBER_ATOMIC(BPF_W
, BPF_AND
| BPF_FETCH
),
12094 BPF_TEST_CLOBBER_ATOMIC(BPF_W
, BPF_OR
| BPF_FETCH
),
12095 BPF_TEST_CLOBBER_ATOMIC(BPF_W
, BPF_XOR
| BPF_FETCH
),
12096 BPF_TEST_CLOBBER_ATOMIC(BPF_W
, BPF_XCHG
),
12097 BPF_TEST_CLOBBER_ATOMIC(BPF_W
, BPF_CMPXCHG
),
12098 #undef BPF_TEST_CLOBBER_ATOMIC
12099 /* Checking that ALU32 src is not zero extended in place */
12100 #define BPF_ALU32_SRC_ZEXT(op) \
12102 "ALU32_" #op "_X: src preserved in zext", \
12104 BPF_LD_IMM64(R1, 0x0123456789acbdefULL),\
12105 BPF_LD_IMM64(R2, 0xfedcba9876543210ULL),\
12106 BPF_ALU64_REG(BPF_MOV, R0, R1), \
12107 BPF_ALU32_REG(BPF_##op, R2, R1), \
12108 BPF_ALU64_REG(BPF_SUB, R0, R1), \
12109 BPF_ALU64_REG(BPF_MOV, R1, R0), \
12110 BPF_ALU64_IMM(BPF_RSH, R1, 32), \
12111 BPF_ALU64_REG(BPF_OR, R0, R1), \
12118 BPF_ALU32_SRC_ZEXT(MOV
),
12119 BPF_ALU32_SRC_ZEXT(AND
),
12120 BPF_ALU32_SRC_ZEXT(OR
),
12121 BPF_ALU32_SRC_ZEXT(XOR
),
12122 BPF_ALU32_SRC_ZEXT(ADD
),
12123 BPF_ALU32_SRC_ZEXT(SUB
),
12124 BPF_ALU32_SRC_ZEXT(MUL
),
12125 BPF_ALU32_SRC_ZEXT(DIV
),
12126 BPF_ALU32_SRC_ZEXT(MOD
),
12127 #undef BPF_ALU32_SRC_ZEXT
12128 /* Checking that ATOMIC32 src is not zero extended in place */
12129 #define BPF_ATOMIC32_SRC_ZEXT(op) \
12131 "ATOMIC_W_" #op ": src preserved in zext", \
12133 BPF_LD_IMM64(R0, 0x0123456789acbdefULL), \
12134 BPF_ALU64_REG(BPF_MOV, R1, R0), \
12135 BPF_ST_MEM(BPF_W, R10, -4, 0), \
12136 BPF_ATOMIC_OP(BPF_W, BPF_##op, R10, R1, -4), \
12137 BPF_ALU64_REG(BPF_SUB, R0, R1), \
12138 BPF_ALU64_REG(BPF_MOV, R1, R0), \
12139 BPF_ALU64_IMM(BPF_RSH, R1, 32), \
12140 BPF_ALU64_REG(BPF_OR, R0, R1), \
12146 .stack_depth = 8, \
12148 BPF_ATOMIC32_SRC_ZEXT(ADD
),
12149 BPF_ATOMIC32_SRC_ZEXT(AND
),
12150 BPF_ATOMIC32_SRC_ZEXT(OR
),
12151 BPF_ATOMIC32_SRC_ZEXT(XOR
),
12152 #undef BPF_ATOMIC32_SRC_ZEXT
12153 /* Checking that CMPXCHG32 src is not zero extended in place */
12155 "ATOMIC_W_CMPXCHG: src preserved in zext",
12157 BPF_LD_IMM64(R1
, 0x0123456789acbdefULL
),
12158 BPF_ALU64_REG(BPF_MOV
, R2
, R1
),
12159 BPF_ALU64_REG(BPF_MOV
, R0
, 0),
12160 BPF_ST_MEM(BPF_W
, R10
, -4, 0),
12161 BPF_ATOMIC_OP(BPF_W
, BPF_CMPXCHG
, R10
, R1
, -4),
12162 BPF_ALU64_REG(BPF_SUB
, R1
, R2
),
12163 BPF_ALU64_REG(BPF_MOV
, R2
, R1
),
12164 BPF_ALU64_IMM(BPF_RSH
, R2
, 32),
12165 BPF_ALU64_REG(BPF_OR
, R1
, R2
),
12166 BPF_ALU64_REG(BPF_MOV
, R0
, R1
),
12174 /* Checking that JMP32 immediate src is not zero extended in place */
12175 #define BPF_JMP32_IMM_ZEXT(op) \
12177 "JMP32_" #op "_K: operand preserved in zext", \
12179 BPF_LD_IMM64(R0, 0x0123456789acbdefULL),\
12180 BPF_ALU64_REG(BPF_MOV, R1, R0), \
12181 BPF_JMP32_IMM(BPF_##op, R0, 1234, 1), \
12182 BPF_JMP_A(0), /* Nop */ \
12183 BPF_ALU64_REG(BPF_SUB, R0, R1), \
12184 BPF_ALU64_REG(BPF_MOV, R1, R0), \
12185 BPF_ALU64_IMM(BPF_RSH, R1, 32), \
12186 BPF_ALU64_REG(BPF_OR, R0, R1), \
12193 BPF_JMP32_IMM_ZEXT(JEQ
),
12194 BPF_JMP32_IMM_ZEXT(JNE
),
12195 BPF_JMP32_IMM_ZEXT(JSET
),
12196 BPF_JMP32_IMM_ZEXT(JGT
),
12197 BPF_JMP32_IMM_ZEXT(JGE
),
12198 BPF_JMP32_IMM_ZEXT(JLT
),
12199 BPF_JMP32_IMM_ZEXT(JLE
),
12200 BPF_JMP32_IMM_ZEXT(JSGT
),
12201 BPF_JMP32_IMM_ZEXT(JSGE
),
12202 BPF_JMP32_IMM_ZEXT(JSLT
),
12203 BPF_JMP32_IMM_ZEXT(JSLE
),
12204 #undef BPF_JMP2_IMM_ZEXT
12205 /* Checking that JMP32 dst & src are not zero extended in place */
12206 #define BPF_JMP32_REG_ZEXT(op) \
12208 "JMP32_" #op "_X: operands preserved in zext", \
12210 BPF_LD_IMM64(R0, 0x0123456789acbdefULL),\
12211 BPF_LD_IMM64(R1, 0xfedcba9876543210ULL),\
12212 BPF_ALU64_REG(BPF_MOV, R2, R0), \
12213 BPF_ALU64_REG(BPF_MOV, R3, R1), \
12214 BPF_JMP32_IMM(BPF_##op, R0, R1, 1), \
12215 BPF_JMP_A(0), /* Nop */ \
12216 BPF_ALU64_REG(BPF_SUB, R0, R2), \
12217 BPF_ALU64_REG(BPF_SUB, R1, R3), \
12218 BPF_ALU64_REG(BPF_OR, R0, R1), \
12219 BPF_ALU64_REG(BPF_MOV, R1, R0), \
12220 BPF_ALU64_IMM(BPF_RSH, R1, 32), \
12221 BPF_ALU64_REG(BPF_OR, R0, R1), \
12228 BPF_JMP32_REG_ZEXT(JEQ
),
12229 BPF_JMP32_REG_ZEXT(JNE
),
12230 BPF_JMP32_REG_ZEXT(JSET
),
12231 BPF_JMP32_REG_ZEXT(JGT
),
12232 BPF_JMP32_REG_ZEXT(JGE
),
12233 BPF_JMP32_REG_ZEXT(JLT
),
12234 BPF_JMP32_REG_ZEXT(JLE
),
12235 BPF_JMP32_REG_ZEXT(JSGT
),
12236 BPF_JMP32_REG_ZEXT(JSGE
),
12237 BPF_JMP32_REG_ZEXT(JSLT
),
12238 BPF_JMP32_REG_ZEXT(JSLE
),
12239 #undef BPF_JMP2_REG_ZEXT
12240 /* ALU64 K register combinations */
12242 "ALU64_MOV_K: registers",
12247 .fill_helper
= bpf_fill_alu64_mov_imm_regs
,
12250 "ALU64_AND_K: registers",
12255 .fill_helper
= bpf_fill_alu64_and_imm_regs
,
12258 "ALU64_OR_K: registers",
12263 .fill_helper
= bpf_fill_alu64_or_imm_regs
,
12266 "ALU64_XOR_K: registers",
12271 .fill_helper
= bpf_fill_alu64_xor_imm_regs
,
12274 "ALU64_LSH_K: registers",
12279 .fill_helper
= bpf_fill_alu64_lsh_imm_regs
,
12282 "ALU64_RSH_K: registers",
12287 .fill_helper
= bpf_fill_alu64_rsh_imm_regs
,
12290 "ALU64_ARSH_K: registers",
12295 .fill_helper
= bpf_fill_alu64_arsh_imm_regs
,
12298 "ALU64_ADD_K: registers",
12303 .fill_helper
= bpf_fill_alu64_add_imm_regs
,
12306 "ALU64_SUB_K: registers",
12311 .fill_helper
= bpf_fill_alu64_sub_imm_regs
,
12314 "ALU64_MUL_K: registers",
12319 .fill_helper
= bpf_fill_alu64_mul_imm_regs
,
12322 "ALU64_DIV_K: registers",
12327 .fill_helper
= bpf_fill_alu64_div_imm_regs
,
12330 "ALU64_MOD_K: registers",
12335 .fill_helper
= bpf_fill_alu64_mod_imm_regs
,
12337 /* ALU32 K registers */
12339 "ALU32_MOV_K: registers",
12344 .fill_helper
= bpf_fill_alu32_mov_imm_regs
,
12347 "ALU32_AND_K: registers",
12352 .fill_helper
= bpf_fill_alu32_and_imm_regs
,
12355 "ALU32_OR_K: registers",
12360 .fill_helper
= bpf_fill_alu32_or_imm_regs
,
12363 "ALU32_XOR_K: registers",
12368 .fill_helper
= bpf_fill_alu32_xor_imm_regs
,
12371 "ALU32_LSH_K: registers",
12376 .fill_helper
= bpf_fill_alu32_lsh_imm_regs
,
12379 "ALU32_RSH_K: registers",
12384 .fill_helper
= bpf_fill_alu32_rsh_imm_regs
,
12387 "ALU32_ARSH_K: registers",
12392 .fill_helper
= bpf_fill_alu32_arsh_imm_regs
,
12395 "ALU32_ADD_K: registers",
12400 .fill_helper
= bpf_fill_alu32_add_imm_regs
,
12403 "ALU32_SUB_K: registers",
12408 .fill_helper
= bpf_fill_alu32_sub_imm_regs
,
12411 "ALU32_MUL_K: registers",
12416 .fill_helper
= bpf_fill_alu32_mul_imm_regs
,
12419 "ALU32_DIV_K: registers",
12424 .fill_helper
= bpf_fill_alu32_div_imm_regs
,
12427 "ALU32_MOD_K: registers",
12432 .fill_helper
= bpf_fill_alu32_mod_imm_regs
,
12434 /* ALU64 X register combinations */
12436 "ALU64_MOV_X: register combinations",
12441 .fill_helper
= bpf_fill_alu64_mov_reg_pairs
,
12444 "ALU64_AND_X: register combinations",
12449 .fill_helper
= bpf_fill_alu64_and_reg_pairs
,
12452 "ALU64_OR_X: register combinations",
12457 .fill_helper
= bpf_fill_alu64_or_reg_pairs
,
12460 "ALU64_XOR_X: register combinations",
12465 .fill_helper
= bpf_fill_alu64_xor_reg_pairs
,
12468 "ALU64_LSH_X: register combinations",
12473 .fill_helper
= bpf_fill_alu64_lsh_reg_pairs
,
12476 "ALU64_RSH_X: register combinations",
12481 .fill_helper
= bpf_fill_alu64_rsh_reg_pairs
,
12484 "ALU64_ARSH_X: register combinations",
12489 .fill_helper
= bpf_fill_alu64_arsh_reg_pairs
,
12492 "ALU64_ADD_X: register combinations",
12497 .fill_helper
= bpf_fill_alu64_add_reg_pairs
,
12500 "ALU64_SUB_X: register combinations",
12505 .fill_helper
= bpf_fill_alu64_sub_reg_pairs
,
12508 "ALU64_MUL_X: register combinations",
12513 .fill_helper
= bpf_fill_alu64_mul_reg_pairs
,
12516 "ALU64_DIV_X: register combinations",
12521 .fill_helper
= bpf_fill_alu64_div_reg_pairs
,
12524 "ALU64_MOD_X: register combinations",
12529 .fill_helper
= bpf_fill_alu64_mod_reg_pairs
,
12531 /* ALU32 X register combinations */
12533 "ALU32_MOV_X: register combinations",
12538 .fill_helper
= bpf_fill_alu32_mov_reg_pairs
,
12541 "ALU32_AND_X: register combinations",
12546 .fill_helper
= bpf_fill_alu32_and_reg_pairs
,
12549 "ALU32_OR_X: register combinations",
12554 .fill_helper
= bpf_fill_alu32_or_reg_pairs
,
12557 "ALU32_XOR_X: register combinations",
12562 .fill_helper
= bpf_fill_alu32_xor_reg_pairs
,
12565 "ALU32_LSH_X: register combinations",
12570 .fill_helper
= bpf_fill_alu32_lsh_reg_pairs
,
12573 "ALU32_RSH_X: register combinations",
12578 .fill_helper
= bpf_fill_alu32_rsh_reg_pairs
,
12581 "ALU32_ARSH_X: register combinations",
12586 .fill_helper
= bpf_fill_alu32_arsh_reg_pairs
,
12589 "ALU32_ADD_X: register combinations",
12594 .fill_helper
= bpf_fill_alu32_add_reg_pairs
,
12597 "ALU32_SUB_X: register combinations",
12602 .fill_helper
= bpf_fill_alu32_sub_reg_pairs
,
12605 "ALU32_MUL_X: register combinations",
12610 .fill_helper
= bpf_fill_alu32_mul_reg_pairs
,
12613 "ALU32_DIV_X: register combinations",
12618 .fill_helper
= bpf_fill_alu32_div_reg_pairs
,
12621 "ALU32_MOD_X register combinations",
12626 .fill_helper
= bpf_fill_alu32_mod_reg_pairs
,
12628 /* Exhaustive test of ALU64 shift operations */
12630 "ALU64_LSH_K: all shift values",
12632 INTERNAL
| FLAG_NO_DATA
,
12635 .fill_helper
= bpf_fill_alu64_lsh_imm
,
12638 "ALU64_RSH_K: all shift values",
12640 INTERNAL
| FLAG_NO_DATA
,
12643 .fill_helper
= bpf_fill_alu64_rsh_imm
,
12646 "ALU64_ARSH_K: all shift values",
12648 INTERNAL
| FLAG_NO_DATA
,
12651 .fill_helper
= bpf_fill_alu64_arsh_imm
,
12654 "ALU64_LSH_X: all shift values",
12656 INTERNAL
| FLAG_NO_DATA
,
12659 .fill_helper
= bpf_fill_alu64_lsh_reg
,
12662 "ALU64_RSH_X: all shift values",
12664 INTERNAL
| FLAG_NO_DATA
,
12667 .fill_helper
= bpf_fill_alu64_rsh_reg
,
12670 "ALU64_ARSH_X: all shift values",
12672 INTERNAL
| FLAG_NO_DATA
,
12675 .fill_helper
= bpf_fill_alu64_arsh_reg
,
12677 /* Exhaustive test of ALU32 shift operations */
12679 "ALU32_LSH_K: all shift values",
12681 INTERNAL
| FLAG_NO_DATA
,
12684 .fill_helper
= bpf_fill_alu32_lsh_imm
,
12687 "ALU32_RSH_K: all shift values",
12689 INTERNAL
| FLAG_NO_DATA
,
12692 .fill_helper
= bpf_fill_alu32_rsh_imm
,
12695 "ALU32_ARSH_K: all shift values",
12697 INTERNAL
| FLAG_NO_DATA
,
12700 .fill_helper
= bpf_fill_alu32_arsh_imm
,
12703 "ALU32_LSH_X: all shift values",
12705 INTERNAL
| FLAG_NO_DATA
,
12708 .fill_helper
= bpf_fill_alu32_lsh_reg
,
12711 "ALU32_RSH_X: all shift values",
12713 INTERNAL
| FLAG_NO_DATA
,
12716 .fill_helper
= bpf_fill_alu32_rsh_reg
,
12719 "ALU32_ARSH_X: all shift values",
12721 INTERNAL
| FLAG_NO_DATA
,
12724 .fill_helper
= bpf_fill_alu32_arsh_reg
,
12727 * Exhaustive test of ALU64 shift operations when
12728 * source and destination register are the same.
12731 "ALU64_LSH_X: all shift values with the same register",
12733 INTERNAL
| FLAG_NO_DATA
,
12736 .fill_helper
= bpf_fill_alu64_lsh_same_reg
,
12739 "ALU64_RSH_X: all shift values with the same register",
12741 INTERNAL
| FLAG_NO_DATA
,
12744 .fill_helper
= bpf_fill_alu64_rsh_same_reg
,
12747 "ALU64_ARSH_X: all shift values with the same register",
12749 INTERNAL
| FLAG_NO_DATA
,
12752 .fill_helper
= bpf_fill_alu64_arsh_same_reg
,
12755 * Exhaustive test of ALU32 shift operations when
12756 * source and destination register are the same.
12759 "ALU32_LSH_X: all shift values with the same register",
12761 INTERNAL
| FLAG_NO_DATA
,
12764 .fill_helper
= bpf_fill_alu32_lsh_same_reg
,
12767 "ALU32_RSH_X: all shift values with the same register",
12769 INTERNAL
| FLAG_NO_DATA
,
12772 .fill_helper
= bpf_fill_alu32_rsh_same_reg
,
12775 "ALU32_ARSH_X: all shift values with the same register",
12777 INTERNAL
| FLAG_NO_DATA
,
12780 .fill_helper
= bpf_fill_alu32_arsh_same_reg
,
12782 /* ALU64 immediate magnitudes */
12784 "ALU64_MOV_K: all immediate value magnitudes",
12786 INTERNAL
| FLAG_NO_DATA
,
12789 .fill_helper
= bpf_fill_alu64_mov_imm
,
12790 .nr_testruns
= NR_PATTERN_RUNS
,
12793 "ALU64_AND_K: all immediate value magnitudes",
12795 INTERNAL
| FLAG_NO_DATA
,
12798 .fill_helper
= bpf_fill_alu64_and_imm
,
12799 .nr_testruns
= NR_PATTERN_RUNS
,
12802 "ALU64_OR_K: all immediate value magnitudes",
12804 INTERNAL
| FLAG_NO_DATA
,
12807 .fill_helper
= bpf_fill_alu64_or_imm
,
12808 .nr_testruns
= NR_PATTERN_RUNS
,
12811 "ALU64_XOR_K: all immediate value magnitudes",
12813 INTERNAL
| FLAG_NO_DATA
,
12816 .fill_helper
= bpf_fill_alu64_xor_imm
,
12817 .nr_testruns
= NR_PATTERN_RUNS
,
12820 "ALU64_ADD_K: all immediate value magnitudes",
12822 INTERNAL
| FLAG_NO_DATA
,
12825 .fill_helper
= bpf_fill_alu64_add_imm
,
12826 .nr_testruns
= NR_PATTERN_RUNS
,
12829 "ALU64_SUB_K: all immediate value magnitudes",
12831 INTERNAL
| FLAG_NO_DATA
,
12834 .fill_helper
= bpf_fill_alu64_sub_imm
,
12835 .nr_testruns
= NR_PATTERN_RUNS
,
12838 "ALU64_MUL_K: all immediate value magnitudes",
12840 INTERNAL
| FLAG_NO_DATA
,
12843 .fill_helper
= bpf_fill_alu64_mul_imm
,
12844 .nr_testruns
= NR_PATTERN_RUNS
,
12847 "ALU64_DIV_K: all immediate value magnitudes",
12849 INTERNAL
| FLAG_NO_DATA
,
12852 .fill_helper
= bpf_fill_alu64_div_imm
,
12853 .nr_testruns
= NR_PATTERN_RUNS
,
12856 "ALU64_MOD_K: all immediate value magnitudes",
12858 INTERNAL
| FLAG_NO_DATA
,
12861 .fill_helper
= bpf_fill_alu64_mod_imm
,
12862 .nr_testruns
= NR_PATTERN_RUNS
,
12864 /* ALU32 immediate magnitudes */
12866 "ALU32_MOV_K: all immediate value magnitudes",
12868 INTERNAL
| FLAG_NO_DATA
,
12871 .fill_helper
= bpf_fill_alu32_mov_imm
,
12872 .nr_testruns
= NR_PATTERN_RUNS
,
12875 "ALU32_AND_K: all immediate value magnitudes",
12877 INTERNAL
| FLAG_NO_DATA
,
12880 .fill_helper
= bpf_fill_alu32_and_imm
,
12881 .nr_testruns
= NR_PATTERN_RUNS
,
12884 "ALU32_OR_K: all immediate value magnitudes",
12886 INTERNAL
| FLAG_NO_DATA
,
12889 .fill_helper
= bpf_fill_alu32_or_imm
,
12890 .nr_testruns
= NR_PATTERN_RUNS
,
12893 "ALU32_XOR_K: all immediate value magnitudes",
12895 INTERNAL
| FLAG_NO_DATA
,
12898 .fill_helper
= bpf_fill_alu32_xor_imm
,
12899 .nr_testruns
= NR_PATTERN_RUNS
,
12902 "ALU32_ADD_K: all immediate value magnitudes",
12904 INTERNAL
| FLAG_NO_DATA
,
12907 .fill_helper
= bpf_fill_alu32_add_imm
,
12908 .nr_testruns
= NR_PATTERN_RUNS
,
12911 "ALU32_SUB_K: all immediate value magnitudes",
12913 INTERNAL
| FLAG_NO_DATA
,
12916 .fill_helper
= bpf_fill_alu32_sub_imm
,
12917 .nr_testruns
= NR_PATTERN_RUNS
,
12920 "ALU32_MUL_K: all immediate value magnitudes",
12922 INTERNAL
| FLAG_NO_DATA
,
12925 .fill_helper
= bpf_fill_alu32_mul_imm
,
12926 .nr_testruns
= NR_PATTERN_RUNS
,
12929 "ALU32_DIV_K: all immediate value magnitudes",
12931 INTERNAL
| FLAG_NO_DATA
,
12934 .fill_helper
= bpf_fill_alu32_div_imm
,
12935 .nr_testruns
= NR_PATTERN_RUNS
,
12938 "ALU32_MOD_K: all immediate value magnitudes",
12940 INTERNAL
| FLAG_NO_DATA
,
12943 .fill_helper
= bpf_fill_alu32_mod_imm
,
12944 .nr_testruns
= NR_PATTERN_RUNS
,
12946 /* ALU64 register magnitudes */
12948 "ALU64_MOV_X: all register value magnitudes",
12950 INTERNAL
| FLAG_NO_DATA
,
12953 .fill_helper
= bpf_fill_alu64_mov_reg
,
12954 .nr_testruns
= NR_PATTERN_RUNS
,
12957 "ALU64_AND_X: all register value magnitudes",
12959 INTERNAL
| FLAG_NO_DATA
,
12962 .fill_helper
= bpf_fill_alu64_and_reg
,
12963 .nr_testruns
= NR_PATTERN_RUNS
,
12966 "ALU64_OR_X: all register value magnitudes",
12968 INTERNAL
| FLAG_NO_DATA
,
12971 .fill_helper
= bpf_fill_alu64_or_reg
,
12972 .nr_testruns
= NR_PATTERN_RUNS
,
12975 "ALU64_XOR_X: all register value magnitudes",
12977 INTERNAL
| FLAG_NO_DATA
,
12980 .fill_helper
= bpf_fill_alu64_xor_reg
,
12981 .nr_testruns
= NR_PATTERN_RUNS
,
12984 "ALU64_ADD_X: all register value magnitudes",
12986 INTERNAL
| FLAG_NO_DATA
,
12989 .fill_helper
= bpf_fill_alu64_add_reg
,
12990 .nr_testruns
= NR_PATTERN_RUNS
,
12993 "ALU64_SUB_X: all register value magnitudes",
12995 INTERNAL
| FLAG_NO_DATA
,
12998 .fill_helper
= bpf_fill_alu64_sub_reg
,
12999 .nr_testruns
= NR_PATTERN_RUNS
,
13002 "ALU64_MUL_X: all register value magnitudes",
13004 INTERNAL
| FLAG_NO_DATA
,
13007 .fill_helper
= bpf_fill_alu64_mul_reg
,
13008 .nr_testruns
= NR_PATTERN_RUNS
,
13011 "ALU64_DIV_X: all register value magnitudes",
13013 INTERNAL
| FLAG_NO_DATA
,
13016 .fill_helper
= bpf_fill_alu64_div_reg
,
13017 .nr_testruns
= NR_PATTERN_RUNS
,
13020 "ALU64_MOD_X: all register value magnitudes",
13022 INTERNAL
| FLAG_NO_DATA
,
13025 .fill_helper
= bpf_fill_alu64_mod_reg
,
13026 .nr_testruns
= NR_PATTERN_RUNS
,
13028 /* ALU32 register magnitudes */
13030 "ALU32_MOV_X: all register value magnitudes",
13032 INTERNAL
| FLAG_NO_DATA
,
13035 .fill_helper
= bpf_fill_alu32_mov_reg
,
13036 .nr_testruns
= NR_PATTERN_RUNS
,
13039 "ALU32_AND_X: all register value magnitudes",
13041 INTERNAL
| FLAG_NO_DATA
,
13044 .fill_helper
= bpf_fill_alu32_and_reg
,
13045 .nr_testruns
= NR_PATTERN_RUNS
,
13048 "ALU32_OR_X: all register value magnitudes",
13050 INTERNAL
| FLAG_NO_DATA
,
13053 .fill_helper
= bpf_fill_alu32_or_reg
,
13054 .nr_testruns
= NR_PATTERN_RUNS
,
13057 "ALU32_XOR_X: all register value magnitudes",
13059 INTERNAL
| FLAG_NO_DATA
,
13062 .fill_helper
= bpf_fill_alu32_xor_reg
,
13063 .nr_testruns
= NR_PATTERN_RUNS
,
13066 "ALU32_ADD_X: all register value magnitudes",
13068 INTERNAL
| FLAG_NO_DATA
,
13071 .fill_helper
= bpf_fill_alu32_add_reg
,
13072 .nr_testruns
= NR_PATTERN_RUNS
,
13075 "ALU32_SUB_X: all register value magnitudes",
13077 INTERNAL
| FLAG_NO_DATA
,
13080 .fill_helper
= bpf_fill_alu32_sub_reg
,
13081 .nr_testruns
= NR_PATTERN_RUNS
,
13084 "ALU32_MUL_X: all register value magnitudes",
13086 INTERNAL
| FLAG_NO_DATA
,
13089 .fill_helper
= bpf_fill_alu32_mul_reg
,
13090 .nr_testruns
= NR_PATTERN_RUNS
,
13093 "ALU32_DIV_X: all register value magnitudes",
13095 INTERNAL
| FLAG_NO_DATA
,
13098 .fill_helper
= bpf_fill_alu32_div_reg
,
13099 .nr_testruns
= NR_PATTERN_RUNS
,
13102 "ALU32_MOD_X: all register value magnitudes",
13104 INTERNAL
| FLAG_NO_DATA
,
13107 .fill_helper
= bpf_fill_alu32_mod_reg
,
13108 .nr_testruns
= NR_PATTERN_RUNS
,
13110 /* LD_IMM64 immediate magnitudes and byte patterns */
13112 "LD_IMM64: all immediate value magnitudes",
13114 INTERNAL
| FLAG_NO_DATA
,
13117 .fill_helper
= bpf_fill_ld_imm64_magn
,
13120 "LD_IMM64: checker byte patterns",
13122 INTERNAL
| FLAG_NO_DATA
,
13125 .fill_helper
= bpf_fill_ld_imm64_checker
,
13128 "LD_IMM64: random positive and zero byte patterns",
13130 INTERNAL
| FLAG_NO_DATA
,
13133 .fill_helper
= bpf_fill_ld_imm64_pos_zero
,
13136 "LD_IMM64: random negative and zero byte patterns",
13138 INTERNAL
| FLAG_NO_DATA
,
13141 .fill_helper
= bpf_fill_ld_imm64_neg_zero
,
13144 "LD_IMM64: random positive and negative byte patterns",
13146 INTERNAL
| FLAG_NO_DATA
,
13149 .fill_helper
= bpf_fill_ld_imm64_pos_neg
,
13151 /* 64-bit ATOMIC register combinations */
13153 "ATOMIC_DW_ADD: register combinations",
13158 .fill_helper
= bpf_fill_atomic64_add_reg_pairs
,
13162 "ATOMIC_DW_AND: register combinations",
13167 .fill_helper
= bpf_fill_atomic64_and_reg_pairs
,
13171 "ATOMIC_DW_OR: register combinations",
13176 .fill_helper
= bpf_fill_atomic64_or_reg_pairs
,
13180 "ATOMIC_DW_XOR: register combinations",
13185 .fill_helper
= bpf_fill_atomic64_xor_reg_pairs
,
13189 "ATOMIC_DW_ADD_FETCH: register combinations",
13194 .fill_helper
= bpf_fill_atomic64_add_fetch_reg_pairs
,
13198 "ATOMIC_DW_AND_FETCH: register combinations",
13203 .fill_helper
= bpf_fill_atomic64_and_fetch_reg_pairs
,
13207 "ATOMIC_DW_OR_FETCH: register combinations",
13212 .fill_helper
= bpf_fill_atomic64_or_fetch_reg_pairs
,
13216 "ATOMIC_DW_XOR_FETCH: register combinations",
13221 .fill_helper
= bpf_fill_atomic64_xor_fetch_reg_pairs
,
13225 "ATOMIC_DW_XCHG: register combinations",
13230 .fill_helper
= bpf_fill_atomic64_xchg_reg_pairs
,
13234 "ATOMIC_DW_CMPXCHG: register combinations",
13239 .fill_helper
= bpf_fill_atomic64_cmpxchg_reg_pairs
,
13242 /* 32-bit ATOMIC register combinations */
13244 "ATOMIC_W_ADD: register combinations",
13249 .fill_helper
= bpf_fill_atomic32_add_reg_pairs
,
13253 "ATOMIC_W_AND: register combinations",
13258 .fill_helper
= bpf_fill_atomic32_and_reg_pairs
,
13262 "ATOMIC_W_OR: register combinations",
13267 .fill_helper
= bpf_fill_atomic32_or_reg_pairs
,
13271 "ATOMIC_W_XOR: register combinations",
13276 .fill_helper
= bpf_fill_atomic32_xor_reg_pairs
,
13280 "ATOMIC_W_ADD_FETCH: register combinations",
13285 .fill_helper
= bpf_fill_atomic32_add_fetch_reg_pairs
,
13289 "ATOMIC_W_AND_FETCH: register combinations",
13294 .fill_helper
= bpf_fill_atomic32_and_fetch_reg_pairs
,
13298 "ATOMIC_W_OR_FETCH: register combinations",
13303 .fill_helper
= bpf_fill_atomic32_or_fetch_reg_pairs
,
13307 "ATOMIC_W_XOR_FETCH: register combinations",
13312 .fill_helper
= bpf_fill_atomic32_xor_fetch_reg_pairs
,
13316 "ATOMIC_W_XCHG: register combinations",
13321 .fill_helper
= bpf_fill_atomic32_xchg_reg_pairs
,
13325 "ATOMIC_W_CMPXCHG: register combinations",
13330 .fill_helper
= bpf_fill_atomic32_cmpxchg_reg_pairs
,
13333 /* 64-bit ATOMIC magnitudes */
13335 "ATOMIC_DW_ADD: all operand magnitudes",
13337 INTERNAL
| FLAG_NO_DATA
,
13340 .fill_helper
= bpf_fill_atomic64_add
,
13342 .nr_testruns
= NR_PATTERN_RUNS
,
13345 "ATOMIC_DW_AND: all operand magnitudes",
13347 INTERNAL
| FLAG_NO_DATA
,
13350 .fill_helper
= bpf_fill_atomic64_and
,
13352 .nr_testruns
= NR_PATTERN_RUNS
,
13355 "ATOMIC_DW_OR: all operand magnitudes",
13357 INTERNAL
| FLAG_NO_DATA
,
13360 .fill_helper
= bpf_fill_atomic64_or
,
13362 .nr_testruns
= NR_PATTERN_RUNS
,
13365 "ATOMIC_DW_XOR: all operand magnitudes",
13367 INTERNAL
| FLAG_NO_DATA
,
13370 .fill_helper
= bpf_fill_atomic64_xor
,
13372 .nr_testruns
= NR_PATTERN_RUNS
,
13375 "ATOMIC_DW_ADD_FETCH: all operand magnitudes",
13377 INTERNAL
| FLAG_NO_DATA
,
13380 .fill_helper
= bpf_fill_atomic64_add_fetch
,
13382 .nr_testruns
= NR_PATTERN_RUNS
,
13385 "ATOMIC_DW_AND_FETCH: all operand magnitudes",
13387 INTERNAL
| FLAG_NO_DATA
,
13390 .fill_helper
= bpf_fill_atomic64_and_fetch
,
13392 .nr_testruns
= NR_PATTERN_RUNS
,
13395 "ATOMIC_DW_OR_FETCH: all operand magnitudes",
13397 INTERNAL
| FLAG_NO_DATA
,
13400 .fill_helper
= bpf_fill_atomic64_or_fetch
,
13402 .nr_testruns
= NR_PATTERN_RUNS
,
13405 "ATOMIC_DW_XOR_FETCH: all operand magnitudes",
13407 INTERNAL
| FLAG_NO_DATA
,
13410 .fill_helper
= bpf_fill_atomic64_xor_fetch
,
13412 .nr_testruns
= NR_PATTERN_RUNS
,
13415 "ATOMIC_DW_XCHG: all operand magnitudes",
13417 INTERNAL
| FLAG_NO_DATA
,
13420 .fill_helper
= bpf_fill_atomic64_xchg
,
13422 .nr_testruns
= NR_PATTERN_RUNS
,
13425 "ATOMIC_DW_CMPXCHG: all operand magnitudes",
13427 INTERNAL
| FLAG_NO_DATA
,
13430 .fill_helper
= bpf_fill_cmpxchg64
,
13432 .nr_testruns
= NR_PATTERN_RUNS
,
13434 /* 32-bit atomic magnitudes */
13436 "ATOMIC_W_ADD: all operand magnitudes",
13438 INTERNAL
| FLAG_NO_DATA
,
13441 .fill_helper
= bpf_fill_atomic32_add
,
13443 .nr_testruns
= NR_PATTERN_RUNS
,
13446 "ATOMIC_W_AND: all operand magnitudes",
13448 INTERNAL
| FLAG_NO_DATA
,
13451 .fill_helper
= bpf_fill_atomic32_and
,
13453 .nr_testruns
= NR_PATTERN_RUNS
,
13456 "ATOMIC_W_OR: all operand magnitudes",
13458 INTERNAL
| FLAG_NO_DATA
,
13461 .fill_helper
= bpf_fill_atomic32_or
,
13463 .nr_testruns
= NR_PATTERN_RUNS
,
13466 "ATOMIC_W_XOR: all operand magnitudes",
13468 INTERNAL
| FLAG_NO_DATA
,
13471 .fill_helper
= bpf_fill_atomic32_xor
,
13473 .nr_testruns
= NR_PATTERN_RUNS
,
13476 "ATOMIC_W_ADD_FETCH: all operand magnitudes",
13478 INTERNAL
| FLAG_NO_DATA
,
13481 .fill_helper
= bpf_fill_atomic32_add_fetch
,
13483 .nr_testruns
= NR_PATTERN_RUNS
,
13486 "ATOMIC_W_AND_FETCH: all operand magnitudes",
13488 INTERNAL
| FLAG_NO_DATA
,
13491 .fill_helper
= bpf_fill_atomic32_and_fetch
,
13493 .nr_testruns
= NR_PATTERN_RUNS
,
13496 "ATOMIC_W_OR_FETCH: all operand magnitudes",
13498 INTERNAL
| FLAG_NO_DATA
,
13501 .fill_helper
= bpf_fill_atomic32_or_fetch
,
13503 .nr_testruns
= NR_PATTERN_RUNS
,
13506 "ATOMIC_W_XOR_FETCH: all operand magnitudes",
13508 INTERNAL
| FLAG_NO_DATA
,
13511 .fill_helper
= bpf_fill_atomic32_xor_fetch
,
13513 .nr_testruns
= NR_PATTERN_RUNS
,
13516 "ATOMIC_W_XCHG: all operand magnitudes",
13518 INTERNAL
| FLAG_NO_DATA
,
13521 .fill_helper
= bpf_fill_atomic32_xchg
,
13523 .nr_testruns
= NR_PATTERN_RUNS
,
13526 "ATOMIC_W_CMPXCHG: all operand magnitudes",
13528 INTERNAL
| FLAG_NO_DATA
,
13531 .fill_helper
= bpf_fill_cmpxchg32
,
13533 .nr_testruns
= NR_PATTERN_RUNS
,
13535 /* JMP immediate magnitudes */
13537 "JMP_JSET_K: all immediate value magnitudes",
13539 INTERNAL
| FLAG_NO_DATA
,
13542 .fill_helper
= bpf_fill_jmp_jset_imm
,
13543 .nr_testruns
= NR_PATTERN_RUNS
,
13546 "JMP_JEQ_K: all immediate value magnitudes",
13548 INTERNAL
| FLAG_NO_DATA
,
13551 .fill_helper
= bpf_fill_jmp_jeq_imm
,
13552 .nr_testruns
= NR_PATTERN_RUNS
,
13555 "JMP_JNE_K: all immediate value magnitudes",
13557 INTERNAL
| FLAG_NO_DATA
,
13560 .fill_helper
= bpf_fill_jmp_jne_imm
,
13561 .nr_testruns
= NR_PATTERN_RUNS
,
13564 "JMP_JGT_K: all immediate value magnitudes",
13566 INTERNAL
| FLAG_NO_DATA
,
13569 .fill_helper
= bpf_fill_jmp_jgt_imm
,
13570 .nr_testruns
= NR_PATTERN_RUNS
,
13573 "JMP_JGE_K: all immediate value magnitudes",
13575 INTERNAL
| FLAG_NO_DATA
,
13578 .fill_helper
= bpf_fill_jmp_jge_imm
,
13579 .nr_testruns
= NR_PATTERN_RUNS
,
13582 "JMP_JLT_K: all immediate value magnitudes",
13584 INTERNAL
| FLAG_NO_DATA
,
13587 .fill_helper
= bpf_fill_jmp_jlt_imm
,
13588 .nr_testruns
= NR_PATTERN_RUNS
,
13591 "JMP_JLE_K: all immediate value magnitudes",
13593 INTERNAL
| FLAG_NO_DATA
,
13596 .fill_helper
= bpf_fill_jmp_jle_imm
,
13597 .nr_testruns
= NR_PATTERN_RUNS
,
13600 "JMP_JSGT_K: all immediate value magnitudes",
13602 INTERNAL
| FLAG_NO_DATA
,
13605 .fill_helper
= bpf_fill_jmp_jsgt_imm
,
13606 .nr_testruns
= NR_PATTERN_RUNS
,
13609 "JMP_JSGE_K: all immediate value magnitudes",
13611 INTERNAL
| FLAG_NO_DATA
,
13614 .fill_helper
= bpf_fill_jmp_jsge_imm
,
13615 .nr_testruns
= NR_PATTERN_RUNS
,
13618 "JMP_JSLT_K: all immediate value magnitudes",
13620 INTERNAL
| FLAG_NO_DATA
,
13623 .fill_helper
= bpf_fill_jmp_jslt_imm
,
13624 .nr_testruns
= NR_PATTERN_RUNS
,
13627 "JMP_JSLE_K: all immediate value magnitudes",
13629 INTERNAL
| FLAG_NO_DATA
,
13632 .fill_helper
= bpf_fill_jmp_jsle_imm
,
13633 .nr_testruns
= NR_PATTERN_RUNS
,
13635 /* JMP register magnitudes */
13637 "JMP_JSET_X: all register value magnitudes",
13639 INTERNAL
| FLAG_NO_DATA
,
13642 .fill_helper
= bpf_fill_jmp_jset_reg
,
13643 .nr_testruns
= NR_PATTERN_RUNS
,
13646 "JMP_JEQ_X: all register value magnitudes",
13648 INTERNAL
| FLAG_NO_DATA
,
13651 .fill_helper
= bpf_fill_jmp_jeq_reg
,
13652 .nr_testruns
= NR_PATTERN_RUNS
,
13655 "JMP_JNE_X: all register value magnitudes",
13657 INTERNAL
| FLAG_NO_DATA
,
13660 .fill_helper
= bpf_fill_jmp_jne_reg
,
13661 .nr_testruns
= NR_PATTERN_RUNS
,
13664 "JMP_JGT_X: all register value magnitudes",
13666 INTERNAL
| FLAG_NO_DATA
,
13669 .fill_helper
= bpf_fill_jmp_jgt_reg
,
13670 .nr_testruns
= NR_PATTERN_RUNS
,
13673 "JMP_JGE_X: all register value magnitudes",
13675 INTERNAL
| FLAG_NO_DATA
,
13678 .fill_helper
= bpf_fill_jmp_jge_reg
,
13679 .nr_testruns
= NR_PATTERN_RUNS
,
13682 "JMP_JLT_X: all register value magnitudes",
13684 INTERNAL
| FLAG_NO_DATA
,
13687 .fill_helper
= bpf_fill_jmp_jlt_reg
,
13688 .nr_testruns
= NR_PATTERN_RUNS
,
13691 "JMP_JLE_X: all register value magnitudes",
13693 INTERNAL
| FLAG_NO_DATA
,
13696 .fill_helper
= bpf_fill_jmp_jle_reg
,
13697 .nr_testruns
= NR_PATTERN_RUNS
,
13700 "JMP_JSGT_X: all register value magnitudes",
13702 INTERNAL
| FLAG_NO_DATA
,
13705 .fill_helper
= bpf_fill_jmp_jsgt_reg
,
13706 .nr_testruns
= NR_PATTERN_RUNS
,
13709 "JMP_JSGE_X: all register value magnitudes",
13711 INTERNAL
| FLAG_NO_DATA
,
13714 .fill_helper
= bpf_fill_jmp_jsge_reg
,
13715 .nr_testruns
= NR_PATTERN_RUNS
,
13718 "JMP_JSLT_X: all register value magnitudes",
13720 INTERNAL
| FLAG_NO_DATA
,
13723 .fill_helper
= bpf_fill_jmp_jslt_reg
,
13724 .nr_testruns
= NR_PATTERN_RUNS
,
13727 "JMP_JSLE_X: all register value magnitudes",
13729 INTERNAL
| FLAG_NO_DATA
,
13732 .fill_helper
= bpf_fill_jmp_jsle_reg
,
13733 .nr_testruns
= NR_PATTERN_RUNS
,
13735 /* JMP32 immediate magnitudes */
13737 "JMP32_JSET_K: all immediate value magnitudes",
13739 INTERNAL
| FLAG_NO_DATA
,
13742 .fill_helper
= bpf_fill_jmp32_jset_imm
,
13743 .nr_testruns
= NR_PATTERN_RUNS
,
13746 "JMP32_JEQ_K: all immediate value magnitudes",
13748 INTERNAL
| FLAG_NO_DATA
,
13751 .fill_helper
= bpf_fill_jmp32_jeq_imm
,
13752 .nr_testruns
= NR_PATTERN_RUNS
,
13755 "JMP32_JNE_K: all immediate value magnitudes",
13757 INTERNAL
| FLAG_NO_DATA
,
13760 .fill_helper
= bpf_fill_jmp32_jne_imm
,
13761 .nr_testruns
= NR_PATTERN_RUNS
,
13764 "JMP32_JGT_K: all immediate value magnitudes",
13766 INTERNAL
| FLAG_NO_DATA
,
13769 .fill_helper
= bpf_fill_jmp32_jgt_imm
,
13770 .nr_testruns
= NR_PATTERN_RUNS
,
13773 "JMP32_JGE_K: all immediate value magnitudes",
13775 INTERNAL
| FLAG_NO_DATA
,
13778 .fill_helper
= bpf_fill_jmp32_jge_imm
,
13779 .nr_testruns
= NR_PATTERN_RUNS
,
13782 "JMP32_JLT_K: all immediate value magnitudes",
13784 INTERNAL
| FLAG_NO_DATA
,
13787 .fill_helper
= bpf_fill_jmp32_jlt_imm
,
13788 .nr_testruns
= NR_PATTERN_RUNS
,
13791 "JMP32_JLE_K: all immediate value magnitudes",
13793 INTERNAL
| FLAG_NO_DATA
,
13796 .fill_helper
= bpf_fill_jmp32_jle_imm
,
13797 .nr_testruns
= NR_PATTERN_RUNS
,
13800 "JMP32_JSGT_K: all immediate value magnitudes",
13802 INTERNAL
| FLAG_NO_DATA
,
13805 .fill_helper
= bpf_fill_jmp32_jsgt_imm
,
13806 .nr_testruns
= NR_PATTERN_RUNS
,
13809 "JMP32_JSGE_K: all immediate value magnitudes",
13811 INTERNAL
| FLAG_NO_DATA
,
13814 .fill_helper
= bpf_fill_jmp32_jsge_imm
,
13815 .nr_testruns
= NR_PATTERN_RUNS
,
13818 "JMP32_JSLT_K: all immediate value magnitudes",
13820 INTERNAL
| FLAG_NO_DATA
,
13823 .fill_helper
= bpf_fill_jmp32_jslt_imm
,
13824 .nr_testruns
= NR_PATTERN_RUNS
,
13827 "JMP32_JSLE_K: all immediate value magnitudes",
13829 INTERNAL
| FLAG_NO_DATA
,
13832 .fill_helper
= bpf_fill_jmp32_jsle_imm
,
13833 .nr_testruns
= NR_PATTERN_RUNS
,
13835 /* JMP32 register magnitudes */
13837 "JMP32_JSET_X: all register value magnitudes",
13839 INTERNAL
| FLAG_NO_DATA
,
13842 .fill_helper
= bpf_fill_jmp32_jset_reg
,
13843 .nr_testruns
= NR_PATTERN_RUNS
,
13846 "JMP32_JEQ_X: all register value magnitudes",
13848 INTERNAL
| FLAG_NO_DATA
,
13851 .fill_helper
= bpf_fill_jmp32_jeq_reg
,
13852 .nr_testruns
= NR_PATTERN_RUNS
,
13855 "JMP32_JNE_X: all register value magnitudes",
13857 INTERNAL
| FLAG_NO_DATA
,
13860 .fill_helper
= bpf_fill_jmp32_jne_reg
,
13861 .nr_testruns
= NR_PATTERN_RUNS
,
13864 "JMP32_JGT_X: all register value magnitudes",
13866 INTERNAL
| FLAG_NO_DATA
,
13869 .fill_helper
= bpf_fill_jmp32_jgt_reg
,
13870 .nr_testruns
= NR_PATTERN_RUNS
,
13873 "JMP32_JGE_X: all register value magnitudes",
13875 INTERNAL
| FLAG_NO_DATA
,
13878 .fill_helper
= bpf_fill_jmp32_jge_reg
,
13879 .nr_testruns
= NR_PATTERN_RUNS
,
13882 "JMP32_JLT_X: all register value magnitudes",
13884 INTERNAL
| FLAG_NO_DATA
,
13887 .fill_helper
= bpf_fill_jmp32_jlt_reg
,
13888 .nr_testruns
= NR_PATTERN_RUNS
,
13891 "JMP32_JLE_X: all register value magnitudes",
13893 INTERNAL
| FLAG_NO_DATA
,
13896 .fill_helper
= bpf_fill_jmp32_jle_reg
,
13897 .nr_testruns
= NR_PATTERN_RUNS
,
13900 "JMP32_JSGT_X: all register value magnitudes",
13902 INTERNAL
| FLAG_NO_DATA
,
13905 .fill_helper
= bpf_fill_jmp32_jsgt_reg
,
13906 .nr_testruns
= NR_PATTERN_RUNS
,
13909 "JMP32_JSGE_X: all register value magnitudes",
13911 INTERNAL
| FLAG_NO_DATA
,
13914 .fill_helper
= bpf_fill_jmp32_jsge_reg
,
13915 .nr_testruns
= NR_PATTERN_RUNS
,
13918 "JMP32_JSLT_X: all register value magnitudes",
13920 INTERNAL
| FLAG_NO_DATA
,
13923 .fill_helper
= bpf_fill_jmp32_jslt_reg
,
13924 .nr_testruns
= NR_PATTERN_RUNS
,
13927 "JMP32_JSLE_X: all register value magnitudes",
13929 INTERNAL
| FLAG_NO_DATA
,
13932 .fill_helper
= bpf_fill_jmp32_jsle_reg
,
13933 .nr_testruns
= NR_PATTERN_RUNS
,
13935 /* Conditional jumps with constant decision */
13937 "JMP_JSET_K: imm = 0 -> never taken",
13939 BPF_ALU64_IMM(BPF_MOV
, R0
, 1),
13940 BPF_JMP_IMM(BPF_JSET
, R1
, 0, 1),
13941 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
13944 INTERNAL
| FLAG_NO_DATA
,
13949 "JMP_JLT_K: imm = 0 -> never taken",
13951 BPF_ALU64_IMM(BPF_MOV
, R0
, 1),
13952 BPF_JMP_IMM(BPF_JLT
, R1
, 0, 1),
13953 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
13956 INTERNAL
| FLAG_NO_DATA
,
13961 "JMP_JGE_K: imm = 0 -> always taken",
13963 BPF_ALU64_IMM(BPF_MOV
, R0
, 1),
13964 BPF_JMP_IMM(BPF_JGE
, R1
, 0, 1),
13965 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
13968 INTERNAL
| FLAG_NO_DATA
,
13973 "JMP_JGT_K: imm = 0xffffffff -> never taken",
13975 BPF_ALU64_IMM(BPF_MOV
, R0
, 1),
13976 BPF_JMP_IMM(BPF_JGT
, R1
, U32_MAX
, 1),
13977 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
13980 INTERNAL
| FLAG_NO_DATA
,
13985 "JMP_JLE_K: imm = 0xffffffff -> always taken",
13987 BPF_ALU64_IMM(BPF_MOV
, R0
, 1),
13988 BPF_JMP_IMM(BPF_JLE
, R1
, U32_MAX
, 1),
13989 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
13992 INTERNAL
| FLAG_NO_DATA
,
13997 "JMP32_JSGT_K: imm = 0x7fffffff -> never taken",
13999 BPF_ALU64_IMM(BPF_MOV
, R0
, 1),
14000 BPF_JMP32_IMM(BPF_JSGT
, R1
, S32_MAX
, 1),
14001 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
14004 INTERNAL
| FLAG_NO_DATA
,
14009 "JMP32_JSGE_K: imm = -0x80000000 -> always taken",
14011 BPF_ALU64_IMM(BPF_MOV
, R0
, 1),
14012 BPF_JMP32_IMM(BPF_JSGE
, R1
, S32_MIN
, 1),
14013 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
14016 INTERNAL
| FLAG_NO_DATA
,
14021 "JMP32_JSLT_K: imm = -0x80000000 -> never taken",
14023 BPF_ALU64_IMM(BPF_MOV
, R0
, 1),
14024 BPF_JMP32_IMM(BPF_JSLT
, R1
, S32_MIN
, 1),
14025 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
14028 INTERNAL
| FLAG_NO_DATA
,
14033 "JMP32_JSLE_K: imm = 0x7fffffff -> always taken",
14035 BPF_ALU64_IMM(BPF_MOV
, R0
, 1),
14036 BPF_JMP32_IMM(BPF_JSLE
, R1
, S32_MAX
, 1),
14037 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
14040 INTERNAL
| FLAG_NO_DATA
,
14045 "JMP_JEQ_X: dst = src -> always taken",
14047 BPF_ALU64_IMM(BPF_MOV
, R0
, 1),
14048 BPF_JMP_REG(BPF_JEQ
, R1
, R1
, 1),
14049 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
14052 INTERNAL
| FLAG_NO_DATA
,
14057 "JMP_JGE_X: dst = src -> always taken",
14059 BPF_ALU64_IMM(BPF_MOV
, R0
, 1),
14060 BPF_JMP_REG(BPF_JGE
, R1
, R1
, 1),
14061 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
14064 INTERNAL
| FLAG_NO_DATA
,
14069 "JMP_JLE_X: dst = src -> always taken",
14071 BPF_ALU64_IMM(BPF_MOV
, R0
, 1),
14072 BPF_JMP_REG(BPF_JLE
, R1
, R1
, 1),
14073 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
14076 INTERNAL
| FLAG_NO_DATA
,
14081 "JMP_JSGE_X: dst = src -> always taken",
14083 BPF_ALU64_IMM(BPF_MOV
, R0
, 1),
14084 BPF_JMP_REG(BPF_JSGE
, R1
, R1
, 1),
14085 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
14088 INTERNAL
| FLAG_NO_DATA
,
14093 "JMP_JSLE_X: dst = src -> always taken",
14095 BPF_ALU64_IMM(BPF_MOV
, R0
, 1),
14096 BPF_JMP_REG(BPF_JSLE
, R1
, R1
, 1),
14097 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
14100 INTERNAL
| FLAG_NO_DATA
,
14105 "JMP_JNE_X: dst = src -> never taken",
14107 BPF_ALU64_IMM(BPF_MOV
, R0
, 1),
14108 BPF_JMP_REG(BPF_JNE
, R1
, R1
, 1),
14109 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
14112 INTERNAL
| FLAG_NO_DATA
,
14117 "JMP_JGT_X: dst = src -> never taken",
14119 BPF_ALU64_IMM(BPF_MOV
, R0
, 1),
14120 BPF_JMP_REG(BPF_JGT
, R1
, R1
, 1),
14121 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
14124 INTERNAL
| FLAG_NO_DATA
,
14129 "JMP_JLT_X: dst = src -> never taken",
14131 BPF_ALU64_IMM(BPF_MOV
, R0
, 1),
14132 BPF_JMP_REG(BPF_JLT
, R1
, R1
, 1),
14133 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
14136 INTERNAL
| FLAG_NO_DATA
,
14141 "JMP_JSGT_X: dst = src -> never taken",
14143 BPF_ALU64_IMM(BPF_MOV
, R0
, 1),
14144 BPF_JMP_REG(BPF_JSGT
, R1
, R1
, 1),
14145 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
14148 INTERNAL
| FLAG_NO_DATA
,
14153 "JMP_JSLT_X: dst = src -> never taken",
14155 BPF_ALU64_IMM(BPF_MOV
, R0
, 1),
14156 BPF_JMP_REG(BPF_JSLT
, R1
, R1
, 1),
14157 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
14160 INTERNAL
| FLAG_NO_DATA
,
14164 /* Short relative jumps */
14166 "Short relative jump: offset=0",
14168 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
14169 BPF_JMP_IMM(BPF_JEQ
, R0
, 0, 0),
14171 BPF_ALU32_IMM(BPF_MOV
, R0
, -1),
14173 INTERNAL
| FLAG_NO_DATA
| FLAG_VERIFIER_ZEXT
,
14178 "Short relative jump: offset=1",
14180 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
14181 BPF_JMP_IMM(BPF_JEQ
, R0
, 0, 1),
14182 BPF_ALU32_IMM(BPF_ADD
, R0
, 1),
14184 BPF_ALU32_IMM(BPF_MOV
, R0
, -1),
14186 INTERNAL
| FLAG_NO_DATA
| FLAG_VERIFIER_ZEXT
,
14191 "Short relative jump: offset=2",
14193 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
14194 BPF_JMP_IMM(BPF_JEQ
, R0
, 0, 2),
14195 BPF_ALU32_IMM(BPF_ADD
, R0
, 1),
14196 BPF_ALU32_IMM(BPF_ADD
, R0
, 1),
14198 BPF_ALU32_IMM(BPF_MOV
, R0
, -1),
14200 INTERNAL
| FLAG_NO_DATA
| FLAG_VERIFIER_ZEXT
,
14205 "Short relative jump: offset=3",
14207 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
14208 BPF_JMP_IMM(BPF_JEQ
, R0
, 0, 3),
14209 BPF_ALU32_IMM(BPF_ADD
, R0
, 1),
14210 BPF_ALU32_IMM(BPF_ADD
, R0
, 1),
14211 BPF_ALU32_IMM(BPF_ADD
, R0
, 1),
14213 BPF_ALU32_IMM(BPF_MOV
, R0
, -1),
14215 INTERNAL
| FLAG_NO_DATA
| FLAG_VERIFIER_ZEXT
,
14220 "Short relative jump: offset=4",
14222 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
14223 BPF_JMP_IMM(BPF_JEQ
, R0
, 0, 4),
14224 BPF_ALU32_IMM(BPF_ADD
, R0
, 1),
14225 BPF_ALU32_IMM(BPF_ADD
, R0
, 1),
14226 BPF_ALU32_IMM(BPF_ADD
, R0
, 1),
14227 BPF_ALU32_IMM(BPF_ADD
, R0
, 1),
14229 BPF_ALU32_IMM(BPF_MOV
, R0
, -1),
14231 INTERNAL
| FLAG_NO_DATA
| FLAG_VERIFIER_ZEXT
,
14235 /* Conditional branch conversions */
14237 "Long conditional jump: taken at runtime",
14239 INTERNAL
| FLAG_NO_DATA
,
14242 .fill_helper
= bpf_fill_max_jmp_taken
,
14245 "Long conditional jump: not taken at runtime",
14247 INTERNAL
| FLAG_NO_DATA
,
14250 .fill_helper
= bpf_fill_max_jmp_not_taken
,
14253 "Long conditional jump: always taken, known at JIT time",
14255 INTERNAL
| FLAG_NO_DATA
,
14258 .fill_helper
= bpf_fill_max_jmp_always_taken
,
14261 "Long conditional jump: never taken, known at JIT time",
14263 INTERNAL
| FLAG_NO_DATA
,
14266 .fill_helper
= bpf_fill_max_jmp_never_taken
,
14268 /* Staggered jump sequences, immediate */
14270 "Staggered jumps: JMP_JA",
14272 INTERNAL
| FLAG_NO_DATA
,
14274 { { 0, MAX_STAGGERED_JMP_SIZE
+ 1 } },
14275 .fill_helper
= bpf_fill_staggered_ja
,
14276 .nr_testruns
= NR_STAGGERED_JMP_RUNS
,
14279 "Staggered jumps: JMP_JEQ_K",
14281 INTERNAL
| FLAG_NO_DATA
,
14283 { { 0, MAX_STAGGERED_JMP_SIZE
+ 1 } },
14284 .fill_helper
= bpf_fill_staggered_jeq_imm
,
14285 .nr_testruns
= NR_STAGGERED_JMP_RUNS
,
14288 "Staggered jumps: JMP_JNE_K",
14290 INTERNAL
| FLAG_NO_DATA
,
14292 { { 0, MAX_STAGGERED_JMP_SIZE
+ 1 } },
14293 .fill_helper
= bpf_fill_staggered_jne_imm
,
14294 .nr_testruns
= NR_STAGGERED_JMP_RUNS
,
14297 "Staggered jumps: JMP_JSET_K",
14299 INTERNAL
| FLAG_NO_DATA
,
14301 { { 0, MAX_STAGGERED_JMP_SIZE
+ 1 } },
14302 .fill_helper
= bpf_fill_staggered_jset_imm
,
14303 .nr_testruns
= NR_STAGGERED_JMP_RUNS
,
14306 "Staggered jumps: JMP_JGT_K",
14308 INTERNAL
| FLAG_NO_DATA
,
14310 { { 0, MAX_STAGGERED_JMP_SIZE
+ 1 } },
14311 .fill_helper
= bpf_fill_staggered_jgt_imm
,
14312 .nr_testruns
= NR_STAGGERED_JMP_RUNS
,
14315 "Staggered jumps: JMP_JGE_K",
14317 INTERNAL
| FLAG_NO_DATA
,
14319 { { 0, MAX_STAGGERED_JMP_SIZE
+ 1 } },
14320 .fill_helper
= bpf_fill_staggered_jge_imm
,
14321 .nr_testruns
= NR_STAGGERED_JMP_RUNS
,
14324 "Staggered jumps: JMP_JLT_K",
14326 INTERNAL
| FLAG_NO_DATA
,
14328 { { 0, MAX_STAGGERED_JMP_SIZE
+ 1 } },
14329 .fill_helper
= bpf_fill_staggered_jlt_imm
,
14330 .nr_testruns
= NR_STAGGERED_JMP_RUNS
,
14333 "Staggered jumps: JMP_JLE_K",
14335 INTERNAL
| FLAG_NO_DATA
,
14337 { { 0, MAX_STAGGERED_JMP_SIZE
+ 1 } },
14338 .fill_helper
= bpf_fill_staggered_jle_imm
,
14339 .nr_testruns
= NR_STAGGERED_JMP_RUNS
,
14342 "Staggered jumps: JMP_JSGT_K",
14344 INTERNAL
| FLAG_NO_DATA
,
14346 { { 0, MAX_STAGGERED_JMP_SIZE
+ 1 } },
14347 .fill_helper
= bpf_fill_staggered_jsgt_imm
,
14348 .nr_testruns
= NR_STAGGERED_JMP_RUNS
,
14351 "Staggered jumps: JMP_JSGE_K",
14353 INTERNAL
| FLAG_NO_DATA
,
14355 { { 0, MAX_STAGGERED_JMP_SIZE
+ 1 } },
14356 .fill_helper
= bpf_fill_staggered_jsge_imm
,
14357 .nr_testruns
= NR_STAGGERED_JMP_RUNS
,
14360 "Staggered jumps: JMP_JSLT_K",
14362 INTERNAL
| FLAG_NO_DATA
,
14364 { { 0, MAX_STAGGERED_JMP_SIZE
+ 1 } },
14365 .fill_helper
= bpf_fill_staggered_jslt_imm
,
14366 .nr_testruns
= NR_STAGGERED_JMP_RUNS
,
14369 "Staggered jumps: JMP_JSLE_K",
14371 INTERNAL
| FLAG_NO_DATA
,
14373 { { 0, MAX_STAGGERED_JMP_SIZE
+ 1 } },
14374 .fill_helper
= bpf_fill_staggered_jsle_imm
,
14375 .nr_testruns
= NR_STAGGERED_JMP_RUNS
,
14377 /* Staggered jump sequences, register */
14379 "Staggered jumps: JMP_JEQ_X",
14381 INTERNAL
| FLAG_NO_DATA
,
14383 { { 0, MAX_STAGGERED_JMP_SIZE
+ 1 } },
14384 .fill_helper
= bpf_fill_staggered_jeq_reg
,
14385 .nr_testruns
= NR_STAGGERED_JMP_RUNS
,
14388 "Staggered jumps: JMP_JNE_X",
14390 INTERNAL
| FLAG_NO_DATA
,
14392 { { 0, MAX_STAGGERED_JMP_SIZE
+ 1 } },
14393 .fill_helper
= bpf_fill_staggered_jne_reg
,
14394 .nr_testruns
= NR_STAGGERED_JMP_RUNS
,
14397 "Staggered jumps: JMP_JSET_X",
14399 INTERNAL
| FLAG_NO_DATA
,
14401 { { 0, MAX_STAGGERED_JMP_SIZE
+ 1 } },
14402 .fill_helper
= bpf_fill_staggered_jset_reg
,
14403 .nr_testruns
= NR_STAGGERED_JMP_RUNS
,
14406 "Staggered jumps: JMP_JGT_X",
14408 INTERNAL
| FLAG_NO_DATA
,
14410 { { 0, MAX_STAGGERED_JMP_SIZE
+ 1 } },
14411 .fill_helper
= bpf_fill_staggered_jgt_reg
,
14412 .nr_testruns
= NR_STAGGERED_JMP_RUNS
,
14415 "Staggered jumps: JMP_JGE_X",
14417 INTERNAL
| FLAG_NO_DATA
,
14419 { { 0, MAX_STAGGERED_JMP_SIZE
+ 1 } },
14420 .fill_helper
= bpf_fill_staggered_jge_reg
,
14421 .nr_testruns
= NR_STAGGERED_JMP_RUNS
,
14424 "Staggered jumps: JMP_JLT_X",
14426 INTERNAL
| FLAG_NO_DATA
,
14428 { { 0, MAX_STAGGERED_JMP_SIZE
+ 1 } },
14429 .fill_helper
= bpf_fill_staggered_jlt_reg
,
14430 .nr_testruns
= NR_STAGGERED_JMP_RUNS
,
14433 "Staggered jumps: JMP_JLE_X",
14435 INTERNAL
| FLAG_NO_DATA
,
14437 { { 0, MAX_STAGGERED_JMP_SIZE
+ 1 } },
14438 .fill_helper
= bpf_fill_staggered_jle_reg
,
14439 .nr_testruns
= NR_STAGGERED_JMP_RUNS
,
14442 "Staggered jumps: JMP_JSGT_X",
14444 INTERNAL
| FLAG_NO_DATA
,
14446 { { 0, MAX_STAGGERED_JMP_SIZE
+ 1 } },
14447 .fill_helper
= bpf_fill_staggered_jsgt_reg
,
14448 .nr_testruns
= NR_STAGGERED_JMP_RUNS
,
14451 "Staggered jumps: JMP_JSGE_X",
14453 INTERNAL
| FLAG_NO_DATA
,
14455 { { 0, MAX_STAGGERED_JMP_SIZE
+ 1 } },
14456 .fill_helper
= bpf_fill_staggered_jsge_reg
,
14457 .nr_testruns
= NR_STAGGERED_JMP_RUNS
,
14460 "Staggered jumps: JMP_JSLT_X",
14462 INTERNAL
| FLAG_NO_DATA
,
14464 { { 0, MAX_STAGGERED_JMP_SIZE
+ 1 } },
14465 .fill_helper
= bpf_fill_staggered_jslt_reg
,
14466 .nr_testruns
= NR_STAGGERED_JMP_RUNS
,
14469 "Staggered jumps: JMP_JSLE_X",
14471 INTERNAL
| FLAG_NO_DATA
,
14473 { { 0, MAX_STAGGERED_JMP_SIZE
+ 1 } },
14474 .fill_helper
= bpf_fill_staggered_jsle_reg
,
14475 .nr_testruns
= NR_STAGGERED_JMP_RUNS
,
14477 /* Staggered jump sequences, JMP32 immediate */
14479 "Staggered jumps: JMP32_JEQ_K",
14481 INTERNAL
| FLAG_NO_DATA
,
14483 { { 0, MAX_STAGGERED_JMP_SIZE
+ 1 } },
14484 .fill_helper
= bpf_fill_staggered_jeq32_imm
,
14485 .nr_testruns
= NR_STAGGERED_JMP_RUNS
,
14488 "Staggered jumps: JMP32_JNE_K",
14490 INTERNAL
| FLAG_NO_DATA
,
14492 { { 0, MAX_STAGGERED_JMP_SIZE
+ 1 } },
14493 .fill_helper
= bpf_fill_staggered_jne32_imm
,
14494 .nr_testruns
= NR_STAGGERED_JMP_RUNS
,
14497 "Staggered jumps: JMP32_JSET_K",
14499 INTERNAL
| FLAG_NO_DATA
,
14501 { { 0, MAX_STAGGERED_JMP_SIZE
+ 1 } },
14502 .fill_helper
= bpf_fill_staggered_jset32_imm
,
14503 .nr_testruns
= NR_STAGGERED_JMP_RUNS
,
14506 "Staggered jumps: JMP32_JGT_K",
14508 INTERNAL
| FLAG_NO_DATA
,
14510 { { 0, MAX_STAGGERED_JMP_SIZE
+ 1 } },
14511 .fill_helper
= bpf_fill_staggered_jgt32_imm
,
14512 .nr_testruns
= NR_STAGGERED_JMP_RUNS
,
14515 "Staggered jumps: JMP32_JGE_K",
14517 INTERNAL
| FLAG_NO_DATA
,
14519 { { 0, MAX_STAGGERED_JMP_SIZE
+ 1 } },
14520 .fill_helper
= bpf_fill_staggered_jge32_imm
,
14521 .nr_testruns
= NR_STAGGERED_JMP_RUNS
,
14524 "Staggered jumps: JMP32_JLT_K",
14526 INTERNAL
| FLAG_NO_DATA
,
14528 { { 0, MAX_STAGGERED_JMP_SIZE
+ 1 } },
14529 .fill_helper
= bpf_fill_staggered_jlt32_imm
,
14530 .nr_testruns
= NR_STAGGERED_JMP_RUNS
,
14533 "Staggered jumps: JMP32_JLE_K",
14535 INTERNAL
| FLAG_NO_DATA
,
14537 { { 0, MAX_STAGGERED_JMP_SIZE
+ 1 } },
14538 .fill_helper
= bpf_fill_staggered_jle32_imm
,
14539 .nr_testruns
= NR_STAGGERED_JMP_RUNS
,
14542 "Staggered jumps: JMP32_JSGT_K",
14544 INTERNAL
| FLAG_NO_DATA
,
14546 { { 0, MAX_STAGGERED_JMP_SIZE
+ 1 } },
14547 .fill_helper
= bpf_fill_staggered_jsgt32_imm
,
14548 .nr_testruns
= NR_STAGGERED_JMP_RUNS
,
14551 "Staggered jumps: JMP32_JSGE_K",
14553 INTERNAL
| FLAG_NO_DATA
,
14555 { { 0, MAX_STAGGERED_JMP_SIZE
+ 1 } },
14556 .fill_helper
= bpf_fill_staggered_jsge32_imm
,
14557 .nr_testruns
= NR_STAGGERED_JMP_RUNS
,
14560 "Staggered jumps: JMP32_JSLT_K",
14562 INTERNAL
| FLAG_NO_DATA
,
14564 { { 0, MAX_STAGGERED_JMP_SIZE
+ 1 } },
14565 .fill_helper
= bpf_fill_staggered_jslt32_imm
,
14566 .nr_testruns
= NR_STAGGERED_JMP_RUNS
,
14569 "Staggered jumps: JMP32_JSLE_K",
14571 INTERNAL
| FLAG_NO_DATA
,
14573 { { 0, MAX_STAGGERED_JMP_SIZE
+ 1 } },
14574 .fill_helper
= bpf_fill_staggered_jsle32_imm
,
14575 .nr_testruns
= NR_STAGGERED_JMP_RUNS
,
14577 /* Staggered jump sequences, JMP32 register */
14579 "Staggered jumps: JMP32_JEQ_X",
14581 INTERNAL
| FLAG_NO_DATA
,
14583 { { 0, MAX_STAGGERED_JMP_SIZE
+ 1 } },
14584 .fill_helper
= bpf_fill_staggered_jeq32_reg
,
14585 .nr_testruns
= NR_STAGGERED_JMP_RUNS
,
14588 "Staggered jumps: JMP32_JNE_X",
14590 INTERNAL
| FLAG_NO_DATA
,
14592 { { 0, MAX_STAGGERED_JMP_SIZE
+ 1 } },
14593 .fill_helper
= bpf_fill_staggered_jne32_reg
,
14594 .nr_testruns
= NR_STAGGERED_JMP_RUNS
,
14597 "Staggered jumps: JMP32_JSET_X",
14599 INTERNAL
| FLAG_NO_DATA
,
14601 { { 0, MAX_STAGGERED_JMP_SIZE
+ 1 } },
14602 .fill_helper
= bpf_fill_staggered_jset32_reg
,
14603 .nr_testruns
= NR_STAGGERED_JMP_RUNS
,
14606 "Staggered jumps: JMP32_JGT_X",
14608 INTERNAL
| FLAG_NO_DATA
,
14610 { { 0, MAX_STAGGERED_JMP_SIZE
+ 1 } },
14611 .fill_helper
= bpf_fill_staggered_jgt32_reg
,
14612 .nr_testruns
= NR_STAGGERED_JMP_RUNS
,
14615 "Staggered jumps: JMP32_JGE_X",
14617 INTERNAL
| FLAG_NO_DATA
,
14619 { { 0, MAX_STAGGERED_JMP_SIZE
+ 1 } },
14620 .fill_helper
= bpf_fill_staggered_jge32_reg
,
14621 .nr_testruns
= NR_STAGGERED_JMP_RUNS
,
14624 "Staggered jumps: JMP32_JLT_X",
14626 INTERNAL
| FLAG_NO_DATA
,
14628 { { 0, MAX_STAGGERED_JMP_SIZE
+ 1 } },
14629 .fill_helper
= bpf_fill_staggered_jlt32_reg
,
14630 .nr_testruns
= NR_STAGGERED_JMP_RUNS
,
14633 "Staggered jumps: JMP32_JLE_X",
14635 INTERNAL
| FLAG_NO_DATA
,
14637 { { 0, MAX_STAGGERED_JMP_SIZE
+ 1 } },
14638 .fill_helper
= bpf_fill_staggered_jle32_reg
,
14639 .nr_testruns
= NR_STAGGERED_JMP_RUNS
,
14642 "Staggered jumps: JMP32_JSGT_X",
14644 INTERNAL
| FLAG_NO_DATA
,
14646 { { 0, MAX_STAGGERED_JMP_SIZE
+ 1 } },
14647 .fill_helper
= bpf_fill_staggered_jsgt32_reg
,
14648 .nr_testruns
= NR_STAGGERED_JMP_RUNS
,
14651 "Staggered jumps: JMP32_JSGE_X",
14653 INTERNAL
| FLAG_NO_DATA
,
14655 { { 0, MAX_STAGGERED_JMP_SIZE
+ 1 } },
14656 .fill_helper
= bpf_fill_staggered_jsge32_reg
,
14657 .nr_testruns
= NR_STAGGERED_JMP_RUNS
,
14660 "Staggered jumps: JMP32_JSLT_X",
14662 INTERNAL
| FLAG_NO_DATA
,
14664 { { 0, MAX_STAGGERED_JMP_SIZE
+ 1 } },
14665 .fill_helper
= bpf_fill_staggered_jslt32_reg
,
14666 .nr_testruns
= NR_STAGGERED_JMP_RUNS
,
14669 "Staggered jumps: JMP32_JSLE_X",
14671 INTERNAL
| FLAG_NO_DATA
,
14673 { { 0, MAX_STAGGERED_JMP_SIZE
+ 1 } },
14674 .fill_helper
= bpf_fill_staggered_jsle32_reg
,
14675 .nr_testruns
= NR_STAGGERED_JMP_RUNS
,
14679 static struct net_device dev
;
14681 static struct sk_buff
*populate_skb(char *buf
, int size
)
14683 struct sk_buff
*skb
;
14685 if (size
>= MAX_DATA
)
14688 skb
= alloc_skb(MAX_DATA
, GFP_KERNEL
);
14692 __skb_put_data(skb
, buf
, size
);
14694 /* Initialize a fake skb with test pattern. */
14695 skb_reset_mac_header(skb
);
14696 skb
->protocol
= htons(ETH_P_IP
);
14697 skb
->pkt_type
= SKB_TYPE
;
14698 skb
->mark
= SKB_MARK
;
14699 skb
->hash
= SKB_HASH
;
14700 skb
->queue_mapping
= SKB_QUEUE_MAP
;
14701 skb
->vlan_tci
= SKB_VLAN_TCI
;
14702 skb
->vlan_proto
= htons(ETH_P_IP
);
14703 dev_net_set(&dev
, &init_net
);
14705 skb
->dev
->ifindex
= SKB_DEV_IFINDEX
;
14706 skb
->dev
->type
= SKB_DEV_TYPE
;
14707 skb_set_network_header(skb
, min(size
, ETH_HLEN
));
14712 static void *generate_test_data(struct bpf_test
*test
, int sub
)
14714 struct sk_buff
*skb
;
14717 if (test
->aux
& FLAG_NO_DATA
)
14720 if (test
->aux
& FLAG_LARGE_MEM
)
14721 return kmalloc(test
->test
[sub
].data_size
, GFP_KERNEL
);
14723 /* Test case expects an skb, so populate one. Various
14724 * subtests generate skbs of different sizes based on
14727 skb
= populate_skb(test
->data
, test
->test
[sub
].data_size
);
14731 if (test
->aux
& FLAG_SKB_FRAG
) {
14733 * when the test requires a fragmented skb, add a
14734 * single fragment to the skb, filled with
14737 page
= alloc_page(GFP_KERNEL
);
14739 goto err_kfree_skb
;
14741 memcpy(page_address(page
), test
->frag_data
, MAX_DATA
);
14742 skb_add_rx_frag(skb
, 0, page
, 0, MAX_DATA
, MAX_DATA
);
14751 static void release_test_data(const struct bpf_test
*test
, void *data
)
14753 if (test
->aux
& FLAG_NO_DATA
)
14756 if (test
->aux
& FLAG_LARGE_MEM
)
14762 static int filter_length(int which
)
14764 struct sock_filter
*fp
;
14767 if (tests
[which
].fill_helper
)
14768 return tests
[which
].u
.ptr
.len
;
14770 fp
= tests
[which
].u
.insns
;
14771 for (len
= MAX_INSNS
- 1; len
> 0; --len
)
14772 if (fp
[len
].code
!= 0 || fp
[len
].k
!= 0)
14778 static void *filter_pointer(int which
)
14780 if (tests
[which
].fill_helper
)
14781 return tests
[which
].u
.ptr
.insns
;
14783 return tests
[which
].u
.insns
;
14786 static struct bpf_prog
*generate_filter(int which
, int *err
)
14788 __u8 test_type
= tests
[which
].aux
& TEST_TYPE_MASK
;
14789 unsigned int flen
= filter_length(which
);
14790 void *fptr
= filter_pointer(which
);
14791 struct sock_fprog_kern fprog
;
14792 struct bpf_prog
*fp
;
14794 switch (test_type
) {
14796 fprog
.filter
= fptr
;
14799 *err
= bpf_prog_create(&fp
, &fprog
);
14800 if (tests
[which
].aux
& FLAG_EXPECTED_FAIL
) {
14801 if (*err
== tests
[which
].expected_errcode
) {
14803 /* Verifier rejected filter as expected. */
14807 pr_cont("UNEXPECTED_PASS\n");
14808 /* Verifier didn't reject the test that's
14809 * bad enough, just return!
14816 pr_cont("FAIL to prog_create err=%d len=%d\n",
14823 fp
= bpf_prog_alloc(bpf_prog_size(flen
), 0);
14825 pr_cont("UNEXPECTED_FAIL no memory left\n");
14831 /* Type doesn't really matter here as long as it's not unspec. */
14832 fp
->type
= BPF_PROG_TYPE_SOCKET_FILTER
;
14833 memcpy(fp
->insnsi
, fptr
, fp
->len
* sizeof(struct bpf_insn
));
14834 fp
->aux
->stack_depth
= tests
[which
].stack_depth
;
14835 fp
->aux
->verifier_zext
= !!(tests
[which
].aux
&
14836 FLAG_VERIFIER_ZEXT
);
14838 /* We cannot error here as we don't need type compatibility
14841 fp
= bpf_prog_select_runtime(fp
, err
);
14843 pr_cont("FAIL to select_runtime err=%d\n", *err
);
14853 static void release_filter(struct bpf_prog
*fp
, int which
)
14855 __u8 test_type
= tests
[which
].aux
& TEST_TYPE_MASK
;
14857 switch (test_type
) {
14859 bpf_prog_destroy(fp
);
14867 static int __run_one(const struct bpf_prog
*fp
, const void *data
,
14868 int runs
, u64
*duration
)
14874 start
= ktime_get_ns();
14876 for (i
= 0; i
< runs
; i
++)
14877 ret
= bpf_prog_run(fp
, data
);
14879 finish
= ktime_get_ns();
14882 *duration
= finish
- start
;
14883 do_div(*duration
, runs
);
14888 static int run_one(const struct bpf_prog
*fp
, struct bpf_test
*test
)
14890 int err_cnt
= 0, i
, runs
= MAX_TESTRUNS
;
14892 if (test
->nr_testruns
)
14893 runs
= min(test
->nr_testruns
, MAX_TESTRUNS
);
14895 for (i
= 0; i
< MAX_SUBTESTS
; i
++) {
14901 * NOTE: Several sub-tests may be present, in which case
14902 * a zero {data_size, result} tuple indicates the end of
14903 * the sub-test array. The first test is always run,
14904 * even if both data_size and result happen to be zero.
14907 test
->test
[i
].data_size
== 0 &&
14908 test
->test
[i
].result
== 0)
14911 data
= generate_test_data(test
, i
);
14912 if (!data
&& !(test
->aux
& FLAG_NO_DATA
)) {
14913 pr_cont("data generation failed ");
14917 ret
= __run_one(fp
, data
, runs
, &duration
);
14918 release_test_data(test
, data
);
14920 if (ret
== test
->test
[i
].result
) {
14921 pr_cont("%lld ", duration
);
14923 s32 res
= test
->test
[i
].result
;
14925 pr_cont("ret %d != %d (%#x != %#x)",
14926 ret
, res
, ret
, res
);
14934 static char test_name
[64];
14935 module_param_string(test_name
, test_name
, sizeof(test_name
), 0);
14937 static int test_id
= -1;
14938 module_param(test_id
, int, 0);
14940 static int test_range
[2] = { 0, INT_MAX
};
14941 module_param_array(test_range
, int, NULL
, 0);
14943 static bool exclude_test(int test_id
)
14945 return test_id
< test_range
[0] || test_id
> test_range
[1];
14948 static __init
struct sk_buff
*build_test_skb(void)
14950 u32 headroom
= NET_SKB_PAD
+ NET_IP_ALIGN
+ ETH_HLEN
;
14951 struct sk_buff
*skb
[2];
14952 struct page
*page
[2];
14953 int i
, data_size
= 8;
14955 for (i
= 0; i
< 2; i
++) {
14956 page
[i
] = alloc_page(GFP_KERNEL
);
14964 /* this will set skb[i]->head_frag */
14965 skb
[i
] = dev_alloc_skb(headroom
+ data_size
);
14973 skb_reserve(skb
[i
], headroom
);
14974 skb_put(skb
[i
], data_size
);
14975 skb
[i
]->protocol
= htons(ETH_P_IP
);
14976 skb_reset_network_header(skb
[i
]);
14977 skb_set_mac_header(skb
[i
], -ETH_HLEN
);
14979 skb_add_rx_frag(skb
[i
], 0, page
[i
], 0, 64, 64);
14980 // skb_headlen(skb[i]): 8, skb[i]->head_frag = 1
14984 skb_shinfo(skb
[0])->gso_size
= 1448;
14985 skb_shinfo(skb
[0])->gso_type
= SKB_GSO_TCPV4
;
14986 skb_shinfo(skb
[0])->gso_type
|= SKB_GSO_DODGY
;
14987 skb_shinfo(skb
[0])->gso_segs
= 0;
14988 skb_shinfo(skb
[0])->frag_list
= skb
[1];
14989 skb_shinfo(skb
[0])->hwtstamps
.hwtstamp
= 1000;
14991 /* adjust skb[0]'s len */
14992 skb
[0]->len
+= skb
[1]->len
;
14993 skb
[0]->data_len
+= skb
[1]->data_len
;
14994 skb
[0]->truesize
+= skb
[1]->truesize
;
14999 __free_page(page
[1]);
15003 __free_page(page
[0]);
15008 static __init
struct sk_buff
*build_test_skb_linear_no_head_frag(void)
15010 unsigned int alloc_size
= 2000;
15011 unsigned int headroom
= 102, doffset
= 72, data_size
= 1308;
15012 struct sk_buff
*skb
[2];
15015 /* skbs linked in a frag_list, both with linear data, with head_frag=0
15016 * (data allocated by kmalloc), both have tcp data of 1308 bytes
15017 * (total payload is 2616 bytes).
15018 * Data offset is 72 bytes (40 ipv6 hdr, 32 tcp hdr). Some headroom.
15020 for (i
= 0; i
< 2; i
++) {
15021 skb
[i
] = alloc_skb(alloc_size
, GFP_KERNEL
);
15029 skb
[i
]->protocol
= htons(ETH_P_IPV6
);
15030 skb_reserve(skb
[i
], headroom
);
15031 skb_put(skb
[i
], doffset
+ data_size
);
15032 skb_reset_network_header(skb
[i
]);
15034 skb_reset_mac_header(skb
[i
]);
15036 skb_set_mac_header(skb
[i
], -ETH_HLEN
);
15037 __skb_pull(skb
[i
], doffset
);
15041 * mimic bpf_skb_proto_4_to_6, which resets gso_segs and assigns a
15042 * reduced gso_size.
15044 skb_shinfo(skb
[0])->gso_size
= 1288;
15045 skb_shinfo(skb
[0])->gso_type
= SKB_GSO_TCPV6
| SKB_GSO_DODGY
;
15046 skb_shinfo(skb
[0])->gso_segs
= 0;
15047 skb_shinfo(skb
[0])->frag_list
= skb
[1];
15049 /* adjust skb[0]'s len */
15050 skb
[0]->len
+= skb
[1]->len
;
15051 skb
[0]->data_len
+= skb
[1]->len
;
15052 skb
[0]->truesize
+= skb
[1]->truesize
;
15062 struct skb_segment_test
{
15064 struct sk_buff
*(*build_skb
)(void);
15065 netdev_features_t features
;
15068 static struct skb_segment_test skb_segment_tests
[] __initconst
= {
15070 .descr
= "gso_with_rx_frags",
15071 .build_skb
= build_test_skb
,
15072 .features
= NETIF_F_SG
| NETIF_F_GSO_PARTIAL
| NETIF_F_IP_CSUM
|
15073 NETIF_F_IPV6_CSUM
| NETIF_F_RXCSUM
15076 .descr
= "gso_linear_no_head_frag",
15077 .build_skb
= build_test_skb_linear_no_head_frag
,
15078 .features
= NETIF_F_SG
| NETIF_F_FRAGLIST
|
15079 NETIF_F_HW_VLAN_CTAG_TX
| NETIF_F_GSO
|
15080 NETIF_F_GRO
| NETIF_F_IPV6_CSUM
| NETIF_F_RXCSUM
|
15081 NETIF_F_HW_VLAN_STAG_TX
15085 static __init
int test_skb_segment_single(const struct skb_segment_test
*test
)
15087 struct sk_buff
*skb
, *segs
;
15090 skb
= test
->build_skb();
15092 pr_info("%s: failed to build_test_skb", __func__
);
15096 segs
= skb_segment(skb
, test
->features
);
15097 if (!IS_ERR(segs
)) {
15098 kfree_skb_list(segs
);
15106 static __init
int test_skb_segment(void)
15108 int i
, err_cnt
= 0, pass_cnt
= 0;
15110 for (i
= 0; i
< ARRAY_SIZE(skb_segment_tests
); i
++) {
15111 const struct skb_segment_test
*test
= &skb_segment_tests
[i
];
15114 if (exclude_test(i
))
15117 pr_info("#%d %s ", i
, test
->descr
);
15119 if (test_skb_segment_single(test
)) {
15128 pr_info("%s: Summary: %d PASSED, %d FAILED\n", __func__
,
15129 pass_cnt
, err_cnt
);
15130 return err_cnt
? -EINVAL
: 0;
15133 static __init
int test_bpf(void)
15135 int i
, err_cnt
= 0, pass_cnt
= 0;
15136 int jit_cnt
= 0, run_cnt
= 0;
15138 for (i
= 0; i
< ARRAY_SIZE(tests
); i
++) {
15139 struct bpf_prog
*fp
;
15143 if (exclude_test(i
))
15146 pr_info("#%d %s ", i
, tests
[i
].descr
);
15148 if (tests
[i
].fill_helper
&&
15149 tests
[i
].fill_helper(&tests
[i
]) < 0) {
15150 pr_cont("FAIL to prog_fill\n");
15154 fp
= generate_filter(i
, &err
);
15156 if (tests
[i
].fill_helper
) {
15157 kfree(tests
[i
].u
.ptr
.insns
);
15158 tests
[i
].u
.ptr
.insns
= NULL
;
15170 pr_cont("jited:%u ", fp
->jited
);
15176 err
= run_one(fp
, &tests
[i
]);
15177 release_filter(fp
, i
);
15180 pr_cont("FAIL (%d times)\n", err
);
15188 pr_info("Summary: %d PASSED, %d FAILED, [%d/%d JIT'ed]\n",
15189 pass_cnt
, err_cnt
, jit_cnt
, run_cnt
);
15191 return err_cnt
? -EINVAL
: 0;
15194 struct tail_call_test
{
15196 struct bpf_insn insns
[MAX_INSNS
];
15200 bool has_tail_call
;
15203 /* Flags that can be passed to tail call test cases */
15204 #define FLAG_NEED_STATE BIT(0)
15205 #define FLAG_RESULT_IN_STATE BIT(1)
15208 * Magic marker used in test snippets for tail calls below.
15209 * BPF_LD/MOV to R2 and R2 with this immediate value is replaced
15210 * with the proper values by the test runner.
15212 #define TAIL_CALL_MARKER 0x7a11ca11
15214 /* Special offset to indicate a NULL call target */
15215 #define TAIL_CALL_NULL 0x7fff
15217 /* Special offset to indicate an out-of-range index */
15218 #define TAIL_CALL_INVALID 0x7ffe
15220 #define TAIL_CALL(offset) \
15221 BPF_LD_IMM64(R2, TAIL_CALL_MARKER), \
15222 BPF_RAW_INSN(BPF_ALU | BPF_MOV | BPF_K, R3, 0, \
15223 offset, TAIL_CALL_MARKER), \
15224 BPF_JMP_IMM(BPF_TAIL_CALL, 0, 0, 0)
15227 * A test function to be called from a BPF program, clobbering a lot of
15228 * CPU registers in the process. A JITed BPF program calling this function
15229 * must save and restore any caller-saved registers it uses for internal
15230 * state, for example the current tail call count.
15232 BPF_CALL_1(bpf_test_func
, u64
, arg
)
15244 return snprintf(buf
, sizeof(buf
),
15245 "%ld %lu %lx %ld %lu %lx %ld %lu %x",
15246 a
, b
, c
, d
, e
, f
, g
, h
, (int)arg
);
15248 #define BPF_FUNC_test_func __BPF_FUNC_MAX_ID
15251 * Tail call tests. Each test case may call any other test in the table,
15252 * including itself, specified as a relative index offset from the calling
15253 * test. The index TAIL_CALL_NULL can be used to specify a NULL target
15254 * function to test the JIT error path. Similarly, the index TAIL_CALL_INVALID
15255 * results in a target index that is out of range.
15257 static struct tail_call_test tail_call_tests
[] = {
15261 BPF_ALU64_REG(BPF_MOV
, R0
, R1
),
15262 BPF_ALU64_IMM(BPF_ADD
, R0
, 1),
15270 BPF_ALU64_IMM(BPF_ADD
, R1
, 2),
15272 BPF_ALU64_IMM(BPF_MOV
, R0
, -1),
15276 .has_tail_call
= true,
15281 BPF_ALU64_IMM(BPF_ADD
, R1
, 3),
15283 BPF_ALU64_IMM(BPF_MOV
, R0
, -1),
15287 .has_tail_call
= true,
15292 BPF_ALU64_IMM(BPF_ADD
, R1
, 4),
15294 BPF_ALU64_IMM(BPF_MOV
, R0
, -1),
15298 .has_tail_call
= true,
15301 "Tail call load/store leaf",
15303 BPF_ALU64_IMM(BPF_MOV
, R1
, 1),
15304 BPF_ALU64_IMM(BPF_MOV
, R2
, 2),
15305 BPF_ALU64_REG(BPF_MOV
, R3
, BPF_REG_FP
),
15306 BPF_STX_MEM(BPF_DW
, R3
, R1
, -8),
15307 BPF_STX_MEM(BPF_DW
, R3
, R2
, -16),
15308 BPF_LDX_MEM(BPF_DW
, R0
, BPF_REG_FP
, -8),
15309 BPF_JMP_REG(BPF_JNE
, R0
, R1
, 3),
15310 BPF_LDX_MEM(BPF_DW
, R0
, BPF_REG_FP
, -16),
15311 BPF_JMP_REG(BPF_JNE
, R0
, R2
, 1),
15312 BPF_ALU64_IMM(BPF_MOV
, R0
, 0),
15319 "Tail call load/store",
15321 BPF_ALU64_IMM(BPF_MOV
, R0
, 3),
15322 BPF_STX_MEM(BPF_DW
, BPF_REG_FP
, R0
, -8),
15324 BPF_ALU64_IMM(BPF_MOV
, R0
, -1),
15329 .has_tail_call
= true,
15332 "Tail call error path, max count reached",
15334 BPF_LDX_MEM(BPF_W
, R2
, R1
, 0),
15335 BPF_ALU64_IMM(BPF_ADD
, R2
, 1),
15336 BPF_STX_MEM(BPF_W
, R1
, R2
, 0),
15340 .flags
= FLAG_NEED_STATE
| FLAG_RESULT_IN_STATE
,
15341 .result
= (MAX_TAIL_CALL_CNT
+ 1) * MAX_TESTRUNS
,
15342 .has_tail_call
= true,
15345 "Tail call count preserved across function calls",
15347 BPF_LDX_MEM(BPF_W
, R2
, R1
, 0),
15348 BPF_ALU64_IMM(BPF_ADD
, R2
, 1),
15349 BPF_STX_MEM(BPF_W
, R1
, R2
, 0),
15350 BPF_STX_MEM(BPF_DW
, R10
, R1
, -8),
15351 BPF_CALL_REL(BPF_FUNC_get_numa_node_id
),
15352 BPF_CALL_REL(BPF_FUNC_ktime_get_ns
),
15353 BPF_CALL_REL(BPF_FUNC_ktime_get_boot_ns
),
15354 BPF_CALL_REL(BPF_FUNC_ktime_get_coarse_ns
),
15355 BPF_CALL_REL(BPF_FUNC_jiffies64
),
15356 BPF_CALL_REL(BPF_FUNC_test_func
),
15357 BPF_LDX_MEM(BPF_DW
, R1
, R10
, -8),
15358 BPF_ALU32_REG(BPF_MOV
, R0
, R1
),
15363 .flags
= FLAG_NEED_STATE
| FLAG_RESULT_IN_STATE
,
15364 .result
= (MAX_TAIL_CALL_CNT
+ 1) * MAX_TESTRUNS
,
15365 .has_tail_call
= true,
15368 "Tail call error path, NULL target",
15370 BPF_LDX_MEM(BPF_W
, R2
, R1
, 0),
15371 BPF_ALU64_IMM(BPF_ADD
, R2
, 1),
15372 BPF_STX_MEM(BPF_W
, R1
, R2
, 0),
15373 TAIL_CALL(TAIL_CALL_NULL
),
15376 .flags
= FLAG_NEED_STATE
| FLAG_RESULT_IN_STATE
,
15377 .result
= MAX_TESTRUNS
,
15378 .has_tail_call
= true,
15381 "Tail call error path, index out of range",
15383 BPF_LDX_MEM(BPF_W
, R2
, R1
, 0),
15384 BPF_ALU64_IMM(BPF_ADD
, R2
, 1),
15385 BPF_STX_MEM(BPF_W
, R1
, R2
, 0),
15386 TAIL_CALL(TAIL_CALL_INVALID
),
15389 .flags
= FLAG_NEED_STATE
| FLAG_RESULT_IN_STATE
,
15390 .result
= MAX_TESTRUNS
,
15391 .has_tail_call
= true,
15395 static void __init
destroy_tail_call_tests(struct bpf_array
*progs
)
15399 for (i
= 0; i
< ARRAY_SIZE(tail_call_tests
); i
++)
15400 if (progs
->ptrs
[i
])
15401 bpf_prog_free(progs
->ptrs
[i
]);
15405 static __init
int prepare_tail_call_tests(struct bpf_array
**pprogs
)
15407 int ntests
= ARRAY_SIZE(tail_call_tests
);
15408 struct bpf_array
*progs
;
15411 /* Allocate the table of programs to be used for tail calls */
15412 progs
= kzalloc(struct_size(progs
, ptrs
, ntests
+ 1), GFP_KERNEL
);
15416 /* Create all eBPF programs and populate the table */
15417 for (which
= 0; which
< ntests
; which
++) {
15418 struct tail_call_test
*test
= &tail_call_tests
[which
];
15419 struct bpf_prog
*fp
;
15422 /* Compute the number of program instructions */
15423 for (len
= 0; len
< MAX_INSNS
; len
++) {
15424 struct bpf_insn
*insn
= &test
->insns
[len
];
15426 if (len
< MAX_INSNS
- 1 &&
15427 insn
->code
== (BPF_LD
| BPF_DW
| BPF_IMM
))
15429 if (insn
->code
== 0)
15433 /* Allocate and initialize the program */
15434 fp
= bpf_prog_alloc(bpf_prog_size(len
), 0);
15439 fp
->type
= BPF_PROG_TYPE_SOCKET_FILTER
;
15440 fp
->aux
->stack_depth
= test
->stack_depth
;
15441 fp
->aux
->tail_call_reachable
= test
->has_tail_call
;
15442 memcpy(fp
->insnsi
, test
->insns
, len
* sizeof(struct bpf_insn
));
15444 /* Relocate runtime tail call offsets and addresses */
15445 for (i
= 0; i
< len
; i
++) {
15446 struct bpf_insn
*insn
= &fp
->insnsi
[i
];
15449 switch (insn
->code
) {
15450 case BPF_LD
| BPF_DW
| BPF_IMM
:
15451 if (insn
->imm
!= TAIL_CALL_MARKER
)
15453 insn
[0].imm
= (u32
)(long)progs
;
15454 insn
[1].imm
= ((u64
)(long)progs
) >> 32;
15457 case BPF_ALU
| BPF_MOV
| BPF_K
:
15458 if (insn
->imm
!= TAIL_CALL_MARKER
)
15460 if (insn
->off
== TAIL_CALL_NULL
)
15461 insn
->imm
= ntests
;
15462 else if (insn
->off
== TAIL_CALL_INVALID
)
15463 insn
->imm
= ntests
+ 1;
15465 insn
->imm
= which
+ insn
->off
;
15469 case BPF_JMP
| BPF_CALL
:
15470 if (insn
->src_reg
!= BPF_PSEUDO_CALL
)
15472 switch (insn
->imm
) {
15473 case BPF_FUNC_get_numa_node_id
:
15474 addr
= (long)&numa_node_id
;
15476 case BPF_FUNC_ktime_get_ns
:
15477 addr
= (long)&ktime_get_ns
;
15479 case BPF_FUNC_ktime_get_boot_ns
:
15480 addr
= (long)&ktime_get_boot_fast_ns
;
15482 case BPF_FUNC_ktime_get_coarse_ns
:
15483 addr
= (long)&ktime_get_coarse_ns
;
15485 case BPF_FUNC_jiffies64
:
15486 addr
= (long)&get_jiffies_64
;
15488 case BPF_FUNC_test_func
:
15489 addr
= (long)&bpf_test_func
;
15495 *insn
= BPF_EMIT_CALL(addr
);
15496 if ((long)__bpf_call_base
+ insn
->imm
!= addr
)
15497 *insn
= BPF_JMP_A(0); /* Skip: NOP */
15502 fp
= bpf_prog_select_runtime(fp
, &err
);
15506 progs
->ptrs
[which
] = fp
;
15509 /* The last entry contains a NULL program pointer */
15510 progs
->map
.max_entries
= ntests
+ 1;
15519 destroy_tail_call_tests(progs
);
15523 static __init
int test_tail_calls(struct bpf_array
*progs
)
15525 int i
, err_cnt
= 0, pass_cnt
= 0;
15526 int jit_cnt
= 0, run_cnt
= 0;
15528 for (i
= 0; i
< ARRAY_SIZE(tail_call_tests
); i
++) {
15529 struct tail_call_test
*test
= &tail_call_tests
[i
];
15530 struct bpf_prog
*fp
= progs
->ptrs
[i
];
15537 if (exclude_test(i
))
15540 pr_info("#%d %s ", i
, test
->descr
);
15545 pr_cont("jited:%u ", fp
->jited
);
15551 if (test
->flags
& FLAG_NEED_STATE
)
15553 ret
= __run_one(fp
, data
, MAX_TESTRUNS
, &duration
);
15554 if (test
->flags
& FLAG_RESULT_IN_STATE
)
15556 if (ret
== test
->result
) {
15557 pr_cont("%lld PASS", duration
);
15560 pr_cont("ret %d != %d FAIL", ret
, test
->result
);
15565 pr_info("%s: Summary: %d PASSED, %d FAILED, [%d/%d JIT'ed]\n",
15566 __func__
, pass_cnt
, err_cnt
, jit_cnt
, run_cnt
);
15568 return err_cnt
? -EINVAL
: 0;
15571 static char test_suite
[32];
15572 module_param_string(test_suite
, test_suite
, sizeof(test_suite
), 0);
15574 static __init
int find_test_index(const char *test_name
)
15578 if (!strcmp(test_suite
, "test_bpf")) {
15579 for (i
= 0; i
< ARRAY_SIZE(tests
); i
++) {
15580 if (!strcmp(tests
[i
].descr
, test_name
))
15585 if (!strcmp(test_suite
, "test_tail_calls")) {
15586 for (i
= 0; i
< ARRAY_SIZE(tail_call_tests
); i
++) {
15587 if (!strcmp(tail_call_tests
[i
].descr
, test_name
))
15592 if (!strcmp(test_suite
, "test_skb_segment")) {
15593 for (i
= 0; i
< ARRAY_SIZE(skb_segment_tests
); i
++) {
15594 if (!strcmp(skb_segment_tests
[i
].descr
, test_name
))
15602 static __init
int prepare_test_range(void)
15606 if (!strcmp(test_suite
, "test_bpf"))
15607 valid_range
= ARRAY_SIZE(tests
);
15608 else if (!strcmp(test_suite
, "test_tail_calls"))
15609 valid_range
= ARRAY_SIZE(tail_call_tests
);
15610 else if (!strcmp(test_suite
, "test_skb_segment"))
15611 valid_range
= ARRAY_SIZE(skb_segment_tests
);
15615 if (test_id
>= 0) {
15617 * if a test_id was specified, use test_range to
15618 * cover only that test.
15620 if (test_id
>= valid_range
) {
15621 pr_err("test_bpf: invalid test_id specified for '%s' suite.\n",
15626 test_range
[0] = test_id
;
15627 test_range
[1] = test_id
;
15628 } else if (*test_name
) {
15630 * if a test_name was specified, find it and setup
15631 * test_range to cover only that test.
15633 int idx
= find_test_index(test_name
);
15636 pr_err("test_bpf: no test named '%s' found for '%s' suite.\n",
15637 test_name
, test_suite
);
15640 test_range
[0] = idx
;
15641 test_range
[1] = idx
;
15642 } else if (test_range
[0] != 0 || test_range
[1] != INT_MAX
) {
15644 * check that the supplied test_range is valid.
15646 if (test_range
[0] < 0 || test_range
[1] >= valid_range
) {
15647 pr_err("test_bpf: test_range is out of bound for '%s' suite.\n",
15652 if (test_range
[1] < test_range
[0]) {
15653 pr_err("test_bpf: test_range is ending before it starts.\n");
15661 static int __init
test_bpf_init(void)
15663 struct bpf_array
*progs
= NULL
;
15666 if (strlen(test_suite
) &&
15667 strcmp(test_suite
, "test_bpf") &&
15668 strcmp(test_suite
, "test_tail_calls") &&
15669 strcmp(test_suite
, "test_skb_segment")) {
15670 pr_err("test_bpf: invalid test_suite '%s' specified.\n", test_suite
);
15675 * if test_suite is not specified, but test_id, test_name or test_range
15676 * is specified, set 'test_bpf' as the default test suite.
15678 if (!strlen(test_suite
) &&
15679 (test_id
!= -1 || strlen(test_name
) ||
15680 (test_range
[0] != 0 || test_range
[1] != INT_MAX
))) {
15681 pr_info("test_bpf: set 'test_bpf' as the default test_suite.\n");
15682 strscpy(test_suite
, "test_bpf", sizeof(test_suite
));
15685 ret
= prepare_test_range();
15689 if (!strlen(test_suite
) || !strcmp(test_suite
, "test_bpf")) {
15695 if (!strlen(test_suite
) || !strcmp(test_suite
, "test_tail_calls")) {
15696 ret
= prepare_tail_call_tests(&progs
);
15699 ret
= test_tail_calls(progs
);
15700 destroy_tail_call_tests(progs
);
15705 if (!strlen(test_suite
) || !strcmp(test_suite
, "test_skb_segment"))
15706 return test_skb_segment();
15711 static void __exit
test_bpf_exit(void)
15715 module_init(test_bpf_init
);
15716 module_exit(test_bpf_exit
);
15718 MODULE_DESCRIPTION("Testsuite for BPF interpreter and BPF JIT compiler");
15719 MODULE_LICENSE("GPL");