optee: Add support for enumerating RPMB-dependent services
Subsystems (3)
v4 cover optee: Add support for enumerating RPMB-dependent services
This allows to find firmware TPM again with recent OP-TEE versions, possibly also other services. The StMM service was not affected because it is directly invoked by efi_variable_tee when needed, and that is late enough so that all dependencies are available by then.
See patches for further details.
Changes in v4:
- avoid multiple binds on same optee service
Changes in v3:
- don't use dev_dev if there is no valid dev
- add device_active check to optee_rpmb_available
Changes in v2:
- fix build breakages with disabled CONFIGs
- structure code differently between optee core and rpmb
- debug() -> dev_dbg()
Jan
Jan Kiszka (6):
tee: optee: Factor out service enumeration and binding functions
tee: optee: Avoid binding a service twice
tee: optee: Add support for enumerating services that only need RPMB
tee: optee: Do not warn about TEE_ERROR_STORAGE_NOT_AVAILABLE
mmc: Call back to optee after a successful mmc_init
mmc: Make "MMC Device not found" a debug output
drivers/mmc/mmc-uclass.c | 2 +- drivers/mmc/mmc.c | 4 ++ drivers/mmc/mmc_legacy.c | 2 +- drivers/tee/optee/core.c | 64 ++++++++++++++++--------------- drivers/tee/optee/optee_private.h | 24 ++++++++++++ drivers/tee/optee/rpmb.c | 20 ++++++++++ include/tee/optee.h | 6 +++ 7 files changed, 90 insertions(+), 32 deletions(-)
Signature · 1 line
2.47.3
PATCH v4 4/6 tee: optee: Do not warn about TEE_ERROR_STORAGE_NOT_AVAILABLE
From: Jan Kiszka <[email protected]>
This is a transitional error that is resolved once an RPMB becomes available. Keep it as debug output only.
--- drivers/tee/optee/core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/tee/optee/core.c +4 -1
@@ -112,7 +112,10 @@ static int __enum_services(struct udevice *dev, struct tee_shm *shm, size_t *shm ret =tee_invoke_func (dev, &arg,1 , ¶m);if (ret || (arg.ret && arg.ret !=TEE_ERROR_SHORT_BUFFER )) { -dev_err (dev,"Enumeration command 0x%x failed: 0x%x\n" , pta_cmd, arg.ret); +if (arg.ret !=TEE_ERROR_STORAGE_NOT_AVAILABLE ) +dev_err (dev,"Enumeration command 0x%x failed: 0x%x\n" , pta_cmd, arg.ret); +else +dev_dbg (dev,"Enumeration command 0x%x failed due to unavailable storage\n" , pta_cmd);return -EINVAL ; }
Signature · 1 line
2.47.3
PATCH v4 3/6 tee: optee: Add support for enumerating services that only need RPMB
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
Up to OP-TEE 4.4.0, all services that needed a supplicant where returned by PTA_CMD_GET_DEVICES_SUPP. Since then, services that only need a supplicant for the purpose of accessing the RPMB are only enumerated by the new, separate PTA_CMD_GET_DEVICES_RPMB. U-Boot so far lacks support for that, thus no longer finds such services, e.g. fTPM.
Perform the separate enumeration during probe but, as that may fail if the MMC is not probed yet, also provide a callback to trigger a retry when another MMC device becomes available.
--- drivers/tee/optee/core.c | 22 +++++++--------------- drivers/tee/optee/optee_private.h | 21 +++++++++++++++++++++ drivers/tee/optee/rpmb.c | 20 ++++++++++++++++++++ include/tee/optee.h | 6 ++++++ 4 files changed, 54 insertions(+), 15 deletions(-)
drivers/tee/optee/core.c +7 -15
@@ -27,19 +27,6 @@*/ #define PTA_DEVICE_ENUM { 0x7011a688, 0xddde, 0x4053, \ { 0xa5, 0xa9, 0x7b, 0x3c, 0x4d, 0xdf, 0x13, 0xb8 } } -/* -* PTA_CMD_GET_DEVICES - List services without supplicant dependencies -* -* [out] memref[0]: List of the UUIDs of service enumerated by OP-TEE -*/ -#define PTA_CMD_GET_DEVICES 0x0 - -/* -* PTA_CMD_GET_DEVICES_SUPP - List services depending on tee supplicant -* -* [out] memref[0]: List of the UUIDs of service enumerated by OP-TEE -*/ -#define PTA_CMD_GET_DEVICES_SUPP 0x1 typedef void (optee_invoke_fn)(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long,
@@ -201,8 +188,8 @@ int optee_bind_services(struct udevice *dev, u32 tee_sess,static int bind_service_drivers (struct udevice *dev) { +int ret, ret2, ret3 =0 ;u32 tee_sess; -int ret, ret2; ret =optee_open_enum_session (dev, &tee_sess);if (ret)
@@ -210,13 +197,18 @@ static int bind_service_drivers(struct udevice *dev) ret =optee_bind_services (dev, tee_sess,PTA_CMD_GET_DEVICES ); ret2 =optee_bind_services (dev, tee_sess,PTA_CMD_GET_DEVICES_SUPP ); +if (CONFIG_IS_ENABLED (SUPPORT_EMMC_RPMB )) + ret3 =optee_bind_services (dev, tee_sess, +PTA_CMD_GET_DEVICES_RPMB );tee_close_session (dev, tee_sess);if (ret)return ret; +if (ret2) +return ret2; -return ret2; +return ret3; }/**
drivers/tee/optee/optee_private.h +21 -0
@@ -9,6 +9,27 @@#include <tee.h> #include <log.h> +/* +* PTA_CMD_GET_DEVICES - List services without supplicant dependencies +* +* [out] memref[0]: List of the UUIDs of service enumerated by OP-TEE +*/ +#define PTA_CMD_GET_DEVICES 0x0 + +/* +* PTA_CMD_GET_DEVICES_SUPP - List services depending on tee supplicant +* +* [out] memref[0]: List of the UUIDs of service enumerated by OP-TEE +*/ +#define PTA_CMD_GET_DEVICES_SUPP 0x1 + +/* +* PTA_CMD_GET_DEVICES_RPMB - List services only depending on RPMB support +* +* [out] memref[0]: List of the UUIDs of service enumerated by OP-TEE +*/ +#define PTA_CMD_GET_DEVICES_RPMB 0x2 +/** * struct optee_private - OP-TEE driver private data * @rpmb_mmc: mmc device for the RPMB partition
drivers/tee/optee/rpmb.c +20 -0
@@ -191,3 +191,23 @@ void optee_suppl_rpmb_release(struct udevice *dev) {release_mmc (dev_get_priv (dev)); } + +void optee_rpmb_available (void ) +{ +struct udevice *dev; +struct uclass *uc; +u32 tee_sess; + + uclass_id_foreach_dev(UCLASS_TEE, dev, uc) { +if (strcmp (dev->driver->name,"optee" ) !=0 || + !device_active (dev)) +continue ; + +if (optee_open_enum_session (dev, &tee_sess) !=0 ) +continue ; + +optee_bind_services (dev, tee_sess,PTA_CMD_GET_DEVICES_RPMB ); + +tee_close_session (dev, tee_sess); + } +}
include/tee/optee.h +6 -0
@@ -74,4 +74,10 @@ static inline bool is_optee_smc_api(void) }#endif +#if defined(CONFIG_OPTEE ) && defined(CONFIG_SUPPORT_EMMC_RPMB ) +void optee_rpmb_available (void ); +#else +static inline void optee_rpmb_available (void ) {} +#endif +#endif /* _OPTEE_H */
Signature · 1 line
2.47.3
PATCH v4 1/6 tee: optee: Factor out service enumeration and binding functions
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
This already avoids code duplication between the different enumeration commands. It will furthermore allow to implement a third one for services with RPMB needs.
--- drivers/tee/optee/core.c | 33 +++++++++++++++++-------------- drivers/tee/optee/optee_private.h | 3 +++ 2 files changed, 21 insertions(+), 15 deletions(-)
drivers/tee/optee/core.c +18 -15
@@ -156,7 +156,7 @@ static int enum_services(struct udevice *dev, struct tee_shm **shm, size_t *counreturn ret; } -static int open_enum_session (struct udevice *dev,u32 *tee_sess) +int optee_open_enum_session (struct udevice *dev,u32 *tee_sess) {const struct tee_optee_ta_uuid pta_uuid =PTA_DEVICE_ENUM ;struct tee_open_session_arg arg = { };
@@ -176,31 +176,34 @@ static int open_enum_session(struct udevice *dev, u32 *tee_sess)return 0 ; } -static int bind_service_drivers (struct udevice *dev) +int optee_bind_services (struct udevice *dev,u32 tee_sess, +unsigned int pta_cmd) {struct tee_shm *service_list =NULL ;size_t service_count; -u32 tee_sess; -int ret, ret2; - - ret =open_enum_session (dev, &tee_sess); -if (ret) -return ret; +int ret; ret =enum_services (dev, &service_list, &service_count, tee_sess, -PTA_CMD_GET_DEVICES ); + pta_cmd);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 && service_count) - ret2 =bind_service_list (dev, service_list, service_count); +return ret; +} + +static int bind_service_drivers (struct udevice *dev) +{ +u32 tee_sess; +int ret, ret2; -tee_shm_free (service_list); + ret =optee_open_enum_session (dev, &tee_sess); +if (ret) +return ret; + + ret =optee_bind_services (dev, tee_sess,PTA_CMD_GET_DEVICES ); + ret2 =optee_bind_services (dev, tee_sess,PTA_CMD_GET_DEVICES_SUPP );tee_close_session (dev, tee_sess);
drivers/tee/optee/optee_private.h +3 -0
@@ -27,6 +27,9 @@ struct optee_msg_arg;void optee_suppl_cmd (struct udevice *dev,struct tee_shm *shm_arg,void **page_list); +int optee_open_enum_session (struct udevice *dev,u32 *tee_sess); +int optee_bind_services (struct udevice *dev,u32 tee_sess, +unsigned int pta_cmd);#ifdef CONFIG_SUPPORT_EMMC_RPMB /**
Signature · 1 line
2.47.3
PATCH v4 6/6 mmc: Make "MMC Device not found" a debug output
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
Callers of find_mmc_device are generally processing and informing about errors already, e.g.
=> mmc dev 2
MMC Device 2 not found
no mmc device at slot 2
---
CC: Peng Fan <[email protected]>
CC: Jaehoon Chung <[email protected]>
--- drivers/mmc/mmc-uclass.c | 2 +- drivers/mmc/mmc_legacy.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/mmc-uclass.c +1 -1
@@ -319,7 +319,7 @@ struct mmc *find_mmc_device(int dev_num)if (ret) {#if !defined(CONFIG_XPL_BUILD ) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT ) -printf ("MMC Device %d not found\n" , dev_num); +debug ("MMC Device %d not found\n" , dev_num);#endif return NULL ; }
drivers/mmc/mmc_legacy.c +1 -1
@@ -45,7 +45,7 @@ struct mmc *find_mmc_device(int dev_num) }#if !defined(CONFIG_XPL_BUILD ) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT ) -printf ("MMC Device %d not found\n" , dev_num); +debug ("MMC Device %d not found\n" , dev_num);#endif return NULL ;
Signature · 1 line
2.47.3
PATCH v4 2/6 tee: optee: Avoid binding a service twice
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
In case optee_bind_services is invoked more than once successfully, make sure that already bound services are not rebound, creating multiple instances of themselves. When introducing RPMB-driven service scanning this scenario could pop up.
--- drivers/tee/optee/core.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/tee/optee/core.c +6 -0
@@ -83,6 +83,7 @@ static int bind_service_list(struct udevice *dev, struct tee_shm *service_list, {const struct tee_optee_ta_uuid *service_uuid = (const void *)service_list->addr;struct optee_service *service; +struct udevice *service_dev;size_t idx;int ret;
@@ -91,6 +92,11 @@ static int bind_service_list(struct udevice *dev, struct tee_shm *service_list,if (!service)continue ; + ret =device_find_child_by_name (dev, service->driver_name, + &service_dev); +if (!ret &&dev_get_flags (service_dev) &DM_FLAG_BOUND ) +continue ; + ret =device_bind_driver_to_node (dev, service->driver_name, service->driver_name,dev_ofnode (dev),NULL );if (ret) {
Signature · 1 line
2.47.3
PATCH v4 5/6 mmc: Call back to optee after a successful mmc_init
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
This is needed to that OP-TEE can re-enumerate services which need RPMB access that may have become available now.
---
CC: Peng Fan <[email protected]>
CC: Jaehoon Chung <[email protected]>
--- drivers/mmc/mmc.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/mmc/mmc.c +4 -0
@@ -27,6 +27,7 @@#include <linux/list.h> #include <linux/printk.h> #include <div64.h> +#include <tee/optee.h> #include "mmc_private.h" #define DEFAULT_CMD6_TIMEOUT_MS 500
@@ -3168,6 +3169,9 @@ int mmc_init(struct mmc *mmc) mmc->cfg->name); } +if (CONFIG_IS_ENABLED (OPTEE ) && mmc->capacity_rpmb >0 ) +optee_rpmb_available (); +return err; }
Signature · 1 line
2.47.3
Quoted 29 lines · Jan Kiszka
This allows to find firmware TPM again with recent OP-TEE versions, possibly also other services. The StMM service was not affected because it is directly invoked by
efi_variable_teewhen needed, and that is late enough so that all dependencies are available by then.See patches for further details.
Changes in v4:
- avoid multiple binds on same optee serviceChanges in v3:
- don't usedev_devif there is no valid dev
- adddevice_activecheck tooptee_rpmb_availableChanges in v2:
- fix build breakages with disabled CONFIGs
- structure code differently between optee core and rpmb
-debug()->dev_dbg()Jan
Jan Kiszka (6):
tee: optee: Factor out service enumeration and binding functions
tee: optee: Avoid binding a service twice
tee: optee: Add support for enumerating services that only need RPMB
tee: optee: Do not warn aboutTEE_ERROR_STORAGE_NOT_AVAILABLE
mmc: Call back to optee after a successfulmmc_init
mmc: Make "MMC Device not found" a debug output
Quoted 9 lines
drivers/mmc/mmc-uclass.c | 2 +- drivers/mmc/mmc.c | 4 ++ drivers/mmc/mmc_legacy.c | 2 +- drivers/tee/optee/core.c | 64 ++++++++++++++++--------------- drivers/tee/optee/optee_private.h | 24 ++++++++++++ drivers/tee/optee/rpmb.c | 20 ++++++++++ include/tee/optee.h | 6 +++ 7 files changed, 90 insertions(+), 32 deletions(-)
Any further comments? And do we have a chance to still include it into the next release?
Jan
Signature · 2 lines
Siemens AG, Foundational Technologies Linux Expert Center
Hi Jan
I'm on a trip this week. I'll try looking at it and sending it over by the end of the week
Cheers
/Ilias
Quoted 49 lines · Jan Kiszka
Quoted 29 lines · Jan Kiszka
This allows to find firmware TPM again with recent OP-TEE versions, possibly also other services. The StMM service was not affected because it is directly invoked by
efi_variable_teewhen needed, and that is late enough so that all dependencies are available by then.See patches for further details.
Changes in v4:
- avoid multiple binds on same optee serviceChanges in v3:
- don't usedev_devif there is no valid dev
- adddevice_activecheck tooptee_rpmb_availableChanges in v2:
- fix build breakages with disabled CONFIGs
- structure code differently between optee core and rpmb
-debug()->dev_dbg()Jan
Jan Kiszka (6):
tee: optee: Factor out service enumeration and binding functions
tee: optee: Avoid binding a service twice
tee: optee: Add support for enumerating services that only need RPMB
tee: optee: Do not warn aboutTEE_ERROR_STORAGE_NOT_AVAILABLE
mmc: Call back to optee after a successfulmmc_init
mmc: Make "MMC Device not found" a debug outputQuoted 9 lines
drivers/mmc/mmc-uclass.c | 2 +- drivers/mmc/mmc.c | 4 ++ drivers/mmc/mmc_legacy.c | 2 +- drivers/tee/optee/core.c | 64 ++++++++++++++++--------------- drivers/tee/optee/optee_private.h | 24 ++++++++++++ drivers/tee/optee/rpmb.c | 20 ++++++++++ include/tee/optee.h | 6 +++ 7 files changed, 90 insertions(+), 32 deletions(-)Any further comments? And do we have a chance to still include it into the next release?
Jan
--
Siemens AG, Foundational Technologies
Linux Expert Center
Re: [PATCH v4 6/6] mmc: Make "MMC Device not found" a debug output
In reply to Jan KiszkaQuoted 5 lines · Jan Kiszka
From: Jan Kiszka <[email protected]>
Callers of
find_mmc_deviceare generally processing and informing about errors already, e.g.
Quoted 7 lines
=> mmc dev 2
MMC Device 2 not found
no mmc device at slot 2Signed-off-by Jan Kiszka <[email protected]>Reviewed-by Tanmay Kathpalia <[email protected]>
Quoted 34 lines
---
CC: Peng Fan <[email protected]>
CC: Jaehoon Chung <[email protected]>--- drivers/mmc/mmc-uclass.c | 2 +- drivers/mmc/mmc_legacy.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)drivers/mmc/mmc-uclass.c +1
-1@@ -319,7 +319,7 @@ struct mmc *find_mmc_device(int dev_num)if (ret) {#if !defined(CONFIG_XPL_BUILD ) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT ) -printf ("MMC Device %d not found\n" , dev_num); +debug ("MMC Device %d not found\n" , dev_num);#endif return NULL ; }drivers/mmc/mmc_legacy.c +1
-1@@ -45,7 +45,7 @@ struct mmc *find_mmc_device(int dev_num) }#if !defined(CONFIG_XPL_BUILD ) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT ) -printf ("MMC Device %d not found\n" , dev_num); +debug ("MMC Device %d not found\n" , dev_num);#endif return NULL ;
Re: [PATCH v4 2/6] tee: optee: Avoid binding a service twice
In reply to Jan KiszkaQuoted 9 lines · Jan Kiszka
From: Jan Kiszka <[email protected]>
In case
optee_bind_servicesis invoked more than once successfully, make sure that already bound services are not rebound, creating multiple instances of themselves. When introducing RPMB-driven service scanning this scenario could pop up.Signed-off-by Jan Kiszka <[email protected]>---
Quoted 27 lines
drivers/tee/optee/core.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/tee/optee/core.c +6
-0@@ -83,6 +83,7 @@ static int bind_service_list(struct udevice *dev, struct tee_shm *service_list, {const struct tee_optee_ta_uuid *service_uuid = (const void *)service_list->addr;struct optee_service *service; +struct udevice *service_dev;size_t idx;int ret;@@ -91,6 +92,11 @@ static int bind_service_list(struct udevice *dev, struct tee_shm *service_list,if (!service)continue ; + ret =device_find_child_by_name (dev, service->driver_name, + &service_dev); +if (!ret &&dev_get_flags (service_dev) &DM_FLAG_BOUND ) +continue ; + ret =device_bind_driver_to_node (dev, service->driver_name, service->driver_name,dev_ofnode (dev),NULL );if (ret) {
Re: [PATCH v4 5/6] mmc: Call back to optee after a successful mmc_init
In reply to Jan KiszkaQuoted 29 lines · Jan Kiszka
From: Jan Kiszka <[email protected]>
This is needed to that OP-TEE can re-enumerate services which need RPMB access that may have become available now.
Signed-off-by Jan Kiszka <[email protected]>Reviewed-by Peng Fan <[email protected]>Reviewed-by Tanmay Kathpalia <[email protected]>---
CC: Peng Fan <[email protected]>
CC: Jaehoon Chung <[email protected]>--- drivers/mmc/mmc.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/mmc/mmc.c +1
-0@@ -27,6 +27,7 @@#include <linux/list.h> #include <linux/printk.h> #include <div64.h> +#include <tee/optee.h> #include "mmc_private.h" #define DEFAULT_CMD6_TIMEOUT_MS 500
drivers/mmc/mmc.c int mmc_init(struct mmc *mmc) · line 3172
Quoted 4 lines
drivers/mmc/mmc.c +1
-0@@ -3168,6 +3169,9 @@ int mmc_init(struct mmc *mmc) mmc->cfg->name); } +if (CONFIG_IS_ENABLED (OPTEE ) && mmc->capacity_rpmb >0 )
This is only used in used in U-Boot proper right? We don't have SPL/TPL symbols for RPMB support, so IS_ENABLED() is better
Cheers
/Ilias
Quoted 8 lines
drivers/mmc/mmc.c +2
-1+optee_rpmb_available (); +return err; } --2.47.3
Re: [PATCH v4 5/6] mmc: Call back to optee after a successful mmc_init
Quoted 33 lines · Ilias Apalodimas
Quoted 32 lines · Jan Kiszka
From: Jan Kiszka <[email protected]>
This is needed to that OP-TEE can re-enumerate services which need RPMB access that may have become available now.
Signed-off-by Jan Kiszka <[email protected]>Reviewed-by Peng Fan <[email protected]>Reviewed-by Tanmay Kathpalia <[email protected]>---
CC: Peng Fan <[email protected]>
CC: Jaehoon Chung <[email protected]>--- drivers/mmc/mmc.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/mmc/mmc.c +1
-0@@ -27,6 +27,7 @@#include <linux/list.h> #include <linux/printk.h> #include <div64.h> +#include <tee/optee.h> #include "mmc_private.h" #define DEFAULT_CMD6_TIMEOUT_MS 500@@ -3168,6 +3169,9 @@ int mmc_init(struct mmc *mmc) mmc->cfg->name); }
Quoted 5 lines
drivers/mmc/mmc.c int mmc_init(struct mmc *mmc) · line 3172
Quoted 1 line
drivers/mmc/mmc.c +1
-0+if (CONFIG_IS_ENABLED (OPTEE ) && mmc->capacity_rpmb >0 )This is only used in used in U-Boot proper right? We don't have SPL/TPL symbols for RPMB support, so
IS_ENABLED()is better
Can change that. Can send a v5, unless this is something that could be fixed up on merge.
For my understanding: Would that be for clarity purposes, or is there a practical advantage of limiting the check?
Thanks,
Jan
Signature · 2 lines
Siemens AG, Foundational Technologies Linux Expert Center
Re: [PATCH v4 5/6] mmc: Call back to optee after a successful mmc_init
Hey Jan
Quoted 35 lines · Jan Kiszka
Quoted 33 lines · Ilias Apalodimas
Quoted 32 lines · Jan Kiszka
From: Jan Kiszka <[email protected]>
This is needed to that OP-TEE can re-enumerate services which need RPMB access that may have become available now.
Signed-off-by Jan Kiszka <[email protected]>Reviewed-by Peng Fan <[email protected]>Reviewed-by Tanmay Kathpalia <[email protected]>---
CC: Peng Fan <[email protected]>
CC: Jaehoon Chung <[email protected]>--- drivers/mmc/mmc.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/mmc/mmc.c +1
-0@@ -27,6 +27,7 @@#include <linux/list.h> #include <linux/printk.h> #include <div64.h> +#include <tee/optee.h> #include "mmc_private.h" #define DEFAULT_CMD6_TIMEOUT_MS 500@@ -3168,6 +3169,9 @@ int mmc_init(struct mmc *mmc) mmc->cfg->name); }
Quoted 8 lines
Quoted 5 lines
drivers/mmc/mmc.c int mmc_init(struct mmc *mmc) · line 3172
Quoted 1 line
drivers/mmc/mmc.c +1
-0+if (CONFIG_IS_ENABLED (OPTEE ) && mmc->capacity_rpmb >0 )This is only used in used in U-Boot proper right? We don't have SPL/TPL symbols for RPMB support, so
IS_ENABLED()is betterCan change that. Can send a v5, unless this is something that could be fixed up on merge.
I am goign through patch #3. If that's ok I can fix this up during the merge.
Quoted 3 lines
For my understanding: Would that be for clarity purposes, or is there a practical advantage of limiting the check?
Clarity, CONFIG_IS_ENABLED() checks for both TPL/SPL symbols as well, but we dont have any of these in SPL.
Cheers
/Ilias
Quoted 7 lines
Thanks,
Jan--
Siemens AG, Foundational Technologies
Linux Expert Center
Re: [PATCH v4 3/6] tee: optee: Add support for enumerating services that only need RPMB
In reply to Jan KiszkaHi Jan
I pinged Jens for some help with the OP-TEE path.
[...]
Quoted 12 lines
drivers/tee/optee/rpmb.c +6
-0@@ -191,3 +191,23 @@ void optee_suppl_rpmb_release(struct udevice *dev) {release_mmc (dev_get_priv (dev)); } + +void optee_rpmb_available (void ) +{ +struct udevice *dev; +struct uclass *uc; +u32 tee_sess;
drivers/tee/optee/rpmb.c void optee_suppl_rpmb_release(struct udevice *dev) · line 209
Quoted 10 lines
drivers/tee/optee/rpmb.c +10
-0+ + uclass_id_foreach_dev(UCLASS_TEE, dev, uc) { +if (strcmp (dev->driver->name,"optee" ) !=0 || + !device_active (dev)) +continue ; + +if (optee_open_enum_session (dev, &tee_sess) !=0 ) +continue ; + +optee_bind_services (dev, tee_sess,PTA_CMD_GET_DEVICES_RPMB );
so both optee_probe() and this function will now call optee_bind_services(dev, tee_sess, PTA_CMD_GET_DEVICES_RPMB);. In OP-TEE that ends up holding a mutex in tee_rpmb_reinit(), but I don't know OP-TEE that well to figure out if this can deadlock.
Jens?
Cheers
/Ilias
Quoted 22 lines
drivers/tee/optee/rpmb.c +4
-0+ +tee_close_session (dev, tee_sess); + } +}include/tee/optee.h +6
-1@@ -74,4 +74,10 @@ static inline bool is_optee_smc_api(void) }#endif +#if defined(CONFIG_OPTEE ) && defined(CONFIG_SUPPORT_EMMC_RPMB ) +void optee_rpmb_available (void ); +#else +static inline void optee_rpmb_available (void ) {} +#endif +#endif /* _OPTEE_H */ --2.47.3
Re: [PATCH v4 3/6] tee: optee: Add support for enumerating services that only need RPMB
Quoted 25 lines · Ilias Apalodimas
Hi Jan
I pinged Jens for some help with the OP-TEE path.
[...]
Quoted 19 lines
drivers/tee/optee/rpmb.c +13
-0@@ -191,3 +191,23 @@ void optee_suppl_rpmb_release(struct udevice *dev) {release_mmc (dev_get_priv (dev)); } + +void optee_rpmb_available (void ) +{ +struct udevice *dev; +struct uclass *uc; +u32 tee_sess; + + uclass_id_foreach_dev(UCLASS_TEE, dev, uc) { +if (strcmp (dev->driver->name,"optee" ) !=0 || + !device_active (dev)) +continue ; + +if (optee_open_enum_session (dev, &tee_sess) !=0 )
Quoted 9 lines
drivers/tee/optee/rpmb.c void optee_suppl_rpmb_release(struct udevice *dev) · line 209
Quoted 3 lines
drivers/tee/optee/rpmb.c +3
-0+continue ; + +optee_bind_services (dev, tee_sess,PTA_CMD_GET_DEVICES_RPMB );so both
optee_probe()and this function will now calloptee_bind_services(dev, tee_sess, PTA_CMD_GET_DEVICES_RPMB);. In OP-TEE that ends up holding a mutex intee_rpmb_reinit(), but I don't know OP-TEE that well to figure out if this can deadlock.
I was developing this under the assumption that probing and init paths are single-threaded in U-Boot - aren't they?
Jan
Quoted 26 lines
Jens?
Cheers
/IliasQuoted 22 lines
drivers/tee/optee/rpmb.c +4
-0+ +tee_close_session (dev, tee_sess); + } +}include/tee/optee.h +6
-1@@ -74,4 +74,10 @@ static inline bool is_optee_smc_api(void) }#endif +#if defined(CONFIG_OPTEE ) && defined(CONFIG_SUPPORT_EMMC_RPMB ) +void optee_rpmb_available (void ); +#else +static inline void optee_rpmb_available (void ) {} +#endif +#endif /* _OPTEE_H */ --2.47.3
Signature · 2 lines
Siemens AG, Foundational Technologies Linux Expert Center
Re: [PATCH v4 3/6] tee: optee: Add support for enumerating services that only need RPMB
Quoted 37 lines · On Thu, Sep 17, 2026, 15:04 Jan Kiszka <[email protected]> wrote:
Quoted 25 lines · Ilias Apalodimas
Hi Jan
I pinged Jens for some help with the OP-TEE path.
[...]
Quoted 19 lines
drivers/tee/optee/rpmb.c +13
-0@@ -191,3 +191,23 @@ void optee_suppl_rpmb_release(struct udevice *dev) {release_mmc (dev_get_priv (dev)); } + +void optee_rpmb_available (void ) +{ +struct udevice *dev; +struct uclass *uc; +u32 tee_sess; + + uclass_id_foreach_dev(UCLASS_TEE, dev, uc) { +if (strcmp (dev->driver->name,"optee" ) !=0 || + !device_active (dev)) +continue ; + +if (optee_open_enum_session (dev, &tee_sess) !=0 )Quoted 9 lines
drivers/tee/optee/rpmb.c void optee_suppl_rpmb_release(struct udevice *dev) · line 209
Quoted 3 lines
drivers/tee/optee/rpmb.c +3
-0+continue ; + +optee_bind_services (dev, tee_sess,PTA_CMD_GET_DEVICES_RPMB );so both
optee_probe()and this function will now calloptee_bind_services(dev, tee_sess, PTA_CMD_GET_DEVICES_RPMB);. In OP-TEE that ends up holding a mutex intee_rpmb_reinit(), but I don't know OP-TEE that well to figure out if this can deadlock.
Quoted 2 lines
I was developing this under the assumption that probing and init paths are single-threaded in U-Boot - aren't they?
They are but iirc the responses from OP-TEE are RPC calls in the RPMB case, they aren't guaranteed to run to completion.
Thanks
/Ilias
Quoted 34 lines
Jan
Quoted 16 lines
Jens?
Cheers
/IliasQuoted 12 lines
drivers/tee/optee/rpmb.c +4
-0+ +tee_close_session (dev, tee_sess); + } +}include/tee/optee.h +0
-0@@ -74,4 +74,10 @@ static inline bool is_optee_smc_api(void) }#endif Quoted 10 lines
Quoted 10 lines
include/tee/optee.h +6
-1+#if defined(CONFIG_OPTEE ) && defined(CONFIG_SUPPORT_EMMC_RPMB ) +void optee_rpmb_available (void ); +#else +static inline void optee_rpmb_available (void ) {} +#endif +#endif /* _OPTEE_H */ --2.47.3
--
Siemens AG, Foundational Technologies
Linux Expert Center
Re: [PATCH v4 3/6] tee: optee: Add support for enumerating services that only need RPMB
Quoted 38 lines · Ilias Apalodimas
Quoted 37 lines · On Thu, Sep 17, 2026, 15:04 Jan Kiszka <[email protected]> wrote:
Quoted 34 lines · Ilias Apalodimas
Hi Jan
I pinged Jens for some help with the OP-TEE path.
[...]
Quoted 12 lines
drivers/tee/optee/rpmb.c +6
-0@@ -191,3 +191,23 @@ void optee_suppl_rpmb_release(struct udevice *dev) {release_mmc (dev_get_priv (dev)); } + +void optee_rpmb_available (void ) +{ +struct udevice *dev; +struct uclass *uc; +u32 tee_sess;drivers/tee/optee/rpmb.c void optee_suppl_rpmb_release(struct udevice *dev) · line 209
Quoted 10 lines
drivers/tee/optee/rpmb.c +10
-0+ + uclass_id_foreach_dev(UCLASS_TEE, dev, uc) { +if (strcmp (dev->driver->name,"optee" ) !=0 || + !device_active (dev)) +continue ; + +if (optee_open_enum_session (dev, &tee_sess) !=0 ) +continue ; + +optee_bind_services (dev, tee_sess,PTA_CMD_GET_DEVICES_RPMB );so both
optee_probe()and this function will now calloptee_bind_services(dev, tee_sess, PTA_CMD_GET_DEVICES_RPMB);. In OP-TEE that ends up holding a mutex intee_rpmb_reinit(), but I don't know OP-TEE that well to figure out if this can deadlock.
Quoted 7 lines
Quoted 2 lines
I was developing this under the assumption that probing and init paths are single-threaded in U-Boot - aren't they?
They are but iirc the responses from OP-TEE are RPC calls in the RPMB case, they aren't guaranteed to run to completion.
Maybe it would help (at least me) if you can sketch a control flow you are concerned about.
Jan
Signature · 2 lines
Siemens AG, Foundational Technologies Linux Expert Center
Ilias Apalodimas
Reviewed-byRe: [PATCH v4 3/6] tee: optee: Add support for enumerating services that only need RPMB
Hi Jan,
Quoted 44 lines · Jan Kiszka
Quoted 42 lines · Ilias Apalodimas
Quoted 39 lines · On Thu, Sep 17, 2026, 15:04 Jan Kiszka <[email protected]> wrote:
Quoted 25 lines · Ilias Apalodimas
Hi Jan
I pinged Jens for some help with the OP-TEE path.
[...]
Quoted 19 lines
drivers/tee/optee/rpmb.c +13
-0@@ -191,3 +191,23 @@ void optee_suppl_rpmb_release(struct udevice *dev) {release_mmc (dev_get_priv (dev)); } + +void optee_rpmb_available (void ) +{ +struct udevice *dev; +struct uclass *uc; +u32 tee_sess; + + uclass_id_foreach_dev(UCLASS_TEE, dev, uc) { +if (strcmp (dev->driver->name,"optee" ) !=0 || + !device_active (dev)) +continue ; + +if (optee_open_enum_session (dev, &tee_sess) !=0 )Quoted 9 lines
drivers/tee/optee/rpmb.c void optee_suppl_rpmb_release(struct udevice *dev) · line 209
Quoted 3 lines
drivers/tee/optee/rpmb.c +3
-0+continue ; + +optee_bind_services (dev, tee_sess,PTA_CMD_GET_DEVICES_RPMB );so both
optee_probe()and this function will now calloptee_bind_services(dev, tee_sess, PTA_CMD_GET_DEVICES_RPMB);. In OP-TEE that ends up holding a mutex intee_rpmb_reinit(), but I don't know OP-TEE that well to figure out if this can deadlock.I was developing this under the assumption that probing and init paths are single-threaded in U-Boot - aren't they?
Quoted 6 lines
Quoted 3 lines
They are but iirc the responses from OP-TEE are RPC calls in the RPMB case, they aren't guaranteed to run to completion.
Maybe it would help (at least me) if you can sketch a control flow you are concerned about.
I didn't have a specific sequence in mind. I just noticed the mutex locks in op-tee and was wondering if there's a chance we can re-enter on a different OP-TEE thread while holding the mutex. But I can't reprocude it locally with or without CONFIG_OPTEE_SERVICE_DISCOVERY (which changes how the device is bound).
P.S: I'll fixup is IS_ENABLED() during merge
Thanks!
/Ilias
Quoted 6 lines
Jan
--
Siemens AG, Foundational Technologies
Linux Expert Center
Re: [PATCH v4 5/6] mmc: Call back to optee after a successful mmc_init
In reply to Ilias ApalodimasPeng,
Since the mmc changes are minimal do you want me to carry them over on my tree?
Cheers
/Ilias
Quoted 66 lines · Ilias Apalodimas
Hey Jan
Quoted 35 lines · Jan Kiszka
Quoted 33 lines · Ilias Apalodimas
Quoted 32 lines · Jan Kiszka
From: Jan Kiszka <[email protected]>
This is needed to that OP-TEE can re-enumerate services which need RPMB access that may have become available now.
Signed-off-by Jan Kiszka <[email protected]>Reviewed-by Peng Fan <[email protected]>Reviewed-by Tanmay Kathpalia <[email protected]>---
CC: Peng Fan <[email protected]>
CC: Jaehoon Chung <[email protected]>--- drivers/mmc/mmc.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/mmc/mmc.c +1
-0@@ -27,6 +27,7 @@#include <linux/list.h> #include <linux/printk.h> #include <div64.h> +#include <tee/optee.h> #include "mmc_private.h" #define DEFAULT_CMD6_TIMEOUT_MS 500@@ -3168,6 +3169,9 @@ int mmc_init(struct mmc *mmc) mmc->cfg->name); }Quoted 8 lines
Quoted 5 lines
drivers/mmc/mmc.c int mmc_init(struct mmc *mmc) · line 3172
Quoted 1 line
drivers/mmc/mmc.c +1
-0+if (CONFIG_IS_ENABLED (OPTEE ) && mmc->capacity_rpmb >0 )This is only used in used in U-Boot proper right? We don't have SPL/TPL symbols for RPMB support, so
IS_ENABLED()is betterCan change that. Can send a v5, unless this is something that could be fixed up on merge.
I am goign through patch #3. If that's ok I can fix this up during the merge.
Quoted 3 lines
For my understanding: Would that be for clarity purposes, or is there a practical advantage of limiting the check?
Clarity,
CONFIG_IS_ENABLED()checks for both TPL/SPL symbols as well, but we dont have any of these in SPL.Cheers
/IliasQuoted 7 lines
Thanks,
Jan--
Siemens AG, Foundational Technologies
Linux Expert Center
Re: [PATCH v4 3/6] tee: optee: Add support for enumerating services that only need RPMB
In reply to Ilias ApalodimasHi Jan
The CI seems to complain again unfortunately.
https://git.u-boot-project.org/u-boot/custodians/u-boot-tpm/-/jobs/96289#L2649
I didnt check yet, but it seems like a missing header somewhere!
Cheers
/Ilias
Quoted 74 lines · Ilias Apalodimas
Hi Jan,
Quoted 44 lines · Jan Kiszka
Quoted 42 lines · Ilias Apalodimas
Quoted 39 lines · On Thu, Sep 17, 2026, 15:04 Jan Kiszka <[email protected]> wrote:
Quoted 25 lines · Ilias Apalodimas
Hi Jan
I pinged Jens for some help with the OP-TEE path.
[...]
Quoted 19 lines
drivers/tee/optee/rpmb.c +13
-0@@ -191,3 +191,23 @@ void optee_suppl_rpmb_release(struct udevice *dev) {release_mmc (dev_get_priv (dev)); } + +void optee_rpmb_available (void ) +{ +struct udevice *dev; +struct uclass *uc; +u32 tee_sess; + + uclass_id_foreach_dev(UCLASS_TEE, dev, uc) { +if (strcmp (dev->driver->name,"optee" ) !=0 || + !device_active (dev)) +continue ; + +if (optee_open_enum_session (dev, &tee_sess) !=0 )Quoted 9 lines
drivers/tee/optee/rpmb.c void optee_suppl_rpmb_release(struct udevice *dev) · line 209
Quoted 3 lines
drivers/tee/optee/rpmb.c +3
-0+continue ; + +optee_bind_services (dev, tee_sess,PTA_CMD_GET_DEVICES_RPMB );so both
optee_probe()and this function will now calloptee_bind_services(dev, tee_sess, PTA_CMD_GET_DEVICES_RPMB);. In OP-TEE that ends up holding a mutex intee_rpmb_reinit(), but I don't know OP-TEE that well to figure out if this can deadlock.I was developing this under the assumption that probing and init paths are single-threaded in U-Boot - aren't they?
Quoted 6 lines
Quoted 3 lines
They are but iirc the responses from OP-TEE are RPC calls in the RPMB case, they aren't guaranteed to run to completion.
Maybe it would help (at least me) if you can sketch a control flow you are concerned about.
I didn't have a specific sequence in mind. I just noticed the mutex locks in op-tee and was wondering if there's a chance we can re-enter on a different OP-TEE thread while holding the mutex. But I can't reprocude it locally with or without
CONFIG_OPTEE_SERVICE_DISCOVERY(which changes how the device is bound).Reviewed-by Ilias Apalodimas <[email protected]>
P.S: I'll fixup isIS_ENABLED()during mergeThanks!
/IliasQuoted 6 lines
Jan
--
Siemens AG, Foundational Technologies
Linux Expert Center
Re: [PATCH v4 3/6] tee: optee: Add support for enumerating services that only need RPMB
Quoted 7 lines · Ilias Apalodimas
Hi Jan
The CI seems to complain again unfortunately.
https://git.u-boot-project.org/u-boot/custodians/u-boot-tpm/-/jobs/96289#L2649I didnt check yet, but it seems like a missing header somewhere!
Where you able to find the reason, or do you need support? I tried to read the CI log, but it is very hard for me to correlate the output with the configuration that might have been involved.
Jan
Quoted 79 lines
Cheers
/IliasQuoted 74 lines · Ilias Apalodimas
Hi Jan,
Quoted 44 lines · Jan Kiszka
Quoted 42 lines · Ilias Apalodimas
Quoted 39 lines · On Thu, Sep 17, 2026, 15:04 Jan Kiszka <[email protected]> wrote:
Quoted 25 lines · Ilias Apalodimas
Hi Jan
I pinged Jens for some help with the OP-TEE path.
[...]
Quoted 19 lines
drivers/tee/optee/rpmb.c +13
-0@@ -191,3 +191,23 @@ void optee_suppl_rpmb_release(struct udevice *dev) {release_mmc (dev_get_priv (dev)); } + +void optee_rpmb_available (void ) +{ +struct udevice *dev; +struct uclass *uc; +u32 tee_sess; + + uclass_id_foreach_dev(UCLASS_TEE, dev, uc) { +if (strcmp (dev->driver->name,"optee" ) !=0 || + !device_active (dev)) +continue ; + +if (optee_open_enum_session (dev, &tee_sess) !=0 )Quoted 9 lines
drivers/tee/optee/rpmb.c void optee_suppl_rpmb_release(struct udevice *dev) · line 209
Quoted 3 lines
drivers/tee/optee/rpmb.c +3
-0+continue ; + +optee_bind_services (dev, tee_sess,PTA_CMD_GET_DEVICES_RPMB );so both
optee_probe()and this function will now calloptee_bind_services(dev, tee_sess, PTA_CMD_GET_DEVICES_RPMB);. In OP-TEE that ends up holding a mutex intee_rpmb_reinit(), but I don't know OP-TEE that well to figure out if this can deadlock.I was developing this under the assumption that probing and init paths are single-threaded in U-Boot - aren't they?
Quoted 6 lines
Quoted 3 lines
They are but iirc the responses from OP-TEE are RPC calls in the RPMB case, they aren't guaranteed to run to completion.
Maybe it would help (at least me) if you can sketch a control flow you are concerned about.
I didn't have a specific sequence in mind. I just noticed the mutex locks in op-tee and was wondering if there's a chance we can re-enter on a different OP-TEE thread while holding the mutex. But I can't reprocude it locally with or without
CONFIG_OPTEE_SERVICE_DISCOVERY(which changes how the device is bound).Reviewed-by Ilias Apalodimas <[email protected]>
P.S: I'll fixup isIS_ENABLED()during mergeThanks!
/IliasQuoted 6 lines
Jan
--
Siemens AG, Foundational Technologies
Linux Expert Center
Signature · 2 lines
Siemens AG, Foundational Technologies Linux Expert Center
Re: [PATCH v4 3/6] tee: optee: Add support for enumerating services that only need RPMB
Quoted 7 lines · Jan Kiszka
Quoted 5 lines · Ilias Apalodimas
Hi Jan
The CI seems to complain again unfortunately.
https://git.u-boot-project.org/u-boot/custodians/u-boot-tpm/-/jobs/96289#L2649
Quoted 6 lines
Quoted 2 lines
I didnt check yet, but it seems like a missing header somewhere!
Where you able to find the reason, or do you need support? I tried to read the CI log, but it is very hard for me to correlate the output with the configuration that might have been involved.
It blows up in SPL, so I probably triggered that from switching CONFIG_IS_ENABLED to IS_ENABLED. I'll requeue it on the CI with that change
Cheers
/Ilias
Quoted 86 lines
Jan
Quoted 79 lines
Cheers
/IliasQuoted 74 lines · Ilias Apalodimas
Hi Jan,
Quoted 44 lines · Jan Kiszka
Quoted 42 lines · Ilias Apalodimas
Quoted 39 lines · On Thu, Sep 17, 2026, 15:04 Jan Kiszka <[email protected]> wrote:
Quoted 25 lines · Ilias Apalodimas
Hi Jan
I pinged Jens for some help with the OP-TEE path.
[...]
Quoted 19 lines
drivers/tee/optee/rpmb.c +13
-0@@ -191,3 +191,23 @@ void optee_suppl_rpmb_release(struct udevice *dev) {release_mmc (dev_get_priv (dev)); } + +void optee_rpmb_available (void ) +{ +struct udevice *dev; +struct uclass *uc; +u32 tee_sess; + + uclass_id_foreach_dev(UCLASS_TEE, dev, uc) { +if (strcmp (dev->driver->name,"optee" ) !=0 || + !device_active (dev)) +continue ; + +if (optee_open_enum_session (dev, &tee_sess) !=0 )Quoted 9 lines
drivers/tee/optee/rpmb.c void optee_suppl_rpmb_release(struct udevice *dev) · line 209
Quoted 3 lines
drivers/tee/optee/rpmb.c +3
-0+continue ; + +optee_bind_services (dev, tee_sess,PTA_CMD_GET_DEVICES_RPMB );so both
optee_probe()and this function will now calloptee_bind_services(dev, tee_sess, PTA_CMD_GET_DEVICES_RPMB);. In OP-TEE that ends up holding a mutex intee_rpmb_reinit(), but I don't know OP-TEE that well to figure out if this can deadlock.I was developing this under the assumption that probing and init paths are single-threaded in U-Boot - aren't they?
Quoted 6 lines
Quoted 3 lines
They are but iirc the responses from OP-TEE are RPC calls in the RPMB case, they aren't guaranteed to run to completion.
Maybe it would help (at least me) if you can sketch a control flow you are concerned about.
I didn't have a specific sequence in mind. I just noticed the mutex locks in op-tee and was wondering if there's a chance we can re-enter on a different OP-TEE thread while holding the mutex. But I can't reprocude it locally with or without
CONFIG_OPTEE_SERVICE_DISCOVERY(which changes how the device is bound).Reviewed-by Ilias Apalodimas <[email protected]>
P.S: I'll fixup isIS_ENABLED()during mergeThanks!
/IliasQuoted 6 lines
Jan
--
Siemens AG, Foundational Technologies
Linux Expert Center--
Siemens AG, Foundational Technologies
Linux Expert Center