forked from mirrors/linux
		
	arm64: dma-mapping: clear buffers allocated with FORCE_CONTIGUOUS flag
dma_alloc_*() buffers might be exposed to userspace via mmap() call, so they should be cleared on allocation. In case of IOMMU-based dma-mapping implementation such buffer clearing was missing in the code path for DMA_ATTR_FORCE_CONTIGUOUS flag handling, because dma_alloc_from_contiguous() doesn't honor __GFP_ZERO flag. This patch fixes this issue. For more information on clearing buffers allocated by dma_alloc_* functions, see commit6829e274a6("arm64: dma-mapping: always clear allocated buffers"). Fixes:44176bb38f("arm64: Add support for DMA_ATTR_FORCE_CONTIGUOUS to IOMMU") Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
This commit is contained in:
		
							parent
							
								
									ce397d215c
								
							
						
					
					
						commit
						dd65a941f6
					
				
					 1 changed files with 5 additions and 4 deletions
				
			
		|  | @ -583,13 +583,14 @@ static void *__iommu_alloc_attrs(struct device *dev, size_t size, | ||||||
| 						    size >> PAGE_SHIFT); | 						    size >> PAGE_SHIFT); | ||||||
| 			return NULL; | 			return NULL; | ||||||
| 		} | 		} | ||||||
| 		if (!coherent) |  | ||||||
| 			__dma_flush_area(page_to_virt(page), iosize); |  | ||||||
| 
 |  | ||||||
| 		addr = dma_common_contiguous_remap(page, size, VM_USERMAP, | 		addr = dma_common_contiguous_remap(page, size, VM_USERMAP, | ||||||
| 						   prot, | 						   prot, | ||||||
| 						   __builtin_return_address(0)); | 						   __builtin_return_address(0)); | ||||||
| 		if (!addr) { | 		if (addr) { | ||||||
|  | 			memset(addr, 0, size); | ||||||
|  | 			if (!coherent) | ||||||
|  | 				__dma_flush_area(page_to_virt(page), iosize); | ||||||
|  | 		} else { | ||||||
| 			iommu_dma_unmap_page(dev, *handle, iosize, 0, attrs); | 			iommu_dma_unmap_page(dev, *handle, iosize, 0, attrs); | ||||||
| 			dma_release_from_contiguous(dev, page, | 			dma_release_from_contiguous(dev, page, | ||||||
| 						    size >> PAGE_SHIFT); | 						    size >> PAGE_SHIFT); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Marek Szyprowski
						Marek Szyprowski