Skip to contentSkip to conversation

TEE: minor cleanup

PATCH Superseded Igor Opaniuk 2 participants 16 messages Apr 4, 2024

Subsystems (2)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v4 cover TEE: minor cleanup

- Address some spelling errors and typos
- Support CMD_OPTEE_RPMB for SANDBOX configurations and add python tests
- Remove common.h inclusion for drivers/tee
- Add calls for closing tee session after every read/write operation.

CI build:
[1] https://dev.azure.com/igoropaniuk/u-boot/_build/results?buildId=31&view=results

Changes in v4:
- Rebased on the latest master and excluded "tee: sandbox: fix spelling errors", as it was merged already by Heinrich Schuchardt

Changes in v3:
- Added calls for closing tee session after every read/write operation

Changes in v2:
- Fixed chimp_optee.c:37:9: error: implicit declaration of function 'memset'
- Applied R-b and T-b tags

Igor Opaniuk (5):
tee: optee: fix description in Kconfig
cmd: optee_rpmb: close tee session
cmd: optee_rpmb: build cmd for sandbox
test: py: add optee_rpmb tests
tee: remove common.h inclusion

 cmd/Kconfig                        |  4 +++-
 cmd/optee_rpmb.c                   | 23 +++++++++++++++++------
 drivers/tee/broadcom/chimp_optee.c |  3 ++-
 drivers/tee/optee/Kconfig          |  2 +-
 drivers/tee/optee/core.c           |  1 -
 drivers/tee/optee/i2c.c            |  1 -
 drivers/tee/optee/rpmb.c           |  1 -
 drivers/tee/optee/supplicant.c     |  2 +-
 drivers/tee/sandbox.c              |  2 +-
 drivers/tee/tee-uclass.c           |  1 -
 test/py/tests/test_optee_rpmb.py   | 20 ++++++++++++++++++++
 11 files changed, 45 insertions(+), 15 deletions(-)
 create mode 100644 test/py/tests/test_optee_rpmb.py
Signature · 1 line
2.34.1
#1 lore raw

PATCH v4 1/5 tee: optee: fix description in Kconfig

Fix OPTEE_TA_AVB symbol description in Kconfig:
s/"write"rb"/"write_rb"/g

---

(no changes since v2)

Changes in v2:
- Applied R-b tags

 drivers/tee/optee/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tee/optee/Kconfig +1 -1
index 9dc65b0501e..db0bcfa6f15 100644
@@ -19,7 +19,7 @@ config OPTEE_TA_AVB
 	default y
 	help
 	  Enables support for the AVB Trusted Application (TA) in OP-TEE.
-	  The TA can support the "avb" subcommands "read_rb", "write"rb"
+	  The TA can support the "avb" subcommands "read_rb", "write_rb"
 	  and "is_unlocked".
 
 config OPTEE_TA_RPC_TEST
Signature · 1 line
2.34.1
#2 lore raw

PATCH v4 2/5 cmd: optee_rpmb: close tee session

In reply to Igor Opaniuk

Add calls for closing tee session after every read/write operation.

---

(no changes since v1)

 cmd/optee_rpmb.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)
cmd/optee_rpmb.c +17 -6
index e0e44bbed04..b3cafd92410 100644
@@ -87,8 +87,10 @@ static int read_persistent_value(const char *name,
 
 	rc = tee_shm_alloc(tee, name_size,
 			   TEE_SHM_ALLOC, &shm_name);
-	if (rc)
-		return -ENOMEM;
+	if (rc) {
+		rc = -ENOMEM;
+		goto close_session;
+	}
 
 	rc = tee_shm_alloc(tee, buffer_size,
 			   TEE_SHM_ALLOC, &shm_buf);
@@ -125,6 +127,9 @@ out:
 	tee_shm_free(shm_buf);
 free_name:
 	tee_shm_free(shm_name);
+close_session:
+	tee_close_session(tee, session);
+	tee = NULL;
 
 	return rc;
 }
@@ -139,17 +144,20 @@ static int write_persistent_value(const char *name,
 	struct tee_param param[2];
 	size_t name_size = strlen(name) + 1;
 
+	if (!value_size)
+		return -EINVAL;
+
 	if (!tee) {
 		if (avb_ta_open_session())
 			return -ENODEV;
 	}
-	if (!value_size)
-		return -EINVAL;
 
 	rc = tee_shm_alloc(tee, name_size,
 			   TEE_SHM_ALLOC, &shm_name);
-	if (rc)
-		return -ENOMEM;
+	if (rc) {
+		rc = -ENOMEM;
+		goto close_session;
+	}
 
 	rc = tee_shm_alloc(tee, value_size,
 			   TEE_SHM_ALLOC, &shm_buf);
@@ -178,6 +186,9 @@ out:
 	tee_shm_free(shm_buf);
 free_name:
 	tee_shm_free(shm_name);
+close_session:
+	tee_close_session(tee, session);
+	tee = NULL;
 
 	return rc;
 }
Signature · 1 line
2.34.1
#3 lore raw

Re: [PATCH v4 2/5] cmd: optee_rpmb: close tee session

Hi Igor,

I was about to apply the series, but noticed neither me or Jens were cc'ed on this. Adding Jens to the party

Quoted 1 line · Igor Opaniuk

Add calls for closing tee session after every read/write operation.

What the patch is pretty obvious, but I am missing an explanation of why this is needed

Quoted 14 lines

---

(no changes since v1)

 cmd/optee_rpmb.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)
cmd/optee_rpmb.c +0 -0
index e0e44bbed04..b3cafd92410 100644

cmd/optee_rpmb.c static int read_persistent_value(const char *name, · line 93

Quoted 9 lines
cmd/optee_rpmb.c +4 -2
@@ -87,8 +87,10 @@ static int read_persistent_value(const char *name,
 
 	rc = tee_shm_alloc(tee, name_size,
 			   TEE_SHM_ALLOC, &shm_name);
-	if (rc)
-		return -ENOMEM;
+	if (rc) {
+		rc = -ENOMEM;
+		goto close_session;
+	}

I don't think you need the session to be opened to allocate memory. So instead of of doing this, why don't we just move the alloc call before opening the session?

Quoted 25 lines
cmd/optee_rpmb.c +6 -1
 	rc = tee_shm_alloc(tee, buffer_size,
 			   TEE_SHM_ALLOC, &shm_buf);
@@ -125,6 +127,9 @@ out:
 	tee_shm_free(shm_buf);
 free_name:
 	tee_shm_free(shm_name);
+close_session:
+	tee_close_session(tee, session);
+	tee = NULL;
 
 	return rc;
 }
@@ -139,17 +144,20 @@ static int write_persistent_value(const char *name,
 	struct tee_param param[2];
 	size_t name_size = strlen(name) + 1;
 
+	if (!value_size)
+		return -EINVAL;
+
 	if (!tee) {
 		if (avb_ta_open_session())
 			return -ENODEV;
 	}
-	if (!value_size)

cmd/optee_rpmb.c static int write_persistent_value(const char *name, · line 160

Quoted 10 lines
cmd/optee_rpmb.c +4 -3
-		return -EINVAL;
 
 	rc = tee_shm_alloc(tee, name_size,
 			   TEE_SHM_ALLOC, &shm_name);
-	if (rc)
-		return -ENOMEM;
+	if (rc) {
+		rc = -ENOMEM;
+		goto close_session;
+	}

ditto

Quoted 14 lines
cmd/optee_rpmb.c +3 -1
 	rc = tee_shm_alloc(tee, value_size,
 			   TEE_SHM_ALLOC, &shm_buf);
@@ -178,6 +186,9 @@ out:
 	tee_shm_free(shm_buf);
 free_name:
 	tee_shm_free(shm_name);
+close_session:
+	tee_close_session(tee, session);
+	tee = NULL;
 
 	return rc;
 }
--
Quoted 2 lines

2.34.1

Thanks
/Ilias

#4 lore raw

Re: [PATCH v4 2/5] cmd: optee_rpmb: close tee session

Hi Igor,

Quoted 27 lines · Ilias Apalodimas

Hi Igor,

I was about to apply the series, but noticed neither me or Jens were cc'ed on this. Adding Jens to the party

Quoted 1 line · Igor Opaniuk

Add calls for closing tee session after every read/write operation.

What the patch is pretty obvious, but I am missing an explanation of why this is needed

Quoted 15 lines

---

(no changes since v1)

 cmd/optee_rpmb.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)
cmd/optee_rpmb.c +0 -0
index e0e44bbed04..b3cafd92410 100644
@@ -87,8 +87,10 @@ static int read_persistent_value(const char *name,
 
Quoted 12 lines

cmd/optee_rpmb.c static int read_persistent_value(const char *name, · line 93

Quoted 8 lines
cmd/optee_rpmb.c +4 -2
      rc = tee_shm_alloc(tee, name_size,
                         TEE_SHM_ALLOC, &shm_name);
-     if (rc)
-             return -ENOMEM;
+     if (rc) {
+             rc = -ENOMEM;
+             goto close_session;
+     }

I don't think you need the session to be opened to allocate memory. So instead of of doing this, why don't we just move the alloc call before opening the session?

Looking at it again, we do need tee != NULL, but I think it's cleaner to add something like
if (!dev)
return -ENODEV
to __tee_shm_add() instead.

Cheers
/Ilias

Quoted 58 lines
Quoted 26 lines
cmd/optee_rpmb.c +6 -1
      rc = tee_shm_alloc(tee, buffer_size,
                         TEE_SHM_ALLOC, &shm_buf);
@@ -125,6 +127,9 @@ out:
      tee_shm_free(shm_buf);
 free_name:
      tee_shm_free(shm_name);
+close_session:
+     tee_close_session(tee, session);
+     tee = NULL;
 
      return rc;
 }
@@ -139,17 +144,20 @@ static int write_persistent_value(const char *name,
      struct tee_param param[2];
      size_t name_size = strlen(name) + 1;
 
+     if (!value_size)
+             return -EINVAL;
+
      if (!tee) {
              if (avb_ta_open_session())
                      return -ENODEV;
      }
-     if (!value_size)

cmd/optee_rpmb.c static int write_persistent_value(const char *name, · line 160

Quoted 10 lines
cmd/optee_rpmb.c +4 -3
-             return -EINVAL;
 
      rc = tee_shm_alloc(tee, name_size,
                         TEE_SHM_ALLOC, &shm_name);
-     if (rc)
-             return -ENOMEM;
+     if (rc) {
+             rc = -ENOMEM;
+             goto close_session;
+     }

ditto

Quoted 14 lines
cmd/optee_rpmb.c +3 -1
      rc = tee_shm_alloc(tee, value_size,
                         TEE_SHM_ALLOC, &shm_buf);
@@ -178,6 +186,9 @@ out:
      tee_shm_free(shm_buf);
 free_name:
      tee_shm_free(shm_name);
+close_session:
+     tee_close_session(tee, session);
+     tee = NULL;
 
      return rc;
 }
--
Quoted 2 lines

2.34.1

Thanks
/Ilias

#5 lore raw

Re: [PATCH v4 2/5] cmd: optee_rpmb: close tee session

Hi Ilias,

Quoted 45 lines · Ilias Apalodimas

Hi Igor,

Quoted 4 lines · Ilias Apalodimas

Hi Igor,

I was about to apply the series, but noticed neither me or Jens were

cc'ed

Quoted 23 lines

on this. Adding Jens to the party

Quoted 1 line · Igor Opaniuk

Add calls for closing tee session after every read/write operation.

What the patch is pretty obvious, but I am missing an explanation of why this is needed

Quoted 15 lines

---

(no changes since v1)

 cmd/optee_rpmb.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)
cmd/optee_rpmb.c +0 -0
index e0e44bbed04..b3cafd92410 100644
@@ -87,8 +87,10 @@ static int read_persistent_value(const char *name,
 
Quoted 12 lines

cmd/optee_rpmb.c static int read_persistent_value(const char *name, · line 93

Quoted 8 lines
cmd/optee_rpmb.c +4 -2
      rc = tee_shm_alloc(tee, name_size,
                         TEE_SHM_ALLOC, &shm_name);
-     if (rc)
-             return -ENOMEM;
+     if (rc) {
+             rc = -ENOMEM;
+             goto close_session;
+     }

I don't think you need the session to be opened to allocate memory. So instead of of doing this, why don't we just move the alloc call before opening the session?

Quoted 6 lines

Looking at it again, we do need tee != NULL, but I think it's cleaner to add something like
if (!dev)
return -ENODEV
to __tee_shm_add() instead.

Do you mind if I address that in a separate patch series, as tbh I don't want to add additional patches to the existing series?

Quoted 63 lines

Cheers
/Ilias

Quoted 12 lines
Quoted 12 lines
cmd/optee_rpmb.c +3 -0
      rc = tee_shm_alloc(tee, buffer_size,
                         TEE_SHM_ALLOC, &shm_buf);
@@ -125,6 +127,9 @@ out:
      tee_shm_free(shm_buf);
 free_name:
      tee_shm_free(shm_name);
+close_session:
+     tee_close_session(tee, session);
+     tee = NULL;
 
Quoted 3 lines

cmd/optee_rpmb.c static int write_persistent_value(const char

Quoted 3 lines
cmd/optee_rpmb.c +0 -0
      return rc;
 }
@@ -139,17 +144,20 @@ static int write_persistent_value(const char

*name,

Quoted 43 lines
Quoted 11 lines
cmd/optee_rpmb.c +3 -1
      struct tee_param param[2];
      size_t name_size = strlen(name) + 1;
 
+     if (!value_size)
+             return -EINVAL;
+
      if (!tee) {
              if (avb_ta_open_session())
                      return -ENODEV;
      }
-     if (!value_size)

cmd/optee_rpmb.c static int write_persistent_value(const char *name, · line 160

Quoted 10 lines
cmd/optee_rpmb.c +4 -3
-             return -EINVAL;
 
      rc = tee_shm_alloc(tee, name_size,
                         TEE_SHM_ALLOC, &shm_name);
-     if (rc)
-             return -ENOMEM;
+     if (rc) {
+             rc = -ENOMEM;
+             goto close_session;
+     }

ditto

Quoted 14 lines
cmd/optee_rpmb.c +3 -1
      rc = tee_shm_alloc(tee, value_size,
                         TEE_SHM_ALLOC, &shm_buf);
@@ -178,6 +186,9 @@ out:
      tee_shm_free(shm_buf);
 free_name:
      tee_shm_free(shm_name);
+close_session:
+     tee_close_session(tee, session);
+     tee = NULL;
 
      return rc;
 }
--
Quoted 2 lines

2.34.1

Thanks
/Ilias

Signature · 7 lines
Best regards - Atentamente - Meilleures salutations

Igor Opaniuk

mailto: [email protected]
skype: igor.opanyuk
https://www.linkedin.com/in/iopaniuk <http://ua.linkedin.com/in/iopaniuk>
#6 lore raw

Re: [PATCH v4 2/5] cmd: optee_rpmb: close tee session

Hi Igor,

Quoted 49 lines · Igor Opaniuk

Hi Ilias,

Quoted 45 lines · Ilias Apalodimas

Hi Igor,

Quoted 39 lines · Ilias Apalodimas

Hi Igor,

I was about to apply the series, but noticed neither me or Jens were cc'ed on this. Adding Jens to the party

Quoted 1 line · Igor Opaniuk

Add calls for closing tee session after every read/write operation.

What the patch is pretty obvious, but I am missing an explanation of why this is needed

Quoted 14 lines

---

(no changes since v1)

 cmd/optee_rpmb.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)
cmd/optee_rpmb.c +0 -0
index e0e44bbed04..b3cafd92410 100644

cmd/optee_rpmb.c static int read_persistent_value(const char *name, · line 93

Quoted 9 lines
cmd/optee_rpmb.c +4 -2
@@ -87,8 +87,10 @@ static int read_persistent_value(const char *name,
 
      rc = tee_shm_alloc(tee, name_size,
                         TEE_SHM_ALLOC, &shm_name);
-     if (rc)
-             return -ENOMEM;
+     if (rc) {
+             rc = -ENOMEM;
+             goto close_session;
+     }

I don't think you need the session to be opened to allocate memory. So instead of of doing this, why don't we just move the alloc call before opening the session?

Quoted 8 lines
Quoted 5 lines

Looking at it again, we do need tee != NULL, but I think it's cleaner to add something like
if (!dev)
return -ENODEV
to __tee_shm_add() instead.

Do you mind if I address that in a separate patch series, as tbh I don't want to add additional patches to the existing series?

We still completely change the functionality. So, the patchset is not a 'tiny cleanup', it instead closes the session every time instead of keeping it open.
There are a few things going on, that aren't explained clearly in the commit message
- Why is this needed? Looking at the code it is an actual problem since sessions tied to the AVB uuid will remain open
- Is there any side effect by always closing the session? I don't mind merging it as is with a proper commit message, but I think the alternative is just easier.

Thanks
/Ilias

Quoted 75 lines
Quoted 63 lines

Cheers
/Ilias

Quoted 58 lines
Quoted 26 lines
cmd/optee_rpmb.c +6 -1
      rc = tee_shm_alloc(tee, buffer_size,
                         TEE_SHM_ALLOC, &shm_buf);
@@ -125,6 +127,9 @@ out:
      tee_shm_free(shm_buf);
 free_name:
      tee_shm_free(shm_name);
+close_session:
+     tee_close_session(tee, session);
+     tee = NULL;
 
      return rc;
 }
@@ -139,17 +144,20 @@ static int write_persistent_value(const char *name,
      struct tee_param param[2];
      size_t name_size = strlen(name) + 1;
 
+     if (!value_size)
+             return -EINVAL;
+
      if (!tee) {
              if (avb_ta_open_session())
                      return -ENODEV;
      }
-     if (!value_size)

cmd/optee_rpmb.c static int write_persistent_value(const char *name, · line 160

Quoted 10 lines
cmd/optee_rpmb.c +4 -3
-             return -EINVAL;
 
      rc = tee_shm_alloc(tee, name_size,
                         TEE_SHM_ALLOC, &shm_name);
-     if (rc)
-             return -ENOMEM;
+     if (rc) {
+             rc = -ENOMEM;
+             goto close_session;
+     }

ditto

Quoted 14 lines
cmd/optee_rpmb.c +3 -1
      rc = tee_shm_alloc(tee, value_size,
                         TEE_SHM_ALLOC, &shm_buf);
@@ -178,6 +186,9 @@ out:
      tee_shm_free(shm_buf);
 free_name:
      tee_shm_free(shm_name);
+close_session:
+     tee_close_session(tee, session);
+     tee = NULL;
 
      return rc;
 }
--
Quoted 2 lines

2.34.1

Thanks
/Ilias

--
Best regards - Atentamente - Meilleures salutations

Igor Opaniuk

mailto: [email protected]
skype: igor.opanyuk
https://www.linkedin.com/in/iopaniuk

#7 lore raw

Re: [PATCH v4 2/5] cmd: optee_rpmb: close tee session

Ilias,

Quoted 66 lines · Ilias Apalodimas

Hi Igor,

Quoted 4 lines · Igor Opaniuk

Hi Ilias,

On Thu, Apr 4, 2024 at 10:54 AM Ilias Apalodimas <

Quoted 9 lines · [email protected]> wrote:
Quoted 9 lines

Hi Igor,

Quoted 4 lines · Ilias Apalodimas

Hi Igor,

I was about to apply the series, but noticed neither me or Jens were

cc'ed

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

on this. Adding Jens to the party

Quoted 1 line · Igor Opaniuk

Add calls for closing tee session after every read/write operation.

What the patch is pretty obvious, but I am missing an explanation of

why

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

this is needed

Quoted 6 lines

---

(no changes since v1)

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

cmd/optee_rpmb.c static int read_persistent_value(const char

Quoted 8 lines
 cmd/optee_rpmb.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)
cmd/optee_rpmb.c +0 -0
index e0e44bbed04..b3cafd92410 100644
@@ -87,8 +87,10 @@ static int read_persistent_value(const char

*name,

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
cmd/optee_rpmb.c +4 -2
      rc = tee_shm_alloc(tee, name_size,
                         TEE_SHM_ALLOC, &shm_name);
-     if (rc)
-             return -ENOMEM;
+     if (rc) {
+             rc = -ENOMEM;
+             goto close_session;
+     }
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

I don't think you need the session to be opened to allocate memory. So instead of of doing this, why don't we just move the alloc call

before

Quoted 10 lines
Quoted 7 lines
Quoted 1 line

opening the session?

Looking at it again, we do need tee != NULL, but I think it's cleaner to add something like
if (!dev)
return -ENODEV
to __tee_shm_add() instead.

Do you mind if I address that in a separate patch series, as tbh I don't want to add additional patches to the existing series?

Quoted 11 lines

We still completely change the functionality. So, the patchset is not a 'tiny cleanup', it instead closes the session every time instead of keeping it open.
There are a few things going on, that aren't explained clearly in the commit message
- Why is this needed? Looking at the code it is an actual problem since sessions tied to the AVB uuid will remain open
- Is there any side effect by always closing the session? I don't mind merging it as is with a proper commit message, but I think the alternative is just easier.

I'll provide a bit more context here. The problem initially was in the TEE sandbox
driver implementation(drivers/tee/sandbox.c) and it's limitations, which doesn't
permit to have multiple simultaneous sessions with different TAs. This is what actually happened in this CI run [1], firstly "optee_rpmb" cmd was executed (and after execution we had one session open), and then "scp03", which also makes calls to OP-TEE, however it fails in sandbox_tee_open_session() because of this check:

if (state->ta) {
    printf("A session is already open\n");
    return -EBUSY;
}

So basically I had two ways in mind to address that:
1. Close a session on each optee_rpmb cmd invocation.
I don't see any reason to keep this session open, as obviously there is no other mechanism (tbh, I don't know if DM calls ".remove" for active
devices) to close it automatically before handing over control to Linux kernel. As a result we might end up with some orphaned sessions registered in OP-TEE OS core (obvious resource leak).
2. Extend TEE sandbox driver, add support for multiple simultaneous sessions just to handle the case.

I've chosen the first approach, as IMO it was "kill two birds with one stone",
I could address resource leak in OP-TEE and bypass limitations of TEE sandbox driver.

[1] https://source.denx.de/u-boot/custodians/u-boot-tpm/-/jobs/792216

Quoted 81 lines

Thanks
/Ilias

Quoted 17 lines
Quoted 17 lines

Cheers
/Ilias

Quoted 12 lines
Quoted 12 lines
cmd/optee_rpmb.c +3 -0
      rc = tee_shm_alloc(tee, buffer_size,
                         TEE_SHM_ALLOC, &shm_buf);
@@ -125,6 +127,9 @@ out:
      tee_shm_free(shm_buf);
 free_name:
      tee_shm_free(shm_name);
+close_session:
+     tee_close_session(tee, session);
+     tee = NULL;
 
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

cmd/optee_rpmb.c static int write_persistent_value(const char

Quoted 3 lines
cmd/optee_rpmb.c +0 -0
      return rc;
 }
@@ -139,17 +144,20 @@ static int write_persistent_value(const char

*name,

Quoted 55 lines
Quoted 35 lines
Quoted 35 lines
Quoted 11 lines
cmd/optee_rpmb.c +3 -1
      struct tee_param param[2];
      size_t name_size = strlen(name) + 1;
 
+     if (!value_size)
+             return -EINVAL;
+
      if (!tee) {
              if (avb_ta_open_session())
                      return -ENODEV;
      }
-     if (!value_size)

cmd/optee_rpmb.c static int write_persistent_value(const char *name, · line 160

Quoted 10 lines
cmd/optee_rpmb.c +4 -3
-             return -EINVAL;
 
      rc = tee_shm_alloc(tee, name_size,
                         TEE_SHM_ALLOC, &shm_name);
-     if (rc)
-             return -ENOMEM;
+     if (rc) {
+             rc = -ENOMEM;
+             goto close_session;
+     }

ditto

Quoted 11 lines
cmd/optee_rpmb.c +3 -0
      rc = tee_shm_alloc(tee, value_size,
                         TEE_SHM_ALLOC, &shm_buf);
@@ -178,6 +186,9 @@ out:
      tee_shm_free(shm_buf);
 free_name:
      tee_shm_free(shm_name);
+close_session:
+     tee_close_session(tee, session);
+     tee = NULL;
 
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
cmd/optee_rpmb.c +0 -1
      return rc;
 }
--

2.34.1

Thanks
/Ilias

--
Best regards - Atentamente - Meilleures salutations

Igor Opaniuk

mailto: [email protected]
skype: igor.opanyuk
https://www.linkedin.com/in/iopaniuk

Signature · 7 lines
Best regards - Atentamente - Meilleures salutations

Igor Opaniuk

mailto: [email protected]
skype: igor.opanyuk
https://www.linkedin.com/in/iopaniuk <http://ua.linkedin.com/in/iopaniuk>
#8 lore raw

Re: [PATCH v4 2/5] cmd: optee_rpmb: close tee session

Hi Igor,

Quoted 100 lines · Igor Opaniuk

Ilias,

Quoted 62 lines · Ilias Apalodimas

Hi Igor,

Quoted 49 lines · Igor Opaniuk

Hi Ilias,

Quoted 45 lines · Ilias Apalodimas

Hi Igor,

Quoted 39 lines · Ilias Apalodimas

Hi Igor,

I was about to apply the series, but noticed neither me or Jens were cc'ed on this. Adding Jens to the party

Quoted 1 line · Igor Opaniuk

Add calls for closing tee session after every read/write operation.

What the patch is pretty obvious, but I am missing an explanation of why this is needed

Quoted 14 lines

---

(no changes since v1)

 cmd/optee_rpmb.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)
cmd/optee_rpmb.c +0 -0
index e0e44bbed04..b3cafd92410 100644

cmd/optee_rpmb.c static int read_persistent_value(const char *name, · line 93

Quoted 9 lines
cmd/optee_rpmb.c +4 -2
@@ -87,8 +87,10 @@ static int read_persistent_value(const char *name,
 
      rc = tee_shm_alloc(tee, name_size,
                         TEE_SHM_ALLOC, &shm_name);
-     if (rc)
-             return -ENOMEM;
+     if (rc) {
+             rc = -ENOMEM;
+             goto close_session;
+     }

I don't think you need the session to be opened to allocate memory. So instead of of doing this, why don't we just move the alloc call before opening the session?

Quoted 8 lines
Quoted 5 lines

Looking at it again, we do need tee != NULL, but I think it's cleaner to add something like
if (!dev)
return -ENODEV
to __tee_shm_add() instead.

Do you mind if I address that in a separate patch series, as tbh I don't want to add additional patches to the existing series?

Quoted 10 lines

We still completely change the functionality. So, the patchset is not a 'tiny cleanup', it instead closes the session every time instead of keeping it open.
There are a few things going on, that aren't explained clearly in the commit message
- Why is this needed? Looking at the code it is an actual problem since sessions tied to the AVB uuid will remain open
- Is there any side effect by always closing the session? I don't mind merging it as is with a proper commit message, but I think the alternative is just easier.

I'll provide a bit more context here. The problem initially was in the TEE sandbox driver implementation(drivers/tee/sandbox.c) and it's limitations, which doesn't permit to have multiple simultaneous sessions with different TAs. This is what actually happened in this CI run [1], firstly "optee_rpmb" cmd was executed (and after execution we had one session open), and then "scp03", which also makes calls to OP-TEE, however it fails
in sandbox_tee_open_session() because of this check:

if (state->ta) {
    printf("A session is already open\n");
    return -EBUSY;
}

So basically I had two ways in mind to address that:
1. Close a session on each optee_rpmb cmd invocation.
I don't see any reason to keep this session open, as obviously there is no other mechanism (tbh, I don't know if DM calls ".remove" for active devices) to close it automatically before handing over control to Linux kernel. As a result we might end up with some orphaned sessions registered in OP-TEE OS core (obvious resource leak).
2. Extend TEE sandbox driver, add support for multiple simultaneous sessions just to handle the case.

Quoted 3 lines

I've chosen the first approach, as IMO it was "kill two birds with one stone", I could address resource leak in OP-TEE and bypass limitations of TEE sandbox driver.

Thanks, this helps.
All this needs to be in the commit message, instead of a mail thread. Can you send a new revision with the commit message amended?

Thanks
/Ilias

Quoted 94 lines

[1] https://source.denx.de/u-boot/custodians/u-boot-tpm/-/jobs/792216

Quoted 80 lines

Thanks
/Ilias

Quoted 75 lines
Quoted 63 lines

Cheers
/Ilias

Quoted 58 lines
Quoted 26 lines
cmd/optee_rpmb.c +6 -1
      rc = tee_shm_alloc(tee, buffer_size,
                         TEE_SHM_ALLOC, &shm_buf);
@@ -125,6 +127,9 @@ out:
      tee_shm_free(shm_buf);
 free_name:
      tee_shm_free(shm_name);
+close_session:
+     tee_close_session(tee, session);
+     tee = NULL;
 
      return rc;
 }
@@ -139,17 +144,20 @@ static int write_persistent_value(const char *name,
      struct tee_param param[2];
      size_t name_size = strlen(name) + 1;
 
+     if (!value_size)
+             return -EINVAL;
+
      if (!tee) {
              if (avb_ta_open_session())
                      return -ENODEV;
      }
-     if (!value_size)

cmd/optee_rpmb.c static int write_persistent_value(const char *name, · line 160

Quoted 10 lines
cmd/optee_rpmb.c +4 -3
-             return -EINVAL;
 
      rc = tee_shm_alloc(tee, name_size,
                         TEE_SHM_ALLOC, &shm_name);
-     if (rc)
-             return -ENOMEM;
+     if (rc) {
+             rc = -ENOMEM;
+             goto close_session;
+     }

ditto

Quoted 14 lines
cmd/optee_rpmb.c +3 -1
      rc = tee_shm_alloc(tee, value_size,
                         TEE_SHM_ALLOC, &shm_buf);
@@ -178,6 +186,9 @@ out:
      tee_shm_free(shm_buf);
 free_name:
      tee_shm_free(shm_name);
+close_session:
+     tee_close_session(tee, session);
+     tee = NULL;
 
      return rc;
 }
--
Quoted 2 lines

2.34.1

Thanks
/Ilias

--
Best regards - Atentamente - Meilleures salutations

Igor Opaniuk

mailto: [email protected]
skype: igor.opanyuk
https://www.linkedin.com/in/iopaniuk

--
Best regards - Atentamente - Meilleures salutations

Igor Opaniuk

mailto: [email protected]
skype: igor.opanyuk
https://www.linkedin.com/in/iopaniuk

#9 lore raw

Re: [PATCH v4 2/5] cmd: optee_rpmb: close tee session

In reply to Ilias Apalodimas

Hi Ilias,

Quoted 5 lines · Ilias Apalodimas

Hi Igor,

I was about to apply the series, but noticed neither me or Jens were cc'ed on this. Adding Jens to the party

I usually rely on automatic CC-list creation by patman. Looks like there is no
entry in MAINTAINERS for this specific file, that's why only Tom was added. I'll send a patch for that if you don't mind.

Quoted 21 lines · Igor Opaniuk
Quoted 1 line

Add calls for closing tee session after every read/write operation.

What the patch is pretty obvious, but I am missing an explanation of why this is needed

Quoted 15 lines

---

(no changes since v1)

 cmd/optee_rpmb.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)
cmd/optee_rpmb.c +0 -0
index e0e44bbed04..b3cafd92410 100644
@@ -87,8 +87,10 @@ static int read_persistent_value(const char *name,
 
Quoted 13 lines

cmd/optee_rpmb.c static int read_persistent_value(const char *name, · line 93

Quoted 8 lines
cmd/optee_rpmb.c +4 -2
      rc = tee_shm_alloc(tee, name_size,
                         TEE_SHM_ALLOC, &shm_name);
-     if (rc)
-             return -ENOMEM;
+     if (rc) {
+             rc = -ENOMEM;
+             goto close_session;
+     }

I don't think you need the session to be opened to allocate memory. So instead of of doing this, why don't we just move the alloc call before opening the session?

That's correct, but avb_ta_open_session() wrapper calls
both tee_find_device()/
tee_open_session(), and tee_shm_alloc() expects valid tee device as param, which
is initialized by tee_find_device(). My intention was to address the only one particular issue
that was catched by CI and explained in [1] instead of doing overhaul of the whole optee_rpmb cmd implementation.

Quoted 49 lines
Quoted 25 lines
cmd/optee_rpmb.c +6 -1
      rc = tee_shm_alloc(tee, buffer_size,
                         TEE_SHM_ALLOC, &shm_buf);
@@ -125,6 +127,9 @@ out:
      tee_shm_free(shm_buf);
 free_name:
      tee_shm_free(shm_name);
+close_session:
+     tee_close_session(tee, session);
+     tee = NULL;
 
      return rc;
 }
@@ -139,17 +144,20 @@ static int write_persistent_value(const char *name,
      struct tee_param param[2];
      size_t name_size = strlen(name) + 1;
 
+     if (!value_size)
+             return -EINVAL;
+
      if (!tee) {
              if (avb_ta_open_session())
                      return -ENODEV;
      }
-     if (!value_size)

cmd/optee_rpmb.c static int write_persistent_value(const char *name, · line 160

Quoted 10 lines
cmd/optee_rpmb.c +4 -3
-             return -EINVAL;
 
      rc = tee_shm_alloc(tee, name_size,
                         TEE_SHM_ALLOC, &shm_name);
-     if (rc)
-             return -ENOMEM;
+     if (rc) {
+             rc = -ENOMEM;
+             goto close_session;
+     }

ditto

Quoted 11 lines
cmd/optee_rpmb.c +3 -0
      rc = tee_shm_alloc(tee, value_size,
                         TEE_SHM_ALLOC, &shm_buf);
@@ -178,6 +186,9 @@ out:
      tee_shm_free(shm_buf);
 free_name:
      tee_shm_free(shm_name);
+close_session:
+     tee_close_session(tee, session);
+     tee = NULL;
 
Quoted 9 lines
Quoted 5 lines
cmd/optee_rpmb.c +0 -1
      return rc;
 }
--

2.34.1

Thanks
/Ilias

[1]
https://lore.kernel.org/all/[email protected]/T/

Signature · 7 lines
Best regards - Atentamente - Meilleures salutations

Igor Opaniuk

mailto: [email protected]
skype: igor.opanyuk
https://www.linkedin.com/in/iopaniuk <http://ua.linkedin.com/in/iopaniuk>
#10 lore raw

Re: [PATCH v4 2/5] cmd: optee_rpmb: close tee session

HI Ilias

Quoted 7 lines · Igor Opaniuk

Hi Ilias,

Quoted 2 lines · Ilias Apalodimas

Hi Igor,

Quoted 8 lines
Quoted 3 lines

I was about to apply the series, but noticed neither me or Jens were cc'ed on this. Adding Jens to the party

I usually rely on automatic CC-list creation by patman. Looks like there is no
entry in MAINTAINERS for this specific file, that's why only Tom was added. I'll send a patch for that if you don't mind.

I've added all orphaned tee-related files to MAINTAINERS in [1], so I patman should generate the CC list correctly next time.

[1]
https://lore.kernel.org/u-boot/[email protected]/T/#u

Quoted 118 lines
Quoted 23 lines · Igor Opaniuk
Quoted 1 line

Add calls for closing tee session after every read/write operation.

What the patch is pretty obvious, but I am missing an explanation of why this is needed

Quoted 15 lines

---

(no changes since v1)

 cmd/optee_rpmb.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)
cmd/optee_rpmb.c +0 -0
index e0e44bbed04..b3cafd92410 100644
@@ -87,8 +87,10 @@ static int read_persistent_value(const char *name,
 
Quoted 13 lines

cmd/optee_rpmb.c static int read_persistent_value(const char *name, · line 93

Quoted 8 lines
cmd/optee_rpmb.c +4 -2
      rc = tee_shm_alloc(tee, name_size,
                         TEE_SHM_ALLOC, &shm_name);
-     if (rc)
-             return -ENOMEM;
+     if (rc) {
+             rc = -ENOMEM;
+             goto close_session;
+     }

I don't think you need the session to be opened to allocate memory. So instead of of doing this, why don't we just move the alloc call before opening the session?

That's correct, but avb_ta_open_session() wrapper calls
both tee_find_device()/
tee_open_session(), and tee_shm_alloc() expects valid tee device as param, which
is initialized by tee_find_device(). My intention was to address the only one particular issue
that was catched by CI and explained in [1] instead of doing overhaul of the whole optee_rpmb cmd implementation.

Quoted 50 lines

cmd/optee_rpmb.c static int write_persistent_value(const char

Quoted 14 lines
cmd/optee_rpmb.c +3 -0
      rc = tee_shm_alloc(tee, buffer_size,
                         TEE_SHM_ALLOC, &shm_buf);
@@ -125,6 +127,9 @@ out:
      tee_shm_free(shm_buf);
 free_name:
      tee_shm_free(shm_name);
+close_session:
+     tee_close_session(tee, session);
+     tee = NULL;
 
      return rc;
 }
@@ -139,17 +144,20 @@ static int write_persistent_value(const char

*name,

Quoted 11 lines
cmd/optee_rpmb.c +3 -1
      struct tee_param param[2];
      size_t name_size = strlen(name) + 1;
 
+     if (!value_size)
+             return -EINVAL;
+
      if (!tee) {
              if (avb_ta_open_session())
                      return -ENODEV;
      }
-     if (!value_size)

cmd/optee_rpmb.c static int write_persistent_value(const char *name, · line 160

Quoted 10 lines
cmd/optee_rpmb.c +4 -3
-             return -EINVAL;
 
      rc = tee_shm_alloc(tee, name_size,
                         TEE_SHM_ALLOC, &shm_name);
-     if (rc)
-             return -ENOMEM;
+     if (rc) {
+             rc = -ENOMEM;
+             goto close_session;
+     }

ditto

Quoted 11 lines
cmd/optee_rpmb.c +3 -0
      rc = tee_shm_alloc(tee, value_size,
                         TEE_SHM_ALLOC, &shm_buf);
@@ -178,6 +186,9 @@ out:
      tee_shm_free(shm_buf);
 free_name:
      tee_shm_free(shm_name);
+close_session:
+     tee_close_session(tee, session);
+     tee = NULL;
 
Quoted 9 lines
Quoted 5 lines
cmd/optee_rpmb.c +0 -1
      return rc;
 }
--

2.34.1

Thanks
/Ilias

[1]
https://lore.kernel.org/all/[email protected]/T/

--
Best regards - Atentamente - Meilleures salutations

Igor Opaniuk

mailto: [email protected]
skype: igor.opanyuk
https://www.linkedin.com/in/iopaniuk <http://ua.linkedin.com/in/iopaniuk>

Signature · 7 lines
Best regards - Atentamente - Meilleures salutations

Igor Opaniuk

mailto: [email protected]
skype: igor.opanyuk
https://www.linkedin.com/in/iopaniuk <http://ua.linkedin.com/in/iopaniuk>
#11 lore raw

PATCH v4 3/5 cmd: optee_rpmb: build cmd for sandbox

In reply to Igor Opaniuk

Support CMD_OPTEE_RPMB for SANDBOX configurations. Test:

$ ./u-boot -d arch/sandbox/dts/test.dtb
...
=> optee_rpmb write_pvalue test_variable test_value
Wrote 11 bytes
=> optee_rpmb read_pvalue test_variable 11
Read 11 bytes, value = test_value

---

(no changes since v2)

Changes in v2:
- Applied R-b and T-b tags

 cmd/Kconfig | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
cmd/Kconfig +3 -1
index 61e280fb1a4..227d66a7eea 100644
@@ -1394,7 +1394,9 @@ config CMD_CLONE
 
 config CMD_OPTEE_RPMB
 	bool "Enable read/write support on RPMB via OPTEE"
-	depends on SUPPORT_EMMC_RPMB && OPTEE
+	depends on (SUPPORT_EMMC_RPMB && OPTEE) || SANDBOX_TEE
+	default y if SANDBOX_TEE
+	select OPTEE_TA_AVB if SANDBOX_TEE
 	help
 	  Enable the commands for reading, writing persistent named values
 	  in the Replay Protection Memory Block partition in eMMC by
Signature · 1 line
2.34.1
#12 lore raw

PATCH v4 4/5 test: py: add optee_rpmb tests

In reply to Igor Opaniuk

Add read/write tests for optee_rpmb cmd.

---

(no changes since v1)

 test/py/tests/test_optee_rpmb.py | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 test/py/tests/test_optee_rpmb.py
test/py/tests/test_optee_rpmb.py new file +20 -0
new file mode 100644
index 00000000000..8a081b5c494
@@ -0,0 +1,20 @@
+# SPDX-License-Identifier:  GPL-2.0+
+#
+# Tests for OP-TEE RPMB read/write support
+
+"""
+This tests optee_rpmb cmd in U-Boot
+"""
+
+import pytest
+import u_boot_utils as util
+
[email protected]('cmd_optee_rpmb')
+def test_optee_rpmb_read_write(u_boot_console):
+    """Test OP-TEE RPMB cmd read/write
+    """
+    response = u_boot_console.run_command('optee_rpmb write_pvalue test_variable test_value')
+    assert response == 'Wrote 11 bytes'
+
+    response = u_boot_console.run_command('optee_rpmb read_pvalue test_variable 11')
+    assert response == 'Read 11 bytes, value = test_value'
\ No newline at end of file
Signature · 1 line
2.34.1
#13 lore raw

PATCH v4 5/5 tee: remove common.h inclusion

In reply to Igor Opaniuk

The usage of the common.h include file is deprecated [1], and has already been removed from several files.
Get rid of all inclusions in the "drivers/tee" directory, and replace it with required include files directly where needed.

[1] doc/develop/codingstyle.rst

---

(no changes since v3)

Changes in v3:
- Added calls for closing tee session after every read/write operation
- Added calls for closing tee session after every read/write operation

Changes in v2:
- Fixed chimp_optee.c:37:9: error: implicit declaration of function 'memset'
- Applied R-b and T-b tags
- Fixed chimp_optee.c:37:9: error: implicit declaration of function 'memset'

 drivers/tee/broadcom/chimp_optee.c | 3 ++-
 drivers/tee/optee/core.c           | 1 -
 drivers/tee/optee/i2c.c            | 1 -
 drivers/tee/optee/rpmb.c           | 1 -
 drivers/tee/optee/supplicant.c     | 2 +-
 drivers/tee/sandbox.c              | 2 +-
 drivers/tee/tee-uclass.c           | 1 -
 7 files changed, 4 insertions(+), 7 deletions(-)
drivers/tee/broadcom/chimp_optee.c +2 -1
index 37f9b094f76..bd146ef2899 100644
@@ -3,9 +3,10 @@
  * Copyright 2020 Broadcom.
  */
 
-#include <common.h>
 #include <tee.h>
 #include <broadcom/chimp.h>
+#include <linux/errno.h>
+#include <string.h>
 
 #ifdef CONFIG_CHIMP_OPTEE
 
drivers/tee/optee/core.c +0 -1
index 47f845cffe3..5fc0505c788 100644
@@ -3,7 +3,6 @@
  * Copyright (c) 2018-2020 Linaro Limited
  */
 
-#include <common.h>
 #include <cpu_func.h>
 #include <dm.h>
 #include <dm/device_compat.h>
drivers/tee/optee/i2c.c +0 -1
index ef4e10f9912..e3fb99897c5 100644
@@ -3,7 +3,6 @@
  * Copyright (c) 2020 Foundries.io Ltd
  */
 
-#include <common.h>
 #include <dm.h>
 #include <i2c.h>
 #include <tee.h>
drivers/tee/optee/rpmb.c +0 -1
index 5bc13757ea8..bacced6af6c 100644
@@ -3,7 +3,6 @@
  * Copyright (c) 2018 Linaro Limited
  */
 
-#include <common.h>
 #include <dm.h>
 #include <log.h>
 #include <tee.h>
drivers/tee/optee/supplicant.c +1 -1
index f9dd874b594..8a426f53ba8 100644
@@ -3,10 +3,10 @@
  * Copyright (c) 2018, Linaro Limited
  */
 
-#include <common.h>
 #include <log.h>
 #include <malloc.h>
 #include <tee.h>
+#include <linux/errno.h>
 #include <linux/types.h>
 
 #include "optee_msg.h"
drivers/tee/sandbox.c +1 -1
index ec66401878c..8ad7c09efdd 100644
@@ -2,7 +2,7 @@
 /*
  * Copyright (C) 2018 Linaro Limited
  */
-#include <common.h>
+
 #include <dm.h>
 #include <sandboxtee.h>
 #include <tee.h>
drivers/tee/tee-uclass.c +0 -1
index 52412a4098e..0194d732193 100644
@@ -5,7 +5,6 @@
 
 #define LOG_CATEGORY UCLASS_TEE
 
-#include <common.h>
 #include <cpu_func.h>
 #include <dm.h>
 #include <log.h>
Signature · 1 line
2.34.1
#14 lore raw

Re: [PATCH v4 5/5] tee: remove common.h inclusion

I've already reviewed this one. [0]
I'll add my tag

[0] https://lore.kernel.org/u-boot/CAC_iWjLZcKEo6-0P_gkz5UOe7VanuNv1+=i3xcUTKVo5B1tpQg@mail.gmail.com/
Cheers
/Ilias

Quoted 127 lines · Igor Opaniuk

The usage of the common.h include file is deprecated [1], and has already been removed from several files.
Get rid of all inclusions in the "drivers/tee" directory, and replace it with required include files directly where needed.

[1] doc/develop/codingstyle.rst

---

(no changes since v3)

Changes in v3:
- Added calls for closing tee session after every read/write operation
- Added calls for closing tee session after every read/write operation

Changes in v2:
- Fixed chimp_optee.c:37:9: error: implicit declaration of function 'memset'
- Applied R-b and T-b tags
- Fixed chimp_optee.c:37:9: error: implicit declaration of function 'memset'

 drivers/tee/broadcom/chimp_optee.c | 3 ++-
 drivers/tee/optee/core.c           | 1 -
 drivers/tee/optee/i2c.c            | 1 -
 drivers/tee/optee/rpmb.c           | 1 -
 drivers/tee/optee/supplicant.c     | 2 +-
 drivers/tee/sandbox.c              | 2 +-
 drivers/tee/tee-uclass.c           | 1 -
 7 files changed, 4 insertions(+), 7 deletions(-)
drivers/tee/broadcom/chimp_optee.c +2 -1
index 37f9b094f76..bd146ef2899 100644
@@ -3,9 +3,10 @@
  * Copyright 2020 Broadcom.
  */
 
-#include <common.h>
 #include <tee.h>
 #include <broadcom/chimp.h>
+#include <linux/errno.h>
+#include <string.h>
 
 #ifdef CONFIG_CHIMP_OPTEE
 
drivers/tee/optee/core.c +0 -1
index 47f845cffe3..5fc0505c788 100644
@@ -3,7 +3,6 @@
  * Copyright (c) 2018-2020 Linaro Limited
  */
 
-#include <common.h>
 #include <cpu_func.h>
 #include <dm.h>
 #include <dm/device_compat.h>
drivers/tee/optee/i2c.c +0 -1
index ef4e10f9912..e3fb99897c5 100644
@@ -3,7 +3,6 @@
  * Copyright (c) 2020 Foundries.io Ltd
  */
 
-#include <common.h>
 #include <dm.h>
 #include <i2c.h>
 #include <tee.h>
drivers/tee/optee/rpmb.c +0 -1
index 5bc13757ea8..bacced6af6c 100644
@@ -3,7 +3,6 @@
  * Copyright (c) 2018 Linaro Limited
  */
 
-#include <common.h>
 #include <dm.h>
 #include <log.h>
 #include <tee.h>
drivers/tee/optee/supplicant.c +1 -1
index f9dd874b594..8a426f53ba8 100644
@@ -3,10 +3,10 @@
  * Copyright (c) 2018, Linaro Limited
  */
 
-#include <common.h>
 #include <log.h>
 #include <malloc.h>
 #include <tee.h>
+#include <linux/errno.h>
 #include <linux/types.h>
 
 #include "optee_msg.h"
drivers/tee/sandbox.c +1 -1
index ec66401878c..8ad7c09efdd 100644
@@ -2,7 +2,7 @@
 /*
  * Copyright (C) 2018 Linaro Limited
  */
-#include <common.h>
+
 #include <dm.h>
 #include <sandboxtee.h>
 #include <tee.h>
drivers/tee/tee-uclass.c +0 -2
index 52412a4098e..0194d732193 100644
@@ -5,7 +5,6 @@
 
 #define LOG_CATEGORY UCLASS_TEE
 
-#include <common.h>
 #include <cpu_func.h>
 #include <dm.h>
 #include <log.h>
--

2.34.1

#15 lore raw
In reply to Igor Opaniuk

Thanks Igor

I'll pick this up

Quoted 44 lines · Igor Opaniuk

- Address some spelling errors and typos
- Support CMD_OPTEE_RPMB for SANDBOX configurations and add python tests
- Remove common.h inclusion for drivers/tee
- Add calls for closing tee session after every read/write operation.

CI build:
[1] https://dev.azure.com/igoropaniuk/u-boot/_build/results?buildId=31&view=results

Changes in v4:
- Rebased on the latest master and excluded "tee: sandbox: fix spelling errors", as it was merged already by Heinrich Schuchardt

Changes in v3:
- Added calls for closing tee session after every read/write operation

Changes in v2:
- Fixed chimp_optee.c:37:9: error: implicit declaration of function 'memset'
- Applied R-b and T-b tags

Igor Opaniuk (5):
tee: optee: fix description in Kconfig
cmd: optee_rpmb: close tee session
cmd: optee_rpmb: build cmd for sandbox
test: py: add optee_rpmb tests
tee: remove common.h inclusion

 cmd/Kconfig                        |  4 +++-
 cmd/optee_rpmb.c                   | 23 +++++++++++++++++------
 drivers/tee/broadcom/chimp_optee.c |  3 ++-
 drivers/tee/optee/Kconfig          |  2 +-
 drivers/tee/optee/core.c           |  1 -
 drivers/tee/optee/i2c.c            |  1 -
 drivers/tee/optee/rpmb.c           |  1 -
 drivers/tee/optee/supplicant.c     |  2 +-
 drivers/tee/sandbox.c              |  2 +-
 drivers/tee/tee-uclass.c           |  1 -
 test/py/tests/test_optee_rpmb.py   | 20 ++++++++++++++++++++
 11 files changed, 45 insertions(+), 15 deletions(-)
 create mode 100644 test/py/tests/test_optee_rpmb.py

--
2.34.1