From: Jack Lange Date: Wed, 9 Mar 2011 01:10:53 +0000 (-0600) Subject: internal decoders works enough to boot a 32 bit linux guest X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=commitdiff_plain;h=14bea80332af1e5d63df6ab9fc86e449cdcb3c3a;p=palacios.git internal decoders works enough to boot a 32 bit linux guest --- diff --git a/palacios/include/palacios/vmm_instr_decoder.h b/palacios/include/palacios/vmm_instr_decoder.h index 15d6271..1c292a3 100644 --- a/palacios/include/palacios/vmm_instr_decoder.h +++ b/palacios/include/palacios/vmm_instr_decoder.h @@ -135,8 +135,7 @@ typedef enum { } op_form_t; -static int get_addr_width(struct guest_info * info, struct x86_instr * instr, - op_form_t form) { +static int get_addr_width(struct guest_info * info, struct x86_instr * instr) { switch (v3_get_vm_cpu_mode(info)) { case REAL: @@ -453,6 +452,25 @@ static inline int decode_cr(struct guest_info * core, val; \ }) + +#define ADDR_MASK(val, length) ({ \ + ullong_t mask = 0x0LL; \ + switch (length) { \ + case 2: \ + mask = 0x00000000000fffffLL; \ + break; \ + case 4: \ + mask = 0x00000000ffffffffLL; \ + break; \ + case 8: \ + mask = 0xffffffffffffffffLL; \ + break; \ + } \ + val & mask; \ + }) + + + static int decode_rm_operand16(struct guest_info * core, uint8_t * modrm_instr, struct x86_instr * instr, @@ -548,7 +566,8 @@ static int decode_rm_operand16(struct guest_info * core, seg = &(core->segments.ds); } - operand->operand = get_addr_linear(core, base_addr, seg); + operand->operand = ADDR_MASK(get_addr_linear(core, base_addr, seg), + get_addr_width(core, instr)); } @@ -718,7 +737,8 @@ static int decode_rm_operand32(struct guest_info * core, seg = &(core->segments.ds); } - operand->operand = get_addr_linear(core, base_addr, seg); + operand->operand = ADDR_MASK(get_addr_linear(core, base_addr, seg), + get_addr_width(core, instr)); } diff --git a/palacios/src/palacios/vmm_v3dec.c b/palacios/src/palacios/vmm_v3dec.c index f02d04b..7dd716e 100644 --- a/palacios/src/palacios/vmm_v3dec.c +++ b/palacios/src/palacios/vmm_v3dec.c @@ -21,33 +21,24 @@ #include -/* Disgusting mask hack... - I can't think right now, so we'll do it this way... -*/ -static const ullong_t mask_1 = 0x00000000000000ffLL; -static const ullong_t mask_2 = 0x000000000000ffffLL; -static const ullong_t mask_4 = 0x00000000ffffffffLL; -static const ullong_t mask_8 = 0xffffffffffffffffLL; - - -#define MASK(val, length) ({ \ - ullong_t mask = 0x0LL; \ - switch (length) { \ - case 1: \ - mask = mask_1; \ - break; \ - case 2: \ - mask = mask_2; \ - break; \ - case 4: \ - mask = mask_4; \ - break; \ - case 8: \ - mask = mask_8; \ - break; \ - } \ - val & mask; \ - }) +#define MASK(val, length) ({ \ + ullong_t mask = 0x0LL; \ + switch (length) { \ + case 1: \ + mask = 0x00000000000000ffLL; \ + break; \ + case 2: \ + mask = 0x000000000000ffffLL; \ + break; \ + case 4: \ + mask = 0x00000000ffffffffLL; \ + break; \ + case 8: \ + mask = 0xffffffffffffffffLL; \ + break; \ + } \ + val & mask; \ + }) static v3_op_type_t op_form_to_type(op_form_t form); static int parse_operands(struct guest_info * core, uint8_t * instr_ptr, struct x86_instr * instr, op_form_t form); @@ -124,7 +115,7 @@ static int parse_operands(struct guest_info * core, uint8_t * instr_ptr, struct x86_instr * instr, op_form_t form) { // get operational mode of the guest for operand width uint8_t operand_width = get_operand_width(core, instr, form); - uint8_t addr_width = get_addr_width(core, instr, form); + uint8_t addr_width = get_addr_width(core, instr); int ret = 0; uint8_t * instr_start = instr_ptr;