Home | History | Annotate | Download | only in bpf

Lines Matching refs:insn

477 decode (SIM_CPU *cpu, uint64_t pc, struct bpf_insn *insn)
486 /* Initialize the insn struct. */
487 memset (insn, 0, sizeof (struct bpf_insn));
497 insn->id = opcode->id;
498 insn->size = 8;
509 insn->dst = bpf_extract_dst (word, endian);
514 insn->src = bpf_extract_src (word, endian);
519 insn->dst = bpf_extract_dst (word, endian);
524 insn->src = bpf_extract_src (word, endian);
531 insn->imm32 = bpf_extract_imm32 (word, endian);
537 insn->offset16 = bpf_extract_offset16 (word, endian);
545 insn->imm64 = bpf_extract_imm64 (word, word2, endian);
546 insn->size = 16;
614 execute (SIM_CPU *cpu, struct bpf_insn *insn)
616 uint64_t next_pc = bpf_pc + insn->size;
631 switch (insn->id)
642 bpf_regs[insn->dst] += bpf_regs[insn->src];
646 bpf_regs[insn->dst] += insn->imm32;
650 bpf_regs[insn->dst] -= bpf_regs[insn->src];
654 bpf_regs[insn->dst] -= insn->imm32;
658 bpf_regs[insn->dst] *= bpf_regs[insn->src];
662 bpf_regs[insn->dst] *= insn->imm32;
666 if (bpf_regs[insn->src] == 0)
668 bpf_regs[insn->dst] /= bpf_regs[insn->src];
672 if (insn->imm32 == 0)
674 bpf_regs[insn->dst] /= insn->imm32;
678 if (bpf_regs[insn->src] == 0)
680 bpf_regs[insn->dst] %= bpf_regs[insn->src];
684 if (insn->imm32 == 0)
686 bpf_regs[insn->dst] %= insn->imm32;
690 bpf_regs[insn->dst] |= bpf_regs[insn->src];
694 bpf_regs[insn->dst] |= insn->imm32;
698 bpf_regs[insn->dst] &= bpf_regs[insn->src];
702 bpf_regs[insn->dst] &= insn->imm32;
706 bpf_regs[insn->dst] ^= bpf_regs[insn->src];
710 bpf_regs[insn->dst] ^= insn->imm32;
714 if (bpf_regs[insn->src] == 0)
716 bpf_regs[insn->dst] = (int64_t) bpf_regs[insn->dst] / (int64_t) bpf_regs[insn->src];
720 if (insn->imm32 == 0)
722 bpf_regs[insn->dst] = (int64_t) bpf_regs[insn->dst] / (int64_t) insn->imm32;
726 if (bpf_regs[insn->src] == 0)
728 bpf_regs[insn->dst] = (int64_t) bpf_regs[insn->dst] % (int64_t) bpf_regs[insn->src];
732 if (insn->imm32 == 0)
734 bpf_regs[insn->dst] = (int64_t) bpf_regs[insn->dst] % (int64_t) insn->imm32;
738 bpf_regs[insn->dst] = - (int64_t) bpf_regs[insn->dst];
742 bpf_regs[insn->dst] <<= bpf_regs[insn->src];
746 bpf_regs[insn->dst] <<= insn->imm32;
750 bpf_regs[insn->dst] >>= bpf_regs[insn->src];
754 bpf_regs[insn->dst] >>= insn->imm32;
758 bpf_regs[insn->dst] = (int64_t) bpf_regs[insn->dst] >> bpf_regs[insn->src];
762 bpf_regs[insn->dst] = (int64_t) bpf_regs[insn->dst] >> insn->imm32;
766 bpf_regs[insn->dst] = bpf_regs[insn->src];
770 bpf_regs[insn->dst] = insn->imm32;
775 bpf_regs[insn->dst] = (int32_t) bpf_regs[insn->dst] + (int32_t) bpf_regs[insn->src];
779 bpf_regs[insn->dst] = (int32_t) bpf_regs[insn->dst] + insn->imm32;
783 bpf_regs[insn->dst] = (int32_t) bpf_regs[insn->dst] - (int32_t) bpf_regs[insn->src];
787 bpf_regs[insn->dst] = (int32_t) bpf_regs[insn->dst] - insn->imm32;
791 bpf_regs[insn->dst] = (int32_t) bpf_regs[insn->dst] * (int32_t) bpf_regs[insn->src];
795 bpf_regs[insn->dst] = (int32_t) bpf_regs[insn->dst] * (int32_t) insn->imm32;
799 if (bpf_regs[insn->src] == 0)
801 bpf_regs[insn->dst] = (uint32_t) bpf_regs[insn->dst] / (uint32_t) bpf_regs[insn->src];
805 if (insn->imm32 == 0)
807 bpf_regs[insn->dst] = (uint32_t) bpf_regs[insn->dst] / (uint32_t) insn->imm32;
811 if (bpf_regs[insn->src] == 0)
813 bpf_regs[insn->dst] = (uint32_t) bpf_regs[insn->dst] % (uint32_t) bpf_regs[insn->src];
817 if (insn->imm32 == 0)
819 bpf_regs[insn->dst] = (uint32_t) bpf_regs[insn->dst] % (uint32_t) insn->imm32;
823 bpf_regs[insn->dst] = (uint32_t) bpf_regs[insn->dst] | (int32_t) bpf_regs[insn->src];
827 bpf_regs[insn->dst] = (uint32_t) bpf_regs[insn->dst] | (int32_t) insn->imm32;
831 bpf_regs[insn->dst] = (uint32_t) bpf_regs[insn->dst] & (int32_t) bpf_regs[insn->src];
835 bpf_regs[insn->dst] = (uint32_t) bpf_regs[insn->dst] & (int32_t) insn->imm32;
839 bpf_regs[insn->dst] = (uint32_t) bpf_regs[insn->dst] ^ (int32_t) bpf_regs[insn->src];
843 bpf_regs[insn->dst] = (uint32_t) bpf_regs[insn->dst] ^ (int32_t) insn->imm32;
847 if (bpf_regs[insn->src] == 0)
849 bpf_regs[insn->dst] = (int32_t) bpf_regs[insn->dst] / (int32_t) bpf_regs[insn->src];
853 if (insn->imm32 == 0)
855 bpf_regs[insn->dst] = (int32_t) bpf_regs[insn->dst] / (int32_t) insn->imm32;
859 if (bpf_regs[insn->src] == 0)
861 bpf_regs[insn->dst] = (int32_t) bpf_regs[insn->dst] % (int32_t) bpf_regs[insn->src];
865 if (insn->imm32 == 0)
867 bpf_regs[insn->dst] = (int32_t) bpf_regs[insn->dst] % (int32_t) insn->imm32;
871 bpf_regs[insn->dst] = (uint32_t) (- (int32_t) bpf_regs[insn->dst]);
875 bpf_regs[insn->dst] = (uint32_t) bpf_regs[insn->dst] << bpf_regs[insn->src];
879 bpf_regs[insn->dst] = (uint32_t) bpf_regs[insn->dst] << insn->imm32;
883 bpf_regs[insn->dst] = (uint32_t) bpf_regs[insn->dst] >> bpf_regs[insn->src];
887 bpf_regs[insn->dst] = (uint32_t) bpf_regs[insn->dst] >> insn->imm32;
891 bpf_regs[insn->dst] = (uint32_t)((int32_t)(uint32_t) bpf_regs[insn->dst] >> bpf_regs[insn->src]);
895 bpf_regs[insn->dst] = (uint32_t)((int32_t)(uint32_t) bpf_regs[insn->dst] >> insn->imm32);
899 bpf_regs[insn->dst] = (uint32_t) bpf_regs[insn->src];
903 bpf_regs[insn->dst] = (uint32_t) insn->imm32;
908 bpf_regs[insn->dst] = endian_h2le_2 (endian_t2h_2 (bpf_regs[insn->dst]));
912 bpf_regs[insn->dst] = endian_h2le_4 (endian_t2h_4 (bpf_regs[insn->dst]));
916 bpf_regs[insn->dst] = endian_h2le_8 (endian_t2h_8 (bpf_regs[insn->dst]));
920 bpf_regs[insn->dst] = endian_h2be_2 (endian_t2h_2 (bpf_regs[insn->dst]));
924 bpf_regs[insn->dst] = endian_h2be_4 (endian_t2h_4 (bpf_regs[insn->dst]));
928 bpf_regs[insn->dst] = endian_h2be_8 (endian_t2h_8 (bpf_regs[insn->dst]));
933 bpf_regs[insn->dst] = insn->imm64;
940 + bpf_regs[insn->src] + insn->imm32);
946 + bpf_regs[insn->src] + insn->imm32);
952 + bpf_regs[insn->src] + insn->imm32);
958 + insn->imm32);
964 + insn->imm32);
970 + insn->imm32);
975 bpf_regs[insn->dst] = (int8_t) bpf_read_u8 (cpu,
976 bpf_regs[insn->src] + insn->offset16);
980 bpf_regs[insn->dst] = (int16_t) bpf_read_u16 (cpu,
981 bpf_regs[insn->src] + insn->offset16);
985 bpf_regs[insn->dst] = (int32_t) bpf_read_u32 (cpu,
986 bpf_regs[insn->src] + insn->offset16);
990 bpf_regs[insn->dst] = bpf_read_u64 (cpu,
991 bpf_regs[insn->src] + insn->offset16);
997 bpf_regs[insn->dst] + insn->offset16,
998 bpf_regs[insn->src]);
1003 bpf_regs[insn->dst] + insn->offset16,
1004 bpf_regs[insn->src]);
1009 bpf_regs[insn->dst] + insn->offset16,
1010 bpf_regs[insn->src]);
1015 insn->dst] + insn->offset16,
1016 bpf_regs[insn->src]);
1022 bpf_regs[insn->dst] + insn->offset16,
1023 insn->imm32);
1028 bpf_regs[insn->dst] + insn->offset16,
1029 insn->imm32);
1034 bpf_regs[insn->dst] + insn->offset16,
1035 insn->imm32);
1040 bpf_regs[insn->dst] + insn->offset16,
1041 insn->imm32);
1046 next_pc = bpf_pc + DISP (insn->offset16);
1050 if (bpf_regs[insn->dst] == bpf_regs[insn->src])
1051 next_pc = bpf_pc + DISP (insn->offset16);
1055 if (bpf_regs[insn->dst] > bpf_regs[insn->src])
1056 next_pc = bpf_pc + DISP (insn->offset16);
1060 if ((int64_t) bpf_regs[insn->dst] > (int64_t) bpf_regs[insn->src])
1061 next_pc = bpf_pc + DISP (insn->offset16);
1065 if (bpf_regs[insn->dst] >= bpf_regs[insn->src])
1066 next_pc = bpf_pc + DISP (insn->offset16);
1070 if ((int64_t) bpf_regs[insn->dst] >= (int64_t) bpf_regs[insn->src])
1071 next_pc = bpf_pc + DISP (insn->offset16);
1075 if (bpf_regs[insn->dst] < bpf_regs[insn->src])
1076 next_pc = bpf_pc + DISP (insn->offset16);
1080 if ((int64_t) bpf_regs[insn->dst] < (int64_t) bpf_regs[insn->src])
1081 next_pc = bpf_pc + DISP (insn->offset16);
1085 if (bpf_regs[insn->dst] <= bpf_regs[insn->src])
1086 next_pc = bpf_pc + DISP (insn->offset16);
1090 if ((int64_t) bpf_regs[insn->dst] <= (int64_t) bpf_regs[insn->src])
1091 next_pc = bpf_pc + DISP (insn->offset16);
1095 if (bpf_regs[insn->dst] & bpf_regs[insn->src])
1096 next_pc = bpf_pc + DISP (insn->offset16);
1100 if (bpf_regs[insn->dst] != bpf_regs[insn->src])
1101 next_pc = bpf_pc + DISP (insn->offset16);
1105 bpf_call (cpu, DISP (bpf_regs[insn->dst]), insn->src);
1109 bpf_call (cpu, insn->imm32, insn->src);
1124 if (bpf_regs[insn->dst] == insn->imm32)
1125 next_pc = bpf_pc + DISP (insn->offset16);
1129 if (bpf_regs[insn->dst] > insn->imm32)
1130 next_pc = bpf_pc + DISP (insn->offset16);
1134 if ((int64_t) bpf_regs[insn->dst] > insn->imm32)
1135 next_pc = bpf_pc + DISP (insn->offset16);
1139 if (bpf_regs[insn->dst] >= insn->imm32)
1140 next_pc = bpf_pc + DISP (insn->offset16);
1144 if ((int64_t) bpf_regs[insn->dst] >= (int64_t) insn->imm32)
1145 next_pc = bpf_pc + DISP (insn->offset16);
1149 if (bpf_regs[insn->dst] < insn->imm32)
1150 next_pc = bpf_pc + DISP (insn->offset16);
1154 if ((int64_t) bpf_regs[insn->dst] < (int64_t) insn->imm32)
1155 next_pc = bpf_pc + DISP (insn->offset16);
1159 if (bpf_regs[insn->dst] <= insn->imm32)
1160 next_pc = bpf_pc + DISP (insn->offset16);
1164 if ((int64_t) bpf_regs[insn->dst] <= (int64_t) insn->imm32)
1165 next_pc = bpf_pc + DISP (insn->offset16);
1169 if (bpf_regs[insn->dst] & insn->imm32)
1170 next_pc = bpf_pc + DISP (insn->offset16);
1174 if (bpf_regs[insn->dst] != insn->imm32)
1175 next_pc = bpf_pc + DISP (insn->offset16);
1180 if ((uint32_t) bpf_regs[insn->dst] == (uint32_t) bpf_regs[insn->src])
1181 next_pc = bpf_pc + DISP (insn->offset16);
1185 if ((uint32_t) bpf_regs[insn->dst] > (uint32_t) bpf_regs[insn->src])
1186 next_pc = bpf_pc + DISP (insn->offset16);
1190 if ((int32_t) bpf_regs[insn->dst] > (int32_t) bpf_regs[insn->src])
1191 next_pc = bpf_pc + DISP (insn->offset16);
1195 if ((uint32_t) bpf_regs[insn->dst] >= (uint32_t) bpf_regs[insn->src])
1196 next_pc = bpf_pc + DISP (insn->offset16);
1200 if ((int32_t) bpf_regs[insn->dst] >= (int32_t) bpf_regs[insn->src])
1201 next_pc = bpf_pc + DISP (insn->offset16);
1205 if ((uint32_t) bpf_regs[insn->dst] < (uint32_t) bpf_regs[insn->src])
1206 next_pc = bpf_pc + DISP (insn->offset16);
1210 if ((int32_t) bpf_regs[insn->dst] < (int32_t) bpf_regs[insn->src])
1211 next_pc = bpf_pc + DISP (insn->offset16);
1215 if ((uint32_t) bpf_regs[insn->dst] <= (uint32_t) bpf_regs[insn->src])
1216 next_pc = bpf_pc + DISP (insn->offset16);
1220 if ((int32_t) bpf_regs[insn->dst] <= (int32_t) bpf_regs[insn->src])
1221 next_pc = bpf_pc + DISP (insn->offset16);
1225 if ((uint32_t) bpf_regs[insn->dst] & (uint32_t) bpf_regs[insn->src])
1226 next_pc = bpf_pc + DISP (insn->offset16);
1230 if ((uint32_t) bpf_regs[insn->dst] != (uint32_t) bpf_regs[insn->src])
1231 next_pc = bpf_pc + DISP (insn->offset16);
1236 if ((uint32_t) bpf_regs[insn->dst] == insn->imm32)
1237 next_pc = bpf_pc + DISP (insn->offset16);
1241 if ((uint32_t) bpf_regs[insn->dst] > insn->imm32)
1242 next_pc = bpf_pc + DISP (insn->offset16);
1246 if ((int32_t) bpf_regs[insn->dst] > insn->imm32)
1247 next_pc = bpf_pc + DISP (insn->offset16);
1251 if ((uint32_t) bpf_regs[insn->dst] >= insn->imm32)
1252 next_pc = bpf_pc + DISP (insn->offset16);
1256 if ((int32_t) bpf_regs[insn->dst] >= (int32_t) insn->imm32)
1257 next_pc = bpf_pc + DISP (insn->offset16);
1261 if ((uint32_t) bpf_regs[insn->dst] < insn->imm32)
1262 next_pc = bpf_pc + DISP (insn->offset16);
1266 if ((int32_t) bpf_regs[insn->dst] < (int32_t) insn->imm32)
1267 next_pc = bpf_pc + DISP (insn->offset16);
1271 if ((uint32_t) bpf_regs[insn->dst] <= insn->imm32)
1272 next_pc = bpf_pc + DISP (insn->offset16);
1276 if ((int32_t) bpf_regs[insn->dst] <= (int32_t) insn->imm32)
1277 next_pc = bpf_pc + DISP (insn->offset16);
1281 if ((uint32_t) bpf_regs[insn->dst] & insn->imm32)
1282 next_pc = bpf_pc + DISP (insn->offset16);
1286 if ((uint32_t) bpf_regs[insn->dst] != insn->imm32)
1287 next_pc = bpf_pc + DISP (insn->offset16);
1293 bpf_regs[insn->dst] + insn->offset16,
1294 bpf_read_u64 (cpu, bpf_regs[insn->dst] + insn->offset16)
1295 + bpf_regs[insn->src]);
1300 bpf_regs[insn->dst] + insn->offset16,
1301 (int32_t) bpf_read_u32 (cpu, bpf_regs[insn->dst] + insn->offset16)
1302 + bpf_regs[insn->src]);
1422 struct bpf_insn insn;
1426 if (!decode (cpu, bpf_pc, &insn))
1433 if (!execute (cpu, &insn))