Extensions
Forms
1 (1 Legacy)
Data
Intel XED v2026.08.23

RSTORSSP moves a thread onto another shadow stack. A switch between coroutines or user-level threads loads a new RSP, and under CET the shadow stack has to follow; SSP cannot be written directly, so RSTORSSP moves it, but only onto a stack that carries a restore token: an 8-byte entry on top that records where that stack’s SSP stood when the token was made. The unwinding page notes that glibc’s longjmp uses it to return to a different shadow stack.

The checks

The memory operand is the token’s address, which must be 8-byte aligned, or #GP(0), and lie in a shadow-stack page, or #PF. In one locked step RSTORSSP reads the token and checks that bit 0 matches 64-bit mode, bit 1 is clear, and the address it records, less 8 and rounded down to a multiple of 8, is the token’s own: a token is valid only right on top of the stack it describes. A failing token is written back unchanged and RSTORSSP raises #CP, with error code 4 in Intel’s list and 3 in AMD’s. A valid one is replaced by a previous-SSP token, the old SSP with bits 1 and 0 set, and SSP moves to the token’s address. As the read and the write are one locked operation, two threads cannot both take the same stack.

After the switch

The previous-SSP token now on top tells SAVEPREVSSP where the old stack ended, so that it can leave a restore token there for the way back; a switch that never returns pops it with INCSSPQ instead. CF reports bit 2 of the restore token: the recorded SSP was 4-byte but not 8-byte aligned, a hole of 4 bytes that only 32-bit code leaves. OF, SF, ZF, AF and PF are cleared. SAVEPREVSSP reads that CF, so code between the two must not change it.

With -mshstk, GCC 14 compiles _rstorssp(p) to rstorssp QWORD PTR [rdi]; Clang 23’s Intel syntax prints dword ptr for the same 8-byte operand. Without shadow stacks enabled at the current privilege level, RSTORSSP raises #UD.

AMD’s Zen 5 guide lists RSTORSSP among the shadow-stack instructions Zen 5 supports, as microcoded. The KVM guest that ran the probe reported no shadow stacks in CPUID (leaf 07H, ECX bit 7), and both recorded cases raised #UD, with the token in memory unchanged.

Forms

Every encoding of RSTORSSP that Intel XED knows, one row per XED instruction form (iform). How to read the notation.
InstructionEncodingRequires
RSTORSSP m64 RSTORSSP_MEMu64F3 0F 01 /5CET

Operation

What the forms do, in pseudocode that our tests run against results recorded on real processors. How to read.

if not cr4 >> 23 & 1:            # CR4.CET; clear without CET
    fault(UD)
cet = u_cet if CPL == 3 else s_cet
if not cet & 1:                  # SH_STK_EN: shadow stacks off
    fault(UD)
a = src.address                  # the restore token
if not canonical(a):
    fault(GP, 0)                 # #SS(0) through RSP or RBP
if a & 7:
    fault(GP, 0)                 # 8-byte aligned
t = ss_load(a, 64)               # locked until the store below
home = (t & ~1) - 8 & ~7         # where the token says it lies
ok = t & 3 == 1 and home == a    # L = 1 (64-bit mode), bit 1 clear
p = ssp | 3                      # previous-SSP token: SSP, L = 1
ss_store(a, 64, p if ok else t)  # a bad token is written back as
if not ok:                       # it was
    fault(CP, 4)                 # #CP(RSTORSSP)
ssp = a
cf = t >> 2 & 1                  # SSP in the token 4-byte aligned:
                                 # an alignment hole, which only
                                 # compatibility mode leaves
zf = pf = af = of = sf = 0

Run on AMD Zen 5 (EPYC 9645): 2 cases. Its cases ran where CPUID reported no CET, and every one raised an exception.

Operands

What each form reads and writes, as Intel XED records it: the operands of its syntax, in order, and the implicit ones that the syntax does not name. How to read.
OperandKindAction
RSTORSSP m64
m64explicitread, write
SSPimplicitwrite

Flags

None: XED records no flag that the forms test or change.

Attributes

What else XED records about the forms. How to read.

All forms
not in real-address mode

Intrinsics

The C intrinsics of Clang 23.1.2 that compile to RSTORSSP, each with the form it compiles to and the Clang options it needs. The forms come from compiling every intrinsic and decoding the result with Intel XED; all intrinsics A–Z explains the method.

IntrinsicCompiles to
_rstorssp void _rstorssp(void *__p)

RSTORSSP m64 Legacy -mshstk

CPUID and processors

Each form belongs to an XED ISA set. A form can be used when the processor reports every CPUID bit of one of its ISA set's alternatives.

CPUID requirements and processors of the XED ISA sets above. Alternatives are separated by “or”; processors follow XED’s chip model, whose AMD processors end with Zen 2, and the CPU data of this site for Zen 3 to Zen 6.
ISA setCPUIDProcessors
CET

CET
CPUID.(EAX=07H,ECX=0):ECX[7] CET

Tiger Lake, Alder Lake, Arrow Lake, Panther Lake, Nova Lake, Sapphire Rapids, Emerald Rapids, Granite Rapids, Diamond Rapids, Sierra Forest, Clearwater Forest, Zen 3, Zen 4, Zen 5, Zen 6

Note: Zen 3 to Zen 6 have the shadow stacks of CET but not its indirect branch tracking, so ENDBR32 and ENDBR64 run on them as hint NOPs. AMD's references for Zen 3, Zen 4 and Zen 5 (55898, 55901, 57238) set CPUID_Fn00000007_ECX_x00[CET_SS] (bit 7) and leave bit 20 of CPUID_Fn00000007_EDX_x00, which Intel gives to indirect branch tracking, reserved and clear.

Note: Zen 6 is listed because Zen 5 has these instructions. GCC's -march sets, which give the other features of Zen 6, leave them out, and AMD has not yet published a Processor Programming Reference for Zen 6.

More CET instructions

Sources

  1. Intel XED v2026.08.23 (commit 0bcb6237345c): forms, encodings, operands, flags, exception classes, attributes, ISA sets, CPUID bits and chip model.
  2. The CPU data of x86-64.net: Zen 3 to Zen 6, from GCC’s -march feature sets and AMD’s Processor Programming References, which the page of each processor cites.
  3. Clang's x86 intrinsic headers, LLVM 23.1.2 (commit 85ac56026243): the intrinsics, their signatures and doc comments, and the Clang of that release, which compiled each of them.
  4. Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 2 (325383-093, September 2026): Volume 2B, page 4-598 (RSTORSSP)
  5. Linux kernel documentation: Control-flow Enforcement Technology (CET) Shadow Stack
  6. Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 1 (253665-093, September 2026)
  7. Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 3 (325384-093, September 2026)
  8. AMD64 Architecture Programmer's Manual, Volume 2: System Programming (24593, rev. 3.42, March 2024), Wayback Machine copy of AMD's PDF
  9. AMD64 Architecture Programmer's Manual, Volume 3: General-Purpose and System Instructions (24594, rev. 3.36, March 2024), Wayback Machine copy of AMD's PDF
  10. Software Optimization Guide for the AMD Zen5 Microarchitecture (58455, rev. 1.00, August 2024), Wayback Machine copy of AMD's ZIP

The tables are derived from Intel XED, Copyright Intel Corporation, licensed under the Apache License 2.0; x86-64.net converted and reformatted them. The intrinsics and their signatures come from Clang, part of the LLVM Project, licensed under the Apache License 2.0 with LLVM Exceptions. The text is our own.