Skip to content

Commit 46e0505

Browse files
committed
iommufd/selftest: Fix iommufd_test_dirty() to handle <u8 bitmaps
JIRA: https://issues.redhat.com/browse/RHEL-40162 Upstream Status: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git commit 9560393 Author: Joao Martins <joao.m.martins@oracle.com> Date: Thu Jun 27 12:00:56 2024 +0100 iommufd/selftest: Fix iommufd_test_dirty() to handle <u8 bitmaps The calculation returns 0 if it sets less than the number of bits per byte. For calculating memory allocation from bits, lets round it up to one byte. Link: https://lore.kernel.org/r/20240627110105.62325-3-joao.m.martins@oracle.com Reported-by: Matt Ochs <mochs@nvidia.com> Fixes: a9af47e ("iommufd/selftest: Test IOMMU_HWPT_GET_DIRTY_BITMAP") Signed-off-by: Joao Martins <joao.m.martins@oracle.com> Reviewed-by: Kevin Tian <kevin.tian@intel.com> Tested-by: Matt Ochs <mochs@nvidia.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> (cherry picked from commit 9560393) Signed-off-by: Jerry Snitselaar <jsnitsel@redhat.com>
1 parent 04734de commit 46e0505

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/iommu/iommufd/selftest.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1334,7 +1334,7 @@ static int iommufd_test_dirty(struct iommufd_ucmd *ucmd, unsigned int mockpt_id,
13341334
}
13351335

13361336
max = length / page_size;
1337-
bitmap_size = max / BITS_PER_BYTE;
1337+
bitmap_size = DIV_ROUND_UP(max, BITS_PER_BYTE);
13381338

13391339
tmp = kvzalloc(bitmap_size, GFP_KERNEL_ACCOUNT);
13401340
if (!tmp) {

0 commit comments

Comments
 (0)