diff options
author | 2024-06-27 12:00:56 +0100 | |
---|---|---|
committer | 2024-06-28 13:12:22 -0300 | |
commit | 9560393b830b415b2151b3dd8e065257cccbffa7 (patch) | |
tree | 875e1ec707b0f2f0d649d8823276d395f77a80dd | |
parent | iommufd/selftest: Fix dirty bitmap tests with u8 bitmaps (diff) | |
download | wireguard-linux-9560393b830b415b2151b3dd8e065257cccbffa7.tar.xz wireguard-linux-9560393b830b415b2151b3dd8e065257cccbffa7.zip |
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: a9af47e382a4 ("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>
-rw-r--r-- | drivers/iommu/iommufd/selftest.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/iommu/iommufd/selftest.c b/drivers/iommu/iommufd/selftest.c index 7a2199470f31..654ed3339095 100644 --- a/drivers/iommu/iommufd/selftest.c +++ b/drivers/iommu/iommufd/selftest.c @@ -1334,7 +1334,7 @@ static int iommufd_test_dirty(struct iommufd_ucmd *ucmd, unsigned int mockpt_id, } max = length / page_size; - bitmap_size = max / BITS_PER_BYTE; + bitmap_size = DIV_ROUND_UP(max, BITS_PER_BYTE); tmp = kvzalloc(bitmap_size, GFP_KERNEL_ACCOUNT); if (!tmp) { |