drm/nouveau/svm: fix vma range check for migration
authorRalph Campbell <rcampbell@nvidia.com>
Wed, 4 Mar 2020 00:13:36 +0000 (16:13 -0800)
committerBen Skeggs <bskeggs@redhat.com>
Tue, 7 Apr 2020 04:37:49 +0000 (14:37 +1000)
find_vma_intersection(mm, start, end) only guarantees that end is greater
than or equal to vma->vm_start but doesn't guarantee that start is
greater than or equal to vma->vm_start. The calculation for the
intersecting range in nouveau_svmm_bind() isn't accounting for this and
can call migrate_vma_setup() with a starting address less than
vma->vm_start. This results in migrate_vma_setup() returning -EINVAL for
the range instead of nouveau skipping that part of the range and migrating
the rest.

Signed-off-by: Ralph Campbell <rcampbell@nvidia.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/nouveau_svm.c

index df9bf1f..1693204 100644 (file)
@@ -179,6 +179,7 @@ nouveau_svmm_bind(struct drm_device *dev, void *data,
                if (!vma)
                        break;
 
+               addr = max(addr, vma->vm_start);
                next = min(vma->vm_end, end);
                /* This is a best effort so we ignore errors */
                nouveau_dmem_migrate_vma(cli->drm, vma, addr, next);