| |||
| Home > Program Flow Trace Protocol > Tracing security state changes > Changing from Secure to Non-secure state | |||
The processor can change from Secure to Non-secure state for the following reasons:
An exception return. ARM recommends this as the normal way of returning to Non-secure state.
Execution of an MCR instruction to
write to bit [0] of the SCR, to change the security state.
Execution of an MSR instruction when
in Monitor mode, to change the security state.
When the state change is because of an exception return, the PTM generates a branch address packet that indicates the security state change. If you have enabled Context ID tracing the PTM generates a Context ID packet, if required, immediately after the branch address packet.
ARM recommends that you do not use the other mechanisms to change security state, and if one of these mechanisms causes the state change, the ARM architecture does not guarantee the exact point of the security state change. The state change might not take effect until the next time the processor executes an ISB or exception return instruction or takes an exception and therefore the PTM does not trace the state change immediately. This means that the security state change is not marked in the trace output when it occurs, but only at the next branch address packet generated by the PTM. After a security state update, the PTM always generates a branch address packet for a taken direct branch, and therefore the state change is reported at the first of:
the next taken branch, whether the branch is direct or indirect
the next exception.
In the unusual case that the next waypoint after the security state change is a not-taken branch, the PTM generates an N atom, and does not report the state change until the next taken branch or exception. If the next waypoint after the security state change is an exception that returns the processor to Secure state the PTM does not indicate the entry to Non-secure state in the trace output stream.