aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorAvi Kivity <avi@redhat.com>2010-01-19 07:20:10 -0500
committerAvi Kivity <avi@redhat.com>2011-05-11 07:56:58 -0400
commit5287f194bf0d7062d6d99b725366202556f03e28 (patch)
tree8c4c60bfe927cd17ba5ab88a9a3ae0fbeda4bde6 /arch
parent70252a1053636c35776d6bc843dd3b260d9d6de1 (diff)
KVM: Split mmio completion into a function
Make room for sse mmio completions. Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/kvm/x86.c39
1 files changed, 25 insertions, 14 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 3b234c18b635..bb6b9d3f5e93 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -5441,6 +5441,27 @@ static int __vcpu_run(struct kvm_vcpu *vcpu)
5441 return r; 5441 return r;
5442} 5442}
5443 5443
5444static int complete_mmio(struct kvm_vcpu *vcpu)
5445{
5446 struct kvm_run *run = vcpu->run;
5447 int r;
5448
5449 if (!(vcpu->arch.pio.count || vcpu->mmio_needed))
5450 return 1;
5451
5452 if (vcpu->mmio_needed) {
5453 memcpy(vcpu->mmio_data, run->mmio.data, 8);
5454 vcpu->mmio_read_completed = 1;
5455 vcpu->mmio_needed = 0;
5456 }
5457 vcpu->srcu_idx = srcu_read_lock(&vcpu->kvm->srcu);
5458 r = emulate_instruction(vcpu, EMULTYPE_NO_DECODE);
5459 srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx);
5460 if (r != EMULATE_DONE)
5461 return 0;
5462 return 1;
5463}
5464
5444int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) 5465int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
5445{ 5466{
5446 int r; 5467 int r;
@@ -5467,20 +5488,10 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
5467 } 5488 }
5468 } 5489 }
5469 5490
5470 if (vcpu->arch.pio.count || vcpu->mmio_needed) { 5491 r = complete_mmio(vcpu);
5471 if (vcpu->mmio_needed) { 5492 if (r <= 0)
5472 memcpy(vcpu->mmio_data, kvm_run->mmio.data, 8); 5493 goto out;
5473 vcpu->mmio_read_completed = 1; 5494
5474 vcpu->mmio_needed = 0;
5475 }
5476 vcpu->srcu_idx = srcu_read_lock(&vcpu->kvm->srcu);
5477 r = emulate_instruction(vcpu, EMULTYPE_NO_DECODE);
5478 srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx);
5479 if (r != EMULATE_DONE) {
5480 r = 0;
5481 goto out;
5482 }
5483 }
5484 if (kvm_run->exit_reason == KVM_EXIT_HYPERCALL) 5495 if (kvm_run->exit_reason == KVM_EXIT_HYPERCALL)
5485 kvm_register_write(vcpu, VCPU_REGS_RAX, 5496 kvm_register_write(vcpu, VCPU_REGS_RAX,
5486 kvm_run->hypercall.ret); 5497 kvm_run->hypercall.ret);