# [solved]intel early microcode with iucode_tool-1.5

## ulenrich

Seeing Debian updates the iucode_tool I made a version bump  bug entry

because I saw different outcomes of  {gentoo,debian}/lib/firmware/intel-ucode

I didn't not believe any thing any more

and downloaded original Intel microcode

But it is identical with sys-apps/microcode-data-20151106

per sha256sum. 

I searched a way without using intermediates of /lib/firmware/intel-ucode. A very short HowTo:

To get an early microcode initrd image I just did with my new iucode_tool-1.5

```
/usr/sbin/iucode_tool -v -td --scan-system --list --write-earlyfw=/boot/efi/core2fw.img \

  --strict-checks  /lib/firmware/microcode.dat 
```

 which I then can prepend to any other initrd by just writing before the main initrd the line "initrd=/core2fw.img". This image placed at "/" despite efi is mounted /boot/efi, because I use an efi system with my kernels directly on that vFat 200Mbyte efi partition. There is a way to "cat" the two of the initrds together, but having both of them works best, if you sometime want to boot without the main initrd.

Logs then show

Nov 18 00:22:43 maci kernel: microcode: CPU0 sig=0x1067a, pf=0x80, revision=0xa0b

Nov 18 00:22:43 maci kernel: microcode: CPU1 sig=0x1067a, pf=0x80, revision=0xa0b

as before with microcode of a year ago. Without this early microcode I get revision=0xa07

of the original Bios.

What I do not understand is the output of the iucode_tool of the microcodes selected:

001: sig 0x0001067a, pf mask 0xa0, 2010-09-28, rev 0x0a0b, size 8192

002: sig 0x0001067a, pf mask 0x11, 2010-09-28, rev 0x0a0b, size 8192

003: sig 0x0001067a, pf mask 0x44, 2010-09-28, rev 0x0a0b, size 8192

which show different pf masks than the "pf=0x80"  of my Log ?

My 2cents critics: 

When I inspect sys-apps/microcode-data--2015110.ebuild

I can see an extra tool: files/intel-microcode2ucode.c 

which is used to split the microcode.dat. I don't think this is nice and beautiful to have, because this should be done by the iucode_tool? And microcode-data should be in sys-kernel category like the other firmware ebuild, I think ...

----------

## Fitzcarraldo

For my Intel Core i7 I just needed to do the following to get the microcode updated at every boot:

I made sure the kernel is set up as follows:

```
# grep CONFIG_BLK_DEV_INITRD /usr/src/linux/.config

CONFIG_BLK_DEV_INITRD=y

# grep CONFIG_MICROCODE /usr/src/linux/.config

CONFIG_MICROCODE=y

CONFIG_MICROCODE_INTEL=y

# CONFIG_MICROCODE_AMD is not set

CONFIG_MICROCODE_OLD_INTERFACE=y

CONFIG_MICROCODE_INTEL_EARLY=y

# CONFIG_MICROCODE_AMD_EARLY is not set

CONFIG_MICROCODE_EARLY=y

# grep CONFIG_INITRAMFS_SOURCE /usr/src/linux/.config

CONFIG_INITRAMFS_SOURCE=""
```

Then I set the initramfs USE flag and unmasked the ~amd64 ebuilds microcode-ctl, microcode-data and iucode_tool:

```
# cat /etc/portage/package.use/microcode-data

sys-apps/microcode-data initramfs

# cat /etc/portage/package.accept_keywords/microcode-data

sys-apps/microcode-data ~amd64

sys-apps/iucode_tool ~amd64

# cat /etc/portage/package.accept_keywords/microcode-ctl

sys-apps/microcode-ctl ~amd64
```

Then I merged the packages:

```
# emerge --ask microcode-ctl microcode-data
```

Then I copied to the boot directory the cpio file created when I merged the packages:

```
# cp /lib/firmware/microcode.cpio /boot/
```

Then I added an initrd line to /boot/grub/grub.cfg as shown below:

```
# grep -B 15 -A 1 initrd /boot/grub/grub.cfg

### BEGIN /etc/grub.d/10_linux ###

menuentry 'Gentoo GNU/Linux' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-525a90f1-8ad2-44a3-ade3-20f18a0a9595' {

        load_video

        insmod gzio

        insmod part_msdos

        insmod ext2

        set root='hd0,msdos1'

        if [ x$feature_platform_search_hint = xy ]; then

          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  f6ffc085-66fe-4bbe-b080-cec355749f85

        else

          search --no-floppy --fs-uuid --set=root f6ffc085-66fe-4bbe-b080-cec355749f85

        fi

        echo    'Loading Linux 3.18.11-gentoo ...'

        linux   /vmlinuz-3.18.11-gentoo root=/dev/sda5 ro  drm_kms_helper.edid_firmware=edid/1920x1080_Clevo_W230SS.bin i915.modeset=1 rcutree.rcu_idle_gp_delay=1

        initrd /microcode.cpio

}
```

Works correctly:

```
$ dmesg | grep microcode

[    0.000000] CPU0 microcode updated early to revision 0x1e, date = 2015-08-13

[    0.048340] CPU1 microcode updated early to revision 0x1e, date = 2015-08-13

[    0.063442] CPU2 microcode updated early to revision 0x1e, date = 2015-08-13

[    0.078471] CPU3 microcode updated early to revision 0x1e, date = 2015-08-13

[    0.267442] microcode: CPU0 sig=0x306c3, pf=0x10, revision=0x1e

[    0.267540] microcode: CPU1 sig=0x306c3, pf=0x10, revision=0x1e

[    0.267640] microcode: CPU2 sig=0x306c3, pf=0x10, revision=0x1e

[    0.267738] microcode: CPU3 sig=0x306c3, pf=0x10, revision=0x1e

[    0.267838] microcode: CPU4 sig=0x306c3, pf=0x10, revision=0x1e

[    0.267935] microcode: CPU5 sig=0x306c3, pf=0x10, revision=0x1e

[    0.268053] microcode: CPU6 sig=0x306c3, pf=0x10, revision=0x1e

[    0.268150] microcode: CPU7 sig=0x306c3, pf=0x10, revision=0x1e

[    0.268265] microcode: Microcode Update Driver: v2.00 <tigran@aivazian.fsnet.co.uk>, Peter Oruba
```

----------

