Skip to content

Commit de5c6df

Browse files
lorcjenswi-linaro
authored andcommitted
tee: optee: Update protocol definitions
There were changes in REE<->OP-TEE ABI recently. Now ABI allows us to pass non-contiguous memory buffers as list of pages to OP-TEE. This can be achieved by using new parameter attribute OPTEE_MSG_ATTR_NONCONTIG. OP-TEE also is able to use all non-secure RAM for shared buffers. This new capability is enabled with OPTEE_SMC_SEC_CAP_DYNAMIC_SHM flag. This patch adds necessary definitions to the protocol definition files at Linux side. Signed-off-by: Volodymyr Babchuk <[email protected]> Signed-off-by: Jens Wiklander <[email protected]>
1 parent e0c69ae commit de5c6df

File tree

2 files changed

+39
-6
lines changed

2 files changed

+39
-6
lines changed

drivers/tee/optee/optee_msg.h

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,32 @@
6767
#define OPTEE_MSG_ATTR_META BIT(8)
6868

6969
/*
70-
* The temporary shared memory object is not physically contigous and this
71-
* temp memref is followed by another fragment until the last temp memref
72-
* that doesn't have this bit set.
70+
* Pointer to a list of pages used to register user-defined SHM buffer.
71+
* Used with OPTEE_MSG_ATTR_TYPE_TMEM_*.
72+
* buf_ptr should point to the beginning of the buffer. Buffer will contain
73+
* list of page addresses. OP-TEE core can reconstruct contiguous buffer from
74+
* that page addresses list. Page addresses are stored as 64 bit values.
75+
* Last entry on a page should point to the next page of buffer.
76+
* Every entry in buffer should point to a 4k page beginning (12 least
77+
* significant bits must be equal to zero).
78+
*
79+
* 12 least significant bints of optee_msg_param.u.tmem.buf_ptr should hold page
80+
* offset of the user buffer.
81+
*
82+
* So, entries should be placed like members of this structure:
83+
*
84+
* struct page_data {
85+
* uint64_t pages_array[OPTEE_MSG_NONCONTIG_PAGE_SIZE/sizeof(uint64_t) - 1];
86+
* uint64_t next_page_data;
87+
* };
88+
*
89+
* Structure is designed to exactly fit into the page size
90+
* OPTEE_MSG_NONCONTIG_PAGE_SIZE which is a standard 4KB page.
91+
*
92+
* The size of 4KB is chosen because this is the smallest page size for ARM
93+
* architectures. If REE uses larger pages, it should divide them to 4KB ones.
7394
*/
74-
#define OPTEE_MSG_ATTR_FRAGMENT BIT(9)
95+
#define OPTEE_MSG_ATTR_NONCONTIG BIT(9)
7596

7697
/*
7798
* Memory attributes for caching passed with temp memrefs. The actual value
@@ -94,6 +115,11 @@
94115
#define OPTEE_MSG_LOGIN_APPLICATION_USER 0x00000005
95116
#define OPTEE_MSG_LOGIN_APPLICATION_GROUP 0x00000006
96117

118+
/*
119+
* Page size used in non-contiguous buffer entries
120+
*/
121+
#define OPTEE_MSG_NONCONTIG_PAGE_SIZE 4096
122+
97123
/**
98124
* struct optee_msg_param_tmem - temporary memory reference parameter
99125
* @buf_ptr: Address of the buffer
@@ -145,8 +171,8 @@ struct optee_msg_param_value {
145171
*
146172
* @attr & OPTEE_MSG_ATTR_TYPE_MASK indicates if tmem, rmem or value is used in
147173
* the union. OPTEE_MSG_ATTR_TYPE_VALUE_* indicates value,
148-
* OPTEE_MSG_ATTR_TYPE_TMEM_* indicates tmem and
149-
* OPTEE_MSG_ATTR_TYPE_RMEM_* indicates rmem.
174+
* OPTEE_MSG_ATTR_TYPE_TMEM_* indicates @tmem and
175+
* OPTEE_MSG_ATTR_TYPE_RMEM_* indicates @rmem,
150176
* OPTEE_MSG_ATTR_TYPE_NONE indicates that none of the members are used.
151177
*/
152178
struct optee_msg_param {

drivers/tee/optee/optee_smc.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,13 @@ struct optee_smc_get_shm_config_result {
222222
#define OPTEE_SMC_SEC_CAP_HAVE_RESERVED_SHM BIT(0)
223223
/* Secure world can communicate via previously unregistered shared memory */
224224
#define OPTEE_SMC_SEC_CAP_UNREGISTERED_SHM BIT(1)
225+
226+
/*
227+
* Secure world supports commands "register/unregister shared memory",
228+
* secure world accepts command buffers located in any parts of non-secure RAM
229+
*/
230+
#define OPTEE_SMC_SEC_CAP_DYNAMIC_SHM BIT(2)
231+
225232
#define OPTEE_SMC_FUNCID_EXCHANGE_CAPABILITIES 9
226233
#define OPTEE_SMC_EXCHANGE_CAPABILITIES \
227234
OPTEE_SMC_FAST_CALL_VAL(OPTEE_SMC_FUNCID_EXCHANGE_CAPABILITIES)

0 commit comments

Comments
 (0)