kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] vfio iommu: Use shift operation for 64-bit integer division
@ 2020-06-02 18:42 Kirti Wankhede
  2020-06-02 18:42 ` [PATCH 2/2] vfio iommu: typecast corrections Kirti Wankhede
  2020-06-02 19:54 ` [PATCH 1/2] vfio iommu: Use shift operation for 64-bit integer division Alex Williamson
  0 siblings, 2 replies; 3+ messages in thread
From: Kirti Wankhede @ 2020-06-02 18:42 UTC (permalink / raw)
  To: alex.williamson, cjia
  Cc: kevin.tian, ziye.yang, changpeng.liu, yi.l.liu, mlevitsk,
	eskultet, cohuck, dgilbert, jonathan.davies, eauger, aik, pasic,
	felipe, Zhengxiao.zx, shuangtai.tst, Ken.Xue, zhi.a.wang,
	yan.y.zhao, qemu-devel, kvm, Kirti Wankhede

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);
 	}
 }
 
-- 
2.7.0


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

* [PATCH 2/2] vfio iommu: typecast corrections
  2020-06-02 18:42 [PATCH 1/2] vfio iommu: Use shift operation for 64-bit integer division Kirti Wankhede
@ 2020-06-02 18:42 ` Kirti Wankhede
  2020-06-02 19:54 ` [PATCH 1/2] vfio iommu: Use shift operation for 64-bit integer division Alex Williamson
  1 sibling, 0 replies; 3+ messages in thread
From: Kirti Wankhede @ 2020-06-02 18:42 UTC (permalink / raw)
  To: alex.williamson, cjia
  Cc: kevin.tian, ziye.yang, changpeng.liu, yi.l.liu, mlevitsk,
	eskultet, cohuck, dgilbert, jonathan.davies, eauger, aik, pasic,
	felipe, Zhengxiao.zx, shuangtai.tst, Ken.Xue, zhi.a.wang,
	yan.y.zhao, qemu-devel, kvm, Kirti Wankhede

Fixes sparse warnings by adding '__user' in typecast for
copy_[from,to]_user()

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 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
index 9d9c8709a24c..5e556ac9102a 100644
--- a/drivers/vfio/vfio_iommu_type1.c
+++ b/drivers/vfio/vfio_iommu_type1.c
@@ -998,14 +998,14 @@ static int update_user_bitmap(u64 __user *bitmap, struct vfio_iommu *iommu,
 				  nbits + shift);
 
 		if (copy_from_user(&leftover,
-				   (const void *)(bitmap + copy_offset),
+				   (void __user *)(bitmap + copy_offset),
 				   sizeof(leftover)))
 			return -EFAULT;
 
 		bitmap_or(dma->bitmap, dma->bitmap, &leftover, shift);
 	}
 
-	if (copy_to_user((void *)(bitmap + copy_offset), dma->bitmap,
+	if (copy_to_user((void __user *)(bitmap + copy_offset), dma->bitmap,
 			 DIRTY_BITMAP_BYTES(nbits + shift)))
 		return -EFAULT;
 
-- 
2.7.0


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

* Re: [PATCH 1/2] vfio iommu: Use shift operation for 64-bit integer division
  2020-06-02 18:42 [PATCH 1/2] vfio iommu: Use shift operation for 64-bit integer division Kirti Wankhede
  2020-06-02 18:42 ` [PATCH 2/2] vfio iommu: typecast corrections Kirti Wankhede
@ 2020-06-02 19:54 ` Alex Williamson
  1 sibling, 0 replies; 3+ messages in thread
From: Alex Williamson @ 2020-06-02 19:54 UTC (permalink / raw)
  To: Kirti Wankhede
  Cc: cjia, kevin.tian, ziye.yang, changpeng.liu, yi.l.liu, mlevitsk,
	eskultet, cohuck, dgilbert, jonathan.davies, eauger, aik, pasic,
	felipe, Zhengxiao.zx, shuangtai.tst, Ken.Xue, zhi.a.wang,
	yan.y.zhao, qemu-devel, kvm

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


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

end of thread, other threads:[~2020-06-02 19:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-02 18:42 [PATCH 1/2] vfio iommu: Use shift operation for 64-bit integer division Kirti Wankhede
2020-06-02 18:42 ` [PATCH 2/2] vfio iommu: typecast corrections Kirti Wankhede
2020-06-02 19:54 ` [PATCH 1/2] vfio iommu: Use shift operation for 64-bit integer division Alex Williamson

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).