summaryrefslogtreecommitdiffstats
path: root/usr.sbin/cpucontrol/cpucontrol.8
blob: 4e54bb51bafcee87a156c8d3939910284ec7f5ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
.\" Copyright (c) 2006, 2008 Stanislav Sedov <stas@FreeBSD.org>.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD$
.\"
.Dd January 5, 2018
.Dt CPUCONTROL 8
.Os
.Sh NAME
.Nm cpucontrol
.Nd control utility for the
.Xr cpuctl 4
device
.Sh SYNOPSIS
.Nm
.Bk
.Op Fl v
.Fl m Ar msr
.Ar device
.Ek
.Bk
.Nm
.Op Fl v
.Fl m Ar msr Ns = Ns Ar value
.Ar device
.Ek
.Bk
.Nm
.Op Fl v
.Fl m Ar msr Ns &= Ns Ar mask
.Ar device
.Ek
.Bk
.Nm
.Op Fl v
.Fl m Ar msr Ns |= Ns Ar mask
.Ar device
.Ek
.Bk
.Nm
.Op Fl v
.Fl i Ar level
.Ar device
.Ek
.Bk
.Nm
.Op Fl v
.Fl i Ar level,level_type
.Ar device
.Ek
.Bk
.Nm
.Op Fl vn
.Op Fl d Ar datadir
.Fl u
.Ar device
.Ek
.Bk
.Nm
.Fl e
.Ar device
.Ek
.Sh DESCRIPTION
The
.Nm
utility can be used to read and write arbitrary machine-specific
CPU registers via the
.Xr cpuctl 4
special device.
It can also be used to apply CPU firmware updates.
.Pp
The following options are available:
.Bl -tag -width indent
.It Fl d Ar datadir
Directory paths where to look for microcode images.
The option can be specified multiple times.
The paths are added in order of the options appearance on the command
line, default directories are appended after the user-supplied paths.
.It Fl n
Do not look for the microcode images in the standard directories.
Currently standard directory to look for the microcode update files is
.Pa /usr/local/share/cpucontrol .
.It Fl m Ar msr
Show value of the specified MSR.
MSR register number should be given as a hexadecimal number.
The high word is printed first, then the low word is printed second.
.It Fl m Ar msr Ns = Ns Ar value
Store the
.Ar value
in the specified MSR register.
The
.Ar value
argument can be prefixed with ~ operator.
In this case the inverted value of argument will be stored in the register.
.It Fl m Ar msr Ns &= Ns Ar mask
Store the result of bitwise AND operation between
.Ar mask
and the current MSR value in the MSR register.
The
.Ar mask
argument can be prefixed with ~ operator.
In this case the inverted value of mask will be used.
.It Fl m Ar msr Ns |= Ns Ar mask
Store the result of bitwise OR operation between
.Ar mask
and the current MSR value in the MSR register.
The
.Ar mask
argument can be prefixed with ~ operator.
In this case the inverted value of mask will be used.
.It Fl i Ar level
Retrieve CPUID info.
Level should be given as a hex number.
.It Fl i Ar level,level_type
Retrieve CPUID info.
Level and level_type should be given as hex numbers.
.It Fl u
Apply CPU firmware updates.
The
.Nm
utility will walk through the configured data directories
and apply all firmware updates available for this CPU.
.It Fl e
Re-evaluate the kernel flags indicating the present CPU features.
This command is typically executed after a firmware update was applied
which changes information reported by the
.Dv CPUID
instruction.
.Pp
.Bf -symbolic
Only execute the
.Fl e
command after the microcode update was applied to all CPUs in the system.
The kernel does not operate correctly if the features of processors are
not identical.
.Ef
.It Fl v
Increase the verbosity level.
.It Fl h
Show help message.
.El
.Sh EXIT STATUS
.Ex -std
.Sh EXAMPLES
The command
.Pp
.Dq Li "cpucontrol -m 0x10 /dev/cpuctl0"
.Pp
will read the contents of TSC MSR from CPU 0.
.Pp
To set the CPU 0 TSC MSR register value to 0x1 issue
.Pp
.Dq Li "cpucontrol -m 0x10=0x1 /dev/cpuctl0" .
.Pp
The following command will clear the second bit of TSC register:
.Pp
.Dq Li "cpucontrol -m 0x10&=~0x02 /dev/cpuctl0" .
.Pp
The following command will set the forth and second bit of TSC register:
.Pp
.Dq Li "cpucontrol -m 0x10|=0x0a /dev/cpuctl0" .
.Pp
The command
.Pp
.Dq Li "cpucontrol -i 0x1 /dev/cpuctl1"
.Pp
will retrieve the CPUID level 0x1 from CPU 1.
.Pp
To perform firmware updates on CPU 0 from images located at
.Pa /usr/local/share/cpuctl
use the following command:
.Pp
.Dq Li "cpucontrol -nd /usr/local/share/cpuctl -u /dev/cpuctl0"
.Sh SEE ALSO
.Xr cpuctl 4
.Sh HISTORY
The
.Nm
utility first appeared in
.Fx 7.2 .
.Sh AUTHORS
The
.Nm
utility and this manual page was written by
.An Stanislav Sedov Aq Mt stas@FreeBSD.org .
OpenPOWER on IntegriCloud