Skip to content

Commit 1a22ec5

Browse files
committed
Fix setting incorrect sp if single-hart
If single-hart is enabled, the sp is set to _stack_start - _hart_stack_size, rather than _stack_start. Fix this. Fixes: e540f1e ("Add feature single-hart") Signed-off-by: Chien Wong <[email protected]>
1 parent 448eec9 commit 1a22ec5

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

riscv-rt/src/asm.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,16 @@ _abs_start:
8585
.option push
8686
.option norelax
8787
la gp, __global_pointer$
88-
.option pop",
88+
.option pop
89+
// Allocate stacks",
8990
#[cfg(all(not(feature = "single-hart"), feature = "s-mode"))]
9091
"mv t2, a0 // the hartid is passed as parameter by SMODE",
9192
#[cfg(all(not(feature = "single-hart"), not(feature = "s-mode")))]
9293
"csrr t2, mhartid",
9394
#[cfg(not(feature = "single-hart"))]
9495
"lui t0, %hi(_max_hart_id)
9596
add t0, t0, %lo(_max_hart_id)
96-
bgtu t2, t0, abort",
97-
"// Allocate stacks
98-
la sp, _stack_start
97+
bgtu t2, t0, abort
9998
lui t0, %hi(_hart_stack_size)
10099
add t0, t0, %lo(_hart_stack_size)",
101100
#[cfg(all(not(feature = "single-hart"), riscvm))]
@@ -109,9 +108,10 @@ _abs_start:
109108
addi t1, t1, -1
110109
bnez t1, 1b
111110
2: ",
112-
"sub sp, sp, t0
113-
114-
// Set frame pointer
111+
"la sp, _stack_start",
112+
#[cfg(not(feature = "single-hart"))]
113+
"sub sp, sp, t0",
114+
"// Set frame pointer
115115
add s0, sp, zero
116116
117117
jal zero, _start_rust

0 commit comments

Comments
 (0)