* Re: [PATCH v1 1/2] vdpa/mlx5: Support creating resources with uid == 0
[not found] <20210531160404.31368-1-elic@nvidia.com>
@ 2021-05-31 22:17 ` Michael S. Tsirkin
2021-06-01 1:54 ` Jason Wang
1 sibling, 0 replies; 2+ messages in thread
From: Michael S. Tsirkin @ 2021-05-31 22:17 UTC (permalink / raw)
To: Eli Cohen; +Cc: linux-kernel, virtualization
On Mon, May 31, 2021 at 07:04:04PM +0300, Eli Cohen wrote:
> Currently all resources must be created with uid != 0 which is essential
> when userspace processes are allocating virtquueue resources. Since this
> is a kernel implementation, it is perfectly legal to open resources with
> uid == 0.
>
> In case firmware supports, avoid allocating user context.
>
> Signed-off-by: Eli Cohen <elic@nvidia.com>
> ---
> v0 --> v1:
> Fix typo and modify phrasing
threading's broken now
> drivers/vdpa/mlx5/core/resources.c | 6 ++++++
> include/linux/mlx5/mlx5_ifc.h | 4 +++-
> 2 files changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/vdpa/mlx5/core/resources.c b/drivers/vdpa/mlx5/core/resources.c
> index 6521cbd0f5c2..836ab9ef0fa6 100644
> --- a/drivers/vdpa/mlx5/core/resources.c
> +++ b/drivers/vdpa/mlx5/core/resources.c
> @@ -54,6 +54,9 @@ static int create_uctx(struct mlx5_vdpa_dev *mvdev, u16 *uid)
> void *in;
> int err;
>
> + if (MLX5_CAP_GEN(mvdev->mdev, umem_uid_0))
> + return 0;
> +
> /* 0 means not supported */
> if (!MLX5_CAP_GEN(mvdev->mdev, log_max_uctx))
> return -EOPNOTSUPP;
> @@ -79,6 +82,9 @@ static void destroy_uctx(struct mlx5_vdpa_dev *mvdev, u32 uid)
> u32 out[MLX5_ST_SZ_DW(destroy_uctx_out)] = {};
> u32 in[MLX5_ST_SZ_DW(destroy_uctx_in)] = {};
>
> + if (!uid)
> + return;
> +
> MLX5_SET(destroy_uctx_in, in, opcode, MLX5_CMD_OP_DESTROY_UCTX);
> MLX5_SET(destroy_uctx_in, in, uid, uid);
>
> diff --git a/include/linux/mlx5/mlx5_ifc.h b/include/linux/mlx5/mlx5_ifc.h
> index 9c68b2da14c6..606d2aeacad4 100644
> --- a/include/linux/mlx5/mlx5_ifc.h
> +++ b/include/linux/mlx5/mlx5_ifc.h
> @@ -1487,7 +1487,9 @@ struct mlx5_ifc_cmd_hca_cap_bits {
> u8 uar_4k[0x1];
> u8 reserved_at_241[0x9];
> u8 uar_sz[0x6];
> - u8 reserved_at_250[0x8];
> + u8 reserved_at_248[0x2];
> + u8 umem_uid_0[0x1];
> + u8 reserved_at_250[0x5];
> u8 log_pg_sz[0x8];
>
> u8 bf[0x1];
> --
> 2.31.1
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v1 1/2] vdpa/mlx5: Support creating resources with uid == 0
[not found] <20210531160404.31368-1-elic@nvidia.com>
2021-05-31 22:17 ` [PATCH v1 1/2] vdpa/mlx5: Support creating resources with uid == 0 Michael S. Tsirkin
@ 2021-06-01 1:54 ` Jason Wang
1 sibling, 0 replies; 2+ messages in thread
From: Jason Wang @ 2021-06-01 1:54 UTC (permalink / raw)
To: Eli Cohen, mst, virtualization, linux-kernel
在 2021/6/1 上午12:04, Eli Cohen 写道:
> Currently all resources must be created with uid != 0 which is essential
> when userspace processes are allocating virtquueue resources. Since this
> is a kernel implementation, it is perfectly legal to open resources with
> uid == 0.
>
> In case firmware supports, avoid allocating user context.
>
> Signed-off-by: Eli Cohen <elic@nvidia.com>
Acked-by: Jason Wang <jasowang@redhat.com>
> ---
> v0 --> v1:
> Fix typo and modify phrasing
>
> drivers/vdpa/mlx5/core/resources.c | 6 ++++++
> include/linux/mlx5/mlx5_ifc.h | 4 +++-
> 2 files changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/vdpa/mlx5/core/resources.c b/drivers/vdpa/mlx5/core/resources.c
> index 6521cbd0f5c2..836ab9ef0fa6 100644
> --- a/drivers/vdpa/mlx5/core/resources.c
> +++ b/drivers/vdpa/mlx5/core/resources.c
> @@ -54,6 +54,9 @@ static int create_uctx(struct mlx5_vdpa_dev *mvdev, u16 *uid)
> void *in;
> int err;
>
> + if (MLX5_CAP_GEN(mvdev->mdev, umem_uid_0))
> + return 0;
> +
> /* 0 means not supported */
> if (!MLX5_CAP_GEN(mvdev->mdev, log_max_uctx))
> return -EOPNOTSUPP;
> @@ -79,6 +82,9 @@ static void destroy_uctx(struct mlx5_vdpa_dev *mvdev, u32 uid)
> u32 out[MLX5_ST_SZ_DW(destroy_uctx_out)] = {};
> u32 in[MLX5_ST_SZ_DW(destroy_uctx_in)] = {};
>
> + if (!uid)
> + return;
> +
> MLX5_SET(destroy_uctx_in, in, opcode, MLX5_CMD_OP_DESTROY_UCTX);
> MLX5_SET(destroy_uctx_in, in, uid, uid);
>
> diff --git a/include/linux/mlx5/mlx5_ifc.h b/include/linux/mlx5/mlx5_ifc.h
> index 9c68b2da14c6..606d2aeacad4 100644
> --- a/include/linux/mlx5/mlx5_ifc.h
> +++ b/include/linux/mlx5/mlx5_ifc.h
> @@ -1487,7 +1487,9 @@ struct mlx5_ifc_cmd_hca_cap_bits {
> u8 uar_4k[0x1];
> u8 reserved_at_241[0x9];
> u8 uar_sz[0x6];
> - u8 reserved_at_250[0x8];
> + u8 reserved_at_248[0x2];
> + u8 umem_uid_0[0x1];
> + u8 reserved_at_250[0x5];
> u8 log_pg_sz[0x8];
>
> u8 bf[0x1];
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-06-01 1:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20210531160404.31368-1-elic@nvidia.com>
2021-05-31 22:17 ` [PATCH v1 1/2] vdpa/mlx5: Support creating resources with uid == 0 Michael S. Tsirkin
2021-06-01 1:54 ` Jason Wang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox