History

tee: add TEE_IOCTL_PARAM_ATTR_TYPE_OBJREF

The TEE subsystem allows session-based access to trusted services, requiring a session to be established to receive a service. This is not suitable for an environment that represents services as objects. An object supports various operations that a client can invoke, potentially generating a result or a new object that can be invoked independently of the original object. Add TEE_IOCTL_PARAM_ATTR_TYPE_OBJREF_INPUT/OUTPUT/INOUT to represent an object. Objects may reside in either TEE or userspace. To invoke an object in TEE, introduce a new ioctl. Use the existing SUPPL_RECV and SUPPL_SEND to invoke an object in userspace.

Amirreza Zarrabi committed 1 year ago

Commit d5b8b0f1 parent 54a53e94 files · +130 −6Browse files

Showing the changes to include/uapi (1 of 4 files). Show all

Unified · Split

include/uapi/linux/tee.h+35−6
@@ -48,8 +48,10 @@ · 47 unmodified lines
4848 #define TEE_GEN_CAP_PRIVILEGED (1 << 1)/* Privileged device (for supplicant) */
4949 #define TEE_GEN_CAP_REG_MEM (1 << 2)/* Supports registering shared memory */
5050 #define TEE_GEN_CAP_MEMREF_NULL (1 << 3)/* NULL MemRef support */
51+#define TEE_GEN_CAP_OBJREF (1 << 4)/* Supports generic object reference */
5152
52−#define TEE_MEMREF_NULL (__u64)(-1) /* NULL MemRef Buffer */
53+#define TEE_MEMREF_NULL ((__u64)(-1)) /* NULL MemRef Buffer */
54+#define TEE_OBJREF_NULL ((__u64)(-1)) /* NULL ObjRef Object */
5355
5456 /*
5557 * TEE Implementation ID
@@ -158,6 +160,13 @@ struct tee_ioctl_buf_data { · 102 unmodified lines
158160 #define TEE_IOCTL_PARAM_ATTR_TYPE_UBUF_OUTPUT 9
159161 #define TEE_IOCTL_PARAM_ATTR_TYPE_UBUF_INOUT 10 /* input and output */
160162
163+/*
164+ * These defines object reference parameters.
165+ */
166+#define TEE_IOCTL_PARAM_ATTR_TYPE_OBJREF_INPUT 11
167+#define TEE_IOCTL_PARAM_ATTR_TYPE_OBJREF_OUTPUT 12
168+#define TEE_IOCTL_PARAM_ATTR_TYPE_OBJREF_INOUT 13
169+
161170 /*
162171 * Mask for the type part of the attribute, leaves room for more types
163172 */
@@ -195,15 +204,16 @@ struct tee_ioctl_buf_data { · 31 unmodified lines
195204 * @attr: attributes
196205 * @a: if a memref, offset into the shared memory object,
197206 * else if a ubuf, address of the user buffer,
198− * else a value parameter
199− * @b: if a memref or ubuf, size of the buffer, else a value parameter
207+ * else if an objref, object identifier, else a value parameter
208+ * @b: if a memref or ubuf, size of the buffer,
209+ * else if objref, flags for the object, else a value parameter
200210 * @c: if a memref, shared memory identifier, else a value parameter
201211 *
202212 * @attr & TEE_PARAM_ATTR_TYPE_MASK indicates if memref, ubuf, or value is
203213 * used in the union. TEE_PARAM_ATTR_TYPE_VALUE_* indicates value,
204− * TEE_PARAM_ATTR_TYPE_MEMREF_* indicates memref, and TEE_PARAM_ATTR_TYPE_UBUF_*
205− * indicates ubuf. TEE_PARAM_ATTR_TYPE_NONE indicates that none of the members
206− * are used.
214+ * TEE_PARAM_ATTR_TYPE_MEMREF_* indicates memref, TEE_PARAM_ATTR_TYPE_UBUF_*
215+ * indicates ubuf, and TEE_PARAM_ATTR_TYPE_OBJREF_* indicates objref.
216+ * TEE_PARAM_ATTR_TYPE_NONE indicates that none of the members are used.
207217 *
208218 * Shared memory is allocated with TEE_IOC_SHM_ALLOC which returns an
209219 * identifier representing the shared memory object. A memref can reference
@@ -442,4 +452,23 @@ struct tee_ioctl_shm_register_fd_data { · 232 unmodified lines
442452 * munmap(): unmaps previously shared memory
443453 */
444454
455+/**
456+ * struct tee_ioctl_invoke_func_arg - Invokes an object in a Trusted Application
457+ * @id: [in] Object id
458+ * @op: [in] Object operation, specific to the object
459+ * @ret: [out] return value
460+ * @num_params: [in] number of parameters following this struct
461+ */
462+struct tee_ioctl_object_invoke_arg {
463+ __u64 id;
464+ __u32 op;
465+ __u32 ret;
466+ __u32 num_params;
467+ /* num_params tells the actual number of element in params */
468+ struct tee_ioctl_param params[];
469+};
470+
471+#define TEE_IOC_OBJECT_INVOKE _IOR(TEE_IOC_MAGIC, TEE_IOC_BASE + 10, \
472+ struct tee_ioctl_buf_data)
473+
445474 #endif /*__TEE_H*/