Browse Source

securemsm-kernel: smcinvoke: expand API

Expand SMCInvoke API to support possible
future requirements.

Change-Id: I9f6031751489c43a27afc2860a1cb9f87c7ebb87
Signed-off-by: Reut Zysman <[email protected]>
Reut Zysman 1 year ago
parent
commit
780711b60c
3 changed files with 25 additions and 17 deletions
  1. 12 8
      include/linux/smcinvoke.h
  2. 12 8
      include/uapi/linux/smcinvoke.h
  3. 1 1
      smcinvoke/smcinvoke.c

+ 12 - 8
include/linux/smcinvoke.h

@@ -20,8 +20,8 @@ struct smcinvoke_buf {
 
 struct smcinvoke_obj {
 	__s64 fd;
-	__s32 cb_server_fd;
-	__s32 reserved;
+	__s64 cb_server_fd;
+	__s64 reserved;
 };
 
 union smcinvoke_arg {
@@ -36,6 +36,7 @@ union smcinvoke_arg {
  * @result - result of invoke operation
  * @argsize - size of each of arguments
  * @args - args is pointer to buffer having all arguments
+ * @reserved: IN/OUT: Usage is not defined but should be set to 0
  */
 struct smcinvoke_cmd_req {
 	__u32 op;
@@ -43,42 +44,45 @@ struct smcinvoke_cmd_req {
 	__s32 result;
 	__u32 argsize;
 	__u64 args;
+	__s64 reserved;
 };
 
 /*
  * struct smcinvoke_accept: structure to process CB req from TEE
  * @has_resp: IN: Whether IOCTL is carrying response data
- * @txn_id: OUT: An id that should be passed as it is for response
  * @result: IN: Outcome of operation op
- * @cbobj_id: OUT: Callback object which is target of operation op
  * @op: OUT: Operation to be performed on target object
  * @counts: OUT: Number of arguments, embedded in buffer pointed by
  *               buf_addr, to complete operation
  * @reserved: IN/OUT: Usage is not defined but should be set to 0.
  * @argsize: IN: Size of any argument, all of equal size, embedded
  *               in buffer pointed by buf_addr
+ * @txn_id: OUT: An id that should be passed as it is for response
+ * @cbobj_id: OUT: Callback object which is target of operation op
  * @buf_len: IN: Len of buffer pointed by buf_addr
  * @buf_addr: IN: Buffer containing all arguments which are needed
  *                to complete operation op
  */
 struct smcinvoke_accept {
 	__u32 has_resp;
-	__u32 txn_id;
 	__s32 result;
-	__s32 cbobj_id;
 	__u32 op;
 	__u32 counts;
 	__s32 reserved;
 	__u32 argsize;
+	__u64 txn_id;
+	__s64 cbobj_id;
 	__u64 buf_len;
 	__u64 buf_addr;
 };
 
 /*
  * @cb_buf_size: IN: Max buffer size for any callback obj implemented by client
+ * @reserved: IN/OUT: Usage is not defined but should be set to 0
  */
 struct smcinvoke_server {
-	__u32 cb_buf_size;
+	__u64 cb_buf_size;
+	__s64 reserved;
 };
 
 #define SMCINVOKE_IOC_MAGIC    0x98
@@ -93,7 +97,7 @@ struct smcinvoke_server {
 	_IOWR(SMCINVOKE_IOC_MAGIC, 3, struct smcinvoke_server)
 
 #define SMCINVOKE_IOCTL_ACK_LOCAL_OBJ \
-	_IOWR(SMCINVOKE_IOC_MAGIC, 4, __s32)
+	_IOWR(SMCINVOKE_IOC_MAGIC, 4, __s64)
 
 /*
   * smcinvoke logging buffer is for communicating with the smcinvoke driver additional

+ 12 - 8
include/uapi/linux/smcinvoke.h

@@ -20,8 +20,8 @@ struct smcinvoke_buf {
 
 struct smcinvoke_obj {
 	__s64 fd;
-	__s32 cb_server_fd;
-	__s32 reserved;
+	__s64 cb_server_fd;
+	__s64 reserved;
 };
 
 union smcinvoke_arg {
@@ -36,6 +36,7 @@ union smcinvoke_arg {
  * @result - result of invoke operation
  * @argsize - size of each of arguments
  * @args - args is pointer to buffer having all arguments
+ * @reserved: IN/OUT: Usage is not defined but should be set to 0
  */
 struct smcinvoke_cmd_req {
 	__u32 op;
@@ -43,42 +44,45 @@ struct smcinvoke_cmd_req {
 	__s32 result;
 	__u32 argsize;
 	__u64 args;
+	__s64 reserved;
 };
 
 /*
  * struct smcinvoke_accept: structure to process CB req from TEE
  * @has_resp: IN: Whether IOCTL is carrying response data
- * @txn_id: OUT: An id that should be passed as it is for response
  * @result: IN: Outcome of operation op
- * @cbobj_id: OUT: Callback object which is target of operation op
  * @op: OUT: Operation to be performed on target object
  * @counts: OUT: Number of arguments, embedded in buffer pointed by
  *               buf_addr, to complete operation
  * @reserved: IN/OUT: Usage is not defined but should be set to 0.
  * @argsize: IN: Size of any argument, all of equal size, embedded
  *               in buffer pointed by buf_addr
+ * @txn_id: OUT: An id that should be passed as it is for response
+ * @cbobj_id: OUT: Callback object which is target of operation op
  * @buf_len: IN: Len of buffer pointed by buf_addr
  * @buf_addr: IN: Buffer containing all arguments which are needed
  *                to complete operation op
  */
 struct smcinvoke_accept {
 	__u32 has_resp;
-	__u32 txn_id;
 	__s32 result;
-	__s32 cbobj_id;
 	__u32 op;
 	__u32 counts;
 	__s32 reserved;
 	__u32 argsize;
+	__u64 txn_id;
+	__s64 cbobj_id;
 	__u64 buf_len;
 	__u64 buf_addr;
 };
 
 /*
  * @cb_buf_size: IN: Max buffer size for any callback obj implemented by client
+ * @reserved: IN/OUT: Usage is not defined but should be set to 0
  */
 struct smcinvoke_server {
-	__u32 cb_buf_size;
+	__u64 cb_buf_size;
+	__s64 reserved;
 };
 
 #define SMCINVOKE_IOC_MAGIC    0x98
@@ -93,7 +97,7 @@ struct smcinvoke_server {
 	_IOWR(SMCINVOKE_IOC_MAGIC, 3, struct smcinvoke_server)
 
 #define SMCINVOKE_IOCTL_ACK_LOCAL_OBJ \
-	_IOWR(SMCINVOKE_IOC_MAGIC, 4, __s32)
+	_IOWR(SMCINVOKE_IOC_MAGIC, 4, __s64)
 
 /*
   * smcinvoke logging buffer is for communicating with the smcinvoke driver additional

+ 1 - 1
smcinvoke/smcinvoke.c

@@ -2085,7 +2085,7 @@ static int marshal_in_tzcb_req(const struct smcinvoke_cb_txn *cb_txn,
 
 	user_req->txn_id = cb_txn->txn_id;
 	if (get_uhandle_from_tzhandle(tzcb_req->hdr.tzhandle, srvr_id,
-			&user_req->cbobj_id, TAKE_LOCK,
+			(int32_t*)(&user_req->cbobj_id), TAKE_LOCK,
 			SMCINVOKE_OBJ_TYPE_TZ_OBJ)) {
 		ret = -EINVAL;
 		goto out;