Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit faa5a3ae authored by Avi Kivity's avatar Avi Kivity
Browse files

KVM: x86 emulator: Extract 'pop' sequence into a function



Switch 'pop r/m' instruction to use the new function.

Signed-off-by: default avatarAvi Kivity <avi@redhat.com>
parent b8209182
Loading
Loading
Loading
Loading
+17 −4
Original line number Diff line number Diff line
@@ -1057,7 +1057,7 @@ 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,
static int emulate_pop(struct x86_emulate_ctxt *ctxt,
		       struct x86_emulate_ops *ops)
{
	struct decode_cache *c = &ctxt->decode;
@@ -1065,12 +1065,25 @@ static inline int emulate_grp1a(struct x86_emulate_ctxt *ctxt,

	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;
}