Skip to content

Commit 20d2292

Browse files
greentimepaul-walmsley-sifive
authored andcommitted
riscv: make sure the cores stay looping in .Lsecondary_park
The code in secondary_park is currently placed in the .init section. The kernel reclaims and clears this code when it finishes booting. That causes the cores parked in it to go to somewhere unpredictable, so we move this function out of init to make sure the cores stay looping there. The instruction bgeu a0, t0, .Lsecondary_park may have "a relocation truncated to fit" issue during linking time. It is because that sections are too far to jump. Let's use tail to jump to the .Lsecondary_park. Signed-off-by: Greentime Hu <[email protected]> Reviewed-by: Anup Patel <[email protected]> Cc: Andreas Schwab <[email protected]> Cc: [email protected] Fixes: 76d2a04 ("RISC-V: Init and Halt Code") Signed-off-by: Paul Walmsley <[email protected]>
1 parent b3a987b commit 20d2292

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

arch/riscv/kernel/head.S

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ _start_kernel:
8080

8181
#ifdef CONFIG_SMP
8282
li t0, CONFIG_NR_CPUS
83-
bgeu a0, t0, .Lsecondary_park
83+
blt a0, t0, .Lgood_cores
84+
tail .Lsecondary_park
85+
.Lgood_cores:
8486
#endif
8587

8688
/* Pick one hart to run the main boot sequence */
@@ -209,11 +211,6 @@ relocate:
209211
tail smp_callin
210212
#endif
211213

212-
.align 2
213-
.Lsecondary_park:
214-
/* We lack SMP support or have too many harts, so park this hart */
215-
wfi
216-
j .Lsecondary_park
217214
END(_start)
218215

219216
#ifdef CONFIG_RISCV_M_MODE
@@ -295,6 +292,13 @@ ENTRY(reset_regs)
295292
END(reset_regs)
296293
#endif /* CONFIG_RISCV_M_MODE */
297294

295+
.section ".text", "ax",@progbits
296+
.align 2
297+
.Lsecondary_park:
298+
/* We lack SMP support or have too many harts, so park this hart */
299+
wfi
300+
j .Lsecondary_park
301+
298302
__PAGE_ALIGNED_BSS
299303
/* Empty zero page */
300304
.balign PAGE_SIZE

0 commit comments

Comments
 (0)