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_LD_IMM64(BPF_REG_3, 0xfefefeULL),
66 	BPF_ALU64_IMM(BPF_MUL, BPF_REG_3, 0xefefef),
67 	BPF_JMP_REG(BPF_JEQ, BPF_REG_3, BPF_REG_2, 2),
68 	BPF_MOV64_IMM(BPF_REG_0, 1),
69 	BPF_EXIT_INSN(),
70 	BPF_MOV32_REG(BPF_REG_2, BPF_REG_2),
71 	BPF_LD_IMM64(BPF_REG_0, 0xfefefeULL),
72 	BPF_ALU32_REG(BPF_MUL, BPF_REG_0, BPF_REG_1),
73 	BPF_JMP_REG(BPF_JEQ, BPF_REG_0, BPF_REG_2, 2),
74 	BPF_MOV64_IMM(BPF_REG_0, 1),
75 	BPF_EXIT_INSN(),
76 	BPF_LD_IMM64(BPF_REG_3, 0xfefefeULL),
77 	BPF_ALU32_REG(BPF_MUL, BPF_REG_3, BPF_REG_1),
78 	BPF_JMP_REG(BPF_JEQ, BPF_REG_3, BPF_REG_2, 2),
79 	BPF_MOV64_IMM(BPF_REG_0, 1),
80 	BPF_EXIT_INSN(),
81 	BPF_LD_IMM64(BPF_REG_3, 0xfefefeULL),
82 	BPF_ALU32_IMM(BPF_MUL, BPF_REG_3, 0xefefef),
83 	BPF_JMP_REG(BPF_JEQ, BPF_REG_3, BPF_REG_2, 2),
84 	BPF_MOV64_IMM(BPF_REG_0, 1),
85 	BPF_EXIT_INSN(),
86 	BPF_LD_IMM64(BPF_REG_0, 0xfefefeULL),
87 	BPF_LD_IMM64(BPF_REG_2, 0x2ad4d4aaULL),
88 	BPF_ALU32_IMM(BPF_MUL, BPF_REG_0, 0x2b),
89 	BPF_JMP_REG(BPF_JEQ, BPF_REG_0, BPF_REG_2, 2),
90 	BPF_MOV64_IMM(BPF_REG_0, 1),
91 	BPF_EXIT_INSN(),
92 	BPF_LD_IMM64(BPF_REG_0, 0x952a7bbcULL),
93 	BPF_LD_IMM64(BPF_REG_1, 0xfefefeULL),
94 	BPF_LD_IMM64(BPF_REG_5, 0xeeff0d413122ULL),
95 	BPF_ALU32_REG(BPF_MUL, BPF_REG_5, BPF_REG_1),
96 	BPF_JMP_REG(BPF_JEQ, BPF_REG_5, BPF_REG_0, 2),
97 	BPF_MOV64_IMM(BPF_REG_0, 1),
98 	BPF_EXIT_INSN(),
99 	BPF_MOV64_IMM(BPF_REG_0, 2),
100 	BPF_EXIT_INSN(),
101 	},
102 	.result = ACCEPT,
103 	.retval = 2,
104 },
105 {
106 	"jit: jsgt, jslt",
107 	.insns = {
108 	BPF_LD_IMM64(BPF_REG_1, 0x80000000ULL),
109 	BPF_LD_IMM64(BPF_REG_2, 0x0ULL),
110 	BPF_JMP_REG(BPF_JSGT, BPF_REG_1, BPF_REG_2, 2),
111 	BPF_MOV64_IMM(BPF_REG_0, 1),
112 	BPF_EXIT_INSN(),
113 
114 	BPF_JMP_REG(BPF_JSLT, BPF_REG_2, BPF_REG_1, 2),
115 	BPF_MOV64_IMM(BPF_REG_0, 1),
116 	BPF_EXIT_INSN(),
117 
118 	BPF_MOV64_IMM(BPF_REG_0, 2),
119 	BPF_EXIT_INSN(),
120 	},
121 	.result = ACCEPT,
122 	.retval = 2,
123 },
124 {
125 	"jit: torturous jumps, imm8 nop jmp and pure jump padding",
126 	.insns = { },
127 	.fill_helper = bpf_fill_torturous_jumps,
128 	.prog_type = BPF_PROG_TYPE_SCHED_CLS,
129 	.result = ACCEPT,
130 	.retval = 1,
131 },
132 {
133 	"jit: torturous jumps, imm32 nop jmp and jmp_cond padding",
134 	.insns = { },
135 	.fill_helper = bpf_fill_torturous_jumps,
136 	.prog_type = BPF_PROG_TYPE_SCHED_CLS,
137 	.result = ACCEPT,
138 	.retval = 2,
139 },
140 {
141 	"jit: torturous jumps in subprog",
142 	.insns = { },
143 	.fill_helper = bpf_fill_torturous_jumps,
144 	.prog_type = BPF_PROG_TYPE_SCHED_CLS,
145 	.result = ACCEPT,
146 	.retval = 3,
147 },
148