X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvmm_emulator.c;h=f80aade45891286c1e2148669c3d1add953587c1;hb=46b8faf02be8ec628db5683bc6fdb55e72344c18;hp=8355a28da2c16d516c8126b0bca0fac7621928e1;hpb=d3b877f95b726298bb1ba71027364086bb873fe1;p=palacios.git diff --git a/palacios/src/palacios/vmm_emulator.c b/palacios/src/palacios/vmm_emulator.c index 8355a28..f80aade 100644 --- a/palacios/src/palacios/vmm_emulator.c +++ b/palacios/src/palacios/vmm_emulator.c @@ -24,7 +24,7 @@ #include #include -#ifndef DEBUG_EMULATOR +#ifndef CONFIG_DEBUG_EMULATOR #undef PrintDebug #define PrintDebug(fmt, args...) #endif @@ -38,6 +38,7 @@ static int emulate_string_write_op(struct guest_info * info, struct x86_instr * int (*write_fn)(addr_t guest_addr, void * src, uint_t length, void * priv_data), void * priv_data) { uint_t emulation_length = 0; + uint_t emulation_iter_cnt = 0; addr_t tmp_rcx = 0; addr_t src_addr = 0; @@ -47,12 +48,16 @@ static int emulate_string_write_op(struct guest_info * info, struct x86_instr * return -1; } - emulation_length = ( (dec_instr->str_op_length < (0x1000 - PAGE_OFFSET_4KB(write_gva))) ? + /*emulation_length = ( (dec_instr->str_op_length < (0x1000 - PAGE_OFFSET_4KB(write_gva))) ? dec_instr->str_op_length : + (0x1000 - PAGE_OFFSET_4KB(write_gva)));*/ + emulation_length = ( (dec_instr->str_op_length * (dec_instr->dst_operand.size) < (0x1000 - PAGE_OFFSET_4KB(write_gva))) ? + dec_instr->str_op_length * dec_instr->dst_operand.size : (0x1000 - PAGE_OFFSET_4KB(write_gva))); /* ** Fix emulation length so that it doesn't overrun over the src page either ** */ - tmp_rcx = emulation_length / dec_instr->dst_operand.size; + emulation_iter_cnt = emulation_length / dec_instr->dst_operand.size; + tmp_rcx = emulation_iter_cnt; if (dec_instr->op_type == V3_OP_MOVS) { @@ -89,7 +94,7 @@ static int emulate_string_write_op(struct guest_info * info, struct x86_instr * // RCX is only modified if the rep prefix is present if (dec_instr->prefixes.rep == 1) { - info->vm_regs.rcx -= emulation_length; + info->vm_regs.rcx -= emulation_iter_cnt; } } else if (dec_instr->op_type == V3_OP_STOS) { @@ -113,7 +118,7 @@ static int emulate_string_write_op(struct guest_info * info, struct x86_instr * // RCX is only modified if the rep prefix is present if (dec_instr->prefixes.rep == 1) { - info->vm_regs.rcx -= emulation_length; + info->vm_regs.rcx -= emulation_iter_cnt; } } else {