diff mbox series

[1/2] vfio iommu: Use shift operation for 64-bit integer division

Message ID 1591123357-18297-1-git-send-email-kwankhede@nvidia.com (mailing list archive)
State New, archived
Headers show
Series [1/2] vfio iommu: Use shift operation for 64-bit integer division | expand

Commit Message

Kirti Wankhede June 2, 2020, 6:42 p.m. UTC
Fixes compilation error with ARCH=i386.

Error fixed by this commit:
ld: drivers/vfio/vfio_iommu_type1.o: in function `vfio_dma_populate_bitmap':
>> vfio_iommu_type1.c:(.text+0x666): undefined reference to `__udivdi3'

Fixes: d6a4c185660c (vfio iommu: Implementation of ioctl for dirty pages tracking)

Signed-off-by: Kirti Wankhede <kwankhede@nvidia.com>
Reported-by: kbuild test robot <lkp@intel.com>
---
 drivers/vfio/vfio_iommu_type1.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Alex Williamson June 2, 2020, 7:54 p.m. UTC | #1
On Wed, 3 Jun 2020 00:12:36 +0530
Kirti Wankhede <kwankhede@nvidia.com> wrote:

> Fixes compilation error with ARCH=i386.
> 
> Error fixed by this commit:
> ld: drivers/vfio/vfio_iommu_type1.o: in function `vfio_dma_populate_bitmap':
> >> vfio_iommu_type1.c:(.text+0x666): undefined reference to `__udivdi3'  
> 
> Fixes: d6a4c185660c (vfio iommu: Implementation of ioctl for dirty pages tracking)
> 
> Signed-off-by: Kirti Wankhede <kwankhede@nvidia.com>
> Reported-by: kbuild test robot <lkp@intel.com>
> ---
>  drivers/vfio/vfio_iommu_type1.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
> index 97a29bc04d5d..9d9c8709a24c 100644
> --- a/drivers/vfio/vfio_iommu_type1.c
> +++ b/drivers/vfio/vfio_iommu_type1.c
> @@ -227,11 +227,12 @@ static void vfio_dma_bitmap_free(struct vfio_dma *dma)
>  static void vfio_dma_populate_bitmap(struct vfio_dma *dma, size_t pgsize)
>  {
>  	struct rb_node *p;
> +	unsigned long pgshift = __ffs(pgsize);
>  
>  	for (p = rb_first(&dma->pfn_list); p; p = rb_next(p)) {
>  		struct vfio_pfn *vpfn = rb_entry(p, struct vfio_pfn, node);
>  
> -		bitmap_set(dma->bitmap, (vpfn->iova - dma->iova) / pgsize, 1);
> +		bitmap_set(dma->bitmap, (vpfn->iova - dma->iova) >> pgshift, 1);
>  	}
>  }
>  

Applied and pushed both to the vfio next branch.  Thanks!

Alex
diff mbox series

Patch

diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
index 97a29bc04d5d..9d9c8709a24c 100644
--- a/drivers/vfio/vfio_iommu_type1.c
+++ b/drivers/vfio/vfio_iommu_type1.c
@@ -227,11 +227,12 @@  static void vfio_dma_bitmap_free(struct vfio_dma *dma)
 static void vfio_dma_populate_bitmap(struct vfio_dma *dma, size_t pgsize)
 {
 	struct rb_node *p;
+	unsigned long pgshift = __ffs(pgsize);
 
 	for (p = rb_first(&dma->pfn_list); p; p = rb_next(p)) {
 		struct vfio_pfn *vpfn = rb_entry(p, struct vfio_pfn, node);
 
-		bitmap_set(dma->bitmap, (vpfn->iova - dma->iova) / pgsize, 1);
+		bitmap_set(dma->bitmap, (vpfn->iova - dma->iova) >> pgshift, 1);
 	}
 }