drm/msm/gem: Deal with partial mmap's in fault path
Rob Clark
maintainerPATCH 1/1 drm/msm/gem: Deal with partial mmap's in fault path
Historically we ignored pgoff, as it was a "fake" offset that simply served to map back to the gem handle. Mmaping a partial obj was dis- allowed.
But we can instead just subtract off the fake offset.
drm_gem_mmap() still expects an exact match on pgoff, so unless we use our own path for that, like some other drivers, we don't fully support partial mmap. But this at least makes things more robust if userspace does funny things like partal unmap.
--- drivers/gpu/drm/msm/msm_gem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/msm/msm_gem.c +2 -2
@@ -374,8 +374,8 @@ static vm_fault_t msm_gem_fault(struct vm_fault *vmf)return vmf_error (PTR_ERR (pages)); } -/* We don't use vmf->pgoff since that has the fake offset: */ - pgoff =linear_page_delta (vma, vmf->address); + pgoff =linear_page_index (vma, vmf->address) - +drm_vma_node_start (&obj->vma_node); pfn =page_to_pfn (pages[pgoff]);
Signature · 1 line
2.56.0
Quoted 11 lines · Rob Clark
Historically we ignored pgoff, as it was a "fake" offset that simply served to map back to the gem handle. Mmaping a partial obj was dis- allowed.
But we can instead just subtract off the fake offset.
drm_gem_mmap()still expects an exact match on pgoff, so unless we use our own path for that, like some other drivers, we don't fully support partial mmap. But this at least makes things more robust if userspace does funny things like partal unmap.
Quoted 5 lines
Signed-off-by Rob Clark <[email protected]>--- drivers/gpu/drm/msm/msm_gem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 1 line
Signature · 2 lines
With best wishes Dmitry