Re: [PATCH 5/5] misc: mlx5ctl: Add umem reg/unreg ioctl

From: Saeed Mahameed
Date: Sun Nov 19 2023 - 04:45:08 EST


On 18 Oct 11:30, Arnd Bergmann wrote:
On Wed, Oct 18, 2023, at 10:19, Saeed Mahameed wrote:
From: Saeed Mahameed <saeedm@xxxxxxxxxx>


To do so this patch introduces two ioctls:

MLX5CTL_IOCTL_UMEM_REG(va_address, size):
- calculate page fragments from the user provided virtual address
- pin the pages, and allocate a sg list
- dma map the sg list
- create a UMEM device object that points to the dma addresses
- add a driver umem object to an xarray data base for bookkeeping
- return UMEM ID to user so it can be used in subsequent rpcs

MLX5CTL_IOCTL_UMEM_UNREG(umem_id):
- user provides a pre allocated umem ID
- unwinds the above



[...]

+
+ umem_id = mlx5ctl_umem_reg(mfd->umem_db, (unsigned
long)umem_reg.addr, umem_reg.len);

umem_reg.addr seems to be a user space address, so I would
suggest consistently passing it as a 'void __user *' instead
of casting to (unsigned long) here. You can use u64_to_user_ptr()
to handle the pointer conversion correctly across all
architectures that way, and get better type checking.


Hi Arnd,
I handled all of your comments in V2 except this one, since here we use
the user address for arithmetic calculations only, so it is easier to
convert it to (unsigned long) early on ..