mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-21 14:11:20 +00:00
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>
This commit is contained in:
parent
e7df56e4a0
commit
02c8320972
2 changed files with 24 additions and 25 deletions
|
@ -1237,8 +1237,10 @@ int emulate_instruction(struct kvm_vcpu *vcpu,
|
||||||
kvm_arch_ops->decache_regs(vcpu);
|
kvm_arch_ops->decache_regs(vcpu);
|
||||||
kvm_arch_ops->set_rflags(vcpu, emulate_ctxt.eflags);
|
kvm_arch_ops->set_rflags(vcpu, emulate_ctxt.eflags);
|
||||||
|
|
||||||
if (vcpu->mmio_is_write)
|
if (vcpu->mmio_is_write) {
|
||||||
|
vcpu->mmio_needed = 0;
|
||||||
return EMULATE_DO_MMIO;
|
return EMULATE_DO_MMIO;
|
||||||
|
}
|
||||||
|
|
||||||
return EMULATE_DONE;
|
return EMULATE_DONE;
|
||||||
}
|
}
|
||||||
|
@ -1692,8 +1694,6 @@ static int complete_pio(struct kvm_vcpu *vcpu)
|
||||||
vcpu->regs[VCPU_REGS_RSI] += delta;
|
vcpu->regs[VCPU_REGS_RSI] += delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
vcpu->run->io_completed = 0;
|
|
||||||
|
|
||||||
kvm_arch_ops->decache_regs(vcpu);
|
kvm_arch_ops->decache_regs(vcpu);
|
||||||
|
|
||||||
io->count -= io->cur_count;
|
io->count -= io->cur_count;
|
||||||
|
@ -1800,12 +1800,13 @@ static int kvm_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
|
||||||
/* re-sync apic's tpr */
|
/* re-sync apic's tpr */
|
||||||
vcpu->cr8 = kvm_run->cr8;
|
vcpu->cr8 = kvm_run->cr8;
|
||||||
|
|
||||||
if (kvm_run->io_completed) {
|
|
||||||
if (vcpu->pio.cur_count) {
|
if (vcpu->pio.cur_count) {
|
||||||
r = complete_pio(vcpu);
|
r = complete_pio(vcpu);
|
||||||
if (r)
|
if (r)
|
||||||
goto out;
|
goto out;
|
||||||
} else if (!vcpu->mmio_is_write) {
|
}
|
||||||
|
|
||||||
|
if (vcpu->mmio_needed) {
|
||||||
memcpy(vcpu->mmio_data, kvm_run->mmio.data, 8);
|
memcpy(vcpu->mmio_data, kvm_run->mmio.data, 8);
|
||||||
vcpu->mmio_read_completed = 1;
|
vcpu->mmio_read_completed = 1;
|
||||||
vcpu->mmio_needed = 0;
|
vcpu->mmio_needed = 0;
|
||||||
|
@ -1820,7 +1821,6 @@ static int kvm_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (kvm_run->exit_reason == KVM_EXIT_HYPERCALL) {
|
if (kvm_run->exit_reason == KVM_EXIT_HYPERCALL) {
|
||||||
kvm_arch_ops->cache_regs(vcpu);
|
kvm_arch_ops->cache_regs(vcpu);
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
#include <asm/types.h>
|
#include <asm/types.h>
|
||||||
#include <linux/ioctl.h>
|
#include <linux/ioctl.h>
|
||||||
|
|
||||||
#define KVM_API_VERSION 10
|
#define KVM_API_VERSION 11
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Architectural interrupt line count, and the size of the bitmap needed
|
* Architectural interrupt line count, and the size of the bitmap needed
|
||||||
|
@ -58,9 +58,8 @@ enum kvm_exit_reason {
|
||||||
/* for KVM_RUN, returned by mmap(vcpu_fd, offset=0) */
|
/* for KVM_RUN, returned by mmap(vcpu_fd, offset=0) */
|
||||||
struct kvm_run {
|
struct kvm_run {
|
||||||
/* in */
|
/* in */
|
||||||
__u32 io_completed; /* mmio/pio request completed */
|
|
||||||
__u8 request_interrupt_window;
|
__u8 request_interrupt_window;
|
||||||
__u8 padding1[3];
|
__u8 padding1[7];
|
||||||
|
|
||||||
/* out */
|
/* out */
|
||||||
__u32 exit_reason;
|
__u32 exit_reason;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue