bsps/riscv: Make SMP start more robust

In SMP configurations, check that we run on a configured processor.  If not,
then there is not much that can be done since we do not have a stack available
for this processor.  Just loop forever in this case.  Do this in assemlby to
ensure that no stack memory is used.
This commit is contained in:
Sebastian Huber
2023-03-16 08:31:08 +01:00
parent 0e773420f7
commit e5233057be
2 changed files with 15 additions and 6 deletions

View File

@@ -36,10 +36,7 @@ void bsp_start_on_secondary_processor(Per_CPU_Control *cpu_self)
cpu_index_self = _Per_CPU_Get_index(cpu_self);
if (
cpu_index_self < rtems_configuration_get_maximum_processors()
&& _SMP_Should_start_processor(cpu_index_self)
) {
if (_SMP_Should_start_processor(cpu_index_self)) {
set_csr(mie, MIP_MSIP | MIP_MEIP);
_SMP_Start_multitasking_on_secondary_processor(cpu_self);
} else {

View File

@@ -66,8 +66,17 @@ SYM(_start):
LADDR sp, _ISR_Stack_area_begin
LADDR t2, _ISR_Stack_size
csrr s0, mhartid
li t3, RISCV_BOOT_HARTID
sub s0, s0, t3
li t3, RISCV_BOOT_HARTID
sub s0, s0, t3
/*
* Check that this is a configured processor. If not, then there is
* not much that can be done since we do not have a stack available for
* this processor. Just loop forever in this case.
*/
LREG t3, _SMP_Processor_configured_maximum
bgeu s0, t3, .Lwfi
LADDR t0, _Per_CPU_Information
slli t1, s0, PER_CPU_CONTROL_SIZE_LOG2
add s1, t0, t1
@@ -100,6 +109,9 @@ SYM(_start):
tail boot_card
#ifdef RTEMS_SMP
.Lwfi:
wfi
j .Lwfi
.Lstart_on_secondary_processor: