]> git.hungrycats.org Git - linux/commit
iommufd/iova_bitmap: Switch iova_bitmap::bitmap to an u8 array
authorJoao Martins <joao.m.martins@oracle.com>
Fri, 2 Feb 2024 13:34:08 +0000 (13:34 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 1 Mar 2024 12:26:35 +0000 (13:26 +0100)
commitc5bc02f60d278637101837c3c295021efeca74d9
tree80e22a04cc8a2d268714e9f43b96506cc472029a
parent8d3a5cbc1e92a0da912578afa44506679339aaf3
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@oracle.com
Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
Tested-by: Avihai Horon <avihaih@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/vfio/iova_bitmap.c