- Add mkinitrd script to add AMD microcode to initrd.

This is needed because microcode driver is built in or gets loaded
  automatically via udev early. Therefore the microcode has to be available
  in initrd already.
  This must not be mixed up with early micorcode loading. This feature will
  not be implemented via mkinitrd. Dracut is doing early microcode loading.
- bnc#847158
- mkinitrd scripts:
    - mkinitrd_setup-amd_microcode.sh
      Adding microcode to the initrd
    - mkinitrd_boot-amd_microcode.sh
      Triggering the reload at boot
  on machines with AMD CPUs

OBS-URL: https://build.opensuse.org/package/show/Kernel:HEAD/kernel-firmware?expand=0&rev=74
This commit is contained in:
Thomas Renninger 2013-12-11 11:52:20 +00:00 committed by Git OBS Bridge
parent 712e136c9c
commit f1685d8cbd
4 changed files with 83 additions and 5 deletions

View File

@ -1,8 +1,24 @@
-------------------------------------------------------------------
Tue Dec 10 15:46:02 UTC 2013 - trenn@suse.de
- Add mkinitrd script to add AMD microcode to initrd.
This is needed because microcode driver is built in or gets loaded
automatically via udev early. Therefore the microcode has to be available
in initrd already.
This must not be mixed up with early micorcode loading. This feature will
not be implemented via mkinitrd. Dracut is doing early microcode loading.
- bnc#847158
- mkinitrd scripts:
- mkinitrd_setup-amd_microcode.sh
Adding microcode to the initrd
- mkinitrd_boot-amd_microcode.sh
Triggering the reload at boot
-------------------------------------------------------------------
Mon Dec 9 14:19:50 UTC 2013 - trenn@suse.de
- Correct Supplements string so that the package gets correctly installed
on machines with Intel CPUs
on machines with AMD CPUs
bnc#847158
-------------------------------------------------------------------

View File

@ -31,6 +31,8 @@ Source0: linux-firmware-%{version}.tar.bz2
Source1: firmware.sh
Source3: iwlwifi-4965-1.ucode
Source4: carl9170-1.fw
Source5: mkinitrd_setup-amd_microcode.sh
Source6: mkinitrd_boot-amd_microcode.sh
%define __find_supplements bash %_sourcedir/firmware.sh --find-supplements
%define __ksyms_supplements bash %_sourcedir/firmware.sh --cache %{_builddir}/%{?buildsubdir}/find_supplements.cache --find-supplements
@ -88,6 +90,8 @@ cp -v %{S:4} carl9170-1.fw
# nothing to do
%install
install -D -m 0755 %{SOURCE5} %{buildroot}/lib/mkinitrd/scripts/setup-amd_microcode.sh
install -D -m 0755 %{SOURCE6} %{buildroot}/lib/mkinitrd/scripts/boot-amd_microcode.sh
mkdir -p %{buildroot}/lib/firmware
cp -avf * %{buildroot}/lib/firmware
rm -f %{buildroot}/lib/firmware/WHENCE
@ -103,16 +107,30 @@ rm -rf %{buildroot}/lib/firmware/carl9170fw
%clean
rm -rf %{buildroot}
%post -n ucode-amd
[ -x /sbin/mkinitrd_setup ] && mkinitrd_setup
if [ -e /var/lib/no_initrd_recreation_by_suspend ]; then
echo "Skipping recreation of existing initial ramdisks, due"
echo "to presence of /var/lib/no_initrd_recreation_by_suspend"
elif [ -x /sbin/mkinitrd ]; then
/sbin/mkinitrd
fi
%files
%defattr(0644,root,root,0755)
%doc WHENCE README GPL-3 LICENCE.*
%exclude /lib/firmware/amd-ucode/microcode_amd.bin
%exclude /lib/firmware/amd-ucode/microcode_amd_fam15h.bin
%exclude /lib/firmware/amd-ucode/microcode_amd.bin*
%exclude /lib/firmware/amd-ucode/microcode_amd_fam15h.bin*
/lib/firmware/*
%files -n ucode-amd
%defattr(0644,root,root,0755)
/lib/firmware/amd-ucode/microcode_amd.bin
/lib/firmware/amd-ucode/microcode_amd_fam15h.bin
/lib/firmware/amd-ucode/microcode_amd.bin*
/lib/firmware/amd-ucode/microcode_amd_fam15h.bin*
/lib/firmware/amd-ucode/
%dir /lib/mkinitrd
%dir /lib/mkinitrd/scripts
%attr(0755,root,root) /lib/mkinitrd/scripts/setup-amd_microcode.sh
%attr(0755,root,root) /lib/mkinitrd/scripts/boot-amd_microcode.sh
%changelog

View File

@ -0,0 +1,8 @@
#!/bin/bash
#%stage: boot
#%depends: udev
if [ -w /sys/devices/system/cpu/microcode/reload ];then
echo 1 >/sys/devices/system/cpu/microcode/reload
fi

View File

@ -0,0 +1,36 @@
#/bin/bash
#%stage: boot
#
# Adds AMD microcode to the initrd
#
# If processor(s) are upgraded on the system, mkinitrd has to be re-called
# manually to include a possible other needed firmware to the initrd
#
if grep -q -i AuthenticAMD /proc/cpuinfo; then
echo -n "Microcode: "
if [ ! -e /lib/firmware/amd-ucode ];then
echo "AMD microcode not found, amd-ucode package not installed?"
return 0
fi
fam=`head /proc/cpuinfo |sed -n -e 's/cpu family.*: \([0-9]\+\)/\1/p'`
# Only try to update when family >= 16 (0x10, fam 10h)
if [ $fam -ge 16 >& /dev/null ];then
# Family 0x15 firmware is named: microcode_amd_famXXh.bin"
if [ $fam -lt 21 >& /dev/null ];then
file=microcode_amd.bin
else
file=`printf "microcode_amd_fam%xh.bin" $fam`
fi
if [ -e /lib/firmware/amd-ucode ];then
echo "Adding AMD microcode $file"
mkdir -p $tmp_mnt/lib/firmware/amd-ucode
cp /lib/firmware/amd-ucode/"$file"* $tmp_mnt/lib/firmware/amd-ucode
else
echo "No AMD microcode found, amd-ucode package not installed?"
fi
else
printf "AMD CPU family: 0x%x does not support microcode updates" $fam
fi
fi