Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

9.2 Break-before-make and FEAT_BBM

9.1 showed how to remove a stale TLB entry after a descriptor changes. Removal on its own is not enough when the old and new descriptors are both valid and differ in certain ways. Between the store and the end of the TLBI, a PE can hold the old entry and also walk the new descriptor, and so hold two different valid translations for the same VA. The architecture does not define which one is used, or whether both are. Break-before-make (BBM) closes that window: there is always an invalid state between the old valid entry and the new one.

What can go wrong without it

If more than one TLB entry matches an access, DDI0487 permits these outcomes (it classes them as CONSTRAINED UNPREDICTABLE):

  • A TLB conflict abort. This is a synchronous Data or Instruction Abort with fault status 0b110000. It is the best outcome because you can see it.
  • Use of either translation, possibly a different one for each access. A store may go to the old PA and the following load come from the new PA.
  • An amalgam of the two entries, for example the OA of one with the attributes of the other. Mismatched memory types or cacheability on one PA is then the mismatched-attribute case of 6.6, with possible loss of coherency.

Hardware AF/DBM updates make this worse. A PE writing the dirty state back into the old descriptor can overwrite the new one (5.6).

Which changes need BBM

The Arm ARM requires break-before-make when a valid descriptor is replaced by another valid descriptor and any of these change:

ChangeWhy
Output addressTwo PAs for one VA
Memory type, cacheability or shareabilityMismatched attributes for one PA, or two
Block size: block ↔ table, a different level, or the Contiguous bit set or cleared on live entriesOverlapping entries of different sizes, the classic source of TLB conflict aborts
Non-global → global (nG 1→0), which can create a global entry that overlaps non-global entries in some TLBLinux’s pgattr_change_is_safe() treats nG 0→1 as safe and refuses nG 1→0 on a live entry

The following can be changed live with only the 9.1 update sequence: access permissions (AP, UXN/PXN), AF set by software, DBM/dirty state, and software-defined bits. The architecture guarantees that the old and new entries are then equivalent apart from permissions, so whichever entry a PE uses, the result is still one of the two. Linux encodes this list in pgattr_change_is_safe(). TF-A’s xlat_change_mem_attributes() changes only permissions and execute-never, on page-granular regions, for the same reason.

The sequence

    // Replace live descriptor at [x1] (covering VA range [x3, x4)) with x2
    str     xzr, [x1]          // break: write an invalid descriptor
    dsb     ishst
    // invalidate every VA the old entry covered (see below)
    tlbi    vae1is, x0         // repeat for the range, or use TLBI RVAE1IS
    dsb     ish                // no PE can still hold or use the old entry
    str     x2, [x1]           // make
    dsb     ishst
    isb                        // see 9.1 for when FEAT_ETS2 lets you drop it

Points that matter:

  • Use a non-leaf TLBI (VAE1, not VALE1) when the entry being broken is a table descriptor. Walk-cache entries that point to the old next-level table must also go.
  • Cover the whole range of a block. By-VA invalidation of one address in a block removes the block entry, but cores may cache a block entry as smaller (“splintered”) TLB entries. Invalidating every page-sized step, a range TLBI, or a whole-ASID or VMID flush is the conservative choice. Linux flushes the full PMD or PUD range when it splits a huge page for this reason.
  • Use an atomic swap for the break if hardware updates dirty state (SWP or LDXR/STXR writing zero). The old value returned is the final AF and dirty state, which otherwise is lost.
  • Plan for the window. Any PE that touches the VA between break and make takes a Translation fault. A kernel’s fault handler retries. Firmware usually has no such handler, so the rule is: do not break a mapping that another PE (or this PE’s own instruction fetch, stack or exception vectors) may be using. If you must, park the other PEs, or switch to a separate set of tables via a trampoline (Linux’s __cpu_replace_ttbr1 runs from the idmap for exactly this reason).

Splitting and merging blocks

Split (block → table), level 0 BBM. First build the next-level table so that it reproduces the block’s OA and attributes exactly, and publish it with DSB ISHST. Then break the block descriptor, invalidate the block’s whole range, DSB ISH, write the table descriptor, DSB ISHST, ISB. After the split you can change individual pages with the 9.1 sequence. Linux needs this for rodata=full and for memory hot-remove, and the requirement is why it historically mapped the linear map at page granularity.

Merge (table → block). Break the table descriptor. Invalidate every VA in the range with a non-leaf TLBI (or a full ASID or VMID flush) so that both the leaf entries and any walk-cache entry pointing at the old table are removed. DSB ISH, then write the block descriptor, DSB ISHST, ISB. Free the old table page only after that DSB. The Contiguous bit follows the same rules. Setting or clearing it on 16 live entries (for the 4K granule) is a block-size change, so break all 16, invalidate, and rewrite them.

Security note: Freeing a translation table page before the TLBI that removes walk-cache references to it has completed is a use-after-free in hardware. A walker can still fetch “descriptors” from the reused page, whose contents may be attacker-controlled, and the result is an arbitrary mapping. This is why Linux defers page-table freeing (tlb_remove_table) and why a hypervisor’s stage 2 teardown must complete TLBI IPAS2E1IS/VMALLS12E1IS before reusing table pages.

FEAT_BBM levels

FEAT_BBM (v8.4) relaxes the rules for block-size changes only. Changes to OA, memory type and shareability always need BBM. The level is in ID_AA64MMFR2_EL1.BBM, bits [55:52]:

BBMMeaning
0 (level 0)Full break-before-make is required for every block-size change
1 (level 1)Adds the nT bit (bit 16 of block descriptors). Software uses an nT=1 block during a size change so that the change can be made without a fully invalid window. TLB conflict aborts remain possible. The required sequence is in DDI0487 under the support levels for changing block size
2 (level 2)A block-size change, with the OA, attributes and permissions unchanged, can be made directly (block ↔ table) without breaking coherency, ordering or uniprocessor semantics. nT is ignored. TLB conflict aborts may still be generated
3 (level 3, recent issues)As level 2, but the implementation does not generate TLB conflict aborts for such changes. Check the current DDI0487 issue for the exact definition

With level 2 or higher, the split above becomes: write the table descriptor (equivalent mapping) straight over the block, DSB ISHST, invalidate the block range, DSB ISH, ISB. You still need the TLBI. Level 2 only promises that the overlap between old and new entries is harmless, not that the old entry goes away by itself.

Handling a TLB conflict abort at level 1 or 2. The abort is routed to EL2 when stage 2 is enabled and the conflict comes from a block-size or Contiguous-bit change. Otherwise it goes to the EL that owns the stage 1 regime. The fix is a local invalidation, which removes the duplicate entries without a broadcast, followed by a retry:

conflict_abort:                 // ESR_EL1.DFSC == 0b110000
    tlbi    vmalle1             // or a local TLBI by the faulting VA
    dsb     nsh
    isb
    eret                        // retry the access

Linux took a stricter line. It relaxes BBM for kernel mappings only on CPUs known never to raise conflict aborts. At first this was “BBML2_NOABORT”, an MIDR allow-list, because some cores did not advertise their level correctly in the ID register. In 2026 patches it is being reframed as detection of BBM level 3 or higher from ID_AA64MMFR2_EL1.BBM, with an allow-list kept for cores that implement the behaviour but do not advertise it.

Bring-up note: In early firmware, the usual BBM bug is an mmap_add_dynamic_region()-style remap, or a “change this 2 MB block to Device” helper, run while a secondary core is already executing from, or accessing, the same block. It usually shows up as a sporadic Translation fault on the secondary core (the break window), or, on cores that detect the overlap, a fault-status 0b110000 abort. If you see a TLB conflict abort on a core whose BBM field reads 0, a block-size change was done without BBM.

Checkpoint

Q9.2.1 Firmware must change a live 4 KB page from Normal Write-Back to Device-nGnRE (same PA) while other cores may access it. Which approach is architecturally correct?

  • A. Overwrite the descriptor with the new AttrIndx, then DSB ISHST; TLBI VAE3IS; DSB ISH; ISB, because the PA is unchanged
  • B. Break the mapping, invalidate and complete, write the new descriptor, and ensure no other core accesses the page during the window (plus the cache maintenance that the memory-type change needs)
  • C. Overwrite it directly if ID_AA64MMFR2_EL1.BBM reads 2
  • D. Set nT=1 in the new descriptor and overwrite it directly
Answer

B. A memory-type change always needs break-before-make. FEAT_BBM levels relax only block-size changes, so C and D do not apply. Option A is the tempting one: the PA is the same, but two live entries with different memory types for one PA are a mismatched-attribute alias. Dirty lines from the Write-Back mapping must also be cleaned and invalidated to the PoC before Device accesses rely on memory (see 6.6).

Read more: Arm ARM (DDI0487), Using break-before-make when updating translation table entries

Q9.2.2 A kernel merges 512 page mappings into one 2 MB block. It breaks the table descriptor, issues TLBI VALE1IS for each page, DSB ISH, writes the block descriptor, and frees the old level 3 table. What is wrong?

  • A. Nothing. Every page was invalidated before the block was written
  • B. It should have used TLBI VAAE1IS, because block entries are always global
  • C. The block descriptor must be written before the table is broken, so that the range is never unmapped
  • D. VALE1IS invalidates only leaf entries, so a walk-cache entry that points to the freed table may survive and be used for a later walk
Answer

D. The broken entry was a table descriptor, and walk caches may hold that pointer. Last-level invalidation does not remove it, so a walker can later read the freed page as a level 3 table. Use VAE1IS (or a range or ASID flush), and free the page only after the DSB. Option C describes “make before break”, which is exactly what creates conflicting entries.

Read more: Arm ARM (DDI0487), TLB maintenance instructions, leaf-only (*L*) forms and translation table walk caching

Q9.2.3 On a core with ID_AA64MMFR2_EL1.BBM = 2, a guest kernel splits a block into a table without an invalid step, and occasionally takes a fault with status 0b110000. What does this indicate?

  • A. Expected level 2 behaviour. Conflict aborts remain permitted, and the handler should do a local TLBI and retry (if stage 2 is enabled, the abort may be routed to EL2)
  • B. A hardware bug, because level 2 forbids TLB conflict aborts
  • C. The table descriptor had different attributes from the block. Level 2 rejects these with a conflict abort, and it does not report conflicts for equivalent mappings
  • D. The guest forgot the nT bit, which level 2 requires on the new table descriptor
Answer

A. Level 2 guarantees that the overlap does not break coherency, ordering or uniprocessor semantics, but it still permits conflict aborts. That is why Linux additionally requires “no-abort” behaviour (BBM level 3, or an allow-list) before relaxing BBM. nT is ignored at level 2. Changing attributes during a split is not covered by level 2 at all, so its outcome is not a defined “rejection”.

Read more: Arm ARM (DDI0487), Support levels for changing block size; ID_AA64MMFR2_EL1.BBM