Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-firmware/intel-microcode/
Date: Mon, 02 May 2022 20:46:24
Message-Id: 1651524365.6251af7a0987db60a64e6b6c9871a9a7ca0bc94f.mpagano@gentoo
1 commit: 6251af7a0987db60a64e6b6c9871a9a7ca0bc94f
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Mon May 2 20:46:05 2022 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Mon May 2 20:46:05 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=6251af7a
7
8 sys-firmware/intel-microcode: add 20220419_p20220421
9
10 Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org>
11
12 sys-firmware/intel-microcode/Manifest | 2 +
13 .../intel-microcode-20220419_p20220421.ebuild | 263 +++++++++++++++++++++
14 2 files changed, 265 insertions(+)
15
16 diff --git a/sys-firmware/intel-microcode/Manifest b/sys-firmware/intel-microcode/Manifest
17 index 1713042146b2..95a4de19db6b 100644
18 --- a/sys-firmware/intel-microcode/Manifest
19 +++ b/sys-firmware/intel-microcode/Manifest
20 @@ -4,8 +4,10 @@ DIST intel-microcode-collection-20210514.tar.xz 7907672 BLAKE2B d5226008e50e804c
21 DIST intel-microcode-collection-20210608.tar.xz 8012692 BLAKE2B 98df9d18658bfdf06ac7db84ac30707fe8834874583b324ebc882b514975d71b686788fcd1c9b9c5b05448403b27524e29a94ade34facdffb1645333059019a9 SHA512 7fd810cf05334f6442b9a0c77aef5319d3e2006e887d0354dee952647ded3fa6331a30192abf82eda0676af0439b40f5e3ab0210611f96c78fe52f01f106c5d4
22 DIST intel-microcode-collection-20210830.tar.xz 8681768 BLAKE2B 84f098285ed0b79b953e1f54b9ca077e42e7a2b6b28e862dddcb23a546ebebdd5afb9e54215b6c6493b72bf82121ace4b06f759413d3745571ff8156db52d6b1 SHA512 8a6a7376524888b0e89f9fd9a592d52a3859f4ddf1d961484b60d77098faa6984c5e8efc9cf4258a943cfc2c3503dbb87989868962a7ad8028c391d897e212b6
23 DIST intel-microcode-collection-20220207.tar.xz 9362888 BLAKE2B 9efb2a943bffc1d702675c4ca5d17b6bc7f5bf5688fb1979caadbf96c516c31c3e1894823aaa16dbdb8c778c933eaf49dec6f2d416483d11e58ed1e75823cef8 SHA512 72458aa64c05ceb8bb21b296da5ad15230af3e6ac63240a10370fadec09523cf7ebefaaddce2b31e2c16570c2700a875cccf86fd1770046ff36cc30eb594f041
24 +DIST intel-microcode-collection-20220421.tar.xz 9442704 BLAKE2B 9c0d682d4ae07c6c40b7638cd53e559f0d5b672f40676a3fc478d07ac5772f350da777c20f821ed5a0907ba31800874cd15553fcdbdae319e77e17961cf49f9f SHA512 a7b5ef78618a27c6065a78d5302d19f846feb71bc09cc0359342d1f31f1f793242982bc384227b0e59a4b7f246cb9f4aaa2350ad0a4fe1a23ce3504e59b0d2c2
25 DIST intel-ucode-sig_0x406e3-rev_0xd6.bin 101376 BLAKE2B 66d55867954d69dda1425febd93bb8c89f7aa836d504f8b5fee127f8505bcf2246f4fcc55cc245bc5e532528d60cca2eee278de7ab5174dc2862db7982a2b36f SHA512 248066b521bf512b5d8e4a8c7e921464ce52169c954d6e4ca580d8c172cd789519e22b4cf56c212e452b4191741f0202019f7061d322c9433b5af9ce5413b567
26 DIST microcode-20201112.tar.gz 3610834 BLAKE2B 4212924f1673afded961266a25fe6063ec6cdafaa26c8bee1c42372eb8ab5f278dc2501615b23e09e2f9809bf2792a8db317c98c170bf0c5e1dd62b7dc80a084 SHA512 0875675d065a83ee14fa34a31022ee34e46aee579d1ff192414e79861af157ae269ca7c2c462f03b3accbd45590c76e5cbf4f53d7a6ed237e410213a96459211
27 DIST microcode-20210216.tar.gz 3506111 BLAKE2B e09ab59dcccc77c15545b119dcf5309e626d53649a601c49fc7d6a65d774b8016d9ad44783f75ceb4bf384a03b909bc28693ed2be9f047029342dca9beae9cae SHA512 211ed90a248c891224bb8c569e24c04410d3f67ecc6daee41dc025042bd51c257baaba0da1ac5327df76352d2b53d812e81f06cc8726e43b95ea2f8898bc00bf
28 DIST microcode-20210608.tar.gz 4782451 BLAKE2B 2eac43aaa7832365e428bf2de20797ef42293a53087545920d205bd3b11a3d8ca2afb33931af5d36b8f3a224b9c22ed89ff828acc8afdcfa1b8220884c55ae89 SHA512 61acd2e76aa019fa0002fbf56c503791080a937ff93d81e020f8f0cc089dc08928b4c7e9884f713b886e2f9d4a8409fea59e39f628ef534a588515e1c3fc861d
29 DIST microcode-20220207.tar.gz 4590237 BLAKE2B 8c47a330794615b6684084976b6bb9e8800cd2869f81ecc33b28b54441b220a645502c0ade0cbd58e91879a652ff6bca181800004de477fc74033413ea4b1c8f SHA512 efa9f80815947cf2be371e7da7185634cbacefe779d1d6dfef0c15b78ccae7d2740ea6681b967a19dfbcc3014edce5bcdcdba87c9dea1f19d0415a03fca9e936
30 +DIST microcode-20220419.tar.gz 4590171 BLAKE2B 69d296efad5329324a47640eace5d1a10e38b85cb8b7ac5baa9f14c40391ff809ae17cb7814f99f2e43910fe4c4b02dc77ffea7bb5f2b58069b2c17029e9f76a SHA512 abfe3942c204e42ed121bcea47c366469013a6751ef5d28d9c0d59a3a660bd1ad7010441e000367c052ee1ead00285a252d2b3c3ca86314eaea9f7d0de3f05c6
31
32 diff --git a/sys-firmware/intel-microcode/intel-microcode-20220419_p20220421.ebuild b/sys-firmware/intel-microcode/intel-microcode-20220419_p20220421.ebuild
33 new file mode 100644
34 index 000000000000..4171888a5826
35 --- /dev/null
36 +++ b/sys-firmware/intel-microcode/intel-microcode-20220419_p20220421.ebuild
37 @@ -0,0 +1,263 @@
38 +# Copyright 1999-2022 Gentoo Authors
39 +# Distributed under the terms of the GNU General Public License v2
40 +
41 +EAPI="7"
42 +
43 +inherit linux-info mount-boot
44 +
45 +# Find updates by searching and clicking the first link (hopefully it's the one):
46 +# https://www.intel.com/content/www/us/en/search.html?keyword=Processor+Microcode+Data+File
47 +
48 +COLLECTION_SNAPSHOT="${PV##*_p}"
49 +INTEL_SNAPSHOT="${PV/_p*}"
50 +#NUM="28087"
51 +#https://downloadcenter.intel.com/Detail_Desc.aspx?DwnldID=${NUM}
52 +#https://downloadmirror.intel.com/${NUM}/eng/microcode-${INTEL_SNAPSHOT}.tgz
53 +DESCRIPTION="Intel IA32/IA64 microcode update data"
54 +HOMEPAGE="https://github.com/intel/Intel-Linux-Processor-Microcode-Data-Files http://inertiawar.com/microcode/"
55 +SRC_URI="https://github.com/intel/Intel-Linux-Processor-Microcode-Data-Files/archive/microcode-${INTEL_SNAPSHOT}.tar.gz
56 + https://github.com/intel/Intel-Linux-Processor-Microcode-Data-Files/raw/437f382b1be4412b9d03e2bbdcda46d83d581242/intel-ucode/06-4e-03 -> intel-ucode-sig_0x406e3-rev_0xd6.bin
57 + https://dev.gentoo.org/~mpagano/dist/intel-microcode/intel-microcode-collection-${COLLECTION_SNAPSHOT}.tar.xz"
58 +
59 +LICENSE="intel-ucode"
60 +SLOT="0"
61 +KEYWORDS="-* amd64 x86"
62 +IUSE="hostonly initramfs +split-ucode vanilla"
63 +REQUIRED_USE="|| ( initramfs split-ucode )"
64 +
65 +BDEPEND=">=sys-apps/iucode_tool-2.3"
66 +
67 +# !<sys-apps/microcode-ctl-1.17-r2 due to bug #268586
68 +RDEPEND="hostonly? ( sys-apps/iucode_tool )"
69 +
70 +RESTRICT="binchecks strip"
71 +
72 +S=${WORKDIR}
73 +
74 +# Blacklist bad microcode here.
75 +# 0x000406f1 aka 06-4f-01 aka CPUID 406F1 require newer microcode loader
76 +MICROCODE_BLACKLIST_DEFAULT="-s !0x000406f1"
77 +
78 +# https://github.com/intel/Intel-Linux-Processor-Microcode-Data-Files/issues/31
79 +MICROCODE_BLACKLIST_DEFAULT+=" -s !0x000406e3,0xc0,eq:0x00dc"
80 +
81 +# https://bugs.gentoo.org/722768
82 +MICROCODE_BLACKLIST_DEFAULT+=" -s !0x000406e3,0xc0,eq:0x00da"
83 +
84 +# https://github.com/intel/Intel-Linux-Processor-Microcode-Data-Files/commit/49bb67f32a2e3e631ba1a9a73da1c52e1cac7fd9
85 +MICROCODE_BLACKLIST_DEFAULT+=" -s !0x000806c1,0x80,eq:0x0068"
86 +
87 +# In case we want to set some defaults ...
88 +MICROCODE_SIGNATURES_DEFAULT=""
89 +
90 +# Advanced users only!
91 +# Set MIRCOCODE_SIGNATURES to merge with:
92 +# only current CPU: MICROCODE_SIGNATURES="-S"
93 +# only specific CPU: MICROCODE_SIGNATURES="-s 0x00000f4a -s 0x00010676"
94 +# exclude specific CPU: MICROCODE_SIGNATURES="-s !0x00000686"
95 +
96 +pkg_pretend() {
97 + use initramfs && mount-boot_pkg_pretend
98 +}
99 +
100 +src_prepare() {
101 + default
102 +
103 + if cd Intel-Linux-Processor-Microcode-Data* &>/dev/null; then
104 + # new tarball format from GitHub
105 + mv * ../ || die "Failed to move Intel-Linux-Processor-Microcode-Data*"
106 + cd .. || die
107 + rm -r Intel-Linux-Processor-Microcode-Data* || die
108 + fi
109 +
110 + mkdir intel-ucode-old || die
111 + cp "${DISTDIR}"/intel-ucode-sig_0x406e3-rev_0xd6.bin "${S}"/intel-ucode-old/ || die
112 +
113 + # Prevent "invalid file format" errors from iucode_tool
114 + rm -f "${S}"/intel-ucod*/list || die
115 +
116 +}
117 +
118 +src_install() {
119 + # This will take ALL of the upstream microcode sources:
120 + # - microcode.dat
121 + # - intel-ucode/
122 + # In some cases, they have not contained the same content (eg the directory has newer stuff).
123 + MICROCODE_SRC=(
124 + "${S}"/intel-ucode/
125 + "${S}"/intel-ucode-with-caveats/
126 + "${S}"/intel-ucode-old/
127 + )
128 +
129 + # Allow users who are scared about microcode updates not included in Intel's official
130 + # microcode tarball to opt-out and comply with Intel marketing
131 + if ! use vanilla; then
132 + MICROCODE_SRC+=( "${S}"/intel-microcode-collection-${COLLECTION_SNAPSHOT} )
133 + fi
134 +
135 + # These will carry into pkg_preinst via env saving.
136 + : ${MICROCODE_BLACKLIST=${MICROCODE_BLACKLIST_DEFAULT}}
137 + : ${MICROCODE_SIGNATURES=${MICROCODE_SIGNATUES_DEFAULT}}
138 +
139 + opts=(
140 + ${MICROCODE_BLACKLIST}
141 + ${MICROCODE_SIGNATURES}
142 + # be strict about what we are doing
143 + --overwrite
144 + --strict-checks
145 + --no-ignore-broken
146 + # we want to install latest version
147 + --no-downgrade
148 + # show everything we find
149 + --list-all
150 + # show what we selected
151 + --list
152 + )
153 +
154 + # The earlyfw cpio needs to be in /boot because it must be loaded before
155 + # rootfs is mounted.
156 + use initramfs && dodir /boot && opts+=( --write-earlyfw="${ED}/boot/intel-uc.img" )
157 +
158 + keepdir /lib/firmware/intel-ucode
159 + opts+=( --write-firmware="${ED}/lib/firmware/intel-ucode" )
160 +
161 + iucode_tool \
162 + "${opts[@]}" \
163 + "${MICROCODE_SRC[@]}" \
164 + || die "iucode_tool ${opts[@]} ${MICROCODE_SRC[@]}"
165 +
166 + dodoc releasenote.md
167 +}
168 +
169 +pkg_preinst() {
170 + if [[ ${MICROCODE_BLACKLIST} != ${MICROCODE_BLACKLIST_DEFAULT} ]]; then
171 + ewarn "MICROCODE_BLACKLIST is set to \"${MICROCODE_BLACKLIST}\" instead of default \"${MICROCODE_BLACKLIST_DEFAULT}\". You are on your own!"
172 + fi
173 +
174 + if [[ ${MICROCODE_SIGNATURES} != ${MICROCODE_SIGNATURES_DEFAULT} ]]; then
175 + ewarn "Package was created using advanced options:"
176 + ewarn "MICROCODE_SIGNATURES is set to \"${MICROCODE_SIGNATURES}\" instead of default \"${MICROCODE_SIGNATURES_DEFAULT}\"!"
177 + fi
178 +
179 + # Make sure /boot is available if needed.
180 + use initramfs && mount-boot_pkg_preinst
181 +
182 + local _initramfs_file="${ED}/boot/intel-uc.img"
183 +
184 + if use hostonly; then
185 + # While this output looks redundant we do this check to detect
186 + # rare cases where iucode_tool was unable to detect system's processor(s).
187 + local _detected_processors=$(iucode_tool --scan-system 2>&1)
188 + if [[ -z "${_detected_processors}" ]]; then
189 + ewarn "Looks like iucode_tool was unable to detect any processor!"
190 + else
191 + einfo "Only installing ucode(s) for ${_detected_processors#iucode_tool: system has } due to USE=hostonly ..."
192 + fi
193 +
194 + opts=(
195 + --scan-system
196 + # be strict about what we are doing
197 + --overwrite
198 + --strict-checks
199 + --no-ignore-broken
200 + # we want to install latest version
201 + --no-downgrade
202 + # show everything we find
203 + --list-all
204 + # show what we selected
205 + --list
206 + )
207 +
208 + # The earlyfw cpio needs to be in /boot because it must be loaded before
209 + # rootfs is mounted.
210 + use initramfs && opts+=( --write-earlyfw=${_initramfs_file} )
211 +
212 + if use split-ucode; then
213 + opts+=( --write-firmware="${ED}/lib/firmware/intel-ucode" )
214 + fi
215 +
216 + opts+=( "${ED}/lib/firmware/intel-ucode-temp" )
217 +
218 + mv "${ED}"/lib/firmware/intel-ucode{,-temp} || die
219 + keepdir /lib/firmware/intel-ucode
220 +
221 + iucode_tool "${opts[@]}" || die "iucode_tool ${opts[@]}"
222 +
223 + rm -r "${ED}"/lib/firmware/intel-ucode-temp || die
224 +
225 + elif ! use split-ucode; then # hostonly disabled
226 + rm -r "${ED}"/lib/firmware/intel-ucode || die
227 + fi
228 +
229 + # Because it is possible that this package will install not one single file
230 + # due to user selection which is still somehow unexpected we add the following
231 + # check to inform user so that the user has at least a chance to detect
232 + # a problem/invalid select.
233 + local _has_installed_something=
234 + if use initramfs && [[ -s "${_initramfs_file}" ]]; then
235 + _has_installed_something="yes"
236 + elif use split-ucode; then
237 + _has_installed_something=$(find "${ED}/lib/firmware/intel-ucode" -maxdepth 0 -not -empty -exec echo yes \;)
238 + fi
239 +
240 + if use hostonly && [[ -n "${_has_installed_something}" ]]; then
241 + elog "You only installed ucode(s) for all currently available (=online)"
242 + elog "processor(s). Remember to re-emerge this package whenever you"
243 + elog "change the system's processor model."
244 + elog ""
245 + elif [[ -z "${_has_installed_something}" ]]; then
246 + ewarn "WARNING:"
247 + if [[ ${MICROCODE_SIGNATURES} != ${MICROCODE_SIGNATURES_DEFAULT} ]]; then
248 + ewarn "No ucode was installed! Because you have created this package"
249 + ewarn "using MICROCODE_SIGNATURES variable please double check if you"
250 + ewarn "have an invalid select."
251 + ewarn "It's rare but it is also possible that just no ucode update"
252 + ewarn "is available for your processor(s). In this case it is safe"
253 + ewarn "to ignore this warning."
254 + else
255 + ewarn "No ucode was installed! It's rare but it is also possible"
256 + ewarn "that just no ucode update is available for your processor(s)."
257 + ewarn "In this case it is safe to ignore this warning."
258 + fi
259 +
260 + ewarn ""
261 +
262 + if use hostonly; then
263 + ewarn "Unset \"hostonly\" USE flag to install all available ucodes."
264 + ewarn ""
265 + fi
266 + fi
267 +}
268 +
269 +pkg_prerm() {
270 + # Make sure /boot is mounted so that we can remove /boot/intel-uc.img!
271 + use initramfs && mount-boot_pkg_prerm
272 +}
273 +
274 +pkg_postrm() {
275 + # Don't forget to umount /boot if it was previously mounted by us.
276 + use initramfs && mount-boot_pkg_postrm
277 +}
278 +
279 +pkg_postinst() {
280 + # Don't forget to umount /boot if it was previously mounted by us.
281 + use initramfs && mount-boot_pkg_postinst
282 +
283 + # We cannot give detailed information if user is affected or not:
284 + # If MICROCODE_BLACKLIST wasn't modified, user can still use MICROCODE_SIGNATURES
285 + # to to force a specific, otherwise blacklisted, microcode. So we
286 + # only show a generic warning based on running kernel version:
287 + if kernel_is -lt 4 14 34; then
288 + ewarn "${P} contains microcode updates which require"
289 + ewarn "additional kernel patches which aren't yet included in kernel <4.14.34."
290 + ewarn "Loading such a microcode through kernel interface from an unpatched kernel"
291 + ewarn "can crash your system!"
292 + ewarn ""
293 + ewarn "Those microcodes are blacklisted per default. However, if you have altered"
294 + ewarn "MICROCODE_BLACKLIST or MICROCODE_SIGNATURES, you maybe have unintentionally"
295 + ewarn "re-enabled those microcodes...!"
296 + ewarn ""
297 + ewarn "Check \"${EROOT}/usr/share/doc/${PN}-*/releasenot*\" if your microcode update"
298 + ewarn "requires additional kernel patches or not."
299 + fi
300 +}