mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 16:23:55 -06:00
vhost: Add vhost_svq_valid_features to shadow vq
This allows SVQ to negotiate features with the guest and the device. For the device, SVQ is a driver. While this function bypasses all non-transport features, it needs to disable the features that SVQ does not support when forwarding buffers. This includes packed vq layout, indirect descriptors or event idx. Future changes can add support to offer more features to the guest, since the use of VirtQueue gives this for free. This is left out at the moment for simplicity. Signed-off-by: Eugenio Pérez <eperezma@redhat.com> Acked-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Jason Wang <jasowang@redhat.com>
This commit is contained in:
parent
a8ac88585d
commit
4725a4181b
3 changed files with 61 additions and 0 deletions
|
@ -11,9 +11,53 @@
|
|||
#include "hw/virtio/vhost-shadow-virtqueue.h"
|
||||
|
||||
#include "qemu/error-report.h"
|
||||
#include "qapi/error.h"
|
||||
#include "qemu/main-loop.h"
|
||||
#include "linux-headers/linux/vhost.h"
|
||||
|
||||
/**
|
||||
* Validate the transport device features that both guests can use with the SVQ
|
||||
* and SVQs can use with the device.
|
||||
*
|
||||
* @dev_features: The features
|
||||
* @errp: Error pointer
|
||||
*/
|
||||
bool vhost_svq_valid_features(uint64_t features, Error **errp)
|
||||
{
|
||||
bool ok = true;
|
||||
uint64_t svq_features = features;
|
||||
|
||||
for (uint64_t b = VIRTIO_TRANSPORT_F_START; b <= VIRTIO_TRANSPORT_F_END;
|
||||
++b) {
|
||||
switch (b) {
|
||||
case VIRTIO_F_ANY_LAYOUT:
|
||||
continue;
|
||||
|
||||
case VIRTIO_F_ACCESS_PLATFORM:
|
||||
/* SVQ trust in the host's IOMMU to translate addresses */
|
||||
case VIRTIO_F_VERSION_1:
|
||||
/* SVQ trust that the guest vring is little endian */
|
||||
if (!(svq_features & BIT_ULL(b))) {
|
||||
svq_features |= BIT_ULL(b);
|
||||
ok = false;
|
||||
}
|
||||
continue;
|
||||
|
||||
default:
|
||||
if (svq_features & BIT_ULL(b)) {
|
||||
svq_features &= ~BIT_ULL(b);
|
||||
ok = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!ok) {
|
||||
error_setg(errp, "SVQ Invalid device feature flags, offer: 0x%"PRIx64
|
||||
", ok: 0x%"PRIx64, features, svq_features);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
/**
|
||||
* Forward guest notifications.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue