Commit 2b698710 authored by William Johansson's avatar William Johansson
Browse files

main/grub: fix booting Xen under EFI

Need to use multiboot2 while booting Xen under EFI, and not multiboot as
is used when generating grub.cfg with grub-mkconfig.

Backport commits included in upstream Grub 2.04.

Diskless setups are not affected, as grub.cfg is generated manually by
the mkimage scipts.
parent 686960c5
Pipeline #5189 passed with stages
in 9 minutes and 8 seconds
From cb8fc4eee92e19fe2977026ba45bad6ecf68f55f Mon Sep 17 00:00:00 2001
From: Fu Wei <fu.wei@linaro.org>
Date: Sun, 14 May 2017 15:43:46 +0800
Subject: [PATCH 1/3] util/grub.d/20_linux_xen.in: Add xen_boot command support
for aarch64
This patch adds the support of xen_boot command for aarch64:
xen_hypervisor
xen_module
These two commands are only for aarch64, since it has its own protocol and
commands to boot xen hypervisor and Dom0, but not multiboot.
For other architectures, they are still using multiboot and module
commands.
Signed-off-by: Fu Wei <fu.wei@linaro.org>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
(cherry picked from commit d33045ce7ffcb7c1e4a60c14d5ca64b36e3c5abe)
---
util/grub.d/20_linux_xen.in | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in
index c48af948d..c002fc9f9 100644
--- a/util/grub.d/20_linux_xen.in
+++ b/util/grub.d/20_linux_xen.in
@@ -122,16 +122,16 @@ linux_entry ()
else
xen_rm_opts="no-real-mode edd=off"
fi
- multiboot ${rel_xen_dirname}/${xen_basename} placeholder ${xen_args} \${xen_rm_opts}
+ ${xen_loader} ${rel_xen_dirname}/${xen_basename} placeholder ${xen_args} \${xen_rm_opts}
echo '$(echo "$lmessage" | grub_quote)'
- module ${rel_dirname}/${basename} placeholder root=${linux_root_device_thisversion} ro ${args}
+ ${module_loader} ${rel_dirname}/${basename} placeholder root=${linux_root_device_thisversion} ro ${args}
EOF
if test -n "${initrd}" ; then
# TRANSLATORS: ramdisk isn't identifier. Should be translated.
message="$(gettext_printf "Loading initial ramdisk ...")"
sed "s/^/$submenu_indentation/" << EOF
echo '$(echo "$message" | grub_quote)'
- module --nounzip ${rel_dirname}/${initrd}
+ ${module_loader} --nounzip ${rel_dirname}/${initrd}
EOF
fi
sed "s/^/$submenu_indentation/" << EOF
@@ -206,6 +206,14 @@ while [ "x${xen_list}" != "x" ] ; do
if [ "x$is_top_level" != xtrue ]; then
echo " submenu '$(gettext_printf "Xen hypervisor, version %s" "${xen_version}" | grub_quote)' \$menuentry_id_option 'xen-hypervisor-$xen_version-$boot_device_id' {"
fi
+ $grub_file --is-arm64-efi $current_xen
+ if [ $? -ne 0 ]; then
+ xen_loader="multiboot"
+ module_loader="module"
+ else
+ xen_loader="xen_hypervisor"
+ module_loader="xen_module"
+ fi
while [ "x$list" != "x" ] ; do
linux=`version_find_latest $list`
gettext_printf "Found linux image: %s\n" "$linux" >&2
--
2.24.1
From 0edfe09c35ed63630e2ccba60b9965e3d7f7f518 Mon Sep 17 00:00:00 2001
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Date: Tue, 29 Aug 2017 16:40:52 -0400
Subject: [PATCH 2/3] Fix util/grub.d/20_linux_xen.in: Add xen_boot command
support for aarch64
Commit d33045ce7ffcb7c1e4a60c14d5ca64b36e3c5abe introduced
the support for this, but it does not work under x86 (as it stops
20_linux_xen from running).
The 20_linux_xen is run under a shell and any exits from within it:
(For example on x86):
+ /usr/bin/grub2-file --is-arm64-efi /boot/xen-4.9.0.gz
[root@tst063 grub]# echo $?
1
will result in 20_linux_xen exiting without continuing
and also causing grub2-mkconfig to stop processing.
As in:
[root@tst063 grub]# ./grub-mkconfig | tail
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.13.0-0.rc5.git1.1.fc27.x86_64
Found initrd image: /boot/initramfs-4.13.0-0.rc5.git1.1.fc27.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-ec082ee24aea41b9b16aca52a6d10cc2
Found initrd image: /boot/initramfs-0-rescue-ec082ee24aea41b9b16aca52a6d10cc2.img
echo 'Loading Linux 0-rescue-ec082ee24aea41b9b16aca52a6d10cc2 ...'
linux /vmlinuz-0-rescue-ec082ee24aea41b9b16aca52a6d10cc2 root=/dev/mapper/fedora_tst063-root ro single
echo 'Loading initial ramdisk ...'
initrd /initramfs-0-rescue-ec082ee24aea41b9b16aca52a6d10cc2.img
}
}
### END /usr/local/etc/grub.d/10_linux ###
### BEGIN /usr/local/etc/grub.d/20_linux_xen ###
root@tst063 grub]#
And no more.
This patch wraps the invocation of grub-file to be a in subshell
and to process the return value in a conditional. That fixes
the issue.
RH-BZ 1486002: grub2-mkconfig does not work if xen.gz is installed.
CC: Fu Wei <fu.wei@linaro.org>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
(cherry picked from commit a8e0f1adf7019238fff263111794c86f4eea79ac)
---
util/grub.d/20_linux_xen.in | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in
index c002fc9f9..083bcef5d 100644
--- a/util/grub.d/20_linux_xen.in
+++ b/util/grub.d/20_linux_xen.in
@@ -206,13 +206,12 @@ while [ "x${xen_list}" != "x" ] ; do
if [ "x$is_top_level" != xtrue ]; then
echo " submenu '$(gettext_printf "Xen hypervisor, version %s" "${xen_version}" | grub_quote)' \$menuentry_id_option 'xen-hypervisor-$xen_version-$boot_device_id' {"
fi
- $grub_file --is-arm64-efi $current_xen
- if [ $? -ne 0 ]; then
- xen_loader="multiboot"
- module_loader="module"
- else
+ if ($grub_file --is-arm64-efi $current_xen); then
xen_loader="xen_hypervisor"
module_loader="xen_module"
+ else
+ xen_loader="multiboot"
+ module_loader="module"
fi
while [ "x$list" != "x" ] ; do
linux=`version_find_latest $list`
--
2.24.1
From b4148dbeceee4a2fe4e99acdeeb86edc5e4eed01 Mon Sep 17 00:00:00 2001
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Date: Tue, 29 Aug 2017 16:40:53 -0400
Subject: [PATCH 3/3] Use grub-file to figure out whether multiboot2 should be
used for Xen.gz
The multiboot2 is much more preferable than multiboot. Especiall
if booting under EFI where multiboot does not have the functionality
to pass ImageHandler.
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
(cherry picked from commit b4d709b6ee789cdaf3fa7a80fd90c721a16f48c2)
---
util/grub.d/20_linux_xen.in | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in
index 083bcef5d..0cb0f4e49 100644
--- a/util/grub.d/20_linux_xen.in
+++ b/util/grub.d/20_linux_xen.in
@@ -210,8 +210,13 @@ while [ "x${xen_list}" != "x" ] ; do
xen_loader="xen_hypervisor"
module_loader="xen_module"
else
- xen_loader="multiboot"
- module_loader="module"
+ if ($grub_file --is-x86-multiboot2 $current_xen); then
+ xen_loader="multiboot2"
+ module_loader="module2"
+ else
+ xen_loader="multiboot"
+ module_loader="module"
+ fi
fi
while [ "x$list" != "x" ] ; do
linux=`version_find_latest $list`
--
2.24.1
......@@ -2,7 +2,7 @@
# Maintainer: Timo Teräs <timo.teras@iki.fi>
pkgname=grub
pkgver=2.02
pkgrel=19
pkgrel=20
pkgdesc="Bootloader with support for Linux, Multiboot and more"
url="https://www.gnu.org/software/grub/"
arch="all !s390x"
......@@ -66,6 +66,10 @@ source="https://ftp.gnu.org/gnu/grub/grub-$pkgver.tar.xz
0018-xen_pvh-Support-building-a-standalone-image.patch
0019-xen_pvh-Support-grub-install-for-xen_pvh.patch
0020-xen_pvh-Add-support-to-configure.patch
0001-util-grub.d-20_linux_xen.in-Add-xen_boot-command-sup.patch
0002-Fix-util-grub.d-20_linux_xen.in-Add-xen_boot-command.patch
0003-Use-grub-file-to-figure-out-whether-multiboot2-shoul.patch
"
builddir="$srcdir/grub-$pkgver"
......@@ -264,4 +268,7 @@ fe7ea6eeab330c0fdfd0b2a858acdff88c68f69d80b9abb21b4c3cd1d18f8717ab7c47729e28857c
3e78cd3cd1c70236d8e9e3a536eb2f887283b5d257f60533d22d093df76c1c3c60e490acae4b738301c87edbac2e27398fce6ddbbeb9b2f193191c76afb9bd8b 0017-xen-Use-elfnote-defines-instead-of-plain-numbers.patch
c8a16db1224c9fb4a26ef39fbd8c36bf26ff68d45d88fb4e2530369c5bccadf0208551c34c0d16e9ee4a3102d67edad26a46e7b8388222f530310762246df8ef 0018-xen_pvh-Support-building-a-standalone-image.patch
b00cb9146cadc1f48586dcab31ac4605d9591d860283000accf709a489f136bf5c8fe3351dbefe51f9e27407ca3f1ce5dd7bc2ac64ac826f593183ef5d3a9759 0019-xen_pvh-Support-grub-install-for-xen_pvh.patch
78bc31b69cde95a29b365b43898caf69238c036683a26e5448d66cd48c7a4906d2a9eff065f082c5300b72616d6e63033891fd75d59ce724759dc998d9942a37 0020-xen_pvh-Add-support-to-configure.patch"
78bc31b69cde95a29b365b43898caf69238c036683a26e5448d66cd48c7a4906d2a9eff065f082c5300b72616d6e63033891fd75d59ce724759dc998d9942a37 0020-xen_pvh-Add-support-to-configure.patch
9eb4d168824d863791040e7d288dfa2bd5314c34389adb92683b6335c5bd5426f74ec98257bcfde6ab89836ae33954ac1ad2e1caf451c2d6ab4540a4f394c985 0001-util-grub.d-20_linux_xen.in-Add-xen_boot-command-sup.patch
b0ab04fff0d998a78d5de7610544de14912dc5ac27f99d74e86df7ef59db02ad4a45620030d1ff640d7c09d1f3aecaf7506dfb21dc01377f6a1f3d5a95c2978b 0002-Fix-util-grub.d-20_linux_xen.in-Add-xen_boot-command.patch
34518e3917bd3fd8e5944fcb6d208515ff4f2ae2e74736eb451a532bc116a63232b8fed28ca91c2417e815d179d438795ccbf6735edcaed2c0760555635d595e 0003-Use-grub-file-to-figure-out-whether-multiboot2-shoul.patch"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment