From: Patrice CHOTARD <patrice.chotard@foss.st.com>
To: Etienne Carriere <etienne.carriere@foss.st.com>, <u-boot@lists.denx.de>
Cc: Jens Wiklander <jens.wiklander@linaro.org>,
Patrick Delaunay <patrick.delaunay@foss.st.com>
Subject: Re: [PATCH 2/2] tee: optee: don't enumerate services if there ain't any
Date: Fri, 1 Dec 2023 11:05:54 +0100 [thread overview]
Message-ID: <4e22ffe4-c275-43de-a8be-3a1dc9f931ac@foss.st.com> (raw)
In-Reply-To: <20231129123753.1906956-2-etienne.carriere@foss.st.com>
On 11/29/23 13:37, Etienne Carriere wrote:
> Change optee driver service enumeration to not enumerate (and
> allocate a zero sized shared memory buffer) when OP-TEE
> reports that there is no service to enumerate.
>
> This change fixes an existing issue that occurs when the such zero
> sized shared memory buffer allocated from malloc() has a physical
> address of offset 0 of a physical 4kB page. In such case, OP-TEE
> secure world refuses to register the zero-sized shared memory
> area and makes U-Boot optee service enumeration to fail.
>
> Fixes: 94ccfb78a4d6 ("drivers: tee: optee: discover OP-TEE services")
> Signed-off-by: Etienne Carriere <etienne.carriere@foss.st.com>
> ---
> drivers/tee/optee/core.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c
> index 5308dd58ce..47f845cffe 100644
> --- a/drivers/tee/optee/core.c
> +++ b/drivers/tee/optee/core.c
> @@ -139,6 +139,11 @@ static int enum_services(struct udevice *dev, struct tee_shm **shm, size_t *coun
> if (ret)
> return ret;
>
> + if (!shm_size) {
> + *count = 0;
> + return 0;
> + }
> +
> ret = tee_shm_alloc(dev, shm_size, 0, shm);
> if (ret) {
> dev_err(dev, "Failed to allocated shared memory: %d\n", ret);
> @@ -185,14 +190,15 @@ static int bind_service_drivers(struct udevice *dev)
>
> ret = enum_services(dev, &service_list, &service_count, tee_sess,
> PTA_CMD_GET_DEVICES);
> - if (!ret)
> + if (!ret && service_count)
> ret = bind_service_list(dev, service_list, service_count);
>
> tee_shm_free(service_list);
> + service_list = NULL;
>
> ret2 = enum_services(dev, &service_list, &service_count, tee_sess,
> PTA_CMD_GET_DEVICES_SUPP);
> - if (!ret2)
> + if (!ret2 && service_count)
> ret2 = bind_service_list(dev, service_list, service_count);
>
> tee_shm_free(service_list);
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
Thanks
Patrice
next prev parent reply other threads:[~2023-12-01 10:06 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-29 12:37 [PATCH 1/2] tee: optee: don't fail on services enumeration failure Etienne Carriere
2023-11-29 12:37 ` [PATCH 2/2] tee: optee: don't enumerate services if there ain't any Etienne Carriere
2023-12-01 10:05 ` Patrice CHOTARD [this message]
2023-12-05 15:20 ` Jens Wiklander
2023-12-19 17:46 ` Tom Rini
2023-12-01 10:05 ` [PATCH 1/2] tee: optee: don't fail on services enumeration failure Patrice CHOTARD
2023-12-05 15:14 ` Jens Wiklander
2023-12-19 17:46 ` Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4e22ffe4-c275-43de-a8be-3a1dc9f931ac@foss.st.com \
--to=patrice.chotard@foss.st.com \
--cc=etienne.carriere@foss.st.com \
--cc=jens.wiklander@linaro.org \
--cc=patrick.delaunay@foss.st.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox