Run cpucontrol -e after microcode update to refresh cpu flags. If running on an older system without -e, fail silently. Log any upgrade output via logger to /var/log/messages. Add an instructional pkg-message for users. Intel Release Notes: Intel Processor Microcode Package for Linux 20180108 Release -- Updates upon 20171117 release -- IVT C0 (06-3e-04:ed) 428->42a SKL-U/Y D0 (06-4e-03:c0) ba->c2 BDW-U/Y E/F (06-3d-04:c0) 25->28 HSW-ULT Cx/Dx (06-45-01:72) 20->21 Crystalwell Cx (06-46-01:32) 17->18 BDW-H E/G (06-47-01:22) 17->1b HSX-EX E0 (06-3f-04:80) 0f->10 SKL-H/S R0 (06-5e-03:36) ba->c2 HSW Cx/Dx (06-3c-03:32) 22->23 HSX C0 (06-3f-02:6f) 3a->3b BDX-DE V0/V1 (06-56-02:10) 0f->14 BDX-DE V2 (06-56-03:10) 700000d->7000011 KBL-U/Y H0 (06-8e-09:c0) 62->80 KBL Y0 / CFL D0 (06-8e-0a:c0) 70->80 KBL-H/S B0 (06-9e-09:2a) 5e->80 CFL U0 (06-9e-0a:22) 70->80 CFL B0 (06-9e-0b:02) 72->80 SKX H0 (06-55-04:b7) 2000035->200003c GLK B0 (06-7a-01:01) 1e->22 Reviewed by: A bunch of folks on the review MFH: 2018Q1 Sponsored by: Limelight Networks Differential Revision: https://reviews.freebsd.org/D13815
79 lines
1.9 KiB
Bash
79 lines
1.9 KiB
Bash
#!/bin/sh
|
|
#
|
|
# $FreeBSD$
|
|
#
|
|
|
|
# PROVIDE: microcode_update
|
|
# REQUIRE: root mountcritlocal
|
|
# KEYWORD: nojail
|
|
# BEFORE: SERVERS
|
|
|
|
#
|
|
# Add the following line to /etc/rc.conf to enable flow-capture:
|
|
# microcode_update_enable (bool): Set it to "YES" to update microcode on startup
|
|
# Set to "NO" by default.
|
|
# microcode_update_datadir (str): Directory, microcode updates stored in.
|
|
# Default is "%%DATADIR%%"
|
|
# microcode_update_cpus (str): A list of cpus to update on startup, or "ALL" for all.
|
|
# Example: microcode_update_cpus_cpus="0 CPU0"
|
|
# Set to "ALL" by default.
|
|
# microcode_update_flags (str): Flags for cpucontrol(8).
|
|
|
|
. /etc/rc.subr
|
|
|
|
name="microcode_update"
|
|
rcvar=microcode_update_enable
|
|
stop_cmd=":"
|
|
start_precmd="microcode_update_prepare"
|
|
start_cmd="microcode_update_start"
|
|
requires_modules="cpuctl"
|
|
|
|
CMT="/usr/sbin/cpucontrol"
|
|
|
|
microcode_update_prepare()
|
|
{
|
|
if ! kldstat -q -m cpuctl; then
|
|
if ! kldload cpuctl > /dev/null 2>&1; then
|
|
warn "Can't load cpuctl module."
|
|
return 1
|
|
fi
|
|
fi
|
|
}
|
|
|
|
microcode_update_start()
|
|
{
|
|
echo "Updating CPU Microcode..."
|
|
if [ "${microcode_cpus}" = "ALL" ]; then
|
|
ncpu=`/sbin/sysctl -n hw.ncpu`
|
|
cpus=`jot ${ncpu} 0`;
|
|
else
|
|
cpus=${microcode_cpus}
|
|
fi
|
|
for i in ${cpus}; do
|
|
${CMT} -u ${microcode_update_flags} \
|
|
-d "${microcode_update_datadir}" /dev/cpuctl${i} 2>&1 | \
|
|
logger -p daemon.notice -t microcode_update || \
|
|
(echo "Microcode Update Failed." && exit 1)
|
|
done
|
|
if [ "${microcode_cpus}" = "ALL" ]; then
|
|
for i in ${cpus}; do
|
|
${CMT} -e /dev/cpuctl${i} >/dev/null 2>&1
|
|
if [ $? -ne 0 ]; then
|
|
echo "Re-evalutation of CPU flags Failed."
|
|
exit 1
|
|
fi
|
|
done
|
|
fi
|
|
echo "Done."
|
|
}
|
|
|
|
load_rc_config $name
|
|
|
|
# Set default values
|
|
: ${microcode_update_enable="NO"}
|
|
: ${microcode_update_datadir="%%DATADIR%%"}
|
|
: ${microcode_cpus="ALL"}
|
|
: ${microcode_update_flags=""}
|
|
|
|
run_rc_command "$1"
|