Skip to content

Commit

Permalink
vhost: mask VIRTIO_F_RING_RESET for vhost and vhost-user devices
Browse files Browse the repository at this point in the history
Commit 69e1c14 ("virtio: core: vq reset feature negotation support")
enabled VIRTIO_F_RING_RESET by default for all virtio devices.

This feature is not currently emulated by QEMU, so for vhost and
vhost-user devices we need to make sure it is supported by the offloaded
device emulation (in-kernel or in another process).
To do this we need to add VIRTIO_F_RING_RESET to the features bitmap
passed to vhost_get_features(). This way it will be masked if the device
does not support it.

This issue was initially discovered with vhost-vsock and vhost-user-vsock,
and then also tested with vhost-user-rng which confirmed the same issue.
They fail when sending features through VHOST_SET_FEATURES ioctl or
VHOST_USER_SET_FEATURES message, since VIRTIO_F_RING_RESET is negotiated
by the guest (Linux >= v6.0), but not supported by the device.

Fixes: 69e1c14 ("virtio: core: vq reset feature negotation support")
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1318
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Message-Id: <20221121101101.29400-1-sgarzare@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Acked-by: Raphael Norwitz <raphael.norwitz@nutanix.com>
Acked-by: Jason Wang <jasowang@redhat.com>
  • Loading branch information
stefano-garzarella authored and mstsirkin committed Nov 22, 2022
1 parent 2c83112 commit 562a7d2
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions hw/block/vhost-user-blk.c
Expand Up @@ -52,6 +52,7 @@ static const int user_feature_bits[] = {
VIRTIO_F_NOTIFY_ON_EMPTY,
VIRTIO_F_RING_PACKED,
VIRTIO_F_IOMMU_PLATFORM,
VIRTIO_F_RING_RESET,
VHOST_INVALID_FEATURE_BIT
};

Expand Down
1 change: 1 addition & 0 deletions hw/net/vhost_net.c
Expand Up @@ -75,6 +75,7 @@ static const int user_feature_bits[] = {
VIRTIO_NET_F_MTU,
VIRTIO_F_IOMMU_PLATFORM,
VIRTIO_F_RING_PACKED,
VIRTIO_F_RING_RESET,
VIRTIO_NET_F_RSS,
VIRTIO_NET_F_HASH_REPORT,

Expand Down
1 change: 1 addition & 0 deletions hw/scsi/vhost-scsi.c
Expand Up @@ -38,6 +38,7 @@ static const int kernel_feature_bits[] = {
VIRTIO_RING_F_INDIRECT_DESC,
VIRTIO_RING_F_EVENT_IDX,
VIRTIO_SCSI_F_HOTPLUG,
VIRTIO_F_RING_RESET,
VHOST_INVALID_FEATURE_BIT
};

Expand Down
1 change: 1 addition & 0 deletions hw/scsi/vhost-user-scsi.c
Expand Up @@ -36,6 +36,7 @@ static const int user_feature_bits[] = {
VIRTIO_RING_F_INDIRECT_DESC,
VIRTIO_RING_F_EVENT_IDX,
VIRTIO_SCSI_F_HOTPLUG,
VIRTIO_F_RING_RESET,
VHOST_INVALID_FEATURE_BIT
};

Expand Down
1 change: 1 addition & 0 deletions hw/virtio/vhost-user-fs.c
Expand Up @@ -32,6 +32,7 @@ static const int user_feature_bits[] = {
VIRTIO_F_NOTIFY_ON_EMPTY,
VIRTIO_F_RING_PACKED,
VIRTIO_F_IOMMU_PLATFORM,
VIRTIO_F_RING_RESET,

VHOST_INVALID_FEATURE_BIT
};
Expand Down
1 change: 1 addition & 0 deletions hw/virtio/vhost-user-gpio.c
Expand Up @@ -24,6 +24,7 @@ static const int feature_bits[] = {
VIRTIO_RING_F_INDIRECT_DESC,
VIRTIO_RING_F_EVENT_IDX,
VIRTIO_GPIO_F_IRQ,
VIRTIO_F_RING_RESET,
VHOST_INVALID_FEATURE_BIT
};

Expand Down
1 change: 1 addition & 0 deletions hw/virtio/vhost-user-i2c.c
Expand Up @@ -16,6 +16,7 @@

static const int feature_bits[] = {
VIRTIO_I2C_F_ZERO_LENGTH_REQUEST,
VIRTIO_F_RING_RESET,
VHOST_INVALID_FEATURE_BIT
};

Expand Down
11 changes: 9 additions & 2 deletions hw/virtio/vhost-user-rng.c
Expand Up @@ -16,6 +16,11 @@
#include "qemu/error-report.h"
#include "standard-headers/linux/virtio_ids.h"

static const int feature_bits[] = {
VIRTIO_F_RING_RESET,
VHOST_INVALID_FEATURE_BIT
};

static void vu_rng_start(VirtIODevice *vdev)
{
VHostUserRNG *rng = VHOST_USER_RNG(vdev);
Expand Down Expand Up @@ -106,8 +111,10 @@ static void vu_rng_set_status(VirtIODevice *vdev, uint8_t status)
static uint64_t vu_rng_get_features(VirtIODevice *vdev,
uint64_t requested_features, Error **errp)
{
/* No feature bits used yet */
return requested_features;
VHostUserRNG *rng = VHOST_USER_RNG(vdev);

return vhost_get_features(&rng->vhost_dev, feature_bits,
requested_features);
}

static void vu_rng_handle_output(VirtIODevice *vdev, VirtQueue *vq)
Expand Down
1 change: 1 addition & 0 deletions hw/virtio/vhost-vsock-common.c
Expand Up @@ -21,6 +21,7 @@

const int feature_bits[] = {
VIRTIO_VSOCK_F_SEQPACKET,
VIRTIO_F_RING_RESET,
VHOST_INVALID_FEATURE_BIT
};

Expand Down
1 change: 1 addition & 0 deletions net/vhost-vdpa.c
Expand Up @@ -69,6 +69,7 @@ const int vdpa_feature_bits[] = {
VIRTIO_NET_F_CTRL_VQ,
VIRTIO_F_IOMMU_PLATFORM,
VIRTIO_F_RING_PACKED,
VIRTIO_F_RING_RESET,
VIRTIO_NET_F_RSS,
VIRTIO_NET_F_HASH_REPORT,
VIRTIO_NET_F_GUEST_ANNOUNCE,
Expand Down

0 comments on commit 562a7d2

Please sign in to comment.