1 // SPDX-License-Identifier: GPL-2.0-only
4 #include <linux/io-mapping.h>
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
14 * Note: this is only safe if the mm semaphore is held when called.
16 int io_mapping_map_user(struct io_mapping
*iomap
, struct vm_area_struct
*vma
,
17 unsigned long addr
, unsigned long pfn
, unsigned long size
)
19 vm_flags_t expected_flags
= VM_PFNMAP
| VM_DONTEXPAND
| VM_DONTDUMP
;
21 if (WARN_ON_ONCE((vma
->vm_flags
& expected_flags
) != expected_flags
))
24 /* We rely on prevalidation of the io-mapping to skip track_pfn(). */
25 return remap_pfn_range_notrack(vma
, addr
, pfn
, size
,
26 __pgprot((pgprot_val(iomap
->prot
) & _PAGE_CACHE_MASK
) |
27 (pgprot_val(vma
->vm_page_prot
) & ~_PAGE_CACHE_MASK
)));
29 EXPORT_SYMBOL_GPL(io_mapping_map_user
);