public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] repo/gentoo:master commit in: sys-firmware/intel-microcode/, sys-firmware/intel-microcode/files/
@ 2017-07-12 21:55 Thomas Deutschmann
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Deutschmann @ 2017-07-12 21:55 UTC (permalink / raw
  To: gentoo-commits

commit:     9bd08f12708f4e323910f7f1be17b26bfe7bed57
Author:     Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
AuthorDate: Wed Jul 12 21:55:09 2017 +0000
Commit:     Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
CommitDate: Wed Jul 12 21:55:28 2017 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=9bd08f12

sys-firmware/intel-microcode: Bump to v20170707 (bug #624556)

Package-Manager: Portage-2.3.5, Repoman-2.3.2

 sys-firmware/intel-microcode/Manifest              |   1 +
 .../files/intel-microcode2ucode.c-r1               | 166 +++++++++++++++++++++
 .../intel-microcode-20170707.ebuild                |  48 ++++++
 3 files changed, 215 insertions(+)

diff --git a/sys-firmware/intel-microcode/Manifest b/sys-firmware/intel-microcode/Manifest
index 4ce2cad6897..197db19058f 100644
--- a/sys-firmware/intel-microcode/Manifest
+++ b/sys-firmware/intel-microcode/Manifest
@@ -7,3 +7,4 @@ DIST microcode-20160607.tgz 1236385 SHA256 db821eb47af2caa39613caee0eb89a9584b2e
 DIST microcode-20160714.tgz 1239344 SHA256 f3a9c6fc93275bf1febc26f7c397ac93ed5f109e47fb52932f6dbd5cfdbc840e SHA512 f9e09b6669a86aafcc77642d6e33acf9326109c3a2bc3e0d62b45a062b9ecbde6605b5a0ae31d4a3ad2b0ed3c6d3aadbd18088431fb72216bfc31fc452b0e342 WHIRLPOOL d62bbce555adc1973465d81463d9ef51cc64f5f0937b555a0b616458afc47823b2512a60eb498d4658e96244430e47bde5f36b2e49d202d41e61914bee6a3a9c
 DIST microcode-20161104.tgz 1290125 SHA256 70154ca62ff9b3da6291dfdecc90daaeb399d7290c0d308d719df16dff5ee3d1 SHA512 73a7310c1da5bec7ce82bce5cf7c2aafa3d0189e7524bdebd20e1ea3568cf8242be39d9041fa055fe06e759f98703c5d0a631e57ff185aae3ba3c91dbe83cf7a WHIRLPOOL e811315facf6b7dc80c4a99555d909e1c26aa7904d1f2608de633f7e49f691f5bf6c47973381cd72e4cb8c3b4355651a4c64564c79539ddfa41a007b8f05b5ca
 DIST microcode-20170511.tgz 2143617 SHA256 2f77fd2d87403b754d01a66c78a36a8b8ffc16dc3c50fb7aa2c4cd4da7f681a3 SHA512 4e2066096d56430c2df73631f15cf16f2317c1d8ff745d7b7cdd784ebccc2b797565eb52703cce9b4238774dbfdcaecacd892d729b7869fdfd7644008ce74a60 WHIRLPOOL 492e5e5962696636bfb2e181964893ba59798873b71cb9f5d11b1dcb9a1b32acb9e11634b71d880e05f9b71eb4f45dbc72e7a48e1ac4f38dfec816dbecf79b0d
+DIST microcode-20170707.tgz 2908882 SHA256 4fd44769bf52a7ac11e90651a307aa6e56ca6e1a814e50d750ba8207973bee93 SHA512 2f0643c332318e9c818b9a23a996b59086e86e80e649589e43dbab19f13083d6d9505b8557f67b45ce56de0da043c753a14bb146e597b6669f24fe543656c65f WHIRLPOOL bafae318d350bae1ebb6aeb5611e9ffab7d52d2ca836c7b65cb6b86bae9da7ee2c41945e0252cbe1797de4737507948b5260bbe3996d1d7e3fd2489e32452456

diff --git a/sys-firmware/intel-microcode/files/intel-microcode2ucode.c-r1 b/sys-firmware/intel-microcode/files/intel-microcode2ucode.c-r1
new file mode 100644
index 00000000000..4b3ba4b48ed
--- /dev/null
+++ b/sys-firmware/intel-microcode/files/intel-microcode2ucode.c-r1
@@ -0,0 +1,166 @@
+/*
+ * Convert Intel microcode.dat into individual ucode files
+ * named: intel-ucode/$family-$model-$stepping
+ *
+ * The subdir intel-ucode/ is created in the current working
+ * directory. We get multiple ucodes in the same file, so they
+ * are appended to an existing file. Make sure the directory
+ * is empty before every run of the converter.
+ *
+ * Kay Sievers <kay.sievers@vrfy.org>
+ */
+
+
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE 1
+#endif
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <limits.h>
+#include <stdbool.h>
+#include <inttypes.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <sys/stat.h>
+
+struct microcode_header_intel {
+	unsigned int hdrver;
+	unsigned int rev;
+	unsigned int date;
+	unsigned int sig;
+	unsigned int cksum;
+	unsigned int ldrver;
+	unsigned int pf;
+	unsigned int datasize;
+	unsigned int totalsize;
+	unsigned int reserved[3];
+};
+
+union mcbuf {
+	struct microcode_header_intel hdr;
+	unsigned int i[0];
+	char c[0];
+};
+
+int main(int argc, char *argv[])
+{
+	char *filename = "/lib/firmware/microcode.dat";
+	FILE *f;
+	char line[LINE_MAX];
+	char buf[4000000];
+	union mcbuf *mc;
+	size_t bufsize, count, start;
+	int rc = EXIT_SUCCESS;
+
+	if (argv[1] != NULL)
+		filename = argv[1];
+
+	count = 0;
+	mc = (union mcbuf *) buf;
+	f = fopen(filename, "re");
+	if (f == NULL) {
+		printf("open %s: %m\n", filename);
+		rc = EXIT_FAILURE;
+		goto out;
+	}
+
+	while (fgets(line, sizeof(line), f) != NULL) {
+		if (sscanf(line, "%x, %x, %x, %x",
+		    &mc->i[count],
+		    &mc->i[count + 1],
+		    &mc->i[count + 2],
+		    &mc->i[count + 3]) != 4)
+			continue;
+		count += 4;
+	}
+	fclose(f);
+
+	bufsize = count * sizeof(int);
+	printf("%s: %lu(%luk) bytes, %zu integers\n",
+	       filename,
+	       bufsize,
+	       bufsize / 1024,
+	       count);
+
+	if (bufsize < sizeof(struct microcode_header_intel))
+		goto out;
+
+	mkdir("intel-ucode", 0750);
+
+	start = 0;
+	for (;;) {
+		size_t size;
+		unsigned int family, model, stepping;
+		unsigned int year, month, day;
+
+		mc = (union mcbuf *) &buf[start];
+
+		if (mc->hdr.totalsize)
+			size = mc->hdr.totalsize;
+		else
+			size = 2000 + sizeof(struct microcode_header_intel);
+
+		if (mc->hdr.ldrver != 1 || mc->hdr.hdrver != 1) {
+			printf("unknown version/format:\n");
+			rc = EXIT_FAILURE;
+			break;
+		}
+
+		/*
+		 *  0- 3 stepping
+		 *  4- 7 model
+		 *  8-11 family
+		 * 12-13 type
+		 * 16-19 extended model
+		 * 20-27 extended family
+		 */
+		family = (mc->hdr.sig >> 8) & 0xf;
+		if (family == 0xf)
+			family += (mc->hdr.sig >> 20) & 0xff;
+		model = (mc->hdr.sig >> 4) & 0x0f;
+		if (family == 0x06)
+			model += ((mc->hdr.sig >> 16) & 0x0f) << 4;
+		stepping = mc->hdr.sig & 0x0f;
+
+		year = mc->hdr.date & 0xffff;
+		month = mc->hdr.date >> 24;
+		day = (mc->hdr.date >> 16) & 0xff;
+
+		if (asprintf(&filename, "intel-ucode/%02x-%02x-%02x", family, model, stepping) < 0) {
+			rc = EXIT_FAILURE;
+			goto out;
+		}
+		printf("\n");
+		printf("%s\n", filename);
+		printf("signature: 0x%02x\n", mc->hdr.sig);
+		printf("flags:     0x%02x\n", mc->hdr.pf);
+		printf("revision:  0x%02x\n", mc->hdr.rev);
+		printf("date:      %04x-%02x-%02x\n", year, month, day);
+		printf("size:      %zu\n", size);
+
+		f = fopen(filename, "ae");
+		if (f == NULL) {
+			printf("open %s: %m\n", filename);
+			rc = EXIT_FAILURE;
+			goto out;
+		}
+		if (fwrite(mc, size, 1, f) != 1) {
+			printf("write %s: %m\n", filename);
+			rc = EXIT_FAILURE;
+			goto out;
+		}
+		fclose(f);
+		free(filename);
+
+		start += size;
+		if (start >= bufsize)
+			break;
+	}
+	printf("\n");
+out:
+	return rc;
+}

diff --git a/sys-firmware/intel-microcode/intel-microcode-20170707.ebuild b/sys-firmware/intel-microcode/intel-microcode-20170707.ebuild
new file mode 100644
index 00000000000..acab7d67475
--- /dev/null
+++ b/sys-firmware/intel-microcode/intel-microcode-20170707.ebuild
@@ -0,0 +1,48 @@
+# Copyright 1999-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI="6"
+
+inherit toolchain-funcs
+
+# Find updates by searching and clicking the first link (hopefully it's the one):
+# http://www.intel.com/content/www/us/en/search.html?keyword=Processor+Microcode+Data+File
+
+NUM="26925"
+DESCRIPTION="Intel IA32/IA64 microcode update data"
+HOMEPAGE="http://inertiawar.com/microcode/ https://downloadcenter.intel.com/Detail_Desc.aspx?DwnldID=${NUM}"
+SRC_URI="http://downloadmirror.intel.com/${NUM}/eng/microcode-${PV}.tgz"
+
+LICENSE="intel-ucode"
+SLOT="0"
+KEYWORDS="-* ~amd64 ~x86"
+IUSE="initramfs monolithic +split-ucode"
+REQUIRED_USE="|| ( initramfs monolithic split-ucode )"
+
+DEPEND="initramfs? ( sys-apps/iucode_tool )"
+RDEPEND="!<sys-apps/microcode-ctl-1.17-r2" #268586
+
+S=${WORKDIR}
+
+src_unpack() {
+	default
+	cp "${FILESDIR}"/intel-microcode2ucode.c-r1 ./intel-microcode2ucode.c || die
+}
+
+src_compile() {
+	if use initramfs ; then
+		iucode_tool --write-earlyfw=microcode.cpio microcode.dat || die
+	fi
+
+	if use split-ucode ; then
+		tc-env_build emake intel-microcode2ucode
+		./intel-microcode2ucode microcode.dat || die
+	fi
+}
+
+src_install() {
+	insinto /lib/firmware
+	use initramfs && doins microcode.cpio
+	use monolithic && doins microcode.dat
+	use split-ucode && doins -r intel-ucode
+}


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [gentoo-commits] repo/gentoo:master commit in: sys-firmware/intel-microcode/, sys-firmware/intel-microcode/files/
@ 2024-07-18  6:44 Andrew Ammerlaan
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Ammerlaan @ 2024-07-18  6:44 UTC (permalink / raw
  To: gentoo-commits

commit:     24aae6dd6e42c19b4e7415b9477621a357648219
Author:     Andrew Ammerlaan <andrewammerlaan <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 18 06:34:46 2024 +0000
Commit:     Andrew Ammerlaan <andrewammerlaan <AT> gentoo <DOT> org>
CommitDate: Thu Jul 18 06:34:46 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=24aae6dd

sys-firmware/intel-microcode: avoid mount-boot if ROOT is set

and:
- rdep on iucode_tool for .install hook
- USE=hostonly: iucode_tool is executed in pkg_preinst and should therefore be
an idep instead of a rdep (not that it really makes a functional difference
since it is bdep anyway)
- rework REQUIRED_USE: the *.install hooks require the split-ucode to be
present. Since with USE=dist-kernel, USE=initramfs does not install intel-uc.img
(instead it is delegared to installkernel via the *.install hooks)  we need
always split-ucode with dist-kernel.
- *.install: exit gracefully if no ucode installed

this mirrors recent changes in sys-kernel/linux-firmware

Signed-off-by: Andrew Ammerlaan <andrewammerlaan <AT> gentoo.org>

 .../files/35-intel-microcode-systemd.install       | 23 +++++++++++++---------
 .../files/35-intel-microcode.install               | 10 +++++++---
 ...> intel-microcode-20240531_p20240526-r2.ebuild} | 22 ++++++++++++++-------
 3 files changed, 36 insertions(+), 19 deletions(-)

diff --git a/sys-firmware/intel-microcode/files/35-intel-microcode-systemd.install b/sys-firmware/intel-microcode/files/35-intel-microcode-systemd.install
index 7ad7b8c49e83..58593a675b37 100644
--- a/sys-firmware/intel-microcode/files/35-intel-microcode-systemd.install
+++ b/sys-firmware/intel-microcode/files/35-intel-microcode-systemd.install
@@ -35,13 +35,18 @@ opts=(
 	--no-downgrade
 )
 
-if [[ ${KERNEL_INSTALL_VERBOSE} == 1 ]]; then
-	echo "Generating Intel CPU Microcode early initramfs image..."
-	opts+=(
-		--list-all
-		--list
-	)
+if [[ -d /lib/firmware/intel-ucode ]]; then
+	if [[ ${KERNEL_INSTALL_VERBOSE} == 1 ]]; then
+		echo "Generating Intel CPU Microcode early initramfs image..."
+		opts+=(
+			--list-all
+			--list
+		)
+	fi
+
+	iucode_tool /lib/firmware/intel-ucode "${opts[@]}" ||
+		{ echo "iucode_tool failed" && exit 1; }
+else
+	[[ ${KERNEL_INSTALL_VERBOSE} == 1 ]] && echo \
+		"No Intel CPU Microcode installed, nothing to do here."
 fi
-
-iucode_tool /lib/firmware/intel-ucode "${opts[@]}" ||
-	{ echo "iucode_tool failed" && exit 1; }

diff --git a/sys-firmware/intel-microcode/files/35-intel-microcode.install b/sys-firmware/intel-microcode/files/35-intel-microcode.install
index d4e9ef19d56b..513b3a84d08e 100644
--- a/sys-firmware/intel-microcode/files/35-intel-microcode.install
+++ b/sys-firmware/intel-microcode/files/35-intel-microcode.install
@@ -41,9 +41,13 @@ main() {
 		--list
 	)
 
-	einfo "Generating Intel CPU Microcode early initramfs image..."
-	iucode_tool /lib/firmware/intel-ucode "${opts[@]}" ||
-		die "iucode_tool failed"
+	if [[ -d /lib/firmware/intel-ucode ]]; then
+		einfo "Generating Intel CPU Microcode early initramfs image..."
+		iucode_tool /lib/firmware/intel-ucode "${opts[@]}" ||
+			die "iucode_tool failed"
+	else
+		einfo "No Intel CPU Microcode installed, nothing to do here."
+	fi
 }
 
 main

diff --git a/sys-firmware/intel-microcode/intel-microcode-20240531_p20240526-r1.ebuild b/sys-firmware/intel-microcode/intel-microcode-20240531_p20240526-r2.ebuild
similarity index 97%
rename from sys-firmware/intel-microcode/intel-microcode-20240531_p20240526-r1.ebuild
rename to sys-firmware/intel-microcode/intel-microcode-20240531_p20240526-r2.ebuild
index 55f66f30803d..947e22ff9bc2 100644
--- a/sys-firmware/intel-microcode/intel-microcode-20240531_p20240526-r1.ebuild
+++ b/sys-firmware/intel-microcode/intel-microcode-20240531_p20240526-r2.ebuild
@@ -45,16 +45,24 @@ LICENSE="intel-ucode"
 SLOT="0"
 KEYWORDS="-* ~amd64 ~x86"
 IUSE="dist-kernel hostonly +initramfs +split-ucode vanilla"
-REQUIRED_USE="!dist-kernel? ( || ( initramfs split-ucode ) )"
+REQUIRED_USE="
+	|| ( initramfs split-ucode )
+	dist-kernel? ( split-ucode )
+"
 RESTRICT="binchecks strip"
 
 BDEPEND=">=sys-apps/iucode_tool-2.3"
 # !<sys-apps/microcode-ctl-1.17-r2 due to bug #268586
 RDEPEND="
-	dist-kernel? ( virtual/dist-kernel )
-	hostonly? ( sys-apps/iucode_tool )
+	dist-kernel? (
+		virtual/dist-kernel
+		initramfs? (
+			sys-apps/iucode_tool
+		)
+	)
 "
 IDEPEND="
+	hostonly? ( sys-apps/iucode_tool )
 	dist-kernel? (
 		initramfs? ( sys-kernel/installkernel )
 	)
@@ -84,10 +92,10 @@ MICROCODE_SIGNATURES_DEFAULT=""
 
 pkg_pretend() {
 	if use initramfs; then
-		if [[ -z ${ROOT} ]] && use dist-kernel; then
+		if use dist-kernel; then
 			# Check, but don't die because we can fix the problem and then
 			# emerge --config ... to re-run installation.
-			nonfatal mount-boot_check_status
+			[[ -z ${ROOT} ]] && nonfatal mount-boot_check_status
 		else
 			mount-boot_pkg_pretend
 		fi
@@ -302,8 +310,8 @@ pkg_postrm() {
 
 pkg_postinst() {
 	if use initramfs; then
-		if [[ -z ${ROOT} ]] && use dist-kernel; then
-			dist-kernel_reinstall_initramfs "${KV_DIR}" "${KV_FULL}"
+		if use dist-kernel; then
+			[[ -z ${ROOT} ]] && dist-kernel_reinstall_initramfs "${KV_DIR}" "${KV_FULL}"
 		else
 			# Don't forget to umount /boot if it was previously mounted by us.
 			mount-boot_pkg_postinst


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-07-18  6:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-12 21:55 [gentoo-commits] repo/gentoo:master commit in: sys-firmware/intel-microcode/, sys-firmware/intel-microcode/files/ Thomas Deutschmann
  -- strict thread matches above, loose matches on Subject: below --
2024-07-18  6:44 Andrew Ammerlaan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox