1 // SPDX-License-Identifier: GPL-2.0 2 3 #include <linux/types.h> 4 #include <linux/mmdebug.h> 5 #include <linux/mm.h> 6 #include <asm/page.h> 7 #include <asm/sections.h> 8 9 phys_addr_t __virt_to_phys(unsigned long x) 10 { 11 phys_addr_t y = x - PAGE_OFFSET; 12 13 /* 14 * Boundary checking aginst the kernel linear mapping space. 15 */ 16 WARN(y >= KERN_VIRT_SIZE, 17 "virt_to_phys used for non-linear address: %pK (%pS)\n", 18 (void *)x, (void *)x); 19 20 return __va_to_pa_nodebug(x); 21 } 22 EXPORT_SYMBOL(__virt_to_phys); 23 24 phys_addr_t __phys_addr_symbol(unsigned long x) 25 { 26 unsigned long kernel_start = (unsigned long)PAGE_OFFSET; 27 unsigned long kernel_end = (unsigned long)_end; 28 29 /* 30 * Boundary checking aginst the kernel image mapping. 31 * __pa_symbol should only be used on kernel symbol addresses. 32 */ 33 VIRTUAL_BUG_ON(x < kernel_start || x > kernel_end); 34 35 return __va_to_pa_nodebug(x); 36 } 37 EXPORT_SYMBOL(__phys_addr_symbol); 38