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

Part 14: Speculation and side channels

Prerequisites: 6.1 A hardware mental model (non-architectural), 6.2 Normal and Device memory, 7.4 Dependencies, 7.8 Context synchronization and ISB, 3.1 Exception types and the vector table, 9.1 TLBs and TLB maintenance, 1.3 Implementations and errata. If you already know: the Spectre and Meltdown variants and the Linux or TF-A mitigations for them, skim 14.1, 14.3 and 14.6. Read 14.2 (speculation as a bring-up hazard), 14.4 (the BHB ladder and TF-A’s vector wiring) and 14.7 (SPECRES on a world switch) anyway, and do the 14.8 exercises. Why this matters for bring-up/validation: speculative and prefetch accesses are real transactions that cause SErrors and hangs no instruction explains, and every EL3 vector and SMC handler you ship must carry the right per-core mitigation, which you can only verify by reading ID registers, MIDR and errata notices together.

The architecture says very little about speculation. It permits speculative reads and cache allocation for Normal memory, it forbids speculative data accesses to Device memory and speculative writes that other observers can see, and since 2018 it adds a small set of feature-advertised restrictions (CSV2, CSV3, SSBS, ECBHB) and speculation barriers (CSDB, SB, SSBB/PSSBB, CLRBHB, the SPECRES instructions). Everything else is microarchitecture. 14.1 draws that line precisely and maps each predictor structure to the variant that abuses it. 14.2 turns to what speculation does to the memory system: the cache side channel, but also stray speculative fetches and prefetches into PA holes, untrained DRAM and Secure carve-outs, the speculative-AT errata behind TF-A’s and KVM’s unusual SCTLR_EL1/TCR_EL1 handling, and the places where TF-A puts speculation barriers.

14.3 to 14.6 take the variants one at a time, each with its architectural feature, its software fallback and the firmware interface: Spectre v1 with CSDB, SB and masking; v2 and BHB with CSV2, ECBHB, CLRBHB, the k-iteration loop and SMCCC_ARCH_WORKAROUND_1/3; v4 with SSBS and SMCCC_ARCH_WORKAROUND_2; and the Meltdown class with CSV3, E0PD and KPTI. 14.7 covers prediction isolation across a world switch: SCXTNUM_ELx, the FEAT_SPECRES prediction-restriction instructions, and how to read which mitigations a core needs. 14.8 is the audit exercise, applied to an EL3 vector, an SMC handler and short gadget snippets.