vfio/type1: handle case where IOMMU does not support PAGE_SIZE size
Current vfio_pgsize_bitmap code hides the supported IOMMU page sizes smaller than PAGE_SIZE. As a result, in case the IOMMU does not support PAGE_SIZE page, the alignment check on map/unmap is done with larger page sizes, if any. This can fail although mapping could be done with pages smaller than PAGE_SIZE. This patch modifies vfio_pgsize_bitmap implementation so that, in case the IOMMU supports page sizes smaller than PAGE_SIZE we pretend PAGE_SIZE is supported and hide sub-PAGE_SIZE sizes. That way the user will be able to map/unmap buffers whose size/ start address is aligned with PAGE_SIZE. Pinning code uses that granularity while iommu driver can use the sub-PAGE_SIZE size to map the buffer. Signed-off-by: Eric Auger <eric.auger@linaro.org> Acked-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
This commit is contained in:
parent
1276ece32c
commit
4644321fd3
1 changed files with 14 additions and 1 deletions
|
@ -403,13 +403,26 @@ static void vfio_remove_dma(struct vfio_iommu *iommu, struct vfio_dma *dma)
|
||||||
static unsigned long vfio_pgsize_bitmap(struct vfio_iommu *iommu)
|
static unsigned long vfio_pgsize_bitmap(struct vfio_iommu *iommu)
|
||||||
{
|
{
|
||||||
struct vfio_domain *domain;
|
struct vfio_domain *domain;
|
||||||
unsigned long bitmap = PAGE_MASK;
|
unsigned long bitmap = ULONG_MAX;
|
||||||
|
|
||||||
mutex_lock(&iommu->lock);
|
mutex_lock(&iommu->lock);
|
||||||
list_for_each_entry(domain, &iommu->domain_list, next)
|
list_for_each_entry(domain, &iommu->domain_list, next)
|
||||||
bitmap &= domain->domain->ops->pgsize_bitmap;
|
bitmap &= domain->domain->ops->pgsize_bitmap;
|
||||||
mutex_unlock(&iommu->lock);
|
mutex_unlock(&iommu->lock);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* In case the IOMMU supports page sizes smaller than PAGE_SIZE
|
||||||
|
* we pretend PAGE_SIZE is supported and hide sub-PAGE_SIZE sizes.
|
||||||
|
* That way the user will be able to map/unmap buffers whose size/
|
||||||
|
* start address is aligned with PAGE_SIZE. Pinning code uses that
|
||||||
|
* granularity while iommu driver can use the sub-PAGE_SIZE size
|
||||||
|
* to map the buffer.
|
||||||
|
*/
|
||||||
|
if (bitmap & ~PAGE_MASK) {
|
||||||
|
bitmap &= PAGE_MASK;
|
||||||
|
bitmap |= PAGE_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
return bitmap;
|
return bitmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue