X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Finclude%2Fpalacios%2Fvmm_decoder.h;h=aba2d40418a9e485e9ddf2eba49f1d65964a2318;hb=fdb16aa5e99a19a91264ae84beaf77d3036548d5;hp=81cf0b01452d3c60b4f732489be2a58a9f50170c;hpb=b3e5aa263c35961c74e0b7ed96b8510e8c6d7d0d;p=palacios.git diff --git a/palacios/include/palacios/vmm_decoder.h b/palacios/include/palacios/vmm_decoder.h index 81cf0b0..aba2d40 100644 --- a/palacios/include/palacios/vmm_decoder.h +++ b/palacios/include/palacios/vmm_decoder.h @@ -34,7 +34,7 @@ typedef enum { V3_INVALID_OP, V3_OP_SETB, V3_OP_SETBE, V3_OP_SETL, V3_OP_SETLE, V3_OP_SETNB, V3_OP_SETNBE, V3_OP_SETNL, V3_OP_SETNLE, V3_OP_SETNO, V3_OP_SETNP, V3_OP_SETNS, V3_OP_SETNZ, V3_OP_SETO, V3_OP_SETP, V3_OP_SETS, - V3_OP_SETZ, V3_OP_MOVS, V3_OP_STOS, V3_OP_MOVZX, V3_OP_MOVSX} v3_op_type_t; + V3_OP_SETZ, V3_OP_MOVS, V3_OP_STOS, V3_OP_MOVZX, V3_OP_MOVSX } v3_op_type_t; typedef enum {INVALID_OPERAND, REG_OPERAND, MEM_OPERAND, IMM_OPERAND} v3_operand_type_t; @@ -43,7 +43,9 @@ struct x86_operand { addr_t operand; uint_t size; v3_operand_type_t type; -}; + uint8_t read : 1; // This operand value will be read by the instruction + uint8_t write : 1; // This operand value will be written to by the instruction +} __attribute__((packed)); struct x86_prefixes { uint_t lock : 1; // 0xF0 @@ -62,12 +64,20 @@ struct x86_prefixes { uint_t br_taken : 1; // 0x3E uint_t op_size : 1; // 0x66 uint_t addr_size : 1; // 0x67 -}; + + uint_t rex : 1; + + uint_t rex_rm : 1; // REX.B + uint_t rex_sib_idx : 1; // REX.X + uint_t rex_reg : 1; // REX.R + uint_t rex_op_size : 1; // REX.W + +} __attribute__((packed)); struct x86_instr { struct x86_prefixes prefixes; - uint_t instr_length; + uint8_t instr_length; v3_op_type_t op_type; uint_t num_operands; struct x86_operand dst_operand; @@ -75,7 +85,6 @@ struct x86_instr { struct x86_operand third_operand; addr_t str_op_length; addr_t is_str_op; - void * decoder_data; }; @@ -110,15 +119,16 @@ int v3_decode(struct guest_info * info, addr_t instr_ptr, struct x86_instr * ins * any unused bytes at the end of instr_buf will be filled with nops * IMPORTANT: instr_buf must be allocated and 15 bytes long */ -int v3_encode(struct guest_info * info, struct x86_instr * instr, char * instr_buf); +int v3_encode(struct guest_info * info, struct x86_instr * instr, uint8_t * instr_buf); /* Removes a rep prefix in place */ -void v3_strip_rep_prefix(uchar_t * instr, int length); -void v3_get_prefixes(uchar_t * instr, struct x86_prefixes * prefixes); +void v3_strip_rep_prefix(uint8_t * instr, int length); +uint8_t v3_get_prefixes(uint8_t * instr, struct x86_prefixes * prefixes); +void v3_print_instr(struct x86_instr * instr); #define PREFIX_LOCK 0xF0