Re: [PATCH v2] virtio_pci: support enabling VFs

From: Tiwei Bie
Date: Fri Jun 01 2018 - 00:01:15 EST


On Fri, Jun 01, 2018 at 06:47:01AM +0300, Michael S. Tsirkin wrote:
> On Fri, Jun 01, 2018 at 10:09:21AM +0800, Tiwei Bie wrote:
> > There is a new feature bit allocated in virtio spec to
> > support SR-IOV (Single Root I/O Virtualization):
> >
> > https://github.com/oasis-tcs/virtio-spec/issues/11
> >
> > This patch enables the support for this feature bit in
> > virtio driver.
> >
> > Signed-off-by: Tiwei Bie <tiwei.bie@xxxxxxxxx>
> > Acked-by: Stefan Hajnoczi <stefanha@xxxxxxxxxx>
> > Acked-by: Michael S. Tsirkin <mst@xxxxxxxxxx>
> > ---
>
> Generally you aren't supposed to carry forward acks
> when you make major changes.

Got it! Thank you very much!

>
> In this case I'm fine with the patch, so never mind.

Thank you so much! Anyway, it's my fault.
I'll send a new version dropping all acks.

>
[...]
> >
> > +static int virtio_pci_sriov_configure(struct pci_dev *pci_dev, int num_vfs)
> > +{
> > + struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev);
> > + struct virtio_device *vdev = &vp_dev->vdev;
> > + int ret;
> > +
> > + if (!(vdev->config->get_status(vdev) & VIRTIO_CONFIG_S_DRIVER_OK))
> > + return -EBUSY;
> > +
> > + if (!__virtio_test_bit(vdev, VIRTIO_F_SR_IOV))
> > + return -EINVAL;
> > +
> > + if (pci_vfs_assigned(pci_dev))
> > + return -EPERM;
>
> Not a comment on this patch - existing code has the
> same race - but generally
>
> 1. this seems racy since assigning vfs does not seem
> to take device lock
> 2. does this work correctly for kvm at all?
> pci_set_dev_assigned seems to be only called by xen.
>
> Can you look at addressing this pls?

Sure! I'll do it!

Best regards,
Tiwei Bie