]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
riscv: Fix loading 64-bit NOMMU kernels past the start of RAM
authorSamuel Holland <samuel.holland@sifive.com>
Tue, 27 Feb 2024 00:34:47 +0000 (16:34 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 2 May 2024 14:32:49 +0000 (16:32 +0200)
commitb008e327fa570aca210f98c817757649bae56694
treeb9230e44b393445e6894e0aee89eac980422d081
parenta0f0dbbb1bc49fa0de18e92c36492ff6d804cdaa
riscv: Fix loading 64-bit NOMMU kernels past the start of RAM

[ Upstream commit aea702dde7e9876fb00571a2602f25130847bf0f ]

commit 3335068f8721 ("riscv: Use PUD/P4D/PGD pages for the linear
mapping") added logic to allow using RAM below the kernel load address.
However, this does not work for NOMMU, where PAGE_OFFSET is fixed to the
kernel load address. Since that range of memory corresponds to PFNs
below ARCH_PFN_OFFSET, mm initialization runs off the beginning of
mem_map and corrupts adjacent kernel memory. Fix this by restoring the
previous behavior for NOMMU kernels.

Fixes: 3335068f8721 ("riscv: Use PUD/P4D/PGD pages for the linear mapping")
Signed-off-by: Samuel Holland <samuel.holland@sifive.com>
Link: https://lore.kernel.org/r/20240227003630.3634533-3-samuel.holland@sifive.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/riscv/include/asm/page.h
arch/riscv/mm/init.c