Patch "iommufd/iova_bitmap: Switch iova_bitmap::bitmap to an u8 array" 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

    iommufd/iova_bitmap: Switch iova_bitmap::bitmap to an u8 array

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:
     iommufd-iova_bitmap-switch-iova_bitmap-bitmap-to-an-.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 6238cb20d4be81e33b7a303dedff706056c2a033
Author: Joao Martins <joao.m.martins@xxxxxxxxxx>
Date:   Fri Feb 2 13:34:08 2024 +0000

    iommufd/iova_bitmap: Switch iova_bitmap::bitmap to an u8 array
    
    [ Upstream commit d18411ec305728c6371806c4fb09be07016aad0b ]
    
    iova_bitmap_mapped_length() don't deal correctly with the small bitmaps
    (< 2M bitmaps) when the starting address isn't u64 aligned, leading to
    skipping a tiny part of the IOVA range. This is materialized as not
    marking data dirty that should otherwise have been.
    
    Fix that by using a u8 * in the internal state of IOVA bitmap. Most of the
    data structures use the type of the bitmap to adjust its indexes, thus
    changing the type of the bitmap decreases the granularity of the bitmap
    indexes.
    
    Fixes: b058ea3ab5af ("vfio/iova_bitmap: refactor iova_bitmap_set() to better handle page boundaries")
    Link: https://lore.kernel.org/r/20240202133415.23819-3-joao.m.martins@xxxxxxxxxx
    Signed-off-by: Joao Martins <joao.m.martins@xxxxxxxxxx>
    Tested-by: Avihai Horon <avihaih@xxxxxxxxxx>
    Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/iommu/iommufd/iova_bitmap.c b/drivers/iommu/iommufd/iova_bitmap.c
index a3606b4c22292..9d42ab51a6bb3 100644
--- a/drivers/iommu/iommufd/iova_bitmap.c
+++ b/drivers/iommu/iommufd/iova_bitmap.c
@@ -100,7 +100,7 @@ struct iova_bitmap {
 	struct iova_bitmap_map mapped;
 
 	/* userspace address of the bitmap */
-	u64 __user *bitmap;
+	u8 __user *bitmap;
 
 	/* u64 index that @mapped points to */
 	unsigned long mapped_base_index;
@@ -162,7 +162,7 @@ static int iova_bitmap_get(struct iova_bitmap *bitmap)
 {
 	struct iova_bitmap_map *mapped = &bitmap->mapped;
 	unsigned long npages;
-	u64 __user *addr;
+	u8 __user *addr;
 	long ret;
 
 	/*
@@ -247,7 +247,7 @@ struct iova_bitmap *iova_bitmap_alloc(unsigned long iova, size_t length,
 
 	mapped = &bitmap->mapped;
 	mapped->pgshift = __ffs(page_size);
-	bitmap->bitmap = data;
+	bitmap->bitmap = (u8 __user *)data;
 	bitmap->mapped_total_index =
 		iova_bitmap_offset_to_index(bitmap, length - 1) + 1;
 	bitmap->iova = iova;
@@ -304,7 +304,7 @@ static unsigned long iova_bitmap_mapped_remaining(struct iova_bitmap *bitmap)
 
 	remaining = bitmap->mapped_total_index - bitmap->mapped_base_index;
 	remaining = min_t(unsigned long, remaining,
-			  bytes / sizeof(*bitmap->bitmap));
+			  DIV_ROUND_UP(bytes, sizeof(*bitmap->bitmap)));
 
 	return remaining;
 }




[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