Skip to content

Commit ac48ddf

Browse files
vivekkreddygregkh
authored andcommitted
udmabuf: use vmf_insert_pfn and VM_PFNMAP for handling mmap
commit 7d79cd7 upstream. Add VM_PFNMAP to vm_flags in the mmap handler to ensure that the mappings would be managed without using struct page. And, in the vm_fault handler, use vmf_insert_pfn to share the page's pfn to userspace instead of directly sharing the page (via struct page *). Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Vivek Kasireddy <[email protected]> Suggested-by: David Hildenbrand <[email protected]> Acked-by: David Hildenbrand <[email protected]> Acked-by: Dave Airlie <[email protected]> Acked-by: Gerd Hoffmann <[email protected]> Cc: Daniel Vetter <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: Peter Xu <[email protected]> Cc: Jason Gunthorpe <[email protected]> Cc: Dongwon Kim <[email protected]> Cc: Junxiao Chang <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Christoph Hellwig <[email protected]> Cc: Christoph Hellwig <[email protected]> Cc: Matthew Wilcox (Oracle) <[email protected]> Cc: Mike Kravetz <[email protected]> Cc: Oscar Salvador <[email protected]> Cc: Shuah Khan <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent cfaf835 commit ac48ddf

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

drivers/dma-buf/udmabuf.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,13 @@ static vm_fault_t udmabuf_vm_fault(struct vm_fault *vmf)
3535
struct vm_area_struct *vma = vmf->vma;
3636
struct udmabuf *ubuf = vma->vm_private_data;
3737
pgoff_t pgoff = vmf->pgoff;
38+
unsigned long pfn;
3839

3940
if (pgoff >= ubuf->pagecount)
4041
return VM_FAULT_SIGBUS;
41-
vmf->page = ubuf->pages[pgoff];
42-
get_page(vmf->page);
43-
return 0;
42+
43+
pfn = page_to_pfn(ubuf->pages[pgoff]);
44+
return vmf_insert_pfn(vma, vmf->address, pfn);
4445
}
4546

4647
static const struct vm_operations_struct udmabuf_vm_ops = {
@@ -56,6 +57,7 @@ static int mmap_udmabuf(struct dma_buf *buf, struct vm_area_struct *vma)
5657

5758
vma->vm_ops = &udmabuf_vm_ops;
5859
vma->vm_private_data = ubuf;
60+
vm_flags_set(vma, VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP);
5961
return 0;
6062
}
6163

0 commit comments

Comments
 (0)