Skip to content

Commit

Permalink
KVM: x86 emulator: simplify sib decoding
Browse files Browse the repository at this point in the history
Instead of using sparse switches, use simpler if/else sequences.

Signed-off-by: Avi Kivity <avi@qumranet.com>
  • Loading branch information
Avi Kivity committed Jul 20, 2008
1 parent 8684c0a commit dc71d0f
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions arch/x86/kvm/x86_emulate.c
Original file line number Diff line number Diff line change
Expand Up @@ -748,24 +748,12 @@ static int decode_modrm(struct x86_emulate_ctxt *ctxt,
base_reg |= sib & 7;
scale = sib >> 6;

switch (base_reg) {
case 5:
case 13:
if (c->modrm_mod != 0)
c->modrm_ea += c->regs[base_reg];
else
c->modrm_ea +=
insn_fetch(s32, 4, c->eip);
break;
default:
if ((base_reg & 7) == 5 && c->modrm_mod == 0)
c->modrm_ea += insn_fetch(s32, 4, c->eip);
else
c->modrm_ea += c->regs[base_reg];
}
switch (index_reg) {
case 4:
break;
default:
if (index_reg != 4)
c->modrm_ea += c->regs[index_reg] << scale;
}
break;
case 5:
case 13:
Expand Down

0 comments on commit dc71d0f

Please sign in to comment.