Lines Matching defs:insn

17 				   const struct bpf_insn *insn,
22 if (!insn->src_reg &&
23 insn->imm >= 0 && insn->imm < __BPF_FUNC_MAX_ID &&
24 func_id_str[insn->imm])
25 return func_id_str[insn->imm];
30 res = cbs->cb_call(cbs->private_data, insn);
35 if (insn->src_reg == BPF_PSEUDO_CALL)
36 snprintf(buff, len, "%+d", insn->imm);
37 else if (insn->src_reg == BPF_PSEUDO_KFUNC_CALL)
44 const struct bpf_insn *insn,
48 return cbs->cb_imm(cbs->private_data, insn, full_imm);
140 const struct bpf_insn *insn)
143 insn->code, insn->dst_reg,
144 BPF_SRC(insn->code) == BPF_TO_BE ? "be" : "le",
145 insn->imm, insn->dst_reg);
150 const struct bpf_insn *insn)
153 insn->code, insn->dst_reg,
154 insn->imm, insn->dst_reg);
157 static bool is_sdiv_smod(const struct bpf_insn *insn)
159 return (BPF_OP(insn->code) == BPF_DIV || BPF_OP(insn->code) == BPF_MOD) &&
160 insn->off == 1;
163 static bool is_movsx(const struct bpf_insn *insn)
165 return BPF_OP(insn->code) == BPF_MOV &&
166 (insn->off == 8 || insn->off == 16 || insn->off == 32);
169 static bool is_addr_space_cast(const struct bpf_insn *insn)
171 return insn->code == (BPF_ALU64 | BPF_MOV | BPF_X) &&
172 insn->off == BPF_ADDR_SPACE_CAST;
176 const struct bpf_insn *insn,
180 u8 class = BPF_CLASS(insn->code);
183 if (BPF_OP(insn->code) == BPF_END) {
185 print_bpf_bswap_insn(verbose, cbs->private_data, insn);
187 print_bpf_end_insn(verbose, cbs->private_data, insn);
188 } else if (BPF_OP(insn->code) == BPF_NEG) {
190 insn->code, class == BPF_ALU ? 'w' : 'r',
191 insn->dst_reg, class == BPF_ALU ? 'w' : 'r',
192 insn->dst_reg);
193 } else if (is_addr_space_cast(insn)) {
195 insn->code, insn->dst_reg,
196 insn->src_reg, ((u32)insn->imm) >> 16, (u16)insn->imm);
197 } else if (BPF_SRC(insn->code) == BPF_X) {
199 insn->code, class == BPF_ALU ? 'w' : 'r',
200 insn->dst_reg,
201 is_sdiv_smod(insn) ? bpf_alu_sign_string[BPF_OP(insn->code) >> 4]
202 : bpf_alu_string[BPF_OP(insn->code) >> 4],
203 is_movsx(insn) ? bpf_movsx_string[(insn->off >> 3) - 1] : "",
205 insn->src_reg);
208 insn->code, class == BPF_ALU ? 'w' : 'r',
209 insn->dst_reg,
210 is_sdiv_smod(insn) ? bpf_alu_sign_string[BPF_OP(insn->code) >> 4]
211 : bpf_alu_string[BPF_OP(insn->code) >> 4],
212 insn->imm);
215 if (BPF_MODE(insn->code) == BPF_MEM)
217 insn->code,
218 bpf_ldst_string[BPF_SIZE(insn->code) >> 3],
219 insn->dst_reg,
220 insn->off, insn->src_reg);
221 else if (BPF_MODE(insn->code) == BPF_ATOMIC &&
222 (insn->imm == BPF_ADD || insn->imm == BPF_AND ||
223 insn->imm == BPF_OR || insn->imm == BPF_XOR)) {
225 insn->code,
226 bpf_ldst_string[BPF_SIZE(insn->code) >> 3],
227 insn->dst_reg, insn->off,
228 bpf_alu_string[BPF_OP(insn->imm) >> 4],
229 insn->src_reg);
230 } else if (BPF_MODE(insn->code) == BPF_ATOMIC &&
231 (insn->imm == (BPF_ADD | BPF_FETCH) ||
232 insn->imm == (BPF_AND | BPF_FETCH) ||
233 insn->imm == (BPF_OR | BPF_FETCH) ||
234 insn->imm == (BPF_XOR | BPF_FETCH))) {
236 insn->code, insn->src_reg,
237 BPF_SIZE(insn->code) == BPF_DW ? "64" : "",
238 bpf_atomic_alu_string[BPF_OP(insn->imm) >> 4],
239 bpf_ldst_string[BPF_SIZE(insn->code) >> 3],
240 insn->dst_reg, insn->off, insn->src_reg);
241 } else if (BPF_MODE(insn->code) == BPF_ATOMIC &&
242 insn->imm == BPF_CMPXCHG) {
244 insn->code,
245 BPF_SIZE(insn->code) == BPF_DW ? "64" : "",
246 bpf_ldst_string[BPF_SIZE(insn->code) >> 3],
247 insn->dst_reg, insn->off,
248 insn->src_reg);
249 } else if (BPF_MODE(insn->code) == BPF_ATOMIC &&
250 insn->imm == BPF_XCHG) {
252 insn->code, insn->src_reg,
253 BPF_SIZE(insn->code) == BPF_DW ? "64" : "",
254 bpf_ldst_string[BPF_SIZE(insn->code) >> 3],
255 insn->dst_reg, insn->off, insn->src_reg);
257 verbose(cbs->private_data, "BUG_%02x\n", insn->code);
260 if (BPF_MODE(insn->code) == BPF_MEM) {
262 insn->code,
263 bpf_ldst_string[BPF_SIZE(insn->code) >> 3],
264 insn->dst_reg,
265 insn->off, insn->imm);
266 } else if (BPF_MODE(insn->code) == 0xc0 /* BPF_NOSPEC, no UAPI */) {
267 verbose(cbs->private_data, "(%02x) nospec\n", insn->code);
269 verbose(cbs->private_data, "BUG_st_%02x\n", insn->code);
272 if (BPF_MODE(insn->code) != BPF_MEM && BPF_MODE(insn->code) != BPF_MEMSX) {
273 verbose(cbs->private_data, "BUG_ldx_%02x\n", insn->code);
277 insn->code, insn->dst_reg,
278 BPF_MODE(insn->code) == BPF_MEM ?
279 bpf_ldst_string[BPF_SIZE(insn->code) >> 3] :
280 bpf_ldsx_string[BPF_SIZE(insn->code) >> 3],
281 insn->src_reg, insn->off);
283 if (BPF_MODE(insn->code) == BPF_ABS) {
285 insn->code,
286 bpf_ldst_string[BPF_SIZE(insn->code) >> 3],
287 insn->imm);
288 } else if (BPF_MODE(insn->code) == BPF_IND) {
290 insn->code,
291 bpf_ldst_string[BPF_SIZE(insn->code) >> 3],
292 insn->src_reg, insn->imm);
293 } else if (BPF_MODE(insn->code) == BPF_IMM &&
294 BPF_SIZE(insn->code) == BPF_DW) {
296 * part of the ldimm64 insn is accessible.
298 u64 imm = ((u64)(insn + 1)->imm << 32) | (u32)insn->imm;
299 bool is_ptr = insn->src_reg == BPF_PSEUDO_MAP_FD ||
300 insn->src_reg == BPF_PSEUDO_MAP_VALUE;
307 insn->code, insn->dst_reg,
308 __func_imm_name(cbs, insn, imm,
311 verbose(cbs->private_data, "BUG_ld_%02x\n", insn->code);
315 u8 opcode = BPF_OP(insn->code);
320 if (insn->src_reg == BPF_PSEUDO_CALL) {
322 insn->code,
323 __func_get_name(cbs, insn,
327 verbose(cbs->private_data, "(%02x) call %s#%d\n", insn->code,
328 __func_get_name(cbs, insn,
330 insn->imm);
332 } else if (insn->code == (BPF_JMP | BPF_JA)) {
334 insn->code, insn->off);
335 } else if (insn->code == (BPF_JMP | BPF_JCOND) &&
336 insn->src_reg == BPF_MAY_GOTO) {
338 insn->code, insn->off);
339 } else if (insn->code == (BPF_JMP32 | BPF_JA)) {
341 insn->code, insn->imm);
342 } else if (insn->code == (BPF_JMP | BPF_EXIT)) {
343 verbose(cbs->private_data, "(%02x) exit\n", insn->code);
344 } else if (BPF_SRC(insn->code) == BPF_X) {
347 insn->code, class == BPF_JMP32 ? 'w' : 'r',
348 insn->dst_reg,
349 bpf_jmp_string[BPF_OP(insn->code) >> 4],
351 insn->src_reg, insn->off);
355 insn->code, class == BPF_JMP32 ? 'w' : 'r',
356 insn->dst_reg,
357 bpf_jmp_string[BPF_OP(insn->code) >> 4],
358 insn->imm, insn->off);
362 insn->code, bpf_class_string[class]);