Skip to content

Commit d84835b

Browse files
committed
Merge tag 'riscv-for-linus-5.9-mw1' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux
Pull RISC-V fix from Palmer Dabbelt: "I collected a single fix during the merge window: we managed to break the early trap setup on !MMU, this fixes it" * tag 'riscv-for-linus-5.9-mw1' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux: riscv: Setup exception vector for nommu platform
2 parents 5bbec3c + 76d4467 commit d84835b

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

arch/riscv/kernel/head.S

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,10 @@ relocate:
7777
csrw CSR_SATP, a0
7878
.align 2
7979
1:
80-
/* Set trap vector to exception handler */
81-
la a0, handle_exception
80+
/* Set trap vector to spin forever to help debug */
81+
la a0, .Lsecondary_park
8282
csrw CSR_TVEC, a0
8383

84-
/*
85-
* Set sup0 scratch register to 0, indicating to exception vector that
86-
* we are presently executing in kernel.
87-
*/
88-
csrw CSR_SCRATCH, zero
89-
9084
/* Reload the global pointer */
9185
.option push
9286
.option norelax
@@ -144,9 +138,23 @@ secondary_start_common:
144138
la a0, swapper_pg_dir
145139
call relocate
146140
#endif
141+
call setup_trap_vector
147142
tail smp_callin
148143
#endif /* CONFIG_SMP */
149144

145+
.align 2
146+
setup_trap_vector:
147+
/* Set trap vector to exception handler */
148+
la a0, handle_exception
149+
csrw CSR_TVEC, a0
150+
151+
/*
152+
* Set sup0 scratch register to 0, indicating to exception vector that
153+
* we are presently executing in kernel.
154+
*/
155+
csrw CSR_SCRATCH, zero
156+
ret
157+
150158
.Lsecondary_park:
151159
/* We lack SMP support or have too many harts, so park this hart */
152160
wfi
@@ -240,6 +248,7 @@ clear_bss_done:
240248
call relocate
241249
#endif /* CONFIG_MMU */
242250

251+
call setup_trap_vector
243252
/* Restore C environment */
244253
la tp, init_task
245254
sw zero, TASK_TI_CPU(tp)

0 commit comments

Comments
 (0)