Skip to content

Commit

Permalink
Merge pull request #342 from mariux64/create-microcode-update-archive…
Browse files Browse the repository at this point in the history
…s-and-load-them-in-grub

Create microcode update archives and load them in GRUB
  • Loading branch information
pmenzel authored Aug 24, 2023
2 parents b0f769c + f8108a1 commit b7a2899
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions mxgrub/mxgrub
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ sub update_grub_cfg {

for my $label (@MARIUX) {
my $image=label_to_image($label);
$kernellist.="\tmenuentry \"$label\" --unrestricted { save_env chosen ; linux /boot/$image root=LABEL=root $KERNEL_PARAMETER ; initrd /boot/grub/initramfs.igz }\n";
$kernellist.="\tmenuentry \"$label\" --unrestricted { save_env chosen ; linux /boot/$image root=LABEL=root $KERNEL_PARAMETER ; initrd /boot/amd-ucode.img /boot/intel-ucode.img /boot/grub/initramfs.igz }\n";
}

my $GRUB_CFG_NEW=<<"EOF";
Expand All @@ -267,10 +267,10 @@ insmod all_video
if [ -e /etc/local/USB.usb ]; then
set default="mariuxUSB"
menuentry "mariuxUSB" --unrestricted { save_env chosen ; linux /boot/bzImage.x86_64 root=LABEL=rootusb rootdelay=5 $KERNEL_PARAMETER ; initrd /boot/grub/initramfs.igz }
menuentry "mariuxUSB" --unrestricted { save_env chosen ; linux /boot/bzImage.x86_64 root=LABEL=rootusb rootdelay=5 $KERNEL_PARAMETER ; initrd /boot/amd-ucode.img /boot/intel-ucode.img /boot/grub/initramfs.igz }
else
menuentry "$MARIUX_DEFAULT" --unrestricted { set chosen="$submenu>$MARIUX_DEFAULT" ; save_env chosen ; linux /boot/bzImage.x86_64 root=LABEL=root $KERNEL_PARAMETER ; initrd /boot/grub/initramfs.igz }
menuentry "$MARIUX_DEFAULT" --unrestricted { set chosen="$submenu>$MARIUX_DEFAULT" ; save_env chosen ; linux /boot/bzImage.x86_64 root=LABEL=root $KERNEL_PARAMETER ; initrd /boot/amd-ucode.img /boot/intel-ucode.img /boot/grub/initramfs.igz }
submenu "$submenu" --unrestricted {
$kernellist
Expand Down Expand Up @@ -353,7 +353,23 @@ sub cmd_update {
update_grub_cfg();
}

sub build_microcode {
my ($pattern, $image, $binname) = @_;
sys(<<"EOF");
set -e
DSTDIR=kernel/x86/microcode
mkdir -p /scratch/local/mxgrub-build-microcode/
cd \$_
mkdir -p "\$DSTDIR"
cat $pattern > "\$DSTDIR"/$binname
find . | cpio -o -H newc > $image
rm -rf /scratch/local/mxgrub-build-microcode/
EOF
}

sub cmd_initramfs {
build_microcode('/lib/firmware/amd-ucode/microcode_amd*.bin', '/boot/amd-ucode.img', 'AuthenticAMD.bin');
build_microcode('/lib/firmware/intel-ucode/*', '/boot/intel-ucode.img', 'GenuineIntel.bin');
sys('bash','-c','cd /project/admin/initramfs ; find . -name ".git*" -prune -or -print | cpio -H newc -o | gzip > /boot/grub/initramfs.igz');
}

Expand Down

0 comments on commit b7a2899

Please sign in to comment.