diff options
author | Gleb Natapov <gleb@redhat.com> | 2010-04-28 12:15:39 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2010-08-01 03:35:35 -0400 |
commit | 95c5588652f7742a21c33d9dcce0e043e057d04f (patch) | |
tree | 6f948ccbb9e8996d2af5890ecee32b31db72877c /arch | |
parent | 3457e4192e367fd4e0da5e9f46f9df85fa99cd11 (diff) |
KVM: x86 emulator: advance RIP outside x86 emulator code
Return new RIP as part of instruction emulation result instead of
updating KVM's RIP from x86 emulator code.
Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/kvm/emulate.c | 7 | ||||
-rw-r--r-- | arch/x86/kvm/x86.c | 2 |
2 files changed, 6 insertions, 3 deletions
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index d7a18a0f80a2..437f31bcffea 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c | |||
@@ -2496,8 +2496,9 @@ int emulator_task_switch(struct x86_emulate_ctxt *ctxt, | |||
2496 | 2496 | ||
2497 | if (rc == X86EMUL_CONTINUE) { | 2497 | if (rc == X86EMUL_CONTINUE) { |
2498 | memcpy(ctxt->vcpu->arch.regs, c->regs, sizeof c->regs); | 2498 | memcpy(ctxt->vcpu->arch.regs, c->regs, sizeof c->regs); |
2499 | kvm_rip_write(ctxt->vcpu, c->eip); | ||
2500 | rc = writeback(ctxt, ops); | 2499 | rc = writeback(ctxt, ops); |
2500 | if (rc == X86EMUL_CONTINUE) | ||
2501 | ctxt->eip = c->eip; | ||
2501 | } | 2502 | } |
2502 | 2503 | ||
2503 | return (rc == X86EMUL_UNHANDLEABLE) ? -1 : 0; | 2504 | return (rc == X86EMUL_UNHANDLEABLE) ? -1 : 0; |
@@ -2554,7 +2555,7 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops) | |||
2554 | if (address_mask(c, c->regs[VCPU_REGS_RCX]) == 0) { | 2555 | if (address_mask(c, c->regs[VCPU_REGS_RCX]) == 0) { |
2555 | string_done: | 2556 | string_done: |
2556 | ctxt->restart = false; | 2557 | ctxt->restart = false; |
2557 | kvm_rip_write(ctxt->vcpu, c->eip); | 2558 | ctxt->eip = c->eip; |
2558 | goto done; | 2559 | goto done; |
2559 | } | 2560 | } |
2560 | /* The second termination condition only applies for REPE | 2561 | /* The second termination condition only applies for REPE |
@@ -3032,7 +3033,7 @@ writeback: | |||
3032 | ctxt->decode.mem_read.end = 0; | 3033 | ctxt->decode.mem_read.end = 0; |
3033 | /* Commit shadow register state. */ | 3034 | /* Commit shadow register state. */ |
3034 | memcpy(ctxt->vcpu->arch.regs, c->regs, sizeof c->regs); | 3035 | memcpy(ctxt->vcpu->arch.regs, c->regs, sizeof c->regs); |
3035 | kvm_rip_write(ctxt->vcpu, c->eip); | 3036 | ctxt->eip = c->eip; |
3036 | ops->set_rflags(ctxt->vcpu, ctxt->eflags); | 3037 | ops->set_rflags(ctxt->vcpu, ctxt->eflags); |
3037 | 3038 | ||
3038 | done: | 3039 | done: |
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 9e5a833f3392..8f45cc712dda 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -3941,6 +3941,7 @@ restart: | |||
3941 | 3941 | ||
3942 | shadow_mask = vcpu->arch.emulate_ctxt.interruptibility; | 3942 | shadow_mask = vcpu->arch.emulate_ctxt.interruptibility; |
3943 | kvm_x86_ops->set_interrupt_shadow(vcpu, shadow_mask); | 3943 | kvm_x86_ops->set_interrupt_shadow(vcpu, shadow_mask); |
3944 | kvm_rip_write(vcpu, vcpu->arch.emulate_ctxt.eip); | ||
3944 | 3945 | ||
3945 | if (vcpu->arch.pio.count) { | 3946 | if (vcpu->arch.pio.count) { |
3946 | if (!vcpu->arch.pio.in) | 3947 | if (!vcpu->arch.pio.in) |
@@ -4945,6 +4946,7 @@ int kvm_task_switch(struct kvm_vcpu *vcpu, u16 tss_selector, int reason, | |||
4945 | if (ret) | 4946 | if (ret) |
4946 | return EMULATE_FAIL; | 4947 | return EMULATE_FAIL; |
4947 | 4948 | ||
4949 | kvm_rip_write(vcpu, vcpu->arch.emulate_ctxt.eip); | ||
4948 | kvm_x86_ops->set_rflags(vcpu, vcpu->arch.emulate_ctxt.eflags); | 4950 | kvm_x86_ops->set_rflags(vcpu, vcpu->arch.emulate_ctxt.eflags); |
4949 | return EMULATE_DONE; | 4951 | return EMULATE_DONE; |
4950 | } | 4952 | } |