X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Finclude%2Fpalacios%2Fvmm_instr_decoder.h;h=ce494e748f9157dbec4bb553a452d8f282deec3a;hb=ce3ab888e2ca5f14a89da45b4dc64122ff1e1050;hp=2e2645700adc926be3263c83ef8fceef235ac58f;hpb=382829fe58cb541af371547325c5502e37032ecd;p=palacios.git diff --git a/palacios/include/palacios/vmm_instr_decoder.h b/palacios/include/palacios/vmm_instr_decoder.h index 2e26457..ce494e7 100644 --- a/palacios/include/palacios/vmm_instr_decoder.h +++ b/palacios/include/palacios/vmm_instr_decoder.h @@ -28,6 +28,7 @@ typedef enum { SMSW, CLTS, INVLPG, + INT, MOV_CR2, MOV_2CR, @@ -190,6 +191,7 @@ static int get_operand_width(struct guest_info * info, struct x86_instr * instr, case XOR_MEM2_8: case XOR_IMM2_8: case INC_8: + case INT: case DEC_8: case NEG_8: case NOT_8: @@ -220,8 +222,7 @@ static int get_operand_width(struct guest_info * info, struct x86_instr * instr, case MOV_MEM2: case MOV_2MEM: case MOV_MEM2AX: - case MOV_AX2MEM: - case MOV_IMM2: + case MOV_AX2MEM: case MOVS: case MOVSX: case MOVZX: @@ -255,6 +256,7 @@ static int get_operand_width(struct guest_info * info, struct x86_instr * instr, case OR_IMM2SX_8: case SUB_IMM2SX_8: case XOR_IMM2SX_8: + case MOV_IMM2: switch (v3_get_vm_cpu_mode(info)) { case REAL: return (instr->prefixes.op_size) ? 4 : 2; @@ -262,7 +264,7 @@ static int get_operand_width(struct guest_info * info, struct x86_instr * instr, if (instr->prefixes.rex_op_size) { return 8; } else { - return 4; + return (instr->prefixes.op_size) ? 2 : 4; } case PROTECTED: case PROTECTED_PAE: @@ -277,7 +279,6 @@ static int get_operand_width(struct guest_info * info, struct x86_instr * instr, PrintError("Unsupported CPU mode: %d\n", info->cpu_mode); return -1; } - case INVLPG: switch (v3_get_vm_cpu_mode(info)) { case REAL: @@ -310,6 +311,7 @@ static int get_operand_width(struct guest_info * info, struct x86_instr * instr, return -1; } + //case INT: case MOV_DR2: case MOV_2DR: case MOV_CR2: @@ -679,7 +681,6 @@ static int decode_rm_operand32(struct guest_info * core, } if (has_sib_byte) { - instr_cursor += 1; struct sib_byte * sib = (struct sib_byte *)(instr_cursor); int scale = 0x1 << sib->scale; @@ -734,6 +735,9 @@ static int decode_rm_operand32(struct guest_info * core, case 5: if (modrm->mod != 0) { base_addr += ADDR_MASK(gprs->rbp, 4); + } else { + mod_mode = DISP32; + base_addr = 0; } break; case 6: @@ -886,7 +890,6 @@ int decode_rm_operand64(struct guest_info * core, uint8_t * modrm_instr, } if (has_sib_byte) { - instr_cursor += 1; struct sib_byte * sib = (struct sib_byte *)(instr_cursor); int scale = 0x1 << sib->scale; uint8_t index_val = sib->index; @@ -970,6 +973,9 @@ int decode_rm_operand64(struct guest_info * core, uint8_t * modrm_instr, case 5: if (modrm->mod != 0) { base_addr += gprs->rbp; + } else { + mod_mode = DISP32; + base_addr = 0; } break; case 6: @@ -1016,23 +1022,24 @@ int decode_rm_operand64(struct guest_info * core, uint8_t * modrm_instr, } - /* - Segments should be ignored - // get appropriate segment - 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); - } else { - seg = &(core->segments.ds); - } - */ + + //Segments should be ignored + // get appropriate segment + + 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); + } else { + seg = &(core->segments.ds); + } + operand->operand = ADDR_MASK(get_addr_linear(core, base_addr, seg), get_addr_width(core, instr)); @@ -1060,7 +1067,7 @@ static int decode_rm_operand(struct guest_info * core, case REAL: return decode_rm_operand16(core, instr_ptr, instr, operand, reg_code); case LONG: - if (instr->prefixes.rex_op_size) { + if (instr->prefixes.rex) { return decode_rm_operand64(core, instr_ptr, instr, operand, reg_code); } case PROTECTED: @@ -1331,6 +1338,8 @@ static op_form_t op_code_to_form(uint8_t * instr, int * length) { case 0xf4: return HLT; + case 0xcd: + return INT; case 0xf6: { struct modrm_byte * modrm = (struct modrm_byte *)&(instr[1]); @@ -1493,6 +1502,7 @@ static char * op_form_to_str(op_form_t form) { case SETO: return "SETO"; case STOS_8: return "STOS_8"; case STOS: return "STOS"; + case INT: return "INT"; case INVALID_INSTR: default: