11.5 The SMMU (SMMUv3)
The SMMU is the I/O MMU of an Arm system. It applies stage 1 and/or stage 2 translation, permissions and attributes to transactions from DMA masters, using page tables in the same formats as the PE. It is specified separately in IHI0070 (SMMUv3.x), not in DDI0487, and it is a memory-mapped device programmed through registers, in-memory tables and queues, not through system registers. For an EL3/TEE reviewer, the SMMU is what makes “the device can only reach its buffers” true. For bring-up, it is where most “DMA works with the SMMU in bypass but not in translate” bugs live.
Identifying a transaction: StreamID and SubstreamID
Every transaction that enters the SMMU carries:
- a StreamID (SID), which identifies the master. For PCIe it is derived from the Requester ID (bus/device/function), for other masters from interconnect sideband signals. How SIDs are allocated is a system integration decision, described to software by the ACPI IORT ID mappings or the device tree
iommus/iommu-mapproperties. - optionally a SubstreamID (SSID), which identifies an address space within the master. It is the PCIe PASID, used for shared virtual addressing.
- a Security indication (
SEC_SID). Secure streams use a separate Secure programming interface (SMMU_S_*) and Secure stream table. With RME, Realm and granule-protection checks apply as well (12.4).
Stream table and context descriptors
SMMU_STRTAB_BASE and SMMU_STRTAB_BASE_CFG (FMT, LOG2SIZE, SPLIT) locate the stream table. It is either linear, an array of 64-byte Stream Table Entries indexed by SID, or two-level, with a level-1 array of descriptors pointing to level-2 STE arrays, so that sparse 16-bit or larger SID spaces do not need megabytes of STEs. SMMU_IDR0.ST_LEVEL and SMMU_IDR1.SIDSIZE say what is supported.
An STE says what happens to the stream:
| STE field | Purpose |
|---|---|
V | Valid. An invalid STE makes the stream’s transactions abort with a C_BAD_STE event |
Config | 0b000 abort, 0b100 bypass, 0b101 stage 1 only, 0b110 stage 2 only, 0b111 nested (stage 1 then stage 2) |
S1ContextPtr, S1Fmt, S1CDMax | Base of the context-descriptor table (an IPA if stage 2 is also enabled), its format, and the number of SSIDs |
S2VMID, S2TTB, S2T0SZ, S2SL0, S2TG, S2PS, S2AA64, S2R, S2S | Stage-2 configuration, mirroring VTCR_EL2/VTTBR_EL2, plus record and stall fault behaviour |
EATS | Whether ATS translation requests are allowed (see below) |
STRW | Which translation regime stage 1 belongs to (EL1, EL2, EL2-E2H), and hence which TLBI commands invalidate it |
SHCFG, MTCFG/MemAttr, ALLOCCFG, INSTCFG, PRIVCFG | Overrides for the incoming transaction’s shareability, memory type, allocation, instruction/data and privilege attributes |
A Context Descriptor (CD, 64 bytes) describes one stage-1 address space and is indexed by SSID. It holds TTB0/TTB1, T0SZ/T1SZ, TG0/TG1, IPS, EPD0/1, ASID, MAIR, the walk attributes, AA64, HA/HD, and the fault controls R (record) and S (stall). A CD can point at the same page tables as a CPU process, which is how shared virtual addressing works. CD tables are linear or two-level too, as S1Fmt selects.
SID ──► Stream table ──► STE ──Config=0b111──► CD table[SSID] ──► CD ──► stage-1 tables (IPA)
│ │
└──────────► S2TTB, S2VMID ──► stage-2 tables ◄───┘ (walks also translated)
Nested mode (0b111) is how a guest gets a virtual IOMMU. The guest owns the CD and stage-1 tables at IPAs, the hypervisor owns the STE and stage 2, and the CD-table fetches and stage-1 walks are themselves translated by stage 2, exactly as on the PE (11.3).
Queues, invalidation and faults
Software never writes the SMMU’s internal caches directly. It talks to the SMMU through circular queues in memory, each with PROD/CONS index registers:
- Command queue (
SMMU_CMDQ_BASE,SMMU_CMDQ_PROD/CONS). Configuration-cache invalidation (CMD_CFGI_STE,CMD_CFGI_CD,CMD_CFGI_ALL), TLB invalidation (CMD_TLBI_NH_VA,CMD_TLBI_NH_ASID,CMD_TLBI_S2_IPA,CMD_TLBI_S12_VMALL,CMD_TLBI_EL2_*,CMD_TLBI_NSNH_ALL),CMD_ATC_INV,CMD_PRI_RESP,CMD_RESUME, andCMD_SYNC. The SMMU may process commands in any order up to aCMD_SYNC. ACMD_SYNCcompletes only when all earlier commands have completed and their effects are visible. Completion is signalled by MSI write, by SEV, or by pollingCONS. “Wrote a CMD_TLBI” is therefore not “the TLB is clean”. “CMD_SYNC completed” is. - Event queue (
SMMU_EVENTQ_BASE). Faults and configuration errors:C_BAD_STREAMID(SID beyond the table),F_STE_FETCH,C_BAD_STE,F_STREAM_DISABLED,C_BAD_SUBSTREAMID,F_CD_FETCH,C_BAD_CD,F_WALK_EABT,F_TRANSLATION,F_ADDR_SIZE,F_ACCESS,F_PERMISSION,F_TLB_CONFLICT. Each record carries the SID, SSID, input address and, for stage 2, the IPA. - PRI queue, for PCIe Page Request Interface requests (below).
SMMU_GERRORwithSMMU_GERRORNreports global errors such as a command-queue error (SMMU_CMDQ_CONS.ERRgives the reason) or an abort on an event-queue or MSI write. Event-queue overflow is not a global error: it is flagged bySMMU_EVENTQ_PROD.OVFLG.
The update protocol is the I/O analogue of break-before-make (9.2). Write the STE, CD or page-table entry; make it visible to the SMMU’s table walker (a DSB if the SMMU is coherent, a clean to the PoC first if not); issue the CFGI or TLBI command; then CMD_SYNC and wait for it. An STE with live traffic must be changed so that the SMMU never sees a torn 64-byte entry. Linux’s driver writes the non-V words first, or goes through an abort STE.
Control is in SMMU_CR0 (SMMUEN, EVTQEN, CMDQEN, PRIQEN, ATSCHK, VMW), with each change acknowledged in SMMU_CR0ACK, which software must poll. SMMU_CR1 sets the cacheability and shareability of table walks and queue accesses. SMMU_CR2 has E2H, RECINVSID and PTM. While SMMUEN=0, all traffic either bypasses or aborts according to SMMU_GBPA.ABORT.
ATS and PRI
ATS (PCIe Address Translation Services) lets an endpoint cache translations in its own Address Translation Cache (ATC). The endpoint sends a translation request, which the SMMU answers if STE.EATS allows it, and then issues transactions marked translated. Those transactions carry PAs, and the SMMU passes them without a walk. With split-stage ATS (STE.EATS=0b10), they carry IPAs and still go through stage 2. Two consequences follow:
- Invalidation reaches into the device. After unmapping, software must issue
CMD_ATC_INVto send an ATS invalidation to the endpoint, thenCMD_SYNC, which waits for the endpoint’s completion. A buggy endpoint ATC turns into a use-after-unmap DMA. - Trust. A device that is allowed ATS can claim any address is “translated”.
SMMU_CR0.ATSCHK(where implemented) and stage-2-checked EATS modes reduce what a malicious endpoint can reach, but a device with ATS enabled is part of the trusted computing base. Confidential-computing device assignment adds TDISP/IDE for this reason.
PRI (Page Request Interface) lets an ATS-capable endpoint ask for a page that is not mapped, instead of faulting. Requests arrive on the PRI queue. Software maps the page and answers with CMD_PRI_RESP. Non-PCIe masters can get a similar effect with the stall model: a faulting transaction is held (CD.S/STE.S2S), reported in the event queue, and resumed or terminated with CMD_RESUME. The master must tolerate arbitrarily long stalls, which few do. SMMU_IDR0.STALL_MODEL says what the implementation supports.
Coherency attributes
The SMMU accesses memory in two roles, and each has its own attributes.
- Its own structures: the stream table, CDs, page tables and queues. If
SMMU_IDR0.COHACC=1and the system integrates the SMMU as an I/O-coherent agent, these accesses can be Inner Shareable Write-Back (SMMU_CR1,CD/STEwalk attributes), and software only needs aDSBbefore issuing commands. Otherwise software must clean every updated structure to the PoC (8.7). Firmware describes this with the IORTCOHACCoverride or the DTdma-coherentproperty. A description that claims coherency the interconnect does not provide gives stale STEs and page tables, and the failures are intermittent. - The translated DMA. Its output attributes combine the page-table attributes with the incoming transaction’s attributes. The STE
MTCFG/SHCFG/ALLOCCFGfields can override incoming attributes before combination. A master that issues non-coherent transactions can be made coherent this way, but only if the interconnect path behind the SMMU actually snoops.
Broadcast TLB maintenance (BTM). If SMMU_IDR0.BTM=1 and the SMMU is in the DVM domain, CPU TLBI ...IS instructions also invalidate matching SMMU TLB entries (by ASID/VMID), so shared CPU/SMMU page tables need no command-queue TLBI. SMMU_CR2.PTM=1 opts out. If the platform does not wire DVM to the SMMU, the driver must use commands even when BTM is advertised.
Bring-up mistakes that matter
| Symptom | Usual cause | First check |
|---|---|---|
| All DMA aborts at boot, before any driver loads | SMMU_GBPA.ABORT=1 from reset or firmware, SMMUEN=0 | SMMU_GBPA, and whether early boot relies on bypass |
C_BAD_STREAMID or C_BAD_STE for one device | IORT/DT SID mapping wrong, or SID beyond LOG2SIZE | Event record SID vs the table and the integration spec |
| Device works only after something else flushes caches | Non-coherent SMMU described as coherent, so structures not cleaned | SMMU_IDR0.COHACC, IORT/DT coherency, SMMU_CR1 attributes |
| Stale translations after unmap | Missing CMD_SYNC, or CMD_ATC_INV omitted with ATS | Command-queue sequence; ATS enabled? |
Commands stop, SMMU_GERROR.CMDQ_ERR | Malformed command, or command-queue memory not reachable or coherent | SMMU_CMDQ_CONS.ERR |
| PCIe MSIs never arrive once translated | ITS doorbell (GITS_TRANSLATER) not mapped in the device’s address space | IOVA mapping for the MSI page (4.4) |
| Firmware-era DMA continues into the OS | Firmware left Config=bypass STEs or SMMUEN=0 with GBPA bypass | Security review: what the handoff state allows |
A clean initialisation from firmware or the driver follows a fixed order. Program the queue and table bases with SMMUEN=0. Enable the queues (CMDQEN, EVTQEN) and poll CR0ACK. Issue CMD_CFGI_ALL, CMD_TLBI_NSNH_ALL and CMD_TLBI_EL2_ALL, then CMD_SYNC, because cached configuration at reset is not guaranteed empty. Only then set SMMUEN. The TCU/TBU split of implementations such as Arm’s MMU-600/700, with distributed TBUs next to masters and a central TCU that walks, is IMPLEMENTATION DEFINED. It matters for placement and for DVM connectivity, not for the programming model.
Security note: at the firmware-to-OS handoff, any stream left in bypass is a DMA path around everything the TEE assumed. TF-A and secure firmware should leave the Non-secure SMMU either disabled with
GBPA.ABORT=1or configured with only the streams that firmware itself needs, and they should configure the Secure SMMU interface for any Secure masters. Review the STEConfigof each stream, not onlySMMUEN.
Validation note: drive each StreamID with a directed DMA to an unmapped IOVA and check that the event queue records
F_TRANSLATIONwith the expected SID and input address. That single test validates SID routing, STE lookup and fault reporting. Use the SMMU’s PMCG (performance monitor counter groups) to confirm that TLB misses and walks occur where expected (16.5).
Checkpoint
Q11.5.1 A driver unmaps a DMA buffer by clearing the page-table entry, issues CMD_TLBI_NH_VA for the IOVA, and immediately frees the page. Occasionally the device writes to the freed page. The SMMU is coherent and ATS is not used. What is missing?
- A. A
DSB SYafter writing the command to the queue - B. A
CMD_SYNCafter the TLBI, waiting for its completion, before freeing the page, because commands complete asynchronously - C. A
CMD_CFGI_STE, because TLB entries are cached in the STE - D. Nothing; the SMMU completes each TLBI before consuming the next command
Answer
B. Writing PROD only queues the command. The SMMU may still hold the old translation, and in-flight transactions that used it may still be outstanding, until a later CMD_SYNC completes. The driver does need a barrier between writing the queue entry and updating PROD, but that does not wait for the SMMU. The STE is configuration, not a TLB, so C does not help. D is false: the specification allows commands before a CMD_SYNC to be processed and complete in any order.
Read more: SMMUv3 specification (IHI0070), “CMD_SYNC” and “Command queue”
Q11.5.2 A platform’s IORT marks the SMMU as coherent (COHACC), but the interconnect does not route its table walks through the coherent path. Which failure fits best?
- A. Every transaction aborts with
C_BAD_STREAMID - B.
SMMU_CR0ACKnever acknowledgesSMMUEN - C. DMA is permanently slow because walks miss in the CPU caches
- D. Intermittent use of stale STEs, CDs or PTEs. The driver skips cleaning to the PoC, so the SMMU reads old memory contents while new ones sit in CPU caches
Answer
D. When software believes the SMMU is coherent, it only issues a DSB after updating structures. A non-snooping walker reads DRAM and sees whatever was last written back. The result depends on cache eviction timing, so it is intermittent. A would need a wrong SID or table size. B concerns register handshakes, not memory coherency.
Read more: SMMUv3 specification (IHI0070), SMMU_IDR0.COHACC and SMMU_CR1; Arm DEN0049 (IORT), SMMUv3 node flags
Q11.5.3 A hypervisor gives a guest a virtual IOMMU using STE Config=0b111. The guest writes a CD whose TTB0 is an IPA. Who translates the address the SMMU uses to fetch the guest’s stage-1 descriptors?
- A. Nobody; the SMMU treats
TTB0as a PA in nested mode - B. The guest’s stage 1, recursively
- C. The STE’s stage 2, because in nested mode CD fetches and stage-1 walks are themselves IPAs translated by stage 2
- D. The CPU’s
VTTBR_EL2, through broadcast TLB maintenance
Answer
C. Nested translation in the SMMU follows the PE: the guest’s CD pointer, TTB0 and table descriptors are IPAs, and the SMMU translates them through the stage 2 named by S2TTB/S2VMID. A fault there is reported as a stage-2 fault on a stage-1 walk. The SMMU does not use the CPU’s system registers (D). BTM affects invalidation, not which tables are walked.
Read more: SMMUv3 specification (IHI0070), “Stage 1 and stage 2 translation” and STE.Config