diff options
author | Gleb Natapov <gleb@redhat.com> | 2010-03-18 09:20:28 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2010-05-17 05:16:32 -0400 |
commit | 92bf9748b5bc381070f6adf0b56efd3428e4a97b (patch) | |
tree | b6bbd96be7bcf7e9b95be78412a2562bf78144b1 | |
parent | 7b262e90fc20a49fddf3dad94c8cead1f0439751 (diff) |
KVM: small kvm_arch_vcpu_ioctl_run() cleanup.
Unify all conditions that get us back into emulator after returning from
userspace.
Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
-rw-r--r-- | arch/x86/kvm/x86.c | 32 |
1 files changed, 6 insertions, 26 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index c88cb8145283..cc540f27053f 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -4542,33 +4542,13 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) | |||
4542 | if (!irqchip_in_kernel(vcpu->kvm)) | 4542 | if (!irqchip_in_kernel(vcpu->kvm)) |
4543 | kvm_set_cr8(vcpu, kvm_run->cr8); | 4543 | kvm_set_cr8(vcpu, kvm_run->cr8); |
4544 | 4544 | ||
4545 | if (vcpu->arch.pio.count) { | 4545 | if (vcpu->arch.pio.count || vcpu->mmio_needed || |
4546 | vcpu->srcu_idx = srcu_read_lock(&vcpu->kvm->srcu); | 4546 | vcpu->arch.emulate_ctxt.restart) { |
4547 | r = emulate_instruction(vcpu, 0, 0, EMULTYPE_NO_DECODE); | 4547 | if (vcpu->mmio_needed) { |
4548 | srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx); | 4548 | memcpy(vcpu->mmio_data, kvm_run->mmio.data, 8); |
4549 | if (r == EMULATE_DO_MMIO) { | 4549 | vcpu->mmio_read_completed = 1; |
4550 | r = 0; | 4550 | vcpu->mmio_needed = 0; |
4551 | goto out; | ||
4552 | } | ||
4553 | } | ||
4554 | if (vcpu->mmio_needed) { | ||
4555 | memcpy(vcpu->mmio_data, kvm_run->mmio.data, 8); | ||
4556 | vcpu->mmio_read_completed = 1; | ||
4557 | vcpu->mmio_needed = 0; | ||
4558 | |||
4559 | vcpu->srcu_idx = srcu_read_lock(&vcpu->kvm->srcu); | ||
4560 | r = emulate_instruction(vcpu, vcpu->arch.mmio_fault_cr2, 0, | ||
4561 | EMULTYPE_NO_DECODE); | ||
4562 | srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx); | ||
4563 | if (r == EMULATE_DO_MMIO) { | ||
4564 | /* | ||
4565 | * Read-modify-write. Back to userspace. | ||
4566 | */ | ||
4567 | r = 0; | ||
4568 | goto out; | ||
4569 | } | 4551 | } |
4570 | } | ||
4571 | if (vcpu->arch.emulate_ctxt.restart) { | ||
4572 | vcpu->srcu_idx = srcu_read_lock(&vcpu->kvm->srcu); | 4552 | vcpu->srcu_idx = srcu_read_lock(&vcpu->kvm->srcu); |
4573 | r = emulate_instruction(vcpu, 0, 0, EMULTYPE_NO_DECODE); | 4553 | r = emulate_instruction(vcpu, 0, 0, EMULTYPE_NO_DECODE); |
4574 | srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx); | 4554 | srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx); |