Merge tag 'linux-kselftest-kunit-fixes-5.11-rc3' of git://git.kernel.org/pub/scm...
[linux/fpc-iii.git] / arch / arm64 / mm / mmap.c
blob07937b49cb881c2d2795a16e025da4081ae3921d
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * Based on arch/arm/mm/mmap.c
5 * Copyright (C) 2012 ARM Ltd.
6 */
8 #include <linux/elf.h>
9 #include <linux/fs.h>
10 #include <linux/memblock.h>
11 #include <linux/mm.h>
12 #include <linux/mman.h>
13 #include <linux/export.h>
14 #include <linux/shm.h>
15 #include <linux/sched/signal.h>
16 #include <linux/sched/mm.h>
17 #include <linux/io.h>
18 #include <linux/personality.h>
19 #include <linux/random.h>
21 #include <asm/cputype.h>
24 * You really shouldn't be using read() or write() on /dev/mem. This might go
25 * away in the future.
27 int valid_phys_addr_range(phys_addr_t addr, size_t size)
30 * Check whether addr is covered by a memory region without the
31 * MEMBLOCK_NOMAP attribute, and whether that region covers the
32 * entire range. In theory, this could lead to false negatives
33 * if the range is covered by distinct but adjacent memory regions
34 * that only differ in other attributes. However, few of such
35 * attributes have been defined, and it is debatable whether it
36 * follows that /dev/mem read() calls should be able traverse
37 * such boundaries.
39 return memblock_is_region_memory(addr, size) &&
40 memblock_is_map_memory(addr);
44 * Do not allow /dev/mem mappings beyond the supported physical range.
46 int valid_mmap_phys_addr_range(unsigned long pfn, size_t size)
48 return !(((pfn << PAGE_SHIFT) + size) & ~PHYS_MASK);