[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 12/31] vhost: Add vhost_svq_valid_guest_features to shadow vq
From: |
Eugenio Pérez |
Subject: |
[PATCH 12/31] vhost: Add vhost_svq_valid_guest_features to shadow vq |
Date: |
Fri, 21 Jan 2022 21:27:14 +0100 |
This allows it to test if the guest has acknowledged an invalid
transport feature for SVQ. This will include packed vq layout or
event_idx, where the VirtIO device needs help from SVQ.
It is not needed at this moment, but since SVQ will not re-negotiate
features again with the guest, a failure to acknowledge them is fatal
for SVQ.
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
---
hw/virtio/vhost-shadow-virtqueue.h | 1 +
hw/virtio/vhost-shadow-virtqueue.c | 24 ++++++++++++++++++++++++
2 files changed, 25 insertions(+)
diff --git a/hw/virtio/vhost-shadow-virtqueue.h
b/hw/virtio/vhost-shadow-virtqueue.h
index d963867a04..1aae6a2297 100644
--- a/hw/virtio/vhost-shadow-virtqueue.h
+++ b/hw/virtio/vhost-shadow-virtqueue.h
@@ -16,6 +16,7 @@
typedef struct VhostShadowVirtqueue VhostShadowVirtqueue;
bool vhost_svq_valid_device_features(uint64_t *features);
+bool vhost_svq_valid_guest_features(uint64_t *features);
void vhost_svq_set_svq_kick_fd(VhostShadowVirtqueue *svq, int svq_kick_fd);
void vhost_svq_set_guest_call_notifier(VhostShadowVirtqueue *svq, int call_fd);
diff --git a/hw/virtio/vhost-shadow-virtqueue.c
b/hw/virtio/vhost-shadow-virtqueue.c
index 51442b3dbf..f70160d7ca 100644
--- a/hw/virtio/vhost-shadow-virtqueue.c
+++ b/hw/virtio/vhost-shadow-virtqueue.c
@@ -89,6 +89,30 @@ bool vhost_svq_valid_device_features(uint64_t *dev_features)
return r;
}
+/**
+ * Offers SVQ valid transport features to the guest.
+ *
+ * @guest_features The device's supported features. Return SVQ's if success.
+ *
+ * Returns true if SVQ can handle them, false otherwise.
+ */
+bool vhost_svq_valid_guest_features(uint64_t *guest_features)
+{
+ static const uint64_t transport = MAKE_64BIT_MASK(VIRTIO_TRANSPORT_F_START,
+ VIRTIO_TRANSPORT_F_END - VIRTIO_TRANSPORT_F_START);
+
+ /* These transport features are handled by VirtQueue */
+ static const uint64_t valid = BIT_ULL(VIRTIO_RING_F_INDIRECT_DESC) |
+ BIT_ULL(VIRTIO_F_VERSION_1) |
+ BIT_ULL(VIRTIO_F_IOMMU_PLATFORM);
+
+ /* We are only interested in transport-related feature bits */
+ uint64_t guest_transport_features = (*guest_features) & transport;
+
+ *guest_features &= (valid | ~transport);
+ return !(guest_transport_features & (transport ^ valid));
+}
+
/* Forward guest notifications */
static void vhost_handle_guest_kick(EventNotifier *n)
{
--
2.27.0
- Re: [PATCH 06/31] vhost: Route guest->host notification through shadow virtqueue, (continued)
- [PATCH 07/31] vhost: dd vhost_svq_get_svq_call_notifier, Eugenio Pérez, 2022/01/21
- [PATCH 08/31] vhost: Add vhost_svq_set_guest_call_notifier, Eugenio Pérez, 2022/01/21
- [PATCH 09/31] vhost-vdpa: Take into account SVQ in vhost_vdpa_set_vring_call, Eugenio Pérez, 2022/01/21
- [PATCH 10/31] vhost: Route host->guest notification through shadow virtqueue, Eugenio Pérez, 2022/01/21
- [PATCH 12/31] vhost: Add vhost_svq_valid_guest_features to shadow vq,
Eugenio Pérez <=
- [PATCH 11/31] vhost: Add vhost_svq_valid_device_features to shadow vq, Eugenio Pérez, 2022/01/21
- [PATCH 13/31] vhost: Add vhost_svq_ack_guest_features to shadow vq, Eugenio Pérez, 2022/01/21
- [PATCH 14/31] virtio: Add vhost_shadow_vq_get_vring_addr, Eugenio Pérez, 2022/01/21
- [PATCH 15/31] vdpa: Add vhost_svq_get_num, Eugenio Pérez, 2022/01/21
- [PATCH 16/31] vhost: pass queue index to vhost_vq_get_addr, Eugenio Pérez, 2022/01/21