From: Robin Murphy <robin.murphy@arm.com>
To: Jerry Snitselaar <jsnitsel@redhat.com>
Cc: joro@8bytes.org, iommu@lists.linux.dev, will@kernel.org,
linux-kernel@vger.kernel.org, Jon Hunter <jonathanh@nvidia.com>
Subject: Re: [PATCH] iommu/dma: Fix domain init
Date: Tue, 21 May 2024 16:14:50 +0100 [thread overview]
Message-ID: <02ebbb90-84bc-4d8c-a7aa-94cd78e0a2a5@arm.com> (raw)
In-Reply-To: <jrzrf3vz2rhcrwazsxuljuyhru4mstyzuhjx4uawcfmjlmvipd@lu6usxz22ved>
On 21/05/2024 5:45 am, Jerry Snitselaar wrote:
> On Mon, May 20, 2024 at 08:14:44PM GMT, Robin Murphy wrote:
>> Despite carefully rewording the kerneldoc to describe the new direct
>> interaction with dma_range_map, it seems I managed to confuse myself in
>> removing the redundant force_aperture check and ended up making the code
>> not do that at all. This led to dma_range_maps inadvertently being able
>> to set iovad->start_pfn = 0, and all the nonsensical chaos which ensues
>> from there. Restore the correct behaviour of constraining base_pfn to
>> the domain aperture regardless of dma_range_map, and not trying to apply
>> dma_range_map constraints to the basic IOVA domain since they will be
>> properly handled with reserved regions later.
>>
>> Reported-by: Jon Hunter <jonathanh@nvidia.com>
>> Reported-by: Jerry Snitselaar <jsnitsel@redhat.com>
>> Fixes: e28a114243d1 ("iommu/dma: Make limit checks self-contained")
>
> I'm seeing this upstream as ad4750b07d34 ("iommu/dma: Make limit checks self-contained") now.
What, you mean when Linus pulls some patches I wrote he *doesn't* also
rebase my local development branch for me? /facepalm
Joerg, please shout if you'd like a resend for that.
>> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
>> ---
>
> Tested-by: Jerry Snitselaar <jsnitsel@redhat.com>
> Reviewed-by: Jerry Snitselaar <jsnitsel@redhat.com>
Thanks!
Robin.
>> drivers/iommu/dma-iommu.c | 8 ++++----
>> 1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
>> index 89a53c2f2cf9..1ec89ca75c59 100644
>> --- a/drivers/iommu/dma-iommu.c
>> +++ b/drivers/iommu/dma-iommu.c
>> @@ -685,15 +685,15 @@ static int iommu_dma_init_domain(struct iommu_domain *domain, struct device *dev
>>
>> /* Check the domain allows at least some access to the device... */
>> if (map) {
>> - dma_addr_t base = dma_range_map_min(map);
>> - if (base > domain->geometry.aperture_end ||
>> + if (dma_range_map_min(map) > domain->geometry.aperture_end ||
>> dma_range_map_max(map) < domain->geometry.aperture_start) {
>> pr_warn("specified DMA range outside IOMMU capability\n");
>> return -EFAULT;
>> }
>> - /* ...then finally give it a kicking to make sure it fits */
>> - base_pfn = max(base, domain->geometry.aperture_start) >> order;
>> }
>> + /* ...then finally give it a kicking to make sure it fits */
>> + base_pfn = max_t(unsigned long, base_pfn,
>> + domain->geometry.aperture_start >> order);
>>
>> /* start_pfn is always nonzero for an already-initialised domain */
>> mutex_lock(&cookie->mutex);
>> --
>> 2.39.2.101.g768bb238c484.dirty
>>
>
next prev parent reply other threads:[~2024-05-21 15:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-20 19:14 Robin Murphy
2024-05-21 4:45 ` Jerry Snitselaar
2024-05-21 15:14 ` Robin Murphy [this message]
2024-06-04 11:52 ` 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=02ebbb90-84bc-4d8c-a7aa-94cd78e0a2a5@arm.com \
--to=robin.murphy@arm.com \
--cc=iommu@lists.linux.dev \
--cc=jonathanh@nvidia.com \
--cc=joro@8bytes.org \
--cc=jsnitsel@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--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
all inboxes | Powered by JetHome®