Lines Matching defs:code
38 /* bpf_check() is a static code analyzer that walks eBPF program
1464 if (insn[i].code != (BPF_JMP | BPF_CALL)) {
1495 u8 code = insn[i].code;
1497 if (code == (BPF_JMP | BPF_CALL) && insn[i].imm == BPF_FUNC_tail_call && insn[i].src_reg != BPF_PSEUDO_CALL) {
1500 if (BPF_CLASS(code) == BPF_LD && (BPF_MODE(code) == BPF_ABS || BPF_MODE(code) == BPF_IND)) {
1503 if (BPF_CLASS(code) != BPF_JMP && BPF_CLASS(code) != BPF_JMP32) {
1506 if (BPF_OP(code) == BPF_EXIT || BPF_OP(code) == BPF_CALL) {
1520 if (code != (BPF_JMP | BPF_EXIT) && code != (BPF_JMP | BPF_JA)) {
1587 * code only. It returns TRUE if the source or destination register operates
1593 u8 code, class, op;
1595 code = insn->code;
1596 class = BPF_CLASS(code);
1597 op = BPF_OP(code);
1637 return BPF_SIZE(code) == BPF_DW;
1647 return BPF_SIZE(code) == BPF_DW;
1651 u8 mode = BPF_MODE(code);
1683 u8 class = BPF_CLASS(insn->code);
1802 u8 class = BPF_CLASS(insn->code);
1803 u8 opcode = BPF_OP(insn->code);
1804 u8 mode = BPF_MODE(insn->code);
1809 if (insn->code == 0) {
1823 if (BPF_SRC(insn->code) == BPF_X) {
1840 if (BPF_SRC(insn->code) == BPF_X) {
1866 if (BPF_SIZE(insn->code) != BPF_DW) {
1893 if (BPF_SIZE(insn->code) != BPF_DW) {
3110 * to this code only in strict mode where we want to emulate
3268 if (insn[i].code != (BPF_JMP | BPF_CALL)) {
3899 if ((BPF_SIZE(insn->code) != BPF_W && BPF_SIZE(insn->code) != BPF_DW) || insn->imm != 0) {
3929 err = check_mem_access(env, insn_idx, insn->dst_reg, insn->off, BPF_SIZE(insn->code), BPF_READ, -1, true);
3935 return check_mem_access(env, insn_idx, insn->dst_reg, insn->off, BPF_SIZE(insn->code), BPF_WRITE, -1, true);
5672 return env->bypass_spec_v1 || BPF_SRC(insn->code) == BPF_K;
5720 if (BPF_SRC(insn->code) == BPF_K) {
5722 } else if (BPF_SRC(insn->code) == BPF_X) {
5739 u8 opcode = BPF_OP(insn->code);
5844 const char *op = BPF_OP(insn->code) == BPF_ADD ? "add" : "sub";
5954 u8 opcode = BPF_OP(insn->code);
5968 if (BPF_CLASS(insn->code) != BPF_ALU64) {
6716 u8 opcode = BPF_OP(insn->code);
6722 u64 insn_bitness = (BPF_CLASS(insn->code) == BPF_ALU64) ? VERIFIER_SIXTYFOUR : VERIFIER_THIRTYTWO;
6723 bool alu32 = (BPF_CLASS(insn->code) != BPF_ALU64);
6880 u8 opcode = BPF_OP(insn->code);
6893 if (BPF_SRC(insn->code) == BPF_X) {
6957 u8 opcode = BPF_OP(insn->code);
6962 if (BPF_SRC(insn->code) != 0 || insn->src_reg != BPF_REG_0 || insn->off != 0 || insn->imm != 0) {
6969 BPF_CLASS(insn->code) == BPF_ALU64) {
6992 if (BPF_SRC(insn->code) == BPF_X) {
7015 if (BPF_SRC(insn->code) == BPF_X) {
7019 if (BPF_CLASS(insn->code) == BPF_ALU64) {
7061 if (BPF_CLASS(insn->code) == BPF_ALU64) {
7071 if (BPF_SRC(insn->code) == BPF_X) {
7094 if ((opcode == BPF_MOD || opcode == BPF_DIV) && BPF_SRC(insn->code) == BPF_K && insn->imm == 0) {
7099 if ((opcode == BPF_LSH || opcode == BPF_RSH || opcode == BPF_ARSH) && BPF_SRC(insn->code) == BPF_K) {
7100 int size = BPF_CLASS(insn->code) == BPF_ALU64 ? VERIFIER_SIXTYFOUR : 32;
7726 if (BPF_SRC(insn->code) != BPF_X) {
7731 if (BPF_CLASS(insn->code) == BPF_JMP32) {
7735 switch (BPF_OP(insn->code)) {
7828 u8 opcode = BPF_OP(insn->code);
7839 if (BPF_SRC(insn->code) == BPF_X) {
7870 is_jmp32 = BPF_CLASS(insn->code) == BPF_JMP32;
7872 if (BPF_SRC(insn->code) == BPF_K) {
7887 if (BPF_SRC(insn->code) == BPF_X && !err) {
7929 if (BPF_SRC(insn->code) == BPF_X) {
7963 if (!is_jmp32 && BPF_SRC(insn->code) == BPF_K && insn->imm == 0 && (opcode == BPF_JEQ || opcode == BPF_JNE) &&
7990 if (BPF_SIZE(insn->code) != BPF_DW) {
8086 u8 mode = BPF_MODE(insn->code);
8099 if (insn->dst_reg != BPF_REG_0 || insn->off != 0 || BPF_SIZE(insn->code) == BPF_DW ||
8283 /* non-recursive DFS pseudo code
8341 /* t, w, e - match pseudo-code above:
8429 if (BPF_CLASS(insns[t].code) == BPF_JMP || BPF_CLASS(insns[t].code) == BPF_JMP32) {
8430 u8 opcode = BPF_OP(insns[t].code);
8453 if (BPF_SRC(insns[t].code) != BPF_K) {
8769 if (!prog->insnsi[linfo[i].insn_off].code) {
8770 verbose(env, "Invalid insn code at line_info[%u].insn_off\n", i);
9266 /* Return 0 if no propagation happened. Return negative error code if error
9297 * straight-line code between a state and its parent. When we arrive at an
9299 * code, so read marks in the state must propagate to the parent regardless
9674 class = BPF_CLASS(insn->code);
9765 err = check_mem_access(env, env->insn_idx, insn->src_reg, insn->off, BPF_SIZE(insn->code), BPF_READ,
9792 if (BPF_MODE(insn->code) == BPF_XADD) {
9815 err = check_mem_access(env, env->insn_idx, insn->dst_reg, insn->off, BPF_SIZE(insn->code), BPF_WRITE,
9830 if (BPF_MODE(insn->code) != BPF_MEM || insn->src_reg != BPF_REG_0) {
9846 err = check_mem_access(env, env->insn_idx, insn->dst_reg, insn->off, BPF_SIZE(insn->code), BPF_WRITE, -1,
9852 u8 opcode = BPF_OP(insn->code);
9855 if (BPF_SRC(insn->code) != BPF_K || insn->off != 0 ||
9876 if (BPF_SRC(insn->code) != BPF_K || insn->imm != 0 || insn->src_reg != BPF_REG_0 ||
9884 if (BPF_SRC(insn->code) != BPF_K || insn->imm != 0 || insn->src_reg != BPF_REG_0 ||
9931 u8 mode = BPF_MODE(insn->code);
10079 * perf NMI can hit any arbitrary code sequence.
10165 if (BPF_CLASS(insn->code) == BPF_LDX && (BPF_MODE(insn->code) != BPF_MEM || insn->imm != 0)) {
10170 if (BPF_CLASS(insn->code) == BPF_STX &&
10171 ((BPF_MODE(insn->code) != BPF_MEM && BPF_MODE(insn->code) != BPF_XADD) || insn->imm != 0)) {
10176 if (insn[0].code == (BPF_LD | BPF_IMM | BPF_DW)) {
10182 if (i == insn_cnt - 1 || insn[1].code != 0 || insn[1].dst_reg != 0 || insn[1].src_reg != 0 ||
10294 if (!bpf_opcode_in_insntable(insn->code)) {
10295 verbose(env, "unknown opcode %02x\n", insn->code);
10321 if (insn->code == (BPF_LD | BPF_IMM | BPF_DW)) {
10459 /* func_info->insn_off is set after all code rewrites,
10579 * have dead code too. Therefore replace all dead at-run-time code
10585 * code also wouldn't work since we can have subprogs where the dead
10586 * code could be located.
10605 static bool insn_is_cond_jump(u8 code)
10609 if (BPF_CLASS(code) == BPF_JMP32) {
10613 if (BPF_CLASS(code) != BPF_JMP) {
10617 op = BPF_OP(code);
10630 if (!insn_is_cond_jump(insn->code)) {
10720 u8 code, class;
10727 code = insn.code;
10728 class = BPF_CLASS(code);
10738 if (class == BPF_LD && BPF_MODE(code) == BPF_IMM) {
10827 if (insn->code == (BPF_LDX | BPF_MEM | BPF_B) || insn->code == (BPF_LDX | BPF_MEM | BPF_H) ||
10828 insn->code == (BPF_LDX | BPF_MEM | BPF_W) || insn->code == (BPF_LDX | BPF_MEM | BPF_DW)) {
10831 } else if (insn->code == (BPF_STX | BPF_MEM | BPF_B) || insn->code == (BPF_STX | BPF_MEM | BPF_H) ||
10832 insn->code == (BPF_STX | BPF_MEM | BPF_W) || insn->code == (BPF_STX | BPF_MEM | BPF_DW) ||
10833 insn->code == (BPF_ST | BPF_MEM | BPF_B) || insn->code == (BPF_ST | BPF_MEM | BPF_H) ||
10834 insn->code == (BPF_ST | BPF_MEM | BPF_W) || insn->code == (BPF_ST | BPF_MEM | BPF_DW)) {
10836 ctx_access = BPF_CLASS(insn->code) == BPF_STX;
10882 insn->code = BPF_LDX | BPF_PROBE_MEM | BPF_SIZE((insn)->code);
10920 insn->code = BPF_LDX | BPF_MEM | size_code;
10978 if (insn->code != (BPF_JMP | BPF_CALL) || insn->src_reg != BPF_PSEUDO_CALL) {
11063 if (BPF_CLASS(insn->code) == BPF_LDX && BPF_MODE(insn->code) == BPF_PROBE_MEM) {
11084 if (insn->code != (BPF_JMP | BPF_CALL) || insn->src_reg != BPF_PSEUDO_CALL) {
11129 if (insn->code != (BPF_JMP | BPF_CALL) || insn->src_reg != BPF_PSEUDO_CALL) {
11168 if (insn->code != (BPF_JMP | BPF_CALL) || insn->src_reg != BPF_PSEUDO_CALL) {
11205 if (insn->code != (BPF_JMP | BPF_CALL) || insn->src_reg != BPF_PSEUDO_CALL) {
11239 if (insn->code == (BPF_ALU64 | BPF_MOD | BPF_X) || insn->code == (BPF_ALU64 | BPF_DIV | BPF_X) ||
11240 insn->code == (BPF_ALU | BPF_MOD | BPF_X) || insn->code == (BPF_ALU | BPF_DIV | BPF_X)) {
11241 bool is64 = BPF_CLASS(insn->code) == BPF_ALU64;
11242 bool isdiv = BPF_OP(insn->code) == BPF_DIV;
11273 if (BPF_CLASS(insn->code) == BPF_LD && (BPF_MODE(insn->code) == BPF_ABS || BPF_MODE(insn->code) == BPF_IND)) {
11291 if (insn->code == (BPF_ALU64 | BPF_ADD | BPF_X) || insn->code == (BPF_ALU64 | BPF_SUB | BPF_X)) {
11327 insn->code = insn->code == code_add ? code_sub : code_add;
11346 if (insn->code != (BPF_JMP | BPF_CALL)) {
11380 insn->code = BPF_JMP | BPF_TAIL_CALL;