diff -Nru grub2-2.04/debian/changelog grub2-2.04/debian/changelog --- grub2-2.04/debian/changelog 2020-09-08 10:24:35.000000000 +0000 +++ grub2-2.04/debian/changelog 2020-10-01 15:19:24.000000000 +0000 @@ -1,3 +1,18 @@ +grub2 (2.04-1ubuntu26.6) focal; urgency=medium + + * postinst.in, grub-multi-install: fix logic of skipping installing onto + any device, if one chose to not install bootloader on any device. LP: + #1896608 + * Do not finalize params twice on arm64. LP: #1897819 + + -- Dimitri John Ledkov Thu, 01 Oct 2020 23:19:24 +0800 + +grub2 (2.04-1ubuntu26.5) focal; urgency=medium + + * ubuntu-linuxefi-arm64.patch: Fix build on armhf (LP: #1862279) + + -- Julian Andres Klode Wed, 16 Sep 2020 13:01:19 +0200 + grub2 (2.04-1ubuntu26.4) focal; urgency=medium * grub-install: cherry-pick patch from grub-devel to make grub-install diff -Nru grub2-2.04/debian/.git-dpm grub2-2.04/debian/.git-dpm --- grub2-2.04/debian/.git-dpm 2020-09-08 10:23:01.000000000 +0000 +++ grub2-2.04/debian/.git-dpm 2020-10-01 15:12:21.000000000 +0000 @@ -1,6 +1,6 @@ # see git-dpm(1) from git-dpm package -229c7f88463e2ae9fbb891a286cba50b580f7bad -229c7f88463e2ae9fbb891a286cba50b580f7bad +67fbc0db9b2d5324861bbbca36ab718569f824d2 +67fbc0db9b2d5324861bbbca36ab718569f824d2 578bb115fbd47e1c464696f1f8d6183e5443975d 578bb115fbd47e1c464696f1f8d6183e5443975d grub2_2.04.orig.tar.xz diff -Nru grub2-2.04/debian/grub-multi-install grub2-2.04/debian/grub-multi-install --- grub2-2.04/debian/grub-multi-install 2020-09-08 10:23:00.000000000 +0000 +++ grub2-2.04/debian/grub-multi-install 2020-10-01 15:12:19.000000000 +0000 @@ -402,7 +402,14 @@ db_fset grub-efi/install_devices_empty seen false fi else - exit 1 # noninteractive + # if question was seen we are done + # Otherwise, abort + db_fget grub-efi/install_devices_empty seen + if [ "$RET" = true ]; then + break + else + exit 1 + fi fi else break diff -Nru grub2-2.04/debian/patches/series grub2-2.04/debian/patches/series --- grub2-2.04/debian/patches/series 2020-09-08 10:23:01.000000000 +0000 +++ grub2-2.04/debian/patches/series 2020-10-01 15:12:19.000000000 +0000 @@ -107,3 +107,4 @@ ubuntu-dont-verify-loopback-images.patch ubuntu-recovery-dis_ucode_ldr.patch grub-install-backup-and-restore.patch +ubuntu-linuxefi-arm64.patch diff -Nru grub2-2.04/debian/patches/ubuntu-linuxefi-arm64.patch grub2-2.04/debian/patches/ubuntu-linuxefi-arm64.patch --- grub2-2.04/debian/patches/ubuntu-linuxefi-arm64.patch 1970-01-01 00:00:00.000000000 +0000 +++ grub2-2.04/debian/patches/ubuntu-linuxefi-arm64.patch 2020-10-01 15:12:21.000000000 +0000 @@ -0,0 +1,185 @@ +From 67fbc0db9b2d5324861bbbca36ab718569f824d2 Mon Sep 17 00:00:00 2001 +From: Julian Andres Klode +Date: Fri, 11 Sep 2020 11:28:08 +0200 +Subject: Cherry-pick back parts of "Load arm with SB enabled." + +These parts got lost in our 2.04 rebase, let's add them back. + +Pick (grub_efi_physical_address_t)(grub_efi_uintn_t) cast from +fedora-34 instead, it seems to cause compilation error on armhf +to not do the (grub_efi_uintn_t) cast first. + +Bug-Ubuntu: https://bugs.launchpad.net/bugs/1862279 +Origin: vendor, https://github.com/rhboot/grub2/commit/2786ab864cf00c15123320671f653e9a36ba12b4 +Patch-Name: ubuntu-linuxefi-arm64.patch +--- + grub-core/loader/arm64/linux.c | 106 +++++++++++++++++---------------- + 1 file changed, 56 insertions(+), 50 deletions(-) + +diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c +index 3f5496fc55..130e9c09b4 100644 +--- a/grub-core/loader/arm64/linux.c ++++ b/grub-core/loader/arm64/linux.c +@@ -43,6 +43,8 @@ static int loaded; + + static void *kernel_addr; + static grub_uint64_t kernel_size; ++static grub_uint32_t handover_offset; ++ + + static char *linux_args; + static grub_uint32_t cmdline_size; +@@ -76,7 +78,8 @@ grub_arch_efi_linux_check_image (struct linux_arch_kernel_header * lh) + static grub_err_t + finalize_params_linux (void) + { +- int node, retval; ++ grub_efi_loaded_image_t *loaded_image = NULL; ++ int node, retval, len; + + void *fdt; + +@@ -111,6 +114,27 @@ finalize_params_linux (void) + if (grub_fdt_install() != GRUB_ERR_NONE) + goto failure; + ++ ++ grub_dprintf ("linux", "Installed/updated FDT configuration table @ %p\n", ++ fdt); ++ ++ /* Convert command line to UCS-2 */ ++ loaded_image = grub_efi_get_loaded_image (grub_efi_image_handle); ++ if (!loaded_image) ++ goto failure; ++ ++ loaded_image->load_options_size = len = ++ (grub_strlen (linux_args) + 1) * sizeof (grub_efi_char16_t); ++ loaded_image->load_options = ++ grub_efi_allocate_any_pages (GRUB_EFI_BYTES_TO_PAGES (loaded_image->load_options_size)); ++ if (!loaded_image->load_options) ++ return grub_error(GRUB_ERR_BAD_OS, "failed to create kernel parameters"); ++ ++ loaded_image->load_options_size = ++ 2 * grub_utf8_to_utf16 (loaded_image->load_options, len, ++ (grub_uint8_t *) linux_args, len, NULL); ++ ++ + return GRUB_ERR_NONE; + + failure: +@@ -118,70 +142,48 @@ failure: + return grub_error(GRUB_ERR_BAD_OS, "failed to install/update FDT"); + } + ++static void ++free_params (void) ++{ ++ grub_efi_loaded_image_t *loaded_image = NULL; ++ loaded_image = grub_efi_get_loaded_image (grub_efi_image_handle); ++ if (loaded_image) ++ { ++ if (loaded_image->load_options) ++ grub_efi_free_pages ((grub_efi_physical_address_t)(grub_efi_uintn_t) ++ loaded_image->load_options, ++ GRUB_EFI_BYTES_TO_PAGES (loaded_image->load_options_size)); ++ loaded_image->load_options = NULL; ++ loaded_image->load_options_size = 0; ++ } ++} ++ + grub_err_t + grub_arch_efi_linux_boot_image (grub_addr_t addr, grub_size_t size, char *args) + { +- grub_efi_memory_mapped_device_path_t *mempath; +- grub_efi_handle_t image_handle; +- grub_efi_boot_services_t *b; +- grub_efi_status_t status; +- grub_efi_loaded_image_t *loaded_image; +- int len; +- +- mempath = grub_malloc (2 * sizeof (grub_efi_memory_mapped_device_path_t)); +- if (!mempath) +- return grub_errno; +- +- mempath[0].header.type = GRUB_EFI_HARDWARE_DEVICE_PATH_TYPE; +- mempath[0].header.subtype = GRUB_EFI_MEMORY_MAPPED_DEVICE_PATH_SUBTYPE; +- mempath[0].header.length = grub_cpu_to_le16_compile_time (sizeof (*mempath)); +- mempath[0].memory_type = GRUB_EFI_LOADER_DATA; +- mempath[0].start_address = addr; +- mempath[0].end_address = addr + size; ++ grub_err_t retval; + +- mempath[1].header.type = GRUB_EFI_END_DEVICE_PATH_TYPE; +- mempath[1].header.subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE; +- mempath[1].header.length = sizeof (grub_efi_device_path_t); +- +- b = grub_efi_system_table->boot_services; +- status = b->load_image (0, grub_efi_image_handle, +- (grub_efi_device_path_t *) mempath, +- (void *) addr, size, &image_handle); +- if (status != GRUB_EFI_SUCCESS) +- return grub_error (GRUB_ERR_BAD_OS, "cannot load image"); ++ retval = finalize_params_linux (); ++ if (retval != GRUB_ERR_NONE) ++ return grub_errno; + + grub_dprintf ("linux", "linux command line: '%s'\n", args); + +- /* Convert command line to UCS-2 */ +- loaded_image = grub_efi_get_loaded_image (image_handle); +- loaded_image->load_options_size = len = +- (grub_strlen (args) + 1) * sizeof (grub_efi_char16_t); +- loaded_image->load_options = +- grub_efi_allocate_any_pages (GRUB_EFI_BYTES_TO_PAGES (loaded_image->load_options_size)); +- if (!loaded_image->load_options) +- return grub_errno; +- +- loaded_image->load_options_size = +- 2 * grub_utf8_to_utf16 (loaded_image->load_options, len, +- (grub_uint8_t *) args, len, NULL); ++ (void) addr; ++ (void) size; + +- grub_dprintf ("linux", "starting image %p\n", image_handle); +- status = b->start_image (image_handle, 0, NULL); + +- /* When successful, not reached */ +- b->unload_image (image_handle); +- grub_efi_free_pages ((grub_addr_t) loaded_image->load_options, +- GRUB_EFI_BYTES_TO_PAGES (loaded_image->load_options_size)); ++ retval = grub_efi_linux_boot ((char *)kernel_addr, handover_offset, ++ kernel_addr); + +- return grub_errno; ++ /* Never reached... */ ++ free_params(); ++ return retval; + } + + static grub_err_t + grub_linux_boot (void) + { +- if (finalize_params_linux () != GRUB_ERR_NONE) +- return grub_errno; +- + return (grub_arch_efi_linux_boot_image((grub_addr_t)kernel_addr, + kernel_size, linux_args)); + } +@@ -297,6 +299,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + { + grub_file_t file = 0; + struct linux_arch_kernel_header lh; ++ struct grub_arm64_linux_pe_header *pe; + grub_err_t err; + int rc; + +@@ -354,6 +357,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), + } + } + ++ pe = (void *)((unsigned long)kernel_addr + lh.hdr_offset); ++ handover_offset = pe->opt.entry_addr; ++ + cmdline_size = grub_loader_cmdline_size (argc, argv) + sizeof (LINUX_IMAGE); + linux_args = grub_malloc (cmdline_size); + if (!linux_args) diff -Nru grub2-2.04/debian/postinst.in grub2-2.04/debian/postinst.in --- grub2-2.04/debian/postinst.in 2020-09-08 10:23:00.000000000 +0000 +++ grub2-2.04/debian/postinst.in 2020-10-01 15:12:19.000000000 +0000 @@ -685,7 +685,14 @@ db_fset grub-pc/install_devices_empty seen false fi else - exit 1 # noninteractive + # if question was seen we are done + # Otherwise, abort + db_fget grub-pc/install_devices_empty seen + if [ "$RET" = true ]; then + break + else + exit 1 + fi fi else break