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: <A2975661238FB949B60364EF0F2C25743A134FF2@SHSMSX104.ccr.corp.intel.com>
Date:   Mon, 16 Dec 2019 11:59:51 +0000
From:   "Liu, Yi L" <yi.l.liu@...el.com>
To:     Alex Williamson <alex.williamson@...hat.com>
CC:     "kwankhede@...dia.com" <kwankhede@...dia.com>,
        "Tian, Kevin" <kevin.tian@...el.com>,
        "baolu.lu@...ux.intel.com" <baolu.lu@...ux.intel.com>,
        "Sun, Yi Y" <yi.y.sun@...el.com>,
        "joro@...tes.org" <joro@...tes.org>,
        "jean-philippe.brucker@....com" <jean-philippe.brucker@....com>,
        "peterx@...hat.com" <peterx@...hat.com>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "kvm@...r.kernel.org" <kvm@...r.kernel.org>
Subject: RE: [PATCH v3 03/10] vfio_pci: refine vfio_pci_driver reference in
 vfio_pci.c

> From: Alex Williamson < alex.williamson@...hat.com>
> Sent: Monday, December 16, 2019 6:47 AM
> To: Liu, Yi L <yi.l.liu@...el.com>
> Subject: Re: [PATCH v3 03/10] vfio_pci: refine vfio_pci_driver reference in vfio_pci.c
> 
> On Thu, 21 Nov 2019 19:23:40 +0800
> Liu Yi L <yi.l.liu@...el.com> wrote:
> 
> > This patch replaces the vfio_pci_driver reference in vfio_pci.c with
> > pci_dev_driver(vdev->pdev) which is more helpful to make the functions
> > be generic to module types.
> >
> > Cc: Kevin Tian <kevin.tian@...el.com>
> > Cc: Lu Baolu <baolu.lu@...ux.intel.com>
> > Signed-off-by: Liu Yi L <yi.l.liu@...el.com>
> > ---
> >  drivers/vfio/pci/vfio_pci.c | 33 ++++++++++++++++++---------------
> >  1 file changed, 18 insertions(+), 15 deletions(-)
> >
> > diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
> > index b04e43a..2096e66 100644
> > --- a/drivers/vfio/pci/vfio_pci.c
> > +++ b/drivers/vfio/pci/vfio_pci.c
> > @@ -1460,24 +1460,25 @@ static void vfio_pci_reflck_get(struct vfio_pci_reflck
> *reflck)
> >
> >  static int vfio_pci_reflck_find(struct pci_dev *pdev, void *data)
> >  {
> > -	struct vfio_pci_reflck **preflck = data;
> > +	struct vfio_pci_device *vdev = data;
> > +	struct vfio_pci_reflck **preflck = &vdev->reflck;
> >  	struct vfio_device *device;
> > -	struct vfio_pci_device *vdev;
> > +	struct vfio_pci_device *tmp;
> >
> >  	device = vfio_device_get_from_dev(&pdev->dev);
> >  	if (!device)
> >  		return 0;
> >
> > -	if (pci_dev_driver(pdev) != &vfio_pci_driver) {
> > +	if (pci_dev_driver(pdev) != pci_dev_driver(vdev->pdev)) {
> >  		vfio_device_put(device);
> >  		return 0;
> >  	}
> >
> > -	vdev = vfio_device_data(device);
> > +	tmp = vfio_device_data(device);
> >
> > -	if (vdev->reflck) {
> > -		vfio_pci_reflck_get(vdev->reflck);
> > -		*preflck = vdev->reflck;
> > +	if (tmp->reflck) {
> > +		vfio_pci_reflck_get(tmp->reflck);
> > +		*preflck = tmp->reflck;
> >  		vfio_device_put(device);
> >  		return 1;
> >  	}
> > @@ -1494,7 +1495,7 @@ static int vfio_pci_reflck_attach(struct vfio_pci_device
> *vdev)
> >
> >  	if (pci_is_root_bus(vdev->pdev->bus) ||
> >  	    vfio_pci_for_each_slot_or_bus(vdev->pdev, vfio_pci_reflck_find,
> > -					  &vdev->reflck, slot) <= 0)
> > +					  vdev, slot) <= 0)
> >  		vdev->reflck = vfio_pci_reflck_alloc();
> >
> >  	mutex_unlock(&reflck_lock);
> > @@ -1519,6 +1520,7 @@ static void vfio_pci_reflck_put(struct vfio_pci_reflck
> *reflck)
> >
> >  struct vfio_devices {
> >  	struct vfio_device **devices;
> > +	struct vfio_pci_device *vdev;
> >  	int cur_index;
> >  	int max_index;
> >  };
> > @@ -1527,7 +1529,7 @@ static int vfio_pci_get_unused_devs(struct pci_dev
> *pdev, void *data)
> >  {
> >  	struct vfio_devices *devs = data;
> >  	struct vfio_device *device;
> > -	struct vfio_pci_device *vdev;
> > +	struct vfio_pci_device *tmp;
> >
> >  	if (devs->cur_index == devs->max_index)
> >  		return -ENOSPC;
> > @@ -1536,15 +1538,15 @@ static int vfio_pci_get_unused_devs(struct pci_dev
> *pdev, void *data)
> >  	if (!device)
> >  		return -EINVAL;
> >
> > -	if (pci_dev_driver(pdev) != &vfio_pci_driver) {
> > +	if (pci_dev_driver(pdev) != pci_dev_driver(devs->vdev->pdev)) {
> >  		vfio_device_put(device);
> >  		return -EBUSY;
> >  	}
> >
> > -	vdev = vfio_device_data(device);
> > +	tmp = vfio_device_data(device);
> >
> >  	/* Fault if the device is not unused */
> > -	if (vdev->refcnt) {
> > +	if (tmp->refcnt) {
> >  		vfio_device_put(device);
> >  		return -EBUSY;
> >  	}
> > @@ -1590,6 +1592,7 @@ static void vfio_pci_try_bus_reset(struct vfio_pci_device
> *vdev)
> >  	if (!devs.devices)
> >  		return;
> >
> > +	devs.vdev = vdev;
> 
> This could be added to the declaration initializer:
> 
> struct vfio_devices devs = { .vdev = vdev, .cur_index = 0 };
> 
> It might seem a little less random then.  Thanks,

Got it. Will do it.

Thanks,
Yi Liu

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ