0001
0002 #include <linux/bug.h>
0003 #include <linux/export.h>
0004 #include <linux/types.h>
0005 #include <linux/mmdebug.h>
0006 #include <linux/mm.h>
0007
0008 #include <asm/addrspace.h>
0009 #include <asm/sections.h>
0010 #include <asm/io.h>
0011 #include <asm/page.h>
0012 #include <asm/dma.h>
0013
0014 static inline bool __debug_virt_addr_valid(unsigned long x)
0015 {
0016
0017
0018
0019
0020
0021
0022 if (x == MAX_DMA_ADDRESS)
0023 return true;
0024
0025 return x >= PAGE_OFFSET && (KSEGX(x) < KSEG2 ||
0026 IS_ENABLED(CONFIG_EVA) ||
0027 !IS_ENABLED(CONFIG_HIGHMEM));
0028 }
0029
0030 phys_addr_t __virt_to_phys(volatile const void *x)
0031 {
0032 WARN(!__debug_virt_addr_valid((unsigned long)x),
0033 "virt_to_phys used for non-linear address: %pK (%pS)\n",
0034 x, x);
0035
0036 return __virt_to_phys_nodebug(x);
0037 }
0038 EXPORT_SYMBOL(__virt_to_phys);
0039
0040 phys_addr_t __phys_addr_symbol(unsigned long x)
0041 {
0042
0043
0044
0045 VIRTUAL_BUG_ON(x < (unsigned long)_text ||
0046 x > (unsigned long)_end);
0047
0048 return __pa_symbol_nodebug(x);
0049 }
0050 EXPORT_SYMBOL(__phys_addr_symbol);