-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Freezing OP-TEE fails during suspend #4581
Comments
Thanks a lot for the description. Pretty clear and detailed. |
In order to reproduce the other two situations where wait_for_completion can get stuck, you need multiple parallel requests. To allow multiple requests you can apply the following patch to secure_storage in optee_examples (in addition to the reproduction patch mentioned above)
Afterwards you can reproduce the issue in QEMU v7 using the following command
In QEMU v7 you could additionally schedule resuming e.g. after 30sec by prepending
Afterwards you should get a output similar to below having 3 stuck tasks
The first back-trace is stuck while waiting for tee-supplicant (see initial message) The second back-trace shows The last back-trace seems to be at |
Although it isn't directly related and it won't get stuck I wanted to mention one additional scenario influenced by freezing the tasks. The msleep_interruptible in handle_rpc_func_cmd_wait should be affected by the fake signals of the suspend. |
This issue has been marked as a stale issue because it has been open (more than) 30 days with no activity. Remove the stale label or add a comment, otherwise this issue will automatically be closed in 5 days. Note, that you can always re-open a closed issue at any time. |
I proposed a set of patches via mailing lists Currently waiting for some more feedback |
This issue has been marked as a stale issue because it has been open (more than) 30 days with no activity. Remove the stale label or add a comment, otherwise this issue will automatically be closed in 5 days. Note, that you can always re-open a closed issue at any time. |
Beside the response of @jenswi-linaro I didn't see any feedback on RFC tagged patches Therefore I send patches again - this time without RFC tag |
This issue has been marked as a stale issue because it has been open (more than) 30 days with no activity. Remove the stale label or add a comment, otherwise this issue will automatically be closed in 5 days. Note, that you can always re-open a closed issue at any time. |
Can this thread be re-open and tagged enhancement? |
Hi,
Do you know if the mentioned "suspend" problem has been solved differently ? I have seen that latest kernel has some small changes (787c80cc7b22804aa370f04a19f9fe0fa98b1e49) In case there is some interest in this patch I could
But before starting I would like to understand if there is some general interest in this patch at all or if failing to freeze during suspend is no problem from your perspective. |
Hi @cgellner, Technically speaking I can't say if your patches are correct because I don't know the Linux suspend mechanisms well enough. However it seems you are addressing a real issue with these patches, so I think they deserve more attention.
@jenswi-linaro I think it is the way to go, isn't it? Maybe CC some experts of the "freeze" interface, too? |
I agree and the same problem here that I don't know that area well enough. |
I have meet the problem too. When tee-supplicant has been frozen, and then other task request tee-supplicant, it can't enter freezing flow. So kernel can't finish freeze flow, and will not enter suspend flow. Your patch can solve the problem. |
The last trace of @cgellner 's patchset I could see on the Linux Kernel Mailing list is https://lore.kernel.org/all/[email protected]/ (August 2021) and it has never gathered any Acked-by, Reviewed-by or Tested-by apparently (at least there is no such tags in the patches themselves). @victorchenpan are you subscribed to the LKML? Would you be able to provide feedback if the series was to be re-posted? Or perhaps even reply to the already sent emails by following the "Reply instructions" on the ML page? |
Thanks for your patch @cgellner , I met the same issue. After I update your patch, it seems that it works. However, if I do more test , such as stress test for STR when xtest is running. It may cause CPU rcu stall issue. Do you have similar phenomena ? Thanks |
When trying to suspend to RAM the OP-TEE TA user-space tasks using OP-TEE might fail to freeze
According to my understanding this happens if a TA, triggered by the task to freeze, is trying to communicate to tee-supplicant, but tee-supplicant has been frozen first.
In order to reproduce OP-TEE QEMU environment can be used.
In order to increase the probability of the TA trying to communicate to tee-supplicant during suspend, the below patch should be applied to secure_storage_ta.c in optee_examples.
Afterwards you can reproduce by executing
(optee_example_secure_storage &); sleep 1; echo -n mem > /sys/power/state
from non-secure world.
During debugging I could see, that while kernel trying to freeze the task is looping in
drivers/tee/supp.c - optee_supp_thrd_req
while (wait_for_completion_interruptible(&req->c))
Note: In my understanding other cases might be possible as well e.g.
When I modified kernel/power/process.c - try_to_freeze_tasks - not to freeze tee-supplicant when freezing user tasks, the issue is not reproducible and suspend will happen after the TA did complete its work.
I wonder if there is a generic kernel mechanism to avoid freezing of user-space helper tasks like tee-supplicant.
How is this solved for fuse-FS? Isn't it using some user-space tasks for processing as well?
When I modified drivers/tee/supp.c - optee_supp_thrd_req - to call try_to_freeze in the wait_for_completion_interruptible loop mentioned above, the issue is not reproducible and suspend will happen although TA did not yet complete its work. TA will continue after the resume.
I'm not clear, if it is legal from OP-TEE perspective to suspend while TA is still executing.
The text was updated successfully, but these errors were encountered: