All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nicolin Chen <nicolinc@nvidia.com>
To: <jgg@nvidia.com>, <kevin.tian@intel.com>, <robin.murphy@arm.com>,
	<joro@8bytes.org>, <will@kernel.org>, <agross@kernel.org>,
	<andersson@kernel.org>, <konrad.dybcio@linaro.org>,
	<yong.wu@mediatek.com>, <matthias.bgg@gmail.com>,
	<thierry.reding@gmail.com>, <alex.williamson@redhat.com>,
	<cohuck@redhat.com>
Cc: <vdumpa@nvidia.com>, <jonathanh@nvidia.com>,
	<iommu@lists.linux.dev>, <linux-kernel@vger.kernel.org>,
	<linux-arm-msm@vger.kernel.org>,
	<linux-mediatek@lists.infradead.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-tegra@vger.kernel.org>, <kvm@vger.kernel.org>
Subject: [PATCH 3/4] iommufd: Do not allocate device object if broken_unmanaged_domain
Date: Fri, 27 Jan 2023 12:04:19 -0800	[thread overview]
Message-ID: <74f7033192488c472ca04b7d03e4dc5705f80cc0.1674849118.git.nicolinc@nvidia.com> (raw)
In-Reply-To: <cover.1674849118.git.nicolinc@nvidia.com>

Add a sanity of the broken_unmanaged_domain flag to reject the use of
iommufd in the early stage, if the flag is set by the iommu driver.

Suggested-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
---
 drivers/iommu/iommufd/device.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/iommu/iommufd/device.c b/drivers/iommu/iommufd/device.c
index d81f93a321af..41b55615a693 100644
--- a/drivers/iommu/iommufd/device.c
+++ b/drivers/iommu/iommufd/device.c
@@ -73,6 +73,9 @@ struct iommufd_device *iommufd_device_bind(struct iommufd_ctx *ictx,
 	if (!device_iommu_capable(dev, IOMMU_CAP_CACHE_COHERENCY))
 		return ERR_PTR(-EINVAL);
 
+	if (!device_iommu_unmanaged_supported(dev))
+		return ERR_PTR(-EINVAL);
+
 	group = iommu_group_get(dev);
 	if (!group)
 		return ERR_PTR(-ENODEV);
-- 
2.39.1


WARNING: multiple messages have this Message-ID (diff)
From: Nicolin Chen <nicolinc@nvidia.com>
To: <jgg@nvidia.com>, <kevin.tian@intel.com>, <robin.murphy@arm.com>,
	<joro@8bytes.org>, <will@kernel.org>, <agross@kernel.org>,
	<andersson@kernel.org>, <konrad.dybcio@linaro.org>,
	<yong.wu@mediatek.com>, <matthias.bgg@gmail.com>,
	<thierry.reding@gmail.com>, <alex.williamson@redhat.com>,
	<cohuck@redhat.com>
Cc: kvm@vger.kernel.org, iommu@lists.linux.dev,
	linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org,
	jonathanh@nvidia.com, linux-mediatek@lists.infradead.org,
	linux-tegra@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/4] iommufd: Do not allocate device object if broken_unmanaged_domain
Date: Fri, 27 Jan 2023 12:04:19 -0800	[thread overview]
Message-ID: <74f7033192488c472ca04b7d03e4dc5705f80cc0.1674849118.git.nicolinc@nvidia.com> (raw)
In-Reply-To: <cover.1674849118.git.nicolinc@nvidia.com>

Add a sanity of the broken_unmanaged_domain flag to reject the use of
iommufd in the early stage, if the flag is set by the iommu driver.

Suggested-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
---
 drivers/iommu/iommufd/device.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/iommu/iommufd/device.c b/drivers/iommu/iommufd/device.c
index d81f93a321af..41b55615a693 100644
--- a/drivers/iommu/iommufd/device.c
+++ b/drivers/iommu/iommufd/device.c
@@ -73,6 +73,9 @@ struct iommufd_device *iommufd_device_bind(struct iommufd_ctx *ictx,
 	if (!device_iommu_capable(dev, IOMMU_CAP_CACHE_COHERENCY))
 		return ERR_PTR(-EINVAL);
 
+	if (!device_iommu_unmanaged_supported(dev))
+		return ERR_PTR(-EINVAL);
+
 	group = iommu_group_get(dev);
 	if (!group)
 		return ERR_PTR(-ENODEV);
-- 
2.39.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2023-01-27 20:06 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-27 20:04 [PATCH 0/4] iommu: Reject drivers with broken_unmanaged_domain Nicolin Chen
2023-01-27 20:04 ` Nicolin Chen
2023-01-27 20:04 ` [PATCH 1/4] iommu: Add a broken_unmanaged_domain flag in iommu_ops Nicolin Chen
2023-01-27 20:04   ` Nicolin Chen
2023-01-27 21:58   ` Robin Murphy
2023-01-27 21:58     ` Robin Murphy
2023-01-27 23:39     ` Nicolin Chen
2023-01-27 23:39       ` Nicolin Chen
2023-01-27 23:54     ` Jason Gunthorpe
2023-01-27 23:54       ` Jason Gunthorpe
2023-01-29  8:11       ` Tian, Kevin
2023-01-29  8:11         ` Tian, Kevin
2023-01-30 13:33         ` Jason Gunthorpe
2023-01-30 13:33           ` Jason Gunthorpe
2023-02-01  3:14           ` Tian, Kevin
2023-02-01  3:14             ` Tian, Kevin
2023-02-01 14:55             ` Jason Gunthorpe
2023-02-01 14:55               ` Jason Gunthorpe
2023-02-02  3:50               ` Tian, Kevin
2023-02-02  3:50                 ` Tian, Kevin
2023-01-29  7:54   ` Tian, Kevin
2023-01-29  7:54     ` Tian, Kevin
2023-01-27 20:04 ` [PATCH 2/4] iommu/dma: Do not init domain if broken_unmanaged_domain Nicolin Chen
2023-01-27 20:04   ` Nicolin Chen
2023-01-27 21:59   ` Robin Murphy
2023-01-27 21:59     ` Robin Murphy
2023-01-27 22:51     ` Nicolin Chen
2023-01-27 22:51       ` Nicolin Chen
2023-01-27 20:04 ` Nicolin Chen [this message]
2023-01-27 20:04   ` [PATCH 3/4] iommufd: Do not allocate device object " Nicolin Chen
2023-01-27 20:04 ` [PATCH 4/4] vfio: Do not allocate domain " Nicolin Chen
2023-01-27 20:04   ` Nicolin Chen
2023-01-29  7:46 ` [PATCH 0/4] iommu: Reject drivers with broken_unmanaged_domain Tian, Kevin
2023-01-29  7:46   ` Tian, Kevin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=74f7033192488c472ca04b7d03e4dc5705f80cc0.1674849118.git.nicolinc@nvidia.com \
    --to=nicolinc@nvidia.com \
    --cc=agross@kernel.org \
    --cc=alex.williamson@redhat.com \
    --cc=andersson@kernel.org \
    --cc=cohuck@redhat.com \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@nvidia.com \
    --cc=jonathanh@nvidia.com \
    --cc=joro@8bytes.org \
    --cc=kevin.tian@intel.com \
    --cc=konrad.dybcio@linaro.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=matthias.bgg@gmail.com \
    --cc=robin.murphy@arm.com \
    --cc=thierry.reding@gmail.com \
    --cc=vdumpa@nvidia.com \
    --cc=will@kernel.org \
    --cc=yong.wu@mediatek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.