Michael S. Tsirkin
2023-Jun-05 12:41 UTC
[PATCH] vhost-vdpa: filter VIRTIO_F_RING_PACKED feature
On Mon, Jun 05, 2023 at 01:06:44PM +0200, Stefano Garzarella wrote:> vhost-vdpa IOCTLs (eg. VHOST_GET_VRING_BASE, VHOST_SET_VRING_BASE) > don't support packed virtqueue well yet, so let's filter the > VIRTIO_F_RING_PACKED feature for now in vhost_vdpa_get_features(). > > This way, even if the device supports it, we don't risk it being > negotiated, then the VMM is unable to set the vring state properly. > > Fixes: 4c8cf31885f6 ("vhost: introduce vDPA-based backend") > Cc: stable at vger.kernel.org > Signed-off-by: Stefano Garzarella <sgarzare at redhat.com> > --- > > Notes: > This patch should be applied before the "[PATCH v2 0/3] vhost_vdpa: > better PACKED support" series [1] and backported in stable branches. > > We can revert it when we are sure that everything is working with > packed virtqueues. > > Thanks, > Stefano > > [1] https://lore.kernel.org/virtualization/20230424225031.18947-1-shannon.nelson at amd.com/I'm a bit lost here. So why am I merging "better PACKED support" then? Does this patch make them a NOP?> drivers/vhost/vdpa.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c > index 8c1aefc865f0..ac2152135b23 100644 > --- a/drivers/vhost/vdpa.c > +++ b/drivers/vhost/vdpa.c > @@ -397,6 +397,12 @@ static long vhost_vdpa_get_features(struct vhost_vdpa *v, u64 __user *featurep) > > features = ops->get_device_features(vdpa); > > + /* > + * IOCTLs (eg. VHOST_GET_VRING_BASE, VHOST_SET_VRING_BASE) don't support > + * packed virtqueue well yet, so let's filter the feature for now. > + */ > + features &= ~BIT_ULL(VIRTIO_F_RING_PACKED); > + > if (copy_to_user(featurep, &features, sizeof(features))) > return -EFAULT; > > > base-commit: 9561de3a55bed6bdd44a12820ba81ec416e705a7 > -- > 2.40.1
Stefano Garzarella
2023-Jun-05 12:54 UTC
[PATCH] vhost-vdpa: filter VIRTIO_F_RING_PACKED feature
On Mon, Jun 05, 2023 at 08:41:54AM -0400, Michael S. Tsirkin wrote:>On Mon, Jun 05, 2023 at 01:06:44PM +0200, Stefano Garzarella wrote: >> vhost-vdpa IOCTLs (eg. VHOST_GET_VRING_BASE, VHOST_SET_VRING_BASE) >> don't support packed virtqueue well yet, so let's filter the >> VIRTIO_F_RING_PACKED feature for now in vhost_vdpa_get_features(). >> >> This way, even if the device supports it, we don't risk it being >> negotiated, then the VMM is unable to set the vring state properly. >> >> Fixes: 4c8cf31885f6 ("vhost: introduce vDPA-based backend") >> Cc: stable at vger.kernel.org >> Signed-off-by: Stefano Garzarella <sgarzare at redhat.com> >> --- >> >> Notes: >> This patch should be applied before the "[PATCH v2 0/3] vhost_vdpa: >> better PACKED support" series [1] and backported in stable branches. >> >> We can revert it when we are sure that everything is working with >> packed virtqueues. >> >> Thanks, >> Stefano >> >> [1] https://lore.kernel.org/virtualization/20230424225031.18947-1-shannon.nelson at amd.com/ > >I'm a bit lost here. So why am I merging "better PACKED support" then?To really support packed virtqueue with vhost-vdpa, at that point we would also have to revert this patch. I wasn't sure if you wanted to queue the series for this merge window. In that case do you think it is better to send this patch only for stable branches?>Does this patch make them a NOP?Yep, after applying the "better PACKED support" series and being sure that the IOCTLs of vhost-vdpa support packed virtqueue, we should revert this patch. Let me know if you prefer a different approach. I'm concerned that QEMU uses vhost-vdpa IOCTLs thinking that the kernel interprets them the right way, when it does not. Thanks, Stefano> >> drivers/vhost/vdpa.c | 6 ++++++ >> 1 file changed, 6 insertions(+) >> >> diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c >> index 8c1aefc865f0..ac2152135b23 100644 >> --- a/drivers/vhost/vdpa.c >> +++ b/drivers/vhost/vdpa.c >> @@ -397,6 +397,12 @@ static long vhost_vdpa_get_features(struct vhost_vdpa *v, u64 __user *featurep) >> >> features = ops->get_device_features(vdpa); >> >> + /* >> + * IOCTLs (eg. VHOST_GET_VRING_BASE, VHOST_SET_VRING_BASE) don't support >> + * packed virtqueue well yet, so let's filter the feature for now. >> + */ >> + features &= ~BIT_ULL(VIRTIO_F_RING_PACKED); >> + >> if (copy_to_user(featurep, &features, sizeof(features))) >> return -EFAULT; >> >> >> base-commit: 9561de3a55bed6bdd44a12820ba81ec416e705a7 >> -- >> 2.40.1 >