ARM的TrustZone - 在安全和非安全的OS调度器的行为 [英] ARM TrustZone - Behaviour of the scheduler in Secure and Non-Secure OS

查看:878
本文介绍了ARM的TrustZone - 在安全和非安全的OS调度器的行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

能否有人请向我解释说,CPU是采取安全模式后,(Monitor程序设置 NS = 0 ),如何在安全的操作系统被调度?
难道现在的CPU处于安全模式,定时器节拍中断将由担保操作系统来处理,而不是非安全的世界?

Can some one please explain to me that after the CPU is taken to secured mode, (Monitor program sets the NS = 0), how does the secure OS gets scheduled? Is it that now that the CPU is in secured mode, the timer tick interrupt would be handled by the Secured OS and not the Non-Secured world?

推荐答案

显示器模式设置 NS = 0 将设置CP15寄存器从监控模式可见。参见:<一href=\"http://stackoverflow.com/questions/22080918/trustzone-monitor-mode-and-ifar-ifsr-dfar-dfsr\">monitor模式IFAR / IFSR ... 。当的监控模式的切换到另一种模式 NS = 0 ,则该模式是的安全的世界的版本;这意味着开户CP15寄存器中的安全的版本。另外, NS 位是明确的总线周期

The monitor mode setting NS=0 will set CP15 registers visible from monitor mode. See: monitor mode IFAR/IFSR.... When the monitor mode switches to another mode and NS=0, then the mode is the secure world version; meaning the banked CP15 registers are the secure version. Also the NS bit is clear on bus cycles.

如果 NS = 1 设置,那么当显示器模式开关,开户CP15寄存器是的正常的版本;主要的正常的世界MMU将被激活。此外, NS 位时的总线周期的。 TZ VS虚拟机管理程序

If NS=1 is set, then when monitor mode switches, the banked CP15 registers are the normal version; mainly the normal world MMU will be active. Also, the NS bit is set on bus cycles. TZ vs hypervisor

如何安全的操作系统被调度?

How does the secure OS gets scheduled?

监控模式做到这一点。在 SCR (CP15 C1,C1,0)具有判断是否的监视器的矢量表用于或位的当前CPU的世界(的安全的或的正常的)。如果你是在一个的正常的世界,你希望有一个定时器中断一个世界,你需要的监控模式的处理它。

Monitor mode does this. The SCR (cp15 c1, c1, 0) has bits which determine whether the monitor vector table is used or the current CPU world (secure or normal). If you are in a normal world and you wish for a timer to interrupt that world, you need monitor mode to handle it.

您可以设置两种可能的方式监控模式,

You can setup the monitor mode in two possible ways,


  1. 让所有安全中断为 FIQ

  2. 陷阱所有的中断监测。

建议的首选。在这种模式下,的监测的code必须确保 SCR#FIQ (第2位)是在正常世界,但在安全的世界清晰。在 SCR#IRQ (第1位),运行安全的操作系统(如果你想的正常的中断中断安全OS),并清楚何时将被设置在正常的世界。

The first choice is recommended. In this mode, the monitor code must ensure that SCR#FIQ (bit 2) is set in the normal world, but clear in the secure world. The SCR#IRQ (bit 1) will be set when running the secure OS (if you want normal interrupts to interrupt the secure OS) and clear in the normal world.

所以当的安全的计时器有一个 FIQ 中断,这陷阱来监测模式,做了的世界开关 REF1 和运行的安全的操作系统的计时器code。这的安全定时器的可能会导致安全的世界重新安排。该方式的正常的和的安全的世界调度交互达软件。即,不存在通用的答案。这取决于,

So when the secure timer has a FIQ interrupt, it traps to monitor mode which does a world switchref1 and runs the secure OS timer code. This secure timer may cause the secure world to reschedule. The way the normal and secure world schedulers interact is up to software. Ie, there is no generic answer. It depends on,


  1. 监控模式

  2. 安全的OS。

  3. 正常的世界OS。

  1. Monitor mode
  2. The secure OS.
  3. The normal world OS.

主要的 ARM的TrustZone 的本身并不处理的安全的操作系统的调度。你需要写一个使用提供了实现这个原语的软件。 ARM的TrustZone 的既方便实现它的不同方式。 的TrustZone白皮书

Mainly the ARM TrustZone does not handle the secure OS scheduling by itself. You need to write software that uses the primitives provided to implement this. ARM TrustZone only facilitates different ways of implementing it. TrustZone Whitepaper

请参阅:如何开发针对的TrustZone 方案一些替代设置。

参考文献1:A 世界开关的保存/恢复所有的使用模式都通用CPU寄存器。也就是说,在一个的正常的到的安全的世界开关,R0-R15(及所有开户副本),加上可能NEON / VFP必须保存到一个的正常的世界的店。同样,寄存器必须重新加载了的安全的世界的。监控模式 SP 提供访问良好的锚这些世界环境的。监控模式 SP 应该是安全的启动过程中设置的的正常的世界前初始化。这很像传统的操作系统上下文切换。在 SCR#NS (位0)设置正确;你可能之前或寄存器切换后,做到这一点取决于你如何保存寄存器(即通过模式开关或 SRS )。

See: How to develop programs for TrustZone for some alternative setups.
Ref1: A world switch saves/restores all general purpose CPU registers for all used modes. Ie, on a normal to secure world switch, the R0-R15 (and all banked copies) plus possibly NEON/VFP must be saved to a normal world store. Similarly, the registers must be reloaded for the secure world. Monitor mode sp provides a good anchor for accessing these world contexts. Monitor mode sp should be setup during secure boot, before the normal world initializes. This is much like a traditional OS context switch. The SCR#NS (bit 0) is set appropriately; you may do this before or after the register switching, depending on how you save the registers (Ie, by mode switch or by srs).

这篇关于ARM的TrustZone - 在安全和非安全的OS调度器的行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆