1 // SPDX-License-Identifier: GPL-2.0 1 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> 7 8 #include <asm/sections.h> 9 #include <asm/page.h> 10 #include <asm/fixmap.h> 11 #include <asm/dma.h> 12 13 #include "mm.h" 14 15 static inline bool __virt_addr_valid(unsigned 16 { 17 /* 18 * high_memory does not get immediatel 19 * are early callers of __pa() against 20 */ 21 if (!high_memory && x >= PAGE_OFFSET) 22 return true; 23 24 if (high_memory && x >= PAGE_OFFSET && 25 return true; 26 27 /* 28 * MAX_DMA_ADDRESS is a virtual addres 29 * actual physical address. Enough cod 30 * that we just need to work around it 31 */ 32 if (x == MAX_DMA_ADDRESS) 33 return true; 34 35 return false; 36 } 37 38 phys_addr_t __virt_to_phys(unsigned long x) 39 { 40 WARN(!__virt_addr_valid(x), 41 "virt_to_phys used for non-linear 42 (void *)x, (void *)x); 43 44 return __virt_to_phys_nodebug(x); 45 } 46 EXPORT_SYMBOL(__virt_to_phys); 47 48 phys_addr_t __phys_addr_symbol(unsigned long x 49 { 50 /* This is bounds checking against the 51 * __pa_symbol should only be used on 52 */ 53 VIRTUAL_BUG_ON(x < (unsigned long)KERN 54 x > (unsigned long)KERN 55 56 return __pa_symbol_nodebug(x); 57 } 58 EXPORT_SYMBOL(__phys_addr_symbol); 59
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.