LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 05-01-2022, 01:26 AM   #1
SlackIT
Member
 
Registered: Mar 2022
Posts: 172

Rep: Reputation: 17
AMD Microcode - amd-ucode.cpio?


On Slack 15, does AMD need to have an amd-ucode.cpio, like how the Intel microcode has /boot/intel-ucode.cpio?

https://slackbuilds.org/repository/1...tel-microcode/

And the iucode_tool to load the microcode early, does AMD need/have something to load it early too?

https://slackbuilds.org/repository/1...m/iucode_tool/

THANKS
 
Old 05-01-2022, 01:54 AM   #2
elcore
Senior Member
 
Registered: Sep 2014
Distribution: Slackware
Posts: 1,754

Rep: Reputation: Disabled
I'd just make it part of kernel, so I generally don't need the tool or initrd to load microcode early.
Code:
CONFIG_EXTRA_FIRMWARE="amd-ucode/microcode_amd.bin amd-ucode/microcode_amd_fam15h.bin amd-ucode/microcode_amd_fam16h.bin"
CONFIG_EXTRA_FIRMWARE_DIR="/lib/firmware"
Slackware can't really force this firmware on everyone, you'll have to do it yourself or use initrd to load early.
 
Old 05-01-2022, 03:26 AM   #3
aus9
LQ 5k Club
 
Registered: Oct 2003
Location: Western Australia
Distribution: Icewm
Posts: 5,842

Rep: Reputation: Disabled
IMHO you do not need to inject into any intramfs/initrd

instead you can you either have grub2 detect it....when using root to run
Code:
update-grub
or alternatively use a grub2 40_custom.

The name of the microcode, is an issue for me, as it has no version number.
So sometimes you have to download something and check it.

ref on grub2 detect
https://wiki.archlinux.org/title/microcode
https://wiki.gentoo.org/wiki/AMD_microcode

ie....as long as name is amd-ucode.img.....located under /boot....update-grub should work.

If update-grub works....your grub.cfg will have a similar structure pathway like the 40_custom
ie microcode then initrd

2) example of 40_custom where no boot dir but grub is used instead

Quote:
menuentry "microcode" {
set root=(hd0,2)
linux /grub/vmlinuz-5.16.0-17.1-liquorix-amd64 root=/dev/sda2 ro quiet
initrd /grub/amd-ucode.img /grub/initrd.img-5.16.0-17.1-liquorix-amd64
}
The main thing is the initrd line must show the microcode file before your initrd.

Good luck

Last edited by aus9; 05-01-2022 at 03:28 AM.
 
Old 05-01-2022, 12:51 PM   #4
Chuck56
Member
 
Registered: Dec 2006
Location: Colorado, USA
Distribution: Slackware
Posts: 930

Rep: Reputation: 479Reputation: 479Reputation: 479Reputation: 479Reputation: 479
Running AMD Ryzen 5 5600G

Here are the dmesg Spectre & microcode lines for my AMD Ryzen 5 5600G:
Code:
root@desktop:~# grep -e 'Spectre' -e 'microcode' /var/log/dmesg
[    0.071347] Spectre V1 : Mitigation: usercopy/swapgs barriers and __user pointer sanitization
[    0.071349] Spectre V2 : Mitigation: Retpolines
[    0.071350] Spectre V2 : Spectre v2 / SpectreRSB mitigation: Filling RSB on context switch
[    0.071352] Spectre V2 : Enabling Restricted Speculation for firmware calls
[    0.071353] Spectre V2 : mitigation: Enabling conditional Indirect Branch Prediction Barrier
[    0.071355] Spectre V2 : User space: Mitigation: STIBP always-on protection
[    0.183151] Spectre V2 : Update user space SMT mitigation: STIBP always-on
[    5.026837] microcode: CPU0: patch_level=0x0a50000b
[    5.026857] microcode: CPU1: patch_level=0x0a50000b
[    5.026870] microcode: CPU2: patch_level=0x0a50000b
[    5.026897] microcode: CPU3: patch_level=0x0a50000b
[    5.026929] microcode: CPU4: patch_level=0x0a50000b
[    5.026961] microcode: CPU5: patch_level=0x0a50000b
[    5.026982] microcode: CPU6: patch_level=0x0a50000b
[    5.027002] microcode: CPU7: patch_level=0x0a50000b
[    5.027020] microcode: CPU8: patch_level=0x0a50000b
[    5.027048] microcode: CPU9: patch_level=0x0a50000b
[    5.027081] microcode: CPU10: patch_level=0x0a50000b
[    5.027116] microcode: CPU11: patch_level=0x0a50000b
[    5.027159] microcode: Microcode Update Driver: v2.2.
root@desktop:~#
Here are my notes for running microcode just before the initrd with elilo:
Code:
2021/02/24
https://wiki.gentoo.org/wiki/AMD_microcode

do after kernel-firmware update (as needed)
check: dmesg | grep microcode

Firmware files preparation
linux-firmware method
Enable the initramfs USE flag for sys-kernel/linux-firmware to get 
/boot/amd-uc.img and re-generate the initramfs.

Manual initramfs
Create the specified directory and cd into it. It might be a different dir 
than /tmp. The kernel/x86/microcode part is important.

as root user
--- START cut & paste ---
mkdir -p /tmp/amd-ucode/kernel/x86/microcode
cd /tmp/amd-ucode

#Concatenate the AMD firmware files into a single file. The path and filename 
#of the output file must not be altered.
cat /lib/firmware/amd-ucode/microcode_amd*.bin > kernel/x86/microcode/AuthenticAMD.bin

#Create a cpio archive in /boot/amd-uc.img using bsdcpio from 
#app-arch/libarchive:
echo kernel/x86/microcode/AuthenticAMD.bin | bsdcpio -o -H newc -R 0:0 > /boot/amd-uc.img
--- END cut & paste ---

mkinitrd.conf, add:
MICROCODE_ARCH="/boot/amd-uc.img"
mkinitrd -F [kernel version]
Here's my mkinitrd.conf file. This is used with the mkinitrd command at the end of my notes above:
Code:
root@desktop:~# cat /etc/mkinitrd.conf
#
# /usr/share/mkinitrd/mkinitrd_command_generator.sh -c > /etc/mkinitrd.conf
#
SOURCE_TREE="/boot/initrd-tree"
CLEAR_TREE="1"
KEYMAP="us"
MODULE_LIST="ext4"
LUKSDEV=""
ROOTDEV="/dev/mapper/desktop-root"
ROOTFS="ext4"
RESUMEDEV=""
RAID=""
LVM="1"
UDEV="1"
WAIT="1"
MODCONF="1"
MICROCODE_ARCH="/boot/amd-uc.img"
root@desktop:~#
Hope that helps...
 
Old 05-01-2022, 09:52 PM   #5
SlackIT
Member
 
Registered: Mar 2022
Posts: 172

Original Poster
Rep: Reputation: 17
The problem I'm trying to figure out, is where is amd-ucode.img? I don't have one, or know how to get it...

I need to create it, as?

Code:
echo kernel/x86/microcode/AuthenticAMD.bin | bsdcpio -o -H newc -R 0:0 > /boot/amd-ucode.img
Do I also need /etc/mkinitrd.conf with MICROCODE_ARCH="/boot/amd-uc.img"?

THANKS

Last edited by SlackIT; 05-01-2022 at 09:58 PM.
 
Old 05-01-2022, 09:56 PM   #6
Chuck56
Member
 
Registered: Dec 2006
Location: Colorado, USA
Distribution: Slackware
Posts: 930

Rep: Reputation: 479Reputation: 479Reputation: 479Reputation: 479Reputation: 479
Quote:
Originally Posted by SlackIT View Post
The problem I'm trying to figure out, is where is amd-ucode.img? I don't have one, or know how to get it....

THANKS
You make it yourself!

Take a look at my notes either the gentoo link or between the --- cut & paste --- markers.
 
Old 05-01-2022, 10:01 PM   #7
SlackIT
Member
 
Registered: Mar 2022
Posts: 172

Original Poster
Rep: Reputation: 17
My bad, I see I need to do first;

Code:
$cat /lib/firmware/amd-ucode/microcode_amd*.bin > kernel/x86/microcode/AuthenticAMD.bin
then
Code:
echo kernel/x86/microcode/AuthenticAMD.bin | bsdcpio -o -H newc -R 0:0 > /boot/amd-ucode.img
But do I still need to use /etc/mkinitrd.conf with MICROCODE_ARCH="/boot/amd-uc.img" like how you are using?

Because I thought when I run; grub-mkconfig -o /boot/grub/grub.cfg it will just show the image is found in the output, and that's all I need to do?

THANKS

P.S. I did everything and I now have /boot/amd-ucode.img (I changed mine to amd-ucode.img)
Code:
mkdir -p /tmp/amd-ucode/kernel/x86/microcode
cd /tmp/amd-ucode
cat /lib/firmware/amd-ucode/microcode_amd*.bin > kernel/x86/microcode/AuthenticAMD.bin
echo kernel/x86/microcode/AuthenticAMD.bin | bsdcpio -o -H newc -R 0:0 > /boot/amd-ucode.img

Last edited by SlackIT; 05-01-2022 at 10:09 PM.
 
Old 05-01-2022, 10:15 PM   #8
Chuck56
Member
 
Registered: Dec 2006
Location: Colorado, USA
Distribution: Slackware
Posts: 930

Rep: Reputation: 479Reputation: 479Reputation: 479Reputation: 479Reputation: 479
I'm not grub compliant. I run elilo or lilo.

To create my initrd I use "mkinitrd -F -k [kernel version]" with a /etc/mkinitrd.conf that contains MICROCODE_ARCH="/boot/amd-uc.img".

That's why I listed my complete mkinitrd.conf in the earlier post.

Last edited by Chuck56; 05-01-2022 at 10:23 PM.
 
Old 05-01-2022, 10:26 PM   #9
SlackIT
Member
 
Registered: Mar 2022
Posts: 172

Original Poster
Rep: Reputation: 17
I jumped the Lilo train a long long time ago, LOL...

When I build a new kernel I run afterwards;
Code:
mkinitrd -c -k 5.15.36 -f ext4 -r /dev/sda1 -m ext4 -u -o /boot/initrd.gz
then
Code:
grub-mkconfig -o /boot/grub/grub.cfg
I'm assuming this should be fine, I'll report back how it goes later.

THANKS
 
Old 05-01-2022, 10:39 PM   #10
Chuck56
Member
 
Registered: Dec 2006
Location: Colorado, USA
Distribution: Slackware
Posts: 930

Rep: Reputation: 479Reputation: 479Reputation: 479Reputation: 479Reputation: 479
Quote:
Originally Posted by SlackIT View Post
I jumped the Lilo train a long long time ago, LOL...

When I build a new kernel I run afterwards;
Code:
mkinitrd -c -k 5.15.36 -f ext4 -r /dev/sda1 -m ext4 -u -o /boot/initrd.gz
then
Code:
grub-mkconfig -o /boot/grub/grub.cfg
I'm assuming this should be fine, I'll report back how it goes later.

THANKS
Per "man mkinitrd" you need to add "-P /boot/amd-ucode.img" to your mkinitrd command line otherwise the microcode will be ignored.
 
Old 05-01-2022, 10:53 PM   #11
SlackIT
Member
 
Registered: Mar 2022
Posts: 172

Original Poster
Rep: Reputation: 17
ok on the -P option...

BUT I ran grub-mkconfig -o /boot/grub/grub.cfg and this is the output;
Code:
 >grub-mkconfig -o /boot/grub/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.15.36
Found initrd image: /boot/amd-ucode.img /boot/initrd.gz
Warning: os-prober will be executed to detect other bootable partitions.
Its output will be used to detect bootable binaries on them and create new boot entries.
Found Windows Boot Manager on /dev/sda2@/EFI/Microsoft/Boot/bootmgfw.efi
Adding boot menu entry for UEFI Firmware Settings ...
done
And aus9 there is no update-grub or grub-update in grub-2.06, when making changes like this, you run; grub-mkconfig -o /boot/grub/grub.cfg

Now this is a line inside the grub.cfg, reflecting changes/adding in the amd-ucode.img; (Now I have several entires like this...)
Code:
initrd  /boot/amd-ucode.img /boot/initrd.gz

Last edited by SlackIT; 05-01-2022 at 10:54 PM.
 
1 members found this post helpful.
Old 05-02-2022, 01:33 AM   #12
aus9
LQ 5k Club
 
Registered: Oct 2003
Location: Western Australia
Distribution: Icewm
Posts: 5,842

Rep: Reputation: Disabled
@SlackIT I know I am posting in Slackware but run Debian Testing and update-grub is gone in grub-common v 2.04.20 too.

but for me,

Code:
ls -al /usr/sbin/update-grub
-rwxr-xr-x 1 root root 64 Jul 11  2021 /usr/sbin/update-grub
suggests when they updated, Debian forgot to remove the executable that Slackware is now missing.
But anyone getting a nightly/monthly snapshot will miss out......which is interesting to note, as I have always relied on it.

but its only a script so in case it helps others

Code:
cat /usr/sbin/update-grub
#!/bin/sh
set -e
exec grub-mkconfig -o /boot/grub/grub.cfg "$@"
and yes I can see you have already posted similar, IMHO update-grub is easier to type and remember.
Be kind as I am an oldie

Last edited by aus9; 05-02-2022 at 01:38 AM.
 
1 members found this post helpful.
Old 05-02-2022, 11:26 PM   #13
SlackIT
Member
 
Registered: Mar 2022
Posts: 172

Original Poster
Rep: Reputation: 17
@aus9 grub-mkconfig works ok for me, no worries, thanks.
 
Old 05-09-2022, 10:34 PM   #14
SlackIT
Member
 
Registered: Mar 2022
Posts: 172

Original Poster
Rep: Reputation: 17
I created amd-ucode.img and the microcode is being loaded at bootup.

Does it matter to have the microcode load early like Intel microcode? Or as long as it loads it's fine?

In /var/log/dmesg starting at line 573, is when I see it loading, so it's getting loaded further down in the boot process.

This is the output I see.
Code:
[    0.317327] microcode: CPU0: patch_level=0x0a50000c
[    0.317345] microcode: CPU1: patch_level=0x0a50000c
[    0.317360] microcode: CPU2: patch_level=0x0a50000c
[    0.317378] microcode: CPU3: patch_level=0x0a50000c
[    0.317394] microcode: CPU4: patch_level=0x0a50000c
[    0.317410] microcode: CPU5: patch_level=0x0a50000c
[    0.317421] microcode: CPU6: patch_level=0x0a50000c
[    0.317433] microcode: CPU7: patch_level=0x0a50000c
[    0.317447] microcode: CPU8: patch_level=0x0a50000c
[    0.317461] microcode: CPU9: patch_level=0x0a50000c
[    0.317475] microcode: CPU10: patch_level=0x0a50000c
[    0.317490] microcode: CPU11: patch_level=0x0a50000c
[    0.317502] microcode: Microcode Update Driver: v2.2.
THANKS

Last edited by SlackIT; 05-10-2022 at 12:02 AM.
 
Old 08-17-2022, 06:49 PM   #15
SlackIT
Member
 
Registered: Mar 2022
Posts: 172

Original Poster
Rep: Reputation: 17
Quote:
Originally Posted by Chuck56 View Post
Per "man mkinitrd" you need to add "-P /boot/amd-ucode.img" to your mkinitrd command line otherwise the microcode will be ignored.
I overlooked this reply, so I need to use -P when running mkinitrd as well as using in /etc/mkinitrd.conf MICROCODE_ARCH="/boot/amd-ucode.img"?

I don't know how to use -P on the mkinitrd cmd?

This is all I've used in the past;
Code:
mkinitrd -c -k 5.15.38 -f ext4 -r /dev/sda1 -m ext4 -u -o /boot/initrd.gz
THANKS

P.S. I read in another post, that you can do either, use -P on the mkinitrd cmd, or use MICROCODE_ARCH= in the mkinitrd.conf is this correct?

Last edited by SlackIT; 08-17-2022 at 09:43 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
AMD microcode/ucode update for Slackware 14.2? obobskivich Slackware 8 07-15-2020 07:09 PM
Apply new Intel microcode- no microcode.dat file Naks110 Linux - Kernel 2 06-12-2018 05:20 PM
[SOLVED] Linux-4.8-rc2 fails reading AMD microcode, /boot/amd-ucode.cpio aaazen Linux - Kernel 1 08-22-2016 08:33 AM
cpio -idcmv command hanged while extracting .cpio command ravindra.atre Linux - General 2 08-22-2011 04:10 AM
How to use cpio to extract a cpio archive? linx win Debian 4 06-17-2005 01:53 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 09:07 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration