Re: [PATCH v6 3/6] iommu: Add iommu_copy_struct_from_user_array helper

Binbin Wu
2024-01-08T08:37:45Z

On 11/17/2023 9:07 PM, Yi Liu wrote:
> +
> +/**
> + * iommu_copy_struct_from_user_array - Copy iommu driver specific user space
> + * data from an iommu_user_data_array
> + * @kdst: Pointer to an iommu driver specific user data that is defined in
> + * include/uapi/linux/iommufd.h
> + * @user_array: Pointer to a struct iommu_user_data_array for a user space array
> + * @data_type: The data type of the @kdst. Must match with @user_array->type
> + * @index: Index to offset the location in the array to copy user data from
> + * @min_last: The last memember of the data structure @kdst points in the

s/memember/member/

> + * initial version.
> + * Return 0 for success, otherwise -error.
> + */
> +#define iommu_copy_struct_from_user_array(kdst, user_array, data_type, \
> + index, min_last) \
> + __iommu_copy_struct_from_user_array(kdst, user_array, data_type, \
> + index, sizeof(*kdst), \
> + offsetofend(typeof(*kdst), \
> + min_last))
> +
> /**
> * struct iommu_ops - iommu ops and capabilities
> * @capable: check capability