7 years, 7 months ago.

RTX, uvisor and interrupts

I'm having an issue with with interrupts using uVisor, every 2,3 interruptions occur, it generates a fault. Without uVisor, it works fine, is it a issue within uVisor? is there a way to solve partially the problem till the release of real solution, like disable irq before a switch context then enable them again?

This is my simple application :

main.cpp

#include "mbed.h"
#include "rtos.h"
#include "uvisor-lib/uvisor-lib.h"
#include "main.h"






extern "C" void SVC_Handler(void);
extern "C" void PendSV_Handler(void);
extern "C" void SysTick_Handler(void);
extern "C" uint32_t rt_suspend(void);
UVISOR_SET_PRIV_SYS_HOOKS(SVC_Handler, PendSV_Handler, SysTick_Handler, rt_suspend);

/* Main box Access Control Lists (ACLs). */

static const UvisorBoxAclItem g_main_box_acls[] = {
    {GCR,                                   sizeof(*GCR),     UVISOR_TACLDEF_PERIPH},
    {TMR0,                                   sizeof(*TMR0),     UVISOR_TACLDEF_PERIPH}, 
    {GPIO0,                                 sizeof(*GPIO0),   UVISOR_TACLDEF_PERIPH}, 
    {UART0,                                 sizeof(*UART0),   UVISOR_TACLDEF_PERIPH},
    {(void *)0x42100000,										0x1000,						UVISOR_TACLDEF_PERIPH},
};

/* Enable uVisor, using the ACLs we just created. */
UVISOR_SET_MODE_ACL(UVISOR_ENABLED, g_main_box_acls);



DigitalOut led2(LED2);
 

int main() {

    while(1){      
        led2 = !led2;
        Thread::wait(1000);
    }

}

box1.cpp

#include "mbed.h"
#include "rtos.h"
#include "uvisor-lib/uvisor-lib.h"
#include "main.h"
#include "box_drivers.h"





/* Private static memory for the secure box */
typedef struct {
  int thekey;
} Contextbox2;


static const UvisorBoxAclItem Thread_2_acls[] = {
  
};

static void Thread_2(const void *);
/* Secure box configuration */
UVISOR_BOX_NAMESPACE(NULL);                   /* We won't specify a box namespace for this example. */
UVISOR_BOX_HEAPSIZE(4096);                    /* Heap size for the secure box */
UVISOR_BOX_MAIN(Thread_2,    /* Main thread for the secure box */
                osPriorityNormal,             /* Priority of the secure box's main thread */
                1024);                        /* Stack size for the secure box's main thread */
UVISOR_BOX_CONFIG(box2,              /* Name of the secure box */
                  Thread_2_acls,       /* ACLs list for the secure box */
                  1024,                       /* Stack size for the secure box */
                  Contextbox2);  /* Private static memory for the secure box. */

Serial pc(SERIAL_TX, SERIAL_RX);
DigitalOut led1(LED1);

static void but_func(void)
{
   pc.printf("toto\r\n");
}

InterruptIn button(SW1);


/* Main thread for the secure box */
static void Thread_2(const void *)
{
  
button.mode(PullUp);
button.fall(&but_func);
  while (true) {
        led1 = !led1;
        Thread::wait(1000);
    }

}

after pushing the button a number of times, 2,3, 4.. a BusFault is generated, and it prints in the terminal :

"RTX error code: 0x00000001, task ID: 0x00000000"

And sometime it's a memfault :

948,729 @"***********************************************************\n"
948,762 @"                    MEMMANAGE FAULT\n"
948,795 @"***********************************************************\n"
948,808 @"\n"
948,841 @"* CFSR  : 0x00000001\n"
948,874 @"\r\n"
948,907 @"\r* MMFAR : 0xE000ED34\n"
948,940 @"\r\n"
948,973 @"\r* No MPU violation found\n"
949,006 @"\r\n"
949,039 @"\r* MEMORY MAP\n"
949,071 @"\r  Address:           0xE000ED34\n"
949,104 @"\r  Region/Peripheral: [not available]\n"
949,117 @"\r    Base address:    0xE000ED34\n"
949,150 @"\r    End address:     0xE000ED34\n"
949,163 @"\r    Before bitband:  [invalid]\n"
949,176 @"\r\n"
949,189 @"\r* EXCEPTION STACK FRAME\n"
949,202 @"  Exception from unprivileged code\n"
949,215 @"    psp:     0x2000A2D8\n"
949,228 @"\r    lr:      0xFFFFFFFD\n"
949,241 @"\r  Exception stack frame:\n"
949,254 @"    psp[07]: 0x00000000 | xPSR\n"
949,267 @"    psp[06]: 0x21000000 | pc\n"
949,280 @"    psp[05]: 0x21000000 | lr\n"
949,313 @"    psp[04]: 0x10001DCC | r12\n"
949,326 @"    psp[03]: 0x1000E81B | r3\n"
949,339 @"    psp[02]: 0x1000CB29 | r2\n"
949,372 @"    psp[01]: 0x2000AAD4 | r1\n"
949,385 @"    psp[00]: 0x00000400 | r0\n"
949,398 @"\n"
949,431 @"* MPU CONFIGURATION\n"
949,444 @"\r\n"
949,457 @"\r  Background region enabled\n"
949,470 @"\r  MPU bypassed @NMI, @HardFault\n"
949,483 @"\r  MPU enabled\n"
949,496 @"\r\n"
949,509 @"\r  Region Start      Size  XN AP  TEX S C B SRD      Valid\n"
949,522 @"\r  0      0x10000000 128KB 0  110 000 0 0 0 00000000 1\n"
949,535 @"\r  1      0x20000000 128KB 0  011 000 0 0 0 00000011 1\n"
949,568 @"\r  2      0x42100000 004KB 1  011 000 0 0 0 00000000 1\n"
949,581 @"\r  3      0x40000000 064B  1  011 000 0 0 0 00000000 1\n"
949,594 @"\r  4      0x40010000 032B  1  011 000 0 0 0 00000000 1\n"
949,627 @"\r  5      0x40008000 256B  1  011 000 0 0 0 00000000 1\n"
949,660 @"\r  6      0x40020000 064B  1  011 000 0 0 0 00000000 1\n"
949,673 @"\r  7      0x42100000 004KB 1  011 000 0 0 0 00000000 1\n"
949,686 @"\r\n"
949,719 @"\r***********************************************************\n"
949,732 @"\n"
949,745 @"HALT_ERROR(./core/system/src/mpu/vmpu_armv7m.c#157): Access to restricted resource denied\\

Created a bug for the uVisor team here: https://github.com/ARMmbed/uvisor/issues/327.

posted by Jan Jongboom 15 Sep 2016

1 Answer

7 years, 7 months ago.

This issue mentions that the Thread.wait calls in the box that own the interrupt might be at fault. Why that's the case, I wouldn't know, but track that issue for updates.

Thank You Jan for you interest and help, I'm the one who created that issue.

posted by abdou sen 16 Sep 2016

Ah, sorry, missed that. :-)

posted by Jan Jongboom 16 Sep 2016