aboutsummaryrefslogtreecommitdiffstats
path: root/virt/kvm/kvm_main.c
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2009-06-29 15:24:32 -0400
committerAvi Kivity <avi@redhat.com>2009-09-10 01:33:05 -0400
commitbda9020e2463ec94db9f97e8615f3bae22069838 (patch)
tree48125316d4c0f419a35aefdfbf665d30ad0c55ca /virt/kvm/kvm_main.c
parent6c474694530f377507f9aca438c17206e051e6e7 (diff)
KVM: remove in_range from io devices
This changes bus accesses to use high-level kvm_io_bus_read/kvm_io_bus_write functions. in_range now becomes unused so it is removed from device ops in favor of read/write callbacks performing range checks internally. This allows aliasing (mostly for in-kernel virtio), as well as better error handling by making it possible to pass errors up to userspace. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'virt/kvm/kvm_main.c')
-rw-r--r--virt/kvm/kvm_main.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 0edc366ecf89..594606526620 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -2512,19 +2512,25 @@ void kvm_io_bus_destroy(struct kvm_io_bus *bus)
2512 } 2512 }
2513} 2513}
2514 2514
2515struct kvm_io_device *kvm_io_bus_find_dev(struct kvm_io_bus *bus, 2515/* kvm_io_bus_write - called under kvm->slots_lock */
2516 gpa_t addr, int len, int is_write) 2516int kvm_io_bus_write(struct kvm_io_bus *bus, gpa_t addr,
2517 int len, const void *val)
2517{ 2518{
2518 int i; 2519 int i;
2520 for (i = 0; i < bus->dev_count; i++)
2521 if (!kvm_iodevice_write(bus->devs[i], addr, len, val))
2522 return 0;
2523 return -EOPNOTSUPP;
2524}
2519 2525
2520 for (i = 0; i < bus->dev_count; i++) { 2526/* kvm_io_bus_read - called under kvm->slots_lock */
2521 struct kvm_io_device *pos = bus->devs[i]; 2527int kvm_io_bus_read(struct kvm_io_bus *bus, gpa_t addr, int len, void *val)
2522 2528{
2523 if (kvm_iodevice_in_range(pos, addr, len, is_write)) 2529 int i;
2524 return pos; 2530 for (i = 0; i < bus->dev_count; i++)
2525 } 2531 if (!kvm_iodevice_read(bus->devs[i], addr, len, val))
2526 2532 return 0;
2527 return NULL; 2533 return -EOPNOTSUPP;
2528} 2534}
2529 2535
2530void kvm_io_bus_register_dev(struct kvm *kvm, struct kvm_io_bus *bus, 2536void kvm_io_bus_register_dev(struct kvm *kvm, struct kvm_io_bus *bus,