1

I am new to ARM TrustZone, I am playing a little bit with it trying to learn how it works (so, all the security implications of this approach are not important to me at the moment). I have a Sabrelite board with a iMX6 Cortex-A9 processor, which boots in secure (Linux kernel). I have written a simple kernel module that should switch the processor mode, from SVC to Monitor mode, but the result is a segmentation fault.

What is wrong with this approach?

Here is the code:

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;
}

and the assembly monitor procedure:

#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 this module results in:

TZ - init trust zone - before monitor call
Bad mode in data abort handler detected
Internal error: Oops - bad mode: 0 [#1] PREEMPT SMP ARM
Cristiano
  • 856
  • 10
  • 24

0 Answers0