Cortex-a57 crash after enabling mmu

My code is running at EL2 in one of the cortex-a57 cores in an nvidia tx2. The code is crashing just during initialization after I enable MMU.

However, what I just found out is that this is only happening if I run a “tlbi alle2”. If I execute it before enabling the MMU, the cpu crashes when I enable the MMU by writing to SCTLR_EL2. If I execute it after enabling the MMU, it crashes when I execute the tlbi instruction but only when followed by a dsb. If I don’t invalidate the tlb at any point, the code seems to be running fine.

Any idea on what the problem might be?


PS: when I say “crash”, I guess an exception happens, but the processor actually seems to be stalling. I cant be sure what happens and why I lose control of the processor. I don’t have a debugger, so I can only figure out where the code stops, by printing using the uart at specific points.

I don’t know enough to actually help other than a reference on the instruction:

There is significant emphasis in the docs about how the instruction invalidates certain content to avoid secure/non-secure loopholes. I would suggest looking closely at what the instruction invalidates, along with references to what the MMU requires to work correctly. I would bet it is a simple case of needing to set some particular invalidated value before enabling the MMU, or else using an alternate secure world instruction to do the same setup (don’t really know, but that is the gist of how the instruction seems to work).

Hi josemartins90,
Could you try the below sequence to ensure completion and visibility of the invalidation.
dsb sy
tlbi alle2
dsb sy
If doesn’t work, then please share the test check if possible.