Message ID | 1381497887-14586-2-git-send-email-a.motakis@virtualopensystems.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Fri, Oct 11, 2013 at 02:24:47PM +0100, Antonios Motakis wrote: > The return value of arm_smmu_iova_to_phys is directly passed to the > user of the IOMMU API via iommu_iova_to_phys; however the ARM SMMU > driver returns -EINVAL on error, which is not consistent with the > rest of the drivers implementing the IOMMU API. VFIO also relies on > the call returning NULL when a page has not been mapped already. > > Signed-off-by: Antonios Motakis <a.motakis@virtualopensystems.com> > --- > drivers/iommu/arm-smmu.c | 5 +---- > 1 file changed, 1 insertion(+), 4 deletions(-) > > diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c > index 8b71332..fe81b20 100644 > --- a/drivers/iommu/arm-smmu.c > +++ b/drivers/iommu/arm-smmu.c > @@ -1480,10 +1480,7 @@ static phys_addr_t arm_smmu_iova_to_phys(struct iommu_domain *domain, > > err_unlock: > spin_unlock(&smmu_domain->lock); > - dev_warn(smmu->dev, > - "invalid (corrupt?) page tables detected for iova 0x%llx\n", > - (unsigned long long)iova); > - return -EINVAL; > + return NULL; Why are you removing the warning message? Will
On Mon, Oct 14, 2013 at 2:48 PM, Will Deacon <will.deacon@arm.com> wrote: > On Fri, Oct 11, 2013 at 02:24:47PM +0100, Antonios Motakis wrote: >> The return value of arm_smmu_iova_to_phys is directly passed to the >> user of the IOMMU API via iommu_iova_to_phys; however the ARM SMMU >> driver returns -EINVAL on error, which is not consistent with the >> rest of the drivers implementing the IOMMU API. VFIO also relies on >> the call returning NULL when a page has not been mapped already. >> >> Signed-off-by: Antonios Motakis <a.motakis@virtualopensystems.com> >> --- >> drivers/iommu/arm-smmu.c | 5 +---- >> 1 file changed, 1 insertion(+), 4 deletions(-) >> >> diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c >> index 8b71332..fe81b20 100644 >> --- a/drivers/iommu/arm-smmu.c >> +++ b/drivers/iommu/arm-smmu.c >> @@ -1480,10 +1480,7 @@ static phys_addr_t arm_smmu_iova_to_phys(struct iommu_domain *domain, >> >> err_unlock: >> spin_unlock(&smmu_domain->lock); >> - dev_warn(smmu->dev, >> - "invalid (corrupt?) page tables detected for iova 0x%llx\n", >> - (unsigned long long)iova); >> - return -EINVAL; >> + return NULL; > > Why are you removing the warning message? VFIO will exercise this code path every time when mapping DMA memory. This is normal and VFIO *expects* the function to fail - it is only if the function succeeds that VFIO needs to back down from the DMA mapping and fail. This means that there would be a warning every time a VFIO user maps some memory for DMA use, even though nothing went wrong. > > Will
On Mon, Oct 14, 2013 at 04:17:51PM +0100, Antonios Motakis wrote: > On Mon, Oct 14, 2013 at 2:48 PM, Will Deacon <will.deacon@arm.com> wrote: > > On Fri, Oct 11, 2013 at 02:24:47PM +0100, Antonios Motakis wrote: > >> The return value of arm_smmu_iova_to_phys is directly passed to the > >> user of the IOMMU API via iommu_iova_to_phys; however the ARM SMMU > >> driver returns -EINVAL on error, which is not consistent with the > >> rest of the drivers implementing the IOMMU API. VFIO also relies on > >> the call returning NULL when a page has not been mapped already. > >> > >> Signed-off-by: Antonios Motakis <a.motakis@virtualopensystems.com> > >> --- > >> drivers/iommu/arm-smmu.c | 5 +---- > >> 1 file changed, 1 insertion(+), 4 deletions(-) > >> > >> diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c > >> index 8b71332..fe81b20 100644 > >> --- a/drivers/iommu/arm-smmu.c > >> +++ b/drivers/iommu/arm-smmu.c > >> @@ -1480,10 +1480,7 @@ static phys_addr_t arm_smmu_iova_to_phys(struct iommu_domain *domain, > >> > >> err_unlock: > >> spin_unlock(&smmu_domain->lock); > >> - dev_warn(smmu->dev, > >> - "invalid (corrupt?) page tables detected for iova 0x%llx\n", > >> - (unsigned long long)iova); > >> - return -EINVAL; > >> + return NULL; > > > > Why are you removing the warning message? > > VFIO will exercise this code path every time when mapping DMA memory. > This is normal and VFIO *expects* the function to fail - it is only if > the function succeeds that VFIO needs to back down from the DMA > mapping and fail. > > This means that there would be a warning every time a VFIO user maps > some memory for DMA use, even though nothing went wrong. Ok, in which case it might be worth reworking arm_smmu_iova_to_phys to treat {pgd,pud,pmd,pte}_none different from {pgd,pud,pmd,pte}_bad. Will
On Mon, Oct 14, 2013 at 06:09:48PM +0100, Will Deacon wrote: > On Mon, Oct 14, 2013 at 04:17:51PM +0100, Antonios Motakis wrote: > > On Mon, Oct 14, 2013 at 2:48 PM, Will Deacon <will.deacon@arm.com> wrote: > > > On Fri, Oct 11, 2013 at 02:24:47PM +0100, Antonios Motakis wrote: > > VFIO will exercise this code path every time when mapping DMA memory. > > This is normal and VFIO *expects* the function to fail - it is only if > > the function succeeds that VFIO needs to back down from the DMA > > mapping and fail. > > > > This means that there would be a warning every time a VFIO user maps > > some memory for DMA use, even though nothing went wrong. > > Ok, in which case it might be worth reworking arm_smmu_iova_to_phys to treat > {pgd,pud,pmd,pte}_none different from {pgd,pud,pmd,pte}_bad. Just an FYI, but I realised the page table locking is broken in my driver (hold a spinlock over a non-atomic allocation; looks like the exynos guys do this too), so I've just reworked a bunch of iova_to_phys and incorporated this change as part of that. Cheers, Will
diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c index 8b71332..fe81b20 100644 --- a/drivers/iommu/arm-smmu.c +++ b/drivers/iommu/arm-smmu.c @@ -1480,10 +1480,7 @@ static phys_addr_t arm_smmu_iova_to_phys(struct iommu_domain *domain, err_unlock: spin_unlock(&smmu_domain->lock); - dev_warn(smmu->dev, - "invalid (corrupt?) page tables detected for iova 0x%llx\n", - (unsigned long long)iova); - return -EINVAL; + return NULL; } static int arm_smmu_domain_has_cap(struct iommu_domain *domain,
The return value of arm_smmu_iova_to_phys is directly passed to the user of the IOMMU API via iommu_iova_to_phys; however the ARM SMMU driver returns -EINVAL on error, which is not consistent with the rest of the drivers implementing the IOMMU API. VFIO also relies on the call returning NULL when a page has not been mapped already. Signed-off-by: Antonios Motakis <a.motakis@virtualopensystems.com> --- drivers/iommu/arm-smmu.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)