aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJean-Philippe Brucker <jean-philippe.brucker@arm.com>2019-01-10 14:12:39 +0000
committerWill Deacon <will.deacon@arm.com>2019-01-22 06:55:26 +0000
commit95242e44535bfb37b4ac4c90c353d5b73824a08e (patch)
treef80b5bc3110146ff12f37a1f3912db10937b0ab1 /include
parent56c82a0305d7f889a05c71fd11bff4c6609c5199 (diff)
downloadkvmtool-95242e44535bfb37b4ac4c90c353d5b73824a08e.tar.gz
virtio: Implement notify_status
Modern virtio require proper status handling and reset. A "notify_status" callback is already present in the virtio ops, but isn't implemented by any device. Instead they currently use "set_guest_feature" to reset the device and deal with endianess. This isn't sufficient for proper device reset, so add the notify_status callback to all devices that need it. To add useful hints like "start" and "stop", extend the status variable to 32-bits. Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com> [Julien T: Remove VIRTIO_CONFIG_S_NEEDS_RESET from config mask, as it is virtio v1+ macro and kvmtool only implements v0.9, this macro should not be referenced for now] Signed-off-by: Julien Thierry <julien.thierry@arm.com> Signed-off-by: Will Deacon <will.deacon@arm.com>
Diffstat (limited to 'include')
-rw-r--r--include/kvm/virtio.h20
1 files changed, 19 insertions, 1 deletions
diff --git a/include/kvm/virtio.h b/include/kvm/virtio.h
index 72290fc5..f1433210 100644
--- a/include/kvm/virtio.h
+++ b/include/kvm/virtio.h
@@ -7,6 +7,7 @@
#include <linux/virtio_pci.h>
#include <linux/types.h>
+#include <linux/virtio_config.h>
#include <sys/uio.h>
#include "kvm/barrier.h"
@@ -27,6 +28,20 @@
#define VIRTIO_ENDIAN_HOST VIRTIO_ENDIAN_BE
#endif
+/* Reserved status bits */
+#define VIRTIO_CONFIG_S_MASK \
+ (VIRTIO_CONFIG_S_ACKNOWLEDGE | \
+ VIRTIO_CONFIG_S_DRIVER | \
+ VIRTIO_CONFIG_S_DRIVER_OK | \
+ VIRTIO_CONFIG_S_FEATURES_OK | \
+ VIRTIO_CONFIG_S_FAILED)
+
+/* Kvmtool status bits */
+/* Start the device */
+#define VIRTIO__STATUS_START (1 << 8)
+/* Stop the device */
+#define VIRTIO__STATUS_STOP (1 << 9)
+
struct virt_queue {
struct vring vring;
u32 pfn;
@@ -162,6 +177,7 @@ struct virtio_device {
struct virtio_ops *ops;
u16 endian;
u32 features;
+ u32 status;
};
struct virtio_ops {
@@ -178,7 +194,7 @@ struct virtio_ops {
void (*notify_vq_eventfd)(struct kvm *kvm, void *dev, u32 vq, u32 efd);
int (*signal_vq)(struct kvm *kvm, struct virtio_device *vdev, u32 queueid);
int (*signal_config)(struct kvm *kvm, struct virtio_device *vdev);
- void (*notify_status)(struct kvm *kvm, void *dev, u8 status);
+ void (*notify_status)(struct kvm *kvm, void *dev, u32 status);
int (*init)(struct kvm *kvm, void *dev, struct virtio_device *vdev,
int device_id, int subsys_id, int class);
int (*exit)(struct kvm *kvm, struct virtio_device *vdev);
@@ -204,5 +220,7 @@ static inline void virtio_init_device_vq(struct virtio_device *vdev,
void virtio_set_guest_features(struct kvm *kvm, struct virtio_device *vdev,
void *dev, u32 features);
+void virtio_notify_status(struct kvm *kvm, struct virtio_device *vdev,
+ void *dev, u8 status);
#endif /* KVM__VIRTIO_H */