aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/kvm/kvm_main.c
diff options
context:
space:
mode:
authorAvi Kivity <avi@qumranet.com>2007-04-29 08:02:17 -0400
committerAvi Kivity <avi@qumranet.com>2007-05-03 03:52:32 -0400
commit02c83209726270ddf9597deabc45e08f6fc3942c (patch)
tree570c2d96c1daba96ae2891e63b1e55b3959e9aba /drivers/kvm/kvm_main.c
parente7df56e4a00358b6975fae3b70dc9df1282d427a (diff)
KVM: Don't require explicit indication of completion of mmio or pio
It is illegal not to return from a pio or mmio request without completing it, as mmio or pio is an atomic operation. Therefore, we can simplify the userspace interface by avoiding the completion indication. Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers/kvm/kvm_main.c')
-rw-r--r--drivers/kvm/kvm_main.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index f267dbb52845..c8b8cfa332bb 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -1237,8 +1237,10 @@ int emulate_instruction(struct kvm_vcpu *vcpu,
1237 kvm_arch_ops->decache_regs(vcpu); 1237 kvm_arch_ops->decache_regs(vcpu);
1238 kvm_arch_ops->set_rflags(vcpu, emulate_ctxt.eflags); 1238 kvm_arch_ops->set_rflags(vcpu, emulate_ctxt.eflags);
1239 1239
1240 if (vcpu->mmio_is_write) 1240 if (vcpu->mmio_is_write) {
1241 vcpu->mmio_needed = 0;
1241 return EMULATE_DO_MMIO; 1242 return EMULATE_DO_MMIO;
1243 }
1242 1244
1243 return EMULATE_DONE; 1245 return EMULATE_DONE;
1244} 1246}
@@ -1692,8 +1694,6 @@ static int complete_pio(struct kvm_vcpu *vcpu)
1692 vcpu->regs[VCPU_REGS_RSI] += delta; 1694 vcpu->regs[VCPU_REGS_RSI] += delta;
1693 } 1695 }
1694 1696
1695 vcpu->run->io_completed = 0;
1696
1697 kvm_arch_ops->decache_regs(vcpu); 1697 kvm_arch_ops->decache_regs(vcpu);
1698 1698
1699 io->count -= io->cur_count; 1699 io->count -= io->cur_count;
@@ -1800,25 +1800,25 @@ static int kvm_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
1800 /* re-sync apic's tpr */ 1800 /* re-sync apic's tpr */
1801 vcpu->cr8 = kvm_run->cr8; 1801 vcpu->cr8 = kvm_run->cr8;
1802 1802
1803 if (kvm_run->io_completed) { 1803 if (vcpu->pio.cur_count) {
1804 if (vcpu->pio.cur_count) { 1804 r = complete_pio(vcpu);
1805 r = complete_pio(vcpu); 1805 if (r)
1806 if (r) 1806 goto out;
1807 goto out; 1807 }
1808 } else if (!vcpu->mmio_is_write) { 1808
1809 memcpy(vcpu->mmio_data, kvm_run->mmio.data, 8); 1809 if (vcpu->mmio_needed) {
1810 vcpu->mmio_read_completed = 1; 1810 memcpy(vcpu->mmio_data, kvm_run->mmio.data, 8);
1811 vcpu->mmio_needed = 0; 1811 vcpu->mmio_read_completed = 1;
1812 r = emulate_instruction(vcpu, kvm_run, 1812 vcpu->mmio_needed = 0;
1813 vcpu->mmio_fault_cr2, 0); 1813 r = emulate_instruction(vcpu, kvm_run,
1814 if (r == EMULATE_DO_MMIO) { 1814 vcpu->mmio_fault_cr2, 0);
1815 /* 1815 if (r == EMULATE_DO_MMIO) {
1816 * Read-modify-write. Back to userspace. 1816 /*
1817 */ 1817 * Read-modify-write. Back to userspace.
1818 kvm_run->exit_reason = KVM_EXIT_MMIO; 1818 */
1819 r = 0; 1819 kvm_run->exit_reason = KVM_EXIT_MMIO;
1820 goto out; 1820 r = 0;
1821 } 1821 goto out;
1822 } 1822 }
1823 } 1823 }
1824 1824