Patch "vfio/pds: Fix calculations in pds_vfio_dirty_sync" has been added to the 6.7-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    vfio/pds: Fix calculations in pds_vfio_dirty_sync

to the 6.7-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     vfio-pds-fix-calculations-in-pds_vfio_dirty_sync.patch
and it can be found in the queue-6.7 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit e7c5a3fb71ed8aa6511234af8981ca81bce011e2
Author: Brett Creeley <brett.creeley@xxxxxxx>
Date:   Thu Nov 16 16:12:02 2023 -0800

    vfio/pds: Fix calculations in pds_vfio_dirty_sync
    
    [ Upstream commit 4004497cec3093d7b0087bc70709b45969fa07b6 ]
    
    The incorrect check is being done for comparing the
    iova/length being requested to sync. This can cause
    the dirty sync operation to fail. Fix this by making
    sure the iova offset added to the requested sync
    length doesn't exceed the region_size.
    
    Also, the region_start is assumed to always be at 0.
    This can cause dirty tracking to fail because the
    device/driver bitmap offset always starts at 0,
    however, the region_start/iova may not. Fix this by
    determining the iova offset from region_start to
    determine the bitmap offset.
    
    Fixes: f232836a9152 ("vfio/pds: Add support for dirty page tracking")
    Signed-off-by: Brett Creeley <brett.creeley@xxxxxxx>
    Signed-off-by: Shannon Nelson <shannon.nelson@xxxxxxx>
    Link: https://lore.kernel.org/r/20231117001207.2793-2-brett.creeley@xxxxxxx
    Signed-off-by: Alex Williamson <alex.williamson@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/vfio/pci/pds/dirty.c b/drivers/vfio/pci/pds/dirty.c
index c937aa6f3954..27607d7b9030 100644
--- a/drivers/vfio/pci/pds/dirty.c
+++ b/drivers/vfio/pci/pds/dirty.c
@@ -478,8 +478,7 @@ static int pds_vfio_dirty_sync(struct pds_vfio_pci_device *pds_vfio,
 		pds_vfio->vf_id, iova, length, pds_vfio->dirty.region_page_size,
 		pages, bitmap_size);
 
-	if (!length || ((dirty->region_start + iova + length) >
-			(dirty->region_start + dirty->region_size))) {
+	if (!length || ((iova - dirty->region_start + length) > dirty->region_size)) {
 		dev_err(dev, "Invalid iova 0x%lx and/or length 0x%lx to sync\n",
 			iova, length);
 		return -EINVAL;
@@ -496,7 +495,8 @@ static int pds_vfio_dirty_sync(struct pds_vfio_pci_device *pds_vfio,
 		return -EINVAL;
 	}
 
-	bmp_offset = DIV_ROUND_UP(iova / dirty->region_page_size, sizeof(u64));
+	bmp_offset = DIV_ROUND_UP((iova - dirty->region_start) /
+				  dirty->region_page_size, sizeof(u64));
 
 	dev_dbg(dev,
 		"Syncing dirty bitmap, iova 0x%lx length 0x%lx, bmp_offset %llu bmp_bytes %llu\n",




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux