Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 1 | .. _trusted_applications: |
| 2 | |
| 3 | #################### |
| 4 | Trusted Applications |
| 5 | #################### |
| 6 | There are two ways to implement Trusted Applications (TAs), Pseudo TAs and user |
| 7 | mode TAs. User mode TAs are full featured Trusted Applications as specified by |
| 8 | the :ref:`globalplatform_api` TEE specifications, these are simply the ones |
| 9 | people are referring to when they are saying "Trusted Applications" and in most |
| 10 | cases this is the preferred type of TA to write and use. |
| 11 | |
| 12 | .. _pta: |
| 13 | |
| 14 | Pseudo Trusted Applications |
| 15 | *************************** |
Etienne Carriere | 5ecb86a | 2020-06-03 18:47:45 +0200 | [diff] [blame] | 16 | A Pseudo Trusted Application is not a Trusted Application. A Pseudo TA is not a |
| 17 | specific entity. A Pseudo TA is an interface. It is an interface exposed by the |
| 18 | OP-TEE Core to its outer world: to secure client Trusted Applications and to |
| 19 | non-secure client entities. |
| 20 | |
Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 21 | These are implemented directly to the OP-TEE core tree in, e.g., |
Jerome Forissier | fa993db | 2019-09-13 15:58:53 +0200 | [diff] [blame] | 22 | ``core/pta`` and are built along with and statically built into the |
Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 23 | OP-TEE core blob. |
| 24 | |
| 25 | The Pseudo Trusted Applications included in OP-TEE already are OP-TEE secure |
| 26 | privileged level services hidden behind a "GlobalPlatform TA Client" API. These |
| 27 | Pseudo TAs are used for various purposes such as specific secure services or |
| 28 | embedded tests services. |
| 29 | |
| 30 | Pseudo TAs **do not** benefit from the GlobalPlatform Core Internal API support |
| 31 | specified by the GlobalPlatform TEE specs. These APIs are provided to TAs as a |
| 32 | static library each TA shall link against (the ":ref:`libutee`") and that calls |
| 33 | OP-TEE core service through system calls. As OP-TEE core does not link with |
| 34 | :ref:`libutee`, Pseudo TAs can **only** use the OP-TEE core internal APIs and |
| 35 | routines. |
| 36 | |
| 37 | As Pseudo TAs runs at the same privileged execution level as the OP-TEE core |
| 38 | code itself and that might or might not be desirable depending on the use case. |
| 39 | |
| 40 | In most cases an unprivileged (user mode) TA is the best choice instead of |
| 41 | adding your code directly to the OP-TEE core. However if you decide your |
| 42 | application is best handled directly in OP-TEE core like this, you can look at |
Jerome Forissier | fa993db | 2019-09-13 15:58:53 +0200 | [diff] [blame] | 43 | ``core/pta/stats.c`` as a template and just add your Pseudo TA based on |
Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 44 | that to the ``sub.mk`` in the same directory. |
| 45 | |
| 46 | .. _user_mode_ta: |
| 47 | |
| 48 | User Mode Trusted Applications |
| 49 | ****************************** |
| 50 | User Mode Trusted Applications are loaded (mapped into memory) by OP-TEE core in |
| 51 | the Secure World when something in Rich Execution Environment (REE) wants to |
| 52 | talk to that particular application UUID. They run at a lower CPU privilege |
| 53 | level than OP-TEE core code. In that respect, they are quite similar to regular |
| 54 | applications running in the REE, except that they execute in Secure World. |
| 55 | |
| 56 | Trusted Application benefit from the GlobalPlatform :ref:`tee_internal_core_api` |
| 57 | as specified by the GlobalPlatform TEE specifications. There are several types |
| 58 | of user mode TAs, which differ by the way they are stored. |
| 59 | |
| 60 | TA locations |
| 61 | ************ |
| 62 | Plain TAs (user mode) can reside and be loaded from various places. There are |
| 63 | three ways currently supported in OP-TEE. |
| 64 | |
| 65 | .. _early_ta: |
| 66 | |
| 67 | Early TA |
| 68 | ======== |
| 69 | The so-called early TAs are virtually identical to the REE FS TAs, but instead |
| 70 | of being loaded from the Normal World file system, they are linked into a |
| 71 | special data section in the TEE core blob. Therefore, they are available even |
| 72 | before ``tee-supplicant`` and the REE's filesystems have come up. Please find |
| 73 | more details in the `early TA commit`_. |
| 74 | |
| 75 | .. _ree_fs_ta: |
| 76 | |
| 77 | REE filesystem TA |
| 78 | ================= |
Sumit Garg | de0c0c7 | 2020-04-17 13:15:30 +0530 | [diff] [blame] | 79 | They consist of a ELF_ file, signed and optionally encrypted, named from the |
| 80 | UUID of the TA and the suffix ``.ta``. They are built separately from the |
| 81 | OP-TEE core boot-time blob, although when they are built they use the same |
| 82 | build system, and are signed with the key from the build of the original OP-TEE |
| 83 | core blob. |
Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 84 | |
Sumit Garg | de0c0c7 | 2020-04-17 13:15:30 +0530 | [diff] [blame] | 85 | Because the TAs are signed and optionally encrypted with |
| 86 | ``scripts/sign_encrypt.py``, they are able to be stored in the untrusted REE |
Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 87 | filesystem, and ``tee-supplicant`` will take care of passing them to be checked |
Sumit Garg | de0c0c7 | 2020-04-17 13:15:30 +0530 | [diff] [blame] | 88 | and loaded by the Secure World OP-TEE core. |
Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 89 | |
Sumit Garg | de0c0c7 | 2020-04-17 13:15:30 +0530 | [diff] [blame] | 90 | REE-FS TA rollback protection |
| 91 | ----------------------------- |
| 92 | OP-TEE core maintains a ``ta_ver.db`` file in secure storage to check for |
| 93 | version of REE TAs as they are loaded from REE-FS in order to prevent against |
| 94 | any TA version downgrades. TA version can be configured via TA build option: |
| 95 | ``CFG_TA_VERSION=<unsigned integer>``. |
Jens Wiklander | 6054d68 | 2019-11-19 11:31:14 +0100 | [diff] [blame] | 96 | |
Sumit Garg | de0c0c7 | 2020-04-17 13:15:30 +0530 | [diff] [blame] | 97 | Note: Here rollback protection is effective only when ``CFG_RPMB_FS=y``. |
| 98 | |
| 99 | REE-FS TA formats |
| 100 | ----------------- |
| 101 | REE filesystem TAs come in three formats: |
| 102 | |
| 103 | 1. Legacy TAs signed, not encrypted, cannot be created anymore by the build |
| 104 | scripts since version 3.7.0. |
| 105 | |
| 106 | 2. Bootstrap TAs, signed with the key from the build of the original OP-TEE |
| 107 | core blob, not encrypted. |
| 108 | |
| 109 | 3. Encrypted TAs, sign-then-encrypt-then-MAC, encrypted with ``TA_ENC_KEY`` |
| 110 | when ``CFG_ENCRYPT_TA=y``. During OP-TEE runtime, the symmetric key used |
| 111 | to decrypt TA has to be provided in a platform specific manner via |
| 112 | overriding API: |
| 113 | |
| 114 | .. code-block:: c |
| 115 | |
| 116 | TEE_Result tee_otp_get_ta_enc_key(uint32_t key_type, uint8_t *buffer, |
| 117 | size_t len); |
| 118 | |
| 119 | REE-FS TA header structure |
| 120 | -------------------------- |
Jens Wiklander | 6054d68 | 2019-11-19 11:31:14 +0100 | [diff] [blame] | 121 | All REE filesystems TAs has common header, ``struct shdr``, defined as: |
| 122 | |
| 123 | .. code-block:: c |
| 124 | |
| 125 | enum shdr_img_type { |
| 126 | SHDR_TA = 0, |
| 127 | SHDR_BOOTSTRAP_TA = 1, |
Sumit Garg | de0c0c7 | 2020-04-17 13:15:30 +0530 | [diff] [blame] | 128 | SHDR_ENCRYPTED_TA = 2, |
Jens Wiklander | 6054d68 | 2019-11-19 11:31:14 +0100 | [diff] [blame] | 129 | }; |
| 130 | |
| 131 | #define SHDR_MAGIC 0x4f545348 |
| 132 | |
| 133 | /** |
| 134 | * struct shdr - signed header |
| 135 | * @magic: magic number must match SHDR_MAGIC |
| 136 | * @img_type: image type, values defined by enum shdr_img_type |
| 137 | * @img_size: image size in bytes |
| 138 | * @algo: algorithm, defined by public key algorithms TEE_ALG_* |
| 139 | * from TEE Internal API specification |
| 140 | * @hash_size: size of the signed hash |
| 141 | * @sig_size: size of the signature |
| 142 | * @hash: hash of an image |
| 143 | * @sig: signature of @hash |
| 144 | */ |
| 145 | struct shdr { |
| 146 | uint32_t magic; |
| 147 | uint32_t img_type; |
| 148 | uint32_t img_size; |
| 149 | uint32_t algo; |
| 150 | uint16_t hash_size; |
| 151 | uint16_t sig_size; |
| 152 | /* |
| 153 | * Commented out element used to visualize the layout dynamic part |
| 154 | * of the struct. |
| 155 | * |
| 156 | * hash is accessed through the macro SHDR_GET_HASH and |
| 157 | * signature is accessed through the macro SHDR_GET_SIG |
| 158 | * |
| 159 | * uint8_t hash[hash_size]; |
| 160 | * uint8_t sig[sig_size]; |
| 161 | */ |
| 162 | }; |
| 163 | |
| 164 | #define SHDR_GET_SIZE(x) (sizeof(struct shdr) + (x)->hash_size + \ |
| 165 | (x)->sig_size) |
| 166 | #define SHDR_GET_HASH(x) (uint8_t *)(((struct shdr *)(x)) + 1) |
| 167 | #define SHDR_GET_SIG(x) (SHDR_GET_HASH(x) + (x)->hash_size) |
| 168 | |
| 169 | |
Jens Wiklander | a6315cd | 2019-11-19 14:34:30 +0100 | [diff] [blame] | 170 | The field ``img_type`` tells the type of TA, if it's ``SHDR_TA`` (0), |
Jens Wiklander | 6054d68 | 2019-11-19 11:31:14 +0100 | [diff] [blame] | 171 | it's a legacy TA. If it's ``SHDR_BOOTSTRAP_TA`` (1) it's a bootstrap TA. |
| 172 | |
Jens Wiklander | a6315cd | 2019-11-19 14:34:30 +0100 | [diff] [blame] | 173 | The field ``algo`` tells the algorithm used. The script used to sign TAs |
| 174 | currently uses ``TEE_ALG_RSASSA_PKCS1_V1_5_SHA256`` (0x70004830). This |
| 175 | means RSA with PKCS#1v1.5 padding and SHA-256 hash function. OP-TEE accepts |
| 176 | any of the ``TEE_ALG_RSASSA_PKCS1_*`` algorithms. |
| 177 | |
Jens Wiklander | 6054d68 | 2019-11-19 11:31:14 +0100 | [diff] [blame] | 178 | For bootstrap TAs ``struct shdr`` is followed by a subheader, ``struct |
| 179 | shdr_bootstrap_ta`` which is defined as: |
| 180 | |
| 181 | .. code-block:: c |
| 182 | |
| 183 | /** |
| 184 | * struct shdr_bootstrap_ta - bootstrap TA subheader |
| 185 | * @uuid: UUID of the TA |
| 186 | * @ta_version: Version of the TA |
| 187 | */ |
| 188 | struct shdr_bootstrap_ta { |
| 189 | uint8_t uuid[sizeof(TEE_UUID)]; |
| 190 | uint32_t ta_version; |
| 191 | }; |
| 192 | |
| 193 | The fields ``uuid`` and ``ta_version`` allows extra checks to be performed |
| 194 | when loading the TA. Currently only the ``uuid`` field is checked. |
| 195 | |
Sumit Garg | de0c0c7 | 2020-04-17 13:15:30 +0530 | [diff] [blame] | 196 | For encrypted TAs ``struct shdr`` is followed by a subheader, ``struct |
| 197 | shdr_bootstrap_ta`` which is followed by another subheader, ``struct |
| 198 | shdr_encrypted_ta`` defined as: |
| 199 | |
| 200 | .. code-block:: c |
| 201 | |
| 202 | /** |
| 203 | * struct shdr_encrypted_ta - encrypted TA header |
| 204 | * @enc_algo: authenticated encyption algorithm, defined by symmetric key |
| 205 | * algorithms TEE_ALG_* from TEE Internal API |
| 206 | * specification |
| 207 | * @flags: authenticated encyption flags |
| 208 | * @iv_size: size of the initialization vector |
| 209 | * @tag_size: size of the authentication tag |
| 210 | * @iv: initialization vector |
| 211 | * @tag: authentication tag |
| 212 | */ |
| 213 | struct shdr_encrypted_ta { |
| 214 | uint32_t enc_algo; |
| 215 | uint32_t flags; |
| 216 | uint16_t iv_size; |
| 217 | uint16_t tag_size; |
| 218 | /* |
| 219 | * Commented out element used to visualize the layout dynamic part |
| 220 | * of the struct. |
| 221 | * |
| 222 | * iv is accessed through the macro SHDR_ENC_GET_IV and |
| 223 | * tag is accessed through the macro SHDR_ENC_GET_TAG |
| 224 | * |
| 225 | * uint8_t iv[iv_size]; |
| 226 | * uint8_t tag[tag_size]; |
| 227 | */ |
| 228 | }; |
| 229 | |
| 230 | The field ``enc_algo`` tells the algorithm used. The script used to encrypt |
| 231 | TAs currently uses ``TEE_ALG_AES_GCM`` (0x40000810). OP-TEE core also accepts |
| 232 | ``TEE_ALG_AES_CCM`` algorithm. |
| 233 | |
| 234 | The field ``flags`` supports a single flag to tell encryption key type which |
| 235 | is defined as: |
| 236 | |
| 237 | .. code-block:: c |
| 238 | |
| 239 | #define SHDR_ENC_KEY_TYPE_MASK 0x1 |
| 240 | |
| 241 | enum shdr_enc_key_type { |
| 242 | SHDR_ENC_KEY_DEV_SPECIFIC = 0, |
| 243 | SHDR_ENC_KEY_CLASS_WIDE = 1, |
| 244 | }; |
| 245 | |
| 246 | REE-FS TA binary formats |
| 247 | ------------------------ |
| 248 | TA binary follows the ELF file which normally is stripped as additional |
| 249 | symbols etc will be ignored when loading the TA. |
Jens Wiklander | 6054d68 | 2019-11-19 11:31:14 +0100 | [diff] [blame] | 250 | |
| 251 | Legacy TA binary is formatted as: |
| 252 | |
| 253 | .. code-block:: none |
| 254 | |
| 255 | hash = H(<struct shdr> || <stripped ELF>) |
| 256 | signature = RSA-Sign(hash) |
| 257 | legacy_binary = <struct shdr> || <hash> || <signature> || <stripped ELF> |
| 258 | |
| 259 | Bootstrap TA binary is formatted as: |
| 260 | |
| 261 | .. code-block:: none |
| 262 | |
| 263 | hash = H(<struct shdr> || <struct shdr_bootstrap_ta> || <stripped ELF>) |
| 264 | signature = RSA-Sign(<hash>) |
| 265 | bootstrap_binary = <struct shdr> || <hash> || <signature> || |
| 266 | <struct shdr_bootstrap_ta> || <stripped ELF> |
| 267 | |
Sumit Garg | de0c0c7 | 2020-04-17 13:15:30 +0530 | [diff] [blame] | 268 | Encrypted TA binary is formatted as: |
| 269 | |
| 270 | .. code-block:: none |
| 271 | |
| 272 | nonce = <unique random value> |
| 273 | ciphertext, tag = AES_GCM(<stripped ELF>) |
| 274 | hash = H(<struct shdr> || <struct shdr_bootstrap_ta> || |
| 275 | <struct shdr_encrypted_ta> || <nonce> || <tag> || <stripped ELF>) |
| 276 | signature = RSA-Sign(<hash>) |
| 277 | encrypted_binary = <struct shdr> || <hash> || <signature> || |
| 278 | <struct shdr_bootstrap_ta> || |
| 279 | <struct shdr_encrypted_ta> || <nonce> || <tag> || |
| 280 | <ciphertext> |
| 281 | |
| 282 | Loading REE-FS TA |
| 283 | ----------------- |
Jens Wiklander | 6054d68 | 2019-11-19 11:31:14 +0100 | [diff] [blame] | 284 | A REE TA is loaded into shared memory using a series or RPC in |
| 285 | :ref:`load_ree_ta`. The payload memory is allocated via TEE-supplicant and |
| 286 | later freed when the TA has been loaded into secure memory in |
| 287 | :ref:`free_appl_shm`. |
| 288 | |
| 289 | .. _load_ree_ta: |
| 290 | |
| 291 | .. figure:: ../images/trusted_applications/load_ree_ta.png |
| 292 | :figclass: align-center |
| 293 | |
| 294 | Loading a REE TA into nonsecure shared memory |
| 295 | |
| 296 | .. _free_appl_shm: |
| 297 | |
| 298 | .. figure:: ../images/trusted_applications/free_appl_shm.png |
| 299 | :figclass: align-center |
| 300 | |
| 301 | Freeing previously allocated nonsecure shared memory |
| 302 | |
| 303 | |
Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 304 | .. _secure_storage_ta: |
| 305 | |
| 306 | Secure Storage TA |
| 307 | ================= |
| 308 | These are stored in secure storage. The meta data is stored in a database of all |
| 309 | installed TAs and the actual binary is stored encrypted and integrity protected |
| 310 | as a separate file in the untrusted REE filesystem (flash). Before these TAs can |
| 311 | be loaded they have to be installed first, this is something that can be done |
| 312 | during initial deployment or at a later stage. |
| 313 | |
| 314 | For test purposes the test program xtest can install a TA into secure storage |
| 315 | with the command: |
| 316 | |
| 317 | .. code-block:: bash |
| 318 | |
| 319 | $ xtest --install-ta |
| 320 | |
Jens Wiklander | 6b67a66 | 2019-11-25 10:58:46 +0100 | [diff] [blame] | 321 | TAs stored in secure storage are kept in a TA database. The TA database |
| 322 | consists of a single file with the name ``dirf.db`` which is stored either |
| 323 | in the REE filesystem based secure storage or in RPMB. The file is |
| 324 | encrypted and integrity protected as any other object in secure storage. |
| 325 | The TAs themselves are not stored in ``dirf.db``, they are instead stored |
| 326 | in the REE filesystem encrypted and integrity protected. One reason for |
| 327 | this is that TAs can potentially be quite large, several megabytes, while |
| 328 | secure storage is designed to hold only small objects counted in kilobytes. |
| 329 | |
| 330 | ``dirf.db`` constsist of an array of ``struct tadb_entry``, defined as: |
| 331 | |
| 332 | .. code-block:: C |
| 333 | |
| 334 | /* |
| 335 | * struct tee_tadb_property |
| 336 | * @uuid: UUID of Trusted Application (TA) or Security Domain (SD) |
| 337 | * @version: Version of TA or SD |
| 338 | * @custom_size:Size of customized properties, prepended to the encrypted |
| 339 | * TA binary |
| 340 | * @bin_size: Size of the binary TA |
| 341 | */ |
| 342 | struct tee_tadb_property { |
| 343 | TEE_UUID uuid; |
| 344 | uint32_t version; |
| 345 | uint32_t custom_size; |
| 346 | uint32_t bin_size; |
| 347 | }; |
| 348 | |
| 349 | #define TADB_IV_SIZE TEE_AES_BLOCK_SIZE |
| 350 | #define TADB_TAG_SIZE TEE_AES_BLOCK_SIZE |
| 351 | #define TADB_KEY_SIZE TEE_AES_MAX_KEY_SIZE |
| 352 | |
| 353 | /* |
| 354 | * struct tadb_entry - TA database entry |
| 355 | * @prop: properties of TA |
| 356 | * @file_number: encrypted TA is stored in <file_number>.ta |
| 357 | * @iv: Initialization vector of the authentication crypto |
| 358 | * @tag: Tag used to validate the authentication encrypted TA |
| 359 | * @key: Key used to decrypt the TA |
| 360 | */ |
| 361 | struct tadb_entry { |
| 362 | struct tee_tadb_property prop; |
| 363 | uint32_t file_number; |
| 364 | uint8_t iv[TADB_IV_SIZE]; |
| 365 | uint8_t tag[TADB_TAG_SIZE]; |
| 366 | uint8_t key[TADB_KEY_SIZE]; |
| 367 | }; |
| 368 | |
| 369 | Entries where the ``UUID`` consists of zeros only are not valid and are |
| 370 | ignored. The ``file_number`` field represents that name of the file stored |
| 371 | in the REE filesystem. The filename is made from the decimal string |
| 372 | representation of ``file_number`` with ``.ta`` appended, or if it was to be |
| 373 | printed: ``printf("%u.ta", file_number)``. |
| 374 | |
| 375 | The TA is decrypted using the authentication encryption algorithm AES-GCM |
| 376 | initialized with the ``iv`` and ``key`` fields, the ``tag`` field is used |
| 377 | when finalizing the decryption |
| 378 | |
| 379 | A TA is looked up in the TA database by opening ``dirf.db`` and scanning |
| 380 | through the elements which are of type ``struct tadb_entry`` until a |
| 381 | matching UUID is found. |
Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 382 | |
Jens Wiklander | a6315cd | 2019-11-19 14:34:30 +0100 | [diff] [blame] | 383 | Loading and preparing TA for execution |
| 384 | ************************************** |
| 385 | |
| 386 | User mode TAs are loaded into final memory in the same way using the user |
| 387 | mode ELF loader ``ldelf``. The different TA locations has a common |
| 388 | interface towards ``ldelf`` which makes the user mode operations identical |
| 389 | regarless of how the TA is stored. |
| 390 | |
| 391 | The TA is loaded into secure memory in :ref:`prepare_ta`. |
| 392 | |
| 393 | .. _prepare_ta: |
| 394 | |
| 395 | .. figure:: ../images/trusted_applications/prepare_ta.png |
| 396 | :figclass: align-center |
| 397 | |
| 398 | Preparing TA for execution |
| 399 | |
| 400 | After ``ldelf`` has returned with a TA prepared for execution it still |
| 401 | remains in memory to serve the TA if dlopen() and friends are used. |
| 402 | ``ldelf`` is also used to dump stack trace and detailed memory mappings if |
| 403 | a TA is terminated via an abort. |
| 404 | |
| 405 | A high level view of the entire flow from the client application in Linux |
| 406 | user space where a session is opened to a TA is given in |
| 407 | :ref:`open_session`. |
| 408 | |
| 409 | .. _open_session: |
| 410 | |
| 411 | .. figure:: ../images/trusted_applications/open_session.png |
| 412 | :figclass: align-center |
| 413 | |
| 414 | Open session to a TA |
| 415 | |
| 416 | |
Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 417 | .. _ta_properties: |
| 418 | |
| 419 | TA Properties |
| 420 | ************* |
| 421 | This section give a more in depth description of the TA properties (see |
| 422 | :ref:`build_trusted_applications` also). |
| 423 | |
Etienne Carriere | 2f459d1 | 2019-03-11 11:58:05 +0100 | [diff] [blame] | 424 | GlobalPlatform Properties |
| 425 | ========================= |
Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 426 | Standard TA properties must be defined through property flag in macro |
| 427 | ``TA_FLAGS`` in ``user_ta_header_defines.h`` |
| 428 | |
Etienne Carriere | 2f459d1 | 2019-03-11 11:58:05 +0100 | [diff] [blame] | 429 | Single Instance |
| 430 | --------------- |
Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 431 | ``"gpd.ta.singleInstance"`` is a boolean property of the TA. This property |
| 432 | defines if one instance of the TA must be created and will receive all open |
| 433 | session request, or if a new specific TA instance must be created for each |
| 434 | incoming open session request. OP-TEE TA flag ``TA_FLAG_SINGLE_INSTANCE`` sets |
| 435 | to configuration of this property. The boolean property is set to ``true`` if |
| 436 | ``TA_FLAGS`` sets bit ``TA_FLAG_SINGLE_INSTANCE``, otherwise the boolean |
| 437 | property is set to ``false``. |
| 438 | |
Etienne Carriere | 2f459d1 | 2019-03-11 11:58:05 +0100 | [diff] [blame] | 439 | Multi-session |
| 440 | ------------- |
Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 441 | ``"gpd.ta.multiSession"`` is a boolean property of the TA. This property defines |
| 442 | if the TA instance can handle several sessions. If disabled, TA instance support |
| 443 | only one session. In such case, if the TA already has a opened session, any open |
| 444 | session request will return with a busy error status. |
| 445 | |
| 446 | .. note:: |
| 447 | |
| 448 | This property is **meaningless** if TA is **NOT** SingleInstance TA. |
| 449 | |
| 450 | OP-TEE TA flag ``TA_FLAG_MULTI_SESSION`` sets to configuration of this property. |
| 451 | The boolean property is set to ``true`` if ``TA_FLAGS`` sets bit |
| 452 | ``TA_FLAG_MULTI_SESSION``, otherwise the boolean property is set to ``false``. |
| 453 | |
Etienne Carriere | 2f459d1 | 2019-03-11 11:58:05 +0100 | [diff] [blame] | 454 | Keep Alive |
| 455 | ---------- |
Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 456 | ``"gpd.ta.instanceKeepAlive"`` is a boolean property of the TA. This property |
| 457 | defines if the TA instance created must be destroyed or not when all sessions |
| 458 | opened towards the TA are closed. If the property is enabled, TA instance, once |
| 459 | created (at 1st open session request), is never removed unless the TEE itself is |
| 460 | restarted (boot/reboot). |
| 461 | |
| 462 | .. note:: |
| 463 | |
| 464 | This property is **meaningless** if TA is **NOT** SingleInstance TA. |
| 465 | |
| 466 | OP-TEE TA flag ``TA_FLAG_INSTANCE_KEEP_ALIVE`` sets to configuration of this |
| 467 | property. The boolean property is set to ``true`` if ``TA_FLAGS`` sets bit |
| 468 | ``TA_FLAG_INSTANCE_KEEP_ALIVE``, otherwise the boolean property is set to |
| 469 | ``false``. |
| 470 | |
Etienne Carriere | 2f459d1 | 2019-03-11 11:58:05 +0100 | [diff] [blame] | 471 | Heap Size |
| 472 | --------- |
Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 473 | ``"gpd.ta.dataSize"`` is a 32bit integer property of the TA. This property |
| 474 | defines the size in bytes of the TA allocation pool, in which ``TEE_Malloc()`` |
| 475 | and friends allocate memory. The value of the property must be defined by the |
| 476 | macro ``TA_DATA_SIZE`` in ``user_ta_header_defines.h`` (see |
| 477 | :ref:`build_ta_properties`). |
| 478 | |
Etienne Carriere | 2f459d1 | 2019-03-11 11:58:05 +0100 | [diff] [blame] | 479 | Stack Size |
| 480 | ---------- |
Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 481 | ``"gpd.ta.stackSize"`` is a 32bit integer property of the TA. This property |
| 482 | defines the size in bytes of the stack used for TA execution. The value of the |
| 483 | property must be defined by the macro ``TA_STACK_SIZE`` in |
| 484 | ``user_ta_header_defines.h`` (see :ref:`build_ta_properties`). |
| 485 | |
Etienne Carriere | 2f459d1 | 2019-03-11 11:58:05 +0100 | [diff] [blame] | 486 | Property Extensions |
| 487 | =================== |
Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 488 | |
Etienne Carriere | 2f459d1 | 2019-03-11 11:58:05 +0100 | [diff] [blame] | 489 | Secure Data Path Flag |
| 490 | --------------------- |
Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 491 | ``TA_FLAG_SECURE_DATA_PATH`` is a bit flag supported by ``TA_FLAGS``. This |
| 492 | property flag claims the secure data support from the OP-TEE OS for the TA. |
| 493 | Refer to the OP-TEE OS for secure data path support. TAs that do not set |
| 494 | ``TA_FLAG_SECURE_DATA_PATH`` in the value of ``TA_FLAGS`` will **not** be able |
| 495 | to handle memory reference invocation parameters that relate to secure data path |
| 496 | buffers. |
| 497 | |
Etienne Carriere | 5b99ccc | 2019-03-11 11:57:30 +0100 | [diff] [blame] | 498 | .. _ta_property_cache_maintenance: |
Etienne Carriere | 2f459d1 | 2019-03-11 11:58:05 +0100 | [diff] [blame] | 499 | |
| 500 | Cache maintenance Flag |
| 501 | ---------------------- |
Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 502 | ``TA_FLAG_CACHE_MAINTENANCE`` is a bit flag supported by ``TA_FLAGS``. This |
Etienne Carriere | 5b99ccc | 2019-03-11 11:57:30 +0100 | [diff] [blame] | 503 | property flag, when enabled, allows Trusted Applciation to use the cache |
| 504 | maintenance API extension of the Internal Core API described in |
| 505 | :ref:`extensions_cache_maintenance`. TAs that do not set |
| 506 | ``TA_FLAG_CACHE_MAINTENANCE`` in the value of their ``TA_FLAGS`` will not be |
| 507 | able to call the cache maintenance API. |
Etienne Carriere | 0ab5cc2 | 2019-03-11 10:44:13 +0100 | [diff] [blame] | 508 | |
Etienne Carriere | 2f459d1 | 2019-03-11 11:58:05 +0100 | [diff] [blame] | 509 | Deprecated Property Flags |
| 510 | ------------------------- |
Etienne Carriere | 0ab5cc2 | 2019-03-11 10:44:13 +0100 | [diff] [blame] | 511 | Older versions of OP-TEE used to define extended property flags that are |
| 512 | deprecated and meaningless to current OP-TEE. These are ``TA_FLAG_USER_MODE``, |
| 513 | ``TA_FLAG_EXEC_DDR`` and ``TA_FLAG_REMAP_SUPPORT``. |
Etienne Carriere | 2f459d1 | 2019-03-11 11:58:05 +0100 | [diff] [blame] | 514 | |
| 515 | .. _ELF: https://en.wikipedia.org/wiki/Executable_and_Linkable_Format |
| 516 | .. _early TA commit: https://github.com/OP-TEE/optee_os/commit/d0c636148b3a |