[PATCH v2 2/2] tee: optee: support session login as REE kernel

Etienne Carriere etienne.carriere at linaro.org
Wed May 19 16:26:13 CEST 2021


Remove unused OPTEE_MSG_LOGIN_* IDs and rely on the ones introduced in
tee.h. Change optee core to treat invalid client IDs as public login.

Signed-off-by: Etienne Carriere <etienne.carriere at linaro.org>
---
Changes since v1:
- Remove ID conversion. I kept the sanitation of login ID for optee.
---
 drivers/tee/optee/core.c      | 19 ++++++++++++++++++-
 drivers/tee/optee/optee_msg.h | 10 ----------
 2 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c
index 73dbb22ba0..14f9cce5f8 100644
--- a/drivers/tee/optee/core.c
+++ b/drivers/tee/optee/core.c
@@ -349,6 +349,23 @@ static int optee_close_session(struct udevice *dev, u32 session)
 	return 0;
 }
 
+static u32 optee_login_id(u32 login_id)
+{
+	/* Treat invalid IDs as public login */
+	switch (login_id) {
+	case TEE_LOGIN_USER:
+	case TEE_LOGIN_GROUP:
+	case TEE_LOGIN_APPLICATION:
+	case TEE_LOGIN_APPLICATION_USER:
+	case TEE_LOGIN_APPLICATION_GROUP:
+	case TEE_LOGIN_REE_KERNEL:
+		return login_id;
+	case TEE_LOGIN_PUBLIC:
+	default:
+		return TEE_LOGIN_PUBLIC;
+	}
+}
+
 static int optee_open_session(struct udevice *dev,
 			      struct tee_open_session_arg *arg,
 			      uint num_params, struct tee_param *params)
@@ -372,7 +389,7 @@ static int optee_open_session(struct udevice *dev,
 				  OPTEE_MSG_ATTR_META;
 	memcpy(&msg_arg->params[0].u.value, arg->uuid, sizeof(arg->uuid));
 	memcpy(&msg_arg->params[1].u.value, arg->uuid, sizeof(arg->clnt_uuid));
-	msg_arg->params[1].u.value.c = arg->clnt_login;
+	msg_arg->params[1].u.value.c = optee_login_id(arg->clnt_login);
 
 	rc = to_msg_param(msg_arg->params + 2, num_params, params);
 	if (rc)
diff --git a/drivers/tee/optee/optee_msg.h b/drivers/tee/optee/optee_msg.h
index 8d40ce60c2..9490592a8e 100644
--- a/drivers/tee/optee/optee_msg.h
+++ b/drivers/tee/optee/optee_msg.h
@@ -86,16 +86,6 @@
 #define OPTEE_MSG_ATTR_CACHE_MASK		GENMASK(2, 0)
 #define OPTEE_MSG_ATTR_CACHE_PREDEFINED		0
 
-/*
- * Same values as TEE_LOGIN_* from TEE Internal API
- */
-#define OPTEE_MSG_LOGIN_PUBLIC			0x00000000
-#define OPTEE_MSG_LOGIN_USER			0x00000001
-#define OPTEE_MSG_LOGIN_GROUP			0x00000002
-#define OPTEE_MSG_LOGIN_APPLICATION		0x00000004
-#define OPTEE_MSG_LOGIN_APPLICATION_USER	0x00000005
-#define OPTEE_MSG_LOGIN_APPLICATION_GROUP	0x00000006
-
 /*
  * Page size used in non-contiguous buffer entries
  */
-- 
2.17.1



More information about the U-Boot mailing list