diff options
author | Avi Kivity <avi@qumranet.com> | 2008-06-16 00:23:17 -0400 |
---|---|---|
committer | Avi Kivity <avi@qumranet.com> | 2008-07-20 05:42:33 -0400 |
commit | dc71d0f1620790ec8e54101ca37e7b31e31208a8 (patch) | |
tree | 75016ef3339ea6e82e2aaaee99d17e1ffeb64696 /arch/x86/kvm/x86_emulate.c | |
parent | 8684c0af0b2bab770c257e2a04e1546eed35fa56 (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/kvm/x86_emulate.c')
-rw-r--r-- | arch/x86/kvm/x86_emulate.c | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/arch/x86/kvm/x86_emulate.c b/arch/x86/kvm/x86_emulate.c index 3721cfddc973..ca7ab2469a4a 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, | |||
748 | base_reg |= sib & 7; | 748 | base_reg |= sib & 7; |
749 | scale = sib >> 6; | 749 | scale = sib >> 6; |
750 | 750 | ||
751 | switch (base_reg) { | 751 | if ((base_reg & 7) == 5 && c->modrm_mod == 0) |
752 | case 5: | 752 | c->modrm_ea += insn_fetch(s32, 4, c->eip); |
753 | case 13: | 753 | else |
754 | if (c->modrm_mod != 0) | ||
755 | c->modrm_ea += c->regs[base_reg]; | ||
756 | else | ||
757 | c->modrm_ea += | ||
758 | insn_fetch(s32, 4, c->eip); | ||
759 | break; | ||
760 | default: | ||
761 | c->modrm_ea += c->regs[base_reg]; | 754 | c->modrm_ea += c->regs[base_reg]; |
762 | } | 755 | if (index_reg != 4) |
763 | switch (index_reg) { | ||
764 | case 4: | ||
765 | break; | ||
766 | default: | ||
767 | c->modrm_ea += c->regs[index_reg] << scale; | 756 | c->modrm_ea += c->regs[index_reg] << scale; |
768 | } | ||
769 | break; | 757 | break; |
770 | case 5: | 758 | case 5: |
771 | case 13: | 759 | case 13: |