Speculation and the Microarchitectural Leak

One bug, slowly. Then thirty of them, quickly.

CS 4250 — Computer Architecture

2026-11-30

The Machine That Guesses

A core at 1 GHz can start an instruction every nanosecond. That is the clock the whole pipeline is built around.

About one instruction in five is a branch, and resolving one takes 10–20 cycles. A core that waited for the answer would idle most of the time.

So it does not wait. It predicts — and then it executes the prediction before it is confirmed.

This is not an optimisation bolted onto the pipeline. It is how the pipeline is fed.

The Squash

When the prediction turns out to be wrong, the core rolls back.

  • registers — restored
  • memory — restored
  • the program counter — restored

That is what precise exceptions means: when control returns to the program, it is as if the wrong path never ran. Exactly.

But the wrong path did run. It fetched, it decoded, it computed addresses, it loaded — for however many cycles it took the core to notice.

Architecturally, none of it happened.

Everything Is Timed

The rollback is architectural. The hardware is still holding the results.

  • L1 hit — 4 cycles
  • L2 hit — 12 cycles
  • DRAM — 200 cycles

Any program can time its own memory accesses — rdtsc on x86, rdcycle on RISC-V where the platform exposes it. So the state of the cache is readable by anyone who can run code on the machine.

A wrong guess that touched memory has therefore left something observable behind.

Two Kinds of State

The ISA defines the left column and says nothing about the right. So the right column is where every one of these bugs lives.

The Bug Class in One Sentence

A wrong guess is rolled back in the registers, and not in the caches.

Everything else in this deck is an instance of that sentence. A different guess, a different structure, a different fix — the same shape.

Speculation is not the bug. The residue of speculation is the bug.

Part I — One Bug, Slowly

The Victim

char   array1[16];              /* the victim's data          */
size_t array1_size = 16;

void victim(size_t x) {
    if (x < array1_size) {      /* a bounds check             */
        char v = array1[x];     /* a byte we should not see   */
        probe[v * 4096] = 1;    /* one page, chosen by v      */
    }
}

There is nothing wrong with this function. It is correct C. The bounds check is present, it is in the right place, and it works.

It is also a gadget.

The Bound Is a Branch

if (x < array1_size) is a compare and a conditional branch.

On a pipelined core, the branch is resolved in a stage — EX, the execute stage — and predicted in the fetch stage.

The prediction happens in cycle 1. The comparison happens in cycle 3.

The core decides whether the check passes before it knows the answer. It has to; that is what prediction is for.

And a predictor that decides before it knows is a predictor that can be wrong on purpose.

What a Predictor Is

Three tables, three jobs. Every core that speculates has some version of these:

Structure Full name Job
BHT branch history table direction — taken, or not taken?
BTB branch target buffer target — where does this branch go?
RSB return stack buffer returns — where did this call come from?

The tables are indexed by PC, so the answer is available in the same cycle as the fetch — that is why a correct prediction costs zero cycles.

(Some manuals call the RSB the RAS, for return address stack. Same structure — this deck uses RSB throughout.)

Two properties matter here, and neither is a defect:

  • It is trained by execution. Run a branch and the table learns it.
  • It is shared and not flushed. It survives context switches, system calls, and (historically) privilege changes.

A structure that learns from what it sees, and is not reset, can be taught.

Train It

The attacker calls victim(0) thirty times.

call x check predicted actual
1 0 passes — taken
2 0 passes taken taken
… 0 passes taken taken
30 0 passes taken taken
31 5000 fails taken not taken

At call 31 the predictor is confident and wrong. The core fetches the wrong path — and then executes it.

The Window

1 2 3 4 5 6
IF bge ld a1[x] ld probe
ID bge ld a1[x] ld probe
EX bge ld a1[x] ld probe
MEM ld a1[x] ld probe
WB ld a1[x]

IF fetch · ID decode · EX execute · MEM memory · WB write back

bge reaches EX in cycle 3 and discovers the check failed. By then two loads are already in flight behind it.

The orange cell is the whole attack: ld probe reaches the memory unit in cycle 5, before the squash reaches it, and fills a cache line on its way.

What array1[x] Actually Reads

The out-of-bounds read is not a fault. array1[5000] is a perfectly valid address — it is just the wrong data. Nothing traps. Nothing is logged.

Why 4096

The secret is one byte: 256 possible values. We need to turn a value into a time difference.

probe[v * 4096] puts byte value v on page v, and on cache line v.

  • 4096 = the page size, so two different byte values are never on the same page.
  • A 64-byte line holds 64 bytes, so a stride of 1 would put 64 secret values on one line and destroy the signal.
  • A stride of 4096 also defeats the hardware prefetcher: it sees 256 far-apart streams, not one sequential one.

What Survives the Squash

The branch resolves. The core does exactly what it promised:

bge ld a1[x] ld probe
Architectural resolved discarded discarded
Microarchitectural predictor updated L1 filled L1 filled — survives

The rightmost column is the leak. It is not a bug in the squash. The squash did its job perfectly — it discarded the results.

Encode

After the transient window, exactly one line of probe is in L1.

The attacker does not need to know which line until they measure. That is the trick: the secret chose the address, so measuring the address reveals the secret.

This is a covert channel — 256 symbols, one per byte value, transmitted through the cache. The channel is the vulnerability’s delivery mechanism, not the vulnerability itself.

Decode: Flush+Reload

The Attack on One Page

Every stage is a performance feature doing its job. Not one of them is a memory-safety bug.

What It Costs

The original work measured on the order of 10–500 kB/s depending on setup.

That is not a file-copy channel. It is also far more than enough:

  • a 256-bit AES key is 32 bytes — well under a second;
  • a password is shorter than that;
  • a KASLR slide is a handful of bytes, and it unlocks everything else.

KASLR — kernel address space layout randomisation. The kernel is placed at a random offset at each boot, so an attacker cannot hard-code the address of a kernel gadget. That offset is the slide. Leak it, and every kernel address is known.

Bandwidth is the wrong metric. A single correct byte is often decisive.

Part II — Meltdown

A Different Kind of Bug

Everything so far needed a mistake in the victim’s code: a bounds check that could be bypassed.

Meltdown needs no bug in your code at all.

char secret = *(char *)0xffff888000000000;  /* kernel memory */
probe[secret * 4096] = 1;                   /* and then... */

That is the whole attack. Two lines. It is correct code in the sense that it does exactly what it says — it just should not be allowed to.

The Permission Check Race

Nobody’s check was wrong. On one design the check resolved late; on the other it gated the issue. That is the entire difference.

Why Precise Exceptions Create It

A core that executes out of order finishes instructions in whatever order they become ready. It still has to report faults in program order.

So it needs a reorder buffer: a structure that tracks every in-flight instruction and commits them in program order, no matter what order they finished in.

Precise means: when a fault is reported, everything before it has committed and everything after it has not. That requires holding the fault until the instruction is ready to retire.

The hold is the window. The machinery that gives you precise exceptions gives the attacker a delay between detecting a fault and delivering it — and in that delay, the data is already in a register.

KPTI

If user mode cannot address kernel memory, there is nothing to read.

KPTI — kernel page table isolation: separate page tables. While in user mode, kernel memory is not mapped at all.

Cost: two page tables, and a write to CR3 — the register holding the base of the current page table — on every trap and every return.

  • Naive: 5–30% on syscall-heavy workloads, worse on microbenchmarks.
  • With PCID (process-context identifiers), the TLB — the translation lookaside buffer, which caches recent address translations — need not be flushed, and the cost drops substantially.

This is a real fix. It removes the ability to name the address, which removes the attack. It is not a mitigation you can train programmers to defeat.

Why AMD Never Had It

Because the check was in a different place, and had been since the design was drawn.

This is worth sitting with. The bug was not “speculation is dangerous”. It was “one microarchitecture put a check on the wrong side of a queue, and another did not”.

A security property that depends on which side of a queue a check sits on is not a security property you can reason about from the ISA.

Part III — The Ladder

The First Fix

For Spectre v1, the obvious fix: if the check fails, make the index safe.

if (x < array1_size) {
    char v = array1[x & mask];   /* mask is 0 when the check fails */
    probe[v * 4096] = 1;
}

Linux’s version is array_index_nospec().

This works, and it works for the right reason: the speculative path now computes an address that is in bounds, so there is nothing out of bounds to leak.

The Fix Has a Bug

BCBS — Bounds Check Bypass Store (CVE-2018-3693).

The same misprediction can make a store transiently out of bounds, not just a load. And a transient store can overwrite a security-critical value — a permission flag, a function pointer, a return address — that a later, correctly speculated instruction then reads.

So the fix for “reading the wrong thing” had a hole where the answer was “writing the wrong thing”.

Barriers, and the Audit Problem

The blunt instrument: a speculation barrier after the check.

if (x < array1_size) {
    __asm__ volatile("lfence");    /* stop speculating here */
    char v = array1[x];
    ...
}

Correct. Also expensive, and — more importantly — it has to be everywhere.

The audit problem: every load whose address depends on untrusted input needs one, in every program, forever. Miss one and the class is back.

Fix the Branch, Not the Check

v1 mistrains a direction. The next attack poisons a target.

Spectre v2 — Branch Target Injection (CVE-2017-5715).

The attacker trains the BTB so that the victim’s indirect branch — call *%rax, a virtual dispatch, a switch table — speculatively goes to an address the attacker chose.

Now the attacker does not need a gadget in the victim’s code. They need a gadget anywhere in the address space that the victim will speculatively execute.

Poison the Target

/* attacker, in their own address space */
for (int i = 0; i < 30; i++)
    indirect_call(&gadget);      /* BTB now says: this PC -> gadget */

/* victim, elsewhere */
victim->indirect_call(...);      /* speculatively goes to gadget */

gadget reads a secret and encodes it into the cache — the same encoder from Part I. The only thing that changed is how control got there.

Retpoline

Replace indirect branches with a ret that the predictor cannot follow usefully.

call  set_up
pause
lfence
jmp   *%rax        /* never actually executed speculatively */
set_up:
mov   %rax, (%rsp)
ret

The ret uses the RSB — the return stack buffer — which is harder to poison than the BTB, the branch target buffer. The speculative path loops harmlessly instead of going where the attacker wants.

A software fix, deployed by recompiling everything. It worked. For four years.

Where We Are

v1 v2
Steers a direction a target
Needs a gadget in the victim’s code any mapped code
Fixed by index masking, barriers retpoline, IBRS, eIBRS
Fix status permanent software tax bypassed, re-fixed, bypassed

IBRS — indirect branch restricted speculation, a microcoded switch that isolates predictor entries by privilege. eIBRS is the hardware version, much cheaper.

Two variants, two fixes, and already the pattern is: the fix is shaped like the attack, so the next attack is shaped like the fix.

Store-to-Load Forwarding

A load can take its value from an older store that has not yet reached memory. That is a feature — it is how a core avoids stalling on every store followed by a load.

Spectre v4 — Speculative Store Bypass (CVE-2018-3639).

If the load forwards from a store that the core has speculated will not conflict, it can read a stale value — bypassing a newer store that would have made the access safe.

Same shape as v1, different mechanism: the bounds check is enforced by a store, and the forwarding lets the load read the old, permissive value.

L1TF: the Page Walk

Foreshadow / L1TF — L1 terminal fault (CVE-2018-3615, -3620, -3646).

When a page walk hits a non-present entry, the CPU may speculatively continue and use the physical address in that entry to index L1.

The attacker writes a PTE (page-table entry) with a chosen physical address and the not-present bit set. Then a speculative load reads L1 data from that physical address — memory the process was never allowed to map.

The fix is beautiful: PTE inversion. Non-present entries have their address bits inverted, so a speculative walk lands somewhere harmless. No measurable cost.

MDS: the Buffers

MDS — microarchitectural data sampling (CVE-2018-12126, -12127, -12130, CVE-2019-11091), published under four names: MDS, RIDL, ZombieLoad, Fallout.

Fill buffers, load ports, and store buffers hold data in flight. A speculative load can sample them.

Variant Full name Buffer
MFBDS microarchitectural fill buffer data sampling fill buffers
MLPDS microarchitectural load port data sampling load ports
MSBDS microarchitectural store buffer data sampling store buffers
MDSUM data sampling of uncacheable memory uncacheable memory

Here the leak is not the cache at all. It is the staging hardware — the buffers that exist to keep the memory system busy.

TAA and SWAPGS

TAA — TSX asynchronous abort (CVE-2019-11135) — the same buffers, reached through TSX, Intel’s transactional synchronisation extensions. A transaction that aborts gives you a new way to create a transient window.

SWAPGS (CVE-2019-1125) — the kernel’s swapgs instruction can execute speculatively with the wrong GS base. swapgs swaps the GS segment base between user and kernel; get it wrong and a kernel entry gadget reads kernel memory using a userspace base.

Both are the same lesson: every new mechanism is a new way to open a window. TSX was a feature nobody used. It still had to be disabled.

The Return Stack

The RSB — the return stack buffer, the third table from Part I — is a predictor too. So it has the same problem.

  • SpectreRSB (2018) — poison a return address; the victim’s ret speculatively returns to the attacker’s gadget.
  • Retbleed (2022, CVE-2022-29900 AMD / -29901 Intel) — attack return prediction itself. This bypassed retpoline, which was built on the RSB.
  • Inception (2023, CVE-2023-20569) — AMD Zen 1–4. Make an XOR look like a recursive call, overflow the RSB with an attacker-chosen target.

SpectreRSB → Retbleed → Inception is one continuous line: the fix for v2 became the target.

BHI: the Hardware Fix That Wasn’t

Branch History Injection / Spectre-BHB (CVE-2022-0001, -0002).

eIBRS (Intel) and CSV2 — ARM’s cache speculation variant 2 — were hardware fixes for v2: tag predictor entries by privilege so userland cannot train kernel targets.

BHI: the attacker cannot inject a target, but they can poison the BHB — the branch history buffer, the global record of recent branch outcomes. The BHB selects which predictor entry the kernel uses. Steer it, and you steer the kernel to a kernel gadget.

The hardware fix constrained the target. It did not constrain the index.

Rapid Fire I

  • LVI (CVE-2020-0551) — Load Value Injection. The attacker injects data into the victim’s speculative load. Not a predictor attack; a data-flow attack. Mitigation: fences after untrusted loads. Reported up to 77% on some Xeon configurations.
  • Downfall (CVE-2022-40982) — AVX-512, Intel’s 512-bit vector extension. Its gather instruction — one load from many scattered addresses — leaks the vector register file. Intel 6th–11th Gen Core and 1st–4th Gen Xeon. Roughly nine years of silicon. Mitigation: GDS_CTRL — a gather-data-sampling control bit — at up to ~50% on gather-heavy code.

Two new surfaces: injected data and the register file. Neither was on anybody’s list in 2018.

Rapid Fire II

  • Zenbleed (CVE-2023-20593) — AMD Zen 2. vzeroupper is supposed to zero the upper bits of the YMM registers (the 256-bit vector registers) and on Zen 2 did not always. Stale data leaks across contexts. This is the CPU in this room. Fixed by microcode.
  • CacheOut (CVE-2020-0548, -0549) — data being evicted from L1 can be transferred to leaky buffers on the way out.
  • EntryBleed (CVE-2022-4543) — prefetch timing reveals whether a kernel address is mapped, breaking KASLR under KPTI.
  • SLAM (2024) — Spectre with LAM. Linear-address-masking features — Intel LAM, ARM TBI, AMD UAI, all of which let software ignore some upper address bits — create unmasked speculative addresses that reach gadgets.

Note what EntryBleed does: it breaks KPTI, the fix from Part II. Not the protection it gave — the assumption that KPTI made addresses unguessable.

The Ladder

Variant Window opens by Fix Status
Spectre v1 mispredicted direction index masking, barriers permanent
BCBS mispredicted direction barriers around stores permanent
Spectre v2 poisoned BTB target retpoline, IBRS, eIBRS bypassed
Meltdown permission-check race KPTI + PCID fixed
Spectre v4 store-to-load forwarding SSBD feature off
L1TF terminal page fault PTE inversion fixed
MDS speculative buffer sample VERW + no SMT feature off
Retbleed / Inception return prediction safe RET, SRSO bypassed
BHI branch history clear BHB on entry bypassed
Downfall gather sampling GDS_CTRL fixed

SSBD speculative store bypass disable · VERW the instruction microcode extends to clear the buffers · SRSO speculative return stack overflow · SMT simultaneous multithreading

Read the last column, not the third. Four of the ten have a fix you can call finished.

Part IV — How Many?

How Many?

The count depends on how you count. That is not a dodge — it is the finding.

  • By CVE: around thirty, and still climbing.
  • By paper: more, because a paper often demonstrates several.
  • By mechanism: far fewer — and that is the useful number.

The useful question is not “how many are there”. It is “how many shapes are there”. The answer is a grid with four cells.

The Grid

Nine Years

Every Fix Is Followed by a Paper

Fix Deployed Broken by
retpoline 2018 Retbleed, 2022
KPTI 2018 EntryBleed (assumption), 2022
eIBRS (hardware) 2019 BHI, 2022
CSV2 (ARM hardware) 2019 BHI, 2022
retpoline + RSB stuffing 2018 Inception, 2023
index masking 2018 BCBS (the store shape)

Six fixes. Six follow-ups. The mean time to a bypass is about three years.

Why It Accelerated

Three reasons the count grew rather than shrank:

  1. The tools got better. Once the recipe was published, finding a new instance was an exercise: find a buffer or predictor, find a gadget, find a timer.
  2. The surface grew. Every new feature — TSX, AVX-512 gather, LAM, SMT topologies — added a structure nobody had asked about.
  3. The fixes created new boundaries. Retpoline created the RSB as a target; eIBRS created branch history as a target.

Reason 3 is the one that should worry you. Defence is generating offence.

Part V — What Can Be Fixed

Four Kinds of Fix

“The industry can’t fix these” is too strong, and it is the claim a smart student will attack. The honest version has four categories.

Category Meaning
1 Fixed in silicon a real bug, a real fix, finished
2 Fixed by giving up the feature the leak is the sharing
3 Provisionally fixed deployed, then bypassed
4 Permanently unfixable no hardware can know your intent

1. Fixed in Silicon

fixed

  • Meltdown — RDCL_NO (“rogue data cache load: not affected”) in the IA32_ARCH_CAPABILITIES MSR (model-specific register); later designs do not have the race. AMD never did.
  • L1TF — PTE inversion. A format change, no measurable cost, complete.
  • Zenbleed — microcode.
  • Downfall — GDS_CTRL microcode.

These are the existence proof. The class is not uniformly unfixable, and anyone who says otherwise is over-claiming.

2. Fixed by Giving Up the Feature

feature off

  • MDS — VERW on every context switch, and SMT off.
  • Spectre v4 — SSBD disables store-to-load forwarding.
  • TAA — TSX disabled entirely.

The leak is not a side effect of the feature. The leak is the sharing. If two threads share a fill buffer, a speculative load can read across the boundary; there is no version of the buffer that is both shared and safe.

So the “fix” is a decision that the feature is not worth its price — which is a business decision, not an engineering one.

3. Provisionally Fixed

bypassed

Anything gated on predictor isolation:

  • retpoline → Retbleed
  • eIBRS → BHI
  • CSV2 → BHI
  • RSB stuffing → Inception

The fix is always “constrain the predictor”. The predictor is finite, shared, and indexed by hashed addresses and history — so there is always another input.

A fix that works by constraining a finite shared structure is a fix with a search problem attached.

4. Permanently Unfixable

permanent

Spectre v1. No hardware can know that your bounds check is a security boundary.

if (x < array1_size) { ... }     /* a security check */
if (i < n) { ... }               /* a loop bound */

These are the same instruction. The CPU cannot tell them apart, and it must not stall for either — stalling on every conditional branch would cost more than the whole pipeline is worth.

So the fix is a permanent, universal software contract: every load whose address depends on untrusted input must be masked or fenced. Enforced by every programmer, forever, with no way to test compliance.

SMT: the Structural Amplifier

Simultaneous multithreading puts two threads on one core. They share:

Shared Consequence
L1 data cache Prime+Probe becomes practical
Fill / load / store buffers MDS reads across threads
Branch predictors Training crosses threads
Execution ports Port contention leaks

SMT does not create these bugs. It converts a local bug into a cross-tenant one — and cross-tenant is where the money is.

The Uncomfortable Conclusion

We spent twenty years building machines whose performance depends on shared, persistent, observable state — and then connected them to each other.

Every mitigation in this deck is one of three things:

  • remove a capability (rare, and the only real fix),
  • disable a feature (a business decision),
  • add a per-operation tax (paid by everyone, forever).

There is no fourth option, because the fourth option would be to stop speculating — and nobody is going to do that.

Part VI — This Machine

The Machine on the Desk

zoologist — the machine this deck is presented on.

CPU AMD Ryzen 5 PRO 4650U — Zen 2 “Renoir”, family 23 model 96
Cores 6C / 12T, SMT on
L1 32 KB 8-way data, 32 KB 8-way instruction
L2 512 KB 8-way, per core
L3 4 MB 16-way, per CCX (core complex) — there are two
Line 64 bytes
ISA AVX2 (256-bit vectors), no AVX-512; clflush, rdtscp

Four of these numbers are load-bearing for the rest of the deck:

  • 64-byte lines set the probe stride — that is why it is 4096 and not 1.
  • SMT on is why the buffer-sampling family is relevant at all.
  • 32 KB, 8-way L1 is small enough to fill and evict deliberately.
  • No AVX-512 is why one row of the next slide reads “Not affected”.

The Vulnerabilities Wall

$ for f in /sys/devices/system/cpu/vulnerabilities/*; do
      printf '%-26s %s\n' "$(basename $f)" "$(cat $f)"; done

gather_data_sampling       Not affected
indirect_target_selection  Not affected
l1tf                       Not affected
mds                        Not affected
meltdown                   Not affected
retbleed                   Mitigation: untrained return thunk; SMT enabled with STIBP protection
spec_rstack_overflow       Mitigation: Safe RET
spec_store_bypass          Mitigation: Speculative Store Bypass disabled via prctl
spectre_v1                 Mitigation: usercopy/swapgs barriers and __user pointer sanitization
spectre_v2                 Mitigation: Retpolines; IBPB: conditional; STIBP: always-on; RSB filling
srbds                      Not affected
tsx_async_abort            Not affected

(abridged — 17 rows in total)

Reading the Wall

Row Says Category
meltdown Not affected 1 — never had the race
l1tf, mds, srbds Not affected 1 — Intel-only families
gather_data_sampling Not affected 1 — no AVX-512, by luck
spec_store_bypass disabled via prctl 2 — opt-in feature off
retbleed untrained return thunk 3 — a patch to the patch
spectre_v1 usercopy/swapgs barriers 4 — code discipline

retbleed’s mitigation is literally the replacement for retpoline, itself patched. That is category 3 in one line of kernel output.

What “Not Affected” Means

“Not affected” is a claim about this silicon, made by the vendor, and it is not the same as “safe”.

Three different reasons produce the same three words:

  • the race was never in the design (meltdown),
  • the bug is in a structure this part does not have (l1tf, mds),
  • the feature is not in this model (gather_data_sampling).

Only the first is a security property. The second is a different product. The third is luck, and luck does not survive the next generation.

What “Mitigation” Means

spectre_v2 on this machine:

Mitigation: Retpolines; IBPB: conditional; STIBP: always-on; RSB filling

Four mechanisms, and the qualifiers matter more than the mechanisms:

  • IBPB — indirect branch prediction barrier: the predictor flush happens on some transitions, not all.
  • STIBP — single thread indirect branch predictors: the SMT isolation is paid for on every cycle, on both threads.

“Mitigated” is not a boolean. It is a configuration, and the configuration is a performance decision someone made.

SSBD Is Opt-In

spec_store_bypass: Mitigation: Speculative Store Bypass disabled via prctl

prctl. Not “enabled”. Not “always”. The protection is off unless a program asks for it.

Because turning it on costs performance, and most programs do not need it — and “most programs” is not a security boundary, it is a guess about who is running what.

This is the most honest slide in the deck. You are running with some of these mitigations off, and nobody told you.

Zenbleed Was This CPU

CVE-2023-20593 — AMD Zen 2. vzeroupper fails to zero the upper bits of the YMM registers; stale data leaks across contexts.

This is the CPU in the room. Not an ancestor, not a sibling — this die.

And it was fixed. By microcode. vzeroupper now does what the manual always said it did.

So hold both facts at once: this machine shipped with a register-file leak, and this machine got a real fix. That is the strongest argument against the word “unfixable” — and it is the right frame for the next slide.

The Demo That Didn’t Work

We tried the naive Spectre v1 PoC on this machine. At -O2 it failed:

fastest-reload histogram: <100:0  100-200:0  200-300:300  300-400:0  ...
best byte was 84 ('T') in 0/300 tries

Every probe line missed. The probe array was never touched transiently — the compiler had inlined the victim and the window was not what the paper assumed.

This is the mitigation working, seen from the attacker’s side. A modern compiler and a modern core make the naive attack not work, and that is a real result.

Part VII — The Board on the Desk

The C906, Predicted

The SG2000’s big core: an in-order RISC-V C906 with a real predictor — 8–16 Kb GSHARE BHT (indexed by the branch’s PC and recent branch history), 16-entry fully associative BTB, 4-level RSB.

Prediction, not measurement. We did not test this board, and I will not pretend we did.

What the architecture predicts:

  • v1: in-order cores still speculate on predicted branches, and the C906 has a predictor in the fetch stage. It should be vulnerable. The small BTB (16 entries) makes aliasing easier, not harder.
  • Meltdown: needs a permission-check race. Nothing suggests this design has one, and M-mode with physical addressing changes the question entirely.
  • MDS / L1TF: need the Intel-specific buffer and page-walk behaviour. Unlikely.

Part VIII — Synthesis

What We Learned

  1. The ISA is a contract with a gap. Architectural state rolls back; microarchitectural state does not.
  2. Speculation is not the bug. The residue of speculation is the bug.
  3. The count is not the point. Thirty CVEs, four mechanisms.
  4. The fixes are shaped like the attacks, so the next attack is shaped like the fix.
  5. Only some of it is fixable, and the unfixable part is a permanent tax on software rather than on silicon.

Every structure you were taught as a performance mechanism is on the attack surface list. That is not a coincidence. It is the same list.

Discussion Prompts

  • A CPU cannot tell a security bounds check from a loop bound. Design a mechanism that would let it — and say what it costs.
  • spec_store_bypass is off by default on this machine. Should it be on? Who decides, and what do they need to know?
  • MDS is “fixed” by turning SMT off. What would you tell a cloud provider who has to choose between 20% throughput and a cross-tenant leak?
  • Retpoline was bypassed in four years. Was deploying it a mistake?
  • The C906 has a 16-entry BTB. Is that better or worse for an attacker than a 4096-entry BTB? Argue both ways.
  • Which of the four categories does a new feature you would add to a CPU fall into, before anyone attacks it?

Every one is answerable from this deck. None has a single right answer.

Refs

Core papers

  • Kocher et al., Spectre Attacks: Exploiting Speculative Execution, IEEE S&P 2018.
  • Lipp et al., Meltdown: Reading Kernel Memory from User Space, USENIX Security 2018.
  • Canella et al., A Systematic Evaluation of Transient Execution Attacks and Defenses, USENIX Security 2019 — the grid.
  • Van Bulck et al., Foreshadow, USENIX Security 2018.
  • Weber et al., Retbleed, USENIX Security 2022.
  • Moghimi, Downfall, USENIX Security 2023.
  • Tuchecheerer et al., Inception, 2023.
  • Hertogh et al., SLAM, IEEE S&P 2024.

Hardware and OS

  • AMD Zen 2 / Ryzen 5 PRO 4650U — lscpu, /sys/devices/system/cpu/vulnerabilities on zoologist. Every number in Part VI is from this machine.
  • XuanTie C906 User Manual (openc906), §7.1.3 — the BHT/BTB/RSB geometry in Part I and Part VII.
  • Linux kernel documentation: Documentation/admin-guide/hw-vuln/ — one file per family, and the source for every mitigation string in Part VI.