diff options
author | Yishai Hadas <yishaih@mellanox.com> | 2018-09-20 20:45:19 +0200 |
---|---|---|
committer | Jason Gunthorpe <jgg@mellanox.com> | 2018-09-27 21:01:33 +0200 |
commit | 76dc5a8406bffabf3f466e331a3e9515ddf93954 (patch) | |
tree | 60784970a8ff2d047edf54ab553f1cd2db71ad77 /drivers/infiniband/hw/mlx5/main.c | |
parent | IB/mlx5: Expose RAW QP device handles to user space (diff) | |
download | linux-76dc5a8406bffabf3f466e331a3e9515ddf93954.tar.xz linux-76dc5a8406bffabf3f466e331a3e9515ddf93954.zip |
IB/mlx5: Manage device uid for DEVX white list commands
Manage device uid for DEVX white list commands. The created device uid
will be used on white list commands if the user didn't supply its own uid.
This will enable the firmware to filter out non privileged functionality
as of the recognition of the uid.
Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Diffstat (limited to 'drivers/infiniband/hw/mlx5/main.c')
-rw-r--r-- | drivers/infiniband/hw/mlx5/main.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c index 597cd3c171c9..10e59923e95b 100644 --- a/drivers/infiniband/hw/mlx5/main.c +++ b/drivers/infiniband/hw/mlx5/main.c @@ -1765,9 +1765,10 @@ static struct ib_ucontext *mlx5_ib_alloc_ucontext(struct ib_device *ibdev, goto out_uars; } - err = mlx5_ib_devx_create(dev, context); - if (err) + err = mlx5_ib_devx_create(dev); + if (err < 0) goto out_uars; + context->devx_uid = err; } err = mlx5_ib_alloc_transport_domain(dev, &context->tdn, @@ -1870,7 +1871,7 @@ out_mdev: mlx5_ib_dealloc_transport_domain(dev, context->tdn, context->devx_uid); out_devx: if (req.flags & MLX5_IB_ALLOC_UCTX_DEVX) - mlx5_ib_devx_destroy(dev, context); + mlx5_ib_devx_destroy(dev, context->devx_uid); out_uars: deallocate_uars(dev, context); @@ -1904,7 +1905,7 @@ static int mlx5_ib_dealloc_ucontext(struct ib_ucontext *ibcontext) mlx5_ib_dealloc_transport_domain(dev, context->tdn, context->devx_uid); if (context->devx_uid) - mlx5_ib_devx_destroy(dev, context); + mlx5_ib_devx_destroy(dev, context->devx_uid); deallocate_uars(dev, context); kfree(bfregi->sys_pages); @@ -6189,6 +6190,8 @@ void __mlx5_ib_remove(struct mlx5_ib_dev *dev, profile->stage[stage].cleanup(dev); } + if (dev->devx_whitelist_uid) + mlx5_ib_devx_destroy(dev, dev->devx_whitelist_uid); ib_dealloc_device((struct ib_device *)dev); } @@ -6197,6 +6200,7 @@ void *__mlx5_ib_add(struct mlx5_ib_dev *dev, { int err; int i; + int uid; for (i = 0; i < MLX5_IB_STAGE_MAX; i++) { if (profile->stage[i].init) { @@ -6206,6 +6210,10 @@ void *__mlx5_ib_add(struct mlx5_ib_dev *dev, } } + uid = mlx5_ib_devx_create(dev); + if (uid > 0) + dev->devx_whitelist_uid = uid; + dev->profile = profile; dev->ib_active = true; |