Commit graph

3207 commits

Author SHA1 Message Date
kar-rahul-aws 18ed8886fe [AUTO][RELEASE]: Update SBOM 2023-11-29 14:13:55 +00:00
kar-rahul-aws 650025f227 [AUTO][RELEASE]: Update version number in manifest.yml 2023-11-29 14:13:52 +00:00
kar-rahul-aws ef7b253b56 [AUTO][RELEASE]: Bump file header version to "10.6.2" 2023-11-29 14:13:51 +00:00
kar-rahul-aws a86ae9b06e [AUTO][RELEASE]: Bump task.h version macros to "10.6.2" 2023-11-29 14:13:50 +00:00
Rahul Kar dfa52a70c5
Update History.txt for V10.6.2 (#912)
* Update History.txt for V10.6.2
2023-11-29 19:42:18 +05:30
Gaurav-Aggarwal-AWS 2f66e475fa
Fix prototype of MPU_vTimerSetReloadMode (#911)
Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
2023-11-29 19:15:07 +05:30
Gaurav-Aggarwal-AWS 6b7d4cf41b
Add Access Control List to MPU ports (#897)
This PR adds Access Control to kernel objects on a per task basis to MPU
ports. The following needs to be defined in the `FreeRTOSConfig.h` to
enable this feature:

```c
```

This PR adds the following new APIs:

```c
void vGrantAccessToTask( TaskHandle_t xTask,
                         TaskHandle_t xTaskToGrantAccess );
void vRevokeAccessToTask( TaskHandle_t xTask,
                          TaskHandle_t xTaskToRevokeAccess );

void vGrantAccessToSemaphore( TaskHandle_t xTask,
                              SemaphoreHandle_t xSemaphoreToGrantAccess );
void vRevokeAccessToSemaphore( TaskHandle_t xTask,
                               SemaphoreHandle_t xSemaphoreToRevokeAccess );

void vGrantAccessToQueue( TaskHandle_t xTask,
                          QueueHandle_t xQueueToGrantAccess );
void vRevokeAccessToQueue( TaskHandle_t xTask,
                           QueueHandle_t xQueueToRevokeAccess );

void vGrantAccessToQueueSet( TaskHandle_t xTask,
                             QueueSetHandle_t xQueueSetToGrantAccess );
void vRevokeAccessToQueueSet( TaskHandle_t xTask,
                              QueueSetHandle_t xQueueSetToRevokeAccess );

void vGrantAccessToEventGroup( TaskHandle_t xTask,
                               EventGroupHandle_t xEventGroupToGrantAccess );
void vRevokeAccessToEventGroup( TaskHandle_t xTask,
                                EventGroupHandle_t xEventGroupToRevokeAccess );

void vGrantAccessToStreamBuffer( TaskHandle_t xTask,
                                 StreamBufferHandle_t xStreamBufferToGrantAccess );
void vRevokeAccessToStreamBuffer( TaskHandle_t xTask,
                                  StreamBufferHandle_t xStreamBufferToRevokeAccess );

void vGrantAccessToMessageBuffer( TaskHandle_t xTask,
                                  MessageBufferHandle_t xMessageBufferToGrantAccess );
void vRevokeAccessToMessageBuffer( TaskHandle_t xTask,
                                   MessageBufferHandle_t xMessageBufferToRevokeAccess );

void vGrantAccessToTimer( TaskHandle_t xTask,
                          TimerHandle_t xTimerToGrantAccess );
void vRevokeAccessToTimer( TaskHandle_t xTask,
                           TimerHandle_t xTimerToRevokeAccess );
```

An unprivileged task by default has access to itself only and no other
kernel object. The application writer needs to explicitly grant an
unprivileged task access to all the kernel objects it needs. The best
place to do that is before starting the scheduler when all the kernel
objects are created.

For example, let's say an unprivileged tasks needs access to a queue and
an event group, the application writer needs to do the following:

```c
vGrantAccessToQueue( xUnprivilegedTaskHandle, xQueue );
vGrantAccessToEventGroup( xUnprivilegedTaskHandle, xEventGroup );
```

The application writer MUST revoke all the accesses before deleting a
task. Failing to do so will result in undefined behavior. In the above
example, the application writer needs to make the following 2 calls
before deleting the task:

```c
vRevokeAccessToQueue( xUnprivilegedTaskHandle, xQueue );
vRevokeAccessToEventGroup( xUnprivilegedTaskHandle, xEventGroup );

```
2023-11-23 10:45:58 +05:30
Gaurav-Aggarwal-AWS 9bfd85a253
Update system call entry mechanism (#896)
Earlier the System Call entry from an unprivileged task looked like:

1. SVC for entering system call.
2. System call implementation.
3. SVC for exiting system call.

Now, the system call entry needs to make only one system call
and everything else is handled internally.

This PR also makes the following small changes:

1. Add one struct param for system calls with 5 parameters. This
   removes the need for special handling for system calls with 5
   parameters.
2. Remove raise privilege SVC when MPU wrapper v2 is used.
3. Add additional run time parameter checks to MPU wrappers
   for xTaskGenericNotify and xQueueTakeMutexRecursive APIs.

These changes are tested on the following platforms:
1. STM32H743ZI (Cortex-M7)
2. STM32L152RE (Cortex-M3)
3. Nuvoton M2351 (Cortex-M23)
4. NXP LPC55S69 (Cortex-M33)
2023-11-21 18:42:23 +05:30
Gaurav-Aggarwal-AWS 52c1c6e578
Covert object type check to runtime check (#847)
It was checked using assert earlier.

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
2023-10-20 22:08:19 +05:30
Rahul Kar d9fc48bced
Backport PR 839 to FreeRTOS-Kernel V10.6.1 (#840)
* Fix size alignment in the integer overflow issue

* Remove CORTEX_M3_MPS2_QEMU demo in the V10.6.x branch to sync with the main branch.
2023-10-19 11:21:27 +05:30
Gaurav-Aggarwal-AWS 7003ba73ed
Backport PR 836 to FreeRTOS-Kernel V10.6.1 (#837)
Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
2023-10-17 23:49:09 +05:30
kar-rahul-aws 0264280230 [AUTO][RELEASE]: Update SBOM 2023-08-17 17:14:08 +00:00
kar-rahul-aws ab6744c08c [AUTO][RELEASE]: Update version number in manifest.yml 2023-08-17 17:14:06 +00:00
kar-rahul-aws c5edc980c5 [AUTO][RELEASE]: Bump file header version to "10.6.1" 2023-08-17 17:14:06 +00:00
kar-rahul-aws 76a4a16800 [AUTO][RELEASE]: Bump task.h version macros to "10.6.1" 2023-08-17 17:14:04 +00:00
kar-rahul-aws 5678e7a27c
Update History.txt for V10.6.1 (#759)
Update History.txt for V10.6.1

Signed-off-by: kar-rahul-aws <karahulx@amazon.com>
2023-08-17 22:42:41 +05:30
kar-rahul-aws ace6b39fa0
Add runtime parameter checks (#758)
* Add runtime parameter checks

This commit adds runtime checks for function parameters
to mpu_wrappers_v2 file. The same checks are performed
in the API implementation using asserts.

Signed-off-by: kar-rahul-aws <karahulx@amazon.com>
2023-08-17 18:53:42 +05:30
kar-rahul-aws 0d871946ab
Update version number in manifest.yml (#756)
Add automation to update version number in manifest.yml. Also,
bring required commits from main.
2023-08-17 17:20:53 +05:30
kar-rahul-aws fe005419f0 Update SBOM 2023-07-13 11:45:34 +00:00
kar-rahul-aws aec827831a [AUTO][RELEASE]: Bump file header version to "10.6.0" 2023-07-13 11:45:32 +00:00
kar-rahul-aws 81a2a656d1 [AUTO][RELEASE]: Bump task.h version macros to "10.6.0" 2023-07-13 11:45:30 +00:00
kar-rahul-aws b60ab2fa14
Update History for Version 10.6.0 (#706)
Signed-off-by: kar-rahul-aws <karahulx@amazon.com>
2023-07-13 17:13:16 +05:30
kar-rahul-aws 97050a17aa
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.
2023-07-13 16:51:04 +05:30
Patrick Cook 18e2937239
Fix circular dependency in CMake project (#700)
* Fix circular dependency in cmake project

Fix for https://github.com/FreeRTOS/FreeRTOS-Kernel/issues/687
In order for custom ports to also break the cycle, they must link
against freertos_kernel_include instead of freertos_kernel.

* Simplify include path
2023-07-10 15:08:59 -07:00
chinglee-iot 77ec05e641
Update uxTaskGetSystemState for tasks in pending ready list (#702)
* Update uxTaskGetSystemState to sync with eTaskGetState
* Update in vTaskGetInfo for tasks in pending ready list should be in
  ready state.
2023-07-10 14:29:38 +08:00
chinglee-iot d0a490e491
Remove empty expression statement compiler warning (#692)
* Add do while( 0 ) loop for empty expression statement compiler warning
2023-07-06 10:44:24 +08:00
Joris Putcuyps 1c5eca348f
Fix #697: Missing portPOINTER_SIZE_TYPE definition for ATmega port (#698) 2023-06-29 11:18:51 -07:00
Evgeny Ermakov 891dcdf80a
Fix typos in comments for the AT91SAM7S port (#695)
Co-authored-by: RichardBarry <3073890+RichardBarry@users.noreply.github.com>
2023-06-26 11:13:10 -07:00
chinglee-iot 788f8cfd76
Update static stream buffer size check (#693)
* Use volatile size instead of sizeof directly to prevent always
  true/false warning
2023-06-26 15:44:33 +08:00
chinglee-iot aa012e8d82
Add constant type for portMAX_DELAY in port (#691)
Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
2023-06-26 10:49:59 +08:00
chinglee-iot 9a6284262e
Fix typo in check comment of configMAX_SYSCALL_INTERRUPT_PRIORITY (#690) 2023-06-21 15:05:18 +05:30
chinglee-iot 17a46c252f
Use portTASK_FUNCTION_PROTO to replace portNORETURN (#688)
* Use portTASK_FUNCTION_PROTO to replace portNORETURN
2023-06-12 16:17:17 +05:30
chinglee-iot 77d8086f1c
Fix clang warning in croutine and stream buffer (#686)
* Fix document warning in croutine
* Fix cast-qual warning in stream buffer
2023-06-12 17:44:23 +08:00
chinglee-iot 80f67449ba
Use UBaseType_t as interrupt mask (#689)
* Use UBaseType_t as interrupt mask
* Update GCC posix port to use UBaseType_t as interrupt mask
2023-06-12 17:33:52 +08:00
chinglee-iot 4a35c97fec
Remove __NVIC_PRIO_BITS and configPRIO_BITS check in port (#683)
* Remove __NVIC_PRIO_BITS and configPRIO_BITS check in CM3, CM4 and ARMv8.
* Add hardware not implemented bits check. These bits should be zero.

---------

Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
2023-06-08 10:52:08 +08:00
Aniruddha Kanhere d3c289fe5b
Add back croutines by reverting PR#590 (#685)
* Add croutines to the code base

* Add croutine changes to cmake, lexicon and readme

* Add croutine file to portable cmake file

* Add back more references from PR 591
2023-06-02 11:03:40 -07:00
Tony Josi d43680169b
Generates SBOM after source files are updated with release tag (#680)
* update source file with release version info before SBOM generation

* delete tag branch during cleanup
2023-05-31 15:34:18 +05:30
Gaurav-Aggarwal-AWS 953c1ee6cb
Fix eTaskGetState for pending ready tasks (#679)
This commit fixes eTaskGetState so that eReady is returned for pending ready
tasks.

Co-authored-by: Darian Leung <darian@espressif.com>
2023-05-25 16:33:10 +05:30
Gaurav-Aggarwal-AWS 97434a4e0c
Use the extended movx instruction instead of mov (#676)
The following is from the MSP430X instruction set -

```
MOVX.W Move source word to destination word.

The source operand is copied to the destination. The source operand is
not affected. Both operands may be located in the full address space.
```

The movx instruction allows both the operands to be located in the full
address space and therefore, works with large data model as well.

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
2023-05-15 23:29:04 +05:30
Devaraj Ranganna a07f649bd5
Armv8-M (except Cortex-M23) interrupt priority checking (#673)
* Armv8-M: Formatting changes

Signed-off-by: Devaraj Ranganna <devaraj.ranganna@arm.com>

* Armv8-M: Add support for interrupt priority check

FreeRTOS provides `FromISR` system calls which can be called directly
from interrupt service routines. It is crucial that the priority of
these ISRs is set to same or lower value (numerically higher) than that
of `configMAX_SYSCALL_INTERRUPT_PRIORITY`. For more information refer
to https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html.

Add a check to trigger an assert when an ISR with priority higher
(numerically lower) than `configMAX_SYSCALL_INTERRUPT_PRIORITY` calls
`FromISR` system calls if `configASSERT` macro is defined.

In addition, add a config option
`configQEMU_DISABLE_INTERRUPT_PRIO_BITS_CHECK` to disable interrupt
priority check while running on QEMU. Based on the discussion
https://gitlab.com/qemu-project/qemu/-/issues/1122, The interrupt
priority bits in QEMU do not match the real hardware. Therefore the
assert that checks the number of implemented bits and __NVIC_PRIO_BITS
will always fail. The config option
 `configQEMU_DISABLE_INTERRUPT_PRIO_BITS_CHECK` should be defined in the
`FreeRTOSConfig.h` for QEMU targets.

Signed-off-by: Devaraj Ranganna <devaraj.ranganna@arm.com>

* Use SHPR2 for calculating interrupt priority bits

This removes the dependency on the secure software to mark the interrupt
as non-secure.

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>

---------

Signed-off-by: Devaraj Ranganna <devaraj.ranganna@arm.com>
Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
Co-authored-by: Gaurav Aggarwal <aggarg@amazon.com>
Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
2023-05-11 09:41:00 -07:00
Monika Singh 9149af9a6f
Align StackSize and StackAddress for macOS (#674) 2023-05-10 12:11:52 +05:30
Gaurav-Aggarwal-AWS 153e52b729
Fix cast alignment warning (#669)
* Fix cast alignment warning

Without this change, the code produces the following warning when
compiled with `-Wcast-align` flag:

```
cast increases required alignment of target type
```

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
2023-05-08 23:01:26 +05:30
Sudeep Mohanty 4550780f0c
Updated tasks.c checks for scheduler suspension (#670)
This commit updates the checks for the variable uxSchedulerSuspended in
tasks.c module to use a uniform format.

Signed-off-by: Sudeep Mohanty <sudp.mohanty@gmail.com>
2023-05-08 12:27:28 +05:30
tcpluess eb00a535a1
Paranthesize expression-like macro (#668) 2023-04-28 14:05:56 -07:00
Paul Bartell c1980cedb1 tree-wide: Unify formatting of __cplusplus ifdefs 2023-04-25 11:32:08 -07:00
Paul Bartell 5f19e34f87 portable/ARM_CM0: Add xPortIsInsideInterrupt
Add missing xPortIsInsideInterrupt function to Cortex-M0 port.
2023-04-20 15:13:11 -07:00
Paul Bartell 714e543247 Format portmacro.h in arm CM0 ports 2023-04-20 15:13:11 -07:00
Paul Bartell 686b6e62eb
ARMv7M: Adjust implemented priority bit assertions (#665)
Adjust assertions related to the CMSIS __NVIC_PRIO_BITS and FreeRTOS
configPRIO_BITS configuration macros such that these macros specify the
minimum number of implemented priority bits supported by a config
build rather than the exact number of implemented priority bits.

Related to Qemu issue #1122
2023-04-20 10:54:54 +05:30
Vo Trung Chi aa987a3443
fix conversion warning (#658)
FreeRTOS-Kernel/portable/GCC/ARM_CM4F/port.c:399:41: error: conversion from 'uint32_t' {aka 'long unsigned int'} to 'uint8_t' {aka 'unsigned char'} may change value [-Werror=conversion]

Signed-off-by: Vo Trung Chi <chi.votrung@vn.bosch.com>
2023-04-04 08:10:54 -07:00
Nicolas 1b8a4244bd
add a missing comma (#651) 2023-03-29 18:53:45 +05:30