diff options
author | Marian Buschsieweke <marian.buschsieweke@ovgu.de> | 2017-06-26 15:13:27 +0200 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2017-06-27 06:49:17 +0000 |
commit | 641e27116b9f61c8f86aa62108d607cd6c514a89 (patch) | |
tree | 7fd7325c5c86de5e8b78fb76a6974b4180fb09c9 /non-free/intel-ucode/intel-microcode2ucode.c | |
parent | fe2d4fd44dda9dfe064a31f29986de87ea080da8 (diff) | |
download | aports-641e27116b9f61c8f86aa62108d607cd6c514a89.tar.bz2 aports-641e27116b9f61c8f86aa62108d607cd6c514a89.tar.xz |
non-free/intel-ucode: Update to 20170511
In the context of the recent Skylake/Kaby Lake hyper-threading bug [1], an
update of the intel microcode seems to be quite relevant. The resulting
package will contain "/boot/intel-ucode.img", which needs to be added as
first initial ram drive. This is achieved in extlinux by chaining the line
INITRD=linux-$tag
to
INITRD=intel-ucode.img,linux-$tag
See [2] for more details. If this packet is accepted, changing
/sbin/update-extlinux to check for "/boot/init-ucode.img" and adding it
as first INITRD on detection seems to be a good idea.
All credit goes to Thomas Bächler [3], from whom I shamelessly stole the build
recipe.
[1] https://lists.debian.org/debian-devel/2017/06/msg00308.html
[2] https://wiki.archlinux.org/index.php/Microcode#Syslinux
[3] https://git.archlinux.org/svntogit/packages.git/tree/trunk/PKGBUILD?h=packages/intel-ucode
Diffstat (limited to 'non-free/intel-ucode/intel-microcode2ucode.c')
-rw-r--r-- | non-free/intel-ucode/intel-microcode2ucode.c | 47 |
1 files changed, 20 insertions, 27 deletions
diff --git a/non-free/intel-ucode/intel-microcode2ucode.c b/non-free/intel-ucode/intel-microcode2ucode.c index caad0323e8..fe410ac86e 100644 --- a/non-free/intel-ucode/intel-microcode2ucode.c +++ b/non-free/intel-ucode/intel-microcode2ucode.c @@ -1,13 +1,8 @@ /* - * Convert Intel microcode.dat into individual ucode files - * named: intel-ucode/$family-$model-$stepping + * Convert Intel microcode.dat into a single binary microcode.bin file * - * 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> + * Based on code by Kay Sievers <kay.sievers@vrfy.org> + * Changed to create a single file by Thomas Bächler <thomas@archlinux.org> */ @@ -48,7 +43,7 @@ union mcbuf { int main(int argc, char *argv[]) { - char *filename = "/lib/firmware/microcode.dat"; + const char *filename = "/lib/firmware/microcode.dat"; FILE *f; char line[LINE_MAX]; char buf[4000000]; @@ -89,12 +84,17 @@ int main(int argc, char *argv[]) if (bufsize < sizeof(struct microcode_header_intel)) goto out; - mkdir("intel-ucode", 0750); + f = fopen("microcode.bin", "we"); + if (f == NULL) { + printf("open microcode.bin: %m\n"); + rc = EXIT_FAILURE; + goto out; + } start = 0; for (;;) { size_t size; - unsigned int family, model, stepping; + unsigned int family, model, stepping, type; unsigned int year, month, day; mc = (union mcbuf *) &buf[start]; @@ -118,45 +118,38 @@ int main(int argc, char *argv[]) * 16-19 extended model * 20-27 extended family */ - family = (mc->hdr.sig >> 8) & 0xf; - if (family == 0xf) - family += (mc->hdr.sig >> 20) & 0xff; + stepping = mc->hdr.sig & 0x0f; model = (mc->hdr.sig >> 4) & 0x0f; + family = (mc->hdr.sig >> 8) & 0x0f; + type = (mc->hdr.sig >> 12) & 0x0f; if (family == 0x06) model += ((mc->hdr.sig >> 16) & 0x0f) << 4; - stepping = mc->hdr.sig & 0x0f; + if (family == 0x0f) + family += (mc->hdr.sig >> 20) & 0xff; year = mc->hdr.date & 0xffff; month = mc->hdr.date >> 24; day = (mc->hdr.date >> 16) & 0xff; - asprintf(&filename, "intel-ucode/%02x-%02x-%02x", family, model, stepping); printf("\n"); - printf("%s\n", filename); - printf("signature: 0x%02x\n", mc->hdr.sig); + printf("signature: 0x%02x (stepping %d, model %d, family %d, type %d)\n", + mc->hdr.sig, stepping, model, family, type); 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); + printf("write microcode.bin: %m\n"); rc = EXIT_FAILURE; goto out; } - fclose(f); - free(filename); start += size; if (start >= bufsize) break; } + fclose(f); printf("\n"); out: return rc; |