#include <palacios/vmm_instr_emulator.h>
#include <palacios/vmm_ctrl_regs.h>
-#ifndef CONFIG_DEBUG_EMULATOR
+#ifndef V3_CONFIG_DEBUG_EMULATOR
#undef PrintDebug
#define PrintDebug(fmt, args...)
#endif
int src_op_size, int dst_op_size) {
if (src_op_size == 1) {
- PrintDebug("Executing 8 bit instruction\n");
+ PrintDebug(info->vm_info, info, "Executing 8 bit instruction\n");
switch (op_type) {
case V3_OP_ADC:
break;
default:
- PrintError("Unknown 8 bit instruction\n");
+ PrintError(info->vm_info, info, "Unknown 8 bit instruction\n");
return -1;
}
} else if (src_op_size == 2) {
- PrintDebug("Executing 16 bit instruction\n");
+ PrintDebug(info->vm_info, info, "Executing 16 bit instruction\n");
switch (op_type) {
case V3_OP_ADC:
break;
default:
- PrintError("Unknown 16 bit instruction\n");
+ PrintError(info->vm_info, info, "Unknown 16 bit instruction\n");
return -1;
}
} else if (src_op_size == 4) {
- PrintDebug("Executing 32 bit instruction\n");
+ PrintDebug(info->vm_info, info, "Executing 32 bit instruction\n");
switch (op_type) {
case V3_OP_ADC:
break;
default:
- PrintError("Unknown 32 bit instruction\n");
+ PrintError(info->vm_info, info, "Unknown 32 bit instruction\n");
return -1;
}
#ifdef __V3_64BIT__
} else if (src_op_size == 8) {
- PrintDebug("Executing 64 bit instruction\n");
+ PrintDebug(info->vm_info, info, "Executing 64 bit instruction\n");
switch (op_type) {
case V3_OP_ADC:
break;
default:
- PrintError("Unknown 64 bit instruction\n");
+ PrintError(info->vm_info, info, "Unknown 64 bit instruction\n");
return -1;
}
#endif
} else {
- PrintError("Invalid Operation Size\n");
+ PrintError(info->vm_info, info, "Invalid Operation Size\n");
return -1;
}
int emulation_length = op_size * rep_cnt;
struct rflags * flags_reg = (struct rflags *)&(core->ctrl_regs.rflags);
+
+ PrintDebug(core->vm_info, core, "Emulation_len=%d, tmp_rcx=%d\n", emulation_length, (uint_t)tmp_rcx);
+
+
if (instr->op_type == V3_OP_MOVS) {
if (op_size== 1) {
movs8((addr_t *)&dst_addr, &src_addr, &tmp_rcx, (addr_t *)&(core->ctrl_regs.rflags));
movs64((addr_t *)&dst_addr, &src_addr, &tmp_rcx, (addr_t *)&(core->ctrl_regs.rflags));
#endif
} else {
- PrintError("Invalid operand length\n");
+ PrintError(core->vm_info, core, "Invalid operand length\n");
return -1;
}
stos64((addr_t *)&dst_addr, (addr_t *)&(core->vm_regs.rax), &tmp_rcx, (addr_t *)&(core->ctrl_regs.rflags));
#endif
} else {
- PrintError("Invalid operand length\n");
+ PrintError(core->vm_info, core, "Invalid operand length\n");
return -1;
}
+
+
if (flags_reg->df == 0) {
core->vm_regs.rdi += emulation_length;
} else {
core->vm_regs.rcx -= rep_cnt;
}
} else {
- PrintError("Unimplemented String operation\n");
+ PrintError(core->vm_info, core, "Unimplemented String operation\n");
return -1;
}
addr_t src_hva = 0;
addr_t dst_hva = 0;
-
- PrintError("USING THE NEW EMULATOR\n");
+
if (instr->src_operand.type == MEM_OPERAND) {
src_hva = mem_hva_src;
} else {
src_hva = (addr_t)&(instr->src_operand.operand);
}
-
+
if (instr->dst_operand.type == MEM_OPERAND) {
dst_hva = mem_hva_dst;
} else if (instr->dst_operand.type == REG_OPERAND) {
} else {
dst_hva = (addr_t)&(instr->dst_operand.operand);
}
-
+
if (instr->is_str_op == 0) {
int src_op_len = instr->src_operand.size;
}
-
return -1;
}