Hi All,
Please find the link to the TrustedFirmware Community Code of Conduct here:
https://developer.trustedfirmware.org/w/collaboration/community_guidelines/…
Trusted Firmware has a very diverse and global developer community. It is
important that we adhere to the code of conduct in all our interactions.
For some of you all this may be new and for others just a gentle reminder.
In either case, if you have any questions, please feel free to reach out to
me directly.
And thanks to you all for your contributions to the TrustedFirmware
community!
Best regards,
Don Harbin
TrustedFirmware Community Manager
don.harbin(a)linaro.org
Hi,
We don't have any topics for the meeting this month. Hence cancelling.
Following topics related to OP-TEE will be presented in Linaro Connect Tech
Day : Core Technologies
<https://www.linaro.org/events/linaro-connect-tech-day-core-technologies/> on
March 29. Feel free to join us there.
- OP-TEE and FF-A evolution
- OP-TEE Lightning Talk
Regards,
Ruchika
(on behalf of OP-TEE team)
Hi,
I have been exploring secure storage in OP-TEE for a few days and I need
some help in putting some files into it.
I have been trying to find some tool which could help me put any files from
Linux into secure storage and retrieve them back later so that I could
see secure storage in action but haven't been able to find any yet.
Is there any tool which you guys might know of which helps put files in
secure storage and retrieve them back later?
Best Regards,
Manorit
Hi all,
This patchset is a general cleanup of shared memory handling in the TEE
subsystem.
Until now has the in-kernel tee clients used tee_shm_alloc() and
tee_shm_register() to share memory with secure world. These two function
exposes via a flags parameter a bit more of the internals of the TEE
subsystem than one would like. So in order to make things easier are those
two functions replaced by few functions which should provide better
abstraction.
Two in-kernel tee clients are updated to use these new functions.
The shared memory pool handling is simplified, an internal matter for the
two TEE drivers OP-TEE and AMDTEE.
In the v3 review it was suggested [1] to break out "optee: add driver
private tee_context" and "optee: use driver internal tee_contex for some
rpc" into a separate patch to fix to allow those a faster path upstream as
they fix reported problems. So this patchset is now rebased on top of those
patches separated.
This patchset is based on [2] and is also available at [3].
Thanks,
Jens
[1] https://lore.kernel.org/lkml/20220125162938.838382-1-jens.wiklander@linaro.…
[2] https://git.linaro.org/people/jens.wiklander/linux-tee.git/log/?h=fixes
[3] https://git.linaro.org/people/jens.wiklander/linux-tee.git/log/?h=tee_shm_v4
v3->v4:
* Broke out "optee: add driver private tee_context" and "optee: use driver
internal tee_contex for some rpc" into a separate patch as that fixes
earlier reported issues and deserves a to go into v5.17 and stable
trees.
* Rebased on the recent fixes for the OP-TEE driver on top of v5.17-rc2
* All patches are now reviewed by Sumit Garg + some small fixes from the
last review
v2->v3:
* Make tee_shm_alloc_user_buf() and tee_shm_register_user_buf() internal
and don't export them to the drivers.
* Rename tee_shm_alloc_priv_kernel_buf() to tee_shm_alloc_priv_buf()
* Adressing comments on variable names and choice of types in "tee: replace
tee_shm_register()"
* Adding detailed explaination on alignment in "tee: simplify shm pool handling"
* Added Sumits R-B on a few of the patches
v1->v2:
* The commits three "tee: add tee_shm_alloc_kernel_buf()",
"tpm_ftpm_tee: use tee_shm_alloc_kernel_buf()" and
"firmware: tee_bnxt: use tee_shm_alloc_kernel_buf()" has been merged some
time ago as part of another patchset.
* Another in-kernel tee client is updated with the commit
"KEYS: trusted: tee: use tee_shm_register_kernel_buf()"
* tee_shm_alloc_anon_kernel_buf() is replaced with an easier to use function
tee_shm_alloc_priv_kernel_buf() and tee_shm_free_anon_kernel_buf() has
been dropped.
* A driver internal struct tee_context is used to when doing driver internal
calls to secure world.
* Adds patches to replace tee_shm_register() in a similar way as how
tee_shm_alloc() is replaced.
* A patch is added to clean up the TEE_SHM_* flags
* Fixed a warning reported by kernel test robot <lkp(a)intel.com>
Jens Wiklander (10):
hwrng: optee-rng: use tee_shm_alloc_kernel_buf()
tee: remove unused tee_shm_pool_alloc_res_mem()
tee: add tee_shm_alloc_user_buf()
tee: simplify shm pool handling
tee: replace tee_shm_alloc()
optee: add optee_pool_op_free_helper()
tee: add tee_shm_register_{user,kernel}_buf()
KEYS: trusted: tee: use tee_shm_register_kernel_buf()
tee: replace tee_shm_register()
tee: refactor TEE_SHM_* flags
drivers/char/hw_random/optee-rng.c | 6 +-
drivers/tee/amdtee/shm_pool.c | 55 ++--
drivers/tee/optee/Kconfig | 8 -
drivers/tee/optee/call.c | 2 +-
drivers/tee/optee/core.c | 21 +-
drivers/tee/optee/device.c | 5 +-
drivers/tee/optee/ffa_abi.c | 63 ++---
drivers/tee/optee/optee_private.h | 7 +-
drivers/tee/optee/smc_abi.c | 125 +++------
drivers/tee/tee_core.c | 5 +-
drivers/tee/tee_private.h | 15 +-
drivers/tee/tee_shm.c | 320 +++++++++++++++--------
drivers/tee/tee_shm_pool.c | 162 +++---------
include/linux/tee_drv.h | 138 +++-------
security/keys/trusted-keys/trusted_tee.c | 23 +-
15 files changed, 388 insertions(+), 567 deletions(-)
--
2.31.1
Hi,
OP-TEE Contributions (LOC) monthly meeting is planned for Thursday Feb 24
@16.00 (UTC).
We have following on the agenda
- SDP DT Configuration, Olivier Masse, NXP
If you have any more topics you'd like to discuss, please let us know and
we can schedule them.
Meeting details:
---------------
Date/time: Feb 24(a)16.00 (UTC)
https://everytimezone.com/s/fef76b1b
Connection details: https://www.trustedfirmware.org/meetings/
Meeting notes: http://bit.ly/loc-notes
Regards,
Ruchika on behalf of the Linaro OP-TEE team
Hello arm-soc maintainers,
Please pull this TEE shared memory cleanup. Some kernel internal APIs are
replaced with easier to use counter parts. The TEE shared memory pool is
also simplified.
Note that this pull request includes two patches which are outside the TEE
subsystem:
- 231b1fc5da09 ("KEYS: trusted: tee: use tee_shm_register_kernel_buf()")
- e7ddab084740 ("hwrng: optee-rng: use tee_shm_alloc_kernel_buf()")
Those patches are reviewed by their maintainer. I've also asked the
maintainers that normally sends patches upstream for these modules if it's
OK that I take these patches via my tree. As I got no answer I assume that
it's OK.
This pull request is on top of the patch, aceeafefff73 ("optee: use driver
internal tee_context for some rpc"), I've already sent (and has since been
merged) for the 5.17 kernel. That's why I'm not including it in the stat.
Thanks,
Jens
The following changes since commit aceeafefff736057e8f93f19bbfbef26abd94604:
optee: use driver internal tee_context for some rpc (2022-02-03 13:36:32 +0100)
are available in the Git repository at:
git://git.linaro.org:/people/jens.wiklander/linux-tee.git tags/tee-shm-for-v5.18
for you to fetch changes up to a45ea4efa358577c623d7353a6ba9af3c17f6ca0:
tee: refactor TEE_SHM_* flags (2022-02-16 07:49:41 +0100)
----------------------------------------------------------------
TEE shared memory cleanup for v5.18
- The TEE shared memory pool based on two pools is replaced with a single
somewhat more capable pool.
- Replaces tee_shm_alloc() and tee_shm_register() with new functions
easier to use and maintain. The TEE subsystem and the TEE drivers are
updated to use the new functions instead.
- The TEE based Trusted keys routines are updated to use the new
simplified functions above.
- The OP-TEE based rng driver is updated to use the new simplified
functions above.
- The TEE_SHM-flags are refactored to better match their usage
----------------------------------------------------------------
Jens Wiklander (10):
hwrng: optee-rng: use tee_shm_alloc_kernel_buf()
tee: remove unused tee_shm_pool_alloc_res_mem()
tee: add tee_shm_alloc_user_buf()
tee: simplify shm pool handling
tee: replace tee_shm_alloc()
optee: add optee_pool_op_free_helper()
tee: add tee_shm_register_{user,kernel}_buf()
KEYS: trusted: tee: use tee_shm_register_kernel_buf()
tee: replace tee_shm_register()
tee: refactor TEE_SHM_* flags
drivers/char/hw_random/optee-rng.c | 6 +-
drivers/tee/amdtee/shm_pool.c | 55 ++----
drivers/tee/optee/Kconfig | 8 -
drivers/tee/optee/call.c | 2 +-
drivers/tee/optee/core.c | 21 +-
drivers/tee/optee/device.c | 5 +-
drivers/tee/optee/ffa_abi.c | 63 ++----
drivers/tee/optee/optee_private.h | 7 +-
drivers/tee/optee/smc_abi.c | 125 ++++--------
drivers/tee/tee_core.c | 5 +-
drivers/tee/tee_private.h | 15 +-
drivers/tee/tee_shm.c | 320 ++++++++++++++++++++-----------
drivers/tee/tee_shm_pool.c | 162 ++++------------
include/linux/tee_drv.h | 138 +++----------
security/keys/trusted-keys/trusted_tee.c | 23 +--
15 files changed, 388 insertions(+), 567 deletions(-)
Hello arm-soc maintainers,
Please pull this small AMDTEE driver simplification to use the LIST_HEAD()
macro instead for a global variable.
Note that this isn't a usual Arm driver update. This targets AMD instead,
but is part of the TEE subsystem.
Thanks,
Jens
The following changes since commit 26291c54e111ff6ba87a164d85d4a4e134b7315c:
Linux 5.17-rc2 (2022-01-30 15:37:07 +0200)
are available in the Git repository at:
git://git.linaro.org:/people/jens.wiklander/linux-tee.git tags/amdtee-for-v5.18
for you to fetch changes up to f7b67642dd98617dc569836cdcba041c7ff00cbb:
tee: amdtee: Make use of the helper macro LIST_HEAD() (2022-02-14 10:57:55 +0100)
----------------------------------------------------------------
Small simplification in AMDTE driver
----------------------------------------------------------------
Cai Huoqing (1):
tee: amdtee: Make use of the helper macro LIST_HEAD()
drivers/tee/amdtee/call.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Hello arm-soc maintainers,
Please pull this small OP-TEE driver fix taking care of a broken return
code in the error path of the two probe functions in the OP-TEE driver.
Please note that this pull request is on top of the previously just merged
patch which introduced the problem fixed here.
Thanks,
Jens
The following changes since commit aceeafefff736057e8f93f19bbfbef26abd94604:
optee: use driver internal tee_context for some rpc (2022-02-03 13:36:32 +0100)
are available in the Git repository at:
git://git.linaro.org/people/jens.wiklander/linux-tee.git tags/optee-fix2-for-v5.17
for you to fetch changes up to 40eb0dcf4114cbfff4d207890fa5a19e82da9fdc:
tee: optee: fix error return code in probe function (2022-02-14 12:36:48 +0100)
----------------------------------------------------------------
OP-TEE fix error return code in probe functions
----------------------------------------------------------------
Yang Yingliang (1):
tee: optee: fix error return code in probe function
drivers/tee/optee/ffa_abi.c | 4 +++-
drivers/tee/optee/smc_abi.c | 4 +++-
2 files changed, 6 insertions(+), 2 deletions(-)
Hello arm-soc maintainers,
Please pull this OP-TEE driver fix which decouples driver private shared
memory objects from the original tee_context. This fixes the root cause of
a shutdown problem where the driver would dead-lock waiting for tee-supplicant.
Thanks,
Jens
The following changes since commit 26291c54e111ff6ba87a164d85d4a4e134b7315c:
Linux 5.17-rc2 (2022-01-30 15:37:07 +0200)
are available in the Git repository at:
git://git.linaro.org/people/jens.wiklander/linux-tee.git tags/optee-fix-for-v5.17
for you to fetch changes up to aceeafefff736057e8f93f19bbfbef26abd94604:
optee: use driver internal tee_context for some rpc (2022-02-03 13:36:32 +0100)
----------------------------------------------------------------
OP-TEE fix shutdown problems
----------------------------------------------------------------
Jens Wiklander (1):
optee: use driver internal tee_context for some rpc
drivers/tee/optee/core.c | 1 +
drivers/tee/optee/ffa_abi.c | 77 ++++++++++++++++++++++-----------------
drivers/tee/optee/optee_private.h | 5 ++-
drivers/tee/optee/smc_abi.c | 48 +++++++++---------------
4 files changed, 64 insertions(+), 67 deletions(-)
Hi all,
This patchset is a general cleanup of shared memory handling in the TEE
subsystem.
Until now has the in-kernel tee clients used tee_shm_alloc() and
tee_shm_register() to share memory with secure world. These two function
exposes via a flags parameter a bit more of the internals of the TEE
subsystem than one would like. So in order to make things easier are those
two functions replaced by few functions which should provide better
abstraction.
Two in-kernel tee clients are updated to use these new functions.
The shared memory pool handling is simplified, an internal matter for the
two TEE drivers OP-TEE and AMDTEE.
An OP-TEE driver internal tee_context is added to handle shared memory
allocations received via RPC, for instance the argument structure needed
to make more complex RPC requests. The tee_context used when doing such a
memory allocation must be kept until the memory is freed. With this we can
avoid keeping a tee_context of a client around for longer than necessary.
In the v1 review it was suggested [1] to allow physically non-contiguous
memory allocations by the drivers. It turned out to be harder than
anticipated so I'll save that for a separate patch.
This patchset is also available at [2].
Thanks,
Jens
[1] https://lore.kernel.org/linux-arm-kernel/20210609145811.GJ4910@sequoia/
[2] https://git.linaro.org/people/jens.wiklander/linux-tee.git/log/?h=tee_shm_v3
v2->v3:
* Make tee_shm_alloc_user_buf() and tee_shm_register_user_buf() internal
and don't export them to the drivers.
* Rename tee_shm_alloc_priv_kernel_buf() to tee_shm_alloc_priv_buf()
* Adressing comments on variable names and choice of types in "tee: replace
tee_shm_register()"
* Adding detailed explaination on alignment in "tee: simplify shm pool handling"
* Added Sumits R-B on a few of the patches
v1->v2:
* The commits three "tee: add tee_shm_alloc_kernel_buf()",
"tpm_ftpm_tee: use tee_shm_alloc_kernel_buf()" and
"firmware: tee_bnxt: use tee_shm_alloc_kernel_buf()" has been merged some
time ago as part of another patchset.
* Another in-kernel tee client is updated with the commit
"KEYS: trusted: tee: use tee_shm_register_kernel_buf()"
* tee_shm_alloc_anon_kernel_buf() is replaced with an easier to use function
tee_shm_alloc_priv_kernel_buf() and tee_shm_free_anon_kernel_buf() has
been dropped.
* A driver internal struct tee_context is used to when doing driver internal
calls to secure world.
* Adds patches to replace tee_shm_register() in a similar way as how
tee_shm_alloc() is replaced.
* A patch is added to clean up the TEE_SHM_* flags
* Fixed a warning reported by kernel test robot <lkp(a)intel.com>
Jens Wiklander (12):
hwrng: optee-rng: use tee_shm_alloc_kernel_buf()
tee: remove unused tee_shm_pool_alloc_res_mem()
tee: add tee_shm_alloc_user_buf()
tee: simplify shm pool handling
tee: replace tee_shm_alloc()
optee: add driver private tee_context
optee: use driver internal tee_contex for some rpc
optee: add optee_pool_op_free_helper()
tee: add tee_shm_register_{user,kernel}_buf()
KEYS: trusted: tee: use tee_shm_register_kernel_buf()
tee: replace tee_shm_register()
tee: refactor TEE_SHM_* flags
drivers/char/hw_random/optee-rng.c | 6 +-
drivers/tee/amdtee/shm_pool.c | 55 ++--
drivers/tee/optee/Kconfig | 8 -
drivers/tee/optee/call.c | 2 +-
drivers/tee/optee/core.c | 22 +-
drivers/tee/optee/device.c | 5 +-
drivers/tee/optee/ffa_abi.c | 136 ++++------
drivers/tee/optee/optee_private.h | 12 +-
drivers/tee/optee/smc_abi.c | 159 +++--------
drivers/tee/tee_core.c | 5 +-
drivers/tee/tee_private.h | 15 +-
drivers/tee/tee_shm.c | 320 +++++++++++++++--------
drivers/tee/tee_shm_pool.c | 162 +++---------
include/linux/tee_drv.h | 138 +++-------
security/keys/trusted-keys/trusted_tee.c | 23 +-
15 files changed, 438 insertions(+), 630 deletions(-)
--
2.31.1
The addition of a shutdown hook by commit f25889f93184 ("optee:
fix tee out of memory failure seen during kexec reboot") introduced a
kernel shutdown regression that can be triggered after running the
xtest suites.
Once the shutdown hook is called it is not possible to communicate any
more with the supplicant process because the system is not scheduling
task any longer. Thus if the optee driver shutdown path receives a
supplicant RPC request from the OP-TEE we will deadlock the kernel's
shutdown.
This unexpected event will in fact occur after the xtest suite has
been run. It seems some cached SHM kept alive a context object which
in turn kept alive a session towards a PTA or TA. Closing the session
results in a socket RPC command being sent back from OP-TEE.
This sequence of events is captured by a 5.15 kernel annotated with
extra prints:
Calling OPTEE_SMC_DISABLE_SHM_CACHE
OPTEE_SMC_DISABLE_SHM_CACHE returned 0
freeing SHM ptr 0xFFFFFF8001079380
Calling OPTEE_SMC_DISABLE_SHM_CACHE
OPTEE_SMC_DISABLE_SHM_CACHE returned 0
freeing SHM ptr 0xFFFFFF8001CC5580
Calling OPTEE_SMC_DISABLE_SHM_CACHE
OPTEE_SMC_DISABLE_SHM_CACHE returned 0
freeing SHM ptr 0xFFFFFF8006308A80
Calling OPTEE_SMC_DISABLE_SHM_CACHE
OPTEE_SMC_DISABLE_SHM_CACHE returned 0
freeing SHM ptr 0xFFFFFF8006308B00
optee: optee_handle_rpc: a0=0XFFFF0000 a1=0XA0 a2=0X0
optee: optee_handle_rpc: a0=0XFFFF0005 a1=0XFFFFFF80 a2=0X61E6500
optee: handle_rpc_func_cmd: cmd = 0XA
optee_supp_thrd_req: func=0XA
Introduce a shutdown state in the optee device object to return an
immediate error to all RPC requests in the shutdown path.
Fixes: f25889f93184 ("optee: fix tee out of memory failure seen during kexec reboot")
Signed-off-by: Lars Persson <larper(a)axis.com>
---
drivers/tee/optee/optee_private.h | 1 +
drivers/tee/optee/smc_abi.c | 5 ++++-
drivers/tee/optee/supp.c | 8 ++++++++
3 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/drivers/tee/optee/optee_private.h b/drivers/tee/optee/optee_private.h
index 46f74ab07c7e..9eb72931e11f 100644
--- a/drivers/tee/optee/optee_private.h
+++ b/drivers/tee/optee/optee_private.h
@@ -162,6 +162,7 @@ struct optee {
struct tee_shm_pool *pool;
unsigned int rpc_arg_count;
bool scan_bus_done;
+ bool shutting_down;
struct workqueue_struct *scan_bus_wq;
struct work_struct scan_bus_work;
};
diff --git a/drivers/tee/optee/smc_abi.c b/drivers/tee/optee/smc_abi.c
index 449d6a72d289..10af747da816 100644
--- a/drivers/tee/optee/smc_abi.c
+++ b/drivers/tee/optee/smc_abi.c
@@ -1356,7 +1356,10 @@ static int optee_smc_remove(struct platform_device *pdev)
*/
static void optee_shutdown(struct platform_device *pdev)
{
- optee_disable_shm_cache(platform_get_drvdata(pdev));
+ struct optee *optee = platform_get_drvdata(pdev);
+
+ optee->shutting_down = true;
+ optee_disable_shm_cache(optee);
}
static int optee_probe(struct platform_device *pdev)
diff --git a/drivers/tee/optee/supp.c b/drivers/tee/optee/supp.c
index 322a543b8c27..801b4ec659e8 100644
--- a/drivers/tee/optee/supp.c
+++ b/drivers/tee/optee/supp.c
@@ -83,6 +83,14 @@ u32 optee_supp_thrd_req(struct tee_context *ctx, u32 func, size_t num_params,
bool interruptable;
u32 ret;
+ /*
+ * When the system is shutting down we cannot talk
+ * to the supplicant anymore even if we seem to have
+ * an open session to it.
+ */
+ if (optee->shutting_down)
+ return TEEC_ERROR_COMMUNICATION;
+
/*
* Return in case there is no supplicant available and
* non-blocking request.
--
2.30.2
Hi,
OP-TEE Contributions (LOC) monthly meeting is planned for Thursday Jan 27
@16.00 (UTC).
If you have any topics you'd like to discuss, please let us know and we can
schedule them.
Meeting details:
---------------
Date/time: January 27(a)16.00 (UTC)
https://everytimezone.com/s/c3460919
Connection details: https://www.trustedfirmware.org/meetings/
Meeting notes: http://bit.ly/loc-notes
Regards,
Ruchika on behalf of the Linaro OP-TEE team
Hello arm-soc maintainers,
Please pull these OP-TEE driver fixes all concerning the recent changes
regarding FF-A and asynchronous notifications.
Thanks,
Jens
The following changes since commit e783362eb54cd99b2cac8b3a9aeac942e6f6ac07:
Linux 5.17-rc1 (2022-01-23 10:12:53 +0200)
are available in the Git repository at:
git://git.linaro.org/people/jens.wiklander/linux-tee.git tags/optee-fixes-for-v5.17
for you to fetch changes up to 4064c461148ab129dfe5eaeea129b4af6cf4b9b7:
optee: add error checks in optee_ffa_do_call_with_arg() (2022-01-24 13:00:59 +0100)
----------------------------------------------------------------
OP-TE fixes for v5.17
- Adds error checking in optee_ffa_do_call_with_arg()
- Reintroduces an accidentally lost fix for a memref size check
- Uses bitmap_free() to free memory obtained with bitmap_zalloc()
----------------------------------------------------------------
Christophe JAILLET (1):
optee: Use bitmap_free() to free bitmap
Jens Wiklander (1):
optee: add error checks in optee_ffa_do_call_with_arg()
Jerome Forissier (1):
tee: optee: do not check memref size on return from Secure World
drivers/tee/optee/ffa_abi.c | 15 ++++++++++++---
drivers/tee/optee/notif.c | 2 +-
drivers/tee/optee/smc_abi.c | 10 ----------
3 files changed, 13 insertions(+), 14 deletions(-)
Hi all,
This patchset is a general cleanup of shared memory handling in the TEE
subsystem.
Until now has the in-kernel tee clients used tee_shm_alloc() and
tee_shm_register() to share memory with secure world. These two function
exposes via a flags parameter a bit more of the internals of the TEE
subsystem than one would like. So in order to make things easier are those
two functions replaced by few functions which should provide better
abstraction.
Two in-kernel tee clients are updated to use these new functions.
The shared memory pool handling is simplified, an internal matter for the
two TEE drivers OP-TEE and AMDTEE.
An OP-TEE driver internal tee_context is added to handle shared memory
allocations received via RPC, for instance the argument structure needed
to make more complex RPC requests. The tee_context used when doing such a
memory allocation must be kept until the memory is freed. With this we can
avoid keeping a tee_context of a client around for longer than necessary.
In the v1 review it was suggested [1] to allow physically non-contiguous
memory allocations by the drivers. It turned out to be harder than
anticipated so I'll save that for a separate patch.
This patchset is also available at [2] and is based on the asynchronous
notification patches [3] which was just merged during this merge window.
Thanks,
Jens
[1] https://lore.kernel.org/linux-arm-kernel/20210609145811.GJ4910@sequoia/
[2] https://git.linaro.org/people/jens.wiklander/linux-tee.git/log/?h=tee_shm_v2
[3] https://git.linaro.org/people/jens.wiklander/linux-tee.git/log/?h=async_not…
v1->v2:
* The commits three "tee: add tee_shm_alloc_kernel_buf()",
"tpm_ftpm_tee: use tee_shm_alloc_kernel_buf()" and
"firmware: tee_bnxt: use tee_shm_alloc_kernel_buf()" has been merged some
time ago as part of another patchset.
* Another in-kernel tee client is updated with the commit
"KEYS: trusted: tee: use tee_shm_register_kernel_buf()"
* tee_shm_alloc_anon_kernel_buf() is replaced with an easier to use function
tee_shm_alloc_priv_kernel_buf() and tee_shm_free_anon_kernel_buf() has
been dropped.
* A driver internal struct tee_context is used to when doing driver internal
calls to secure world.
* Adds patches to replace tee_shm_register() in a similar way as how
tee_shm_alloc() is replaced.
* A patch is added to clean up the TEE_SHM_* flags
* Fixed a warning reported by kernel test robot <lkp(a)intel.com>
Jens Wiklander (12):
hwrng: optee-rng: use tee_shm_alloc_kernel_buf()
tee: remove unused tee_shm_pool_alloc_res_mem()
tee: add tee_shm_alloc_user_buf()
tee: simplify shm pool handling
tee: replace tee_shm_alloc()
optee: add driver private tee_context
optee: use driver internal tee_contex for some rpc
optee: add optee_pool_op_free_helper()
tee: add tee_shm_register_{user,kernel}_buf()
KEYS: trusted: tee: use tee_shm_register_kernel_buf()
tee: replace tee_shm_register()
tee: refactor TEE_SHM_* flags
drivers/char/hw_random/optee-rng.c | 6 +-
drivers/tee/amdtee/shm_pool.c | 55 ++--
drivers/tee/optee/Kconfig | 8 -
drivers/tee/optee/call.c | 2 +-
drivers/tee/optee/core.c | 22 +-
drivers/tee/optee/device.c | 5 +-
drivers/tee/optee/ffa_abi.c | 136 ++++------
drivers/tee/optee/optee_private.h | 12 +-
drivers/tee/optee/smc_abi.c | 155 +++--------
drivers/tee/tee_core.c | 5 +-
drivers/tee/tee_private.h | 11 -
drivers/tee/tee_shm.c | 322 +++++++++++++++--------
drivers/tee/tee_shm_pool.c | 162 +++---------
include/linux/tee_drv.h | 133 +++-------
security/keys/trusted-keys/trusted_tee.c | 23 +-
15 files changed, 434 insertions(+), 623 deletions(-)
--
2.31.1
[BCC all OP-TEE maintainers]
Hi OP-TEE maintainers & contributors,
OP-TEE v3.16.0 is scheduled to be released on 2022-01-28. So, now is a
good time to start testing the master branch on the various platforms
and report/fix any bugs.
The GitHub pull request for collecting Tested-by tags or any other
comments is https://github.com/OP-TEE/optee_os/pull/5094
As usual, we will create a release candidate tag one week before the
release date for final testing.
In addition to that you can find some additional information related
to releases here:
https://optee.readthedocs.io/en/latest/general/releases.html
Thanks,
Jens
The addition of a shutdown hook by commit f25889f93184 ("optee:
fix tee out of memory failure seen during kexec reboot") introduced a
kernel shutdown regression that can be triggered after running the
xtest suites.
Once the shutdown hook is called it is not possible to communicate any
more with the supplicant process because the system is not scheduling
task any longer. Thus if the optee driver shutdown path receives a
supplicant RPC request from the OP-TEE we will deadlock the kernel's
shutdown.
This unexpected event will in fact occur after the xtest suite has
been run. It seems some cached SHM kept alive a context object which
in turn kept alive a session towards a PTA or TA. Closing the session
results in a socket RPC command being sent back from OP-TEE.
This sequence of events is captured by a 5.15 kernel annotated with
extra prints:
Calling OPTEE_SMC_DISABLE_SHM_CACHE
OPTEE_SMC_DISABLE_SHM_CACHE returned 0
freeing SHM ptr 0xFFFFFF8001079380
Calling OPTEE_SMC_DISABLE_SHM_CACHE
OPTEE_SMC_DISABLE_SHM_CACHE returned 0
freeing SHM ptr 0xFFFFFF8001CC5580
Calling OPTEE_SMC_DISABLE_SHM_CACHE
OPTEE_SMC_DISABLE_SHM_CACHE returned 0
freeing SHM ptr 0xFFFFFF8006308A80
Calling OPTEE_SMC_DISABLE_SHM_CACHE
OPTEE_SMC_DISABLE_SHM_CACHE returned 0
freeing SHM ptr 0xFFFFFF8006308B00
optee: optee_handle_rpc: a0=0XFFFF0000 a1=0XA0 a2=0X0
optee: optee_handle_rpc: a0=0XFFFF0005 a1=0XFFFFFF80 a2=0X61E6500
optee: handle_rpc_func_cmd: cmd = 0XA
optee_supp_thrd_req: func=0XA
Introduce a shutdown state in the optee device object to return an
immediate error to all RPC requests in the shutdown path.
Fixes: f25889f93184 ("optee: fix tee out of memory failure seen during kexec reboot
Signed-off-by: Lars Persson <larper(a)axis.com>
---
drivers/tee/optee/optee_private.h | 1 +
drivers/tee/optee/smc_abi.c | 5 ++++-
drivers/tee/optee/supp.c | 8 ++++++++
3 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/drivers/tee/optee/optee_private.h b/drivers/tee/optee/optee_private.h
index 46f74ab07c7e..83380974ff44 100644
--- a/drivers/tee/optee/optee_private.h
+++ b/drivers/tee/optee/optee_private.h
@@ -164,6 +164,7 @@ struct optee {
bool scan_bus_done;
struct workqueue_struct *scan_bus_wq;
struct work_struct scan_bus_work;
+ bool shutting_down;
};
struct optee_session {
diff --git a/drivers/tee/optee/smc_abi.c b/drivers/tee/optee/smc_abi.c
index 449d6a72d289..10af747da816 100644
--- a/drivers/tee/optee/smc_abi.c
+++ b/drivers/tee/optee/smc_abi.c
@@ -1356,7 +1356,10 @@ static int optee_smc_remove(struct platform_device *pdev)
*/
static void optee_shutdown(struct platform_device *pdev)
{
- optee_disable_shm_cache(platform_get_drvdata(pdev));
+ struct optee *optee = platform_get_drvdata(pdev);
+
+ optee->shutting_down = true;
+ optee_disable_shm_cache(optee);
}
static int optee_probe(struct platform_device *pdev)
diff --git a/drivers/tee/optee/supp.c b/drivers/tee/optee/supp.c
index 322a543b8c27..801b4ec659e8 100644
--- a/drivers/tee/optee/supp.c
+++ b/drivers/tee/optee/supp.c
@@ -83,6 +83,14 @@ u32 optee_supp_thrd_req(struct tee_context *ctx, u32 func, size_t num_params,
bool interruptable;
u32 ret;
+ /*
+ * When the system is shutting down we cannot talk
+ * to the supplicant anymore even if we seem to have
+ * an open session to it.
+ */
+ if (optee->shutting_down)
+ return TEEC_ERROR_COMMUNICATION;
+
/*
* Return in case there is no supplicant available and
* non-blocking request.
--
2.30.2
Signed-off-by: Wang Cheng <wanngchenng(a)gmail.com>
---
Documentation/staging/tee.rst | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Documentation/staging/tee.rst b/Documentation/staging/tee.rst
index 3c63d8dcd61e..498343c7ab08 100644
--- a/Documentation/staging/tee.rst
+++ b/Documentation/staging/tee.rst
@@ -255,7 +255,7 @@ The following picture shows a high level overview of AMD-TEE::
+--------------------------+ +---------+--------------------+
At the lowest level (in x86), the AMD Secure Processor (ASP) driver uses the
-CPU to PSP mailbox regsister to submit commands to the PSP. The format of the
+CPU to PSP mailbox register to submit commands to the PSP. The format of the
command buffer is opaque to the ASP driver. It's role is to submit commands to
the secure processor and return results to AMD-TEE driver. The interface
between AMD-TEE driver and AMD Secure Processor driver can be found in [6].
@@ -290,7 +290,7 @@ cancel_req driver callback is not supported by AMD-TEE.
The GlobalPlatform TEE Client API [5] can be used by the user space (client) to
talk to AMD's TEE. AMD's TEE provides a secure environment for loading, opening
-a session, invoking commands and clossing session with TA.
+a session, invoking commands and closing session with TA.
References
==========
--
2.33.1
Hello, I got problems here:
I built the whole system with yotcto 3.3.3, linux kernel 5.10, optee-os
3.14, platform for rk3399 ( was working for qemu platform ).
Console Configuration:
U-Boot / TrustFirmware-A / optee-os: all pointed console to uart2
linux dts: chosen and secure-chosen all pointed to uart2. uart2's status
and secure-status are both set to "okay"
Build Configuration:
optee-os:
DEBUG=1 \
CFG_TEE_CORE_LOG_LEVEL=4 \
CFG_TEE_CORE_DEBUG=y \
CFG_TEE_TA_LOG_LEVEL=4 \
...
both optee-examples and my TA:
DEBUG=1 \
CFG_TEE_TA_LOG_LEVEL=4 \
...
During boot I can see D/TC: logs, but no any D/TA: log is output.
Some D/TC log like this:
D/TC:? 0 tee_ta_init_session_with_context:607 Re-open TA xxxxx
D/TC:? 0 tee_ta_close_session:512 csess 0xDDDDDD id 1
D/TC:? 0 tee_ta_close_session:531 Destroy session
My TA has correct output, no crashes,or other errors
Thanks.
This V3 series covers points uncovered during the review of the previous
series, one major point being that register readout should not be used
for dynamic JR availability check due to its unreliability.
Instead, JR should have a proper status set in FDT which indicates the
availability of the ring in NS-World. This status is aligned with what
BootROM code configures, and can be modified by all actors in the boot
chain.
Therefore, patch in V2 series that was handling the dynamic JR
availability check is dropped in this series and replaced by the patch
which sets proper DT status for JR nodes.
Andrey Zhizhikin (2):
crypto: caam - convert to use capabilities
arm64: dts: imx8m: define proper status for caam jr
arch/arm64/boot/dts/freescale/imx8mm.dtsi | 4 +
arch/arm64/boot/dts/freescale/imx8mn.dtsi | 4 +
arch/arm64/boot/dts/freescale/imx8mp.dtsi | 4 +
arch/arm64/boot/dts/freescale/imx8mq.dtsi | 4 +
drivers/crypto/caam/caamalg_qi.c | 2 +-
drivers/crypto/caam/ctrl.c | 115 ++++++++++++++--------
drivers/crypto/caam/intern.h | 20 ++--
drivers/crypto/caam/jr.c | 19 +++-
drivers/crypto/caam/regs.h | 2 -
9 files changed, 122 insertions(+), 52 deletions(-)
base-commit: 04fe99a8d936d46a310ca61b8b63dc270962bf01
--
2.25.1
Hello arm-soc maintainers,
Please pull these TEE subsystem and OP-TEE driver fixes which by coincident
all are concerning memory shared with secure world.
There's one in particular nasty race fixed when a tee_shm is about to be
teared down.
Thanks,
Jens
The following changes since commit d58071a8a76d779eedab38033ae4c821c30295a5:
Linux 5.16-rc3 (2021-11-28 14:09:19 -0800)
are available in the Git repository at:
https://git.linaro.org/people/jens.wiklander/linux-tee.git tags/fixes-for-v5.16
for you to fetch changes up to 6add87fdae9bcb1d20b4503df5bd02ce5246cc8b:
optee: Suppress false positive kmemleak report in optee_handle_rpc() (2021-12-16 15:32:48 +0100)
----------------------------------------------------------------
TEE and OP-TEE fixes for v5.16
- Fixes a race when a tee_shm reaches reference count 0 and is about to
be teared down
- Fixes an incorrect page free bug in an error path of the OP-TEE shared
memory pool handling
- Suppresses a false positive kmemleak report when allocating driver
private shared memory buffers for OP-TEE
----------------------------------------------------------------
Jens Wiklander (1):
tee: handle lookup of shm with reference count 0
Sumit Garg (1):
tee: optee: Fix incorrect page free bug
Xiaolei Wang (1):
optee: Suppress false positive kmemleak report in optee_handle_rpc()
drivers/tee/optee/core.c | 6 +-
drivers/tee/optee/smc_abi.c | 2 +
drivers/tee/tee_shm.c | 174 +++++++++++++++++---------------------------
include/linux/tee_drv.h | 4 +-
4 files changed, 72 insertions(+), 114 deletions(-)
Pointer to the allocated pages (struct page *page) has already
progressed towards the end of allocation. It is incorrect to perform
__free_pages(page, order) using this pointer as we would free any
arbitrary pages. Fix this by stop modifying the page pointer.
Fixes: ec185dd3ab25 ("optee: Fix memory leak when failing to register shm pages")
Cc: stable(a)vger.kernel.org
Reported-by: Patrik Lantz <patrik.lantz(a)axis.com>
Signed-off-by: Sumit Garg <sumit.garg(a)linaro.org>
Reviewed-by: Tyler Hicks <tyhicks(a)linux.microsoft.com>
---
Changes since v1:
- Added stable CC tag.
- Picked up Tyler's review tag.
drivers/tee/optee/core.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c
index ab2edfcc6c70..2a66a5203d2f 100644
--- a/drivers/tee/optee/core.c
+++ b/drivers/tee/optee/core.c
@@ -48,10 +48,8 @@ int optee_pool_op_alloc_helper(struct tee_shm_pool_mgr *poolm,
goto err;
}
- for (i = 0; i < nr_pages; i++) {
- pages[i] = page;
- page++;
- }
+ for (i = 0; i < nr_pages; i++)
+ pages[i] = page + i;
shm->flags |= TEE_SHM_REGISTER;
rc = shm_register(shm->ctx, shm, pages, nr_pages,
--
2.25.1
Hi,
In light of the holiday season we are not expecting too many joiners on Dec
23. Hence, let's cancel the LOC (Linaro OP-TEE Contribution) monthly
meeting scheduled for next week.
Wish you all a great holiday and a happy new year. The next scheduled
meeting will be on 27th January 2022.
Regards,
Ruchika
(On behalf of OP-TEE team)
Hi
Me and Patrik have been tracing a kernel memory corruption bug that is
triggered when op-tee runs out of resources and returns an error from
the OPTEE_MSG_CMD_REGISTER_SHM call. This is yet another fall-out from
Patrik's fuzzing of the TEE subsystem.
The symptoms would look like this when page debugging is enabled:
BUG: Bad page state in process optee_example_h pfn:46bb0
page:(ptrval) refcount:-1 mapcount:0 mapping:00000000 index:0x0 pfn:0x46bb0
flags: 0x0(zone=0)
Our reproducer runs a loop with the TEE_IOC_SHM_ALLOC until memory runs
out at the optee-os end (dynamic SHM enabled). The error is 100%
reproducible with such a loop.
We have traced this down to what seems to be a miss in the memory
ownership contract during the call to OPTEE_MSG_CMD_REGISTER_SHM.
When pool_op_alloc() detects that optee_shm_register() has failed, it
will free the allocated page at the very end of the function.
Unfortunately that page has already been freed because OP-TEE has sent a
OPTEE_RPC_CMD_SHM_FREE for this shm object before returning from
OPTEE_MSG_CMD_REGISTER_SHM. This is my conclusion based on prints added
to the code.
I cannot write a patch for this because I am at a loss of who actually
is supposed to trigger the free of the pages in this situation. Is there
an API spec that makes this clear ?
BR,
Lars
Pointer to the allocated pages (struct page *page) has already
progressed towards the end of allocation. It is incorrect to perform
__free_pages(page, order) using this pointer as we would free any
arbitrary pages. Fix this by stop modifying the page pointer.
Fixes: ec185dd3ab25 ("optee: Fix memory leak when failing to register shm pages")
Reported-by: Patrik Lantz <patrik.lantz(a)axis.com>
Signed-off-by: Sumit Garg <sumit.garg(a)linaro.org>
---
drivers/tee/optee/core.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c
index ab2edfcc6c70..2a66a5203d2f 100644
--- a/drivers/tee/optee/core.c
+++ b/drivers/tee/optee/core.c
@@ -48,10 +48,8 @@ int optee_pool_op_alloc_helper(struct tee_shm_pool_mgr *poolm,
goto err;
}
- for (i = 0; i < nr_pages; i++) {
- pages[i] = page;
- page++;
- }
+ for (i = 0; i < nr_pages; i++)
+ pages[i] = page + i;
shm->flags |= TEE_SHM_REGISTER;
rc = shm_register(shm->ctx, shm, pages, nr_pages,
--
2.25.1
Hello arm-soc maintainers,
Please pull these patches which adds support for asynchronous notifications
from OP-TEE in secure world to the OP-TEE driver.
An edge-triggered interrupt is used to notify the the driver.
These patches has been in linux-next for a few weeks already.
Thanks,
Jens
The following changes since commit fa55b7dcdc43c1aa1ba12bca9d2dd4318c2a0dbf:
Linux 5.16-rc1 (2021-11-14 13:56:52 -0800)
are available in the Git repository at:
https://git.linaro.org/people/jens.wiklander/linux-tee.git tags/optee-async-notif-for-v5.17
for you to fetch changes up to b98aee466d194788bd651cb375b0e0f7e0e69865:
optee: Fix NULL but dereferenced coccicheck error (2021-11-29 22:02:25 +0100)
----------------------------------------------------------------
OP-TEE Asynchronous notifications from secure world
Adds support in the SMC based OP-TEE driver to receive asynchronous
notifications from secure world using an edge-triggered interrupt as
delivery mechanism.
----------------------------------------------------------------
Jens Wiklander (6):
docs: staging/tee.rst: add a section on OP-TEE notifications
dt-bindings: arm: optee: add interrupt property
tee: fix put order in teedev_close_context()
tee: export teedev_open() and teedev_close_context()
optee: separate notification functions
optee: add asynchronous notifications
Yang Li (1):
optee: Fix NULL but dereferenced coccicheck error
.../bindings/arm/firmware/linaro,optee-tz.yaml | 8 +
Documentation/staging/tee.rst | 30 +++
drivers/tee/optee/Makefile | 1 +
drivers/tee/optee/core.c | 2 +-
drivers/tee/optee/ffa_abi.c | 6 +-
drivers/tee/optee/notif.c | 125 +++++++++++
drivers/tee/optee/optee_msg.h | 9 +
drivers/tee/optee/optee_private.h | 28 ++-
drivers/tee/optee/optee_rpc_cmd.h | 31 +--
drivers/tee/optee/optee_smc.h | 75 ++++++-
drivers/tee/optee/rpc.c | 71 +-----
drivers/tee/optee/smc_abi.c | 237 ++++++++++++++++++---
drivers/tee/tee_core.c | 10 +-
include/linux/tee_drv.h | 14 ++
14 files changed, 523 insertions(+), 124 deletions(-)
create mode 100644 drivers/tee/optee/notif.c
Hello!
Is it possible to use any compiler-based sanitizers to harden
OP-TEE kernel and/or trustlets?
I know, there is ASAN support in the OP-TEE kernel.
But can it be used with TAs? Or some other sanitizers like UBSan?
Thank you.
Hello John,
> From: John Linn <linnj(a)xilinx.com>
> Date: Thu, Nov 18, 2021 at 10:24 PM
> Subject: Embedded DT (CFG_EMBED_DT) with dynamic shared memory (CFG_CORE_DYN_SHM) in optee-os
> To: op-teeATlists.trustedfirmware.org <op-teeATlists.trustedfirmware.org>
>
>
> It appears that dynamic shared memory does not work with an embedded DT, but I'm likely missing something. I have it working fine with an external DT.
>
> There is a bit of interaction in kernel/boot.c with the two configuration options and my testing is not seeing it work with 3.14 and master looks the same viewing it.
>
> get_external_fdt() is called which does not work with the embedded DT it appears to me.
Indeed the current implementation gets the main memory size from the
external non-secure DTB.
This memory is mainly REE memory and can tbe used as shared memory.
It looks reasonable to get the same info from the embedded DTB instead
but the point to discuss, IMO, is whether the memory nodes of OP-TEE
secure DT relate to OP-TEE "secure memory" or to system-wide (possibly
non-secure) memory. In the former case, that information could not be
used to define the "non-secure shareable address ranges".
Feel free to create a P-R in optee_os for that purpose (something like
try with embedded_dt() then fallback to externalè_dt()),
Regards,
Etienne
>
> Any hints or advice?
>
> Thanks
> John
Hello arm-soc maintainers,
Please pull this AMDTEE driver fix which takes care of a bug where
IS_ERR() was used instead of a NULL check for the return value from
__get_free_pages().
Note that this isn't a usual Arm driver update. This targets AMD instead,
but is part of the TEE subsystem.
Thanks,
Jens
The following changes since commit d58071a8a76d779eedab38033ae4c821c30295a5:
Linux 5.16-rc3 (2021-11-28 14:09:19 -0800)
are available in the Git repository at:
git://git.linaro.org/people/jens.wiklander/linux-tee.git tags/amdtee-fix-for-v5.16
for you to fetch changes up to 9d7482771fac8d8e38e763263f2ca0ca12dd22c6:
tee: amdtee: fix an IS_ERR() vs NULL bug (2021-11-29 09:55:49 +0100)
----------------------------------------------------------------
AMD-TEE fix IS_ERR() bug
----------------------------------------------------------------
Dan Carpenter (1):
tee: amdtee: fix an IS_ERR() vs NULL bug
drivers/tee/amdtee/core.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)