riscv: Check if the code to patch lies in the exit section
authorAlexandre Ghiti <alexghiti@rivosinc.com>
Thu, 14 Dec 2023 09:19:26 +0000 (10:19 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Jan 2024 23:35:50 +0000 (15:35 -0800)
commit8db56df4a954b774bdc68917046a685a9fa2e4bc
treec5b09ac73813967e64f89151ec8d040757e75ae2
parente111d2319a44d325ce7a548ab07460cef4e2c457
riscv: Check if the code to patch lies in the exit section

[ Upstream commit 420370f3ae3d3b883813fd3051a38805160b2b9f ]

Otherwise we fall through to vmalloc_to_page() which panics since the
address does not lie in the vmalloc region.

Fixes: 043cb41a85de ("riscv: introduce interfaces to patch kernel code")
Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Reviewed-by: Charlie Jenkins <charlie@rivosinc.com>
Link: https://lore.kernel.org/r/20231214091926.203439-1-alexghiti@rivosinc.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/riscv/include/asm/sections.h
arch/riscv/kernel/patch.c
arch/riscv/kernel/vmlinux-xip.lds.S
arch/riscv/kernel/vmlinux.lds.S