Skip to content

Commit 4d9f652

Browse files
authored
Add check for if the scheduler is running to MPU ports (#954)
* In the ARM_CM3_MPU and ARM_CM4_MPU Port function xPortIsAuthorizedToAccessBuffer() grant access to the buffer if xSchedulerRunning is false.
1 parent cf2366c commit 4d9f652

File tree

4 files changed

+37
-4
lines changed

4 files changed

+37
-4
lines changed

portable/GCC/ARM_CM3_MPU/port.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1380,7 +1380,15 @@ BaseType_t xPortIsAuthorizedToAccessBuffer( const void * pvBuffer,
13801380
BaseType_t xAccessGranted = pdFALSE;
13811381
const xMPU_SETTINGS * xTaskMpuSettings = xTaskGetMPUSettings( NULL ); /* Calling task's MPU settings. */
13821382

1383-
if( ( xTaskMpuSettings->ulTaskFlags & portTASK_IS_PRIVILEGED_FLAG ) == portTASK_IS_PRIVILEGED_FLAG )
1383+
if( xSchedulerRunning == pdFALSE )
1384+
{
1385+
/* Grant access to all the kernel objects before the scheduler
1386+
* is started. It is necessary because there is no task running
1387+
* yet and therefore, we cannot use the permissions of any
1388+
* task. */
1389+
xAccessGranted = pdTRUE;
1390+
}
1391+
else if( ( xTaskMpuSettings->ulTaskFlags & portTASK_IS_PRIVILEGED_FLAG ) == portTASK_IS_PRIVILEGED_FLAG )
13841392
{
13851393
xAccessGranted = pdTRUE;
13861394
}

portable/GCC/ARM_CM4_MPU/port.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1523,7 +1523,15 @@ BaseType_t xPortIsAuthorizedToAccessBuffer( const void * pvBuffer,
15231523
BaseType_t xAccessGranted = pdFALSE;
15241524
const xMPU_SETTINGS * xTaskMpuSettings = xTaskGetMPUSettings( NULL ); /* Calling task's MPU settings. */
15251525

1526-
if( ( xTaskMpuSettings->ulTaskFlags & portTASK_IS_PRIVILEGED_FLAG ) == portTASK_IS_PRIVILEGED_FLAG )
1526+
if( xSchedulerRunning == pdFALSE )
1527+
{
1528+
/* Grant access to all the kernel objects before the scheduler
1529+
* is started. It is necessary because there is no task running
1530+
* yet and therefore, we cannot use the permissions of any
1531+
* task. */
1532+
xAccessGranted = pdTRUE;
1533+
}
1534+
else if( ( xTaskMpuSettings->ulTaskFlags & portTASK_IS_PRIVILEGED_FLAG ) == portTASK_IS_PRIVILEGED_FLAG )
15271535
{
15281536
xAccessGranted = pdTRUE;
15291537
}

portable/IAR/ARM_CM4F_MPU/port.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1253,7 +1253,15 @@ BaseType_t xPortIsAuthorizedToAccessBuffer( const void * pvBuffer,
12531253
BaseType_t xAccessGranted = pdFALSE;
12541254
const xMPU_SETTINGS * xTaskMpuSettings = xTaskGetMPUSettings( NULL ); /* Calling task's MPU settings. */
12551255

1256-
if( ( xTaskMpuSettings->ulTaskFlags & portTASK_IS_PRIVILEGED_FLAG ) == portTASK_IS_PRIVILEGED_FLAG )
1256+
if( xSchedulerRunning == pdFALSE )
1257+
{
1258+
/* Grant access to all the kernel objects before the scheduler
1259+
* is started. It is necessary because there is no task running
1260+
* yet and therefore, we cannot use the permissions of any
1261+
* task. */
1262+
xAccessGranted = pdTRUE;
1263+
}
1264+
else if( ( xTaskMpuSettings->ulTaskFlags & portTASK_IS_PRIVILEGED_FLAG ) == portTASK_IS_PRIVILEGED_FLAG )
12571265
{
12581266
xAccessGranted = pdTRUE;
12591267
}

portable/RVDS/ARM_CM4_MPU/port.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1508,7 +1508,16 @@ BaseType_t xPortIsAuthorizedToAccessBuffer( const void * pvBuffer,
15081508
BaseType_t xAccessGranted = pdFALSE;
15091509
const xMPU_SETTINGS * xTaskMpuSettings = xTaskGetMPUSettings( NULL ); /* Calling task's MPU settings. */
15101510

1511-
if( ( xTaskMpuSettings->ulTaskFlags & portTASK_IS_PRIVILEGED_FLAG ) == portTASK_IS_PRIVILEGED_FLAG )
1511+
1512+
if( xSchedulerRunning == pdFALSE )
1513+
{
1514+
/* Grant access to all the kernel objects before the scheduler
1515+
* is started. It is necessary because there is no task running
1516+
* yet and therefore, we cannot use the permissions of any
1517+
* task. */
1518+
xAccessGranted = pdTRUE;
1519+
}
1520+
else if( ( xTaskMpuSettings->ulTaskFlags & portTASK_IS_PRIVILEGED_FLAG ) == portTASK_IS_PRIVILEGED_FLAG )
15121521
{
15131522
xAccessGranted = pdTRUE;
15141523
}

0 commit comments

Comments
 (0)