Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 80639
b: refs/heads/master
c: b4c6abf
h: refs/heads/master
i:
  80637: 38426eb
  80635: 8186324
  80631: f24cb69
  80623: ac5f619
  80607: e7277ed
  80575: 9c68d8b
  80511: aa8bd81
  80383: e13e23c
v: v3
  • Loading branch information
Laurent Vivier authored and Avi Kivity committed Jan 30, 2008
1 parent 34164b3 commit 4ec94cc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 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: a22436b7b8ec9b14a0451d9ac0fdc9d370bd7800
refs/heads/master: b4c6abfef400c0f74d9b86a149a6719706cfdbbc
24 changes: 15 additions & 9 deletions trunk/drivers/kvm/x86_emulate.c
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,6 @@ x86_decode_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
{
struct decode_cache *c = &ctxt->decode;
u8 sib, rex_prefix = 0;
unsigned int i;
int rc = 0;
int mode = ctxt->mode;
int index_reg = 0, base_reg = 0, scale, rip_relative = 0;
Expand Down Expand Up @@ -551,7 +550,7 @@ x86_decode_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
}

/* Legacy prefixes. */
for (i = 0; i < 8; i++) {
for (;;) {
switch (c->b = insn_fetch(u8, 1, c->eip)) {
case 0x66: /* operand-size override */
c->op_bytes ^= 6; /* switch between 2/4 bytes */
Expand Down Expand Up @@ -582,6 +581,11 @@ x86_decode_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
case 0x36: /* SS override */
c->override_base = &ctxt->ss_base;
break;
case 0x40 ... 0x4f: /* REX */
if (mode != X86EMUL_MODE_PROT64)
goto done_prefixes;
rex_prefix = c->b;
continue;
case 0xf0: /* LOCK */
c->lock_prefix = 1;
break;
Expand All @@ -592,19 +596,21 @@ x86_decode_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
default:
goto done_prefixes;
}

/* Any legacy prefix after a REX prefix nullifies its effect. */

rex_prefix = 0;
}

done_prefixes:

/* REX prefix. */
if ((mode == X86EMUL_MODE_PROT64) && ((c->b & 0xf0) == 0x40)) {
rex_prefix = c->b;
if (c->b & 8)
if (rex_prefix) {
if (rex_prefix & 8)
c->op_bytes = 8; /* REX.W */
c->modrm_reg = (c->b & 4) << 1; /* REX.R */
index_reg = (c->b & 2) << 2; /* REX.X */
c->modrm_rm = base_reg = (c->b & 1) << 3; /* REG.B */
c->b = insn_fetch(u8, 1, c->eip);
c->modrm_reg = (rex_prefix & 4) << 1; /* REX.R */
index_reg = (rex_prefix & 2) << 2; /* REX.X */
c->modrm_rm = base_reg = (rex_prefix & 1) << 3; /* REG.B */
}

/* Opcode byte(s). */
Expand Down

0 comments on commit 4ec94cc

Please sign in to comment.