Funny PABT behaviour - why?

I came across a weird behaviour when trying out my program on Raspberry Pi 2b (Cortex-A7):

When I try my PABT-handler using BKPT, the handler is entered fine, but on return the program restarts.

The restarted program returns fine from the BKPT and continues as expected.

Any idea what could cause the restart once?

I have MMUs, caches and predictors off, so the memory should be strongly ordered?

And anyway, it's the same code.

void rpi2_pabt_handler() __attribute__ ((naked));

...

void rpi2_pabt_handler()
{
   asm volatile (

         "push {r0 - r12, lr}\n\t"
         "mov r5, lr\n\t"
         "bl rpi2_pabt_handler2\n\t"
         "pop {r0 - r12, lr}\n\t"
         "subs pc, lr, #0 @ to skip bkpt\n\t"
   );
}

#define DEBUG_PABT
void rpi2_pabt_handler2()
{
   uint32_t exc_addr;
   uint32_t exc_cpsr;

#ifdef DEBUG_PABT
   int i;
   char *pp;
   static char scratchpad[16];
#endif

   asm volatile
   (
         "mov %[var_reg], r5\n\t"
         :[var_reg] "=r" (exc_addr) ::
   );
   asm volatile
   (
         "mrs %[var_reg], spsr\n\t"
         :[var_reg] "=r" (exc_cpsr) ::
   );

#ifdef DEBUG_PABT
   pp = "\r\nPABT EXCEPTION\r\n";
   do {i = serial_raw_puts(pp); pp += i;} while (i);

   serial_raw_puts("exc_addr: ");
   util_word_to_hex(scratchpad, exc_addr);
   serial_raw_puts(scratchpad);
   serial_raw_puts("\r\nSPSR: ");
   util_word_to_hex(scratchpad, exc_cpsr);
   serial_raw_puts(scratchpad);
   serial_raw_puts("\r\n");
#endif

   // rpi2_trap_handler();
}

Parents
  • (Jive seems to be acting up - I couldn't put this in the first posting, not even by editing)

    The output is:

    Finally! Got into main()

    trying SVC

    SVC EXCEPTION

    exc_addr: 0000907c

    SPSR: 68000013

    returned from SVC

    trying BKPT

    PABT EXCEPTION

    exc_addr: 000090d0

    SPSR: 60000013

    Finally! Got into main()

    trying SVC

    SVC EXCEPTION

    exc_addr: 0000907c

    SPSR: 6800001b

    returned from SVC

    trying BKPT

    PABT EXCEPTION

    exc_addr: 000090d0

    SPSR: 6000001b

    returned from BKPT

    entering main loop

    kögvnzkljdb lärtsnb ltjn b  ljbv,mdfbn,mxnblmdfz b,mdzf b

    The last BS is just random key presses - the code does the SVC and BKPT calls and after them starts acting as a serial echo.

Reply
  • (Jive seems to be acting up - I couldn't put this in the first posting, not even by editing)

    The output is:

    Finally! Got into main()

    trying SVC

    SVC EXCEPTION

    exc_addr: 0000907c

    SPSR: 68000013

    returned from SVC

    trying BKPT

    PABT EXCEPTION

    exc_addr: 000090d0

    SPSR: 60000013

    Finally! Got into main()

    trying SVC

    SVC EXCEPTION

    exc_addr: 0000907c

    SPSR: 6800001b

    returned from SVC

    trying BKPT

    PABT EXCEPTION

    exc_addr: 000090d0

    SPSR: 6000001b

    returned from BKPT

    entering main loop

    kögvnzkljdb lärtsnb ltjn b  ljbv,mdfbn,mxnblmdfz b,mdzf b

    The last BS is just random key presses - the code does the SVC and BKPT calls and after them starts acting as a serial echo.

Children