Re: [PATCH 1/5] iommu/io-pgtable-arm: Avoid dereferencing bogus PTEs
Hi Robin, Thank you for the patch. On Friday 04 December 2015 17:52:58 Robin Murphy wrote: > In the case of corrupted page tables, or when an invalid size is given, > __arm_lpae_unmap() may recurse beyond the maximum number of levels. > Unfortunately the detection of this error condition only happens *after* > calculating a nonsense offset from something which might not be a valid > table pointer and dereferencing that to see if it is a valid PTE. > > Make things a little more robust by checking the level is valid before > doing anything which depends on it being so. > > Signed-off-by: Robin Murphy This looks good to me. Reviewed-by: Laurent Pinchart I'm curious though, have you seen this error in practice ? > --- > drivers/iommu/io-pgtable-arm.c | 8 +--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c > index 7df9777..366a354 100644 > --- a/drivers/iommu/io-pgtable-arm.c > +++ b/drivers/iommu/io-pgtable-arm.c > @@ -486,11 +486,13 @@ static int __arm_lpae_unmap(struct arm_lpae_io_pgtable > *data, void *cookie = data->iop.cookie; > size_t blk_size = ARM_LPAE_BLOCK_SIZE(lvl, data); > > + /* Something went horribly wrong and we ran out of page table */ > + if (WARN_ON(lvl == ARM_LPAE_MAX_LEVELS)) > + return 0; > + > ptep += ARM_LPAE_LVL_IDX(iova, lvl, data); > pte = *ptep; > - > - /* Something went horribly wrong and we ran out of page table */ > - if (WARN_ON(!pte || (lvl == ARM_LPAE_MAX_LEVELS))) > + if (WARN_ON(!pte)) > return 0; > > /* If the size matches this level, we're in the right place */ -- Regards, Laurent Pinchart ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH 4/5] iommu/io-pgtable: Make io_pgtable_ops_to_pgtable() macro common
Hi Robin, Thank you for the patch. On Friday 04 December 2015 17:53:01 Robin Murphy wrote: > There is no need to keep a useful accessor for a public structure hidden > away in a private implementation. Move it out alongside the structure > definition so that other implementations may reuse it. > > Signed-off-by: Robin Murphy Acked-by: Laurent Pinchart > --- > drivers/iommu/io-pgtable-arm.c | 3 --- > drivers/iommu/io-pgtable.h | 2 ++ > 2 files changed, 2 insertions(+), 3 deletions(-) > > diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c > index 9088d27..1619681 100644 > --- a/drivers/iommu/io-pgtable-arm.c > +++ b/drivers/iommu/io-pgtable-arm.c > @@ -38,9 +38,6 @@ > #define io_pgtable_to_data(x) > \ > container_of((x), struct arm_lpae_io_pgtable, iop) > > -#define io_pgtable_ops_to_pgtable(x) \ > - container_of((x), struct io_pgtable, ops) > - > #define io_pgtable_ops_to_data(x)\ > io_pgtable_to_data(io_pgtable_ops_to_pgtable(x)) > > diff --git a/drivers/iommu/io-pgtable.h b/drivers/iommu/io-pgtable.h > index 2e18469..36673c8 100644 > --- a/drivers/iommu/io-pgtable.h > +++ b/drivers/iommu/io-pgtable.h > @@ -131,6 +131,8 @@ struct io_pgtable { > struct io_pgtable_ops ops; > }; > > +#define io_pgtable_ops_to_pgtable(x) container_of((x), struct io_pgtable, > ops) + > /** > * struct io_pgtable_init_fns - Alloc/free a set of page tables for a > * particular format. -- Regards, Laurent Pinchart ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Using Contig alloc finction
Hello Everyone, I need a around 2GB of physically contiguous memory in Linux. I am using vanilla kernel 4.3 in Fedroa22. I am aware about the function alloc_contig_range and that function should be used through DMA. In DMA what is the exact API to be used and I have enabled CONFIG_CMA and CONFIG_CMA_DMA . In kernel coomand line parameters what is the exact stuff to be given. The documentation is not proper for the kernel parameters in the documentation provided in the source code. Is there any other way to allocate large chunk of memory that is contiguous. Thanking You, Kumar. ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu