This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

SMC not going into EL3

Hello experts,

In my project I need to write some bare metal code in order to boot my software (A VxWorks image), and would like to make the absolute minimum configurations before loading the VxWorks image, which then does the major part of the configurations.

I'm running on a Cortex A53, specifically on an LS1043ARDB board.

After POR I'm in S.EL3 of course, in which I configure all the SCTLR VBAR and SCR registers (I also initilze the RAM controller of course). I leave cache disabled as the VxWorks image will afterwards take care of cache settings.

After jumping to the VxWorks code, it will come up just fine, do the settings and bring itself to NS.EL1, then at some point it makes an smc #0 call in order to use some secure world functionality. Now instead of being vectored to EL3 offset 0x400 ("sync from lower level with current level sp") as expected, it stays in NS.EL1. and is vectored to offset 0 in the vector table which is the "sync with sp0" entry.

If I use U-Boot for boot loading my image all is fine and dandy, so appearantly U-Boot is doing something I don't.

Can anyone please help and let me know if I'm missing any configuration? Is there anything that needs to be configured in order for the CPU to be able to take an exception from NS.EL1 to EL3 via an smc call?

Thanks in advance.

Parents
  • This is also my bet. I use the below to switch the system from EL3 to EL2when having no Secure Monitor in place.

    Note "mov     \xreg1, #0x5b1; msr     scr_el3, \xreg1" - this amonf the others writes 1 to SMD.

    .macro armv8_switch_to_el2_m, xreg1
            /* 64bit EL2 | HCE | SMD | RES1 (Bits[5:4]) | Non-secure EL0/EL1 */
            mov     \xreg1, #0x5b1
            msr     scr_el3, \xreg1
            msr     cptr_el3, xzr           /* Disable coprocessor traps to EL3 */
            mov     \xreg1, #0x33ff
            msr     cptr_el2, \xreg1        /* Disable coprocessor traps to EL2 */

            /* Initialize Generic Timers */
            msr     cntvoff_el2, xzr

            /* Initialize SCTLR_EL2
             *
             * setting RES1 bits (29,28,23,22,18,16,11,5,4) to 1
             * and RES0 bits (31,30,27,26,24,21,20,17,15-13,10-6) +
             * EE,WXN,I,SA,C,A,M to 0
             */
            mov     \xreg1, #0x0830
            movk    \xreg1, #0x30C5, lsl #16
            msr     sctlr_el2, \xreg1

            /* Return to the EL2_SP2 mode from EL3 */
            mov     \xreg1, sp
            msr     sp_el2, \xreg1          /* Migrate SP */
            mrs     \xreg1, vbar_el3
            msr     vbar_el2, \xreg1        /* Migrate VBAR */
            mov     \xreg1, #0x3c9
            msr     spsr_el3, \xreg1        /* EL2_SP2 | D | A | I | F */
            msr     elr_el3, lr
            eret
    .endm

Reply
  • This is also my bet. I use the below to switch the system from EL3 to EL2when having no Secure Monitor in place.

    Note "mov     \xreg1, #0x5b1; msr     scr_el3, \xreg1" - this amonf the others writes 1 to SMD.

    .macro armv8_switch_to_el2_m, xreg1
            /* 64bit EL2 | HCE | SMD | RES1 (Bits[5:4]) | Non-secure EL0/EL1 */
            mov     \xreg1, #0x5b1
            msr     scr_el3, \xreg1
            msr     cptr_el3, xzr           /* Disable coprocessor traps to EL3 */
            mov     \xreg1, #0x33ff
            msr     cptr_el2, \xreg1        /* Disable coprocessor traps to EL2 */

            /* Initialize Generic Timers */
            msr     cntvoff_el2, xzr

            /* Initialize SCTLR_EL2
             *
             * setting RES1 bits (29,28,23,22,18,16,11,5,4) to 1
             * and RES0 bits (31,30,27,26,24,21,20,17,15-13,10-6) +
             * EE,WXN,I,SA,C,A,M to 0
             */
            mov     \xreg1, #0x0830
            movk    \xreg1, #0x30C5, lsl #16
            msr     sctlr_el2, \xreg1

            /* Return to the EL2_SP2 mode from EL3 */
            mov     \xreg1, sp
            msr     sp_el2, \xreg1          /* Migrate SP */
            mrs     \xreg1, vbar_el3
            msr     vbar_el2, \xreg1        /* Migrate VBAR */
            mov     \xreg1, #0x3c9
            msr     spsr_el3, \xreg1        /* EL2_SP2 | D | A | I | F */
            msr     elr_el3, lr
            eret
    .endm

Children