riscv: make sure the cores stay looping in .Lsecondary_park
PATCH v3 1/1 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.
--- arch/riscv/kernel/head.S | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
arch/riscv/kernel/head.S +7 -5
@@ -217,11 +217,6 @@ relocate: tail smp_callin #endif -.align 2 -.Lsecondary_park: - /* We lack SMP support or have too many harts, so park this hart */ - wfi - j .Lsecondary_park END(_start) #ifdef CONFIG_RISCV_M_MODE
@@ -303,6 +298,13 @@ ENTRY(reset_regs) END(reset_regs) #endif /* CONFIG_RISCV_M_MODE */ +.section ".text", "ax",@progbits +.align 2 +.Lsecondary_park: + /* We lack SMP support or have too many harts, so park this hart */ + wfi + j .Lsecondary_park + __PAGE_ALIGNED_BSS /* Empty zero page */ .balign PAGE_SIZE
Signature · 1 line
2.17.1
Quoted 7 lines · Greentime Hu
The code in
secondary_parkis 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.Signed-off-by Greentime Hu <[email protected]>Reviewed-by Anup Patel <[email protected]>
Thanks, the following is what's been queued for v5.5-rc.
- Paul
From: Greentime Hu <[email protected]>
Date: Thu, 9 Jan 2020 11:15:16 +0800
Subject: [PATCH] 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.
--- arch/riscv/kernel/head.S | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
arch/riscv/kernel/head.S +7 -5
@@ -209,11 +209,6 @@ relocate: tail smp_callin #endif -.align 2 -.Lsecondary_park: - /* We lack SMP support or have too many harts, so park this hart */ - wfi - j .Lsecondary_park END(_start) #ifdef CONFIG_RISCV_M_MODE
@@ -295,6 +290,13 @@ ENTRY(reset_regs) END(reset_regs) #endif /* CONFIG_RISCV_M_MODE */ +.section ".text", "ax",@progbits +.align 2 +.Lsecondary_park: + /* We lack SMP support or have too many harts, so park this hart */ + wfi + j .Lsecondary_park + __PAGE_ALIGNED_BSS /* Empty zero page */ .balign PAGE_SIZE
Signature · 1 line
2.25.0.rc2
Hi Greentime,
Quoted 11 lines · Paul Walmsley
Quoted 7 lines · Greentime Hu
The code in
secondary_parkis 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.Signed-off-by Greentime Hu <[email protected]>Reviewed-by Anup Patel <[email protected]>Thanks, the following is what's been queued for v5.5-rc.
During final testing, when building the kernel with an initramfs, I hit the following linker error:
LD .tmp_vmlinux1arch/riscv/kernel/head.o: in function .L0 ':(.init.text+0x5c): relocation truncated to fit: R_RISCV_JAL against .Lsecondary_park' make[1]: *** [Makefile:1079: vmlinux] Error 1
make: *** [Makefile:326: __build_one_by_one] Error 2
Could you take a look at this?
thanks,
- Paul
Hi Paul,
Quoted 20 lines · Paul Walmsley
Hi Greentime,
Quoted 11 lines · Paul Walmsley
Quoted 7 lines · Greentime Hu
The code in
secondary_parkis 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.Signed-off-by Greentime Hu <[email protected]>Reviewed-by Anup Patel <[email protected]>Thanks, the following is what's been queued for v5.5-rc.
During final testing, when building the kernel with an initramfs, I hit the following linker error:
Quoted 6 lines
LD .tmp_vmlinux1
arch/riscv/kernel/head.o: in function.L0 ':(.init.text+0x5c): relocation truncated to fit: R_RISCV_JAL against.Lsecondary_park' make[1]: *** [Makefile:1079: vmlinux] Error 1
make: *** [Makefile:326:__build_one_by_one] Error 2Could you take a look at this?
I think it is because the sections are too far for bqeu to jump and the config I used just small enough for it to jump so I didn't see this bug. Sorry about that.
I tried this fix to boot in Unleashed board.
#ifdef CONFIG_SMP
li t0, CONFIG_NR_CPUS
- bgeu a0, t0, .Lsecondary_park + blt a0, t0, .Lgood_cores + tail .Lsecondary_park
+.Lgood_cores:
#endif
Hi Greentime,
Quoted 3 lines · Greentime Hu
I think it is because the sections are too far for bqeu to jump and the config I used just small enough for it to jump so I didn't see this bug. Sorry about that.
No problem.
Review
Quoted 9 lines
I tried this fix to boot in Unleashed board.
#ifdef
CONFIG_SMP
li t0,CONFIG_NR_CPUS(quoted diff) +3
-1- bgeu a0, t0, .Lsecondary_park + blt a0, t0, .Lgood_cores + tail .Lsecondary_park +.Lgood_cores: #endif
Looks reasonable to me. Care to update and repost the patch?
- Paul
Quoted 21 lines · Paul Walmsley
Hi Greentime,
Quoted 3 lines · Greentime Hu
I think it is because the sections are too far for bqeu to jump and the config I used just small enough for it to jump so I didn't see this bug. Sorry about that.
No problem.
Review
Quoted 9 lines
I tried this fix to boot in Unleashed board.
#ifdef
CONFIG_SMP
li t0,CONFIG_NR_CPUS(quoted diff) +3
-1- bgeu a0, t0, .Lsecondary_park + blt a0, t0, .Lgood_cores + tail .Lsecondary_park +.Lgood_cores: #endif
Quoted 1 line
Looks reasonable to me. Care to update and repost the patch?
Yes, Paul. I have sent the v4 patch.
It is tested in Unleashed board.