mirror of
https://github.com/torvalds/linux.git
synced 2026-11-29 10:07:52 +00:00
track_pfn() does not exist, let's simply refer to it as "pfnmap tracking". Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: David Hildenbrand <[email protected]> Reviewed-by: Lorenzo Stoakes <[email protected]> Acked-by: Ingo Molnar <[email protected]> [x86 bits] Reviewed-by: Liam R. Howlett <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Borislav Betkov <[email protected]> Cc: Dave Airlie <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Cc: Jani Nikula <[email protected]> Cc: Jann Horn <[email protected]> Cc: Jonas Lahtinen <[email protected]> Cc: "Masami Hiramatsu (Google)" <[email protected]> Cc: Mathieu Desnoyers <[email protected]> Cc: Peter Xu <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Rodrigo Vivi <[email protected]> Cc: Steven Rostedt <[email protected]> Cc: Thomas Gleinxer <[email protected]> Cc: Tvrtko Ursulin <[email protected]> Cc: Vlastimil Babka <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
31 lines
1.0 KiB
C
31 lines
1.0 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
|
|
#include <linux/mm.h>
|
|
#include <linux/io-mapping.h>
|
|
|
|
/**
|
|
* io_mapping_map_user - remap an I/O mapping to userspace
|
|
* @iomap: the source io_mapping
|
|
* @vma: user vma to map to
|
|
* @addr: target user address to start at
|
|
* @pfn: physical address of kernel memory
|
|
* @size: size of map area
|
|
*
|
|
* Note: this is only safe if the mm semaphore is held when called.
|
|
*/
|
|
int io_mapping_map_user(struct io_mapping *iomap, struct vm_area_struct *vma,
|
|
unsigned long addr, unsigned long pfn, unsigned long size)
|
|
{
|
|
vm_flags_t expected_flags = VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP;
|
|
|
|
if (WARN_ON_ONCE((vma->vm_flags & expected_flags) != expected_flags))
|
|
return -EINVAL;
|
|
|
|
pgprot_t remap_prot = __pgprot((pgprot_val(iomap->prot) & _PAGE_CACHE_MASK) |
|
|
(pgprot_val(vma->vm_page_prot) & ~_PAGE_CACHE_MASK));
|
|
|
|
/* We rely on prevalidation of the io-mapping to skip pfnmap tracking. */
|
|
return remap_pfn_range_notrack(vma, addr, pfn, size, remap_prot);
|
|
}
|
|
EXPORT_SYMBOL_GPL(io_mapping_map_user);
|