5.1 Translation regimes and stages
A translation regime is the complete set of controls that maps an address issued by a PE to a physical address: one or two stages, the registers that configure each stage, the TLB tagging (ASID, VMID) and the ELs whose accesses use it. You debug a translation problem by first naming the regime the faulting access used. Most “the MMU is broken” reports turn out to be “the access used a different regime from the one I programmed”.
Stages and address spaces
- Stage 1 maps a virtual address (VA) to an output address. If no stage 2 applies, the output is a physical address (PA). Otherwise it is an intermediate physical address (IPA).
- Stage 2 maps an IPA to a PA. It is owned by EL2 and exists only in the EL1&0 regime, and only while EL2 is enabled in the current Security state and
HCR_EL2.VMis 1. Stage 2 is covered in depth in 11.3.
Stage 1 can also be disabled (SCTLR_ELx.M == 0). The VA then maps flat to the output address, with the fixed memory attributes described in 6.5. A disabled stage still checks address size. A VA above the implemented PA size gives an Address size fault, not a wrap.
Every stage 1 table-walk access is itself an IPA when stage 2 is active, so the walker translates each descriptor address through stage 2. If a stage 2 fault hits on one of those accesses, ESR_EL2.ISS.S1PTW is 1 (decode in 5.8). In the worst case, 4 stage-1 levels nested in 4 stage-2 levels take (4+1)×(4+1)−1 = 24 memory accesses for one TLB miss.
The regimes
| Regime | Used by | Stages | VA ranges | Stage-1 registers | TLB tag |
|---|---|---|---|---|---|
| EL1&0 | EL1, and EL0 when not (E2H==1 && TGE==1) | 1, plus stage 2 if EL2 is enabled and HCR_EL2.VM==1 | Two: TTBR0_EL1 (low), TTBR1_EL1 (high) | SCTLR_EL1, TCR_EL1, TCR2_EL1, MAIR_EL1 | ASID (+ VMID when EL2 is enabled) |
| EL2 | EL2 with HCR_EL2.E2H==0 | 1 | One: TTBR0_EL2 | SCTLR_EL2, TCR_EL2, TCR2_EL2, MAIR_EL2 | None: entries are global |
| EL2&0 (FEAT_VHE, v8.1) | EL2 with E2H==1; EL0 with E2H==1 && TGE==1 | 1 | Two: TTBR0_EL2, TTBR1_EL2 | SCTLR_EL2, TCR_EL2 (VHE layout), TCR2_EL2, MAIR_EL2 | ASID |
| EL3 | EL3 | 1 | One: TTBR0_EL3 | SCTLR_EL3, TCR_EL3, MAIR_EL3 | None |
| Stage 2 of EL1&0 | (applies to EL1&0) | 2 | One IPA space | VTTBR_EL2, VTCR_EL2; Secure: VSTTBR_EL2, VSTCR_EL2 (FEAT_SEL2, v8.4) | VMID |
Each regime exists separately in each Security state where its ELs exist. The Arm ARM names them that way: “Secure EL1&0”, “Non-secure EL2&0”, “Realm EL1&0” and so on. With FEAT_RME, EL3 runs in Root state and its regime is the only Root regime. Realm EL1&0 uses VTTBR_EL2/VTCR_EL2 for its stage 2, like Non-secure (Realm EL2 itself has only stage 1). The physical address space an output address lands in (Secure, Non-secure, Root, Realm) is chosen by the regime’s Security state together with the descriptor NS/NSTable bits, and with RME also NSE. That mechanism is in 12.1 and 12.4.
The two-range regimes split the VA space. Addresses with the top bits all 0 use TTBR0, and addresses with the top bits all 1 use TTBR1. The size of each range is set by T0SZ/T1SZ (5.2). An address in the hole between the two ranges takes a Translation fault without any table walk (5.8 covers the level it reports). The single-range regimes (EL2 without VHE, EL3) have only the low range. Any VA whose top bits are not 0 faults, after any top-byte-ignore (13.3).
Which regime does an access use?
The regime is chosen by the EL the access is made for, not always the current EL. Use this decision procedure:
access at EL3 -> EL3 regime
access at EL2: HCR_EL2.E2H == 1 -> EL2&0 regime
HCR_EL2.E2H == 0 -> EL2 regime
access at EL1 -> EL1&0 regime (+ stage 2 if EL2 enabled and VM==1)
access at EL0: E2H == 1 && TGE == 1 -> EL2&0 regime
otherwise -> EL1&0 regime
Some details change which regime applies, or how it applies:
HCR_EL2.TGE == 1withE2H == 0. EL0 still uses EL1&0, but stage 1 behaves as ifSCTLR_EL1.Mwere 0 (for every purpose except reading it back). WithHCR_EL2.VM == 0as well, EL0 addresses map flat to PAs. This lets a non-VHE EL2 kernel run EL0 code, but only without a stage 1 of its own, which is why the configuration is rarely useful. (Non-VHE KVM does not use it: its host kernel runs at EL1 withTGE == 0.) VHE (E2H=1, TGE=1) exists so that host EL0 gets a real stage 1 in the EL2&0 regime. See 11.2.- Unprivileged loads and stores (
LDTR*/STTR*, and the unprivilegedCPY*/SET*forms of FEAT_MOPS) at EL1 use the EL1&0 regime with EL0 permissions. At EL2 withE2H==1 && TGE==1, they use the EL2&0 regime with EL0 permissions. At EL3, and at EL2 otherwise, they behave like ordinary accesses. Permission details are in 5.5. - Address translation instructions name their regime explicitly:
AT S1E1Rwalks EL1&0 stage 1,AT S12E1Rwalks both EL1&0 stages, andAT S1E3Rwalks EL3. EL3 firmware can therefore probe a lower regime without switching to it. See the lab in 5.9. - Instruction fetches and data accesses use the same regime. Separate permission bits apply (5.5), but there are no separate tables.
E2Hmay be fixed. On implementations that do not supportHCR_EL2.E2H == 0, E2H is RES1 and the EL2 (non-VHE) regime never exists. Discovery is throughID_AA64MMFR4_EL1.E2H0(FEAT_E2H0; for the version, see DDI0487 A2). Firmware that assumes it can run EL2 code withE2H=0breaks on such cores.- Non-PE masters (DMA engines, GPUs) do not use any PE translation regime. Their translation goes through the SMMU, which has its own stage 1/stage 2 configuration that mirrors these formats (11.5).
Bring-up note: A TF-A BL31 image runs in the EL3 regime with
TTBR0_EL3only. The BL33/UEFI it hands off to starts in EL2 (or EL1), withSCTLR_EL2.M == 0, so it has no translation at all. When BL31 later handles an SMC from the normal world, a pointer the caller passes in is a normal-world VA. EL3 cannot dereference it through its own regime. It must either be given a PA, or translate it withAT S12E1R/AT S1E2Rand then check the PA space (5.9).
Registers per regime: what is shared and what is not
MAIR_ELx, TCR_ELx, TCR2_ELx and SCTLR_ELx are per regime, not per VA range. Both halves of the EL1&0 regime share one MAIR_EL1 and one SCTLR_EL1. TCR_EL1 holds separate fields for the two halves (T0SZ/T1SZ, TG0/TG1, EPD0/EPD1 and so on). With VHE, TCR_EL2 changes layout to match TCR_EL1, and the _EL12/_EL02 aliases let EL2 reach the real EL1&0 registers while E2H==1 redirects plain _EL1 names to their EL2 counterparts (2.5).
TLB entries are tagged by regime. Changing HCR_EL2.TGE does not invalidate anything. Entries from one regime are not used for lookups in another, but they remain until invalidated. (E2H is in practice set once at boot and not toggled at run time; KVM flips TGE, never E2H. Firmware that does change E2H should invalidate the EL2 entries.) and TLBI operations also name their regime (TLBI VAE1, VAE2, VAE3; VAE2 targets EL2 or EL2&0 according to the current E2H). Invalidation is in 9.1.
Validation note: Regime selection is a good place to look for RTL bugs, because the selection depends on several dynamic inputs (current EL,
E2H,TGE,VM, Security state). A directed test programs disjoint tables for EL1&0 and EL2&0 so that the same VA maps to different PAs, then runs the same EL0 load with each combination of{E2H, TGE}and checks which PA was read. On the FVP, the Tarmac trace shows the physical address each load used. In QEMU,-d mmudoes not log VMSA walks (it logs only PMSA/MPU lookups), so check the value read, or usegva2gpain the monitor andATin the test. On silicon, the PMU eventsDTLB_WALK(0x0034) andL1D_TLB_REFILL(0x0005) confirm that a walk happened, and the value read identifies the regime used.
Checkpoint
Q5.1.1 A hypervisor runs with HCR_EL2.E2H == 1, HCR_EL2.TGE == 0. A guest EL0 application executes LDR x0, [x1]. Which translation applies?
- A. EL2&0 stage 1 only, because
E2His set - B. EL1&0 stage 1 only, because stage 2 is disabled while
E2H == 1 - C. EL1&0 stage 1, then stage 2 if
HCR_EL2.VM == 1 - D. EL2&0 stage 1, then stage 2
Answer
C. EL0 uses the EL2&0 regime only when both E2H and TGE are 1. With TGE == 0, this is a guest EL0, which uses EL1&0, with stage 2 controlled by HCR_EL2.VM. Option A is the tempting mistake: E2H alone changes the regime used by EL2 itself, not by EL0.
Read more: Arm ARM (DDI0487), “Translation regimes” in the AArch64 Virtual Memory System Architecture chapter; HCR_EL2.E2H, HCR_EL2.TGE
Q5.1.2 EL3 firmware receives an SMC whose argument is a Non-secure EL1 VA. Which approach is architecturally sound for EL3 to find the corresponding PA?
- A. Execute
AT S12E1Rwith the VA (with the lower EL’s translation registers still live),ISB, then readPAR_EL1 - B. Dereference the VA directly, because EL3 can always access lower-EL mappings
- C. Execute
AT S1E3Rwith the VA, because EL3 regime tables include all lower-EL mappings - D. Temporarily write
TTBR0_EL3with the value ofTTBR0_EL1and dereference the VA
Answer
A. AT S12E1R walks both stages of the EL1&0 regime using that regime’s current registers, and leaves the result in PAR_EL1 after a context synchronization event. From EL3, the Security state walked is the one selected by SCR_EL3.NS (and NSE with RME), so NS must be 1 to probe the Non-secure regime. Option D looks clever but is wrong: EL3 descriptors use the single-range format, TCR_EL3 differs from TCR_EL1, the VA may be in the TTBR1 range, and stage 2 would be skipped. Option C uses EL3’s own tables, which know nothing of the caller’s mappings.
Read more: Arm ARM (DDI0487), “Address translation instructions”; PAR_EL1
Q5.1.3 Software clears HCR_EL2.TGE while running at EL2 with E2H == 1, then immediately ERETs to a guest EL1 without any TLB invalidation. What do the TLB entries left over from host EL0 mean for the guest?
- A. The guest may hit them, because host EL0 and guest EL0 share ASIDs
- B. The change of
TGEinvalidates all EL2&0 entries automatically - C. It is CONSTRAINED UNPREDICTABLE which regime’s entries are used
- D. They are tagged as EL2&0 regime entries and cannot be used for EL1&0 lookups, although they stay in the TLB
Answer
D. TLB entries are associated with a translation regime (and with ASID/VMID within it), and a lookup for one regime never matches entries of another. Nothing is invalidated automatically (so B is wrong), but stale entries do no harm across regimes. Option A confuses ASID tagging inside one regime with tagging across regimes.
Read more: Arm ARM (DDI0487), “Translation Lookaside Buffers (TLBs)”, “TLB maintenance”