X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvmm_emulator.c;h=1bd777d7447e67a33e546615b8ff74ea754e6da8;hb=bbfa5bc2f12eab6c8dc8f2640bcfd66d18475272;hp=e5cf1f21efe7f95d0975c5566473813453dbd0c5;hpb=0a4bd37f65c15fe50680e51b68f3f95ec8d347ea;p=palacios.git diff --git a/palacios/src/palacios/vmm_emulator.c b/palacios/src/palacios/vmm_emulator.c index e5cf1f2..1bd777d 100644 --- a/palacios/src/palacios/vmm_emulator.c +++ b/palacios/src/palacios/vmm_emulator.c @@ -24,7 +24,7 @@ #include #include -#ifndef CONFIG_DEBUG_EMULATOR +#ifndef V3_CONFIG_DEBUG_EMULATOR #undef PrintDebug #define PrintDebug(fmt, args...) #endif @@ -35,7 +35,7 @@ static int run_op(struct guest_info * info, v3_op_type_t op_type, 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: @@ -135,12 +135,12 @@ static int run_op(struct guest_info * info, v3_op_type_t op_type, 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: @@ -190,12 +190,12 @@ static int run_op(struct guest_info * info, v3_op_type_t op_type, 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: @@ -239,13 +239,13 @@ static int run_op(struct guest_info * info, v3_op_type_t op_type, 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: @@ -289,13 +289,13 @@ static int run_op(struct guest_info * info, v3_op_type_t op_type, 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; } @@ -313,6 +313,10 @@ static int run_str_op(struct guest_info * core, struct x86_instr * instr, 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)); @@ -325,7 +329,7 @@ static int run_str_op(struct guest_info * core, struct x86_instr * instr, 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; } @@ -354,10 +358,12 @@ static int run_str_op(struct guest_info * core, struct x86_instr * instr, 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 { @@ -369,7 +375,7 @@ static int run_str_op(struct guest_info * core, struct x86_instr * instr, core->vm_regs.rcx -= rep_cnt; } } else { - PrintError("Unimplemented String operation\n"); + PrintError(core->vm_info, core, "Unimplemented String operation\n"); return -1; } @@ -383,8 +389,7 @@ int v3_emulate(struct guest_info * core, struct x86_instr * instr, 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; @@ -393,7 +398,7 @@ int v3_emulate(struct guest_info * core, struct x86_instr * instr, } 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) { @@ -401,7 +406,7 @@ int v3_emulate(struct guest_info * core, struct x86_instr * instr, } else { dst_hva = (addr_t)&(instr->dst_operand.operand); } - + if (instr->is_str_op == 0) { int src_op_len = instr->src_operand.size; @@ -421,6 +426,5 @@ int v3_emulate(struct guest_info * core, struct x86_instr * instr, } - return -1; }