Model-specific register
A model-specific register (MSR) is any of various control registers in the x86 instruction set used for debugging, program execution tracing, computer performance monitoring, and toggling certain CPU features.
History
With the introduction of the 80386 processor, Intel began introducing "experimental" features that would not necessarily be present in future versions of the processor. The first of these were two "test registers" (T6 and T7) that allowed the 80386 to speed up virtual-to-physical address conversions. Three additional test registers followed in the 80486 (TR3–TR5) that enabled testing of the processor's caches for code and data. None of these five registers were implemented in the subsequent Pentium processor.[1]
With the introduction of the Pentium processor, Intel provided a pair of instructions (rdmsr
and wrmsr
) to access current and future "model-specific registers", as well as the CPUID instruction to determine which features are present on a particular model. Many of these registers have proven useful enough to be retained. Intel has classified these as architectural model-specific registers and has committed to their inclusion in future product lines.[2]
Using MSRs
Reading and writing to these registers is handled by the rdmsr
and wrmsr
instructions, respectively. As these are privileged instructions, they can be executed only by the operating system. Use of the Linux msr kernel module creates a pseudo file "/dev/cpu/x/msr" (with a unique x for each processor or processor core). A user with permissions to read and/or write to this file can use the file I/O API to access these registers. The msr-tools[3] package provides a reference implementation.
Documentation regarding which MSRs a certain processor implementation supports is usually found in the processor documentation of the CPU vendor. Examples for rather well-known MSRs are the memory type range registers (MTRRs) and the address-range registers (ARRs).
See also
References
- Alan Cruse, [lecture notes, https://www.cs.usfca.edu/~cruse/cs630f06/lesson27.ppt Advanced Microcomputer Programming class] (PowerPoint), University of San Francisco, 2006
- Intel 64 and IA-32 Architectures Software Developer's Manual Volume 3: System Programming Guide, 325384-060US, Section 35.1, September, 2016.
- msr-tools at 01.org