Author: pierre Date: Thu Jan 9 08:18:14 2020 New Revision: 22557 Log: Add early loading of microcode to the initramfs Fix a bug in mkinitramfs, leading to a "cp" error
Modified: trunk/BOOK/general.ent trunk/BOOK/introduction/welcome/changelog.xml trunk/BOOK/postlfs/config/firmware.xml trunk/BOOK/postlfs/filesystems/initramfs.xml Modified: trunk/BOOK/general.ent ============================================================================== --- trunk/BOOK/general.ent Wed Jan 8 18:25:35 2020 (r22556) +++ trunk/BOOK/general.ent Thu Jan 9 08:18:14 2020 (r22557) @@ -1,12 +1,12 @@ <!-- $LastChangedBy$ $Date$ --> -<!ENTITY day "08"> <!-- Always 2 digits --> +<!ENTITY day "09"> <!-- Always 2 digits --> <!ENTITY month "01"> <!-- Always 2 digits --> <!ENTITY year "2020"> <!ENTITY copyrightdate "2001-&year;"> <!ENTITY copyholder "The BLFS Development Team"> <!ENTITY version "&year;-&month;-&day;"> -<!ENTITY releasedate "January 8th, &year;"> +<!ENTITY releasedate "January 9th, &year;"> <!ENTITY pubdate "&year;-&month;-&day;"> <!-- metadata req. by TLDP --> <!ENTITY blfs-version "svn"> <!-- svn|[release #] --> <!ENTITY lfs-version "development"> <!-- x.y|development --> Modified: trunk/BOOK/introduction/welcome/changelog.xml ============================================================================== --- trunk/BOOK/introduction/welcome/changelog.xml Wed Jan 8 18:25:35 2020 (r22556) +++ trunk/BOOK/introduction/welcome/changelog.xml Thu Jan 9 08:18:14 2020 (r22557) @@ -42,6 +42,15 @@ </listitem> --> <listitem> + <para>January 9th, 2020</para> + <itemizedlist> + <listitem> + <para>[pierre] - Add early microcode loading to the initramfs.</para> + </listitem> + </itemizedlist> + </listitem> + + <listitem> <para>January 8th, 2020</para> <itemizedlist> <listitem> @@ -99,7 +108,7 @@ </listitem> <listitem> <para>[bdubbs] - Update to seahorse-3.34.1. Fixes - <ulink url="&blfs-ticket-root;12985">#12985</ulink>.</para> + <ulink url="&blfs-ticket-root;12986">#12986</ulink>.</para> </listitem> <listitem> <para>[bdubbs] - Update to gnome-shell-3.34.3. Fixes Modified: trunk/BOOK/postlfs/config/firmware.xml ============================================================================== --- trunk/BOOK/postlfs/config/firmware.xml Wed Jan 8 18:25:35 2020 (r22556) +++ trunk/BOOK/postlfs/config/firmware.xml Thu Jan 9 08:18:14 2020 (r22557) @@ -308,10 +308,12 @@ <screen><userinput>initrd /boot/microcode.img</userinput></screen> <para>If you are already booting with an initrd (see <xref - linkend="initramfs"/>) you must specify the microcode initrd first, using - a line such as <userinput>initrd /microcode.img - /other-initrd.img</userinput> (adapt that as above if /boot is not a - separate mountpoint).</para> + linkend="initramfs"/>), you should run <command>mkinitramfs</command> + again after putting the appropriate blob or container into <filename + class="directory">/lib/firmware</filename> as explained above. + Alternatively, you can have both initrd on the same line, such as + <userinput>initrd /microcode.img /other-initrd.img</userinput> (adapt + that as above if /boot is not a separate mountpoint).</para> <para>You can now reboot with the added initrd, and then use the same command to check that the early load worked.</para> Modified: trunk/BOOK/postlfs/filesystems/initramfs.xml ============================================================================== --- trunk/BOOK/postlfs/filesystems/initramfs.xml Wed Jan 8 18:25:35 2020 (r22556) +++ trunk/BOOK/postlfs/filesystems/initramfs.xml Thu Jan 9 08:18:14 2020 (r22557) @@ -68,7 +68,7 @@ file=$(type -p $1) fi - if [ -n $file ] ; then + if [ -n "$file" ] ; then cp $file $WDIR/$2 else echo "Missing required file: $1 for directory $2" @@ -208,8 +208,12 @@ # Install libraries sort $unsorted | uniq | while read library ; do - if [ "$library" == "linux-vdso.so.1" ] || - [ "$library" == "linux-gate.so.1" ]; then +# linux-vdso and linux-gate are pseudo libraries and do not correspond to a file +# libsystemd-shared is in /lib/systemd, so it is not found by copy, and +# it is copied below anyway + if [[ "$library" == linux-vdso.so.1 ]] || + [[ "$library" == linux-gate.so.1 ]] || + [[ "$library" == libsystemd-shared* ]]; then continue fi @@ -243,7 +247,31 @@ ( cd $WDIR ; find . | cpio -o -H newc --quiet | gzip -9 ) > $INITRAMFS_FILE -# Remove the temporary directory and file +# Prepare early loading of microcode if available +if ls /lib/firmware/intel-ucode/* >/dev/null 2>&1 || + ls /lib/firmware/amd-ucode/* >/dev/null 2>&1; then + +# first empty WDIR to reuse it + rm -r $WDIR/* + + DSTDIR=$WDIR/kernel/x86/microcode + mkdir -p $DSTDIR + + if [ -d /lib/firmware/amd-ucode ]; then + cat /lib/firmware/amd-ucode/microcode_amd*.bin > $DSTDIR/AuthenticAMD.bin + fi + + if [ -d /lib/firmware/intel-ucode ]; then + cat /lib/firmware/intel-ucode/* > $DSTDIR/GenuineIntel.bin + fi + + ( cd $WDIR; find . | cpio -o -H newc --quiet ) > microcode.img + cat microcode.img $INITRAMFS_FILE > tmpfile + mv tmpfile $INITRAMFS_FILE + rm microcode.img +fi + +# Remove the temporary directories and files rm -rf $WDIR $unsorted printf "done.\n" </literal> @@ -398,7 +426,6 @@ <xref role="runtime" linkend="lvm2"/> and/or <xref role="runtime" linkend="mdadm"/> must be installed before generating the initramfs, if the system partition uses them. - </para> <para condition="html" role="usernotes">User Notes: @@ -420,6 +447,12 @@ the specific kernel specified. The output file will be placed in the current directory.</para> + <para>If early loading of microcode is needed (see <xref + linkend="cpu-microcode"/>), you can install the appropriate blob or + container in <filename class="directory">/lib/firmware</filename>. + It will be automatically added to the initrd when running + <command>mkinitramfs</command>.</para> + <para>After generating the initrd, copy it to the <filename class='directory'>/boot</filename> directory.</para> -- http://lists.linuxfromscratch.org/listinfo/blfs-book FAQ: http://www.linuxfromscratch.org/blfs/faq.html Unsubscribe: See the above information page