Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 1 | ########################### |
| 2 | Non-Secure Identity Manager |
| 3 | ########################### |
Edison Ai | 1c266ae | 2019-03-20 11:21:21 +0800 | [diff] [blame] | 4 | The ID of the current application/thread is known by TF-M, and the SST service |
| 5 | queries the ID of the currently running client via a dedicated API. |
| 6 | |
| 7 | The identity of secure clients can be tracked by TF-M core, because it also |
| 8 | manages the contexts of the partitions. However to differentiate NS clients, it |
| 9 | relies on the services provided by the NS OS. |
| 10 | |
| 11 | Tracking of context changes are possible by relying on the NS OS calling the |
| 12 | Thread Context Management for Armv8-M TrustZone APIs, as described |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 13 | `here <https://www.keil.com/pack/doc/CMSIS/Core/html/group__context__trustzone__functions.html>`__ |
Edison Ai | 1c266ae | 2019-03-20 11:21:21 +0800 | [diff] [blame] | 14 | |
| 15 | However TF-M needs an extra API, to assign a client ID to the TZ context created |
| 16 | as a result of the |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 17 | ``TZ_MemoryId_t TZ_AllocModuleContext_S (TZ_ModuleId_t module)`` call. |
Edison Ai | 1c266ae | 2019-03-20 11:21:21 +0800 | [diff] [blame] | 18 | |
| 19 | To do this, the |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 20 | ``enum tfm_status_e tfm_register_client_id (int32_t ns_client_id)`` have to be |
Edison Ai | 1c266ae | 2019-03-20 11:21:21 +0800 | [diff] [blame] | 21 | called from an SVC handler, with the client ID of the currently running client. |
| 22 | |
| 23 | In the current implementation of TF-M, an SVC call is provided for the NS |
| 24 | clients to be called at the beginning of their main function. |
| 25 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 26 | ``SVC(SVC_TFM_NSPM_REGISTER_CLIENT_ID);`` |
Edison Ai | 1c266ae | 2019-03-20 11:21:21 +0800 | [diff] [blame] | 27 | |
| 28 | The SVC call handler of the above SVC maps the name of the current thread to a |
| 29 | hardcoded client id, and sends it to the TF-M core via the earlier discussed |
| 30 | API. |
| 31 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 32 | The mapping is implemented in ``interface/src/tfm_nspm_svc_handler.c``. |
Edison Ai | 1c266ae | 2019-03-20 11:21:21 +0800 | [diff] [blame] | 33 | |
| 34 | The system integrators **may** implement the non-secure ID mapping based on |
| 35 | their application/threat model. |
| 36 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 37 | In case the NS OS doesn't use the Thread Context Management for Armv8-M |
| 38 | TrustZone APIs, then TF-M considers the NS SW as a single client, and assigns a |
| 39 | client ID to it automatically. |
Edison Ai | 1c266ae | 2019-03-20 11:21:21 +0800 | [diff] [blame] | 40 | |
| 41 | -------------- |
| 42 | |
Gyorgy Szing | db9783c | 2019-04-17 21:08:48 +0200 | [diff] [blame] | 43 | *Copyright (c) 2018-2019, Arm Limited. All rights reserved.* |