aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/x86_emulate.c
diff options
context:
space:
mode:
authorAvi Kivity <avi@qumranet.com>2008-06-16 00:23:17 -0400
committerAvi Kivity <avi@qumranet.com>2008-07-20 05:42:33 -0400
commitdc71d0f1620790ec8e54101ca37e7b31e31208a8 (patch)
tree75016ef3339ea6e82e2aaaee99d17e1ffeb64696 /arch/x86/kvm/x86_emulate.c
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/kvm/x86_emulate.c')
-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,
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: