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

Running Normal World App with OPTEE-OS on The Same Core #1036

Closed
SimonWan opened this Issue Sep 6, 2016 · 4 comments

Comments

Projects
None yet
2 participants
@SimonWan

SimonWan commented Sep 6, 2016

Hi Experts,

I'm confused about how the cpu schedules OPTEE-OS tasks with a NS app at the same time.

I conducted some tests and I found out that a NS app could run on the same core while one TA is already running.
According to my understanding, if one core is running a TA then it has entered the secure world. In this case, how could it also runs a NS app before the TA finished?
Could you please tell me where are the codes that work for handling this case?

Any information is appreciated!

Simon

@jbech-linaro

This comment has been minimized.

Show comment
Hide comment
@jbech-linaro

jbech-linaro Sep 6, 2016

Contributor

@SimonWan a running TA, can trigger RPC calls back to normal world (and there can also be interrupts). So most likely what you have been seeing is that the TA has issued a RPC. During that time before the RPC returns to secure world anyone else can use the core that the TA was running on.

Contributor

jbech-linaro commented Sep 6, 2016

@SimonWan a running TA, can trigger RPC calls back to normal world (and there can also be interrupts). So most likely what you have been seeing is that the TA has issued a RPC. During that time before the RPC returns to secure world anyone else can use the core that the TA was running on.

@SimonWan

This comment has been minimized.

Show comment
Hide comment
@SimonWan

SimonWan Sep 6, 2016

@jbech-linaro thank you for the replying. So you mean the running TA would automatically trigger RPC calls? Are these RPC calls generated in OPTEEOS or A-TF?

Futheremore, do you know where I could find the related code?

SimonWan commented Sep 6, 2016

@jbech-linaro thank you for the replying. So you mean the running TA would automatically trigger RPC calls? Are these RPC calls generated in OPTEEOS or A-TF?

Futheremore, do you know where I could find the related code?

@jbech-linaro

This comment has been minimized.

Show comment
Hide comment
@jbech-linaro

jbech-linaro Sep 6, 2016

Contributor

Yes, depending on what operation the TA was running that can very well happen, FS call, mutex being used, condvar being used. Where it is? RPC code is in many place, easiest is just to search for it: https://github.com/OP-TEE/optee_os/search?utf8=%E2%9C%93&q=rpc . You could also have a look at the design doc, RPC is mentioned in quite a few places there: https://github.com/OP-TEE/optee_os/blob/master/documentation/optee_design.md

One way of testing this being sure that no RPC has been triggered is to do a while(1) {} in the TA. If you do that, then you can be sure that it will stay there until there is an interrupt triggering (which happens quite often). So, you would still get the illusion that it's running the TA, but still runs other apps on the same core, so such an exercise doesn't give much more information and knowledge.

To summarize:
If a TA is running, i.e, code is running in secure world. Then nothing else can run on that core in normal world. But as soon either an RPC fires or a interrupt triggers, then there will be a handover to normal world and secure side is just waiting for the RPC to return or ... until the interrupt has been handled. I.e, code runs in normal world during that time.

Contributor

jbech-linaro commented Sep 6, 2016

Yes, depending on what operation the TA was running that can very well happen, FS call, mutex being used, condvar being used. Where it is? RPC code is in many place, easiest is just to search for it: https://github.com/OP-TEE/optee_os/search?utf8=%E2%9C%93&q=rpc . You could also have a look at the design doc, RPC is mentioned in quite a few places there: https://github.com/OP-TEE/optee_os/blob/master/documentation/optee_design.md

One way of testing this being sure that no RPC has been triggered is to do a while(1) {} in the TA. If you do that, then you can be sure that it will stay there until there is an interrupt triggering (which happens quite often). So, you would still get the illusion that it's running the TA, but still runs other apps on the same core, so such an exercise doesn't give much more information and knowledge.

To summarize:
If a TA is running, i.e, code is running in secure world. Then nothing else can run on that core in normal world. But as soon either an RPC fires or a interrupt triggers, then there will be a handover to normal world and secure side is just waiting for the RPC to return or ... until the interrupt has been handled. I.e, code runs in normal world during that time.

@SimonWan

This comment has been minimized.

Show comment
Hide comment
@SimonWan

SimonWan Sep 6, 2016

@jbech-linaro thank you so much, that's pretty clear and complete answer for me! Have a good day.

SimonWan commented Sep 6, 2016

@jbech-linaro thank you so much, that's pretty clear and complete answer for me! Have a good day.

@SimonWan SimonWan closed this Sep 6, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment