This appendix is a lookup page. Each recipe gives the minimal sequence, which point (PoU, PoC, PoP, PoPA) and which domain (ISH, OSH, SY) it uses and why, and the section that derives it. The recipes assume AArch64, Normal Inner Shareable Write-Back memory for data shared between PEs, and Device-nGnRE for MMIO, unless they say otherwise. They do not replace the derivations: if your case differs from the stated assumptions, go back to the linked section.
Four independent questions decide every recipe. Mixing them up causes most barrier bugs (7.8 separates the memory axes, ordering and completion, from context synchronization).
Question
Tool
Choice
In what order must other observers see my accesses?
DMB, LDAR/STLR, dependencies
The access type (LD, ST or full) is what matters (7.5)
Must an access or maintenance operation have finished before something that is not a memory access (a system-register write, SEV, WFI, a TLBI taking effect, a non-coherent master reading DRAM)?
DSB
The scope must cover every PE or master that the TLBI or IC broadcast must reach: ISH for PEs, OSH when TLBI ...OS or a master outside the Inner Shareable domain is involved, SY when in doubt (7.6)
Must later instructions run with a new context (system registers, translation, fetched code)?
Where must data reach for a given observer to see it?
DC / IC by VA (or by PA at EL3)
PoU for this PE’s or the Inner Shareable domain’s instruction fetch; PoC for any master that does not snoop; PoP/PoDP for persistence; PoPA for a change of physical address space (8.4)
The domain on a DMB: this book follows the position, described in 7.5, that the DMB shareability argument has no functional effect in an other-multi-copy-atomic model. The recipes below still write DMB OSH* for anything involving Device memory or a DMA master and DMB ISH* between PEs. That spelling is correct under both the classical reading and the current one, and it matches what TF-A and Linux emit. Where the choice really matters is on a DSB that completes a TLBI or IC operation, and on whether a cache maintenance operation reaches the right point.
Mailbox between agents that are not mutually coherent
Map the buffer Normal Non-cacheable on both sides (identical attributes); payload stores; DSB SY; doorbell store. Receiver: doorbell interrupt, or poll then DMB OSHLD; payload loads
DSB SY makes the payload complete regardless of whether the far agent is in this PE’s Outer Shareable domain
Only between instructions in the CMODX set (B, BL, NOP, BRK, SVC, HVC, SMC, ISB), with one aligned 32-bit store; then 3.5 before relying on the new instruction
Change of a granule’s physical address space (RME, at EL3)
DC CIPAPA per line; DSB OSH; GPT write; DSB OSHST; TLBI RPALOS; DSB OSH; DC CIPAPA (NS alias); DSB OSH. The full delegate and undelegate orders are in 12.4
PoPA; OSH because PEs and SMMUs cache GPT information
TLBI ALLE3; MSR MAIR_EL3, TCR_EL3, TTBR0_EL3 (any order); DSB ISH; ISB; set SCTLR_EL3.{M,C} (I usually earlier); ISB. The enabling code, stack and vectors must be identity-mapped
Tables or data written with the MMU or D-cache off, read later with caches on
DC IVAC the region to the PoC before writing it (no stale dirty line can be evicted over it) and again after (drop lines allocated in between). Not a clean
Clear SCTLR_EL3.C; ISB; set/way clean+invalidate L1 (DC CISW, levels from CLIDR_EL1); last core: also L2; clear CPUECTLR_EL1.SMPEN; ISB; DSB SY; program power controller; WFI
Bring-up note: Set/way operations (DC ISW, CSW, CISW) appear in this appendix only in 6.4. They are local and not atomic with respect to allocation, so they are never a way to make an address visible to anyone (8.5).
Linux is a reference mapping here. The lowering is from arch/arm64/include/asm/barrier.h, io.h, tlbflush.h and cacheflush.h in recent kernels. Check your tree, because these definitions have changed over time (for example dma_mb() is a relatively recent addition).
Linux API
arm64 lowering
Meaning
Bare-metal / TF-A equivalent
mb()
DSB SY
Full completion barrier, including for MMIO and DMA
dsb sy (dsb() / dsbsy())
rmb()
DSB LD
Earlier loads complete
dsb ld
wmb()
DSB ST
Earlier stores complete
dsb st
dma_mb()
DMB OSH
Full ordering for coherent DMA memory
dmb osh
dma_rmb()
DMB OSHLD
Order reads of a coherent DMA buffer (status, then data)
dmb oshld
dma_wmb()
DMB OSHST
Order writes to a coherent DMA buffer (data, then ownership flag)
dmb oshst (dmboshst())
smp_mb()
DMB ISH
Full ordering between CPUs
dmb ish (dmbish())
smp_rmb()
DMB ISHLD
Load→load and load→store between CPUs
dmb ishld
smp_wmb()
DMB ISHST
Store→store between CPUs
dmb ishst
smp_load_acquire()
LDAR
Acquire (RCsc)
ldar
smp_store_release()
STLR
Release
stlr
smp_cond_load_acquire()
Loop: smp_load_acquire() (LDAR) re-read; while the condition fails, __cmpwait (SEVL; WFE; LDXR; compare; WFE)
Wait for a value with acquire
1.6 above
readl()
LDR; DMB OSHLD; dummy control dependency (EOR; CBNZ) on the loaded value
MMIO read ordered before later loads, and before a following udelay()
mmio_read_32() + dmb oshld
writel()
DMB OSHST; STR
Earlier memory writes (DMA buffers) ordered before the MMIO write
dmb oshst + mmio_write_32()
readl_relaxed() / writel_relaxed()
LDR / STR only
Device-nR order to the same peripheral, nothing else
TF-A mmio_read_32() / mmio_write_32()
ioremap() / ioremap_np()
Device-nGnRE / Device-nGnRnE
Mapping type for MMIO / non-posted MMIO
TF-A MT_DEVICE (nGnRE)
io_stop_wc()
DGH (FEAT_DGH; a NOP where not implemented)
Stop write-combining of earlier Normal-NC stores with later ones
Counter read ordered after earlier and before later instructions
4.4 and 4.6 above
flush_icache_range()
DC CVAU loop (skipped if IDC); DSB ISH; IC IVAU loop (skipped if DIC); DSB ISH; ISB; then an IPI to all CPUs (kick_all_cpus_sync())
3.2 + 3.5
3.2 above
dcache_clean_poc()
DC CVAC loop; DSB SY
Clean to the PoC
TF-A clean_dcache_range()
dcache_inval_poc()
DC CIVAC on partial edge lines, DC IVAC on whole lines; DSB SY
Invalidate to the PoC
TF-A inv_dcache_range() (no edge handling: align your buffers)
dcache_clean_inval_poc()
DC CIVAC loop; DSB SY
Clean and invalidate to the PoC
TF-A flush_dcache_range()
arch_sync_dma_for_device()
dcache_clean_poc()
Before a non-coherent master reads or writes
2.2, first half of 2.3
arch_sync_dma_for_cpu()
dcache_inval_poc() for DMA_FROM_DEVICE and DMA_BIDIRECTIONAL
After a non-coherent master wrote
second half of 2.3
flush_tlb_all()
DSB ISHST; TLBI VMALLE1IS; DSB ISH; ISB
All EL1&0 entries, all CPUs
5.2
local_flush_tlb_all()
DSB NSHST; TLBI VMALLE1; DSB NSH; ISB
This CPU only
5.8
flush_tlb_mm()
DSB ISHST; TLBI ASIDE1IS; DSB ISH
One ASID, all CPUs
5.2
flush_tlb_page()
DSB ISHST; TLBI VALE1IS; DSB ISH
One leaf entry, all CPUs
5.2
Three notes on the table:
mb(), rmb() and wmb() are DSBs, not DMBs, because Linux defines them to order against DMA and MMIO in every case, including non-coherent ones. In firmware, the DMB forms are usually what you want, with an explicit DSB where a recipe above asks for completion.
The Linux smp_* barriers carry no DSB, so they never complete cache or TLB maintenance. The TLB flush helpers carry their own DSBs.
C11 stdatomic.h lowers everything to the ISH forms (7.7). It is not the right tool for DMA, MMIO or non-coherent agents.