[rtems commit] bsps/arm: More robust SMP start
Sebastian Huber
sebh at rtems.org
Thu Aug 12 08:04:03 UTC 2021
Module: rtems
Branch: master
Commit: 59472042ec0ef4b501df675f4df75e377994c92c
Changeset: http://git.rtems.org/rtems/commit/?id=59472042ec0ef4b501df675f4df75e377994c92c
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Wed Aug 4 14:21:34 2021 +0200
bsps/arm: More robust SMP start
Do not continue execution on processors which are not configured to prevent the
use of arbitrary memory for the initialization stack.
---
bsps/arm/fvp/start/bspstarthooks.c | 5 +----
bsps/arm/realview-pbx-a9/start/bspstarthooks.c | 6 +-----
bsps/arm/shared/start/start.S | 16 ++++++++++++++--
3 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/bsps/arm/fvp/start/bspstarthooks.c b/bsps/arm/fvp/start/bspstarthooks.c
index f0087ef..d5e5642 100644
--- a/bsps/arm/fvp/start/bspstarthooks.c
+++ b/bsps/arm/fvp/start/bspstarthooks.c
@@ -66,10 +66,7 @@ void bsp_start_hook_0( void )
* Prevent the fatal errors SMP_FATAL_MULTITASKING_START_ON_INVALID_PROCESSOR
* and SMP_FATAL_MULTITASKING_START_ON_UNASSIGNED_PROCESSOR this way.
*/
- if (
- cpu_index_self >= rtems_configuration_get_maximum_processors()
- || !_SMP_Should_start_processor( cpu_index_self )
- ) {
+ if ( !_SMP_Should_start_processor( cpu_index_self ) ) {
while ( true ) {
_ARM_Wait_for_event();
}
diff --git a/bsps/arm/realview-pbx-a9/start/bspstarthooks.c b/bsps/arm/realview-pbx-a9/start/bspstarthooks.c
index 1e386bf..9549e72 100644
--- a/bsps/arm/realview-pbx-a9/start/bspstarthooks.c
+++ b/bsps/arm/realview-pbx-a9/start/bspstarthooks.c
@@ -67,11 +67,7 @@ BSP_START_TEXT_SECTION void bsp_start_hook_0(void)
* the fatal errors SMP_FATAL_MULTITASKING_START_ON_INVALID_PROCESSOR and
* SMP_FATAL_MULTITASKING_START_ON_UNASSIGNED_PROCESSOR this way.
*/
- if (
- cpu_index_self != 0 &&
- (cpu_index_self >= rtems_configuration_get_maximum_processors() ||
- !_SMP_Should_start_processor(cpu_index_self))
- ) {
+ if (cpu_index_self != 0 && !_SMP_Should_start_processor(cpu_index_self)) {
while (true) {
_ARM_Wait_for_event();
}
diff --git a/bsps/arm/shared/start/start.S b/bsps/arm/shared/start/start.S
index bc87e7b..55b5b8d 100644
--- a/bsps/arm/shared/start/start.S
+++ b/bsps/arm/shared/start/start.S
@@ -197,9 +197,21 @@ _start:
/* Read MPIDR and get current processor index */
mrc p15, 0, r7, c0, c0, 5
and r7, #0xff
-#endif
-#ifdef RTEMS_SMP
+ /*
+ * Check that this is a configured processor. If not, then there is
+ * not much what can be done since we do not have a stack available for
+ * this processor. Just loop forever in this case.
+ */
+ ldr r1, =_SMP_Processor_configured_maximum
+ ldr r1, [r1]
+ cmp r1, r7
+ bgt .Lconfigured_processor
+.Linvalid_processor_wait_for_ever:
+ wfe
+ b .Linvalid_processor_wait_for_ever
+.Lconfigured_processor:
+
/*
* Get current per-CPU control and store it in PL1 only Thread ID
* Register (TPIDRPRW).
More information about the vc
mailing list