6.4 Shareability
Cacheability says whether a location may be held in a cache. Shareability says for which observers hardware must keep that location coherent. The same concept, the shareability domain, also parameterises barriers (DMB ISH), broadcast TLB maintenance (TLBI ...IS) and the reach of cache maintenance by VA. Getting it wrong rarely fails on a single cluster and often fails on a multi-chiplet system.
The three domains
A shareability domain is a set of observers. For a location in a given domain, the architecture guarantees that all observers in that domain see the location coherently, without software maintenance.
| Domain | Descriptor SH[1:0] | Typical membership |
|---|---|---|
| Non-shareable | 00 | The PE itself. Hardware is not required to keep the location coherent with any other observer |
| Inner Shareable | 11 | The PEs controlled by one OS or hypervisor. In practice, all application PEs in the system |
| Outer Shareable | 10 | The Inner Shareable domain plus other agents, for example IO-coherent masters such as a GPU, an accelerator, or a PCIe root complex behind an SMMU |
| (Full system) | n/a | All observers. Used as a barrier domain (SY), not as a memory attribute |
SH=01 is reserved. It gives CONSTRAINED UNPREDICTABLE behaviour.
The domains nest: Non-shareable ⊆ Inner ⊆ Outer ⊆ Full system. Which agents are in which domain is a property of the system design, not of the PE. DDI0487 sets the expectation that PEs under the same OS or hypervisor share an Inner Shareable domain. Platform specifications such as BSA build on that.
The SH field is in bits[9:8] of stage 1 block and page descriptors. There is one exception. With FEAT_LPA2 and TCR_ELx.DS=1, those bits hold output-address bits, and the shareability of block and page mappings comes from TCR_ELx.SH0 (TTBR0 half) or TCR_ELx.SH1 (TTBR1 half), the same fields that give the walk shareability (5.7). The shareability of the table walks themselves comes from TCR_ELx.SH0/SH1 (5.2). With stage 2, the stage 1 and stage 2 shareability combine, and the more shareable of the two wins (11.3).
Device and Normal Non-cacheable are always Outer Shareable
Data accesses to Device memory, and to Normal memory that is Inner Non-cacheable and Outer Non-cacheable, are treated as Outer Shareable, whatever the
SHfield says.
Why does this rule exist? With no cache involved, there is nothing to keep coherent: every access goes to the memory system, so every observer sees the same location. TF-A’s xlat library says so in a comment, and it sets OSH on Device descriptors anyway for tidiness.
Two consequences follow, and the second is the one that matters.
1. SH on such mappings is meaningless. Writing ISH or NSH on a Device or NC mapping is harmless and has no effect.
2. Barriers that must order MMIO, or NC DMA buffers, against an outside observer need an Outer Shareable or full-system domain. A barrier’s domain names the observers for which the ordering is guaranteed. Consider the classic doorbell:
// Descriptor in Normal memory (WB if the DMA master is IO-coherent, NC otherwise)
str w1, [x2, #DESC_LEN]
str x3, [x2, #DESC_ADDR]
dmb oshst // order the descriptor writes before the doorbell, for the device
str w4, [x5, #DOORBELL] // Device-nGnRE MMIO
The DMA engine is an observer outside the Inner Shareable domain. It is usually in the Outer Shareable domain, or merely in the full system. DMB ISHST guarantees ordering only as seen by observers in the Inner Shareable domain, so architecturally it is not enough here. DMB OSHST, DMB ST, or a DSB with the same or a larger domain is enough. This is why Linux defines dma_wmb() as dmb(oshst) and dma_rmb() as dmb(oshld), and why writel() places a dma_wmb() before the store.
A few precise caveats:
- Same peripheral, no barrier needed. Two accesses from one PE to the same Device-nR peripheral are kept in order by the nR attribute alone (6.2).
- Different peripherals, or a Device access against Normal memory, need barriers (7.9).
- The full rules for reading barrier domains against shareability are in 7.5.
- Many implementations treat
ISH,OSHandSYidentically. That is IMPLEMENTATION DEFINED. Code that usesISHfor MMIO ordering may pass on one core and fail on another core, or on another interconnect.
Where shareability is used besides coherence
- DMB/DSB domains. As described above, and in 7.5–7.6.
- Broadcast TLB maintenance.
TLBI ...ISaffects the TLBs of all PEs in the Inner Shareable domain.TLBI ...OS(FEAT_TLBIOS) affects the Outer Shareable domain. TheDSBthat follows must cover at least the same domain (9.1). - Data cache maintenance by VA.
DC CVAC/CIVAC/IVACact on the caches of all observers in the shareability domain of the location. For a Non-shareable mapping, the operation need only affect the caches of the issuing PE. If another core has a dirty copy of a line that you mapped NSH, your clean will not reach it (8.5). - Exclusives. For Non-shareable locations, the local monitor can satisfy a Store-Exclusive. For shareable locations, the global monitor or the coherence protocol is involved (10.1).
- Instruction cache invalidation to PoU.
IC IALLUISis broadcast to the Inner Shareable domain, andIC IALLUis local (8.6).
Non-shareable: a bug that hides
Mapping shared data as Non-shareable is a latent bug. It works on many cores because the hardware keeps all WB lines coherent anyway, but that behaviour is IMPLEMENTATION DEFINED. Common ways it happens:
- Copied tables. A per-CPU table template is copied, and someone later maps a shared region through it with
SH=00. - Defaults. An
SH=00default in a hand-written table generator. - Walk attributes. Translation table walks set NSH in
TCR_ELx.SH0while the tables are shared and updated by another PE.
The symptom on a stricter implementation is stale data or a lost update that appears only across clusters or chiplets. TF-A maps all its Normal memory Inner Shareable. Linux uses ISH for all Normal mappings (PTE_SHARED).
Shareability domains in a real SoC
| Structure | Typical place in the domains |
|---|---|
| PEs in a DynamIQ cluster (DSU, L3) | Inner Shareable, kept coherent by the DSU snoop control |
| Several clusters on a CMN mesh | Inner Shareable, kept coherent by snoop filters in the HN-F home nodes |
| Chiplets joined by CHI C2C (or a proprietary coherent link) | Normally one Inner Shareable domain spanning all chiplets, since one OS image runs on all PEs. Snoops and DVM messages cross the link (8.3, 17.5) |
| IO-coherent masters (ACE-Lite or CHI RN-I, CXL.cache devices) | Snoop the PE caches. Inside the Outer Shareable domain, or inside the Inner Shareable domain, depending on integration |
| Non-coherent masters (simple DMA engines, debug MEM-AP, many accelerators) | Outside every shareability domain for cacheable data. Reached only through maintenance to a point of coherency |
Shareability answers “who must see this location coherently?”. A point of coherency answers “where must the data reach for a given observer to see it?”. The two are separate:
- A non-coherent DMA master is outside every domain. What matters for it is the PoC, through
DC CVAC. - Instruction fetch on the same PE is inside the domain, yet it needs maintenance to the PoU.
8.4 develops this comparison.
Bring-up note: On a multi-chiplet SoC, the Inner Shareable domain exists only once the coherent link is up, and once each chiplet’s snoop filters and DVM targets include the other chiplets. Before then, a secondary chiplet’s PEs are effectively in a different domain.
TLBI ...IS,IC IALLUISandDCby VA issued on one chiplet will not reach the other. Firmware must not release secondaries into shared memory until the link reports that coherency is enabled (17.5).
Validation note: To validate shareability end to end, check that the core exports it.
- Snoopability. Each CHI request has a
SnpAttr(snoopable) bit derived from cacheability and shareability. Check it in a waveform for an ISH WB access, and check that it is 0 for Device accesses (CHI requires Device to be non-snoopable; for Normal NC the value is implementation-specific, so check the core’s TRM).- Coherence across chiplets. Run a cross-chiplet message-passing litmus test with the data mapped ISH WB.
- Broadcast maintenance across chiplets. Run a
DC CIVACtest in which chiplet A writes a line, chiplet B cleans it to PoC, and a non-coherent observer reads DRAM.A failure that disappears when the data is mapped NC points at snoop-filter or DVM routing configuration rather than at the PE.
Checkpoint
Q6.4.1 A descriptor maps a peripheral as Device-nGnRE with SH=00 (Non-shareable). What shareability do the accesses have, and why?
- A. Non-shareable, so only the issuing PE is guaranteed to observe the writes
- B. CONSTRAINED UNPREDICTABLE, because Device memory requires
SH=10 - C. Inner Shareable, the default for all Device memory
- D. Outer Shareable, because Device memory is always treated as Outer Shareable whatever
SHsays
Answer
D. Device data accesses, like Normal Inner-NC/Outer-NC accesses, are uncached, so hardware treats them as Outer Shareable and ignores SH. A is the tempting reading of the field. B confuses this with the reserved encoding SH=01, which is the only one that is CONSTRAINED UNPREDICTABLE.
Read more: Arm ARM (DDI0487), “Shareable Normal memory” and “Device memory”; stage 1 SH field
Q6.4.2 Firmware writes a DMA descriptor into Normal NC memory, executes DMB ISHST, then writes a Device-nGnRE doorbell. The (non-coherent) DMA engine occasionally reads a stale descriptor. Which change is architecturally sufficient?
- A. Change the doorbell mapping to Device-nGnRnE
- B. Use
DMB OSHST(orDMB ST), because the DMA engine is outside the Inner Shareable domain - C. Change the descriptor memory to
SH=11(Inner Shareable) - D. Add
ISBafter theDMB
Answer
B. Both accesses are Outer Shareable (NC and Device), and the observer that needs to see the order is outside the Inner Shareable domain. ISH guarantees ordering only for observers inside the Inner Shareable domain. C has no effect, because SH is ignored for Normal Inner-NC/Outer-NC memory. A removes early acknowledgement but does not order the descriptor writes before the doorbell, as seen by the device.
Read more: Arm ARM (DDI0487), DMB, “Shareability domains”; Linux arch/arm64/include/asm/barrier.h
Q6.4.3 A buffer shared between two PEs on different chiplets was mapped Non-shareable WB by mistake. PE B fills the first half, signals PE A, and PE A fills the second half and executes DC CVAC over the whole buffer (to PoC) and DSB SY. A non-coherent accelerator then reads stale data from DRAM. Why can this happen?
- A.
DC CVACcleans only to the PoU, not the PoC - B.
DSB SYdoes not wait for cache maintenance to complete - C. For a Non-shareable location, the clean is required to affect only PE A’s caches; the dirty lines PE B wrote need not be cleaned
- D. Non-shareable memory is never written back to DRAM
Answer
C. Data cache maintenance by VA acts within the shareability domain of the location. Non-shareable means “this PE only”, so B’s dirty line is outside the scope of A’s clean. A is false, because DC CVAC cleans to the PoC. B is false too: a DSB does wait for earlier maintenance to complete. The fix is to map the buffer ISH and keep a single writer per handover.
Read more: Arm ARM (DDI0487), “Data cache maintenance instructions”, “Effects of instructions that operate by VA to the Point of Coherency”