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]
Date:	Wed, 9 Oct 2013 19:02:25 +0000
From:	Yoder Stuart-B08248 <B08248@...escale.com>
To:	Wood Scott-B07421 <B07421@...escale.com>,
	Kim Phillips <kim.phillips@...aro.org>
CC:	Christoffer Dall <christoffer.dall@...aro.org>,
	Alex Williamson <alex.williamson@...hat.com>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"a.motakis@...tualopensystems.com" <a.motakis@...tualopensystems.com>,
	"agraf@...e.de" <agraf@...e.de>,
	Wood Scott-B07421 <B07421@...escale.com>,
	Sethi Varun-B16395 <B16395@...escale.com>,
	Bhushan Bharat-R65777 <R65777@...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: RFC: (re-)binding the VFIO platform driver to a platform device

Have been thinking about this issue some more.  As Scott mentioned,
'wildcard' matching for a driver can be fairly done in the platform
bus driver.  We could add a new flag to the platform driver struct:

diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 4f8bef3..4d6cf14 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -727,6 +727,10 @@ static int platform_match(struct device *dev, struct device_driver *drv)
        struct platform_device *pdev = to_platform_device(dev);
        struct platform_driver *pdrv = to_platform_driver(drv);

+       /* the driver matches any device */
+       if (pdrv->match_any)
+               return 1;
+
        /* Attempt an OF style match first */
        if (of_driver_match_device(dev, drv))
                return 1;

However, the more problematic issue is that a bus driver has no way to 
differentiate from an explicit bind request via sysfs and a bind that
happened through bus probing.

I think something like the new flag in the snippet below would enable the platform
bus to support platform drivers that only bind on explicit request:

diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 4c289ab..daf6d24 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -201,7 +201,7 @@ static ssize_t bind_store(struct device_driver *drv, const char *buf,
        int err = -ENODEV;

        dev = bus_find_device_by_name(bus, NULL, buf);
-       if (dev && dev->driver == NULL && driver_match_device(drv, dev)) {
+       if (dev && dev->driver == NULL && driver_match_device(drv, dev, 1)) {
                if (dev->parent)        /* Needed for USB */
                        device_lock(dev->parent);
                device_lock(dev);
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 35fa368..bb53785 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -389,7 +389,7 @@ static int __device_attach(struct device_driver *drv, void *data)
 {
        struct device *dev = data;

-       if (!driver_match_device(drv, dev))
+       if (!driver_match_device(drv, dev, 0))
                return 0;

        return driver_probe_device(drv, dev);
@@ -450,7 +450,7 @@ static int __driver_attach(struct device *dev, void *data)
         * is an error.
         */

-       if (!driver_match_device(drv, dev))
+       if (!driver_match_device(drv, dev, 0))
                return 0;

        if (dev->parent)        /* Needed for USB */


diff --git a/drivers/base/base.h b/drivers/base/base.h
index 2cbc677..7a15ef3 100644
--- a/drivers/base/base.h
+++ b/drivers/base/base.h
@@ -114,9 +114,9 @@ extern void driver_detach(struct device_driver *drv);
 extern int driver_probe_device(struct device_driver *drv, struct device *dev);
 extern void driver_deferred_probe_del(struct device *dev);
 static inline int driver_match_device(struct device_driver *drv,
-                                     struct device *dev)
+                                     struct device *dev, int explicit_bind)
 {
-       return drv->bus->match ? drv->bus->match(dev, drv) : 1;
+       return drv->bus->match ? drv->bus->match(dev, drv, explicit_bind) : 1;
 }

Of, course the above change would need to be propagated to the different
bus drivers that implement the 'match' function.

Regards,
Stuart

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ