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: <6A3DF150A5B70D4F9B66A25E3F7C888D071D4FE5@039-SN2MPN1-013.039d.mgd.msft.net>
Date:	Tue, 29 Oct 2013 04:45:46 +0000
From:	Bhushan Bharat-R65777 <R65777@...escale.com>
To:	Wood Scott-B07421 <B07421@...escale.com>
CC:	Alex Williamson <alex.williamson@...hat.com>,
	Kim Phillips <kim.phillips@...aro.org>,
	Yoder Stuart-B08248 <B08248@...escale.com>,
	"christoffer.dall@...aro.org" <christoffer.dall@...aro.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"a.motakis@...tualopensystems.com" <a.motakis@...tualopensystems.com>,
	"agraf@...e.de" <agraf@...e.de>,
	Sethi Varun-B16395 <B16395@...escale.com>,
	"peter.maydell@...aro.org" <peter.maydell@...aro.org>,
	"santosh.shukla@...aro.org" <santosh.shukla@...aro.org>,
	"kvm@...r.kernel.org" <kvm@...r.kernel.org>,
	"gregkh@...uxfoundation.org" <gregkh@...uxfoundation.org>
Subject: RE: [PATCH 3/4] VFIO: pci: amend vfio-pci for explicit binding via
 sysfs only



> -----Original Message-----
> From: Wood Scott-B07421
> Sent: Tuesday, October 29, 2013 10:05 AM
> To: Bhushan Bharat-R65777
> Cc: Wood Scott-B07421; Alex Williamson; Kim Phillips; Yoder Stuart-B08248;
> christoffer.dall@...aro.org; linux-kernel@...r.kernel.org;
> a.motakis@...tualopensystems.com; agraf@...e.de; Sethi Varun-B16395;
> peter.maydell@...aro.org; santosh.shukla@...aro.org; kvm@...r.kernel.org;
> gregkh@...uxfoundation.org
> Subject: Re: [PATCH 3/4] VFIO: pci: amend vfio-pci for explicit binding via
> sysfs only
> 
> On Mon, 2013-10-28 at 23:31 -0500, Bhushan Bharat-R65777 wrote:
> >
> > > -----Original Message-----
> > > From: Wood Scott-B07421
> > > Sent: Tuesday, October 29, 2013 10:00 AM
> > > To: Bhushan Bharat-R65777
> > > Cc: Wood Scott-B07421; Alex Williamson; Kim Phillips; Yoder
> > > Stuart-B08248; christoffer.dall@...aro.org;
> > > linux-kernel@...r.kernel.org; a.motakis@...tualopensystems.com;
> > > agraf@...e.de; Sethi Varun-B16395; peter.maydell@...aro.org;
> > > santosh.shukla@...aro.org; kvm@...r.kernel.org;
> > > gregkh@...uxfoundation.org
> > > Subject: Re: [PATCH 3/4] VFIO: pci: amend vfio-pci for explicit
> > > binding via sysfs only
> > >
> > > On Mon, 2013-10-28 at 22:52 -0500, Bhushan Bharat-R65777 wrote:
> > > >
> > > > > -----Original Message-----
> > > > > From: Wood Scott-B07421
> > > > > Sent: Tuesday, October 29, 2013 9:11 AM
> > > > > To: Bhushan Bharat-R65777
> > > > > Cc: Wood Scott-B07421; Alex Williamson; Kim Phillips; Yoder
> > > > > Stuart-B08248; christoffer.dall@...aro.org;
> > > > > linux-kernel@...r.kernel.org; a.motakis@...tualopensystems.com;
> > > > > agraf@...e.de; Sethi Varun-B16395; peter.maydell@...aro.org;
> > > > > santosh.shukla@...aro.org; kvm@...r.kernel.org;
> > > > > gregkh@...uxfoundation.org
> > > > > Subject: Re: [PATCH 3/4] VFIO: pci: amend vfio-pci for explicit
> > > > > binding via sysfs only
> > > > >
> > > > > On Mon, 2013-10-28 at 22:38 -0500, Bhushan Bharat-R65777 wrote:
> > > > > >
> > > > > > > -----Original Message-----
> > > > > > > From: Wood Scott-B07421
> > > > > > > Sent: Monday, October 28, 2013 11:40 PM
> > > > > > > To: Alex Williamson
> > > > > > > Cc: Kim Phillips; Bhushan Bharat-R65777; Wood Scott-B07421;
> > > > > > > Yoder Stuart-B08248; christoffer.dall@...aro.org;
> > > > > > > linux-kernel@...r.kernel.org;
> > > > > > > a.motakis@...tualopensystems.com; agraf@...e.de; Sethi
> > > > > > > Varun-B16395; peter.maydell@...aro.org;
> > > > > > > santosh.shukla@...aro.org; kvm@...r.kernel.org;
> > > > > > > gregkh@...uxfoundation.org
> > > > > > > Subject: Re: [PATCH 3/4] VFIO: pci: amend vfio-pci for
> > > > > > > explicit binding via sysfs only
> > > > > > >
> > > > > > > On Mon, 2013-10-28 at 13:00 -0500, Scott Wood wrote:
> > > > > > > > On Mon, 2013-10-28 at 11:47 -0600, Alex Williamson wrote:
> > > > > > > > > On Fri, 2013-10-11 at 01:27 -0500, Kim Phillips wrote:
> > > > > > > > > > Force the vfio-pci driver to only be bound explicitly
> > > > > > > > > > via sysfs to avoid conflics with other drivers in the
> > > > > > > > > > event of a
> > > hotplug.
> > > > > > > > >
> > > > > > > > > We can't break userspace, so we can't disable the
> > > > > > > > > current method of binding devices to vfio-pci.  We can
> > > > > > > > > add a new method and perhaps deprecate the existing
> > > > > > > > > mechanism to be removed at some point in the future.
> > > > > > > > > Thanks,
> > > > > > > >
> > > > > > > > I thought the existing method involved using sysfs bind,
> > > > > > > > and this was just eliminating a race.  How does the bind
> > > > > > > > get triggered
> > > currently?
> > > > > > >
> > > > > > > OK, so it seems it's relying on the write to new_id calling
> > > driver_attach().
> > > > > > > Sigh.  I guess we could make driver-sysfs-bind-only be
> > > > > > > settable via sysfs, and have new-userspace set both that and
> > > > > > > PCI_ANY_ID (or the specific ID if userspace
> > > > > > > prefers) via new_id.  The platform bus patches could
> > > > > > > continue as is, since there's no existing mechanism to break.
> > > > > >
> > > > > > What about changing the store_new_id() to bypass exact ids
> > > > > > check if driver
> > > > > have PCI_ANY_ID?
> > > > >
> > > > > I don't follow.
> > > >
> > > > store_new_id() function id defined as:
> > > >
> > > > static ssize_t store_new_id(struct device_driver *driver, const
> > > > char *buf, size_t count) {
> > > >         struct pci_driver *pdrv = to_pci_driver(driver);
> > > >         const struct pci_device_id *ids = pdrv->id_table;
> > > >
> > > > <snip>
> > > >         /* Only accept driver_data values that match an existing id_table
> > > >            entry */
> > > >         if (ids) {
> > > >                 retval = -EINVAL;
> > > >                 while (ids->vendor || ids->subvendor || ids->class_mask) {
> > > >                         if (driver_data == ids->driver_data) {
> > > >                                 retval = 0;
> > > >                                 break;
> > > >                         }
> > > >                         ids++;
> > > >                 }
> > > >                 if (retval)     /* No match */
> > > >                         return retval;
> > > >         }
> > > >
> > > >         retval = pci_add_dynid(pdrv, vendor, device, subvendor, subdevice,
> > > >                                class, class_mask, driver_data);
> > > > <snip>
> > > >
> > > >
> > > > So when ids == NULL it does not check of vendor etc and calls
> > > > pci_add_dynid()
> > > which in turn calls driver_attach().
> > > >
> > > > If we change the above loop to break if ids->vendor == PCI_ANY_ID
> > > >&& ids- subvendor == PCI_ANY_ID then also we will call pci_add_dyids().
> > >
> > > What problem are you trying to solve?
> >
> > new_id interface to continue working as before.
> 
> In what specific way does this allow new_id to continue working as before?  Be
> verbose.


What I observed that this patch (kim's patch) new_id interface stops working. This is found to be because
store_new_id() checks for pdrv->id_table which is no more NULL, so the below check fails

        if (ids) {
^^
This is no more NULL, so enter inside the loop

                retval = -EINVAL;
                while (ids->vendor || ids->subvendor || ids->class_mask) {
                        if (driver_data == ids->driver_data) {
                                retval = 0;
                                break;
                        }
                        ids++;
                }
                if (retval)   /* No match */
                        return retval;
^^^^^
This is where it returns as -EINVAL
        }

I tried a quick test of what I am saying but it does not work directly (although passes from the above mentioned check), may be some more changes required :(

-Bharat

> 
> -Scott
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ