aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/emulate.c
diff options
context:
space:
mode:
authorBandan Das <bsd@redhat.com>2014-04-16 12:46:11 -0400
committerPaolo Bonzini <pbonzini@redhat.com>2014-07-11 03:14:00 -0400
commit02357bdc8c30a60cd33dd438f851c1306c34f435 (patch)
treed74663db7274e8e387554d0373d0c844b96ddba2 /arch/x86/kvm/emulate.c
parent685bbf4ac406364a84a1d4237b4970dc570fd4cb (diff)
KVM: emulate: cleanup decode_modrm
Remove the if conditional - that will help us avoid an "else initialize to 0" Also, rearrange operators for slightly better code. Signed-off-by: Bandan Das <bsd@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/x86/kvm/emulate.c')
-rw-r--r--arch/x86/kvm/emulate.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 000fc7398832..94f5f8b94ce9 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -1066,19 +1066,17 @@ static int decode_modrm(struct x86_emulate_ctxt *ctxt,
1066 struct operand *op) 1066 struct operand *op)
1067{ 1067{
1068 u8 sib; 1068 u8 sib;
1069 int index_reg = 0, base_reg = 0, scale; 1069 int index_reg, base_reg, scale;
1070 int rc = X86EMUL_CONTINUE; 1070 int rc = X86EMUL_CONTINUE;
1071 ulong modrm_ea = 0; 1071 ulong modrm_ea = 0;
1072 1072
1073 if (ctxt->rex_prefix) { 1073 ctxt->modrm_reg = ((ctxt->rex_prefix << 1) & 8); /* REX.R */
1074 ctxt->modrm_reg = (ctxt->rex_prefix & 4) << 1; /* REX.R */ 1074 index_reg = (ctxt->rex_prefix << 2) & 8; /* REX.X */
1075 index_reg = (ctxt->rex_prefix & 2) << 2; /* REX.X */ 1075 base_reg = (ctxt->rex_prefix << 3) & 8; /* REX.B */
1076 ctxt->modrm_rm = base_reg = (ctxt->rex_prefix & 1) << 3; /* REG.B */
1077 }
1078 1076
1079 ctxt->modrm_mod |= (ctxt->modrm & 0xc0) >> 6; 1077 ctxt->modrm_mod = (ctxt->modrm & 0xc0) >> 6;
1080 ctxt->modrm_reg |= (ctxt->modrm & 0x38) >> 3; 1078 ctxt->modrm_reg |= (ctxt->modrm & 0x38) >> 3;
1081 ctxt->modrm_rm |= (ctxt->modrm & 0x07); 1079 ctxt->modrm_rm = base_reg | (ctxt->modrm & 0x07);
1082 ctxt->modrm_seg = VCPU_SREG_DS; 1080 ctxt->modrm_seg = VCPU_SREG_DS;
1083 1081
1084 if (ctxt->modrm_mod == 3 || (ctxt->d & NoMod)) { 1082 if (ctxt->modrm_mod == 3 || (ctxt->d & NoMod)) {