Patch "iommu: Clean up open-coded ownership checks" has been added to the 6.6-stable tree
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 7 lines · Sasha Levin
This is a note to let you know that I've just added the patch titled
iommu: Clean up open-coded ownership checks
to the 6.6-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
Quoted 6 lines
The filename of the patch is:
iommu-clean-up-open-coded-ownership-checks.patch
and it can be found in the queue-6.6 subdirectory.If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Unless you're also going to backport the rest of the larger redesign which makes this commit message true, I don't think this is appropriate.
Thanks,
Robin.
Quoted 181 lines
commit
302639dd441533017096f8ebccb02440090fb09dAuthor: Robin Murphy <[email protected]> Date: Tue Nov 21 18:04:03 2023 +0000iommu: Clean up open-coded ownership checks
[ Upstream commit
e7080665c977ea1aafb8547a9c7bd08b199311d6]Some drivers already implement their own defence against the possibility of being given someone else's device. Since this is now taken care of by the core code (and via a slightly different path from the original fwspec-based idea), let's clean them up.
Acked-by Will Deacon <[email protected]>Reviewed-by Jason Gunthorpe <[email protected]>Reviewed-by Jerry Snitselaar <[email protected]>Signed-off-by Robin Murphy <[email protected]>Link https://lore.kernel.org/r/58a9879ce3f03562bb061e6714fe6efb554c3907.1700589539.git.robin.murphy@arm.com open hereSigned-off-by Joerg Roedel <[email protected]>Stable-dep-of:
229e6ee43d2a("iommu/arm-smmu: Defer probe of clients after smmu device bound")Signed-off-by Sasha Levin <[email protected]>drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +0
-3@@ -2658,9 +2658,6 @@ static struct iommu_device *arm_smmu_probe_device(struct device *dev)struct arm_smmu_master *master;struct iommu_fwspec *fwspec =dev_iommu_fwspec_get (dev); -if (!fwspec || fwspec->ops != &arm_smmu_ops) -return ERR_PTR (-ENODEV ); -if (WARN_ON_ONCE (dev_iommu_priv_get (dev)))return ERR_PTR (-EBUSY );drivers/iommu/arm/arm-smmu/arm-smmu.c +1
-8@@ -1116,11 +1116,6 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev)struct arm_smmu_device *smmu;int ret; -if (!fwspec || fwspec->ops != &arm_smmu_ops) { -dev_err (dev,"cannot attach to SMMU, is it on the same bus?\n" ); -return -ENXIO ; - } -/* * FIXME: The arch/arm DMA API code tries to attach devices to its own * domains between of_xlate() and probe_device() - we have no way to cope @@ -1357,10 +1352,8 @@ static struct iommu_device *arm_smmu_probe_device(struct device *dev) fwspec =dev_iommu_fwspec_get (dev);if (ret) goto out_free; - }else if (fwspec && fwspec->ops == &arm_smmu_ops) { - smmu =arm_smmu_get_by_fwnode (fwspec->iommu_fwnode); }else { -return ERR_PTR (-ENODEV ); + smmu =arm_smmu_get_by_fwnode (fwspec->iommu_fwnode); } ret = -EINVAL ;drivers/iommu/arm/arm-smmu/qcom_iommu.c +3
-13@@ -79,16 +79,6 @@ static struct qcom_iommu_domain *to_qcom_iommu_domain(struct iommu_domain *dom)static const struct iommu_ops qcom_iommu_ops; -static struct qcom_iommu_dev *to_iommu (struct device *dev) -{ -struct iommu_fwspec *fwspec =dev_iommu_fwspec_get (dev); - -if (!fwspec || fwspec->ops != &qcom_iommu_ops) -return NULL ; - -return dev_iommu_priv_get (dev); -} -static struct qcom_iommu_ctx *to_ctx (struct qcom_iommu_domain *d,unsigned asid) {struct qcom_iommu_dev *qcom_iommu = d->iommu;@@ -374,7 +364,7 @@ static void qcom_iommu_domain_free(struct iommu_domain *domain)static int qcom_iommu_attach_dev (struct iommu_domain *domain,struct device *dev) { -struct qcom_iommu_dev *qcom_iommu =to_iommu (dev); +struct qcom_iommu_dev *qcom_iommu =dev_iommu_priv_get (dev);struct qcom_iommu_domain *qcom_domain =to_qcom_iommu_domain (domain);int ret;@@ -406,7 +396,7 @@ static int qcom_iommu_identity_attach(struct iommu_domain *identity_domain,struct iommu_domain *domain =iommu_get_domain_for_dev (dev);struct qcom_iommu_domain *qcom_domain;struct iommu_fwspec *fwspec =dev_iommu_fwspec_get (dev); -struct qcom_iommu_dev *qcom_iommu =to_iommu (dev); +struct qcom_iommu_dev *qcom_iommu =dev_iommu_priv_get (dev);unsigned int i;if (domain == identity_domain || !domain)@@ -537,7 +527,7 @@ static bool qcom_iommu_capable(struct device *dev, enum iommu_cap cap)static struct iommu_device *qcom_iommu_probe_device (struct device *dev) { -struct qcom_iommu_dev *qcom_iommu =to_iommu (dev); +struct qcom_iommu_dev *qcom_iommu =dev_iommu_priv_get (dev);struct device_link *link;if (!qcom_iommu)drivers/iommu/mtk_iommu.c +1
-6@@ -843,16 +843,11 @@ static phys_addr_t mtk_iommu_iova_to_phys(struct iommu_domain *domain,static struct iommu_device *mtk_iommu_probe_device (struct device *dev) {struct iommu_fwspec *fwspec =dev_iommu_fwspec_get (dev); -struct mtk_iommu_data *data; +struct mtk_iommu_data *data =dev_iommu_priv_get (dev);struct device_link *link;struct device *larbdev;unsigned int larbid, larbidx, i; -if (!fwspec || fwspec->ops != &mtk_iommu_ops) -return ERR_PTR (-ENODEV );/* Not a iommu client device */ - - data =dev_iommu_priv_get (dev); -if (!MTK_IOMMU_IS_TYPE (data->plat_data,MTK_IOMMU_TYPE_MM ))return &data->iommu;drivers/iommu/mtk_iommu_v1.c +0
-3@@ -478,9 +478,6 @@ static struct iommu_device *mtk_iommu_v1_probe_device(struct device *dev) idx++; } -if (!fwspec || fwspec->ops != &mtk_iommu_v1_ops) -return ERR_PTR (-ENODEV );/* Not a iommu client device */ - data =dev_iommu_priv_get (dev);/* Link the consumer device with the smi-larb device(supplier) */ drivers/iommu/sprd-iommu.c +1
-7@@ -388,13 +388,7 @@ static phys_addr_t sprd_iommu_iova_to_phys(struct iommu_domain *domain,static struct iommu_device *sprd_iommu_probe_device (struct device *dev) { -struct iommu_fwspec *fwspec =dev_iommu_fwspec_get (dev); -struct sprd_iommu_device *sdev; - -if (!fwspec || fwspec->ops != &sprd_iommu_ops) -return ERR_PTR (-ENODEV ); - - sdev =dev_iommu_priv_get (dev); +struct sprd_iommu_device *sdev =dev_iommu_priv_get (dev);return &sdev->iommu; }drivers/iommu/virtio-iommu.c +0
-3@@ -969,9 +969,6 @@ static struct iommu_device *viommu_probe_device(struct device *dev)struct viommu_dev *viommu =NULL ;struct iommu_fwspec *fwspec =dev_iommu_fwspec_get (dev); -if (!fwspec || fwspec->ops != &viommu_ops) -return ERR_PTR (-ENODEV ); - viommu =viommu_get_by_fwnode (fwspec->iommu_fwnode);if (!viommu)return ERR_PTR (-ENODEV );
Quoted 12 lines · Robin Murphy
Quoted 11 lines · Sasha Levin
This is a note to let you know that I've just added the patch titled
iommu: Clean up open-coded ownership checks
to the 6.6-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summaryThe filename of the patch is:
iommu-clean-up-open-coded-ownership-checks.patch
and it can be found in the queue-6.6 subdirectory.
Quoted 5 lines
Quoted 2 lines
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Unless you're also going to backport the rest of the larger redesign which makes this commit message true, I don't think this is appropriate.
It's needed because of:
Quoted 1 line
Quoted 1 line
Stable-dep-of:
229e6ee43d2a("iommu/arm-smmu: Defer probe of clients after smmu device bound")
That commit.
Is this still not relevant?
thanks,
greg k-h
Quoted 19 lines · Greg KH
Quoted 12 lines · Robin Murphy
Quoted 11 lines · Sasha Levin
This is a note to let you know that I've just added the patch titled
iommu: Clean up open-coded ownership checks
to the 6.6-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summaryThe filename of the patch is:
iommu-clean-up-open-coded-ownership-checks.patch
and it can be found in the queue-6.6 subdirectory.Quoted 5 lines
Quoted 2 lines
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Unless you're also going to backport the rest of the larger redesign which makes this commit message true, I don't think this is appropriate.
Quoted 7 lines
It's needed because of:
Quoted 1 line
Quoted 1 line
Stable-dep-of:
229e6ee43d2a("iommu/arm-smmu: Defer probe of clients after smmu device bound")That commit.
Is this still not relevant?
It's not a functional dependency though, just context, and in this case I think a manual resolution is a lot safer to reason about. Lemme just remind myself how to write up a backport patch correctly, and I'll send it out shortly...
Cheers,
Robin.
Quoted 4 lines
thanks,
greg k-h