aboutsummaryrefslogtreecommitdiff
path: root/arch/x86
diff options
context:
space:
mode:
authorAvi Kivity <avi@qumranet.com>2008-06-15 21:23:17 -0700
committerAvi Kivity <avi@qumranet.com>2008-07-20 12:42:33 +0300
commitdc71d0f1620790ec8e54101ca37e7b31e31208a8 (patch)
tree75016ef3339ea6e82e2aaaee99d17e1ffeb64696 /arch/x86
parent8684c0af0b2bab770c257e2a04e1546eed35fa56 (diff)
KVM: x86 emulator: simplify sib decoding
Instead of using sparse switches, use simpler if/else sequences. Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/kvm/x86_emulate.c20
1 files changed, 4 insertions, 16 deletions
diff --git a/arch/x86/kvm/x86_emulate.c b/arch/x86/kvm/x86_emulate.c
index 3721cfddc97..ca7ab2469a4 100644
--- a/arch/x86/kvm/x86_emulate.c
+++ b/arch/x86/kvm/x86_emulate.c
@@ -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: