Instruction
WRMSR
Writes EDX:EAX to the model-specific register that ECX selects; ring 0 only and, unlike WRMSRNS, serializing.
- Extensions
- Forms
- 1 (1 Legacy)
- Data
- Intel XED v2026.08.23
WRMSR writes EDX:EAX into the model-specific register whose number is in ECX, the high half from EDX; bits 63:32 of RCX, RAX and RDX do not count. It is how a kernel sets up much of the processor: EFER, the SYSCALL targets in STAR and LSTAR, the FS, GS and kernel GS bases that SWAPGS exchanges, the memory type ranges. RDMSR reads them back.
What it checks
WRMSR runs only at CPL 0 (or in real mode) and raises #GP(0) elsewhere: Zen 5 recorded that at CPL 3 for EFER and the time stamp counter, and changed nothing. At CPL 0 it also raises #GP(0) for an MSR that does not exist, for a value that sets a reserved bit, and, for the MSRs that hold addresses, for an address that is not canonical: Intel’s manual names the FS, GS and kernel GS bases, LSTAR, the SYSENTER entry point and stack, and the debug store area. AMD’s manual says that SWAPGS relies on this check and does none of its own. Intel’s manual asks that undefined and reserved bits be written with the values read before, so a write usually follows a read.
A serializing write
WRMSR is serializing in both manuals: everything before it completes, and its buffered stores reach memory, before anything after it starts. Each manual makes exceptions. Intel’s names IA32_TSC_DEADLINE and the x2APIC MSRs; AMD’s names SPEC_CTRL, PRED_CMD and the x2APIC MSRs, and some AVIC ones. A write to a memory type range register also invalidates the TLBs, global entries included (Intel’s manual). Code that used WRMSR to serialize can use SERIALIZE instead, Intel’s manual suggests, and writes that need no serializing can use WRMSRNS or, for up to 64 MSRs from a table, WRMSRLIST, neither of them serializing. All three, Intel’s manual says, keep instructions before them from using the new value and make those after them use it.
Writes from user mode
UWRMSR writes, at any CPL, only the MSRs that the OS allows in a bitmap, today IA32_UARCH_MISC_CTL alone, and without serializing. Under VMX and SVM, the hypervisor’s MSR bitmap or permissions map decides which writes of a guest exit to it. AMD’s Zen 5 guide lists WRMSR as microcoded and names it among the serializing instructions that close write combining.
Forms
| Instruction | Encoding | Requires |
|---|---|---|
WRMSR
WRMSR | 0F 30 | Base instruction set |
Operation
What the forms do, in pseudocode that our tests run against results recorded on real processors. How to read.
if CPL > 0:
fault(GP, 0)
n = ecx # bits 63:32 of RCX, RAX and RDX do
v = edx << 32 | eax # not count
if not msr_allows(n, v):
fault(GP, 0) # an MSR it lacks, a reserved bit
# set, or an address that is not
# canonical
msr[n] = v
# serializing: the instructions after it wait until it is done; a
# write to an MTRR also flushes the TLBsRun on AMD Zen 5 (EPYC 9645): 2 cases. Every one raised an exception, at CPL 3, where the probe runs.
Operands
| Operand | Kind | Action |
|---|---|---|
WRMSR | ||
EAX | implicit | read |
EDX | implicit | read |
ECX | implicit | read |
MSRs | implicit | write |
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
- 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.
| ISA set | CPUID | Processors |
|---|---|---|
PENTIUMREAL | No CPUID bit: part of the base instruction set. | Every x86-64 processor in XED’s model and Zen 3 to Zen 6 |
More System instructions
Sources
- Intel XED v2026.08.23 (commit
0bcb6237345c): forms, encodings, operands, flags, exception classes, attributes, ISA sets, CPUID bits and chip model. - The CPU data of x86-64.net: Zen 3 to Zen 6, from GCC’s
-marchfeature sets and AMD’s Processor Programming References, which the page of each processor cites. - Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 2 (325383-093, September 2026): Volume 2D, page 6-8 (WRMSR)
- Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 3 (325384-093, September 2026)
- AMD64 Architecture Programmer's Manual, Volume 2: System Programming (24593, rev. 3.42, March 2024), Wayback Machine copy of AMD's PDF
- 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
- 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 text is our own.