1 {
2 	"jit: lsh, rsh, arsh by 1",
3 	.insns = {
4 	BPF_MOV64_IMM(BPF_REG_0, 1),
5 	BPF_MOV64_IMM(BPF_REG_1, 0xff),
6 	BPF_ALU64_IMM(BPF_LSH, BPF_REG_1, 1),
7 	BPF_ALU32_IMM(BPF_LSH, BPF_REG_1, 1),
8 	BPF_JMP_IMM(BPF_JEQ, BPF_REG_1, 0x3fc, 1),
9 	BPF_EXIT_INSN(),
10 	BPF_ALU64_IMM(BPF_RSH, BPF_REG_1, 1),
11 	BPF_ALU32_IMM(BPF_RSH, BPF_REG_1, 1),
12 	BPF_JMP_IMM(BPF_JEQ, BPF_REG_1, 0xff, 1),
13 	BPF_EXIT_INSN(),
14 	BPF_ALU64_IMM(BPF_ARSH, BPF_REG_1, 1),
15 	BPF_JMP_IMM(BPF_JEQ, BPF_REG_1, 0x7f, 1),
16 	BPF_EXIT_INSN(),
17 	BPF_MOV64_IMM(BPF_REG_0, 2),
18 	BPF_EXIT_INSN(),
19 	},
20 	.result = ACCEPT,
21 	.retval = 2,
22 },
23 {
24 	"jit: mov32 for ldimm64, 1",
25 	.insns = {
26 	BPF_MOV64_IMM(BPF_REG_0, 2),
27 	BPF_LD_IMM64(BPF_REG_1, 0xfeffffffffffffffULL),
28 	BPF_ALU64_IMM(BPF_RSH, BPF_REG_1, 32),
29 	BPF_LD_IMM64(BPF_REG_2, 0xfeffffffULL),
30 	BPF_JMP_REG(BPF_JEQ, BPF_REG_1, BPF_REG_2, 1),
31 	BPF_MOV64_IMM(BPF_REG_0, 1),
32 	BPF_EXIT_INSN(),
33 	},
34 	.result = ACCEPT,
35 	.retval = 2,
36 },
37 {
38 	"jit: mov32 for ldimm64, 2",
39 	.insns = {
40 	BPF_MOV64_IMM(BPF_REG_0, 1),
41 	BPF_LD_IMM64(BPF_REG_1, 0x1ffffffffULL),
42 	BPF_LD_IMM64(BPF_REG_2, 0xffffffffULL),
43 	BPF_JMP_REG(BPF_JEQ, BPF_REG_1, BPF_REG_2, 1),
44 	BPF_MOV64_IMM(BPF_REG_0, 2),
45 	BPF_EXIT_INSN(),
46 	},
47 	.result = ACCEPT,
48 	.retval = 2,
49 },
50 {
51 	"jit: various mul tests",
52 	.insns = {
53 	BPF_LD_IMM64(BPF_REG_2, 0xeeff0d413122ULL),
54 	BPF_LD_IMM64(BPF_REG_0, 0xfefefeULL),
55 	BPF_LD_IMM64(BPF_REG_1, 0xefefefULL),
56 	BPF_ALU64_REG(BPF_MUL, BPF_REG_0, BPF_REG_1),
57 	BPF_JMP_REG(BPF_JEQ, BPF_REG_0, BPF_REG_2, 2),
58 	BPF_MOV64_IMM(BPF_REG_0, 1),
59 	BPF_EXIT_INSN(),
60 	BPF_LD_IMM64(BPF_REG_3, 0xfefefeULL),
61 	BPF_ALU64_REG(BPF_MUL, BPF_REG_3, BPF_REG_1),
62 	BPF_JMP_REG(BPF_JEQ, BPF_REG_3, BPF_REG_2, 2),
63 	BPF_MOV64_IMM(BPF_REG_0, 1),
64 	BPF_EXIT_INSN(),
65 	BPF_MOV32_REG(BPF_REG_2, BPF_REG_2),
66 	BPF_LD_IMM64(BPF_REG_0, 0xfefefeULL),
67 	BPF_ALU32_REG(BPF_MUL, BPF_REG_0, BPF_REG_1),
68 	BPF_JMP_REG(BPF_JEQ, BPF_REG_0, BPF_REG_2, 2),
69 	BPF_MOV64_IMM(BPF_REG_0, 1),
70 	BPF_EXIT_INSN(),
71 	BPF_LD_IMM64(BPF_REG_3, 0xfefefeULL),
72 	BPF_ALU32_REG(BPF_MUL, BPF_REG_3, BPF_REG_1),
73 	BPF_JMP_REG(BPF_JEQ, BPF_REG_3, BPF_REG_2, 2),
74 	BPF_MOV64_IMM(BPF_REG_0, 1),
75 	BPF_EXIT_INSN(),
76 	BPF_LD_IMM64(BPF_REG_0, 0x952a7bbcULL),
77 	BPF_LD_IMM64(BPF_REG_1, 0xfefefeULL),
78 	BPF_LD_IMM64(BPF_REG_2, 0xeeff0d413122ULL),
79 	BPF_ALU32_REG(BPF_MUL, BPF_REG_2, BPF_REG_1),
80 	BPF_JMP_REG(BPF_JEQ, BPF_REG_2, BPF_REG_0, 2),
81 	BPF_MOV64_IMM(BPF_REG_0, 1),
82 	BPF_EXIT_INSN(),
83 	BPF_MOV64_IMM(BPF_REG_0, 2),
84 	BPF_EXIT_INSN(),
85 	},
86 	.result = ACCEPT,
87 	.retval = 2,
88 },
89 {
90 	"jit: jsgt, jslt",
91 	.insns = {
92 	BPF_LD_IMM64(BPF_REG_1, 0x80000000ULL),
93 	BPF_LD_IMM64(BPF_REG_2, 0x0ULL),
94 	BPF_JMP_REG(BPF_JSGT, BPF_REG_1, BPF_REG_2, 2),
95 	BPF_MOV64_IMM(BPF_REG_0, 1),
96 	BPF_EXIT_INSN(),
97 
98 	BPF_JMP_REG(BPF_JSLT, BPF_REG_2, BPF_REG_1, 2),
99 	BPF_MOV64_IMM(BPF_REG_0, 1),
100 	BPF_EXIT_INSN(),
101 
102 	BPF_MOV64_IMM(BPF_REG_0, 2),
103 	BPF_EXIT_INSN(),
104 	},
105 	.result = ACCEPT,
106 	.retval = 2,
107 },
108 {
109 	"jit: torturous jumps, imm8 nop jmp and pure jump padding",
110 	.insns = { },
111 	.fill_helper = bpf_fill_torturous_jumps,
112 	.prog_type = BPF_PROG_TYPE_SCHED_CLS,
113 	.result = ACCEPT,
114 	.retval = 1,
115 },
116 {
117 	"jit: torturous jumps, imm32 nop jmp and jmp_cond padding",
118 	.insns = { },
119 	.fill_helper = bpf_fill_torturous_jumps,
120 	.prog_type = BPF_PROG_TYPE_SCHED_CLS,
121 	.result = ACCEPT,
122 	.retval = 2,
123 },
124 {
125 	"jit: torturous jumps in subprog",
126 	.insns = { },
127 	.fill_helper = bpf_fill_torturous_jumps,
128 	.prog_type = BPF_PROG_TYPE_SCHED_CLS,
129 	.result = ACCEPT,
130 	.retval = 3,
131 },
132