Skip to content

Commit f40cab8

Browse files
SiFiveHollandpalmer-dabbelt
authored andcommitted
riscv: Fix SMP when shadow call stacks are enabled
This fixes two bugs in SCS initialization for secondary CPUs. First, the SCS was not initialized at all in the spinwait boot path. Second, the code for the SBI HSM path attempted to initialize the SCS before enabling the MMU. However, that involves dereferencing the thread pointer, which requires the MMU to be enabled. Fix both issues by setting up the SCS in the common secondary entry path, after enabling the MMU. Fixes: d1584d7 ("riscv: Implement Shadow Call Stack") Signed-off-by: Samuel Holland <[email protected]> Reviewed-by: Sami Tolvanen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 96ba4a4 commit f40cab8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/riscv/kernel/head.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ secondary_start_sbi:
154154
XIP_FIXUP_OFFSET a3
155155
add a3, a3, a1
156156
REG_L sp, (a3)
157-
scs_load_current
158157

159158
.Lsecondary_start_common:
160159

@@ -165,6 +164,7 @@ secondary_start_sbi:
165164
call relocate_enable_mmu
166165
#endif
167166
call .Lsetup_trap_vector
167+
scs_load_current
168168
tail smp_callin
169169
#endif /* CONFIG_SMP */
170170

0 commit comments

Comments
 (0)