lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <242cf022-503d-553a-8b78-f0abdb58d374@synaptics.com>
Date:   Mon, 21 Aug 2023 17:55:51 +0800
From:   Hsia-Jun Li <Randy.Li@...aptics.com>
To:     linaro-mm-sig@...ts.linaro.org
Cc:     sumit.semwal@...aro.org,
        Benjamin Gaignard <benjamin.gaignard@...labora.com>,
        Brian.Starkey@....com, jstultz@...gle.com, tjmercier@...gle.com,
        christian.koenig@....com,
        Linux Media Mailing List <linux-media@...r.kernel.org>,
        dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org
Subject: [PATCH] dma-buf/heaps: map CMA all pages for user

Page fault would raise a CPU interrupt, it is not
a good idea.

Signed-off-by: Hsia-Jun(Randy) Li <randy.li@...aptics.com>
---
  drivers/dma-buf/heaps/cma_heap.c | 26 +++-----------------------
  1 file changed, 3 insertions(+), 23 deletions(-)

diff --git a/drivers/dma-buf/heaps/cma_heap.c 
b/drivers/dma-buf/heaps/cma_heap.c
index ee899f8e6721..7d0b15ad21a7 100644
--- a/drivers/dma-buf/heaps/cma_heap.c
+++ b/drivers/dma-buf/heaps/cma_heap.c
@@ -160,35 +160,15 @@ static int cma_heap_dma_buf_end_cpu_access(struct 
dma_buf *dmabuf,
  	return 0;
  }
  -static vm_fault_t cma_heap_vm_fault(struct vm_fault *vmf)
-{
-	struct vm_area_struct *vma = vmf->vma;
-	struct cma_heap_buffer *buffer = vma->vm_private_data;
-
-	if (vmf->pgoff > buffer->pagecount)
-		return VM_FAULT_SIGBUS;
-
-	vmf->page = buffer->pages[vmf->pgoff];
-	get_page(vmf->page);
-
-	return 0;
-}
-
-static const struct vm_operations_struct dma_heap_vm_ops = {
-	.fault = cma_heap_vm_fault,
-};
-
  static int cma_heap_mmap(struct dma_buf *dmabuf, struct vm_area_struct 
*vma)
  {
  	struct cma_heap_buffer *buffer = dmabuf->priv;
-
  	if ((vma->vm_flags & (VM_SHARED | VM_MAYSHARE)) == 0)
  		return -EINVAL;
  -	vma->vm_ops = &dma_heap_vm_ops;
-	vma->vm_private_data = buffer;
-
-	return 0;
+	return remap_pfn_range(vma, vma->vm_start,
+			       page_to_pfn(buffer->pages[vma->vm_pgoff]),
+			       vma->vm_end - vma->vm_start, vma->vm_page_prot);
  }
   static void *cma_heap_do_vmap(struct cma_heap_buffer *buffer)
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ