IT lexicon Hardware Return stack buffer (RSB)

Return stack buffer (RSB)

Hardware På svenska → Updated: 2026-05-29

A small hardware stack in the CPU that specifically predicts the return address from function calls. When a function is called the return address is also pushed here; on return the RSB guesses where the code should go back to — faster and more accurate than a general branch predictor.

Why separate: function returns are a special kind of indirect jump where the target (the return address) follows a strict pattern — last-in-first-out, exactly like a stack. The RSB mirrors the call/ret pairs: each call pushes the expected return address, each ret pops it and lets the CPU speculatively fetch from there directly. This is far more accurate for returns than letting the general BTB guess. Limitation: the RSB is small (typically 16-32 entries) → very deep recursion or unmatched call/ret pairs can "overflow" it and lead to mispredictions. Like the BTB, RSB behavior has been exploited in side-channel attacks (Spectre-RSB/retbleed). A specialized but important prediction mechanism. Related to branch target buffer and speculative execution.

← Back to the lexicon