- NetBSD Manual Pages
RDMSR(9) NetBSD/x86 Kernel Developer's Manual RDMSR(9)
Powered by man-cgi (2021-03-02).
Maintained for NetBSD
by Kimmo Suominen.
Based on man-cgi by Panagiotis Christias.
msr, rdmsr, rdmsr_safe, wrmsr -- functions for x86 MSRs
rdmsr_safe(u_int msr, uint64_t *valp);
wrmsr(u_int msr, uint64_t val);
The RDMSR instruction reads from a x86 model-specific register (MSR).
Conversely, the WRMSR instruction is used to write to a MSR. In NetBSD
the rdmsr(), rdmsr_safe(), and wrmsr() functions are used to access MSRs.
The header <x86/specialreg.h> includes definitions for some of the com-
monly used MSRs, that is, control registers that are present in some x86
processor models but unavailable in others.
Returns the value read from msr.
The rdmsr_safe() function is a safer variant of rdmsr(). Upon suc-
cessful completion, the function returns zero and the value read
from the register msr is returned in valp. If a fault occurs while
accessing msr, rdmsr_safe() returns EFAULT.
The wrmsr() function writes val to the register msr.
Note that even though rdmsr_safe() provides support for reading MSRs in a
safe manner, it is still a good practice to always verify that the given
model-specific register is present by using the CPUID instruction, avail-
able in NetBSD via x86_cpuid().
NetBSD 9.1 February 17, 2017 NetBSD 9.1