History log of /freebsd-current/usr.sbin/cpucontrol/cpucontrol.c
Revision Date Author Comments
# 1d386b48 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 4d846d26 10-May-2023 Warner Losh <imp@FreeBSD.org>

spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix


# 1f474190 27-Oct-2020 Stefan Eßer <se@FreeBSD.org>

Replace literal uses of /usr/local in C sources with _PATH_LOCALBASE

Literal references to /usr/local exist in a large number of files in
the FreeBSD base system. Many are in contributed software, in configuration
files, or in the documentation, but 19 uses have been identified in C
source files or headers outside the contrib and sys/contrib directories.

This commit makes it possible to set _PATH_LOCALBASE in paths.h to use
a different prefix for locally installed software.

In order to avoid changes to openssh source files, LOCALBASE is passed to
the build via Makefiles under src/secure. While _PATH_LOCALBASE could have
been used here, there is precedent in the construction of the path used to
a xauth program which depends on the LOCALBASE value passed on the compiler
command line to select a non-default directory.

This could be changed in a later commit to make the openssh build
consistently use _PATH_LOCALBASE. It is considered out-of-scope for this
commit.

Reviewed by: imp
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D26942


# 7672c254 13-Nov-2019 Konstantin Belousov <kib@FreeBSD.org>

cpucontrol: print more useful information when MSR access fails.

Instead of providing ioctl cmd value, which has no meaning to user,
print MSR number. The later is what the user expects in this place
even.

Reported by: pstef
Sponsored by: The FreeBSD Foundation
MFC after: 3 days


# e4e0dad4 11-Jan-2019 Konstantin Belousov <kib@FreeBSD.org>

cpucontrol: check for the supposed firmware file type and skip
non-regular entry.

do_update() skips entries with DT_DIR type. This does not eliminate
other entries that might exist in the directory. More, since NFS
might fill d_type with DT_UNKNOWN, dot and dotdot entries are not
skipped, then mmap(2) call failed for them when update microcode files
are located on NFS.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week


# dee401e8 13-Nov-2018 Conrad Meyer <cem@FreeBSD.org>

cpucontrol(8): De-duplicate common update logic

Every µcode-updater must open the cpucontrol devfs node RDWR, open a
firmware file, validate the FW file has a positive length, mmap it, etc.
De-duplicate that identical logic between every individual platform.

Also, constify references to the readonly-mapped firmware files while here.

Sponsored by: Dell EMC Isilon


# 0530a936 05-Jan-2018 Konstantin Belousov <kib@FreeBSD.org>

Make it possible to re-evaluate cpu_features.

Add cpuctl(4) ioctl CPUCTL_EVAL_CPU_FEATURES which forces re-read of
cpu_features, cpu_features2, cpu_stdext_features, and
std_stdext_features2.

The intent is to allow the kernel to see the changes in the CPU
features after micocode update. Of course, the update is not atomic
across variables and not synchronized with readers. See the man page
warning as well.

Reviewed by: imp (previous version), jilles
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D13770


# 1de7b4b8 27-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

various: general adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

No functional change intended.


# 0539c173 30-Sep-2017 Konstantin Belousov <kib@FreeBSD.org>

Allow to disable default microcode updates search path with the new
'-n' option.

Look for updates in the default locations only after user-supplied
locations are tried.

If newer microcode files are put into non-standard path, both measures
allow to avoid situation where older update loaded from the default
path first, and then the second update is applied from non-standard
path. Applying intermediate updates might be undesirable.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week


# 0112b52b 02-Nov-2016 Andriy Gapon <avg@FreeBSD.org>

Add support for microcode update on newer AMD CPUs (10h+)

This includes new code for parsing microcode files as well as
the kernel-side change to apply the update on all processors
at the same time.

Developed with help from Borislav Petkov, formerly bp@amd64.org.

Tested using Athlon II X2 processor on a system where BIOS does
not have the latest microcode version:
/boot/firmware/microcode_amd.bin: updating cpu /dev/cpuctl0 to revision 0x10000c7... done.

The microcode file is taken from here:
https://web.archive.org/web/20160528230514/http://www.amd64.org/microcode.html
(note that the original site seems to be down at the moment)
It can also be found here:
https://git.kernel.org/cgit/linux/kernel/git/firmware/linux-firmware.git/tree/amd-ucode

Reviewed by: kib, stas
MFC after: 2 weeks
Relnotes: maybe
Differential Revision: https://reviews.freebsd.org/D8384


# 78a6a430 15-Jun-2016 Konstantin Belousov <kib@FreeBSD.org>

Return usual error indicator to shell.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Approved by: re (hrs)


# cef789cd 20-Jun-2014 Konstantin Belousov <kib@FreeBSD.org>

Restore the ABI of the cpuctl(4) ioctl request CPUCTL_CPUID, use
separate argument structure with added level_type field for
CPUID_CPUID_COUNT request.

Reviewed by: attilio (previous version)
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks


# aa1cb750 19-Jun-2014 Attilio Rao <attilio@FreeBSD.org>

Following comments in r242565 add the possibility to specify ecx when
performing cpuid calls.
Add also a new way to specify the level type to cpucontrol(8) as
reported in the manpage.

Sponsored by: EMC / Isilon storage division
Reviewed by: bdrewery, gcooper
Testerd by: bdrewery


# bf70bece 19-Oct-2012 Ed Schouten <ed@FreeBSD.org>

More -Wmissing-variable-declarations fixes.

In addition to adding `static' where possible:

- bin/date: Move `retval' into extern.h to make it visible to date.c.
- bin/ed: Move globally used variables into ed.h.
- sbin/camcontrol: Move `verbose' into camcontrol.h and fix shadow warnings.
- usr.bin/calendar: Remove unneeded variables.
- usr.bin/chat: Make `line' local instead of global.
- usr.bin/elfdump: Comment out unneeded function.
- usr.bin/rlogin: Use _Noreturn instead of __dead2.
- usr.bin/tset: Pull `Ospeed' into extern.h.
- usr.sbin/mfiutil: Put global variables in mfiutil.h.
- usr.sbin/pkg: Remove unused `os_corres'.
- usr.sbin/quotaon, usr.sbin/repquota: Remove unused `qfname'.


# 0bb2aabf 18-May-2012 Gleb Kurtsou <gleb@FreeBSD.org>

Hide DIR definition by making it an opaque struct typedef.

Introduce dirfd() libc exported symbol replacing macro with same name,
preserve _dirfd() macro for internal use.

Replace dirp->dd_fd with dirfd() call. Avoid using dirfd as variable
name to prevent shadowing global symbol.

Sponsored by: Google Summer Of Code 2011


# 96ff3b75 11-Dec-2011 Fabien Thomas <fabient@FreeBSD.org>

Add VIA microde update support to cpuctl(4) and cpucontrol(8).

Support have been tested with X2 CPU and QuadCore CPU.

MFC after: 1 month


# 3b232eb6 07-Jan-2011 Stanislav Sedov <stas@FreeBSD.org>

- Save some space relying on the fact that all ioctl commands
prefixes are the same.

Suggested by: "Carlos A. M. dos Santos" <unixmania@gmail.com>


# f264409a 06-Jan-2011 Stanislav Sedov <stas@FreeBSD.org>

- Show textual representation of ioctl command in warning message
if ioctl(4) is failed besides the command number.

Suggested by: delphij
MFC after: 2 weeks


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# fe0506d7 09-Mar-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Create the altix project branch. The altix project will add support
for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting
is a two-module system, consisting of a base compute module and a
CPU expansion module. SGI's NUMAFlex architecture can be an excellent
platform to test CPU affinity and NUMA-aware features in FreeBSD.


# e2b36efd 29-Jan-2010 Antoine Brodin <antoine@FreeBSD.org>

MFC r201145 to stable/8:
(S)LIST_HEAD_INITIALIZER takes a (S)LIST_HEAD as an argument.
Fix some wrong usages.
Note: this does not affect generated binaries as this argument is not used.

PR: 137213
Submitted by: Eygene Ryabinkin (initial version)


# 10bc3a7f 29-Dec-2009 Ed Schouten <ed@FreeBSD.org>

ANSIfy almost all applications that use WARNS=6.

I was considering committing all these patches one by one, but as
discussed with brooks@, there is no need to do this. If we ever
need/want to merge these changes back, it is still possible to do this
per application.


# 13e403fd 28-Dec-2009 Antoine Brodin <antoine@FreeBSD.org>

(S)LIST_HEAD_INITIALIZER takes a (S)LIST_HEAD as an argument.
Fix some wrong usages.
Note: this does not affect generated binaries as this argument is not used.

PR: 137213
Submitted by: Eygene Ryabinkin (initial version)
MFC after: 1 month


# b2d75854 29-Jun-2009 Stanislav Sedov <stas@FreeBSD.org>

- Add support to atomically set/clear individual bits of a MSR register
via cpuctl(4) driver. Two new CPUCTL_MSRSBIT and CPUCTL_MSRCBIT ioctl(2)
calls treat the data field of the argument struct passed as a mask
and set/clear bits of the MSR register according to the mask value.
- Allow user to perform atomic bitwise AND and OR operaions on MSR registers
via cpucontrol(8) utility. Two new operations ("&=" and "|=") have been
added. The first one applies bitwise AND operaion between the current
contents of the MSR register and the mask, and the second performs bitwise
OR. The argument can be optionally prefixed with "~" inversion operator.
This allows one to mimic the "clear bit" behavior by using the command
like this:
cpucontrol -m 0x10&=~0x02 # clear the second bit of TSC MSR

Inversion operator support in all modes (assignment, OR, AND).

Approved by: re (kib)
MFC after: 1 month


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# cbcc5579 12-Aug-2008 Stanislav Sedov <stas@FreeBSD.org>

- Fix error reporting.

Approved by: kib


# e085f869 08-Aug-2008 Stanislav Sedov <stas@FreeBSD.org>

- Add cpuctl(4) pseudo-device driver to provide access to some low-level
features of CPUs like reading/writing machine-specific registers,
retrieving cpuid data, and updating microcode.
- Add cpucontrol(8) utility, that provides userland access to
the features of cpuctl(4).
- Add subsequent manpages.

The cpuctl(4) device operates as follows. The pseudo-device node cpuctlX
is created for each cpu present in the systems. The pseudo-device minor
number corresponds to the cpu number in the system. The cpuctl(4) pseudo-
device allows a number of ioctl to be preformed, namely RDMSR/WRMSR/CPUID
and UPDATE. The first pair alows the caller to read/write machine-specific
registers from the correspondent CPU. cpuid data could be retrieved using
the CPUID call, and microcode updates are applied via UPDATE.

The permissions are inforced based on the pseudo-device file permissions.
RDMSR/CPUID will be allowed when the caller has read access to the device
node, while WRMSR/UPDATE will be granted only when the node is opened
for writing. There're also a number of priv(9) checks.

The cpucontrol(8) utility is intened to provide userland access to
the cpuctl(4) device features. The utility also allows one to apply
cpu microcode updates.

Currently only Intel and AMD cpus are supported and were tested.

Approved by: kib
Reviewed by: rpaulo, cokane, Peter Jeremy
MFC after: 1 month