On 10/13/26 08:32, Huang, Honglei wrote:
> 
> 
> On 10/10/2026 8:50 PM, Dmitry Osipenko wrote:
>> On 10/10/26 10:37, Huang, Honglei wrote:
>>>
>>>
>>> On 10/10/2026 2:53 AM, Dmitry Osipenko wrote:
>>>> 24.09.2026 12:55, Honglei Huang пишет:
>>>>> +int virtio_gpu_userptr_create(struct virtio_gpu_device *vgdev,
>>>>> +                  struct drm_file *file,
>>>>> +                  struct virtio_gpu_object_params *params,
>>>>> +                  struct virtio_gpu_object **bo_ptr)
>>>>> +{
>>>>> +    struct virtio_gpu_object_userptr *userptr;
>>>>> +    struct virtio_gpu_mem_entry *ents = NULL;
>>>>> +    struct sg_table *sgt;
>>>>> +    struct mm_struct *mm;
>>>>> +    unsigned long lock_limit;
>>>>> +    unsigned long start;
>>>>> +    unsigned long end;
>>>>> +    s64 new_pinned;
>>>>> +    unsigned int nents;
>>>>> +    int ret;
>>>>> +
>>>>> +    *bo_ptr = NULL;
>>>>> +
>>>>> +    if (!params->size || !IS_ALIGNED(params->size, PAGE_SIZE) ||
>>>>> +        params->userptr != (unsigned long)params->userptr)
>>>>> +        return -EINVAL;
>>>>> +
>>>>> +    start = params->userptr;
>>>>> +    if (!IS_ALIGNED(start, PAGE_SIZE) ||
>>>>> +        check_add_overflow(start, (unsigned long)params->size, &end))
>>>>> +        return -EINVAL;
>>>>
>>>> There is new vgdev->blob_alignment defining host page size as it may
>>>> differ from guest's page. Will be good to validate both.
>>>>
>>>
>>> Will add blob_alignment check in next version, thanks for the review.
>> Missed that verify_blob() already should be validating the userptr
>> blob_alignment. The patches look good.
>>
>> BTW, previously the extra AMD KFD patches were needed on host kernel,
>> did they land upstream?
> 
> According to KFD maintainer, they want to us to add those virtio
> specific feature into drm svm, a new SVM frame work based on drm svm
> helpers. We are working on it:
> https://lore.kernel.org/amd-gfx/[email protected]/
> 
> And the amdgpu VM maintainer has agreed that he will help to consider
> how to intergate the virtio requirements into the design of amdgpu drmsvm.
> 
> And for now we can use a user space method to replace the AMD KFD
> patches function, it is mremap, it also works, we tested it, but
> it has some performance loss, I will update the whole thing when all the
> components code are ready.

Thanks for the clarification

-- 
Best regards,
Dmitry

Reply via email to