lkml.org 
[lkml]   [2020]   [Oct]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.8 440/633] vfio/type1: fix dirty bitmap calculation in vfio_dma_rw
    Date
    From: Yan Zhao <yan.y.zhao@intel.com>

    [ Upstream commit 2c5af98592f65517170c7bcc714566590d3f7397 ]

    The count of dirtied pages is not only determined by count of copied
    pages, but also by the start offset.

    e.g. if offset = PAGE_SIZE - 1, and *copied=2, the dirty pages count
    is 2, instead of 1 or 0.

    Fixes: d6a4c185660c ("vfio iommu: Implementation of ioctl for dirty pages tracking")
    Signed-off-by: Yan Zhao <yan.y.zhao@intel.com>
    Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    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 f48f0db908a46..eb7bb14e4f62a 100644
    --- a/drivers/vfio/vfio_iommu_type1.c
    +++ b/drivers/vfio/vfio_iommu_type1.c
    @@ -2899,7 +2899,8 @@ static int vfio_iommu_type1_dma_rw_chunk(struct vfio_iommu *iommu,
    * size
    */
    bitmap_set(dma->bitmap, offset >> pgshift,
    - *copied >> pgshift);
    + ((offset + *copied - 1) >> pgshift) -
    + (offset >> pgshift) + 1);
    }
    } else
    *copied = copy_from_user(data, (void __user *)vaddr,
    --
    2.25.1


    \
     
     \ /
      Last update: 2020-10-27 18:02    [W:2.624 / U:0.072 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site