diff mbox series

[V3] riscv: set trap vector earlier

Message ID 20240508022445.6131-1-gaoshanliukou@163.com (mailing list archive)
State Accepted
Commit 6ad8735994b854b23c824dd6b1dd2126e893a3b4
Headers show
Series [V3] riscv: set trap vector earlier | expand

Checks

Context Check Description
conchuod/vmtest-for-next-PR fail PR summary
conchuod/patch-1-test-1 success .github/scripts/patches/tests/build_rv32_defconfig.sh
conchuod/patch-1-test-2 fail .github/scripts/patches/tests/build_rv64_clang_allmodconfig.sh
conchuod/patch-1-test-3 fail .github/scripts/patches/tests/build_rv64_gcc_allmodconfig.sh
conchuod/patch-1-test-4 success .github/scripts/patches/tests/build_rv64_nommu_k210_defconfig.sh
conchuod/patch-1-test-5 success .github/scripts/patches/tests/build_rv64_nommu_virt_defconfig.sh
conchuod/patch-1-test-6 success .github/scripts/patches/tests/checkpatch.sh
conchuod/patch-1-test-7 success .github/scripts/patches/tests/dtb_warn_rv64.sh
conchuod/patch-1-test-8 success .github/scripts/patches/tests/header_inline.sh
conchuod/patch-1-test-9 success .github/scripts/patches/tests/kdoc.sh
conchuod/patch-1-test-10 success .github/scripts/patches/tests/module_param.sh
conchuod/patch-1-test-11 success .github/scripts/patches/tests/verify_fixes.sh
conchuod/patch-1-test-12 success .github/scripts/patches/tests/verify_signedoff.sh

Commit Message

yang.zhang May 8, 2024, 2:24 a.m. UTC
From: "yang.zhang" <yang.zhang@hexintek.com>

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@rivosinc.com>
Signed-off-by: yang.zhang <yang.zhang@hexintek.com>

---
V2 -> v3:
- Fix commit message

v1 -> v2:
- As Alex commented, remove the patch for supporting hugesize kernek image
- Add the omissive logic of set trap vector earlier
https://lore.kernel.org/lkml/20240506022239.6817-1-gaoshanliukou@163.com
---
 arch/riscv/kernel/head.S | 3 +++
 1 file changed, 3 insertions(+)

Comments

patchwork-bot+linux-riscv@kernel.org July 14, 2024, 8:30 p.m. UTC | #1
Hello:

This patch was applied to riscv/linux.git (for-next)
by Palmer Dabbelt <palmer@rivosinc.com>:

On Wed,  8 May 2024 10:24:45 +0800 you wrote:
> From: "yang.zhang" <yang.zhang@hexintek.com>
> 
> 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.
> 
> [...]

Here is the summary with links:
  - [V3] riscv: set trap vector earlier
    https://git.kernel.org/riscv/c/6ad8735994b8

You are awesome, thank you!
yang.zhang July 15, 2024, 5:42 a.m. UTC | #2
hi:
Yeah, thanks.













At 2024-07-15 04:30:33, patchwork-bot+linux-riscv@kernel.org wrote:
>Hello:
>
>This patch was applied to riscv/linux.git (for-next)
>by Palmer Dabbelt <palmer@rivosinc.com>:
>
>On Wed,  8 May 2024 10:24:45 +0800 you wrote:
>> From: "yang.zhang" <yang.zhang@hexintek.com>
>> 
>> 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.
>> 
>> [...]
>
>Here is the summary with links:
>  - [V3] riscv: set trap vector earlier
>    https://git.kernel.org/riscv/c/6ad8735994b8
>
>You are awesome, thank you!
>-- 
>Deet-doot-dot, I am a bot.
>https://korg.docs.kernel.org/patchwork/pwbot.html
>
diff mbox series

Patch

diff --git a/arch/riscv/kernel/head.S b/arch/riscv/kernel/head.S
index 4236a69c35cb..03dc440e643e 100644
--- a/arch/riscv/kernel/head.S
+++ b/arch/riscv/kernel/head.S
@@ -300,6 +300,9 @@  SYM_CODE_START(_start_kernel)
 #else
 	mv a0, a1
 #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