Skip to content

Commit

Permalink
KVM: x86 emulator: Extract 'pop' sequence into a function
Browse files Browse the repository at this point in the history
Switch 'pop r/m' instruction to use the new function.

Signed-off-by: Avi Kivity <[email protected]>
  • Loading branch information
avikivity committed Dec 31, 2008
1 parent b820918 commit faa5a3a
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions arch/x86/kvm/x86_emulate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1057,20 +1057,33 @@ static inline void emulate_push(struct x86_emulate_ctxt *ctxt)
c->regs[VCPU_REGS_RSP]);
}

static inline int emulate_grp1a(struct x86_emulate_ctxt *ctxt,
struct x86_emulate_ops *ops)
static int emulate_pop(struct x86_emulate_ctxt *ctxt,
struct x86_emulate_ops *ops)
{
struct decode_cache *c = &ctxt->decode;
int rc;

rc = ops->read_std(register_address(c, ss_base(ctxt),
c->regs[VCPU_REGS_RSP]),
&c->dst.val, c->dst.bytes, ctxt->vcpu);
&c->src.val, c->src.bytes, ctxt->vcpu);
if (rc != 0)
return rc;

register_address_increment(c, &c->regs[VCPU_REGS_RSP], c->dst.bytes);
register_address_increment(c, &c->regs[VCPU_REGS_RSP], c->src.bytes);
return rc;
}

static inline int emulate_grp1a(struct x86_emulate_ctxt *ctxt,
struct x86_emulate_ops *ops)
{
struct decode_cache *c = &ctxt->decode;
int rc;

c->src.bytes = c->dst.bytes;
rc = emulate_pop(ctxt, ops);
if (rc != 0)
return rc;
c->dst.val = c->src.val;
return 0;
}

Expand Down

0 comments on commit faa5a3a

Please sign in to comment.