physaddr.c 773 B

1234567891011121314151617181920212223242526272829303132
  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>
  7. #include <asm/memory.h>
  8. phys_addr_t __virt_to_phys(unsigned long x)
  9. {
  10. WARN(!__is_lm_address(x),
  11. "virt_to_phys used for non-linear address: %pK (%pS)\n",
  12. (void *)x,
  13. (void *)x);
  14. return __virt_to_phys_nodebug(x);
  15. }
  16. EXPORT_SYMBOL(__virt_to_phys);
  17. phys_addr_t __phys_addr_symbol(unsigned long x)
  18. {
  19. /*
  20. * This is bounds checking against the kernel image only.
  21. * __pa_symbol should only be used on kernel symbol addresses.
  22. */
  23. VIRTUAL_BUG_ON(x < (unsigned long) KERNEL_START ||
  24. x > (unsigned long) KERNEL_END);
  25. return __pa_symbol_nodebug(x);
  26. }
  27. EXPORT_SYMBOL(__phys_addr_symbol);