From 1fa457371a09e219c7673fe7744bcbe382350463 Mon Sep 17 00:00:00 2001 From: Soren Ptak Date: Tue, 16 Jan 2024 11:47:58 -0500 Subject: [PATCH 1/4] Add a check for if xSchedulerRunning is false to portable/GCC/ARM_CM3_MPU/port.c:xPortIsAuthorizedToAccessBuffer() --- portable/GCC/ARM_CM3_MPU/port.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/portable/GCC/ARM_CM3_MPU/port.c b/portable/GCC/ARM_CM3_MPU/port.c index d8c18325c4d..9d3285c3031 100644 --- a/portable/GCC/ARM_CM3_MPU/port.c +++ b/portable/GCC/ARM_CM3_MPU/port.c @@ -1352,7 +1352,15 @@ BaseType_t xPortIsAuthorizedToAccessBuffer( const void * pvBuffer, BaseType_t xAccessGranted = pdFALSE; const xMPU_SETTINGS * xTaskMpuSettings = xTaskGetMPUSettings( NULL ); /* Calling task's MPU settings. */ - if( ( xTaskMpuSettings->ulTaskFlags & portTASK_IS_PRIVILEGED_FLAG ) == portTASK_IS_PRIVILEGED_FLAG ) + if( xSchedulerRunning == pdFALSE ) + { + /* Grant access to all the kernel objects before the scheduler + * is started. It is necessary because there is no task running + * yet and therefore, we cannot use the permissions of any + * task. */ + xAccessGranted = pdTRUE; + } + else if( ( xTaskMpuSettings->ulTaskFlags & portTASK_IS_PRIVILEGED_FLAG ) == portTASK_IS_PRIVILEGED_FLAG ) { xAccessGranted = pdTRUE; } From 99df2d2aae9d04ee9246ae4e9a3e656200163fbe Mon Sep 17 00:00:00 2001 From: Soren Ptak Date: Tue, 16 Jan 2024 11:48:38 -0500 Subject: [PATCH 2/4] Add a check for if xSchedulerRunning is false to portable/GCC/ARM_CM4_MPU/port.c:xPortIsAuthorizedToAccessBuffer() --- portable/GCC/ARM_CM4_MPU/port.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/portable/GCC/ARM_CM4_MPU/port.c b/portable/GCC/ARM_CM4_MPU/port.c index 0775cfbf899..ce234c455d1 100644 --- a/portable/GCC/ARM_CM4_MPU/port.c +++ b/portable/GCC/ARM_CM4_MPU/port.c @@ -1523,7 +1523,15 @@ BaseType_t xPortIsAuthorizedToAccessBuffer( const void * pvBuffer, BaseType_t xAccessGranted = pdFALSE; const xMPU_SETTINGS * xTaskMpuSettings = xTaskGetMPUSettings( NULL ); /* Calling task's MPU settings. */ - if( ( xTaskMpuSettings->ulTaskFlags & portTASK_IS_PRIVILEGED_FLAG ) == portTASK_IS_PRIVILEGED_FLAG ) + if( xSchedulerRunning == pdFALSE ) + { + /* Grant access to all the kernel objects before the scheduler + * is started. It is necessary because there is no task running + * yet and therefore, we cannot use the permissions of any + * task. */ + xAccessGranted = pdTRUE; + } + else if( ( xTaskMpuSettings->ulTaskFlags & portTASK_IS_PRIVILEGED_FLAG ) == portTASK_IS_PRIVILEGED_FLAG ) { xAccessGranted = pdTRUE; } From 09e741faf1731f058570158b55b0d46541bea160 Mon Sep 17 00:00:00 2001 From: Soren Ptak Date: Tue, 16 Jan 2024 11:48:47 -0500 Subject: [PATCH 3/4] Add a check for if xSchedulerRunning is false to portable/IAR/ARM_CM4F_MPU/port.c:xPortIsAuthorizedToAccessBuffer() --- portable/IAR/ARM_CM4F_MPU/port.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/portable/IAR/ARM_CM4F_MPU/port.c b/portable/IAR/ARM_CM4F_MPU/port.c index c3bab2671cf..a682a9d87d6 100644 --- a/portable/IAR/ARM_CM4F_MPU/port.c +++ b/portable/IAR/ARM_CM4F_MPU/port.c @@ -1253,7 +1253,15 @@ BaseType_t xPortIsAuthorizedToAccessBuffer( const void * pvBuffer, BaseType_t xAccessGranted = pdFALSE; const xMPU_SETTINGS * xTaskMpuSettings = xTaskGetMPUSettings( NULL ); /* Calling task's MPU settings. */ - if( ( xTaskMpuSettings->ulTaskFlags & portTASK_IS_PRIVILEGED_FLAG ) == portTASK_IS_PRIVILEGED_FLAG ) + if( xSchedulerRunning == pdFALSE ) + { + /* Grant access to all the kernel objects before the scheduler + * is started. It is necessary because there is no task running + * yet and therefore, we cannot use the permissions of any + * task. */ + xAccessGranted = pdTRUE; + } + else if( ( xTaskMpuSettings->ulTaskFlags & portTASK_IS_PRIVILEGED_FLAG ) == portTASK_IS_PRIVILEGED_FLAG ) { xAccessGranted = pdTRUE; } From 432ef9c96ab54ee49e44107afa23e70766e5622e Mon Sep 17 00:00:00 2001 From: Soren Ptak Date: Tue, 16 Jan 2024 11:48:58 -0500 Subject: [PATCH 4/4] Add a check for if xSchedulerRunning is false to portable/RVDS/ARM_CM4_MPU/port.c:xPortIsAuthorizedToAccessBuffer() --- portable/RVDS/ARM_CM4_MPU/port.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/portable/RVDS/ARM_CM4_MPU/port.c b/portable/RVDS/ARM_CM4_MPU/port.c index af4ea632f03..364370109b6 100644 --- a/portable/RVDS/ARM_CM4_MPU/port.c +++ b/portable/RVDS/ARM_CM4_MPU/port.c @@ -1508,7 +1508,16 @@ BaseType_t xPortIsAuthorizedToAccessBuffer( const void * pvBuffer, BaseType_t xAccessGranted = pdFALSE; const xMPU_SETTINGS * xTaskMpuSettings = xTaskGetMPUSettings( NULL ); /* Calling task's MPU settings. */ - if( ( xTaskMpuSettings->ulTaskFlags & portTASK_IS_PRIVILEGED_FLAG ) == portTASK_IS_PRIVILEGED_FLAG ) + + if( xSchedulerRunning == pdFALSE ) + { + /* Grant access to all the kernel objects before the scheduler + * is started. It is necessary because there is no task running + * yet and therefore, we cannot use the permissions of any + * task. */ + xAccessGranted = pdTRUE; + } + else if( ( xTaskMpuSettings->ulTaskFlags & portTASK_IS_PRIVILEGED_FLAG ) == portTASK_IS_PRIVILEGED_FLAG ) { xAccessGranted = pdTRUE; }