From 6e604848b068069c74bcecfeb9000ec24be33970 Mon Sep 17 00:00:00 2001 From: Konrad Rzeszutek Wilk Date: Oct 06 2017 20:56:48 +0000 Subject: Fix grub2-mkconfig does not work if xen.gz is installed. Two bugs in one: - The recent ARM work on detecting if the payload is multiboot2 or not would cause the 20_linux shell script to exit (prematurily) instead of returning 0 or 1 on x86. Hence on x86 we would never include xen.gz anymore. - Added also support to detect multiboot2 to use that (which can do EFI handoff). Fixes rhbz#1486002 Signed-off-by: Konrad Rzeszutek Wilk --- diff --git a/0195-Fix-util-grub.d-20_linux_xen.in-Add-xen_boot-command.patch b/0195-Fix-util-grub.d-20_linux_xen.in-Add-xen_boot-command.patch new file mode 100644 index 0000000..bcdb06a --- /dev/null +++ b/0195-Fix-util-grub.d-20_linux_xen.in-Add-xen_boot-command.patch @@ -0,0 +1,62 @@ +From 496e3469481ea95513d826c1ea5c8ad9012e05f5 Mon Sep 17 00:00:00 2001 +From: Konrad Rzeszutek Wilk +Date: Mon, 28 Aug 2017 13:51:14 -0400 +Subject: [PATCH 1/2] 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 exciting without continuing +and also causing grub2-mkconfig to stop processing. + +As in: + +[root@tst063 ~]# + +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 +Signed-off-by: Konrad Rzeszutek Wilk +--- + 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 c002fc9..083bcef 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.1.4 + diff --git a/0196-Use-grub-file-to-figure-out-whether-multiboot2-shoul.patch b/0196-Use-grub-file-to-figure-out-whether-multiboot2-shoul.patch new file mode 100644 index 0000000..979650b --- /dev/null +++ b/0196-Use-grub-file-to-figure-out-whether-multiboot2-shoul.patch @@ -0,0 +1,35 @@ +From 77c198905ca5218db9cb78569d5a53e2dbd0a8eb Mon Sep 17 00:00:00 2001 +From: Konrad Rzeszutek Wilk +Date: Mon, 28 Aug 2017 13:59:12 -0400 +Subject: [PATCH 2/2] 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 +--- +v2: Rebase on top of d33045ce7ffcb7c1e4a60c14d5ca64b36e3c5abe +--- + util/grub.d/20_linux_xen.in | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in +index 083bcef..29e015b 100644 +--- a/util/grub.d/20_linux_xen.in ++++ b/util/grub.d/20_linux_xen.in +@@ -212,6 +212,10 @@ while [ "x${xen_list}" != "x" ] ; do + else + xen_loader="multiboot" + module_loader="module" ++ if ($grub_file --is-x86-multiboot2 $current_xen); then ++ xen_loader="multiboot2" ++ module_loader="module2" ++ fi + fi + while [ "x$list" != "x" ] ; do + linux=`version_find_latest $list` +-- +2.1.4 + diff --git a/grub.macros b/grub.macros index 44c6886..2e42f32 100644 --- a/grub.macros +++ b/grub.macros @@ -87,7 +87,7 @@ ### fixme %ifarch aarch64 %{arm} -%global efi_modules " http linux " +%global efi_modules " http linux xen_boot" %else %global efi_modules " backtrace http linuxefi usb usbserial_common usbserial_pl2303 usbserial_ftdi usbserial_usbdebug " %endif @@ -330,7 +330,7 @@ GRUB_MODULES=" all_video boot btrfs cat chain configfile echo \\\ password_pbkdf2 png reboot \\\ search search_fs_uuid search_fs_file \\\ search_label serial sleep syslinuxcfg test tftp \\\ - video xfs" \ + video xfs multiboot multiboot2" \ GRUB_MODULES+=%{efi_modules} \ %{expand:%%{mkimage %{1} %{2} %{3} %{4}}} \ %{nil} diff --git a/grub.patches b/grub.patches index aac5386..cd59717 100644 --- a/grub.patches +++ b/grub.patches @@ -192,3 +192,5 @@ Patch0191: 0191-Clean-up-some-errors-in-the-linuxefi-loader.patch Patch0192: 0192-editenv-handle-relative-symlinks.patch Patch0193: 0193-Make-libgrub.pp-depend-on-config-util.h.patch Patch0194: 0194-Don-t-guess-boot-efi-as-HFS-on-ppc-machines-in-grub-.patch +Patch0195: 0195-Fix-util-grub.d-20_linux_xen.in-Add-xen_boot-command.patch +Patch0196: 0196-Use-grub-file-to-figure-out-whether-multiboot2-shoul.patch diff --git a/grub2.spec b/grub2.spec index 23ac5a9..1fac3ef 100644 --- a/grub2.spec +++ b/grub2.spec @@ -7,7 +7,7 @@ Name: grub2 Epoch: 1 Version: 2.02 -Release: 18%{?dist} +Release: 19%{?dist} Summary: Bootloader with support for Linux, Multiboot and more Group: System Environment/Base License: GPLv3+ @@ -454,6 +454,11 @@ fi %endif %changelog +* Fri Oct 6 2017 Konrad Rzeszutek Wilk - 2.02-19 +- Fix util-grub.d-20_linux_xen breaking x86 multiboot2 +- Make util-grub.d-20_linux_xen work on x86 (EFI and non-efi) + Resolves: rhbz#1486002 + * Wed Sep 20 2017 Peter Jones - 2.02-18 - Make grub2-efi-aa64 provide grub2 Resolves: rhbz#1491045