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

ERETU is the way back to user mode when FRED is enabled. It expects RSP to point at the frame that FRED event delivery pushed, skips the error code, and restores RIP, CS, RFLAGS, RSP and SS from it, loading CS and SS for ring 3 based on IA32_STAR. It also swaps the GS base with IA32_KERNEL_GS_BASE, undoing the swap made on entry.

It works only at privilege level 0 with FRED enabled (#UD otherwise), and only at stack level 0 (#GP otherwise). With supervisor shadow stacks enabled it also checks the shadow-stack pointers. ERETS is the counterpart for events that happened in the kernel: it returns within ring 0 and leaves CS, SS and GS alone.

Forms

Every encoding of ERETU that Intel XED knows, one row per XED instruction form (iform). How to read the notation.
InstructionEncodingRequires
ERETU 64-bit mode only ERETUF3 0F 01 CAFRED

Operation

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

if not cr4 >> 32 & 1 or CPL > 0:
    fault(UD)                    # FRED off, or CPL 3: #UD, not #GP
if msr[0x1D4] & 3:
    fault(GP, 0)                 # from stack level 0 only
t = load(rsp + 8, 64)            # RIP; the error code is skipped
c = load(rsp + 16, 64)           # CS
f = load(rsp + 24, 64)           # RFLAGS
p = load(rsp + 32, 64)           # RSP
s = load(rsp + 40, 64)           # SS, bits 18:16 event state
if c & 0xFFFFFFFFFFFF0003 != 3:
    fault(GP, 0)                 # to CPL 3, no other bits
if f & 0xFFFFFFFFFFC2B02A != 2:
    fault(GP, 0)                 # bit 1 set; IOPL, VM and reserved
                                 # bits clear
if s & 0xFFF80003 != 3:
    fault(GP, 0)
u = star >> 48                   # STAR[63:48], SYSRET's selectors
c &= 0xFFFF
s &= 0xFFFF
if c == u + 16 and s == u + 8:
    wide = 1                     # 64-bit code, flat, as SYSRET has it
elif c == u and s == u + 8:
    wide = 0                     # 32-bit code, flat
else:
    d = descriptor(c)            # any other: both descriptors read
    wide = d >> 53 & 1           # and checked as IRET checks them
if wide and not canonical(t):
    fault(GP, 0)
if not wide:
    t &= 0xFFFFFFFF              # to compatibility mode: 32 bits,
    p &= 0xFFFFFFFF              # within CS's limit
rip = t
rsp = p
cs = c                           # CPL 3
ss = s
cf = f & 1
pf = f >> 2 & 1
af = f >> 4 & 1
zf = f >> 6 & 1
sf = f >> 7 & 1
tf = f >> 8 & 1
if_ = f >> 9 & 1
df = f >> 10 & 1
of = f >> 11 & 1
iopl = f >> 12 & 3               # 0, as checked
nt = f >> 14 & 1
rf = f >> 16 & 1                 # RF may come back set
vm = f >> 17 & 1                 # 0, as checked
ac = f >> 18 & 1
vif = f >> 19 & 1
vip = f >> 20 & 1
id = f >> 21 & 1
k = kernel_gs_base               # GS's base swapped, as SWAPGS does
kernel_gs_base = gsbase
gsbase = k
# SS bit 17: a pending single-step #DB, if TF is set; bit 18: NMIs
# unblocked. With shadow stacks, SSP comes from IA32_PL3_SSP

Not run on a processor: the Zen 5 guest that ran the probe does not report FRED in CPUID.

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
ERETU 64-bit mode only
stackimplicitread
rSPimplicitread, write
CSimplicitwrite
SSimplicitwrite
RIPimplicitwrite
RSPimplicitwrite
GS baseimplicitwrite
IA32_KERNEL_GS_BASEimplicitwrite
RFLAGSimplicitwrite

Flags

P loaded from the stack; blank: not affected. How to read.
OFSFZFAFPFCFDFIFTFACIOPLNTRFVMVIFVIPID
All forms
PPPPPPPPPPPPPPPPP

Attributes

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

All forms
privileged: CPL 0 only; may abort a TSX transaction

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
FRED

FRED
CPUID.(EAX=07H,ECX=1):EAX[17] FRED

Panther Lake, Nova Lake, Diamond Rapids, Zen 6

More FRED 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. Flexible Return and Event Delivery (FRED) Specification (346446-009)
  4. Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 2 (325383-093, September 2026): Volume 2A, page 3-301 (ERETU)
  5. Linux kernel documentation: Flexible Return and Event Delivery (FRED)

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 text is our own.