New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SingleInstance, MultiSession TA is loaded multiple times #6801
Comments
Hi @KhOlegDc, I don't understand. |
There is only one TA available and it's my one. To make sure that TA_FLAGS are correctly passed to the TA during build, I added check for these values:
you can see the output in the log:
This setup runs in QEMU, I start the VM, connect to it via SSH and upload the TA to |
The same behaviour is observed with OP-TEE v4.2.0 - calls from two CAs result in two TA instances loaded in memory. |
I'll try to reproduce on qemu_virt or qemu_armv8a. |
Hi @KhOlegDc, |
Hi @etienne-lms, |
I applied this change on optee_test: diff --git a/ta/crypt/include/user_ta_header_defines.h b/ta/crypt/include/user_ta_header_defines.h
index ac83ae05f..ea0ce9a54 100644
--- a/ta/crypt/include/user_ta_header_defines.h
+++ b/ta/crypt/include/user_ta_header_defines.h
@@ -11,7 +11,7 @@
#define TA_UUID TA_CRYPT_UUID
-#define TA_FLAGS (TA_FLAG_USER_MODE | TA_FLAG_EXEC_DDR)
+#define TA_FLAGS (TA_FLAG_SINGLE_INSTANCE | TA_FLAG_MULTI_SESSION)
#define TA_STACK_SIZE (32 * 1024)
#define TA_DATA_SIZE (32 * 1024)
diff --git a/ta/crypt/ta_entry.c b/ta/crypt/ta_entry.c
index b997b0c7e..8bd6ce2e3 100644
--- a/ta/crypt/ta_entry.c
+++ b/ta/crypt/ta_entry.c
@@ -70,6 +70,8 @@ TEE_Result TA_InvokeCommandEntryPoint(void *pSessionContext,
(void)pSessionContext;
+ TEE_Wait(1000);
+
switch (nCommandID) {
case TA_CRYPT_CMD_SHA224:
use_fptr = !use_fptr; and run from Linux console The OP-TEE debug level logs show 2 sessions & 1 TA context:
|
In my case I also could achieve that only one instance gets loaded. When I run two copies this way:
I observe that two instances are loaded as shown in the log in my first message. When I run the applications this way:
I see that only one instance is loaded:
My hypothesis is that there is a race. The context is only then gets visible to In my case, |
Fix race condition on single instance TA creation where several instances of a single instance TA could be created if invoked closed enough that they are created after tee_ta_init_session() calls tee_ta_init_session_with_context(). Closes: OP-TEE#6801 Signed-off-by: Etienne Carriere <etienne.carriere@foss.st.com>
Fix race condition on single instance TA creation where several instances of a single instance TA could be created if invoked close enough that they are both created after tee_ta_init_session() calls tee_ta_init_session_with_context(). Closes: OP-TEE#6801 Signed-off-by: Etienne Carriere <etienne.carriere@foss.st.com>
Indeed! nice catch, thanks. I should have tried without this sleep command :( |
Fix race condition on single instance TA creation where several instances of a single instance TA could be created if invoked close enough that they are both created after tee_ta_init_session() calls tee_ta_init_session_with_context(). Closes: OP-TEE#6801 Signed-off-by: Etienne Carriere <etienne.carriere@foss.st.com>
Hello,
I have two CAs, connecting to the same TA. I want that only one TA instance will be in memory, serving requests from both CAs. I understand that requests will be served sequentially, that's OK and even desired. The idea is to share TA's RAM (heap objects) when serving requests from different CAs.
To achieve this, I configured TA:
and initialized each of CAs:
I run both CAs, making sure that sessions from both overlap in time. However, in the log I see that a separate TA instance is loaded for each CA session:
OP-TEE v3.22, running on qemu_v8
Could you suggest something to have only one TA instance in memory?
The text was updated successfully, but these errors were encountered: