Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v6.16 30 lines 1.0 kB view raw
1// SPDX-License-Identifier: GPL-2.0-only 2 3#include <linux/mm.h> 4#include <linux/io-mapping.h> 5 6/** 7 * io_mapping_map_user - remap an I/O mapping to userspace 8 * @iomap: the source io_mapping 9 * @vma: user vma to map to 10 * @addr: target user address to start at 11 * @pfn: physical address of kernel memory 12 * @size: size of map area 13 * 14 * Note: this is only safe if the mm semaphore is held when called. 15 */ 16int io_mapping_map_user(struct io_mapping *iomap, struct vm_area_struct *vma, 17 unsigned long addr, unsigned long pfn, unsigned long size) 18{ 19 vm_flags_t expected_flags = VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP; 20 21 if (WARN_ON_ONCE((vma->vm_flags & expected_flags) != expected_flags)) 22 return -EINVAL; 23 24 pgprot_t remap_prot = __pgprot((pgprot_val(iomap->prot) & _PAGE_CACHE_MASK) | 25 (pgprot_val(vma->vm_page_prot) & ~_PAGE_CACHE_MASK)); 26 27 /* We rely on prevalidation of the io-mapping to skip pfnmap tracking. */ 28 return remap_pfn_range_notrack(vma, addr, pfn, size, remap_prot); 29} 30EXPORT_SYMBOL_GPL(io_mapping_map_user);