12.4 RME and Arm CCA
FEAT_RME (permitted from v9.2) does two things to the TrustZone model of 12.1. It adds two Security states, Realm and Root, giving four. And it moves the “which world may touch this memory” decision from a static, system-level TZASC into a PE-side check against an in-memory table that EL3 owns and can change at run time: the Granule Protection Table (GPT). Arm CCA (Confidential Compute Architecture) is the system and software architecture built on top: the RMM at R-EL2, the RMI/RSI interfaces and attestation. The system-level requirements (which requesters must be checked, the PoPA, memory encryption) are in DEN0129.
Four PASes and who may access them
| Security state | ELs | SCR_EL3.{NSE,NS} | PASes it may access |
|---|---|---|---|
| Root | EL3 only | n/a | Root, Secure, Non-secure, Realm |
| Secure | S-EL0–S-EL2 | {0,0} | Secure, Non-secure |
| Non-secure | NS-EL0–NS-EL2 | {0,1} | Non-secure |
| Realm | R-EL0–R-EL2 | {1,1} | Realm, Non-secure |
At EL3, the stage 1 descriptor selects the output PAS with NS (bit 5) plus NSE (bit 11, which is not otherwise used at EL3). PA-based maintenance operands select it with bits [63:62] = {NS, NSE}: Secure {0,0}, Root {0,1}, Non-secure {1,0}, Realm {1,1}. Note that this ordering differs from SCR_EL3, where NSE is bit 62 and NS is bit 0. Getting the two encodings confused is a common source of “the CMO did nothing” bugs.
The table says which PAS a state may name. Whether the access then succeeds is decided by the Granule Protection Check (GPC): after translation, every access, including translation table walks, is checked against the GPT entry for its PA. Each entry holds a 4-bit GPI (Granule Protection Information):
| GPI | Meaning | Notes |
|---|---|---|
0b0000 | No access | Used as the intermediate state while a granule changes owner |
0b1000 | Secure only | |
0b1001 | Non-secure only | |
0b1010 | Root only | GPT itself and EL3 memory |
0b1011 | Realm only | |
0b1101 | NSO (Non-secure Only), a more restricted form of Non-secure access | FEAT_RME_GPC2, enabled by GPCCR_EL3.NSO, otherwise reserved. See the GPI encodings in DDI0487 for the exact access rule |
0b1111 | Any access | Typical for device MMIO that every world may reach |
0b0100–0b0111 | Further encodings (SA, NSP, NA6, NA7) | Later extensions (FEAT_RME_GDI), each enabled by its own GPCCR_EL3 bit, otherwise reserved |
An access passes only if its PAS matches the GPI, or the GPI is “any”.
GPCCR_EL3, GPTBR_EL3 and the walk
GPTBR_EL3.BADDR holds the level 0 table’s PA, from bit 12 upwards. GPCCR_EL3 configures the check:
| Field | Bits | Meaning |
|---|---|---|
PPS | [2:0] (plus PPS3 at [3] with GPC3) | Protected Physical Address Size: the PA range the GPT covers |
IRGN, ORGN, SH | [9:8], [11:10], [13:12] | Cacheability and shareability of GPT walks |
PGS | [15:14] | Physical granule size: 00 4 KB, 10 16 KB, 01 64 KB |
GPC | [16] | Enables granule protection checks |
GPCP | [17] | GPC fault priority for stage 2 table walks (may be RES0) |
L0GPTSZ | [23:20] | Read-only, IMPLEMENTATION DEFINED: PA bits covered by each level 0 entry, encoded 0 = 30 bits (1 GB) up to 9 = 39 bits (512 GB) |
NSO, SPAD/NSPAD/RLPAD, APPSAA | [19], [7]/[6]/[5], [24] | FEAT_RME_GPC2: NSO encoding enable, per-PAS “access disable”, and how Secure/Realm/Root accesses above PPS are treated |
GPCBW | [29] | FEAT_RME_GPC3: enables the GPC bypass windows defined in GPCBW_EL3 |
The walk has at most two levels, indexed by PA:
PA[PPS-1 : L0GPTSZ] -> level 0 entry (64-bit), at GPTBR_EL3 base
bits[3:0] = 0b0001 Block descriptor: GPI in [7:4] for the whole L0 region (e.g. 1 GB)
bits[3:0] = 0b0011 Table descriptor: L1 table address
otherwise invalid -> GPT walk fault
PA[L0GPTSZ-1 : granule_shift+4] -> level 1 entry (64-bit)
Granules descriptor: 16 x 4-bit GPIs, one per granule (64 KB of PA per entry at PGS=4 KB)
Contiguous descriptor: bits[3:0]=0b0001, GPI in [7:4], Contig in [9:8]
(2 MB / 32 MB / 512 MB), replicated in every entry of the block
The contiguous form lets the TLB cache one GPT result for a large block. Software must keep every replicated entry identical. Breaking a contiguous region back into granules needs a TLBI RPALOS over the old block, whereas merging needs no TLB maintenance (Arm’s example flows, document 109839). FEAT_RME_GPC3’s bypass windows (GPCBW_EL3: a base, a size from 1 GB to 64 GB, and an optional stride) let large regions skip the walk entirely and use a fixed default result instead. They are intended for huge flat regions where a walk per TLB miss is wasted.
GPT information may be cached in TLBs and combined with translation entries. That is why TLBI is part of every GPT change.
Granule protection faults
There are two classes:
- GPF: the walk succeeded but the GPI forbids the access. For accesses at EL0–EL2,
SCR_EL3.GPF=1takes them to EL3 as a Granule Protection Check exception, EC 0x1E. WithGPF=0, they are reported as an ordinary Instruction or Data Abort to the EL the abort would normally go to, with xFSC0b101000(GPF not on a translation table walk) or0b100011–0b100111(GPF on a translation table walk, levels −1 to 3). A GPF on a stage 2 walk is what a hypervisor sees when the guest’s tables sit in a granule that has been delegated away. A GPF on an EL3 access is a normal current-EL Data Abort with DFSC0b101000. TF-A’srme_gpf_safe_read()/rme_gpf_safe_write()rely on that to copy from lower-EL buffers without crashing. - GPT walk/configuration faults (invalid GPT descriptor, GPT address size fault): these mean EL3’s own table is broken, and they are reported to EL3 as EC 0x1E.
MFAR_EL3 reports the faulting PA and its PAS for GPC exceptions, because FAR_EL3 holds a VA. Linux treats a GPF on a walk as a kernel bug (oops) and a GPF outside a walk as SIGBUS, since user space may legitimately touch a page the host has just delegated.
Changing a granule’s PA space safely
This is the core RME memory-system sequence. The rules are the ones from Parts 7–9 applied to a new address bit. Arm’s Granule Transition Flow (109839) and TF-A’s gpt_delegate_pas()/gpt_undelegate_pas() implement these steps:
Delegate (NS -> Realm or Secure), executed at EL3 with caches on, under a GPT lock:
1. DC CIPAPA each line of the granule, operand = PA | target PAS // drop speculative fills tagged target-PAS
DSB OSH
2. write GPI = target in the L1 entry
DSB OSHST // GPT write visible to GPT walkers
3. TLBI RPALOS, PA (size = granule) // remove cached GPT info everywhere
DSB OSH
4. DC CIPAPA each line, operand = PA | NS // NS-tagged lines must not be written back later
DSB OSH
Undelegate (Realm or Secure -> NS), the owner has already scrubbed the granule:
1. GPI = No access ; DSB OSHST ; TLBI RPALOS ; DSB OSH // previous owner loses access first
2. DC CIPAPA (old PAS) ; DSB OSH // scrubbed data pushed past the PoPA
3. DC CIPAPA (NS) ; DSB OSH // drop stale speculative NS fills
4. GPI = NS ; DSB OSHST ; TLBI RPALOS ; DSB OSH
(TF-A first shatters a contiguous GPT block that covers the granule, with its
own TLBI RPALOS, and may fuse the block again afterwards.)
Why each piece is there:
- To the PoPA, not the PoC. The Point of Physical Aliasing is where the PAS stops being part of the address and all four PAS aliases of a PA reach the same storage. A line tagged with the old PAS that is still dirty anywhere before the PoPA could later be written back over the new owner’s data, or serve stale data.
DC CIPAPA(clean and invalidate by PA to PoPA, EL3 only) is the only CMO that reaches that point by PA and PAS. With FEAT_MTE2, useDC CIGDPAPAso that allocation tags are cleaned as well. TLBI RPAOS/RPALOS/PAALLOS. These invalidate cached GPT information by PA range (RPA*), by PA range for last-level entries only (RPAL*), or entirely (PAALLOS, used after enabling or rebuilding the GPT). They are Outer Shareable, so every PE and every SMMU that caches GPT results must be in the DVM domain that receives them.OSHbarriers. GPT consumers include other PEs and SMMUs, so Inner Shareable is not enough.- No access first on undelegate. Until the GPI says “no access”, the old owner can still write. Revoking access first guarantees that nothing written later becomes observable.
Validation note: the GTF is a good target for directed tests on FVP and on RTL. Delegate a granule while another core keeps writing to it through an NS mapping, and check that the writer takes a GPF after the TLBI completes and that no NS write lands after the transition (read the granule back through a Realm mapping). Then repeat with the step 4 CMO removed, using FVP with
cache_state_modelled=1: without it the bug is invisible (18.4). On silicon, a skippedTLBI RPALOStypically shows up as a GPF that “should not happen” on another core.MFAR_EL3and the ESR GPCSC field show whether it was a walk fault or a GPI mismatch.
SMMU granule protection checks
Every requester that is not a PE must be checked too, or a DMA master would bypass the GPT. With RME, an SMMUv3 implementation performs the GPC on device accesses (including its own table walks) using the same GPT. It is configured through its Root register page (SMMU_ROOT_*): the GPT base and configuration, which should mirror GPTBR_EL3/GPCCR_EL3, a GPC enable in SMMU_ROOT_CR0, and GPF fault address registers. Requesters that sit behind no SMMU need a completer-side PAS filter, which DEN0129 requires. EL3 firmware owns all of this: enabling the PE’s GPC while leaving the SMMU’s off is a hole, and so is an SMMU that does not receive the TLBI PA broadcasts. Details are in IHI0070’s RME chapter.
What changes for EL3 firmware
- EL3 is the Root world. Its code, data, stacks and the GPT itself must be GPI Root, and the GPT must be valid before
GPCCR_EL3.GPC=1. In TF-A, BL2 runs at EL3 when RME is enabled, builds the GPT early, and loads the RMM into Realm PAS. - There are three lower-world contexts to switch (Secure, Non-secure, Realm), each with full EL2 state, using
SCR_EL3.NSEon the ERET. - The RMMD in BL31 forwards RMI calls (SMC64, OEN 4, function numbers
0x150–0x18F) from the Normal-world host to the RMM. It also serves the RMM-EL3 interface:RMM_GTSI_DELEGATE/UNDELEGATE(the GTF above),RMM_ATTEST_GET_REALM_KEY,RMM_ATTEST_GET_PLAT_TOKEN, andRMM_BOOT_COMPLETE. - Any EL3 access to a lower-world buffer must be GPF-tolerant, because the buffer’s owner may have changed since the pointer was validated.
RMM, RMI and RSI in brief. The RMM (TF-RMM is the reference) runs at R-EL2 and is the only component that can map Realm memory into Realms. The host (KVM) asks it, through RMI, to delegate granules, create a Realm descriptor (RD), Realm Execution Contexts (RECs) and Realm Translation Tables (RTTs), populate measured data (RMI_DATA_CREATE) and run a REC (RMI_REC_ENTER). The host chooses which memory, and the RMM guarantees how that memory is used. A Realm calls the RMM through RSI (SMC from R-EL1, function numbers starting at 0x190) for attestation tokens, measurement extension and IPA-state changes (RSI_IPA_STATE_SET marks a range as RAM or as shared with the host).
Attestation in brief. A CCA attestation token has two parts. The platform token is signed by the platform’s root of trust (for example an RSE) and covers firmware measurements and the security lifecycle state. The Realm token is signed by the RMM’s Realm Attestation Key, which the platform token binds, and covers the Realm Initial Measurement (RIM), the Realm Extensible Measurements (REMs) and a challenge from the verifier.
Checkpoint
Q12.4.1 In a delegate sequence, firmware writes the GPI to Realm and issues TLBI RPALOS and DSB OSH, but skips the final DC CIPAPA with the Non-secure PAS. What can go wrong?
- A. A dirty NS-tagged line for that PA, left by the host before the delegate, can later be evicted and written back past the PoPA, overwriting data the Realm has since stored
- B. Nothing: the GPC blocks the NS writeback because the granule is now Realm
- C. The host takes a GPF on its next read, which is the intended outcome, so the CMO is only a performance optimisation
- D. The RMM’s later reads return zeros, because the line is still tagged NS
Answer
A. Caches before the PoPA hold the line as an NS location, which is a different location from the Realm alias. A writeback is the eviction of an access that already passed its GPC, so B is the tempting but wrong answer. Cleaning and invalidating the NS alias to the PoPA removes it before it can corrupt the Realm’s view.
Read more: Arm ARM (DDI0487), DC CIPAPA and the Point of Physical Aliasing; Arm RME and MEC example software flows (109839), Granule Transition Flow
Q12.4.2 EL3 copies a structure from a pointer the Normal world passed in an SMC. The page was delegated to Realm on another core after EL3 validated the pointer. What does EL3 observe, and how does TF-A deal with it?
- A. EC 0x1E with
SCR_EL3.GPFset, and BL31 panics - B. Stale NS data, because EL3 accesses bypass the GPC
- C. A Data Abort from the current EL with DFSC “Granule Protection Fault not on translation table walk”. TF-A’s GPF-tolerant copy helpers have a fixup table that resumes at a recovery PC and return a short count
- D. A GPT walk fault, because Root cannot address Realm PAS through an NS-attributed mapping
Answer
C. EL3 accesses are subject to the GPC, so B is wrong. A GPF on an EL3 access is reported as a normal current-EL abort (SCR_EL3.GPF concerns EL0–EL2 only), which is why A is wrong. TF-A’s rme_gpf_safe_read() checks for DFSC 0b101000 in its EL3 handler. The access is a GPF, not a walk fault (D): the walk succeeded, and the GPI simply does not allow NS.
Read more: Arm ARM (DDI0487), Granule protection checks and GPC exceptions; TF-A lib/gpt_rme, rme_helpers.S
Q12.4.3 A platform enables GPCCR_EL3.GPC on the PEs but leaves the SMMU’s Root GPC disabled, intending to “do it later in the kernel”. Which statement is correct?
- A. This is acceptable, because the SMMU’s stage 2 for the device already prevents access to Realm memory
- B. It is a hole: device DMA is then not checked against the GPT, so a Non-secure device (or the host programming its stage 2) can reach Realm and Root memory. Only Root firmware can enable the SMMU GPC, so it must be enabled before any lower world runs
- C. It is acceptable as long as the SMMU is in the DVM domain, because TLBI RPALOS also blocks its accesses
- D. The PE GPC catches DMA writes when the lines are next read by a PE, so integrity is preserved
Answer
B. The host controls the SMMU’s Non-secure stage 2, so that stage 2 is not a protection against the host (A). TLBI only invalidates cached GPT information. It does not enforce a check that is turned off (C). A PE-side check on a later read does not undo a write that has already reached memory (D).
Read more: Arm SMMUv3 (IHI0070), Realm Management Extension: granule protection checks; RME system architecture (DEN0129), requester checks