aboutsummaryrefslogtreecommitdiffstats
path: root/virt/kvm/iodev.h
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/iodev.h
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/iodev.h')
-rw-r--r--virt/kvm/iodev.h39
1 files changed, 15 insertions, 24 deletions
diff --git a/virt/kvm/iodev.h b/virt/kvm/iodev.h
index 06e38b23fa61..12fd3caffd2b 100644
--- a/virt/kvm/iodev.h
+++ b/virt/kvm/iodev.h
@@ -17,23 +17,24 @@
17#define __KVM_IODEV_H__ 17#define __KVM_IODEV_H__
18 18
19#include <linux/kvm_types.h> 19#include <linux/kvm_types.h>
20#include <asm/errno.h>
20 21
21struct kvm_io_device; 22struct kvm_io_device;
22 23
23/** 24/**
24 * kvm_io_device_ops are called under kvm slots_lock. 25 * kvm_io_device_ops are called under kvm slots_lock.
26 * read and write handlers return 0 if the transaction has been handled,
27 * or non-zero to have it passed to the next device.
25 **/ 28 **/
26struct kvm_io_device_ops { 29struct kvm_io_device_ops {
27 void (*read)(struct kvm_io_device *this, 30 int (*read)(struct kvm_io_device *this,
31 gpa_t addr,
32 int len,
33 void *val);
34 int (*write)(struct kvm_io_device *this,
28 gpa_t addr, 35 gpa_t addr,
29 int len, 36 int len,
30 void *val); 37 const void *val);
31 void (*write)(struct kvm_io_device *this,
32 gpa_t addr,
33 int len,
34 const void *val);
35 int (*in_range)(struct kvm_io_device *this, gpa_t addr, int len,
36 int is_write);
37 void (*destructor)(struct kvm_io_device *this); 38 void (*destructor)(struct kvm_io_device *this);
38}; 39};
39 40
@@ -48,26 +49,16 @@ static inline void kvm_iodevice_init(struct kvm_io_device *dev,
48 dev->ops = ops; 49 dev->ops = ops;
49} 50}
50 51
51static inline void kvm_iodevice_read(struct kvm_io_device *dev, 52static inline int kvm_iodevice_read(struct kvm_io_device *dev,
52 gpa_t addr, 53 gpa_t addr, int l, void *v)
53 int len,
54 void *val)
55{ 54{
56 dev->ops->read(dev, addr, len, val); 55 return dev->ops->read ? dev->ops->read(dev, addr, l, v) : -EOPNOTSUPP;
57} 56}
58 57
59static inline void kvm_iodevice_write(struct kvm_io_device *dev, 58static inline int kvm_iodevice_write(struct kvm_io_device *dev,
60 gpa_t addr, 59 gpa_t addr, int l, const void *v)
61 int len,
62 const void *val)
63{ 60{
64 dev->ops->write(dev, addr, len, val); 61 return dev->ops->write ? dev->ops->write(dev, addr, l, v) : -EOPNOTSUPP;
65}
66
67static inline int kvm_iodevice_in_range(struct kvm_io_device *dev,
68 gpa_t addr, int len, int is_write)
69{
70 return dev->ops->in_range(dev, addr, len, is_write);
71} 62}
72 63
73static inline void kvm_iodevice_destructor(struct kvm_io_device *dev) 64static inline void kvm_iodevice_destructor(struct kvm_io_device *dev)