17.3 The EL3 feature-enable checklist
Almost every architecture extension since v8.4 that adds system registers or instructions reachable from below EL3 arrives disabled or trapped, with the controlling bit in an EL3 register. The reasons are compatibility and security. Firmware written before the feature existed leaves the new bit at a value that keeps the feature off, so new state cannot leak between worlds through firmware that does not know to context-switch it. The cost is that every new core needs an EL3 audit: each feature the OS will use needs its enable bit set, and each enabled feature needs its state saved and restored wherever two worlds share the PE. This section is that audit, as a method plus a table. The general trap map is in 2.6, the version timeline in Appendix A, and fine-grained traps in 11.1.
How the gating works
Four EL3 mechanisms cover nearly all features:
SCR_EL3enable bits. Since v8.6 the convention is an...Enbit where 0 means “accesses from EL2 and below to this feature’s registers trap to EL3” and 1 means “no trap from this control”. Examples areHXEn,FGTEn,ECVEn,TCR2En,SCTLR2En,PIEn,GCSEn,D128En,MECEnandEnFPM. Older bits are less regular:ATA(allocation-tag access, 1 = allowed),API/APK(PAuth, 1 = don’t trap), andTRNDR(1 = trapRNDR/RNDRRSto EL3).CPTR_EL3bits:EZandESMare enables, andTFP,TTA,TAMandTCPACare traps (17.2).MDCR_EL3fields for debug, PMU, SPE, TRBE and BRBE. These are mostly ownership fields that assign a resource to a Security state, rather than plain enables.- EL2 registers that EL3 must initialise when EL2 is implemented but the world starts at EL1, or when EL3 owns EL2’s initial state:
HCRX_EL2, theHFG*TR_EL2fine-grained trap registers,TCR2_EL2and others. IfSCR_EL3.HXEn=1but nobody writesHCRX_EL2, its UNKNOWN fields (for exampleEnALS,EnASR,MSCEn,SMPME) apply to EL1&0. Conversely, withHXEn=0the pseudocode treatsHCRX_EL2as disabled (IsHCRXEL2Enabled()returns FALSE), so every EL1 feature whose EL2-level enable lives inHCRX_EL2is off as well: the two-level gating means EL1 needs both the EL3 bit and the EL2 bit.
When an enable is 0, the trap is usually reported to EL3 as EC 0x18 (trapped MSR, MRS or System instruction), with the ISS giving Op0, Op1, CRn, CRm, Op2 and Rt of the access. There are exceptions. SVE traps with EC 0x19, SME with EC 0x1D, FP/SIMD with EC 0x07, and some new instructions in the HINT space execute as NOP instead of trapping (2.3). The EC tells you which class of control to look at (Appendix D).
The ID-check-then-enable pattern in TF-A
TF-A treats each feature with the same three-part pattern.
1. Build flag. ENABLE_FEAT_<X> takes one of three values:
| Value | Meaning (FEAT_STATE_*) | Use |
|---|---|---|
| 0 | DISABLED: no code for the feature is built; the enable bit stays 0 | Feature absent, or deliberately not supported |
| 1 | ALWAYS: code built and the bit set unconditionally | Fixed silicon known to implement it |
| 2 | CHECKED: code built; enabled only if the ID register field says the feature is present | Platforms that must run on several core types (FVP, reference designs) |
2. Runtime predicate. is_feat_<x>_supported() folds the build flag and the ID check together: it is constant false for 0, constant true for 1, and reads the relevant ID_AA64*_EL1 field for 2 (1.1). Every enable site is guarded by it.
3. Enable and context. In the context-management library (lib/el3_runtime/aarch64/context_mgmt.c and lib/extensions/*), the guarded code does two things:
/* Pattern from TF-A's per-world SCR_EL3 composition (simplified) */
if (is_feat_tcr2_supported()) {
scr_el3 |= SCR_TCR2EN_BIT; /* EL2 and below may access TCR2_ELx */
}
if (is_feat_sxpie_supported() || is_feat_sxpoe_supported()) {
scr_el3 |= SCR_PIEN_BIT; /* one bit gates PIR_ELx, PIRE0_EL1 and POR_ELx */
}
/* ...and, separately, TCR2_EL1/TCR2_EL2 join the EL1/EL2 context save/restore */
The enable goes into a per-world SCR_EL3 (or MDCR_EL3/CPTR_EL3) value, and the feature’s registers join the save/restore lists that run on a world switch. TF-A has three context granularities, and each feature belongs in a specific one:
- Per CPU, per world (
cpu_context_t): GPRs,SCR_EL3,MDCR_EL3, the EL1 system registers (and the EL2 registers whenCTX_INCLUDE_EL2_REGSis set because an SPMC runs at S-EL2), PAuth keys, and optionally FP registers. - Per world, shared by all CPUs (
per_world_context_t):CPTR_EL3andMPAM3_EL3(plus the emulated ID-register values when FEAT_IDTE3 support is built). A world either may or may not use SVE/SME/AMU. - EL3 only, per CPU (
cm_manage_extensions_el3()): settings for EL3 itself, such asZCR_EL3,SMCR_EL3and AMU counter enables.
FEATURE_DETECTION=1 is a debug build option that compares each ENABLE_FEAT_* setting with the ID registers at boot and reports any mismatch. TF-A’s documentation says it is intended for flexible platforms such as models and for hardware at bring-up time. Use it once per new core and per new FVP configuration, before trusting a =1 build.
Security note: “enable it for the Normal world” is never one bit. If a feature’s registers are enabled for the Normal world but not context-switched, the Secure or Realm world runs with the Normal world’s values (for example its
TCR2_EL1,POR_EL1orGCSPR_EL1), and can leak its own values back. Some combinations are architecturally security-sensitive. WithSCR_EL3.ATA=1, MTE tag access works in the world, and if tag storage is not protected per world, a Normal-worldSTGto Secure memory is a confidentiality and integrity problem (13.6). Audit enable and context together.
What breaks when a bit is missed
The symptom depends on who owns the trap and which TF-A version is running:
| Missed item | Symptom |
|---|---|
| Enable bit 0, feature visible in the ID registers | The kernel probes ID_AA64MMFR3_EL1 (for example) and finds TCR2 implemented, then writes TCR2_EL1. The access traps to EL3 with EC 0x18. Older TF-A panics in EL3 (report_unhandled_exception, then a console dump). In recent TF-A releases (the change landed in 2023), an unhandled EC 0x18 trap from an AArch64 lower EL is answered by injecting an UNDEF into that EL (inject_undef64), so Linux reports Internal error: Oops - Undefined instruction (EC 0x00 at EL1) at the first use, often in early cpufeature code or the first context switch |
| Enable bit set, ID register hidden | With TID3 (FEAT_IDTE3) or a hypervisor hiding the feature, the OS won’t use it. Harmless, but sometimes surprising |
| Enable bit set, registers not context-switched | No crash. State crosses worlds: the Secure world inherits Normal-world TCR2_EL1/PIR_EL1, PAuth keys or MTE GCR_EL1, and the Normal world finds its values changed after an SMC. Symptoms appear only after the first SMC that runs Secure EL1 code, and only intermittently |
| EL2 register not initialised (EL2 present, OS at EL1) | Random behaviour of EL1&0 that depends on UNKNOWN HCRX_EL2, HFGRTR_EL2… fields: unexpected traps to an EL2 that has no handler, or features that silently don’t work |
Feature enabled in one world, CPTR_EL3 per world wrong | The Secure world’s first FP or SVE instruction traps to EL3 (EC 0x07 or 0x19) |
MDCR_EL3 ownership missed | Linux perf sees SPE/TRBE/BRBE in the ID registers, then gets UNDEF or “no device”, or profiles Secure execution if ownership is too permissive |
Bring-up note: when the kernel dies with an UNDEF on a system-register instruction that should exist on the core, decode the instruction (
mrs/msrencoding, 2.5), look up which EL3 control gates that register in its XML “Accessibility” pseudocode, and check the bit in the Normal-worldSCR_EL3,CPTR_EL3orMDCR_EL3value (halt inel3_exitand read the context, or add a debug print of the composed values). With an older BL31, the same bug appears as an EL3 panic whoseESR_EL3has EC 0x18 and whose ISS names the register.
The checklist table
Bit positions are from the TF-A arch.h definitions and the register XML. “EL1/EL2 ctx” means the feature’s registers must be saved and restored as part of that world’s EL1 or EL2 system-register context.
| Feature | EL3 control | Lower-EL state it unlocks | Context requirement |
|---|---|---|---|
| FEAT_HCX (v8.7) | SCR_EL3.HXEn (38) | HCRX_EL2 | EL2 ctx; write HCRX_EL2=0 when EL2 is unused |
| FEAT_FGT (v8.6) | SCR_EL3.FGTEn (27) | HFGRTR_EL2, HFGWTR_EL2, HFGITR_EL2, HDFGRTR_EL2, HDFGWTR_EL2, HAFGRTR_EL2 | EL2 ctx; safe init when EL2 is unused |
| FEAT_FGT2 (v8.9) | SCR_EL3.FGTEn2 (59) | HFGRTR2_EL2 and the other *2 registers | EL2 ctx |
| FEAT_ECV (v8.6) | SCR_EL3.ECVEn (28) | CNTPOFF_EL2 | EL2 ctx |
| FEAT_TCR2 (v8.9) | SCR_EL3.TCR2En (43) | TCR2_EL1, TCR2_EL2 | EL1 and EL2 ctx |
| FEAT_SCTLR2 (v8.9) | SCR_EL3.SCTLR2En (44) | SCTLR2_EL1, SCTLR2_EL2 | EL1 and EL2 ctx; EL3 writes its own SCTLR2_EL3 |
| FEAT_S1PIE, FEAT_S1POE (v8.9) | SCR_EL3.PIEn (45) | PIR_ELx, PIRE0_ELx, POR_ELx | EL1 and EL2 ctx |
| FEAT_GCS (v9.4) | SCR_EL3.GCSEn (39) | GCSCR_ELx, GCSPR_ELx, GCSCRE0_EL1, GCSPR_EL0 | EL1 and EL2 ctx (13.2) |
| FEAT_THE (v8.9) | SCR_EL3.RCWMASKEn (42) | RCWMASK_EL1, RCWSMASK_EL1 | EL1 ctx |
| FEAT_D128, FEAT_SYSREG128 (v9.4) | SCR_EL3.D128En (47) | MRRS/MSRR to 128-bit TTBRn_ELx, PAR_EL1, VTTBR_EL2 | Context must save all 128 bits |
| FEAT_MTE2 (v8.5) | SCR_EL3.ATA (26) | Allocation-tag access; GCR_EL1, RGSR_EL1, TFSR_EL1, TFSRE0_EL1 | Per world, EL1 ctx; tag storage protected per world |
| FEAT_PAuth (v8.3) | SCR_EL3.API (17), APK (16) | PAC/AUT instructions; AP*Key*_EL1 | EL1 ctx (keys) per world (13.1) |
| FEAT_MEC (v9.2) | SCR_EL3.MECEn (49) | MECID_*_EL2, VMECID_*_EL2 | EL2 ctx, Realm world (12.5) |
| FEAT_FPMR (with FP8) | SCR_EL3.EnFPM (50) | FPMR | Per world, with the FP state |
| FEAT_LS64_ACCDATA (v8.7) | SCR_EL3.ADEn (37), EnAS0 (36) | ACCDATA_EL1, ST64BV0 | EL1 ctx |
| FEAT_AMUv1p1 (v8.6) | SCR_EL3.AMVOFFEN (35) | AMEVCNTVOFF0n_EL2, AMEVCNTVOFF1n_EL2 | EL2 ctx (16.4) |
| FEAT_RNG_TRAP (v8.5) | SCR_EL3.TRNDR (40), 1 = trap | EL3 emulates RNDR/RNDRRS | EL3 service only |
| FP/Advanced SIMD | CPTR_EL3.TFP (10), 1 = trap | V0–V31, FPCR, FPSR | Per world (CTX_INCLUDE_FPREGS) or handled by the SPMC/SPD |
| FEAT_SVE (v8.2, mandatory in v9.0) | CPTR_EL3.EZ (8), 1 = enable; ZCR_EL3.LEN | ZCR_ELx, Z/P/FFR | Per-world CPTR_EL3; Z/P state only if the Secure world uses SVE (15.3) |
| FEAT_SME (v9.2) | CPTR_EL3.ESM (12), 1 = enable; SCR_EL3.EnTP2 (41); SMCR_EL3 | SMCR_ELx, SVCR, ZA, TPIDR2_EL0 | Per-world CPTR_EL3; streaming state must not survive into another world |
| FEAT_AMUv1 (v8.4) | CPTR_EL3.TAM (30), 1 = trap | AM*_EL0 counters | Save/restore across power-down; per-world TAM |
| Trace (ETE/ETM system registers) | CPTR_EL3.TTA (20), 1 = trap | TRC* registers | Trace unit state across power-down |
| FEAT_TRF (v8.4) | MDCR_EL3.TTRF (19), 1 = trap | TRFCR_EL1, TRFCR_EL2 | EL1 and EL2 ctx; prohibit Secure trace (16.6) |
| FEAT_SPE (v8.2) | MDCR_EL3.NSPB (13:12), NSPBE (11) with RME | PMB*_EL1, PMS*_EL1 | Ownership per world in MDCR_EL3; drain the buffer before a world switch |
| FEAT_TRBE (v9.0) | MDCR_EL3.NSTB (25:24), NSTBE (26) with RME | TRB*_EL1 | Ownership per world in MDCR_EL3 |
| FEAT_BRBE (v9.2) | MDCR_EL3.SBRBE (33:32) | BRB*_EL1, BRBCR_EL2 | Ownership and Secure prohibition in MDCR_EL3 |
| FEAT_PMUv3 | MDCR_EL3.TPM (6), 1 = trap; SPME (17); SCCD (23); MCCD (34); MPMX (35) | PM* registers | MDCR_EL2 per world; Secure counting prohibited by default (16.3) |
| Debug | MDCR_EL3.TDA (9), TDOSA (10), SDD (16) | DBG*, OS lock | SDD=1 keeps Secure self-hosted debug off |
Version numbers in the first column are the earliest version in which the feature is permitted (Appendix A gives the “mandatory from” column). They do not tell you whether your core implements it. Only the ID registers do.
Validation note: for each new core or model configuration, a directed test at Normal-world EL2 should touch one register from every feature that the ID registers advertise, and expect no exception (18.5). Run it once with a Secure-world round trip between “write a pattern” and “read it back”, which checks context switching: any register that comes back changed is missing from the world switch. TFTF has tests of this shape for many features. On FVP, vary the feature parameters (SVE, SME, MTE and so on, in the
cluster0.*parameter namespace; exact names differ between FVP releases, so list them with--list-params) and run withENABLE_FEAT_*=2, which checks theCHECKEDpath on cores both with and without each feature.
Checkpoint
Q17.3.1 A new SoC’s Linux kernel runs at EL2 with VHE. Early boot dies with Oops - Undefined instruction at an msr to TCR2_EL2 (S3_4_C2_C0_3). ID_AA64MMFR3_EL1.TCRX reads 1, and BL31 is a recent TF-A. What is the most likely cause?
- A.
SCR_EL3.TCR2Enis 0 in the Normal-world context (for example becauseENABLE_FEAT_TCR2=0), so the access trapped to EL3 with EC 0x18, and BL31 converted the unhandled trap into an UNDEF injected into the kernel - B. The core does not implement
TCR2_EL1, so the instruction is UNDEFINED in hardware - C.
HCRX_EL2.TCR2Enis 0, which traps the access to EL2 - D. The kernel forgot an
ISBafter writingTCR_EL1
Answer
A. The ID register says the feature exists, so B contradicts the evidence. A recent BL31 injects an UNDEF for an EC 0x18 trap it does not handle, which explains why the kernel sees an UNDEF rather than a hang. C is wrong because HCRX_EL2.TCR2En controls EL1 accesses to TCR2_EL1. It cannot trap an access made at EL2, and the only control above EL2 is SCR_EL3.TCR2En. A missing ISB (D) cannot turn an access into an UNDEF.
Read more: Arm ARM (DDI0487), TCR2_EL1 accessibility pseudocode, SCR_EL3.TCR2En; TF-A build options, ENABLE_FEAT_TCR2
Q17.3.2 On a core with FEAT_HCX, BL31 sets SCR_EL3.HXEn=1 in the Normal-world context. EL2 is implemented, but the kernel is entered at EL1, and BL31 never writes HCRX_EL2. What is the risk?
- A. None:
HCRX_EL2only affects software running at EL2 - B. Every EL1 access to
HCRX_EL2-controlled features traps to EL3, becauseHXEn=1means “trap” - C. None, because the kernel reprograms
HCRX_EL2during its own EL1 setup - D.
HCRX_EL2resets to UNKNOWN values, and withHXEn=1they take effect for EL1&0. Fields such asEnALS,EnASR,MSCEnorTCR2Enthen enable or trap features at random, so behaviour differs between cores and resets
Answer
D. HCRX_EL2 controls EL1&0 whenever EL2 is enabled in the Security state, whether or not software runs at EL2. Setting HXEn=1 makes its contents effective, so EL3 must write it (TF-A writes HCRX_EL2_INIT_VAL, 0, when it is not saving an EL2 context). A is the same misconception as with CNTVOFF_EL2 in 12.2. HXEn=1 means “do not trap” (B). A kernel at EL1 cannot write an EL2 register (C).
Read more: Arm ARM (DDI0487), HCRX_EL2 reset values, SCR_EL3.HXEn; TF-A lib/el3_runtime/aarch64/context_mgmt.c (EL2 initialisation when EL2 is unused)
Q17.3.3 Which TF-A ENABLE_FEAT_* setting is the right default for a firmware image that must run on an FVP whose feature parameters change between test runs, and why?
- A. 1, because FVP implements every feature
- B. 2 (
FEAT_STATE_CHECKED): code is built in, and each enable is guarded by an ID-register check at run time, so the same binary is correct whether or not the model implements the feature - C. 0, because FVP traps every optional feature to EL3 anyway
- D. 1 with
FEATURE_DETECTION=1, which automatically downgrades absent features to 0
Answer
B. =1 sets enable bits and touches registers unconditionally, which on a model without the feature means writing a non-existent register (an UNDEF at EL3) or setting a bit whose effect is undefined there. FEATURE_DETECTION (D) reports mismatches at boot. It does not fix them. FVP implements only the features its parameters enable (A), and nothing makes it trap everything (C).
Read more: TF-A documentation, Build options (ENABLE_FEAT_*, FEATURE_DETECTION); Arm ARM (DDI0487), ID_AA64MMFR3_EL1