Linux 5.7.6
[linux/fpc-iii.git] / arch / arm / mm / physaddr.c
blobcf75819e4c137618cfe1c5c18ef91e7ede6b98bb
1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/bug.h>
3 #include <linux/export.h>
4 #include <linux/types.h>
5 #include <linux/mmdebug.h>
6 #include <linux/mm.h>
8 #include <asm/sections.h>
9 #include <asm/memory.h>
10 #include <asm/fixmap.h>
11 #include <asm/dma.h>
13 #include "mm.h"
15 static inline bool __virt_addr_valid(unsigned long x)
18 * high_memory does not get immediately defined, and there
19 * are early callers of __pa() against PAGE_OFFSET
21 if (!high_memory && x >= PAGE_OFFSET)
22 return true;
24 if (high_memory && x >= PAGE_OFFSET && x < (unsigned long)high_memory)
25 return true;
28 * MAX_DMA_ADDRESS is a virtual address that may not correspond to an
29 * actual physical address. Enough code relies on __pa(MAX_DMA_ADDRESS)
30 * that we just need to work around it and always return true.
32 if (x == MAX_DMA_ADDRESS)
33 return true;
35 return false;
38 phys_addr_t __virt_to_phys(unsigned long x)
40 WARN(!__virt_addr_valid(x),
41 "virt_to_phys used for non-linear address: %pK (%pS)\n",
42 (void *)x, (void *)x);
44 return __virt_to_phys_nodebug(x);
46 EXPORT_SYMBOL(__virt_to_phys);
48 phys_addr_t __phys_addr_symbol(unsigned long x)
50 /* This is bounds checking against the kernel image only.
51 * __pa_symbol should only be used on kernel symbol addresses.
53 VIRTUAL_BUG_ON(x < (unsigned long)KERNEL_START ||
54 x > (unsigned long)KERNEL_END);
56 return __pa_symbol_nodebug(x);
58 EXPORT_SYMBOL(__phys_addr_symbol);