1 # Buildsheet autogenerated by ravenadm tool -- Do not edit.
3 NAMEBASE= cpu-microcode-rc
7 SDESC[standard]= RC script for CPU microcode updates
12 SPKGS[standard]= single
14 OPTIONS_AVAILABLE= none
15 OPTIONS_STANDARD= none
19 FPC_EQUIVALENT= sysutils/cpu-microcode-rc
24 RC_SUBR= microcode_update:single
25 SUB_FILES= pkg-message-single
26 SUB_LIST= DATADIR="{{PREFIX}}/share/cpucontrol"
28 [FILE:215:descriptions/desc.single]
29 An RC script for use with the cpuctl(4) microcode update facility to keep
30 your processor's firmware up-to-date. CPU microcode data must be installed
31 from a vendor. See devcpu-data-amd and devcpu-data-intel ports.
34 [FILE:2251:files/microcode_update.in]
37 # PROVIDE: microcode_update
38 # REQUIRE: root mountcritlocal
43 # Add the following line to /etc/rc.conf to enable flow-capture:
44 # microcode_update_enable (bool): Set it to "YES" to update microcode on startup
45 # Set to "NO" by default.
46 # microcode_update_datadir (str): Directory, microcode updates stored in.
47 # Default is "%%DATADIR%%"
48 # microcode_update_cpus (str): A list of cpus to update on startup, or "ALL" for all.
49 # Example: microcode_update_cpus="0 1"
50 # Set to "ALL" by default.
51 # microcode_update_flags (str): Flags for cpucontrol(8).
55 name="microcode_update"
56 rcvar=microcode_update_enable
58 start_cmd="microcode_update_start"
59 required_modules="cpuctl"
61 CMT="/usr/sbin/cpucontrol"
63 microcode_update_start()
65 echo "Updating CPU Microcode..."
66 if [ "${microcode_update_cpus}" = "ALL" ]; then
67 ncpu=`/sbin/sysctl -n hw.ncpu`
70 cpus=${microcode_update_cpus}
73 ${CMT} -u ${microcode_update_flags} \
74 -d "${microcode_update_datadir}" /dev/cpuctl${i} 2>&1 | \
75 logger -p daemon.notice -t microcode_update || \
76 (echo "Microcode Update Failed." && exit 1)
78 if [ "${microcode_update_cpus}" = "ALL" ]; then
79 CPUCONTROL_UPDATED=$(cpucontrol -h 2>&1 | grep -q -- -e; echo $?)
80 if [ ${CPUCONTROL_UPDATED} -ne 0 ]; then
81 echo "Please update your system in order to update CPU microcode."
83 ${CMT} -e /dev/cpuctl0 >/dev/null 2>&1
85 echo "Re-evalulation of CPU flags Failed."
96 if [ -n "${microcode_cpus}" ]; then
97 if [ -n "${microcode_update_cpus}" ]; then
98 echo "Warning: Ignoring deprecated rc variable, microcode_cpus."
100 echo "Warning: rc variable microcode_cpus is deprecated.
101 Warning: Set microcode_udpate_cpus instead."
102 microcode_update_cpus="${microcode_cpus}"
106 : ${microcode_update_enable="NO"}
107 : ${microcode_update_datadir="%%DATADIR%%"}
108 : ${microcode_update_cpus="ALL"}
109 : ${microcode_update_flags=""}
114 [FILE:1554:files/pkg-message-single.in]
115 This port includes an RC script, which is one of two methods to update
116 the CPU microcode on a FreeBSD system.
118 1. The first method does not require the RC script included here and is
119 only supported with Intel processors. It is the preferred method,
120 because it ensures that any CPU features introduced by a microcode
121 update are visible to the kernel by applying the update before the
122 kernel performs CPU feature detection.
124 To enable updates using the first method, add the following lines to
127 cpu_microcode_load="YES"
128 cpu_microcode_name="/boot/firmware/intel-ucode.bin"
130 The microcode update will be loaded when the system is rebooted.
133 2. The second method, which uses the RC script included here, can be
134 enabled by adding the following line to /etc/rc.conf:
136 microcode_update_enable="YES"
138 The microcode update is then applied upon reboot or when the microcode
139 update service is run via:
141 # service microcode_update start
143 If the CPU requires a microcode update, a console message such as the
144 following will appear:
146 Updating CPU Microcode...
147 %%DATADIR%%/m32306c3_00000022.fw: updating cpu /dev/cpuctl0 from rev 0x17 to rev 0x22... done.
148 %%DATADIR%%/m32306c3_00000022.fw: updating cpu /dev/cpuctl2 from rev 0x17 to rev 0x22... done.
149 %%DATADIR%%/m32306c3_00000022.fw: updating cpu /dev/cpuctl4 from rev 0x17 to rev 0x22... done.
150 %%DATADIR%%/m32306c3_00000022.fw: updating cpu /dev/cpuctl6 from rev 0x17 to rev 0x22... done.
153 It is safe to enable both methods.