All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] grub-mkconfig/20_linux_xen: Support multiple early initrd images
@ 2018-12-08 13:35 Peter Große
  2018-12-20 12:10 ` Daniel Kiper
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Große @ 2018-12-08 13:35 UTC (permalink / raw)
  To: grub-devel; +Cc: Peter Große

Add support for multiple, shared, early initrd images. These early
images will be loaded in the order declared, and all will be loaded
before the initrd image.

While many classes of data can be provided by early images, the
immediate use case would be for distributions to provide CPU
microcode to mitigate the Meltdown and Spectre vulnerabilities.

Xen has also support to load microcode updates provided as additional
modules by the bootloader.

There are two environment variables provided for declaring the early
images.

* GRUB_EARLY_INITRD_LINUX_STOCK is for the distribution declare
  images that are provided by the distribution or installed packages.
  If undeclared, this will default to a set of common microcode image
  names.

* GRUB_EARLY_INITRD_LINUX_CUSTOM is for user created images. User
  images will be loaded after the stock images.

These separate configurations allow the distribution and user to
declare different image sets without clobbering each other.

This also makes a minor update to ensure that UUID partition labels
stay disabled when no initrd image is found, even if early images are
present.

This is basically a copy of a698240d "grub-mkconfig/10_linux: Support
multiple early initrd images" by Matthew S. Turnbull.

Signed-off-by: Peter Große <pegro@friiks.de>
---
 util/grub.d/20_linux_xen.in | 35 +++++++++++++++++++++++++++++------
 1 file changed, 29 insertions(+), 6 deletions(-)

diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in
index d22626e30..96179ea61 100644
--- a/util/grub.d/20_linux_xen.in
+++ b/util/grub.d/20_linux_xen.in
@@ -139,9 +139,13 @@ EOF
   if test -n "${initrd}" ; then
     # TRANSLATORS: ramdisk isn't identifier. Should be translated.
     message="$(gettext_printf "Loading initial ramdisk ...")"
+    initrd_path=
+    for i in ${initrd}; do
+       initrd_path="${initrd_path} ${rel_dirname}/${i}"
+    done
     sed "s/^/$submenu_indentation/" << EOF
 	echo	'$(echo "$message" | grub_quote)'
-	${module_loader}	--nounzip   ${rel_dirname}/${initrd}
+	${module_loader}	--nounzip   $(echo $initrd_path)
 EOF
   fi
   sed "s/^/$submenu_indentation/" << EOF
@@ -228,6 +232,15 @@ while [ "x${xen_list}" != "x" ] ; do
 	    module_loader="module"
         fi
     fi
+
+    initrd_early=
+    for i in ${GRUB_EARLY_INITRD_LINUX_STOCK} \
+             ${GRUB_EARLY_INITRD_LINUX_CUSTOM}; do
+       if test -e "${xen_dirname}/${i}" ; then
+          initrd_early="${initrd_early} ${i}"
+       fi
+    done
+
     while [ "x$list" != "x" ] ; do
 	linux=`version_find_latest $list`
 	gettext_printf "Found linux image: %s\n" "$linux" >&2
@@ -238,7 +251,7 @@ while [ "x${xen_list}" != "x" ] ; do
 	alt_version=`echo $version | sed -e "s,\.old$,,g"`
 	linux_root_device_thisversion="${LINUX_ROOT_DEVICE}"
 
-	initrd=
+	initrd_real=
 	for i in "initrd.img-${version}" "initrd-${version}.img" "initrd-${version}.gz" \
 	   "initrd-${version}" "initramfs-${version}.img" \
 	   "initrd.img-${alt_version}" "initrd-${alt_version}.img" \
@@ -248,13 +261,23 @@ while [ "x${xen_list}" != "x" ] ; do
 	   "initramfs-genkernel-${GENKERNEL_ARCH}-${version}" \
 	   "initramfs-genkernel-${GENKERNEL_ARCH}-${alt_version}" ; do
 	    if test -e "${dirname}/${i}" ; then
-		initrd="$i"
+		initrd_real="$i"
 		break
 	    fi
 	done
-	if test -n "${initrd}" ; then
-	    gettext_printf "Found initrd image: %s\n" "${dirname}/${initrd}" >&2
-	else
+
+	initrd=
+	if test -n "${initrd_early}" || test -n "${initrd_real}"; then
+	    initrd="${initrd_early} ${initrd_real}"
+
+	    initrd_display=
+	    for i in ${initrd}; do
+		initrd_display="${initrd_display} ${dirname}/${i}"
+	    done
+	    gettext_printf "Found initrd image: %s\n" "$(echo $initrd_display)" >&2
+	fi
+
+	if test -z "${initrd_real}"; then
     # "UUID=" magic is parsed by initrds.  Since there's no initrd, it can't work here.
 	    if [ "x${GRUB_DEVICE_PARTUUID}" = "x" ] \
 		|| [ "x${GRUB_DISABLE_LINUX_PARTUUID}" = "xtrue" ]; then
-- 
2.19.2



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] grub-mkconfig/20_linux_xen: Support multiple early initrd images
  2018-12-08 13:35 [PATCH] grub-mkconfig/20_linux_xen: Support multiple early initrd images Peter Große
@ 2018-12-20 12:10 ` Daniel Kiper
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Kiper @ 2018-12-20 12:10 UTC (permalink / raw)
  To: Peter Große; +Cc: grub-devel

On Sat, Dec 08, 2018 at 02:35:03PM +0100, Peter Große wrote:
> Add support for multiple, shared, early initrd images. These early
> images will be loaded in the order declared, and all will be loaded
> before the initrd image.
>
> While many classes of data can be provided by early images, the
> immediate use case would be for distributions to provide CPU
> microcode to mitigate the Meltdown and Spectre vulnerabilities.
>
> Xen has also support to load microcode updates provided as additional
> modules by the bootloader.
>
> There are two environment variables provided for declaring the early
> images.
>
> * GRUB_EARLY_INITRD_LINUX_STOCK is for the distribution declare
>   images that are provided by the distribution or installed packages.
>   If undeclared, this will default to a set of common microcode image
>   names.
>
> * GRUB_EARLY_INITRD_LINUX_CUSTOM is for user created images. User
>   images will be loaded after the stock images.
>
> These separate configurations allow the distribution and user to
> declare different image sets without clobbering each other.
>
> This also makes a minor update to ensure that UUID partition labels
> stay disabled when no initrd image is found, even if early images are
> present.
>
> This is basically a copy of a698240d "grub-mkconfig/10_linux: Support
> multiple early initrd images" by Matthew S. Turnbull.
>
> Signed-off-by: Peter Große <pegro@friiks.de>

Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>

Daniel


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-12-20 12:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-08 13:35 [PATCH] grub-mkconfig/20_linux_xen: Support multiple early initrd images Peter Große
2018-12-20 12:10 ` Daniel Kiper

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.