aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/kvm/kvm_main.c44
-rw-r--r--include/linux/kvm.h5
2 files changed, 24 insertions, 25 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
diff --git a/include/linux/kvm.h b/include/linux/kvm.h
index 07bf353eeb6f..738c2f50c774 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -11,7 +11,7 @@
11#include <asm/types.h> 11#include <asm/types.h>
12#include <linux/ioctl.h> 12#include <linux/ioctl.h>
13 13
14#define KVM_API_VERSION 10 14#define KVM_API_VERSION 11
15 15
16/* 16/*
17 * Architectural interrupt line count, and the size of the bitmap needed 17 * Architectural interrupt line count, and the size of the bitmap needed
@@ -58,9 +58,8 @@ enum kvm_exit_reason {
58/* for KVM_RUN, returned by mmap(vcpu_fd, offset=0) */ 58/* for KVM_RUN, returned by mmap(vcpu_fd, offset=0) */
59struct kvm_run { 59struct kvm_run {
60 /* in */ 60 /* in */
61 __u32 io_completed; /* mmio/pio request completed */
62 __u8 request_interrupt_window; 61 __u8 request_interrupt_window;
63 __u8 padding1[3]; 62 __u8 padding1[7];
64 63
65 /* out */ 64 /* out */
66 __u32 exit_reason; 65 __u32 exit_reason;