aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/emulate.c
diff options
context:
space:
mode:
authorBandan Das <bsd@redhat.com>2014-04-16 12:46:14 -0400
committerPaolo Bonzini <pbonzini@redhat.com>2014-07-11 03:14:01 -0400
commit41061cdb98a0bec464278b4db8e894a3121671f5 (patch)
treeda1cd3e8f52f23fe8dd614b38474065f5b9f3ca1 /arch/x86/kvm/emulate.c
parent573e80fe04db1aa44e8303037f65716ba5c3a343 (diff)
KVM: emulate: do not initialize memopp
rip_relative is only set if decode_modrm runs, and if you have ModRM you will also have a memopp. We can then access memopp unconditionally. Note that rip_relative cannot be hoisted up to decode_modrm, or you break "mov $0, xyz(%rip)". Also, move typecast on "out of range value" of mem.ea to decode_modrm. Together, all these optimizations save about 50 cycles on each emulated instructions (4-6%). Signed-off-by: Bandan Das <bsd@redhat.com> [Fix immediate operands with rip-relative addressing. - Paolo] Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/x86/kvm/emulate.c')
-rw-r--r--arch/x86/kvm/emulate.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 08badf638fb0..390400a54a9c 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -1177,6 +1177,9 @@ static int decode_modrm(struct x86_emulate_ctxt *ctxt,
1177 } 1177 }
1178 } 1178 }
1179 op->addr.mem.ea = modrm_ea; 1179 op->addr.mem.ea = modrm_ea;
1180 if (ctxt->ad_bytes != 8)
1181 ctxt->memop.addr.mem.ea = (u32)ctxt->memop.addr.mem.ea;
1182
1180done: 1183done:
1181 return rc; 1184 return rc;
1182} 1185}
@@ -4425,9 +4428,6 @@ done_prefixes:
4425 4428
4426 ctxt->memop.addr.mem.seg = ctxt->seg_override; 4429 ctxt->memop.addr.mem.seg = ctxt->seg_override;
4427 4430
4428 if (ctxt->memop.type == OP_MEM && ctxt->ad_bytes != 8)
4429 ctxt->memop.addr.mem.ea = (u32)ctxt->memop.addr.mem.ea;
4430
4431 /* 4431 /*
4432 * Decode and fetch the source operand: register, memory 4432 * Decode and fetch the source operand: register, memory
4433 * or immediate. 4433 * or immediate.
@@ -4448,7 +4448,7 @@ done_prefixes:
4448 rc = decode_operand(ctxt, &ctxt->dst, (ctxt->d >> DstShift) & OpMask); 4448 rc = decode_operand(ctxt, &ctxt->dst, (ctxt->d >> DstShift) & OpMask);
4449 4449
4450done: 4450done:
4451 if (ctxt->memopp && ctxt->memopp->type == OP_MEM && ctxt->rip_relative) 4451 if (ctxt->rip_relative)
4452 ctxt->memopp->addr.mem.ea += ctxt->_eip; 4452 ctxt->memopp->addr.mem.ea += ctxt->_eip;
4453 4453
4454 return (rc != X86EMUL_CONTINUE) ? EMULATION_FAILED : EMULATION_OK; 4454 return (rc != X86EMUL_CONTINUE) ? EMULATION_FAILED : EMULATION_OK;