From: Jason Gunthorpe <jgg@ziepe.ca>
To: Robin Murphy <robin.murphy@arm.com>
Cc: joro@8bytes.org, will@kernel.org, iommu@lists.linux.dev,
linux-arm-kernel@lists.infradead.org, m.szyprowski@samsung.com,
heiko@sntech.de, jernej.skrabec@gmail.com,
thierry.reding@gmail.com, vdumpa@nvidia.com
Subject: Re: [PATCH 8/8] iommu: Improve map/unmap sanity checks
Date: Wed, 13 Sep 2023 11:39:28 -0300 [thread overview]
Message-ID: <ZQHJoK0Er/nekjL6@ziepe.ca> (raw)
In-Reply-To: <524db1ec0139c964d26928a6a264945aa66d010c.1694525662.git.robin.murphy@arm.com>
On Tue, Sep 12, 2023 at 05:18:44PM +0100, Robin Murphy wrote:
> The current checks for the __IOMMU_DOMAIN_PAGING capability seem a
> bit stifled, since it is quite likely now that a non-paging domain
> won't have a pgsize_bitmap and/or mapping ops, and thus get caught
> by the earlier condition anyway. Swap them around to test the more
> fundamental condition first, then we can reasonably also upgrade
> the other to a WARN_ON, since if a driver does ever expose a paging
> domain without the means to actually page, it's clearly very broken.
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
> ---
> drivers/iommu/iommu.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
> index c83f2e4c56f5..391bcae4d02d 100644
> --- a/drivers/iommu/iommu.c
> +++ b/drivers/iommu/iommu.c
> @@ -2427,12 +2427,12 @@ static int __iommu_map(struct iommu_domain *domain, unsigned long iova,
> phys_addr_t orig_paddr = paddr;
> int ret = 0;
>
> - if (unlikely(!ops->map_pages || domain->pgsize_bitmap == 0UL))
> - return -ENODEV;
> -
> if (unlikely(!(domain->type & __IOMMU_DOMAIN_PAGING)))
> return -EINVAL;
Why isn't this a WARN_ON? The caller is clearly lost its mind if it
is calling map on a non paging domain..
> + if (WARN_ON(!ops->map_pages || domain->pgsize_bitmap == 0UL))
> + return -ENODEV;
> +
And these could be moved to after attach so they are not in any fast
path, and eventually to after alloc..
Jason
next prev parent reply other threads:[~2023-09-13 14:39 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-12 16:18 [PATCH 0/8] iommu: Clean up map/unmap ops Robin Murphy
2023-09-12 16:18 ` [PATCH 1/8] iommu/exynos: Update to {map,unmap}_pages Robin Murphy
2023-09-12 16:18 ` [PATCH 2/8] iommu/omap: " Robin Murphy
2023-09-12 16:18 ` [PATCH 3/8] iommu/rockchip: " Robin Murphy
2023-09-12 16:18 ` [PATCH 4/8] iommu/sun50i: " Robin Murphy
2023-09-12 16:18 ` [PATCH 5/8] iommu/tegra-gart: " Robin Murphy
2023-09-12 16:18 ` [PATCH 6/8] iommu/tegra-smmu: " Robin Murphy
2023-09-12 16:18 ` [PATCH 7/8] iommu: Retire map/unmap ops Robin Murphy
2023-09-13 14:40 ` Jason Gunthorpe
2023-09-12 16:18 ` [PATCH 8/8] iommu: Improve map/unmap sanity checks Robin Murphy
2023-09-13 14:39 ` Jason Gunthorpe [this message]
2023-09-13 18:46 ` Robin Murphy
2023-09-14 12:48 ` Jason Gunthorpe
2023-09-14 14:23 ` Robin Murphy
2023-09-14 16:48 ` Jason Gunthorpe
2023-09-19 12:18 ` Robin Murphy
2023-09-22 17:28 ` Jason Gunthorpe
2023-09-25 10:05 ` [PATCH 0/8] iommu: Clean up map/unmap ops Joerg Roedel
2023-09-25 15:33 ` Jernej Škrabec
2023-09-26 9:23 ` Joerg Roedel
2023-09-26 12:01 ` Robin Murphy
2023-09-26 14:57 ` Joerg Roedel
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=ZQHJoK0Er/nekjL6@ziepe.ca \
--to=jgg@ziepe.ca \
--cc=heiko@sntech.de \
--cc=iommu@lists.linux.dev \
--cc=jernej.skrabec@gmail.com \
--cc=joro@8bytes.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=m.szyprowski@samsung.com \
--cc=robin.murphy@arm.com \
--cc=thierry.reding@gmail.com \
--cc=vdumpa@nvidia.com \
--cc=will@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox