This is a note to let you know that I've just added the patch titled riscv: set trap vector earlier to the 5.15-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: riscv-set-trap-vector-earlier.patch and it can be found in the queue-5.15 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit f21aaee1ede5572ec11401094eb07c64b267886d Author: yang.zhang <yang.zhang@xxxxxxxxxxxx> Date: Wed May 8 10:24:45 2024 +0800 riscv: set trap vector earlier [ Upstream commit 6ad8735994b854b23c824dd6b1dd2126e893a3b4 ] The exception vector of the booting hart is not set before enabling the mmu and then still points to the value of the previous firmware, typically _start. That makes it hard to debug setup_vm() when bad things happen. So fix that by setting the exception vector earlier. Reviewed-by: Alexandre Ghiti <alexghiti@xxxxxxxxxxxx> Signed-off-by: yang.zhang <yang.zhang@xxxxxxxxxxxx> Link: https://lore.kernel.org/r/20240508022445.6131-1-gaoshanliukou@xxxxxxx Signed-off-by: Palmer Dabbelt <palmer@xxxxxxxxxxxx> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/arch/riscv/kernel/head.S b/arch/riscv/kernel/head.S index 4c3c7592b6fc..a89c59fb08ba 100644 --- a/arch/riscv/kernel/head.S +++ b/arch/riscv/kernel/head.S @@ -309,6 +309,9 @@ clear_bss_done: #else mv a0, s1 #endif /* CONFIG_BUILTIN_DTB */ + /* Set trap vector to spin forever to help debug */ + la a3, .Lsecondary_park + csrw CSR_TVEC, a3 call setup_vm #ifdef CONFIG_MMU la a0, early_pg_dir