lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1649917349.6242197-1-xuanzhuo@linux.alibaba.com>
Date:   Thu, 14 Apr 2022 14:22:29 +0800
From:   Xuan Zhuo <xuanzhuo@...ux.alibaba.com>
To:     Jason Wang <jasowang@...hat.com>
Cc:     Jeff Dike <jdike@...toit.com>, Richard Weinberger <richard@....at>,
        Anton Ivanov <anton.ivanov@...bridgegreys.com>,
        "Michael S. Tsirkin" <mst@...hat.com>,
        "David S. Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>,
        Hans de Goede <hdegoede@...hat.com>,
        Mark Gross <markgross@...nel.org>,
        Vadim Pasternak <vadimp@...dia.com>,
        Bjorn Andersson <bjorn.andersson@...aro.org>,
        Mathieu Poirier <mathieu.poirier@...aro.org>,
        Cornelia Huck <cohuck@...hat.com>,
        Halil Pasic <pasic@...ux.ibm.com>,
        Heiko Carstens <hca@...ux.ibm.com>,
        Vasily Gorbik <gor@...ux.ibm.com>,
        Christian Borntraeger <borntraeger@...ux.ibm.com>,
        Alexander Gordeev <agordeev@...ux.ibm.com>,
        Sven Schnelle <svens@...ux.ibm.com>,
        Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Jesper Dangaard Brouer <hawk@...nel.org>,
        John Fastabend <john.fastabend@...il.com>,
        Johannes Berg <johannes.berg@...el.com>,
        Vincent Whitchurch <vincent.whitchurch@...s.com>,
        linux-um@...ts.infradead.org, netdev@...r.kernel.org,
        platform-driver-x86@...r.kernel.org,
        linux-remoteproc@...r.kernel.org, linux-s390@...r.kernel.org,
        kvm@...r.kernel.org, bpf@...r.kernel.org,
        virtualization@...ts.linux-foundation.org
Subject: Re: [PATCH v9 22/32] virtio_pci: queue_reset: extract the logic of active vq for modern pci

On Tue, 12 Apr 2022 14:58:19 +0800, Jason Wang <jasowang@...hat.com> wrote:
>
> 在 2022/4/6 上午11:43, Xuan Zhuo 写道:
> > Introduce vp_active_vq() to configure vring to backend after vq attach
> > vring. And configure vq vector if necessary.
> >
> > Signed-off-by: Xuan Zhuo <xuanzhuo@...ux.alibaba.com>
> > ---
> >   drivers/virtio/virtio_pci_modern.c | 46 ++++++++++++++++++------------
> >   1 file changed, 28 insertions(+), 18 deletions(-)
> >
> > diff --git a/drivers/virtio/virtio_pci_modern.c b/drivers/virtio/virtio_pci_modern.c
> > index 86d301f272b8..49a4493732cf 100644
> > --- a/drivers/virtio/virtio_pci_modern.c
> > +++ b/drivers/virtio/virtio_pci_modern.c
> > @@ -176,6 +176,29 @@ static void vp_reset(struct virtio_device *vdev)
> >   	vp_disable_cbs(vdev);
> >   }
> >
> > +static int vp_active_vq(struct virtqueue *vq, u16 msix_vec)
> > +{
> > +	struct virtio_pci_device *vp_dev = to_vp_device(vq->vdev);
> > +	struct virtio_pci_modern_device *mdev = &vp_dev->mdev;
> > +	unsigned long index;
> > +
> > +	index = vq->index;
> > +
> > +	/* activate the queue */
> > +	vp_modern_set_queue_size(mdev, index, virtqueue_get_vring_size(vq));
> > +	vp_modern_queue_address(mdev, index, virtqueue_get_desc_addr(vq),
> > +				virtqueue_get_avail_addr(vq),
> > +				virtqueue_get_used_addr(vq));
> > +
> > +	if (msix_vec != VIRTIO_MSI_NO_VECTOR) {
> > +		msix_vec = vp_modern_queue_vector(mdev, index, msix_vec);
> > +		if (msix_vec == VIRTIO_MSI_NO_VECTOR)
> > +			return -EBUSY;
> > +	}
> > +
> > +	return 0;
> > +}
> > +
> >   static u16 vp_config_vector(struct virtio_pci_device *vp_dev, u16 vector)
> >   {
> >   	return vp_modern_config_vector(&vp_dev->mdev, vector);
> > @@ -220,32 +243,19 @@ static struct virtqueue *setup_vq(struct virtio_pci_device *vp_dev,
> >
> >   	vq->num_max = num;
> >
> > -	/* activate the queue */
> > -	vp_modern_set_queue_size(mdev, index, virtqueue_get_vring_size(vq));
> > -	vp_modern_queue_address(mdev, index, virtqueue_get_desc_addr(vq),
> > -				virtqueue_get_avail_addr(vq),
> > -				virtqueue_get_used_addr(vq));
> > +	err = vp_active_vq(vq, msix_vec);
> > +	if (err)
> > +		goto err;
> >
> >   	vq->priv = (void __force *)vp_modern_map_vq_notify(mdev, index, NULL);
> >   	if (!vq->priv) {
> >   		err = -ENOMEM;
> > -		goto err_map_notify;
> > -	}
> > -
> > -	if (msix_vec != VIRTIO_MSI_NO_VECTOR) {
> > -		msix_vec = vp_modern_queue_vector(mdev, index, msix_vec);
> > -		if (msix_vec == VIRTIO_MSI_NO_VECTOR) {
> > -			err = -EBUSY;
> > -			goto err_assign_vector;
> > -		}
> > +		goto err;
> >   	}
> >
> >   	return vq;
> >
> > -err_assign_vector:
> > -	if (!mdev->notify_base)
> > -		pci_iounmap(mdev->pci_dev, (void __iomem __force *)vq->priv);
>
>
> We need keep this or anything I missed?

I think so, after modification, vp_modern_map_vq_notify is the last step before
returning vq. If it fails, then vq->priv is equal to NULL, so there is no need
to execute pci_iounmap.

Did I miss something?

Thanks.

>
> Thanks
>
>
> > -err_map_notify:
> > +err:
> >   	vring_del_virtqueue(vq);
> >   	return ERR_PTR(err);
> >   }
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ