Lines Matching +full:class +full:- +full:d

1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2 /* Copyright (c) 2011-2014 PLUMgrid, http://plumgrid.com
22 if (!insn->src_reg && in __func_get_name()
23 insn->imm >= 0 && insn->imm < __BPF_FUNC_MAX_ID && in __func_get_name()
24 func_id_str[insn->imm]) in __func_get_name()
25 return func_id_str[insn->imm]; in __func_get_name()
27 if (cbs && cbs->cb_call) { in __func_get_name()
30 res = cbs->cb_call(cbs->private_data, insn); in __func_get_name()
35 if (insn->src_reg == BPF_PSEUDO_CALL) in __func_get_name()
36 snprintf(buff, len, "%+d", insn->imm); in __func_get_name()
37 else if (insn->src_reg == BPF_PSEUDO_KFUNC_CALL) in __func_get_name()
38 snprintf(buff, len, "kernel-function"); in __func_get_name()
47 if (cbs && cbs->cb_imm) in __func_imm_name()
48 return cbs->cb_imm(cbs->private_data, insn, full_imm); in __func_imm_name()
75 [BPF_SUB >> 4] = "-=",
142 verbose(private_data, "(%02x) r%d = %s%d r%d\n", in print_bpf_end_insn()
143 insn->code, insn->dst_reg, in print_bpf_end_insn()
144 BPF_SRC(insn->code) == BPF_TO_BE ? "be" : "le", in print_bpf_end_insn()
145 insn->imm, insn->dst_reg); in print_bpf_end_insn()
152 verbose(private_data, "(%02x) r%d = bswap%d r%d\n", in print_bpf_bswap_insn()
153 insn->code, insn->dst_reg, in print_bpf_bswap_insn()
154 insn->imm, insn->dst_reg); in print_bpf_bswap_insn()
159 return (BPF_OP(insn->code) == BPF_DIV || BPF_OP(insn->code) == BPF_MOD) && in is_sdiv_smod()
160 insn->off == 1; in is_sdiv_smod()
165 return BPF_OP(insn->code) == BPF_MOV && in is_movsx()
166 (insn->off == 8 || insn->off == 16 || insn->off == 32); in is_movsx()
171 return insn->code == (BPF_ALU64 | BPF_MOV | BPF_X) && in is_addr_space_cast()
172 insn->off == BPF_ADDR_SPACE_CAST; in is_addr_space_cast()
175 /* Special (internal-only) form of mov, used to resolve per-CPU addrs:
177 * BPF_ADDR_PERCPU is used as a special insn->off value.
179 #define BPF_ADDR_PERCPU (-1)
183 return insn->code == (BPF_ALU64 | BPF_MOV | BPF_X) && insn->off == BPF_ADDR_PERCPU; in is_mov_percpu_addr()
190 const bpf_insn_print_t verbose = cbs->cb_print; in print_bpf_insn()
191 u8 class = BPF_CLASS(insn->code); in print_bpf_insn() local
193 if (class == BPF_ALU || class == BPF_ALU64) { in print_bpf_insn()
194 if (BPF_OP(insn->code) == BPF_END) { in print_bpf_insn()
195 if (class == BPF_ALU64) in print_bpf_insn()
196 print_bpf_bswap_insn(verbose, cbs->private_data, insn); in print_bpf_insn()
198 print_bpf_end_insn(verbose, cbs->private_data, insn); in print_bpf_insn()
199 } else if (BPF_OP(insn->code) == BPF_NEG) { in print_bpf_insn()
200 verbose(cbs->private_data, "(%02x) %c%d = -%c%d\n", in print_bpf_insn()
201 insn->code, class == BPF_ALU ? 'w' : 'r', in print_bpf_insn()
202 insn->dst_reg, class == BPF_ALU ? 'w' : 'r', in print_bpf_insn()
203 insn->dst_reg); in print_bpf_insn()
205 verbose(cbs->private_data, "(%02x) r%d = addr_space_cast(r%d, %d, %d)\n", in print_bpf_insn()
206 insn->code, insn->dst_reg, in print_bpf_insn()
207 insn->src_reg, ((u32)insn->imm) >> 16, (u16)insn->imm); in print_bpf_insn()
209 verbose(cbs->private_data, "(%02x) r%d = &(void __percpu *)(r%d)\n", in print_bpf_insn()
210 insn->code, insn->dst_reg, insn->src_reg); in print_bpf_insn()
211 } else if (BPF_SRC(insn->code) == BPF_X) { in print_bpf_insn()
212 verbose(cbs->private_data, "(%02x) %c%d %s %s%c%d\n", in print_bpf_insn()
213 insn->code, class == BPF_ALU ? 'w' : 'r', in print_bpf_insn()
214 insn->dst_reg, in print_bpf_insn()
215 is_sdiv_smod(insn) ? bpf_alu_sign_string[BPF_OP(insn->code) >> 4] in print_bpf_insn()
216 : bpf_alu_string[BPF_OP(insn->code) >> 4], in print_bpf_insn()
217 is_movsx(insn) ? bpf_movsx_string[(insn->off >> 3) - 1] : "", in print_bpf_insn()
218 class == BPF_ALU ? 'w' : 'r', in print_bpf_insn()
219 insn->src_reg); in print_bpf_insn()
221 verbose(cbs->private_data, "(%02x) %c%d %s %d\n", in print_bpf_insn()
222 insn->code, class == BPF_ALU ? 'w' : 'r', in print_bpf_insn()
223 insn->dst_reg, in print_bpf_insn()
224 is_sdiv_smod(insn) ? bpf_alu_sign_string[BPF_OP(insn->code) >> 4] in print_bpf_insn()
225 : bpf_alu_string[BPF_OP(insn->code) >> 4], in print_bpf_insn()
226 insn->imm); in print_bpf_insn()
228 } else if (class == BPF_STX) { in print_bpf_insn()
229 if (BPF_MODE(insn->code) == BPF_MEM) in print_bpf_insn()
230 verbose(cbs->private_data, "(%02x) *(%s *)(r%d %+d) = r%d\n", in print_bpf_insn()
231 insn->code, in print_bpf_insn()
232 bpf_ldst_string[BPF_SIZE(insn->code) >> 3], in print_bpf_insn()
233 insn->dst_reg, in print_bpf_insn()
234 insn->off, insn->src_reg); in print_bpf_insn()
235 else if (BPF_MODE(insn->code) == BPF_ATOMIC && in print_bpf_insn()
236 (insn->imm == BPF_ADD || insn->imm == BPF_AND || in print_bpf_insn()
237 insn->imm == BPF_OR || insn->imm == BPF_XOR)) { in print_bpf_insn()
238 verbose(cbs->private_data, "(%02x) lock *(%s *)(r%d %+d) %s r%d\n", in print_bpf_insn()
239 insn->code, in print_bpf_insn()
240 bpf_ldst_string[BPF_SIZE(insn->code) >> 3], in print_bpf_insn()
241 insn->dst_reg, insn->off, in print_bpf_insn()
242 bpf_alu_string[BPF_OP(insn->imm) >> 4], in print_bpf_insn()
243 insn->src_reg); in print_bpf_insn()
244 } else if (BPF_MODE(insn->code) == BPF_ATOMIC && in print_bpf_insn()
245 (insn->imm == (BPF_ADD | BPF_FETCH) || in print_bpf_insn()
246 insn->imm == (BPF_AND | BPF_FETCH) || in print_bpf_insn()
247 insn->imm == (BPF_OR | BPF_FETCH) || in print_bpf_insn()
248 insn->imm == (BPF_XOR | BPF_FETCH))) { in print_bpf_insn()
249 verbose(cbs->private_data, "(%02x) r%d = atomic%s_fetch_%s((%s *)(r%d %+d), r%d)\n", in print_bpf_insn()
250 insn->code, insn->src_reg, in print_bpf_insn()
251 BPF_SIZE(insn->code) == BPF_DW ? "64" : "", in print_bpf_insn()
252 bpf_atomic_alu_string[BPF_OP(insn->imm) >> 4], in print_bpf_insn()
253 bpf_ldst_string[BPF_SIZE(insn->code) >> 3], in print_bpf_insn()
254 insn->dst_reg, insn->off, insn->src_reg); in print_bpf_insn()
255 } else if (BPF_MODE(insn->code) == BPF_ATOMIC && in print_bpf_insn()
256 insn->imm == BPF_CMPXCHG) { in print_bpf_insn()
257 verbose(cbs->private_data, "(%02x) r0 = atomic%s_cmpxchg((%s *)(r%d %+d), r0, r%d)\n", in print_bpf_insn()
258 insn->code, in print_bpf_insn()
259 BPF_SIZE(insn->code) == BPF_DW ? "64" : "", in print_bpf_insn()
260 bpf_ldst_string[BPF_SIZE(insn->code) >> 3], in print_bpf_insn()
261 insn->dst_reg, insn->off, in print_bpf_insn()
262 insn->src_reg); in print_bpf_insn()
263 } else if (BPF_MODE(insn->code) == BPF_ATOMIC && in print_bpf_insn()
264 insn->imm == BPF_XCHG) { in print_bpf_insn()
265 verbose(cbs->private_data, "(%02x) r%d = atomic%s_xchg((%s *)(r%d %+d), r%d)\n", in print_bpf_insn()
266 insn->code, insn->src_reg, in print_bpf_insn()
267 BPF_SIZE(insn->code) == BPF_DW ? "64" : "", in print_bpf_insn()
268 bpf_ldst_string[BPF_SIZE(insn->code) >> 3], in print_bpf_insn()
269 insn->dst_reg, insn->off, insn->src_reg); in print_bpf_insn()
271 verbose(cbs->private_data, "BUG_%02x\n", insn->code); in print_bpf_insn()
273 } else if (class == BPF_ST) { in print_bpf_insn()
274 if (BPF_MODE(insn->code) == BPF_MEM) { in print_bpf_insn()
275 verbose(cbs->private_data, "(%02x) *(%s *)(r%d %+d) = %d\n", in print_bpf_insn()
276 insn->code, in print_bpf_insn()
277 bpf_ldst_string[BPF_SIZE(insn->code) >> 3], in print_bpf_insn()
278 insn->dst_reg, in print_bpf_insn()
279 insn->off, insn->imm); in print_bpf_insn()
280 } else if (BPF_MODE(insn->code) == 0xc0 /* BPF_NOSPEC, no UAPI */) { in print_bpf_insn()
281 verbose(cbs->private_data, "(%02x) nospec\n", insn->code); in print_bpf_insn()
283 verbose(cbs->private_data, "BUG_st_%02x\n", insn->code); in print_bpf_insn()
285 } else if (class == BPF_LDX) { in print_bpf_insn()
286 if (BPF_MODE(insn->code) != BPF_MEM && BPF_MODE(insn->code) != BPF_MEMSX) { in print_bpf_insn()
287 verbose(cbs->private_data, "BUG_ldx_%02x\n", insn->code); in print_bpf_insn()
290 verbose(cbs->private_data, "(%02x) r%d = *(%s *)(r%d %+d)\n", in print_bpf_insn()
291 insn->code, insn->dst_reg, in print_bpf_insn()
292 BPF_MODE(insn->code) == BPF_MEM ? in print_bpf_insn()
293 bpf_ldst_string[BPF_SIZE(insn->code) >> 3] : in print_bpf_insn()
294 bpf_ldsx_string[BPF_SIZE(insn->code) >> 3], in print_bpf_insn()
295 insn->src_reg, insn->off); in print_bpf_insn()
296 } else if (class == BPF_LD) { in print_bpf_insn()
297 if (BPF_MODE(insn->code) == BPF_ABS) { in print_bpf_insn()
298 verbose(cbs->private_data, "(%02x) r0 = *(%s *)skb[%d]\n", in print_bpf_insn()
299 insn->code, in print_bpf_insn()
300 bpf_ldst_string[BPF_SIZE(insn->code) >> 3], in print_bpf_insn()
301 insn->imm); in print_bpf_insn()
302 } else if (BPF_MODE(insn->code) == BPF_IND) { in print_bpf_insn()
303 verbose(cbs->private_data, "(%02x) r0 = *(%s *)skb[r%d + %d]\n", in print_bpf_insn()
304 insn->code, in print_bpf_insn()
305 bpf_ldst_string[BPF_SIZE(insn->code) >> 3], in print_bpf_insn()
306 insn->src_reg, insn->imm); in print_bpf_insn()
307 } else if (BPF_MODE(insn->code) == BPF_IMM && in print_bpf_insn()
308 BPF_SIZE(insn->code) == BPF_DW) { in print_bpf_insn()
312 u64 imm = ((u64)(insn + 1)->imm << 32) | (u32)insn->imm; in print_bpf_insn()
313 bool is_ptr = insn->src_reg == BPF_PSEUDO_MAP_FD || in print_bpf_insn()
314 insn->src_reg == BPF_PSEUDO_MAP_VALUE; in print_bpf_insn()
320 verbose(cbs->private_data, "(%02x) r%d = %s\n", in print_bpf_insn()
321 insn->code, insn->dst_reg, in print_bpf_insn()
325 verbose(cbs->private_data, "BUG_ld_%02x\n", insn->code); in print_bpf_insn()
328 } else if (class == BPF_JMP32 || class == BPF_JMP) { in print_bpf_insn()
329 u8 opcode = BPF_OP(insn->code); in print_bpf_insn()
334 if (insn->src_reg == BPF_PSEUDO_CALL) { in print_bpf_insn()
335 verbose(cbs->private_data, "(%02x) call pc%s\n", in print_bpf_insn()
336 insn->code, in print_bpf_insn()
341 verbose(cbs->private_data, "(%02x) call %s#%d\n", insn->code, in print_bpf_insn()
344 insn->imm); in print_bpf_insn()
346 } else if (insn->code == (BPF_JMP | BPF_JA)) { in print_bpf_insn()
347 verbose(cbs->private_data, "(%02x) goto pc%+d\n", in print_bpf_insn()
348 insn->code, insn->off); in print_bpf_insn()
349 } else if (insn->code == (BPF_JMP | BPF_JCOND) && in print_bpf_insn()
350 insn->src_reg == BPF_MAY_GOTO) { in print_bpf_insn()
351 verbose(cbs->private_data, "(%02x) may_goto pc%+d\n", in print_bpf_insn()
352 insn->code, insn->off); in print_bpf_insn()
353 } else if (insn->code == (BPF_JMP32 | BPF_JA)) { in print_bpf_insn()
354 verbose(cbs->private_data, "(%02x) gotol pc%+d\n", in print_bpf_insn()
355 insn->code, insn->imm); in print_bpf_insn()
356 } else if (insn->code == (BPF_JMP | BPF_EXIT)) { in print_bpf_insn()
357 verbose(cbs->private_data, "(%02x) exit\n", insn->code); in print_bpf_insn()
358 } else if (BPF_SRC(insn->code) == BPF_X) { in print_bpf_insn()
359 verbose(cbs->private_data, in print_bpf_insn()
360 "(%02x) if %c%d %s %c%d goto pc%+d\n", in print_bpf_insn()
361 insn->code, class == BPF_JMP32 ? 'w' : 'r', in print_bpf_insn()
362 insn->dst_reg, in print_bpf_insn()
363 bpf_jmp_string[BPF_OP(insn->code) >> 4], in print_bpf_insn()
364 class == BPF_JMP32 ? 'w' : 'r', in print_bpf_insn()
365 insn->src_reg, insn->off); in print_bpf_insn()
367 verbose(cbs->private_data, in print_bpf_insn()
368 "(%02x) if %c%d %s 0x%x goto pc%+d\n", in print_bpf_insn()
369 insn->code, class == BPF_JMP32 ? 'w' : 'r', in print_bpf_insn()
370 insn->dst_reg, in print_bpf_insn()
371 bpf_jmp_string[BPF_OP(insn->code) >> 4], in print_bpf_insn()
372 insn->imm, insn->off); in print_bpf_insn()
375 verbose(cbs->private_data, "(%02x) %s\n", in print_bpf_insn()
376 insn->code, bpf_class_string[class]); in print_bpf_insn()