Skip to contentSkip to conversation

drm/msm/gem: Deal with partial mmap's in fault path

PATCH In review Rob Clark 2 participants 2 messages Nov 6 – Nov 11

Subsystems (3)
lore
Share & tools
lore

Rob Clark

author maintainer
#0 lore raw

PATCH 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
index 000dfcec7809..5826fd69abe4 100644
@@ -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
Reviewed-by on v1 1/1
#1 lore raw
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
---
 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