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