提交 350f69dc 编写于 作者: A Avi Kivity

KVM: x86 emulator: Make emulate_pop() a little more generic

Allow emulate_pop() to read into arbitrary memory rather than just the
source operand.  Needed for complicated instructions like far returns.
Signed-off-by: NAvi Kivity <avi@redhat.com>
上级 10f32d84
...@@ -1136,18 +1136,19 @@ static inline void emulate_push(struct x86_emulate_ctxt *ctxt) ...@@ -1136,18 +1136,19 @@ static inline void emulate_push(struct x86_emulate_ctxt *ctxt)
} }
static int emulate_pop(struct x86_emulate_ctxt *ctxt, static int emulate_pop(struct x86_emulate_ctxt *ctxt,
struct x86_emulate_ops *ops) struct x86_emulate_ops *ops,
void *dest, int len)
{ {
struct decode_cache *c = &ctxt->decode; struct decode_cache *c = &ctxt->decode;
int rc; int rc;
rc = ops->read_emulated(register_address(c, ss_base(ctxt), rc = ops->read_emulated(register_address(c, ss_base(ctxt),
c->regs[VCPU_REGS_RSP]), c->regs[VCPU_REGS_RSP]),
&c->src.val, c->src.bytes, ctxt->vcpu); dest, len, ctxt->vcpu);
if (rc != 0) if (rc != 0)
return rc; return rc;
register_address_increment(c, &c->regs[VCPU_REGS_RSP], c->src.bytes); register_address_increment(c, &c->regs[VCPU_REGS_RSP], len);
return rc; return rc;
} }
...@@ -1157,11 +1158,9 @@ static inline int emulate_grp1a(struct x86_emulate_ctxt *ctxt, ...@@ -1157,11 +1158,9 @@ static inline int emulate_grp1a(struct x86_emulate_ctxt *ctxt,
struct decode_cache *c = &ctxt->decode; struct decode_cache *c = &ctxt->decode;
int rc; int rc;
c->src.bytes = c->dst.bytes; rc = emulate_pop(ctxt, ops, &c->dst.val, c->dst.bytes);
rc = emulate_pop(ctxt, ops);
if (rc != 0) if (rc != 0)
return rc; return rc;
c->dst.val = c->src.val;
return 0; return 0;
} }
...@@ -1467,11 +1466,9 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops) ...@@ -1467,11 +1466,9 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
break; break;
case 0x58 ... 0x5f: /* pop reg */ case 0x58 ... 0x5f: /* pop reg */
pop_instruction: pop_instruction:
c->src.bytes = c->op_bytes; rc = emulate_pop(ctxt, ops, &c->dst.val, c->op_bytes);
rc = emulate_pop(ctxt, ops);
if (rc != 0) if (rc != 0)
goto done; goto done;
c->dst.val = c->src.val;
break; break;
case 0x63: /* movsxd */ case 0x63: /* movsxd */
if (ctxt->mode != X86EMUL_MODE_PROT64) if (ctxt->mode != X86EMUL_MODE_PROT64)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册