linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iommu/arm-smmu: fix bug in pmd construction
@ 2014-09-19 21:58 Mitchel Humpherys
  2014-09-21  7:56 ` Varun Sethi
  0 siblings, 1 reply; 3+ messages in thread
From: Mitchel Humpherys @ 2014-09-19 21:58 UTC (permalink / raw)
  To: linux-arm-kernel

We are using the same pfn for every pte we create while constructing the
pmd. Fix this by actually updating the pfn on each iteration of the pmd
construction loop.

It's not clear if we can actually hit this bug right now since iommu_map
splits up the calls to .map based on the page size, so we only ever seem to
iterate this loop once. However, things might change in the future that
might cause us to hit this.

Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
---
Will, I was unable to come up with a test case to hit this bug based on
what I said in the commit message above. Not sure if my analysis is
completely off base, my head is still spinning from all these page tables
:).
---
 drivers/iommu/arm-smmu.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
index ca18d6d42a..eba4cb390c 100644
--- a/drivers/iommu/arm-smmu.c
+++ b/drivers/iommu/arm-smmu.c
@@ -1368,6 +1368,7 @@ static int arm_smmu_alloc_init_pmd(struct arm_smmu_device *smmu, pud_t *pud,
 		ret = arm_smmu_alloc_init_pte(smmu, pmd, addr, next, pfn,
 					      prot, stage);
 		phys += next - addr;
+		pfn = __phys_to_pfn(phys);
 	} while (pmd++, addr = next, addr < end);
 
 	return ret;
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH] iommu/arm-smmu: fix bug in pmd construction
  2014-09-19 21:58 [PATCH] iommu/arm-smmu: fix bug in pmd construction Mitchel Humpherys
@ 2014-09-21  7:56 ` Varun Sethi
  2014-09-22  8:48   ` Will Deacon
  0 siblings, 1 reply; 3+ messages in thread
From: Varun Sethi @ 2014-09-21  7:56 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Mitchel,
I have made changes to the arm smmu driver paging support, as a part of the huge page support patch. Will is currently reviewing changes made by me. I should be able to post my patch in the next couple of weeks.

Regards
Vaun

> -----Original Message-----
> From: iommu-bounces at lists.linux-foundation.org [mailto:iommu-
> bounces at lists.linux-foundation.org] On Behalf Of Mitchel Humpherys
> Sent: Saturday, September 20, 2014 3:29 AM
> To: linux-arm-kernel at lists.infradead.org; iommu at lists.linux-foundation.org;
> Will Deacon
> Subject: [PATCH] iommu/arm-smmu: fix bug in pmd construction
> 
> We are using the same pfn for every pte we create while constructing the pmd.
> Fix this by actually updating the pfn on each iteration of the pmd construction
> loop.
> 
> It's not clear if we can actually hit this bug right now since iommu_map splits up
> the calls to .map based on the page size, so we only ever seem to iterate this
> loop once. However, things might change in the future that might cause us to
> hit this.
> 
> Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
> ---
> Will, I was unable to come up with a test case to hit this bug based on what I
> said in the commit message above. Not sure if my analysis is completely off
> base, my head is still spinning from all these page tables :).
> ---
>  drivers/iommu/arm-smmu.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c index
> ca18d6d42a..eba4cb390c 100644
> --- a/drivers/iommu/arm-smmu.c
> +++ b/drivers/iommu/arm-smmu.c
> @@ -1368,6 +1368,7 @@ static int arm_smmu_alloc_init_pmd(struct
> arm_smmu_device *smmu, pud_t *pud,
>  		ret = arm_smmu_alloc_init_pte(smmu, pmd, addr, next, pfn,
>  					      prot, stage);
>  		phys += next - addr;
> +		pfn = __phys_to_pfn(phys);
>  	} while (pmd++, addr = next, addr < end);
> 
>  	return ret;
> --
> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
> hosted by The Linux Foundation
> 
> _______________________________________________
> iommu mailing list
> iommu at lists.linux-foundation.org
> https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] iommu/arm-smmu: fix bug in pmd construction
  2014-09-21  7:56 ` Varun Sethi
@ 2014-09-22  8:48   ` Will Deacon
  0 siblings, 0 replies; 3+ messages in thread
From: Will Deacon @ 2014-09-22  8:48 UTC (permalink / raw)
  To: linux-arm-kernel

On Sun, Sep 21, 2014 at 08:56:28AM +0100, Varun Sethi wrote:
> I have made changes to the arm smmu driver paging support, as a part of
> the huge page support patch. Will is currently reviewing changes made by
> me. I should be able to post my patch in the next couple of weeks.

Yup, but this patch looks like a sensible change for now. I agree that we
can't currently hit the bug, but that code is intended to be usable for use
across multiple PMDs, so I'll apply this.

Will

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-09-22  8:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-19 21:58 [PATCH] iommu/arm-smmu: fix bug in pmd construction Mitchel Humpherys
2014-09-21  7:56 ` Varun Sethi
2014-09-22  8:48   ` Will Deacon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).