Open weizhaojiang opened 1 week ago
CFG_CONCURRENT_SINGLE_INSTANCE_TA
here seems skip the lock.
#ifdef CFG_CONCURRENT_SINGLE_INSTANCE_TA
static void lock_single_instance(void)
{
}
static void unlock_single_instance(void)
{
}
static bool has_single_instance_lock(void)
{
return false;
}
#else
Does it mean enabling the CFG_CONCURRENT_SINGLE_INSTANCE_TA option will have single-instance TAs same behavior as multiple-instance TAs? Specifically, CMDs from the same single-instance TA will not be serialized.
CFG_CONCURRENT_SINGLE_INSTANCE_TA was introduced by commit daeea0369d17 ("Add CFG_CONCURRENT_SINGLE_INSTANCE_TA") I think the commit message speaks for itself:
Add CFG_CONCURRENT_SINGLE_INSTANCE_TA
Commit 2b07dcb97c5e ("core: avoid deadlocks caused by single-instance
TA") introduces a lock that allows only one single instance TA to be
executing at any time. While it does address the risk of deadlock that
can arise when several single instance TAs call each other, it also
puts a serious performance limitation on multi-core platforms, which
could otherwise execute several unrelated single instance TAs
simultaneously.
This commit makes the single instance lock optional. By setting
CFG_CONCURRENT_SINGLE_INSTANCE_TA=y, the lock is disabled and TAs are
allowed to run concurrently. In the future, we may implement a deadlock
detection algorithm; in the meantime, this simple solution should be
enough to cover the current use cases.
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Tested-by: Jerome Forissier <jerome.forissier@linaro.org> (HiKey960)
CC: Zeng Tao <prime.zeng@hisilicon.com>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
The
tee_ta_single_instance_thread
andtee_ta_single_instance_count
variables are global variables defined within the TEE core (tee_ta_manager.c), and they play a role in managing the execution of single-instance TAs.Locking Mechanism:
lock_single_instance
is used to acquire a lock for executing a single-instance TA.Because of
tee_ta_single_instance_thread
andtee_ta_single_instance_count
are global variables, it seems that the fucntion oflock_single_instance()/unlock_single_instance()
are to serialize cmds from all single-instance TAs, which means if one single-instance TA is executing, any other single-instance TA's command must wait until the current one completes. Is above understanding correct? If so, my follow up question is why we need to ensure that the execution of single-instance TAs is globally serialized across the entire TEE environment?