]> www.infradead.org Git - users/dwmw2/linux.git/commit
RDMA/mlx5: Fix handling of IOVA != user_va in ODP paths
authorJason Gunthorpe <jgg@mellanox.com>
Wed, 15 Jan 2020 12:43:37 +0000 (14:43 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 14 Feb 2020 21:52:56 +0000 (16:52 -0500)
commit2a4b19c30a56d22caf8abe718925c11d0ca322df
tree378794858f073abe4cc22e2bf4aa936db6631771
parentc12a6cf735493281fb03fdc5b478759c0636a327
RDMA/mlx5: Fix handling of IOVA != user_va in ODP paths

commit 8ffc32485158528f870b62707077ab494ba31deb upstream.

Till recently it was not possible for userspace to specify a different
IOVA, but with the new ibv_reg_mr_iova() library call this can be done.

To compute the user_va we must compute:
  user_va = (iova - iova_start) + user_va_start

while being cautious of overflow and other math problems.

The iova is not reliably stored in the mmkey when the MR is created. Only
the cached creation path (the common one) set it, so it must also be set
when creating uncached MRs.

Fix the weird use of iova when computing the starting page index in the
MR. In the normal case, when iova == umem.address:
  iova & (~(BIT(page_shift) - 1)) ==
  ALIGN_DOWN(umem.address, odp->page_size) ==
  ib_umem_start(odp)

And when iova is different using it in math with a user_va is wrong.

Finally, do not allow an implicit ODP to be created with a non-zero IOVA
as we have no support for that.

Fixes: 7bdf65d411c1 ("IB/mlx5: Handle page faults")
Signed-off-by: Moni Shoua <monis@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/infiniband/hw/mlx5/mr.c
drivers/infiniband/hw/mlx5/odp.c