Ravenports generated: 09 Jan 2022 05:44
[ravenports.git] / bucket_CB / devcpu-data
1 # Buildsheet autogenerated by ravenadm tool -- Do not edit.
2
3 NAMEBASE=               devcpu-data
4 VERSION=                20211109
5 KEYWORDS=               sysutils
6 VARIANTS=               standard
7 SDESC[standard]=        AMD and Intel CPUs microcode updates
8 HOMEPAGE=               none
9 CONTACT=                nobody
10
11 DOWNLOAD_GROUPS=        none
12 SPKGS[standard]=        single
13
14 OPTIONS_AVAILABLE=      none
15 OPTIONS_STANDARD=       none
16
17 RUN_DEPENDS=            devcpu-data-intel:single:standard
18                         devcpu-data-amd:single:standard
19
20 FPC_EQUIVALENT=         sysutils/devcpu-data
21
22 SKIP_BUILD=             yes
23
24 SKIP_INSTALL=           yes
25 RC_SUBR=                microcode_update:single
26 SUB_FILES=              pkg-message-single
27 SUB_LIST=               DATADIR="{{PREFIX}}/share/cpucontrol"
28
29 [FILE:154:descriptions/desc.single]
30 This port supplies microcode updates for use with cpuctl(4) microcode
31 update facility.  These could be used to keep your processor's firmware
32 up-to-date.
33
34
35 [FILE:263:distinfo]
36 fd85b6b769efd029dec6a2c07106fd18fb4dcb548b7bc4cde09295a8344ef6d7      4782451 intel-Intel-Linux-Processor-Microcode-Data-Files-microcode-20210608.tar.gz
37 156eef8950f28436e045c1d5ac6e4738d99c07a6737d35bf966901f4b260abb3        28827 amd64-microcode.20191228.tar.xz
38
39
40 [FILE:2458:files/microcode_update.in]
41 #!/bin/sh
42
43 # PROVIDE:      microcode_update
44 # REQUIRE:      root mountcritlocal
45 # KEYWORD:      nojail
46 # BEFORE:       SERVERS
47
48 #
49 # Add the following line to /etc/rc.conf to enable flow-capture:
50 # microcode_update_enable (bool):       Set it to "YES" to update microcode on startup
51 #                                       Set to "NO" by default.
52 # microcode_update_datadir (str):       Directory, microcode updates stored in.
53 #                                       Default is "%%DATADIR%%"
54 # microcode_update_cpus (str):          A list of cpus to update on startup, or "ALL" for all.
55 #                                       Example: microcode_update_cpus="0 1"
56 #                                       Set to "ALL" by default. 
57 # microcode_update_flags (str):         Flags for cpucontrol(8).
58
59 . /etc/rc.subr
60
61 name="microcode_update"
62 rcvar=microcode_update_enable
63 stop_cmd=":"
64 start_precmd="microcode_update_prepare"
65 start_cmd="microcode_update_start"
66 requires_modules="cpuctl"
67
68 CMT="/usr/sbin/cpucontrol"
69
70 microcode_update_prepare()
71 {
72         if ! kldstat -q -m cpuctl; then
73                 if ! kldload cpuctl > /dev/null 2>&1; then
74                         warn "Can't load cpuctl module."
75                         return 1
76                 fi
77         fi
78 }
79
80 microcode_update_start()
81 {
82         echo "Updating CPU Microcode..."
83         if [ "${microcode_update_cpus}" = "ALL" ]; then
84                 ncpu=`/sbin/sysctl -n hw.ncpu`
85                 cpus=`jot ${ncpu} 0`;
86         else
87                 cpus=${microcode_update_cpus}
88         fi
89         for i in ${cpus}; do
90                 ${CMT} -u ${microcode_update_flags} \
91                     -d "${microcode_update_datadir}" /dev/cpuctl${i} 2>&1 | \
92                     logger -p daemon.notice -t microcode_update || \
93                     (echo "Microcode Update Failed." && exit 1)
94         done
95         if [ "${microcode_update_cpus}" = "ALL" ]; then
96                 CPUCONTROL_UPDATED=$(cpucontrol -h 2>&1 | grep -q -- -e; echo $?)
97                 if [ ${CPUCONTROL_UPDATED} -ne 0 ]; then
98                         echo "Please update your system in order to update CPU microcode."
99                 else
100                         ${CMT} -e /dev/cpuctl0 >/dev/null 2>&1
101                         if [ $? -ne 0 ]; then
102                                 echo "Re-evalulation of CPU flags Failed."
103                                 exit 1
104                         fi
105                 fi
106         fi
107         echo "Done."
108 }
109
110 load_rc_config $name
111
112 # Set default values
113 if [ -n "${microcode_cpus}" ]; then
114         if [ -n "${microcode_update_cpus}" ]; then
115                 echo "Warning: Ignoring deprecated rc variable, microcode_cpus."
116         else
117                 echo "Warning: rc variable microcode_cpus is deprecated.
118 Warning: Set microcode_udpate_cpus instead."
119                 microcode_update_cpus="${microcode_cpus}"
120         fi
121 fi
122
123 : ${microcode_update_enable="NO"}
124 : ${microcode_update_datadir="%%DATADIR%%"}
125 : ${microcode_update_cpus="ALL"}
126 : ${microcode_update_flags=""}
127
128 run_rc_command "$1"
129
130
131 [FILE:1638:files/pkg-message-single.in]
132 This port includes an RC script, which is one of two methods to update the
133 CPU microcode on a FreeBSD system.
134
135 1. The first method, which does not require the RC script included in this
136    port is currently only supported on FreeBSD 12.0 or later and Intel i386
137    and amd64 processors.  It is the preferred method when available because
138    it ensures that any CPU features introduced by a microcode update are
139    visible to the kernel by applying the update before the kernel performs
140    CPU feature detection.
141
142    To enable updates using the first method, add the following lines to
143    /boot/loader.conf:
144
145    cpu_microcode_load="YES"
146    cpu_microcode_name="/boot/firmware/intel-ucode.bin"
147
148    The microcode update will be loaded when the system is rebooted.
149
150
151 2. The second method, which uses the RC script included in this port can
152    be enabled by adding the following line to /etc/rc.conf:
153
154    microcode_update_enable="YES"
155
156    The microcode update is then applied upon reboot or when the microcode
157    update service is run via:
158
159    # service microcode_update start
160
161    If the CPU requires a microcode update, a console message such as the
162    following will appear:
163
164    Updating CPU Microcode...
165    %%DATADIR%%/m32306c3_00000022.fw: updating cpu /dev/cpuctl0 from rev 0x17 to rev 0x22... done.
166    %%DATADIR%%/m32306c3_00000022.fw: updating cpu /dev/cpuctl2 from rev 0x17 to rev 0x22... done.
167    %%DATADIR%%/m32306c3_00000022.fw: updating cpu /dev/cpuctl4 from rev 0x17 to rev 0x22... done.
168    %%DATADIR%%/m32306c3_00000022.fw: updating cpu /dev/cpuctl6 from rev 0x17 to rev 0x22... done.
169    Done.
170
171 It is safe to enable both methods.
172