rdgsbase
Read GS Base
RDGSBASE r64
Reads the GS base address into a register.
Details
Reads the current GS segment base address (from MSR_GS_BASE) into a 64-bit general-purpose register. Available only in 64-bit mode and requires the FSGSBASE CPU feature to be enabled. No flags are modified; the instruction executes with serialization semantics to ensure consistency of segment-base state.
Pseudocode Operation
if (FSGSBASE_enabled) {
dest ← MSR_GS_BASE;
} else {
raise(UD_EXCEPTION);
}
Example
RDGSBASE rax
Encoding
Binary Layout
F3
+0
0F
+1
AE
+2
ModRM
+3
Operands
-
dest
64-bit general-purpose register (e.g. RAX)
Reference (Intel® SDM)
Instruction Forms
| Opcode | Instruction | Op/En | 64/32-bit Mode | CPUID | Description |
|---|---|---|---|---|---|
| F3 0F AE /0 | RDFSBASE r32 | M | V/I | FSGSBASE | Load the 32-bit destination register with the FS base address. |
| F3 REX.W 0F AE /0 | RDFSBASE r64 | M | V/I | FSGSBASE | Load the 64-bit destination register with the FS base address. |
| F3 0F AE /1 | RDGSBASE r32 | M | V/I | FSGSBASE | Load the 32-bit destination register with the GS base address. |
| F3 REX.W 0F AE /1 | RDGSBASE r64 | M | V/I | FSGSBASE | Load the 64-bit destination register with the GS base address. |
Description
Loads the general-purpose register indicated by the ModR/M:r/m field with the FS or GS segment base address.
The destination operand may be either a 32-bit or a 64-bit general-purpose register. The REX.W prefix indicates the operand size is 64 bits. If no REX.W prefix is used, the operand size is 32 bits; the upper 32 bits of the source base address (for FS or GS) are ignored and upper 32 bits of the destination register are cleared.
This instruction is supported only in 64-bit mode.
Operation
DEST := FS/GS segment base address;
Flags Affected
None. C/C++ Compiler Intrinsic Equivalent RDFSBASE unsigned int _readfsbase_u32(void ); RDFSBASE unsigned __int64 _readfsbase_u64(void ); RDGSBASE unsigned int _readgsbase_u32(void ); RDGSBASE unsigned __int64 _readgsbase_u64(void );
Exceptions
Protected Mode Exceptions
#UD The RDFSBASE and RDGSBASE instructions are not recognized in protected mode.
Real-Address Mode Exceptions
#UD The RDFSBASE and RDGSBASE instructions are not recognized in real-address mode.
Virtual-8086 Mode Exceptions
#UD The RDFSBASE and RDGSBASE instructions are not recognized in virtual-8086 mode.
Compatibility Mode Exceptions
#UD The RDFSBASE and RDGSBASE instructions are not recognized in compatibility mode.
RDFSBASE/RDGSBASE—Read FS/GS Segment Base Vol. 2B 4-542
64-Bit Mode Exceptions
#UD If the LOCK prefix is used.
If CR4.FSGSBASE[bit 16] = 0.
If CPUID.07H.00H:EBX.FSGSBASE[0] = 0.
RDFSBASE/RDGSBASE—Read FS/GS Segment Base Vol. 2B 4-543