Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 93768
b: refs/heads/master
c: e09d082
h: refs/heads/master
v: v3
  • Loading branch information
Avi Kivity committed Apr 27, 2008
1 parent e5b6b62 commit 59a0669
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 1ae0a13def678876b9acfb5ac1e2cf7d5d45a60d
refs/heads/master: e09d082c03e137015bc0a17ca77e4b9dca08a5d7
33 changes: 27 additions & 6 deletions trunk/arch/x86/kvm/x86_emulate.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@
#define MemAbs (1<<9) /* Memory operand is absolute displacement */
#define String (1<<10) /* String instruction (rep capable) */
#define Stack (1<<11) /* Stack instruction (push/pop) */
#define Group (1<<14) /* Bits 3:5 of modrm byte extend opcode */
#define GroupDual (1<<15) /* Alternate decoding of mod == 3 */
#define GroupMask 0xff /* Group number stored in bits 0:7 */

static u16 opcode_table[256] = {
/* 0x00 - 0x07 */
Expand Down Expand Up @@ -229,6 +232,12 @@ static u16 twobyte_table[256] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};

static u16 group_table[] = {
};

static u16 group2_table[] = {
};

/* EFLAGS bit definitions. */
#define EFLG_OF (1<<11)
#define EFLG_DF (1<<10)
Expand Down Expand Up @@ -763,7 +772,7 @@ x86_decode_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
struct decode_cache *c = &ctxt->decode;
int rc = 0;
int mode = ctxt->mode;
int def_op_bytes, def_ad_bytes;
int def_op_bytes, def_ad_bytes, group;

/* Shadow copy of register state. Committed on successful emulation. */

Expand Down Expand Up @@ -864,12 +873,24 @@ x86_decode_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
c->b = insn_fetch(u8, 1, c->eip);
c->d = twobyte_table[c->b];
}
}

/* Unrecognised? */
if (c->d == 0) {
DPRINTF("Cannot emulate %02x\n", c->b);
return -1;
}
if (c->d & Group) {
group = c->d & GroupMask;
c->modrm = insn_fetch(u8, 1, c->eip);
--c->eip;

group = (group << 3) + ((c->modrm >> 3) & 7);
if ((c->d & GroupDual) && (c->modrm >> 6) == 3)
c->d = group2_table[group];
else
c->d = group_table[group];
}

/* Unrecognised? */
if (c->d == 0) {
DPRINTF("Cannot emulate %02x\n", c->b);
return -1;
}

if (mode == X86EMUL_MODE_PROT64 && (c->d & Stack))
Expand Down

0 comments on commit 59a0669

Please sign in to comment.