diff options
author | Avi Kivity <avi@redhat.com> | 2012-06-12 13:19:40 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2012-07-09 07:19:03 -0400 |
commit | 51ddff50cbd77568fe40e17a966b3a2ef1231b36 (patch) | |
tree | a1a0e2ef3bbeadcf84efc090e3f9953904bd91c0 /arch/x86/kvm/emulate.c | |
parent | 361cad2b50a2c92b91b6f568db860fabad3bf149 (diff) |
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>
Diffstat (limited to 'arch/x86/kvm/emulate.c')
-rw-r--r-- | arch/x86/kvm/emulate.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 30f4912c6a67..acc647d63701 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c | |||
@@ -1505,17 +1505,22 @@ static int writeback(struct x86_emulate_ctxt *ctxt) | |||
1505 | return X86EMUL_CONTINUE; | 1505 | return X86EMUL_CONTINUE; |
1506 | } | 1506 | } |
1507 | 1507 | ||
1508 | static int em_push(struct x86_emulate_ctxt *ctxt) | 1508 | static int push(struct x86_emulate_ctxt *ctxt, void *data, int bytes) |
1509 | { | 1509 | { |
1510 | struct segmented_address addr; | 1510 | struct segmented_address addr; |
1511 | 1511 | ||
1512 | register_address_increment(ctxt, &ctxt->regs[VCPU_REGS_RSP], -ctxt->op_bytes); | 1512 | register_address_increment(ctxt, &ctxt->regs[VCPU_REGS_RSP], -bytes); |
1513 | addr.ea = register_address(ctxt, ctxt->regs[VCPU_REGS_RSP]); | 1513 | addr.ea = register_address(ctxt, ctxt->regs[VCPU_REGS_RSP]); |
1514 | addr.seg = VCPU_SREG_SS; | 1514 | addr.seg = VCPU_SREG_SS; |
1515 | 1515 | ||
1516 | return segmented_write(ctxt, addr, data, bytes); | ||
1517 | } | ||
1518 | |||
1519 | static int em_push(struct x86_emulate_ctxt *ctxt) | ||
1520 | { | ||
1516 | /* Disable writeback. */ | 1521 | /* Disable writeback. */ |
1517 | ctxt->dst.type = OP_NONE; | 1522 | ctxt->dst.type = OP_NONE; |
1518 | return segmented_write(ctxt, addr, &ctxt->src.val, ctxt->op_bytes); | 1523 | return push(ctxt, &ctxt->src.val, ctxt->op_bytes); |
1519 | } | 1524 | } |
1520 | 1525 | ||
1521 | static int emulate_pop(struct x86_emulate_ctxt *ctxt, | 1526 | static int emulate_pop(struct x86_emulate_ctxt *ctxt, |