18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci#include <linux/bug.h> 38c2ecf20Sopenharmony_ci#include <linux/export.h> 48c2ecf20Sopenharmony_ci#include <linux/types.h> 58c2ecf20Sopenharmony_ci#include <linux/mmdebug.h> 68c2ecf20Sopenharmony_ci#include <linux/mm.h> 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#include <asm/memory.h> 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ciphys_addr_t __virt_to_phys(unsigned long x) 118c2ecf20Sopenharmony_ci{ 128c2ecf20Sopenharmony_ci WARN(!__is_lm_address(__tag_reset(x)), 138c2ecf20Sopenharmony_ci "virt_to_phys used for non-linear address: %pK (%pS)\n", 148c2ecf20Sopenharmony_ci (void *)x, 158c2ecf20Sopenharmony_ci (void *)x); 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci return __virt_to_phys_nodebug(x); 188c2ecf20Sopenharmony_ci} 198c2ecf20Sopenharmony_ciEXPORT_SYMBOL(__virt_to_phys); 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ciphys_addr_t __phys_addr_symbol(unsigned long x) 228c2ecf20Sopenharmony_ci{ 238c2ecf20Sopenharmony_ci /* 248c2ecf20Sopenharmony_ci * This is bounds checking against the kernel image only. 258c2ecf20Sopenharmony_ci * __pa_symbol should only be used on kernel symbol addresses. 268c2ecf20Sopenharmony_ci */ 278c2ecf20Sopenharmony_ci VIRTUAL_BUG_ON(x < (unsigned long) KERNEL_START || 288c2ecf20Sopenharmony_ci x > (unsigned long) KERNEL_END); 298c2ecf20Sopenharmony_ci return __pa_symbol_nodebug(x); 308c2ecf20Sopenharmony_ci} 318c2ecf20Sopenharmony_ciEXPORT_SYMBOL(__phys_addr_symbol); 32