]> begriffs open source - freertos/commit
Memory Protection Unit (MPU) Enhancements (#705)
authorkar-rahul-aws <118818625+kar-rahul-aws@users.noreply.github.com>
Thu, 13 Jul 2023 11:21:04 +0000 (16:51 +0530)
committerGitHub <noreply@github.com>
Thu, 13 Jul 2023 11:21:04 +0000 (16:51 +0530)
commit97050a17aa8ad5fd7a7789874b38083dbce1fb0b
tree8aeaae8581bdb4ad0870cb39fc478444bbfd2192
parent18e293723929da31c0395fb4c7f9187474058a6a
Memory Protection Unit (MPU) Enhancements (#705)

Memory Protection Unit (MPU) Enhancements

This commit introduces a new MPU wrapper that places additional
restrictions on unprivileged tasks. The following is the list of changes
introduced with the new MPU wrapper:

1. Opaque and indirectly verifiable integers for kernel object handles:
   All the kernel object handles (for example, queue handles) are now
   opaque integers. Previously object handles were raw pointers.

2. Saving the task context in Task Control Block (TCB): When a task is
   swapped out by the scheduler, the task's context is now saved in its
   TCB. Previously the task's context was saved on its stack.

3. Execute system calls on a separate privileged only stack: FreeRTOS
   system calls, which execute with elevated privilege, now use a
   separate privileged only stack. Previously system calls used the
   calling task's stack. The application writer can control the size of
   the system call stack using new configSYSTEM_CALL_STACK_SIZE config
   macro.

4. Memory bounds checks: FreeRTOS system calls which accept a pointer
   and de-reference it, now verify that the calling task has required
   permissions to access the memory location referenced by the pointer.

5. System call restrictions: The following system calls are no longer
   available to unprivileged tasks:
    - vQueueDelete
    - xQueueCreateMutex
    - xQueueCreateMutexStatic
    - xQueueCreateCountingSemaphore
    - xQueueCreateCountingSemaphoreStatic
    - xQueueGenericCreate
    - xQueueGenericCreateStatic
    - xQueueCreateSet
    - xQueueRemoveFromSet
    - xQueueGenericReset
    - xTaskCreate
    - xTaskCreateStatic
    - vTaskDelete
    - vTaskPrioritySet
    - vTaskSuspendAll
    - xTaskResumeAll
    - xTaskGetHandle
    - xTaskCallApplicationTaskHook
    - vTaskList
    - vTaskGetRunTimeStats
    - xTaskCatchUpTicks
    - xEventGroupCreate
    - xEventGroupCreateStatic
    - vEventGroupDelete
    - xStreamBufferGenericCreate
    - xStreamBufferGenericCreateStatic
    - vStreamBufferDelete
    - xStreamBufferReset
   Also, an unprivileged task can no longer use vTaskSuspend to suspend
   any task other than itself.

We thank the following people for their inputs in these enhancements:
- David Reiss of Meta Platforms, Inc.
- Lan Luo, Xinhui Shao, Yumeng Wei, Zixia Liu, Huaiyu Yan and Zhen Ling
  of School of Computer Science and Engineering, Southeast University,
  China.
- Xinwen Fu of Department of Computer Science, University of
  Massachusetts Lowell, USA.
- Yuequi Chen, Zicheng Wang, Minghao Lin of University of Colorado
  Boulder, USA.
123 files changed:
.github/lexicon.txt
include/FreeRTOS.h
include/mpu_prototypes.h
include/mpu_wrappers.h
include/portable.h
include/queue.h
include/task.h
portable/ARMv8M/copy_files.py
portable/ARMv8M/non_secure/port.c
portable/ARMv8M/non_secure/portable/GCC/ARM_CM23/mpu_wrappers_v2_asm.c [new file with mode: 0644]
portable/ARMv8M/non_secure/portable/GCC/ARM_CM23/portasm.c
portable/ARMv8M/non_secure/portable/GCC/ARM_CM23_NTZ/mpu_wrappers_v2_asm.c [new file with mode: 0644]
portable/ARMv8M/non_secure/portable/GCC/ARM_CM23_NTZ/portasm.c
portable/ARMv8M/non_secure/portable/GCC/ARM_CM33/mpu_wrappers_v2_asm.c [new file with mode: 0644]
portable/ARMv8M/non_secure/portable/GCC/ARM_CM33/portasm.c
portable/ARMv8M/non_secure/portable/GCC/ARM_CM33_NTZ/mpu_wrappers_v2_asm.c [new file with mode: 0644]
portable/ARMv8M/non_secure/portable/GCC/ARM_CM33_NTZ/portasm.c
portable/ARMv8M/non_secure/portable/IAR/ARM_CM23/mpu_wrappers_v2_asm.S [new file with mode: 0644]
portable/ARMv8M/non_secure/portable/IAR/ARM_CM23/portasm.s
portable/ARMv8M/non_secure/portable/IAR/ARM_CM23_NTZ/mpu_wrappers_v2_asm.S [new file with mode: 0644]
portable/ARMv8M/non_secure/portable/IAR/ARM_CM23_NTZ/portasm.s
portable/ARMv8M/non_secure/portable/IAR/ARM_CM33/mpu_wrappers_v2_asm.S [new file with mode: 0644]
portable/ARMv8M/non_secure/portable/IAR/ARM_CM33/portasm.s
portable/ARMv8M/non_secure/portable/IAR/ARM_CM33_NTZ/mpu_wrappers_v2_asm.S [new file with mode: 0644]
portable/ARMv8M/non_secure/portable/IAR/ARM_CM33_NTZ/portasm.s
portable/ARMv8M/non_secure/portmacrocommon.h
portable/Common/mpu_wrappers.c
portable/Common/mpu_wrappers_v2.c [new file with mode: 0644]
portable/GCC/ARM_CM23/non_secure/mpu_wrappers_v2_asm.c [new file with mode: 0644]
portable/GCC/ARM_CM23/non_secure/port.c
portable/GCC/ARM_CM23/non_secure/portasm.c
portable/GCC/ARM_CM23/non_secure/portmacrocommon.h
portable/GCC/ARM_CM23_NTZ/non_secure/mpu_wrappers_v2_asm.c [new file with mode: 0644]
portable/GCC/ARM_CM23_NTZ/non_secure/port.c
portable/GCC/ARM_CM23_NTZ/non_secure/portasm.c
portable/GCC/ARM_CM23_NTZ/non_secure/portmacrocommon.h
portable/GCC/ARM_CM33/non_secure/mpu_wrappers_v2_asm.c [new file with mode: 0644]
portable/GCC/ARM_CM33/non_secure/port.c
portable/GCC/ARM_CM33/non_secure/portasm.c
portable/GCC/ARM_CM33/non_secure/portmacrocommon.h
portable/GCC/ARM_CM33_NTZ/non_secure/mpu_wrappers_v2_asm.c [new file with mode: 0644]
portable/GCC/ARM_CM33_NTZ/non_secure/port.c
portable/GCC/ARM_CM33_NTZ/non_secure/portasm.c
portable/GCC/ARM_CM33_NTZ/non_secure/portmacrocommon.h
portable/GCC/ARM_CM35P/non_secure/mpu_wrappers_v2_asm.c [new file with mode: 0644]
portable/GCC/ARM_CM35P/non_secure/port.c
portable/GCC/ARM_CM35P/non_secure/portasm.c
portable/GCC/ARM_CM35P/non_secure/portmacrocommon.h
portable/GCC/ARM_CM35P_NTZ/non_secure/mpu_wrappers_v2_asm.c [new file with mode: 0644]
portable/GCC/ARM_CM35P_NTZ/non_secure/port.c
portable/GCC/ARM_CM35P_NTZ/non_secure/portasm.c
portable/GCC/ARM_CM35P_NTZ/non_secure/portmacrocommon.h
portable/GCC/ARM_CM3_MPU/mpu_wrappers_v2_asm.c [new file with mode: 0644]
portable/GCC/ARM_CM3_MPU/port.c
portable/GCC/ARM_CM3_MPU/portmacro.h
portable/GCC/ARM_CM4_MPU/mpu_wrappers_v2_asm.c [new file with mode: 0644]
portable/GCC/ARM_CM4_MPU/port.c
portable/GCC/ARM_CM4_MPU/portmacro.h
portable/GCC/ARM_CM55/non_secure/mpu_wrappers_v2_asm.c [new file with mode: 0644]
portable/GCC/ARM_CM55/non_secure/port.c
portable/GCC/ARM_CM55/non_secure/portasm.c
portable/GCC/ARM_CM55/non_secure/portmacrocommon.h
portable/GCC/ARM_CM55_NTZ/non_secure/mpu_wrappers_v2_asm.c [new file with mode: 0644]
portable/GCC/ARM_CM55_NTZ/non_secure/port.c
portable/GCC/ARM_CM55_NTZ/non_secure/portasm.c
portable/GCC/ARM_CM55_NTZ/non_secure/portmacrocommon.h
portable/GCC/ARM_CM85/non_secure/mpu_wrappers_v2_asm.c [new file with mode: 0644]
portable/GCC/ARM_CM85/non_secure/port.c
portable/GCC/ARM_CM85/non_secure/portasm.c
portable/GCC/ARM_CM85/non_secure/portmacrocommon.h
portable/GCC/ARM_CM85_NTZ/non_secure/mpu_wrappers_v2_asm.c [new file with mode: 0644]
portable/GCC/ARM_CM85_NTZ/non_secure/port.c
portable/GCC/ARM_CM85_NTZ/non_secure/portasm.c
portable/GCC/ARM_CM85_NTZ/non_secure/portmacrocommon.h
portable/IAR/ARM_CM23/non_secure/mpu_wrappers_v2_asm.S [new file with mode: 0644]
portable/IAR/ARM_CM23/non_secure/port.c
portable/IAR/ARM_CM23/non_secure/portasm.s
portable/IAR/ARM_CM23/non_secure/portmacrocommon.h
portable/IAR/ARM_CM23_NTZ/non_secure/mpu_wrappers_v2_asm.S [new file with mode: 0644]
portable/IAR/ARM_CM23_NTZ/non_secure/port.c
portable/IAR/ARM_CM23_NTZ/non_secure/portasm.s
portable/IAR/ARM_CM23_NTZ/non_secure/portmacrocommon.h
portable/IAR/ARM_CM33/non_secure/mpu_wrappers_v2_asm.S [new file with mode: 0644]
portable/IAR/ARM_CM33/non_secure/port.c
portable/IAR/ARM_CM33/non_secure/portasm.s
portable/IAR/ARM_CM33/non_secure/portmacrocommon.h
portable/IAR/ARM_CM33_NTZ/non_secure/mpu_wrappers_v2_asm.S [new file with mode: 0644]
portable/IAR/ARM_CM33_NTZ/non_secure/port.c
portable/IAR/ARM_CM33_NTZ/non_secure/portasm.s
portable/IAR/ARM_CM33_NTZ/non_secure/portmacrocommon.h
portable/IAR/ARM_CM35P/non_secure/mpu_wrappers_v2_asm.S [new file with mode: 0644]
portable/IAR/ARM_CM35P/non_secure/port.c
portable/IAR/ARM_CM35P/non_secure/portasm.s
portable/IAR/ARM_CM35P/non_secure/portmacrocommon.h
portable/IAR/ARM_CM35P_NTZ/non_secure/mpu_wrappers_v2_asm.S [new file with mode: 0644]
portable/IAR/ARM_CM35P_NTZ/non_secure/port.c
portable/IAR/ARM_CM35P_NTZ/non_secure/portasm.s
portable/IAR/ARM_CM35P_NTZ/non_secure/portmacrocommon.h
portable/IAR/ARM_CM4F_MPU/mpu_wrappers_v2_asm.S [new file with mode: 0644]
portable/IAR/ARM_CM4F_MPU/port.c
portable/IAR/ARM_CM4F_MPU/portasm.s
portable/IAR/ARM_CM4F_MPU/portmacro.h
portable/IAR/ARM_CM55/non_secure/mpu_wrappers_v2_asm.S [new file with mode: 0644]
portable/IAR/ARM_CM55/non_secure/port.c
portable/IAR/ARM_CM55/non_secure/portasm.s
portable/IAR/ARM_CM55/non_secure/portmacrocommon.h
portable/IAR/ARM_CM55_NTZ/non_secure/mpu_wrappers_v2_asm.S [new file with mode: 0644]
portable/IAR/ARM_CM55_NTZ/non_secure/port.c
portable/IAR/ARM_CM55_NTZ/non_secure/portasm.s
portable/IAR/ARM_CM55_NTZ/non_secure/portmacrocommon.h
portable/IAR/ARM_CM85/non_secure/mpu_wrappers_v2_asm.S [new file with mode: 0644]
portable/IAR/ARM_CM85/non_secure/port.c
portable/IAR/ARM_CM85/non_secure/portasm.s
portable/IAR/ARM_CM85/non_secure/portmacrocommon.h
portable/IAR/ARM_CM85_NTZ/non_secure/mpu_wrappers_v2_asm.S [new file with mode: 0644]
portable/IAR/ARM_CM85_NTZ/non_secure/port.c
portable/IAR/ARM_CM85_NTZ/non_secure/portasm.s
portable/IAR/ARM_CM85_NTZ/non_secure/portmacrocommon.h
portable/RVDS/ARM_CM4_MPU/mpu_wrappers_v2_asm.c [new file with mode: 0644]
portable/RVDS/ARM_CM4_MPU/port.c
portable/RVDS/ARM_CM4_MPU/portmacro.h
queue.c
tasks.c