RDMA/mlx4: Do not map the core_clock page to user space unless enabled
authorShay Drory <shayd@nvidia.com>
Thu, 3 Jun 2021 13:19:39 +0000 (16:19 +0300)
committerJason Gunthorpe <jgg@nvidia.com>
Thu, 3 Jun 2021 17:19:53 +0000 (14:19 -0300)
commit404e5a12691fe797486475fe28cc0b80cb8bef2c
tree780766b010ff747f2a6c1ef3ef6e52edf3f53b75
parenta0ffb4c12f7fa89163e228e6f27df09b46631db1
RDMA/mlx4: Do not map the core_clock page to user space unless enabled

Currently when mlx4 maps the hca_core_clock page to the user space there
are read-modifiable registers, one of which is semaphore, on this page as
well as the clock counter. If user reads the wrong offset, it can modify
the semaphore and hang the device.

Do not map the hca_core_clock page to the user space unless the device has
been put in a backwards compatibility mode to support this feature.

After this patch, mlx4 core_clock won't be mapped to user space on the
majority of existing devices and the uverbs device time feature in
ibv_query_rt_values_ex() will be disabled.

Fixes: 52033cfb5aab ("IB/mlx4: Add mmap call to map the hardware clock")
Link: https://lore.kernel.org/r/9632304e0d6790af84b3b706d8c18732bc0d5e27.1622726305.git.leonro@nvidia.com
Signed-off-by: Shay Drory <shayd@nvidia.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/infiniband/hw/mlx4/main.c
drivers/net/ethernet/mellanox/mlx4/fw.c
drivers/net/ethernet/mellanox/mlx4/fw.h
drivers/net/ethernet/mellanox/mlx4/main.c
include/linux/mlx4/device.h