<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">2016-05-31 10:35 GMT+01:00 Stefan Kalkowski <span dir="ltr"><<a href="mailto:stefan.kalkowski@...1..." target="_blank">stefan.kalkowski@...169.....1...</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hello Tiago,<br></blockquote><div><br></div><div>Hi Stefan, thanks for your response. It really helps!</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<span class=""><br>
On 05/25/2016 04:56 PM, Tiago Brito wrote:<br>
> Hi, I have an i.MX53 QSB development board and I want to experiment with<br>
> ARM TrustZone.<br>
><br>
> I'm a beginner with regards to genode and kernel development in general.<br>
><br>
> I was able to run tz_vmm on the QSB and interact with the linux which runs<br>
> in normal world. What I want to do next is a fairly simple system where<br>
> inside linux I can call an SMC and switch to the secure world, then whilst<br>
> in secure world print something (like "Hello From Secure World" and also<br>
> print some argument from the normal world) and then go back to linux.<br>
><br>
> I have read some of the messages in the mailing list and I noticed some of<br>
> you (other mailing list subscribers) already achieved similar communication<br>
> protocols but because I'm new to genode I don't know where to start.<br>
<br>
</span>Well, the very first pointer to gain more understanding of this concrete<br>
scenario ist to read the detailed documentation of it:<br>
<br>
  <a href="http://genode.org/documentation/articles/trustzone" rel="noreferrer" target="_blank">http://genode.org/documentation/articles/trustzone</a><br>
<br>
Most of your questions, e.g., how to build the Linux kernel?, or is it a<br>
modified Linux kernel? are already answered there.<br></blockquote><div><br></div><div>I read this and I now understand the flow which makes tz_vmm work.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<span class=""><br>
><br>
> I know I probably have to create a kernel module for the linux running in<br>
> normal world so I can call SMC from a userspace application, but I don't<br>
> know how to do that since I don't see where the linux is being compiled for<br>
> genode [1]. Do I have to compile another linux? How do I incorporate this<br>
> new linux version to work with genode?<br>
<br>
</span>Actually the Linux kernel version you are using when executing the<br>
tz_vmm run-script already issues SMC calls that switch to the secure<br>
world, where the VMM handles those calls and afterwards returns to the<br>
normal world.<br></blockquote><div><br></div><div>I understand this, but is there a way to make a user-level application to trigger an SMC (with an identifier) so that the secure world, after trapping the SMC, can do something accordingly?</div><div><br></div><div>What I read from other posts is that I have to change tz_vmm's Linux in order to support this.</div><div>I think other people from this mailing list already did so by adding system calls or kernel modules which trigger the SMC.</div><div>This way my user-level application can use this system call/kernel module in order to manually switch to the secure world.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<span class=""><br>
><br>
> Besides this I also don't know where to start modifying tz_vmm in order to<br>
> achieve my goals. I know where tz_vmm's code is but I don't know where to<br>
> start changing it. I have also seen some mailing list questions regarding<br>
> the world switch from secure world to normal world. It seems that from<br>
> normal to secure you should call an SMC, but from secure to normal the<br>
> monitor mode implementation cannot handle entries from the secure world and<br>
> thus no SMC can be called directly [2].<br>
<br>
</span>The typical activity flow is:<br>
<br>
 * Linux kernel issues an SMC call, e.g., to tell the VMM where its<br>
   framebuffer is located in physical memory [1]<br>
 * the HW kernel of Genode receives an exception, pauses the Linux VM,<br>
   and delivers a signal to the related VMM [2]<br>
 * the VMM receives the signal that the VM got paused due to an SMC<br>
   call [3]<br>
 * the VMM informs the HW kernel that the VM should be executed again<br>
   after handling the call [4]<br>
 * next time the scheduler of the HW kernel chooses the VM, it issues a<br>
   world-switch to it [5]<br></blockquote><div><br></div><div><div>From tz_vmm's code I understand that both r0 and r1 registers can be used as arguments for the SMC, which solves the identifier problem I mentioned.</div><div>This way I can change tz_vmm so that when the SMC triggered by the user-level app is caught I can print something to the serial console. </div></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
Regards<br>
Stefan<br></blockquote><div><br></div><div>Thanks again!</div><div><br></div><div>Best Regards, Tiago</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
[1]<br>
<a href="https://github.com/skalk/linux/blob/bc1707a23a9770cf080a1b87b4f553a2a39ac636/drivers/video/mxc/mxc_ipuv3_fb.c#L339" rel="noreferrer" target="_blank">https://github.com/skalk/linux/blob/bc1707a23a9770cf080a1b87b4f553a2a39ac636/drivers/video/mxc/mxc_ipuv3_fb.c#L339</a><br>
[2]<br>
<a href="https://github.com/genodelabs/genode/blob/master/repos/base-hw/src/core/spec/arm_v7/trustzone/kernel/vm.cc#L52" rel="noreferrer" target="_blank">https://github.com/genodelabs/genode/blob/master/repos/base-hw/src/core/spec/arm_v7/trustzone/kernel/vm.cc#L52</a><br>
[3]<br>
<a href="https://github.com/genodelabs/genode/blob/master/repos/os/src/server/tz_vmm/spec/imx53/main.cc#L95" rel="noreferrer" target="_blank">https://github.com/genodelabs/genode/blob/master/repos/os/src/server/tz_vmm/spec/imx53/main.cc#L95</a><br>
[4]<br>
<a href="https://github.com/genodelabs/genode/blob/master/repos/os/src/server/tz_vmm/spec/imx53/main.cc#L119" rel="noreferrer" target="_blank">https://github.com/genodelabs/genode/blob/master/repos/os/src/server/tz_vmm/spec/imx53/main.cc#L119</a><br>
[5]<br>
<a href="https://github.com/genodelabs/genode/blob/master/repos/base-hw/src/core/spec/arm_v7/trustzone/kernel/vm.cc#L72" rel="noreferrer" target="_blank">https://github.com/genodelabs/genode/blob/master/repos/base-hw/src/core/spec/arm_v7/trustzone/kernel/vm.cc#L72</a><br>
<span class=""><br>
><br>
> Can you give my some feedback on how to achieve these things on the i.MX53<br>
> QSB?<br>
><br>
> Thanks in advance, Tiago<br>
><br>
> [1] - <a href="https://sourceforge.net/p/genode/mailman/message/33244107/" rel="noreferrer" target="_blank">https://sourceforge.net/p/genode/mailman/message/33244107/</a><br>
> [2] - <a href="https://sourceforge.net/p/genode/mailman/message/34244066/" rel="noreferrer" target="_blank">https://sourceforge.net/p/genode/mailman/message/34244066/</a><br>
></span><br>
</blockquote></div><br></div></div>