我是 ARM TrustZone 的新手,我正在尝试了解它的工作原理(因此,目前这种方法的所有安全隐患对我来说并不重要)。我有一个带有 iMX6 Cortex-A9 处理器的 Sabrelite 板,它可以安全启动(Linux 内核)。我编写了一个简单的内核模块,应该将处理器模式从 SVC 切换到 Monitor 模式,但结果是分段错误。
这种方法有什么问题?
这是代码:
static int __init hello_trustzone_init(void)
{
int res = 0;
printk(KERN_INFO "TZ - init trust zone - before monitor call\n");
res = monitor();
printk(KERN_INFO "TZ - init trust zone - after monitor call - %X\n", res);
return 0;
}
和装配监控程序:
#define cpsr_mode_mon (0x16)
.global monitor
ENTRY(monitor)
push {r4-r8, lr}
.arch_extension sec
CPS #cpsr_mode_mon // Move to monitor mode
MRS R0, CPSR // Copy CPSR into R0
pop {r4-r8, pc}
ENDPROC(monitor)
insmod 这个模块导致:
TZ - init trust zone - before monitor call
Bad mode in data abort handler detected
Internal error: Oops - bad mode: 0 [#1] PREEMPT SMP ARM