mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-28 06:34:12 +08:00
5f763b3b59
KERN_VIRT_SIZE used to encompass the kernel mapping before it was
redefined when moving the kasan mapping next to the kernel mapping to only
match the maximum amount of physical memory.
Then, kernel mapping addresses that go through __virt_to_phys are now
declared as wrong which is not true, one can use __virt_to_phys on such
addresses.
Fix this by redefining the condition that matches wrong addresses.
Fixes: f7ae02333d
("riscv: Move KASAN mapping next to the kernel mapping")
Signed-off-by: Alexandre Ghiti <alexandre.ghiti@canonical.com>
Cc: stable@vger.kernel.org
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
36 lines
891 B
C
36 lines
891 B
C
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
#include <linux/types.h>
|
|
#include <linux/mmdebug.h>
|
|
#include <linux/mm.h>
|
|
#include <asm/page.h>
|
|
#include <asm/sections.h>
|
|
|
|
phys_addr_t __virt_to_phys(unsigned long x)
|
|
{
|
|
/*
|
|
* Boundary checking aginst the kernel linear mapping space.
|
|
*/
|
|
WARN(!is_linear_mapping(x) && !is_kernel_mapping(x),
|
|
"virt_to_phys used for non-linear address: %pK (%pS)\n",
|
|
(void *)x, (void *)x);
|
|
|
|
return __va_to_pa_nodebug(x);
|
|
}
|
|
EXPORT_SYMBOL(__virt_to_phys);
|
|
|
|
phys_addr_t __phys_addr_symbol(unsigned long x)
|
|
{
|
|
unsigned long kernel_start = kernel_map.virt_addr;
|
|
unsigned long kernel_end = (unsigned long)_end;
|
|
|
|
/*
|
|
* Boundary checking aginst the kernel image mapping.
|
|
* __pa_symbol should only be used on kernel symbol addresses.
|
|
*/
|
|
VIRTUAL_BUG_ON(x < kernel_start || x > kernel_end);
|
|
|
|
return __va_to_pa_nodebug(x);
|
|
}
|
|
EXPORT_SYMBOL(__phys_addr_symbol);
|