Commit b41e297a authored by Danilo Krummrich's avatar Danilo Krummrich

drm/nouveau: make use of drm_gpuvm_range_valid()

Use drm_gpuvm_range_valid() in order to validate userspace requests.
Reviewed-by: default avatarDave Airlie <airlied@redhat.com>
Signed-off-by: default avatarDanilo Krummrich <dakr@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20231108001259.15123-5-dakr@redhat.com
parent 9297cfc9
......@@ -929,25 +929,13 @@ nouveau_uvmm_sm_unmap_cleanup(struct nouveau_uvmm *uvmm,
static int
nouveau_uvmm_validate_range(struct nouveau_uvmm *uvmm, u64 addr, u64 range)
{
u64 end = addr + range;
u64 kernel_managed_end = uvmm->kernel_managed_addr +
uvmm->kernel_managed_size;
if (addr & ~PAGE_MASK)
return -EINVAL;
if (range & ~PAGE_MASK)
return -EINVAL;
if (end <= addr)
return -EINVAL;
if (addr < NOUVEAU_VA_SPACE_START ||
end > NOUVEAU_VA_SPACE_END)
return -EINVAL;
if (addr < kernel_managed_end &&
end > uvmm->kernel_managed_addr)
if (!drm_gpuvm_range_valid(&uvmm->base, addr, range))
return -EINVAL;
return 0;
......@@ -1834,9 +1822,6 @@ nouveau_uvmm_init(struct nouveau_uvmm *uvmm, struct nouveau_cli *cli,
goto out_unlock;
}
uvmm->kernel_managed_addr = kernel_managed_addr;
uvmm->kernel_managed_size = kernel_managed_size;
drm_gpuvm_init(&uvmm->base, cli->name, drm,
NOUVEAU_VA_SPACE_START,
NOUVEAU_VA_SPACE_END,
......
......@@ -14,9 +14,6 @@ struct nouveau_uvmm {
struct mutex mutex;
struct dma_resv resv;
u64 kernel_managed_addr;
u64 kernel_managed_size;
bool disabled;
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment