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