Merge tag 'sched-urgent-2020-12-27' of git://git.kernel.org/pub/scm/linux/kernel...
[linux/fpc-iii.git] / arch / riscv / mm / physaddr.c
blobe8e4dcd39fede8d9726ae01892d3f71cf18d5173
1 // SPDX-License-Identifier: GPL-2.0
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>
9 phys_addr_t __virt_to_phys(unsigned long x)
11 phys_addr_t y = x - PAGE_OFFSET;
14 * Boundary checking aginst the kernel linear mapping space.
16 WARN(y >= KERN_VIRT_SIZE,
17 "virt_to_phys used for non-linear address: %pK (%pS)\n",
18 (void *)x, (void *)x);
20 return __va_to_pa_nodebug(x);
22 EXPORT_SYMBOL(__virt_to_phys);
24 phys_addr_t __phys_addr_symbol(unsigned long x)
26 unsigned long kernel_start = (unsigned long)PAGE_OFFSET;
27 unsigned long kernel_end = (unsigned long)_end;
30 * Boundary checking aginst the kernel image mapping.
31 * __pa_symbol should only be used on kernel symbol addresses.
33 VIRTUAL_BUG_ON(x < kernel_start || x > kernel_end);
35 return __va_to_pa_nodebug(x);
37 EXPORT_SYMBOL(__phys_addr_symbol);