1e085f869SStanislav Sedov.\" Copyright (c) 2006, 2008 Stanislav Sedov <stas@FreeBSD.org>. 2e085f869SStanislav Sedov.\" All rights reserved. 3e085f869SStanislav Sedov.\" 4e085f869SStanislav Sedov.\" Redistribution and use in source and binary forms, with or without 5e085f869SStanislav Sedov.\" modification, are permitted provided that the following conditions 6e085f869SStanislav Sedov.\" are met: 7e085f869SStanislav Sedov.\" 1. Redistributions of source code must retain the above copyright 8e085f869SStanislav Sedov.\" notice, this list of conditions and the following disclaimer. 9e085f869SStanislav Sedov.\" 2. Redistributions in binary form must reproduce the above copyright 10e085f869SStanislav Sedov.\" notice, this list of conditions and the following disclaimer in the 11e085f869SStanislav Sedov.\" documentation and/or other materials provided with the distribution. 12e085f869SStanislav Sedov.\" 13e085f869SStanislav Sedov.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14e085f869SStanislav Sedov.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15e085f869SStanislav Sedov.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16e085f869SStanislav Sedov.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17e085f869SStanislav Sedov.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18e085f869SStanislav Sedov.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19e085f869SStanislav Sedov.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20e085f869SStanislav Sedov.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21e085f869SStanislav Sedov.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22e085f869SStanislav Sedov.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23e085f869SStanislav Sedov.\" SUCH DAMAGE. 24e085f869SStanislav Sedov.\" 25e085f869SStanislav Sedov.\" $FreeBSD$ 26e085f869SStanislav Sedov.\" 270530a936SKonstantin Belousov.Dd January 5, 2018 28e085f869SStanislav Sedov.Dt CPUCONTROL 8 29e085f869SStanislav Sedov.Os 30e085f869SStanislav Sedov.Sh NAME 31e085f869SStanislav Sedov.Nm cpucontrol 32e085f869SStanislav Sedov.Nd control utility for the 33e085f869SStanislav Sedov.Xr cpuctl 4 34344c81a1SWarren Blockdevice 35e085f869SStanislav Sedov.Sh SYNOPSIS 360530a936SKonstantin Belousov.Bk 37*856789c1SKonstantin Belousov.Nm 384b06638fSKonstantin Belousov.Op Fl v 39b2d75854SStanislav Sedov.Fl m Ar msr 40b2d75854SStanislav Sedov.Ar device 41b2d75854SStanislav Sedov.Ek 420530a936SKonstantin Belousov.Bk 43b2d75854SStanislav Sedov.Nm 444b06638fSKonstantin Belousov.Op Fl v 45b2d75854SStanislav Sedov.Fl m Ar msr Ns = Ns Ar value 46b2d75854SStanislav Sedov.Ar device 47b2d75854SStanislav Sedov.Ek 480530a936SKonstantin Belousov.Bk 49b2d75854SStanislav Sedov.Nm 504b06638fSKonstantin Belousov.Op Fl v 51b2d75854SStanislav Sedov.Fl m Ar msr Ns &= Ns Ar mask 52b2d75854SStanislav Sedov.Ar device 53b2d75854SStanislav Sedov.Ek 540530a936SKonstantin Belousov.Bk 55b2d75854SStanislav Sedov.Nm 564b06638fSKonstantin Belousov.Op Fl v 57b2d75854SStanislav Sedov.Fl m Ar msr Ns |= Ns Ar mask 58e085f869SStanislav Sedov.Ar device 59e085f869SStanislav Sedov.Ek 600530a936SKonstantin Belousov.Bk 61e085f869SStanislav Sedov.Nm 624b06638fSKonstantin Belousov.Op Fl v 63e085f869SStanislav Sedov.Fl i Ar level 64e085f869SStanislav Sedov.Ar device 65e085f869SStanislav Sedov.Ek 660530a936SKonstantin Belousov.Bk 67e085f869SStanislav Sedov.Nm 684b06638fSKonstantin Belousov.Op Fl v 69aa1cb750SAttilio Rao.Fl i Ar level,level_type 70aa1cb750SAttilio Rao.Ar device 71aa1cb750SAttilio Rao.Ek 720530a936SKonstantin Belousov.Bk 73aa1cb750SAttilio Rao.Nm 744b06638fSKonstantin Belousov.Op Fl vn 75e085f869SStanislav Sedov.Op Fl d Ar datadir 76e085f869SStanislav Sedov.Fl u 770530a936SKonstantin Belousov.Ar device 780530a936SKonstantin Belousov.Ek 79e085f869SStanislav Sedov.Bk 800530a936SKonstantin Belousov.Nm 810530a936SKonstantin Belousov.Fl e 82e085f869SStanislav Sedov.Ar device 83e085f869SStanislav Sedov.Ek 84e085f869SStanislav Sedov.Sh DESCRIPTION 85e085f869SStanislav SedovThe 86e085f869SStanislav Sedov.Nm 876d850876SChristian Bruefferutility can be used to read and write arbitrary machine-specific 886d850876SChristian BruefferCPU registers via the 89e085f869SStanislav Sedov.Xr cpuctl 4 906d850876SChristian Bruefferspecial device. 916d850876SChristian BruefferIt can also be used to apply CPU firmware updates. 92e085f869SStanislav Sedov.Pp 93e085f869SStanislav SedovThe following options are available: 94e085f869SStanislav Sedov.Bl -tag -width indent 95e085f869SStanislav Sedov.It Fl d Ar datadir 964b06638fSKonstantin BelousovDirectory paths where to look for microcode images. 976d850876SChristian BruefferThe option can be specified multiple times. 984b06638fSKonstantin BelousovThe paths are added in order of the options appearance on the command 994b06638fSKonstantin Belousovline, default directories are appended after the user-supplied paths. 1004b06638fSKonstantin Belousov.It Fl n 1014b06638fSKonstantin BelousovDo not look for the microcode images in the standard directories. 1024b06638fSKonstantin BelousovCurrently standard directory to look for the microcode update files is 1034b06638fSKonstantin Belousov.Pa /usr/local/share/cpucontrol . 10432cb21c9SKonstantin Belousov.It Fl m Ar msr 105b2d75854SStanislav SedovShow value of the specified MSR. 106b2d75854SStanislav SedovMSR register number should be given as a hexadecimal number. 10732cb21c9SKonstantin BelousovThe high word is printed first, then the low word is printed second. 108b2d75854SStanislav Sedov.It Fl m Ar msr Ns = Ns Ar value 109b2d75854SStanislav SedovStore the 110b2d75854SStanislav Sedov.Ar value 111b2d75854SStanislav Sedovin the specified MSR register. 112b2d75854SStanislav SedovThe 113b2d75854SStanislav Sedov.Ar value 114b2d75854SStanislav Sedovargument can be prefixed with ~ operator. 115b2d75854SStanislav SedovIn this case the inverted value of argument will be stored in the register. 116b2d75854SStanislav Sedov.It Fl m Ar msr Ns &= Ns Ar mask 117b2d75854SStanislav SedovStore the result of bitwise AND operation between 118b2d75854SStanislav Sedov.Ar mask 119b2d75854SStanislav Sedovand the current MSR value in the MSR register. 120b2d75854SStanislav SedovThe 121b2d75854SStanislav Sedov.Ar mask 122b2d75854SStanislav Sedovargument can be prefixed with ~ operator. 123b2d75854SStanislav SedovIn this case the inverted value of mask will be used. 124b2d75854SStanislav Sedov.It Fl m Ar msr Ns |= Ns Ar mask 125b2d75854SStanislav SedovStore the result of bitwise OR operation between 126b2d75854SStanislav Sedov.Ar mask 127b2d75854SStanislav Sedovand the current MSR value in the MSR register. 128b2d75854SStanislav SedovThe 129b2d75854SStanislav Sedov.Ar mask 130b2d75854SStanislav Sedovargument can be prefixed with ~ operator. 131b2d75854SStanislav SedovIn this case the inverted value of mask will be used. 132e085f869SStanislav Sedov.It Fl i Ar level 1336d850876SChristian BruefferRetrieve CPUID info. 1346d850876SChristian BruefferLevel should be given as a hex number. 135aa1cb750SAttilio Rao.It Fl i Ar level,level_type 136aa1cb750SAttilio RaoRetrieve CPUID info. 137aa1cb750SAttilio RaoLevel and level_type should be given as hex numbers. 138e085f869SStanislav Sedov.It Fl u 1396d850876SChristian BruefferApply CPU firmware updates. 1406d850876SChristian BruefferThe 141e085f869SStanislav Sedov.Nm 142e085f869SStanislav Sedovutility will walk through the configured data directories 14363a07fdbSStanislav Sedovand apply all firmware updates available for this CPU. 1440530a936SKonstantin Belousov.It Fl e 1450530a936SKonstantin BelousovRe-evaluate the kernel flags indicating the present CPU features. 1460530a936SKonstantin BelousovThis command is typically executed after a firmware update was applied 1470530a936SKonstantin Belousovwhich changes information reported by the 1480530a936SKonstantin Belousov.Dv CPUID 1490530a936SKonstantin Belousovinstruction. 1500530a936SKonstantin Belousov.Pp 1510530a936SKonstantin Belousov.Bf -symbolic 1520530a936SKonstantin BelousovOnly execute the 1530530a936SKonstantin Belousov.Fl e 1540530a936SKonstantin Belousovcommand after the microcode update was applied to all CPUs in the system. 1550530a936SKonstantin BelousovThe kernel does not operate correctly if the features of processors are 1560530a936SKonstantin Belousovnot identical. 1570530a936SKonstantin Belousov.Ef 158e085f869SStanislav Sedov.It Fl v 159e085f869SStanislav SedovIncrease the verbosity level. 160e085f869SStanislav Sedov.It Fl h 161e085f869SStanislav SedovShow help message. 162e085f869SStanislav Sedov.El 163e085f869SStanislav Sedov.Sh EXIT STATUS 1647848de15SDaniel Gerzo.Ex -std 165e085f869SStanislav Sedov.Sh EXAMPLES 166e085f869SStanislav SedovThe command 167e085f869SStanislav Sedov.Pp 168e085f869SStanislav Sedov.Dq Li "cpucontrol -m 0x10 /dev/cpuctl0" 169e085f869SStanislav Sedov.Pp 170e085f869SStanislav Sedovwill read the contents of TSC MSR from CPU 0. 171e085f869SStanislav Sedov.Pp 172e085f869SStanislav SedovTo set the CPU 0 TSC MSR register value to 0x1 issue 173e085f869SStanislav Sedov.Pp 174b2d75854SStanislav Sedov.Dq Li "cpucontrol -m 0x10=0x1 /dev/cpuctl0" . 175b2d75854SStanislav Sedov.Pp 176b2d75854SStanislav SedovThe following command will clear the second bit of TSC register: 177b2d75854SStanislav Sedov.Pp 178b2d75854SStanislav Sedov.Dq Li "cpucontrol -m 0x10&=~0x02 /dev/cpuctl0" . 179b2d75854SStanislav Sedov.Pp 180b2d75854SStanislav SedovThe following command will set the forth and second bit of TSC register: 181b2d75854SStanislav Sedov.Pp 182b2d75854SStanislav Sedov.Dq Li "cpucontrol -m 0x10|=0x0a /dev/cpuctl0" . 183e085f869SStanislav Sedov.Pp 184e085f869SStanislav SedovThe command 185e085f869SStanislav Sedov.Pp 186e085f869SStanislav Sedov.Dq Li "cpucontrol -i 0x1 /dev/cpuctl1" 187e085f869SStanislav Sedov.Pp 188e085f869SStanislav Sedovwill retrieve the CPUID level 0x1 from CPU 1. 189e085f869SStanislav Sedov.Pp 1906d850876SChristian BruefferTo perform firmware updates on CPU 0 from images located at 1914b06638fSKonstantin Belousov.Pa /usr/local/share/cpuctl 192e085f869SStanislav Sedovuse the following command: 193e085f869SStanislav Sedov.Pp 1944b06638fSKonstantin Belousov.Dq Li "cpucontrol -nd /usr/local/share/cpuctl -u /dev/cpuctl0" 195e085f869SStanislav Sedov.Sh SEE ALSO 196e085f869SStanislav Sedov.Xr cpuctl 4 19763a07fdbSStanislav Sedov.Sh HISTORY 19863a07fdbSStanislav SedovThe 19963a07fdbSStanislav Sedov.Nm 20063a07fdbSStanislav Sedovutility first appeared in 2012a72feb4SChristian Brueffer.Fx 7.2 . 202e085f869SStanislav Sedov.Sh AUTHORS 203e085f869SStanislav SedovThe 204e085f869SStanislav Sedov.Nm 205e085f869SStanislav Sedovutility and this manual page was written by 20601c2b8acSBaptiste Daroussin.An Stanislav Sedov Aq Mt stas@FreeBSD.org . 207