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: <20190906214409.26677-2-robdclark@gmail.com>
Date:   Fri,  6 Sep 2019 14:44:01 -0700
From:   Rob Clark <robdclark@...il.com>
To:     iommu@...ts.linux-foundation.org
Cc:     dri-devel@...ts.freedesktop.org, linux-arm-msm@...r.kernel.org,
        Robin Murphy <robin.murphy@....com>,
        Joerg Roedel <joro@...tes.org>, Will Deacon <will@...nel.org>,
        Rob Clark <robdclark@...omium.org>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        "Rafael J. Wysocki" <rafael.j.wysocki@...el.com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Suzuki K Poulose <suzuki.poulose@....com>,
        Rasmus Villemoes <linux@...musvillemoes.dk>,
        Heikki Krogerus <heikki.krogerus@...ux.intel.com>,
        Bartosz Golaszewski <brgl@...ev.pl>,
        Sudeep Holla <sudeep.holla@....com>,
        Joe Perches <joe@...ches.com>, Arnd Bergmann <arnd@...db.de>,
        linux-kernel@...r.kernel.org (open list)
Subject: [PATCH v2 1/2] iommu: add support for drivers that manage iommu explicitly

From: Rob Clark <robdclark@...omium.org>

Avoid attaching any non-driver managed domain if the driver indicates
that it manages the iommu directly.

Signed-off-by: Rob Clark <robdclark@...omium.org>
---
 drivers/iommu/iommu.c    | 2 +-
 drivers/iommu/of_iommu.c | 3 +++
 include/linux/device.h   | 3 ++-
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 0c674d80c37f..2ac5e8d48cae 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -674,7 +674,7 @@ int iommu_group_add_device(struct iommu_group *group, struct device *dev)
 
 	mutex_lock(&group->mutex);
 	list_add_tail(&device->list, &group->devices);
-	if (group->domain)
+	if (group->domain && !(dev->driver && dev->driver->driver_manages_iommu))
 		ret = __iommu_attach_device(group->domain, dev);
 	mutex_unlock(&group->mutex);
 	if (ret)
diff --git a/drivers/iommu/of_iommu.c b/drivers/iommu/of_iommu.c
index 614a93aa5305..62b47e384a77 100644
--- a/drivers/iommu/of_iommu.c
+++ b/drivers/iommu/of_iommu.c
@@ -221,6 +221,9 @@ const struct iommu_ops *of_iommu_configure(struct device *dev,
 	} else if (err < 0) {
 		dev_dbg(dev, "Adding to IOMMU failed: %d\n", err);
 		ops = NULL;
+	} else if (dev->driver && dev->driver->driver_manages_iommu) {
+		dev_dbg(dev, "Driver manages IOMMU\n");
+		ops = NULL;
 	}
 
 	return ops;
diff --git a/include/linux/device.h b/include/linux/device.h
index 1aa341b2a0db..b77a11b8d9bb 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -284,7 +284,8 @@ struct device_driver {
 	struct module		*owner;
 	const char		*mod_name;	/* used for built-in modules */
 
-	bool suppress_bind_attrs;	/* disables bind/unbind via sysfs */
+	bool suppress_bind_attrs:1;	/* disables bind/unbind via sysfs */
+	bool driver_manages_iommu:1;	/* driver manages IOMMU explicitly */
 	enum probe_type probe_type;
 
 	const struct of_device_id	*of_match_table;
-- 
2.21.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ