I am implementing a small OS as a university project in a A9 chip (a Xilinx Zynq). I am using trustzone to implement some features and I want to pass through SVC calls from user mode directly to monitor, so I issue an SMC in my SVC handler. Here it is a version of the vector table plus handler which works (I removed other handler code for simplicity):
secure_vectors:ldr pc, _secure_resetb _secure_undefb _secure_svcb _secure_prefAbortb _secure_dataAbortb . /* reserved for HYP mode - not supported */b _secure_irqb . /* reserved for MON mode */
_secure_undef:b ._secure_svc:smc #0movs pc, lr_secure_prefAbort:b ._secure_dataAbort:b ._secure_irq:b
However, I am having an issue if I position my handler code immediately after the vector table. If I position the handler as below, sometimes the SMC call is not issued. When debugging I step through the instruction, but it is as if it never happened since the monitor vector table does not receive the SMC exception:
_secure_svc:smc #0movs pc, lr_secure_undef:b ._secure_prefAbort:b ._secure_dataAbort:b ._secure_irq:b
Even a "NOP" instruction before the handler solves the problem:
nop_secure_svc:smc #0movs pc, lr_secure_undef:b ._secure_prefAbort:b ._secure_dataAbort:b ._secure_irq:b
I really don't understand why this happens. Am I missing missing something obvious?
You wrote:
josecm said:Even a "NOP" instruction before the handler solves the problem:
so I understood, with "nop" the sequence works w/o it doesn't.Anyway, I am out of ideas. If you happen to find the problem, please post it.