From a3c08fdbdb3508ac4895fd159aaabff576fdcd14 Mon Sep 17 00:00:00 2001 From: Puneet Saxena Date: Tue, 7 Jul 2020 21:36:40 +0530 Subject: video: tegra: nvmap: add support to create RO handle from user VA User malloc + mprotect/mmap a buffer as RO and as part of alloc_from_va, user pass the ACCESS_FLAGS as RO and expects NvMap to give dma_buf_fd with RO access. Below are the conditions result in NvRmMemHandle creation - 1) VA: RO and Attr: RW - Don't create NvMap Handle 2) VA: RO and Attr: RO - Create NvMap Handle and set dma_buf_fd as RO 3) VA: RW and Attr: RO - Create NvMap Handle and set dma_buf_fd as RO 4) Mixed VA: RO + RW and Attr: RO - Create NvMap Handle with dma_buf_fd as RO for the whole buffer 5) Mixed VA: RO + RW and Attr: RW - Don't Create NvMap Handle If few pages of the buffer is set as RO and rest as RW, multiple vma are created and vma->end and vma->start doesn't differ by the buffer size, passed to create handle from VA. Hence remove the check. Anyway the check is done in get_user_pages. The change sets dma_buf_fd as RW/RO so that other process should fetch the access permission just by reading f_mode of dma_buf_fd. Bug 200621238 Bug 200634660 Change-Id: I9c50c6f28664f0ff9f70dc08b15d93389e7d7201 Signed-off-by: Puneet Saxena Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2515023 (cherry picked from commit 0514e68ce8948428b417c55057a4dd2f57acd9c2) Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2521313 Reviewed-by: svc-mobile-coverity Reviewed-by: Bibek Basu Reviewed-by: mobile promotions Tested-by: Amulya Yarlagadda Tested-by: mobile promotions GVS: Gerrit_Virtual_Submit --- include/linux/nvmap.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/linux') diff --git a/include/linux/nvmap.h b/include/linux/nvmap.h index 8f17a1c48..b8d267691 100644 --- a/include/linux/nvmap.h +++ b/include/linux/nvmap.h @@ -50,6 +50,7 @@ #define NVMAP_HANDLE_PHYS_CONTIG (0x1ul << 6) #define NVMAP_HANDLE_CACHE_SYNC (0x1ul << 7) #define NVMAP_HANDLE_CACHE_SYNC_AT_RESERVE (0x1ul << 8) +#define NVMAP_HANDLE_RO (0x1ul << 9) #ifdef CONFIG_NVMAP_PAGE_POOLS ulong nvmap_page_pool_get_unused_pages(void); -- cgit v1.2.2