• Is there any way to load AMD Microcode earlier?


    I’m getting this error on my dmesg output:

    x86/CPU: CPU features have changed after loading microcode, but might not take effect.
    x86/CPU: Please consider either early loading through initrd/built-in or a potential BIOS update.
    

    My CPU is an AMD FX8350, being an AMD CPU the microcode comes inside the linux-firmware package and as everybody knows, all motherboards of same era is EOL, so no more BIOS updates, my questions are:

    1. Is there any way to load the AMD microcode earlier and how could I do that?
    2. This could be considered an upstream bug?
  • Since no one seems to have an answer or hasn’t tried it yet … this is how I did it; keep in mind that this may not be the entirely correct way.

    First of all you need to somehow cough up a initrd image containing the AMD microcode. Since it doesn’t exist OOB (Out Of the Box) we have to make one:

    Copy/Paste the code below, save it as “mkamducode.sh

    #!/bin/bash
    
    if [ $UID != "0" ]; then
        echo "Please run as root."
        exit 0
    fi
    
    if [ -d /lib/firmware/amd-ucode ]; then
        echo "Entering /tmp..."
        cd /tmp
    
        if [ -d kernel/x86/microcode ]; then
            echo "    Deleting old files..."
            rm -rf kernel
        fi
    
        echo "    Creating directories..."
        mkdir -p kernel/x86/microcode
    
        echo "    Creating 'AuthenticAMD.bin'..."
        cat /lib/firmware/amd-ucode/microcode_amd*.bin > kernel/x86/microcode/AuthenticAMD.bin
    
        echo "    Creating initrd image..."
        echo kernel/x86/microcode/AuthenticAMD.bin | bsdcpio -o -H newc -R 0:0 > amd-ucode.img
    
        echo "    Cleaning up..."
        rm -rf kernel
    
        if [ -e /boot/amd-ucode.img ]; then
            echo "    Deleting '/boot/amd-ucode.img'..."
            rm /boot/amd-ucode.img
        fi
    
        echo "    Putting 'amd-ucode.img' into /boot..."
        mv amd-ucode.img /boot/
    
        cd
    
        echo "All done."
    else
        echo "Required /lib/firmware/amd_ucode directory not found. "
        echo "Make sure 'linux-firmware' is installed."
        echo "Aborting."
    fi
    
    exit 0
    
    

    We need to make it executable…

    sudo chmod 755 /path/to/mkamducode.sh

    … and run it to create /boot/amd-ucode.img …

    sudo /path/to/mkamducode.sh

    Alright, now that we have the file (also includes the ucode files for Ryzen, in case the files drop faster than a UEFI update) we need to make grub work with it …

    First, let us create a backup copy of the file we’re going to modify; just in case something goes wrong …

    sudo cp /etc/grub.d/10_antergos /root/

    Now we open the file for editing …

    sudo nano /etc/grub.d/10_antergos

    Search for “intel_ucode=”, should be at line 83

    Above the “intel_ucode=” line or below the closing “fi” line - just like you prefer - insert this code block …

    amd_ucode=
    if test -e "/boot/amd-ucode.img" ; then
        gettext_printf "Found AMD Microcode image\n" >&2
        amd_ucode="$(make_system_path_relative_to_its_root /boot/amd-ucode.img)"
    fi
    

    Save the modification (make sure you didn’t typo in case you typed it in).

    Let us re-run grub-mkconfig…

    sudo grub-mkconfig -o /boot/grub/grub.cfg

    One thing you’re going to notice is that it will now print the “Found AMD microcode image” line.

    When grub-mkconfig is done and hasn’t thrown any error reboot the machine.

    Login, open a terminal and issue:

    dmesg | grep microcode

    The output should look like this (copy/pasted from a FX8150 test system):

    [    0.938804] microcode: microcode updated early to new patch_level=0x06000852
    [    0.938830] microcode: CPU0: patch_level=0x06000852
    [    0.938836] microcode: CPU1: patch_level=0x06000852
    [    0.938843] microcode: CPU2: patch_level=0x06000852
    [    0.938849] microcode: CPU3: patch_level=0x06000852
    [    0.938852] microcode: CPU4: patch_level=0x06000852
    [    0.938856] microcode: CPU5: patch_level=0x06000852
    [    0.938863] microcode: CPU6: patch_level=0x06000852
    [    0.938869] microcode: CPU7: patch_level=0x06000852
    [    0.938909] microcode: Microcode Update Driver: v2.2.
    
    

    Now we’re talkin’ “early microcode loadin’ boy” … seems like implementing a simple hack like that to help older systems is too 31337 for Arch.

    Downside of this solution: In case of an updated microcode being shipped via “linux-firmware” requires you to re-run the “mkamducode.sh” script to recreate the initrd image file with the updated bits.

    So, that’s all there is to it. The shell script isn’t even necessary; I only cobbled that one up so you have a script to do it for you instead of having to type each command into the terminal … might be as bothersome as trying to get to Google to do some research.

  • WAIT … I forgot a second modification to /etc/grub.d/10_antergos

    Once you put the “amd_ucode=” block in, go down to line 196 (or thereabouts) …

    Should read:

    initrd  ${intel_ucode} ${rel_dirname}/${initrd}
    

    Make it read:

    initrd  ${amd_ucode} ${intel_ucode} ${rel_dirname}/${initrd}
    

    And then resume at “Let us re-run grub-mkconfig…”

amd36 microcode4 earlier2 Posts 3Views 622
Log in to reply
Bloom Email Optin Plugin

Looks like your connection to Antergos Community Forum was lost, please wait while we try to reconnect.