Skip to content

Commit ce06a70

Browse files
yishaihAlex Williamson
authored andcommitted
vfio/mlx5: Fix range size calculation upon tracker creation
Fix range size calculation to include the last byte of each range. In addition, log round up the length of the total ranges to be stricter. Fixes: c1d050b ("vfio/mlx5: Create and destroy page tracker object") Signed-off-by: Yishai Hadas <yishaih@nvidia.com> Link: https://lore.kernel.org/r/20230208152234.32370-1-yishaih@nvidia.com Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
1 parent b0d2d56 commit ce06a70

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

  • drivers/vfio/pci/mlx5

drivers/vfio/pci/mlx5/cmd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,7 @@ static int mlx5vf_create_tracker(struct mlx5_core_dev *mdev,
830830
node = interval_tree_iter_first(ranges, 0, ULONG_MAX);
831831
for (i = 0; i < num_ranges; i++) {
832832
void *addr_range_i_base = range_list_ptr + record_size * i;
833-
unsigned long length = node->last - node->start;
833+
unsigned long length = node->last - node->start + 1;
834834

835835
MLX5_SET64(page_track_range, addr_range_i_base, start_address,
836836
node->start);
@@ -840,7 +840,7 @@ static int mlx5vf_create_tracker(struct mlx5_core_dev *mdev,
840840
}
841841

842842
WARN_ON(node);
843-
log_addr_space_size = ilog2(total_ranges_len);
843+
log_addr_space_size = ilog2(roundup_pow_of_two(total_ranges_len));
844844
if (log_addr_space_size <
845845
(MLX5_CAP_ADV_VIRTUALIZATION(mdev, pg_track_log_min_addr_space)) ||
846846
log_addr_space_size >

0 commit comments

Comments
 (0)