X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Finclude%2Fpalacios%2Fvmm_instr_decoder.h;h=a7c63fb20591c55ca92859a2033d3003dfde80a5;hb=8d2c7907ad4b10ccb51dfb7e5ee7c02604b786ba;hp=ce494e748f9157dbec4bb553a452d8f282deec3a;hpb=ce3ab888e2ca5f14a89da45b4dc64122ff1e1050;p=palacios.releases.git diff --git a/palacios/include/palacios/vmm_instr_decoder.h b/palacios/include/palacios/vmm_instr_decoder.h index ce494e7..a7c63fb 100644 --- a/palacios/include/palacios/vmm_instr_decoder.h +++ b/palacios/include/palacios/vmm_instr_decoder.h @@ -151,7 +151,7 @@ static int get_addr_width(struct guest_info * info, struct x86_instr * instr) { return (instr->prefixes.addr_size) ? 4 : 2; } default: - PrintError("Unsupported CPU mode: %d\n", info->cpu_mode); + PrintError(info->vm_info, info, "Unsupported CPU mode: %d\n", info->cpu_mode); return -1; } } @@ -276,13 +276,13 @@ static int get_operand_width(struct guest_info * info, struct x86_instr * instr, return (instr->prefixes.op_size) ? 4 : 2; } default: - PrintError("Unsupported CPU mode: %d\n", info->cpu_mode); + PrintError(info->vm_info, info, "Unsupported CPU mode: %d\n", info->cpu_mode); return -1; } case INVLPG: switch (v3_get_vm_cpu_mode(info)) { case REAL: - PrintError("Invalid instruction given operating mode (%d)\n", form); + PrintError(info->vm_info, info, "Invalid instruction given operating mode (%d)\n", form); return 0; case PROTECTED: case PROTECTED_PAE: @@ -291,7 +291,7 @@ static int get_operand_width(struct guest_info * info, struct x86_instr * instr, case LONG: return 8; default: - PrintError("Unsupported CPU mode: %d\n", info->cpu_mode); + PrintError(info->vm_info, info, "Unsupported CPU mode: %d\n", info->cpu_mode); return -1; } @@ -307,7 +307,7 @@ static int get_operand_width(struct guest_info * info, struct x86_instr * instr, case LONG: return 8; default: - PrintError("Unsupported CPU mode: %d\n", info->cpu_mode); + PrintError(info->vm_info, info, "Unsupported CPU mode: %d\n", info->cpu_mode); return -1; } @@ -326,14 +326,14 @@ static int get_operand_width(struct guest_info * info, struct x86_instr * instr, case LONG: return 8; default: - PrintError("Unsupported CPU mode: %d\n", info->cpu_mode); + PrintError(info->vm_info, info, "Unsupported CPU mode: %d\n", info->cpu_mode); return -1; } case MOV_SR2: case MOV_2SR: default: - PrintError("Unsupported instruction form %d\n", form); + PrintError(info->vm_info, info, "Unsupported instruction form %d\n", form); return -1; } @@ -437,7 +437,7 @@ static inline int decode_gpr(struct guest_info * core, reg->operand = (addr_t)&(gprs->r15); break; default: - PrintError("Invalid Reg Code (%d)\n", reg_code); + PrintError(core->vm_info, core, "Invalid Reg Code (%d)\n", reg_code); reg->operand = 0; return -1; } @@ -454,7 +454,7 @@ static inline int decode_cr(struct guest_info * core, struct v3_ctrl_regs * crs = &(core->ctrl_regs); -// PrintDebug("\t Ctrl regs %d\n", reg_code); +// PrintDebug(core->vm_info, core, "\t Ctrl regs %d\n", reg_code); switch (reg_code) { case 0: @@ -471,13 +471,31 @@ static inline int decode_cr(struct guest_info * core, break; default: reg->operand = 0; - PrintError("Invalid Reg Code (%d)\n", reg_code); + PrintError(core->vm_info, core, "Invalid Reg Code (%d)\n", reg_code); return -1; } return 0; } +static struct v3_segment * get_instr_segment(struct guest_info * core, struct x86_instr * instr) { + struct v3_segment * seg = &(core->segments.ds); + + if (instr->prefixes.cs_override) { + seg = &(core->segments.cs); + } else if (instr->prefixes.es_override) { + seg = &(core->segments.es); + } else if (instr->prefixes.ss_override) { + seg = &(core->segments.ss); + } else if (instr->prefixes.fs_override) { + seg = &(core->segments.fs); + } else if (instr->prefixes.gs_override) { + seg = &(core->segments.gs); + } + + return seg; +} + #define ADDR_MASK(val, length) ({ \ @@ -510,14 +528,14 @@ static int decode_rm_operand16(struct guest_info * core, modrm_mode_t mod_mode = 0; uint8_t * instr_cursor = modrm_instr; - // PrintDebug("ModRM mod=%d\n", modrm->mod); + // PrintDebug(core->vm_info, core, "ModRM mod=%d\n", modrm->mod); *reg_code = modrm->reg; instr_cursor += 1; if (modrm->mod == 3) { - //PrintDebug("first operand = Register (RM=%d)\n",modrm->rm); + //PrintDebug(core->vm_info, core, "first operand = Register (RM=%d)\n",modrm->rm); operand->type = REG_OPERAND; decode_gpr(core, modrm->rm, operand); @@ -534,7 +552,7 @@ static int decode_rm_operand16(struct guest_info * core, } else if (modrm->mod == 2) { mod_mode = DISP16; } else { - PrintError("Instruction format error: Invalid mod_rm mode (%d)\n", modrm->mod); + PrintError(core->vm_info, core, "Instruction format error: Invalid mod_rm mode (%d)\n", modrm->mod); v3_print_instr(instr); return -1; } @@ -627,7 +645,7 @@ static int decode_rm_operand32(struct guest_info * core, if (modrm->mod == 3) { operand->type = REG_OPERAND; - // PrintDebug("first operand = Register (RM=%d)\n",modrm->rm); + // PrintDebug(core->vm_info, core, "first operand = Register (RM=%d)\n",modrm->rm); decode_gpr(core, modrm->rm, operand); @@ -643,7 +661,7 @@ static int decode_rm_operand32(struct guest_info * core, } else if (modrm->mod == 2) { mod_mode = DISP32; } else { - PrintError("Instruction format error: Invalid mod_rm mode (%d)\n", modrm->mod); + PrintError(core->vm_info, core, "Instruction format error: Invalid mod_rm mode (%d)\n", modrm->mod); v3_print_instr(instr); return -1; } @@ -806,7 +824,7 @@ int decode_rm_operand64(struct guest_info * core, uint8_t * modrm_instr, rm_val |= (instr->prefixes.rex_rm << 3); operand->type = REG_OPERAND; - // PrintDebug("first operand = Register (RM=%d)\n",modrm->rm); + // PrintDebug(core->vm_info, core, "first operand = Register (RM=%d)\n",modrm->rm); decode_gpr(core, rm_val, operand); } else { @@ -823,7 +841,7 @@ int decode_rm_operand64(struct guest_info * core, uint8_t * modrm_instr, } else if (modrm->mod == 2) { mod_mode = DISP32; } else { - PrintError("Instruction format error: Invalid mod_rm mode (%d)\n", modrm->mod); + PrintError(core->vm_info, core, "Instruction format error: Invalid mod_rm mode (%d)\n", modrm->mod); v3_print_instr(instr); return -1; } @@ -1075,7 +1093,7 @@ static int decode_rm_operand(struct guest_info * core, case LONG_32_COMPAT: return decode_rm_operand32(core, instr_ptr, instr, operand, reg_code); default: - PrintError("Invalid CPU_MODE (%d)\n", mode); + PrintError(core->vm_info, core, "Invalid CPU_MODE (%d)\n", mode); return -1; } }