KVM: x86 emulator: split push logic from push opcode emulation
This allows us to reuse the code without populating ctxt->src and overriding ctxt->op_bytes. Signed-off-by: Avi Kivity <avi@redhat.com>
This commit is contained in:
parent
361cad2b50
commit
51ddff50cb
|
@ -1505,17 +1505,22 @@ static int writeback(struct x86_emulate_ctxt *ctxt)
|
||||||
return X86EMUL_CONTINUE;
|
return X86EMUL_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int em_push(struct x86_emulate_ctxt *ctxt)
|
static int push(struct x86_emulate_ctxt *ctxt, void *data, int bytes)
|
||||||
{
|
{
|
||||||
struct segmented_address addr;
|
struct segmented_address addr;
|
||||||
|
|
||||||
register_address_increment(ctxt, &ctxt->regs[VCPU_REGS_RSP], -ctxt->op_bytes);
|
register_address_increment(ctxt, &ctxt->regs[VCPU_REGS_RSP], -bytes);
|
||||||
addr.ea = register_address(ctxt, ctxt->regs[VCPU_REGS_RSP]);
|
addr.ea = register_address(ctxt, ctxt->regs[VCPU_REGS_RSP]);
|
||||||
addr.seg = VCPU_SREG_SS;
|
addr.seg = VCPU_SREG_SS;
|
||||||
|
|
||||||
|
return segmented_write(ctxt, addr, data, bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int em_push(struct x86_emulate_ctxt *ctxt)
|
||||||
|
{
|
||||||
/* Disable writeback. */
|
/* Disable writeback. */
|
||||||
ctxt->dst.type = OP_NONE;
|
ctxt->dst.type = OP_NONE;
|
||||||
return segmented_write(ctxt, addr, &ctxt->src.val, ctxt->op_bytes);
|
return push(ctxt, &ctxt->src.val, ctxt->op_bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int emulate_pop(struct x86_emulate_ctxt *ctxt,
|
static int emulate_pop(struct x86_emulate_ctxt *ctxt,
|
||||||
|
|
Loading…
Reference in New Issue