| RDMSR(9) | Kernel Developer's Manual (x86) | RDMSR(9) |
msr, rdmsr,
rdmsr_safe, wrmsr —
functions for x86 MSRs
#include
<x86/cpufunc.h>
uint64_t
rdmsr(u_int
msr);
int
rdmsr_safe(u_int
msr, uint64_t
*valp);
void
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 commonly used MSRs, that is, control registers
that are present in some x86 processor models but unavailable in others.
rdmsr(msr)rdmsr_safe(msr,
valp)rdmsr_safe() function is a safer variant of
rdmsr(). Upon successful 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.wrmsr(msr,
val)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,
available in NetBSD via
x86_cpuid().
| February 17, 2017 | NetBSD 11.0 |